changeset 0:74212992fb08

Initial revision
author Sam Lantinga <slouken@lokigames.com>
date Thu, 26 Apr 2001 16:45:43 +0000
parents
children cf2af46e9e2a
files .cvsignore BUGS COPYING CREDITS CWprojects.sea.bin INSTALL MPWmake.sea.bin Makefile.am README README-SDL.txt README.CVS README.MacOS README.MacOSX README.Win32 README.WinCE SDL.spec.in TODO VisualC.html VisualC.zip WhatsNew acinclude.m4 autogen.sh config.guess config.sub configure.in docs.html docs/.cvsignore docs/Makefile.am docs/html/.cvsignore docs/html/Makefile.am docs/html/audio.html docs/html/cdrom.html docs/html/event.html docs/html/eventfunctions.html docs/html/eventstructures.html docs/html/general.html docs/html/guide.html docs/html/guideaboutsdldoc.html docs/html/guideaudioexamples.html docs/html/guidebasicsinit.html docs/html/guidecdromexamples.html docs/html/guidecredits.html docs/html/guideeventexamples.html docs/html/guideexamples.html docs/html/guideinput.html docs/html/guideinputkeyboard.html docs/html/guidepreface.html docs/html/guidethebasics.html docs/html/guidetimeexamples.html docs/html/guidevideo.html docs/html/guidevideoexamples.html docs/html/index.html docs/html/joystick.html docs/html/reference.html docs/html/sdlactiveevent.html docs/html/sdladdtimer.html docs/html/sdlaudiocvt.html docs/html/sdlaudiospec.html docs/html/sdlblitsurface.html docs/html/sdlbuildaudiocvt.html docs/html/sdlcd.html docs/html/sdlcdclose.html docs/html/sdlcdeject.html docs/html/sdlcdname.html docs/html/sdlcdnumdrives.html docs/html/sdlcdopen.html docs/html/sdlcdpause.html docs/html/sdlcdplay.html docs/html/sdlcdplaytracks.html docs/html/sdlcdresume.html docs/html/sdlcdstatus.html docs/html/sdlcdstop.html docs/html/sdlcdtrack.html docs/html/sdlcloseaudio.html docs/html/sdlcolor.html docs/html/sdlcondbroadcast.html docs/html/sdlcondsignal.html docs/html/sdlcondwait.html docs/html/sdlcondwaittimeout.html docs/html/sdlconvertaudio.html docs/html/sdlconvertsurface.html docs/html/sdlcreatecond.html docs/html/sdlcreatecursor.html docs/html/sdlcreatemutex.html docs/html/sdlcreatergbsurface.html docs/html/sdlcreatergbsurfacefrom.html docs/html/sdlcreatesemaphore.html docs/html/sdlcreatethread.html docs/html/sdlcreateyuvoverlay.html docs/html/sdldelay.html docs/html/sdldestroycond.html docs/html/sdldestroymutex.html docs/html/sdldestroysemaphore.html docs/html/sdldisplayformat.html docs/html/sdldisplayformatalpha.html docs/html/sdldisplayyuvoverlay.html docs/html/sdlenablekeyrepeat.html docs/html/sdlenableunicode.html docs/html/sdlevent.html docs/html/sdleventstate.html docs/html/sdlfillrect.html docs/html/sdlflip.html docs/html/sdlfreecursor.html docs/html/sdlfreesurface.html docs/html/sdlfreewav.html docs/html/sdlfreeyuvoverlay.html docs/html/sdlgetappstate.html docs/html/sdlgetaudiostatus.html docs/html/sdlgetcliprect.html docs/html/sdlgetcursor.html docs/html/sdlgeteventfilter.html docs/html/sdlgetgammaramp.html docs/html/sdlgetkeyname.html docs/html/sdlgetkeystate.html docs/html/sdlgetmodstate.html docs/html/sdlgetmousestate.html docs/html/sdlgetrelativemousestate.html docs/html/sdlgetrgb.html docs/html/sdlgetrgba.html docs/html/sdlgetthreadid.html docs/html/sdlgetticks.html docs/html/sdlgetvideoinfo.html docs/html/sdlgetvideosurface.html docs/html/sdlglattr.html docs/html/sdlglgetattribute.html docs/html/sdlglgetprocaddress.html docs/html/sdlglloadlibrary.html docs/html/sdlglsetattribute.html docs/html/sdlglswapbuffers.html docs/html/sdlinit.html docs/html/sdlinitsubsystem.html docs/html/sdljoyaxisevent.html docs/html/sdljoyballevent.html docs/html/sdljoybuttonevent.html docs/html/sdljoyhatevent.html docs/html/sdljoystickclose.html docs/html/sdljoystickeventstate.html docs/html/sdljoystickgetaxis.html docs/html/sdljoystickgetball.html docs/html/sdljoystickgetbutton.html docs/html/sdljoystickgethat.html docs/html/sdljoystickindex.html docs/html/sdljoystickname.html docs/html/sdljoysticknumaxes.html docs/html/sdljoysticknumballs.html docs/html/sdljoysticknumbuttons.html docs/html/sdljoysticknumhats.html docs/html/sdljoystickopen.html docs/html/sdljoystickopened.html docs/html/sdljoystickupdate.html docs/html/sdlkey.html docs/html/sdlkeyboardevent.html docs/html/sdlkeysym.html docs/html/sdlkillthread.html docs/html/sdllistmodes.html docs/html/sdlloadbmp.html docs/html/sdlloadwav.html docs/html/sdllockaudio.html docs/html/sdllocksurface.html docs/html/sdllockyuvoverlay.html docs/html/sdlmaprgb.html docs/html/sdlmaprgba.html docs/html/sdlmixaudio.html docs/html/sdlmousebuttonevent.html docs/html/sdlmousemotionevent.html docs/html/sdlmutexp.html docs/html/sdlmutexv.html docs/html/sdlnumjoysticks.html docs/html/sdlopenaudio.html docs/html/sdloverlay.html docs/html/sdlpalette.html docs/html/sdlpauseaudio.html docs/html/sdlpeepevents.html docs/html/sdlpixelformat.html docs/html/sdlpollevent.html docs/html/sdlpumpevents.html docs/html/sdlpushevent.html docs/html/sdlquit.html docs/html/sdlquitevent.html docs/html/sdlquitsubsystem.html docs/html/sdlrect.html docs/html/sdlremovetimer.html docs/html/sdlresizeevent.html docs/html/sdlsavebmp.html docs/html/sdlsempost.html docs/html/sdlsemtrywait.html docs/html/sdlsemvalue.html docs/html/sdlsemwait.html docs/html/sdlsemwaittimeout.html docs/html/sdlsetalpha.html docs/html/sdlsetcliprect.html docs/html/sdlsetcolorkey.html docs/html/sdlsetcolors.html docs/html/sdlsetcursor.html docs/html/sdlseteventfilter.html docs/html/sdlsetgamma.html docs/html/sdlsetgammaramp.html docs/html/sdlsetmodstate.html docs/html/sdlsetpalette.html docs/html/sdlsettimer.html docs/html/sdlsetvideomode.html docs/html/sdlshowcursor.html docs/html/sdlsurface.html docs/html/sdlsyswmevent.html docs/html/sdlthreadid.html docs/html/sdlunlockaudio.html docs/html/sdlunlocksurface.html docs/html/sdlunlockyuvoverlay.html docs/html/sdlupdaterect.html docs/html/sdlupdaterects.html docs/html/sdluserevent.html docs/html/sdlvideodrivername.html docs/html/sdlvideoinfo.html docs/html/sdlvideomodeok.html docs/html/sdlwaitevent.html docs/html/sdlwaitthread.html docs/html/sdlwarpmouse.html docs/html/sdlwasinit.html docs/html/sdlwmgetcaption.html docs/html/sdlwmgrabinput.html docs/html/sdlwmiconifywindow.html docs/html/sdlwmsetcaption.html docs/html/sdlwmseticon.html docs/html/sdlwmtogglefullscreen.html docs/html/thread.html docs/html/time.html docs/html/video.html docs/html/wm.html docs/images/rainbow.gif docs/index.html docs/man3/.cvsignore docs/man3/Makefile.am docs/man3/SDLKey.3 docs/man3/SDL_ActiveEvent.3 docs/man3/SDL_AddTimer.3 docs/man3/SDL_AudioCVT.3 docs/man3/SDL_AudioSpec.3 docs/man3/SDL_BlitSurface.3 docs/man3/SDL_BuildAudioCVT.3 docs/man3/SDL_CD.3 docs/man3/SDL_CDClose.3 docs/man3/SDL_CDEject.3 docs/man3/SDL_CDName.3 docs/man3/SDL_CDNumDrives.3 docs/man3/SDL_CDOpen.3 docs/man3/SDL_CDPause.3 docs/man3/SDL_CDPlay.3 docs/man3/SDL_CDPlayTracks.3 docs/man3/SDL_CDResume.3 docs/man3/SDL_CDStatus.3 docs/man3/SDL_CDStop.3 docs/man3/SDL_CDtrack.3 docs/man3/SDL_CloseAudio.3 docs/man3/SDL_Color.3 docs/man3/SDL_CondBroadcast.3 docs/man3/SDL_CondSignal.3 docs/man3/SDL_CondWait.3 docs/man3/SDL_CondWaitTimeout.3 docs/man3/SDL_ConvertAudio.3 docs/man3/SDL_ConvertSurface.3 docs/man3/SDL_CreateCond.3 docs/man3/SDL_CreateCursor.3 docs/man3/SDL_CreateMutex.3 docs/man3/SDL_CreateRGBSurface.3 docs/man3/SDL_CreateRGBSurfaceFrom.3 docs/man3/SDL_CreateSemaphore.3 docs/man3/SDL_CreateThread.3 docs/man3/SDL_CreateYUVOverlay.3 docs/man3/SDL_Delay.3 docs/man3/SDL_DestroyCond.3 docs/man3/SDL_DestroyMutex.3 docs/man3/SDL_DestroySemaphore.3 docs/man3/SDL_DisplayFormat.3 docs/man3/SDL_DisplayFormatAlpha.3 docs/man3/SDL_DisplayYUVOverlay.3 docs/man3/SDL_EnableKeyRepeat.3 docs/man3/SDL_EnableUNICODE.3 docs/man3/SDL_Event.3 docs/man3/SDL_EventState.3 docs/man3/SDL_FillRect.3 docs/man3/SDL_Flip.3 docs/man3/SDL_FreeCursor.3 docs/man3/SDL_FreeSurface.3 docs/man3/SDL_FreeWAV.3 docs/man3/SDL_FreeYUVOverlay.3 docs/man3/SDL_GL_GetAttribute.3 docs/man3/SDL_GL_GetProcAddress.3 docs/man3/SDL_GL_LoadLibrary.3 docs/man3/SDL_GL_SetAttribute.3 docs/man3/SDL_GL_SwapBuffers.3 docs/man3/SDL_GLattr.3 docs/man3/SDL_GetAppState.3 docs/man3/SDL_GetAudioStatus.3 docs/man3/SDL_GetClipRect.3 docs/man3/SDL_GetCursor.3 docs/man3/SDL_GetEventFilter.3 docs/man3/SDL_GetGamma.3 docs/man3/SDL_GetGammaRamp.3 docs/man3/SDL_GetKeyName.3 docs/man3/SDL_GetKeyState.3 docs/man3/SDL_GetModState.3 docs/man3/SDL_GetMouseState.3 docs/man3/SDL_GetRGB.3 docs/man3/SDL_GetRGBA.3 docs/man3/SDL_GetRelativeMouseState.3 docs/man3/SDL_GetThreadID.3 docs/man3/SDL_GetTicks.3 docs/man3/SDL_GetVideoInfo.3 docs/man3/SDL_GetVideoSurface.3 docs/man3/SDL_Init.3 docs/man3/SDL_InitSubSystem.3 docs/man3/SDL_JoyAxisEvent.3 docs/man3/SDL_JoyBallEvent.3 docs/man3/SDL_JoyButtonEvent.3 docs/man3/SDL_JoyHatEvent.3 docs/man3/SDL_JoystickClose.3 docs/man3/SDL_JoystickEventState.3 docs/man3/SDL_JoystickGetAxis.3 docs/man3/SDL_JoystickGetBall.3 docs/man3/SDL_JoystickGetButton.3 docs/man3/SDL_JoystickGetHat.3 docs/man3/SDL_JoystickIndex.3 docs/man3/SDL_JoystickName.3 docs/man3/SDL_JoystickNumAxes.3 docs/man3/SDL_JoystickNumBalls.3 docs/man3/SDL_JoystickNumButtons.3 docs/man3/SDL_JoystickNumHats.3 docs/man3/SDL_JoystickOpen.3 docs/man3/SDL_JoystickOpened.3 docs/man3/SDL_JoystickUpdate.3 docs/man3/SDL_KeyboardEvent.3 docs/man3/SDL_KillThread.3 docs/man3/SDL_ListModes.3 docs/man3/SDL_LoadBMP.3 docs/man3/SDL_LoadWAV.3 docs/man3/SDL_LockAudio.3 docs/man3/SDL_LockSurface.3 docs/man3/SDL_LockYUVOverlay.3 docs/man3/SDL_MapRGB.3 docs/man3/SDL_MapRGBA.3 docs/man3/SDL_MixAudio.3 docs/man3/SDL_MouseButtonEvent.3 docs/man3/SDL_MouseMotionEvent.3 docs/man3/SDL_NumJoysticks.3 docs/man3/SDL_OpenAudio.3 docs/man3/SDL_Overlay.3 docs/man3/SDL_Palette.3 docs/man3/SDL_PauseAudio.3 docs/man3/SDL_PeepEvents.3 docs/man3/SDL_PixelFormat.3 docs/man3/SDL_PollEvent.3 docs/man3/SDL_PumpEvents.3 docs/man3/SDL_PushEvent.3 docs/man3/SDL_Quit.3 docs/man3/SDL_QuitEvent.3 docs/man3/SDL_QuitSubSystem.3 docs/man3/SDL_RWFromFile.3 docs/man3/SDL_Rect.3 docs/man3/SDL_RemoveTimer.3 docs/man3/SDL_ResizeEvent.3 docs/man3/SDL_SaveBMP.3 docs/man3/SDL_SemPost.3 docs/man3/SDL_SemTryWait.3 docs/man3/SDL_SemValue.3 docs/man3/SDL_SemWait.3 docs/man3/SDL_SemWaitTimeout.3 docs/man3/SDL_SetAlpha.3 docs/man3/SDL_SetClipRect.3 docs/man3/SDL_SetColorKey.3 docs/man3/SDL_SetColors.3 docs/man3/SDL_SetCursor.3 docs/man3/SDL_SetEventFilter.3 docs/man3/SDL_SetGamma.3 docs/man3/SDL_SetGammaRamp.3 docs/man3/SDL_SetModState.3 docs/man3/SDL_SetPalette.3 docs/man3/SDL_SetTimer.3 docs/man3/SDL_SetVideoMode.3 docs/man3/SDL_ShowCursor.3 docs/man3/SDL_Surface.3 docs/man3/SDL_SysWMEvent.3 docs/man3/SDL_ThreadID.3 docs/man3/SDL_UnlockAudio.3 docs/man3/SDL_UnlockSurface.3 docs/man3/SDL_UnlockYUVOverlay.3 docs/man3/SDL_UpdateRect.3 docs/man3/SDL_UpdateRects.3 docs/man3/SDL_UserEvent.3 docs/man3/SDL_VideoDriverName.3 docs/man3/SDL_VideoInfo.3 docs/man3/SDL_VideoModeOK.3 docs/man3/SDL_WM_GetCaption.3 docs/man3/SDL_WM_GrabInput.3 docs/man3/SDL_WM_IconifyWindow.3 docs/man3/SDL_WM_SetCaption.3 docs/man3/SDL_WM_SetIcon.3 docs/man3/SDL_WM_ToggleFullScreen.3 docs/man3/SDL_WaitEvent.3 docs/man3/SDL_WaitThread.3 docs/man3/SDL_WarpMouse.3 docs/man3/SDL_WasInit.3 docs/man3/SDL_keysym.3 docs/man3/SDL_mutexP.3 docs/man3/SDL_mutexV.3 include/.cvsignore include/Makefile.am include/SDL.h include/SDL_active.h include/SDL_audio.h include/SDL_byteorder.h include/SDL_cdrom.h include/SDL_copying.h include/SDL_endian.h include/SDL_error.h include/SDL_events.h include/SDL_getenv.h include/SDL_joystick.h include/SDL_keyboard.h include/SDL_keysym.h include/SDL_main.h include/SDL_mouse.h include/SDL_mutex.h include/SDL_quit.h include/SDL_rwops.h include/SDL_syswm.h include/SDL_thread.h include/SDL_timer.h include/SDL_types.h include/SDL_version.h include/SDL_video.h include/begin_code.h include/close_code.h install-sh ltconfig ltmain.sh missing mkinstalldirs sdl-config.in sdl.m4 src/.cvsignore src/Makefile.am src/SDL.c src/SDL_error.c src/SDL_error_c.h src/SDL_fatal.c src/SDL_fatal.h src/SDL_getenv.c src/audio/.cvsignore src/audio/Makefile.am src/audio/SDL_audio.c src/audio/SDL_audio_c.h src/audio/SDL_audiocvt.c src/audio/SDL_audiodev.c src/audio/SDL_audiodev_c.h src/audio/SDL_audiomem.c src/audio/SDL_audiomem.h src/audio/SDL_mixer.c src/audio/SDL_sysaudio.h src/audio/SDL_wave.c src/audio/SDL_wave.h src/audio/alsa/.cvsignore src/audio/alsa/Makefile.am src/audio/alsa/SDL_alsa_audio.c src/audio/alsa/SDL_alsa_audio.h src/audio/amigaos/Makefile.am src/audio/amigaos/SDL_ahiaudio.c src/audio/amigaos/SDL_audio.c src/audio/amigaos/SDL_lowaudio.h src/audio/amigaos/SDL_sysaudio.h src/audio/arts/.cvsignore src/audio/arts/Makefile.am src/audio/arts/SDL_artsaudio.c src/audio/arts/SDL_artsaudio.h src/audio/baudio/.cvsignore src/audio/baudio/Makefile.am src/audio/baudio/SDL_beaudio.cc src/audio/baudio/SDL_beaudio.h src/audio/dma/.cvsignore src/audio/dma/Makefile.am src/audio/dma/SDL_dmaaudio.c src/audio/dma/SDL_dmaaudio.h src/audio/dmedia/.cvsignore src/audio/dmedia/Makefile.am src/audio/dmedia/SDL_irixaudio.c src/audio/dmedia/SDL_irixaudio.h src/audio/dsp/.cvsignore src/audio/dsp/Makefile.am src/audio/dsp/SDL_dspaudio.c src/audio/dsp/SDL_dspaudio.h src/audio/esd/.cvsignore src/audio/esd/Makefile.am src/audio/esd/SDL_esdaudio.c src/audio/esd/SDL_esdaudio.h src/audio/macrom/.cvsignore src/audio/macrom/Makefile.am src/audio/macrom/SDL_romaudio.c src/audio/macrom/SDL_romaudio.h src/audio/nas/.cvsignore src/audio/nas/Makefile.am src/audio/nas/SDL_nasaudio.c src/audio/nas/SDL_nasaudio.h src/audio/nto/.cvsignore src/audio/nto/Makefile.am src/audio/nto/SDL_nto_audio.c src/audio/nto/SDL_nto_audio.h src/audio/paudio/.cvsignore src/audio/paudio/Makefile.am src/audio/paudio/SDL_paudio.c src/audio/paudio/SDL_paudio.h src/audio/sun/.cvsignore src/audio/sun/Makefile.am src/audio/sun/SDL_sunaudio.c src/audio/sun/SDL_sunaudio.h src/audio/ums/.cvsignore src/audio/ums/Makefile.am src/audio/ums/SDL_umsaudio.c src/audio/ums/SDL_umsaudio.h src/audio/windib/.cvsignore src/audio/windib/Makefile.am src/audio/windib/SDL_dibaudio.c src/audio/windib/SDL_dibaudio.h src/audio/windx5/.cvsignore src/audio/windx5/Makefile.am src/audio/windx5/SDL_dx5audio.c src/audio/windx5/SDL_dx5audio.h src/cdrom/.cvsignore src/cdrom/Makefile.am src/cdrom/SDL_cdrom.c src/cdrom/SDL_syscdrom.h src/cdrom/aix/SDL_syscdrom.c src/cdrom/beos/SDL_syscdrom.c src/cdrom/dummy/SDL_syscdrom.c src/cdrom/freebsd/SDL_syscdrom.c src/cdrom/linux/SDL_syscdrom.c src/cdrom/macos/SDL_syscdrom.c src/cdrom/macos/SDL_syscdrom_c.h src/cdrom/openbsd/SDL_syscdrom.c src/cdrom/qnx/SDL_syscdrom.c src/cdrom/win32/SDL_syscdrom.c src/endian/.cvsignore src/endian/Makefile.am src/endian/SDL_endian.c src/events/.cvsignore src/events/Makefile.am src/events/SDL_active.c src/events/SDL_events.c src/events/SDL_events_c.h src/events/SDL_expose.c src/events/SDL_keyboard.c src/events/SDL_mouse.c src/events/SDL_quit.c src/events/SDL_resize.c src/events/SDL_sysevents.h src/file/.cvsignore src/file/Makefile.am src/file/SDL_rwops.c src/hermes/.cvsignore src/hermes/COPYING.LIB src/hermes/HeadMMX.h src/hermes/HeadX86.h src/hermes/Makefile.am src/hermes/README src/hermes/mmx_main.asm src/hermes/mmxp2_32.asm src/hermes/x86_main.asm src/hermes/x86p_16.asm src/hermes/x86p_32.asm src/joystick/.cvsignore src/joystick/Makefile.am src/joystick/SDL_joystick.c src/joystick/SDL_joystick_c.h src/joystick/SDL_sysjoystick.h src/joystick/beos/.cvsignore src/joystick/beos/Makefile.am src/joystick/beos/SDL_bejoystick.cc src/joystick/dummy/.cvsignore src/joystick/dummy/Makefile.am src/joystick/dummy/SDL_sysjoystick.c src/joystick/linux/.cvsignore src/joystick/linux/Makefile.am src/joystick/linux/SDL_sysjoystick.c src/joystick/macos/.cvsignore src/joystick/macos/Makefile.am src/joystick/macos/SDL_sysjoystick.c src/joystick/win32/.cvsignore src/joystick/win32/Makefile.am src/joystick/win32/SDL_mmjoystick.c src/main/.cvsignore src/main/Makefile.am src/main/beos/SDL_BeApp.cc src/main/beos/SDL_BeApp.h src/main/beos/exports/Makefile src/main/beos/exports/SDL.exp src/main/beos/exports/genexp.pl src/main/dummy.c src/main/linux/SDL_main.c src/main/macos/SDL.r src/main/macos/SDL_main.c src/main/macos/SIZE.r src/main/macos/exports/Makefile src/main/macos/exports/SDL.x src/main/macos/exports/gendef.pl src/main/win32/SDL_main.c src/main/win32/exports/Makefile src/main/win32/exports/SDL.def src/main/win32/exports/gendef.pl src/thread/.cvsignore src/thread/Makefile.am src/thread/SDL_systhread.h src/thread/SDL_thread.c src/thread/SDL_thread_c.h src/thread/amigaos/SDL_syssem.c src/thread/amigaos/SDL_systhread.c src/thread/amigaos/SDL_systhread_c.h src/thread/amigaos/SDL_thread.c src/thread/beos/SDL_syssem.c src/thread/beos/SDL_systhread.c src/thread/beos/SDL_systhread_c.h src/thread/generic/SDL_syscond.c src/thread/generic/SDL_syscond_c.h src/thread/generic/SDL_sysmutex.c src/thread/generic/SDL_sysmutex_c.h src/thread/generic/SDL_syssem.c src/thread/generic/SDL_syssem_c.h src/thread/generic/SDL_systhread.c src/thread/generic/SDL_systhread_c.h src/thread/irix/SDL_systhread.c src/thread/irix/SDL_systhread_c.h src/thread/linux/SDL_syscond.c src/thread/linux/SDL_sysmutex.c src/thread/linux/SDL_sysmutex_c.h src/thread/linux/SDL_syssem.c src/thread/linux/SDL_systhread.c src/thread/linux/SDL_systhread_c.h src/thread/linux/clone.S src/thread/win32/SDL_sysmutex.c src/thread/win32/SDL_syssem.c src/thread/win32/SDL_systhread.c src/thread/win32/SDL_systhread_c.h src/timer/.cvsignore src/timer/Makefile.am src/timer/SDL_systimer.h src/timer/SDL_timer_c.h src/timer/amigaos/SDL_systimer.c src/timer/beos/SDL_systimer.c src/timer/linux/SDL_systimer.c src/timer/macos/FastTimes.c src/timer/macos/FastTimes.h src/timer/macos/SDL_MPWtimer.c src/timer/macos/SDL_systimer.c src/timer/win32/SDL_systimer.c src/video/.cvsignore src/video/Makefile.am src/video/SDL_RLEaccel.c src/video/SDL_RLEaccel_c.h src/video/SDL_blit.c src/video/SDL_blit.h src/video/SDL_blit_0.c src/video/SDL_blit_1.c src/video/SDL_blit_A.c src/video/SDL_blit_A.h src/video/SDL_blit_N.c src/video/SDL_bmp.c src/video/SDL_cursor.c src/video/SDL_cursor_c.h src/video/SDL_gamma.c src/video/SDL_glfuncs.h src/video/SDL_leaks.h src/video/SDL_memops.h src/video/SDL_pixels.c src/video/SDL_pixels_c.h src/video/SDL_stretch.c src/video/SDL_stretch_c.h src/video/SDL_surface.c src/video/SDL_sysvideo.h src/video/SDL_video.c src/video/SDL_yuv.c src/video/SDL_yuv_mmx.c src/video/SDL_yuv_sw.c src/video/SDL_yuv_sw_c.h src/video/SDL_yuvfuncs.h src/video/aalib/.cvsignore src/video/aalib/Makefile.am src/video/aalib/SDL_aaevents.c src/video/aalib/SDL_aaevents_c.h src/video/aalib/SDL_aamouse.c src/video/aalib/SDL_aamouse_c.h src/video/aalib/SDL_aavideo.c src/video/aalib/SDL_aavideo.h src/video/blank_cursor.h src/video/bwindow/.cvsignore src/video/bwindow/Makefile.am src/video/bwindow/SDL_BView.h src/video/bwindow/SDL_BWin.h src/video/bwindow/SDL_lowvideo.h src/video/bwindow/SDL_sysevents.cc src/video/bwindow/SDL_sysevents_c.h src/video/bwindow/SDL_sysmouse.cc src/video/bwindow/SDL_sysmouse_c.h src/video/bwindow/SDL_sysvideo.cc src/video/bwindow/SDL_syswm.cc src/video/bwindow/SDL_syswm_c.h src/video/cybergfx/.cvsignore src/video/cybergfx/Makefile.am src/video/cybergfx/SDL_amigaevents.c src/video/cybergfx/SDL_amigaevents_c.h src/video/cybergfx/SDL_amigamouse.c src/video/cybergfx/SDL_amigamouse_c.h src/video/cybergfx/SDL_cgxaccel.c src/video/cybergfx/SDL_cgxgl.c src/video/cybergfx/SDL_cgxgl_c.h src/video/cybergfx/SDL_cgximage.c src/video/cybergfx/SDL_cgximage_c.h src/video/cybergfx/SDL_cgxmodes.c src/video/cybergfx/SDL_cgxmodes_c.h src/video/cybergfx/SDL_cgxvideo.c src/video/cybergfx/SDL_cgxvideo.h src/video/cybergfx/SDL_cgxwm.c src/video/cybergfx/SDL_cgxwm_c.h src/video/default_cursor.h src/video/dga/.cvsignore src/video/dga/Makefile.am src/video/dga/SDL_dgaevents.c src/video/dga/SDL_dgaevents_c.h src/video/dga/SDL_dgamouse.c src/video/dga/SDL_dgamouse_c.h src/video/dga/SDL_dgavideo.c src/video/dga/SDL_dgavideo.h src/video/fbcon/.cvsignore src/video/fbcon/3dfx_mmio.h src/video/fbcon/3dfx_regs.h src/video/fbcon/Makefile.am src/video/fbcon/SDL_fb3dfx.c src/video/fbcon/SDL_fb3dfx.h src/video/fbcon/SDL_fbelo.c src/video/fbcon/SDL_fbelo.h src/video/fbcon/SDL_fbevents.c src/video/fbcon/SDL_fbevents_c.h src/video/fbcon/SDL_fbkeys.h src/video/fbcon/SDL_fbmatrox.c src/video/fbcon/SDL_fbmatrox.h src/video/fbcon/SDL_fbmouse.c src/video/fbcon/SDL_fbmouse_c.h src/video/fbcon/SDL_fbvideo.c src/video/fbcon/SDL_fbvideo.h src/video/fbcon/matrox_mmio.h src/video/fbcon/matrox_regs.h src/video/ggi/.cvsignore src/video/ggi/Makefile.am src/video/ggi/SDL_ggievents.c src/video/ggi/SDL_ggievents_c.h src/video/ggi/SDL_ggikeys.h src/video/ggi/SDL_ggimouse.c src/video/ggi/SDL_ggimouse_c.h src/video/ggi/SDL_ggivideo.c src/video/ggi/SDL_ggivideo.h src/video/maccommon/.cvsignore src/video/maccommon/Makefile.am src/video/maccommon/SDL_lowvideo.h src/video/maccommon/SDL_macevents.c src/video/maccommon/SDL_macevents_c.h src/video/maccommon/SDL_macgl.c src/video/maccommon/SDL_macgl_c.h src/video/maccommon/SDL_mackeys.h src/video/maccommon/SDL_macmouse.c src/video/maccommon/SDL_macmouse_c.h src/video/maccommon/SDL_macwm.c src/video/maccommon/SDL_macwm_c.h src/video/macdsp/.cvsignore src/video/macdsp/Makefile.am src/video/macdsp/SDL_dspvideo.c src/video/macdsp/SDL_dspvideo.h src/video/macrom/.cvsignore src/video/macrom/Makefile.am src/video/macrom/SDL_romvideo.c src/video/macrom/SDL_romvideo.h src/video/photon/.cvsignore src/video/photon/Makefile.am src/video/photon/SDL_ph_events.c src/video/photon/SDL_ph_events_c.h src/video/photon/SDL_ph_image.c src/video/photon/SDL_ph_image_c.h src/video/photon/SDL_ph_modes.c src/video/photon/SDL_ph_modes_c.h src/video/photon/SDL_ph_mouse.c src/video/photon/SDL_ph_mouse_c.h src/video/photon/SDL_ph_video.c src/video/photon/SDL_ph_video.h src/video/photon/SDL_ph_wm.c src/video/photon/SDL_ph_wm_c.h src/video/photon/SDL_phyuv.c src/video/photon/SDL_phyuv_c.h src/video/svga/.cvsignore src/video/svga/Makefile.am src/video/svga/SDL_svgaevents.c src/video/svga/SDL_svgaevents_c.h src/video/svga/SDL_svgamouse.c src/video/svga/SDL_svgamouse_c.h src/video/svga/SDL_svgavideo.c src/video/svga/SDL_svgavideo.h src/video/wincommon/.cvsignore src/video/wincommon/Makefile.am src/video/wincommon/SDL_lowvideo.h src/video/wincommon/SDL_sysevents.c src/video/wincommon/SDL_sysmouse.c src/video/wincommon/SDL_sysmouse_c.h src/video/wincommon/SDL_syswm.c src/video/wincommon/SDL_syswm_c.h src/video/wincommon/SDL_wingl.c src/video/wincommon/SDL_wingl_c.h src/video/wincommon/wmmsg.h src/video/windib/.cvsignore src/video/windib/Makefile.am src/video/windib/SDL_dibevents.c src/video/windib/SDL_dibevents_c.h src/video/windib/SDL_dibvideo.c src/video/windib/SDL_dibvideo.h src/video/windib/SDL_vkeys.h src/video/windx5/.cvsignore src/video/windx5/Makefile.am src/video/windx5/SDL_dx5events.c src/video/windx5/SDL_dx5events_c.h src/video/windx5/SDL_dx5video.c src/video/windx5/SDL_dx5video.h src/video/windx5/SDL_dx5yuv.c src/video/windx5/SDL_dx5yuv_c.h src/video/windx5/directx.h src/video/x11/.cvsignore src/video/x11/Makefile.am src/video/x11/SDL_x11dga.c src/video/x11/SDL_x11dga_c.h src/video/x11/SDL_x11events.c src/video/x11/SDL_x11events_c.h src/video/x11/SDL_x11gamma.c src/video/x11/SDL_x11gamma_c.h src/video/x11/SDL_x11gl.c src/video/x11/SDL_x11gl_c.h src/video/x11/SDL_x11image.c src/video/x11/SDL_x11image_c.h src/video/x11/SDL_x11modes.c src/video/x11/SDL_x11modes_c.h src/video/x11/SDL_x11mouse.c src/video/x11/SDL_x11mouse_c.h src/video/x11/SDL_x11video.c src/video/x11/SDL_x11video.h src/video/x11/SDL_x11wm.c src/video/x11/SDL_x11wm_c.h src/video/x11/SDL_x11yuv.c src/video/x11/SDL_x11yuv_c.h strip_fPIC.sh test/.cvsignore test/.gdbinit test/COPYING test/Makefile.am test/README test/acinclude.m4 test/autogen.sh test/checkkeys.c test/config.guess test/config.sub test/configure.in test/graywin.c test/icon.bmp test/install-sh test/loopwave.c test/missing test/mkinstalldirs test/picture.xbm test/sail.bmp test/sample.bmp test/sample.wav test/testalpha.c test/testbitmap.c test/testcdrom.c test/testerror.c test/testgamma.c test/testgl.c test/testhread.c test/testjoystick.c test/testkeys.c test/testlock.c test/testpalette.c test/testsem.c test/testsprite.c test/testtimer.c test/testtypes.c test/testver.c test/testvidinfo.c test/testwin.c test/testwm.c test/threadwin.c test/torturethread.c
diffstat 892 files changed, 170313 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,10 @@
+Makefile.in
+configure
+aclocal.m4
+config.log
+config.cache
+libtool
+config.status
+Makefile
+sdl-config
+SDL.spec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/BUGS	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,199 @@
+
+All:
+	Audio rate conversion is only implemented by multiplying or dividing
+	by a power of two.  This is a side-effect of the requirement that the
+	raw audio buffer size be a power of two, and can hopefully be fixed.
+	This means 8 KHz audio converted to 22 KHz ends up being 16 KHz. :-/
+
+	When the implementation is writing directly to video memory the mouse
+	cursor doesn't work properly.  Applications which do this should use
+	their own mouse cursor and call SDL_ShowCursor(0) to hide the system
+	cursor.
+
+Linux:
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+	The AAlib, GGI, and SVGAlib video drivers are not heavily tested.
+
+Win32:
+	The MCI driver can't tell if the CD-ROM drive is paused or stopped.
+
+	The SDL_INIT_EVENTTHREAD flag is not supported on Win32
+	(Idea: create a separate DirectInput polling thread)
+	The main purpose of this flag is for smooth cursor motion in
+	fullscreen environments.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	This requires the ToUnicode() API which is only implemented on
+	Windows NT/2000, not on Windows 95/98.
+	Latin-1 keyboard input works fine.
+
+	Joysticks are only supported under the Win32 MultiMedia API,
+	DirectInput support is not yet implemented.
+
+BeOS:
+	BePPC is not supported, apparently not even by Be Inc.
+
+	SDL_WM_GrabInput() is not implemented.
+	Does anyone know how to do this?  SDL_WM_GrabInput() is designed
+	to prevent the user from switching input and mouse focus away from
+	the SDL application.
+
+	Continuous relative mouse motion is not implemented.
+
+	The CD driver doesn't detect SCSI CD-ROMs yet.
+
+	Wide UNICODE character input (Kanji, etc.) has not been tested.
+	Latin-1 keyboard input works fine.
+
+MacOS:
+	Palette handling isn't implemented in windowed mode yet.
+
+	Audio hasn't been extensively tested, in particular the locking
+	isn't implemented and mixer routines may not call malloc() or free()
+	because they are called at interrupt time.
+
+	SDL_WM_GrabInput() is not implemented.
+	Does anyone know how to do this?  SDL_WM_GrabInput() is designed
+	to prevent the user from switching input and mouse focus away from
+	the SDL application.
+
+	Continuous relative mouse motion is not implemented.
+
+	SDL_AddTimer() and SDL_RemoveTimer() haven't been implemented yet.
+
+	Not all of the keys are properly recognized on the keyboard.
+
+MacOS X:
+	Fullscreen mode doesn't work - it requires the QuickTime framework
+	and that the new SDL window gets raised to the top of the Z order.
+
+	Palette handling isn't implemented in windowed mode yet.
+
+	Native sound and video routines are not finished, though Carbon
+	seems to work fairly well.
+
+	Joysticks and CD-ROM functions are not implemented yet.
+
+	SDL_WM_GrabInput() is not implemented.
+	Does anyone know how to do this?  SDL_WM_GrabInput() is designed
+	to prevent the user from switching input and mouse focus away from
+	the SDL application.
+
+	Continuous relative mouse motion is not implemented.
+
+	Not all of the keys are properly recognized on the keyboard.
+
+	MacOS X seems to have a broken pthread_cancel() implementation.
+
+FreeBSD:
+	pthread_cancel() isn't supported by FreeBSD 3.X, so threads don't
+	work on versions of FreeBSD earlier than 4.0.
+
+	The CD-ROM handling doesn't work completely.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+Solaris:
+	The joystick functions are not implemented yet.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+IRIX:
+	The CD-ROM handling doesn't work completely.
+
+	The joystick functions are not implemented yet.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+OpenBSD:  -= NOT YET SUPPORTED =-
+	This is reported to work, but I haven't verified this.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+OSF/Tru64:  -= NOT YET SUPPORTED =-
+	The audio functions are not implemented yet.
+
+	Joysticks and CD-ROM functions are not implemented yet.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+AIX:  -= NOT YET SUPPORTED =-
+	This port has only been tested with AIX 4.3.3
+
+	The OpenGL support doesn't work yet.
+
+	The joystick subsystem isn't implemented yet.
+
+	Endian detection doesn't work yet - needs a unique CPP symbol.
+
+	Wide UNICODE character input (Kanji, etc.) is not yet supported.
+	It requires handling of keyboard mapping events and using the XIM
+	input translation extension.  I will implement it as requested.
+	Latin-1 keyboard input works fine.
+
+	The AIX port was done by Carsten.Griwodz@KOM.tu-darmstadt.de
+	More information on this port is available at:
+	http://www.kom.e-technik.tu-darmstadt.de/~griff/SDL/
+
+QNX:  -= NOT YET SUPPORTED =-
+	Configuration doesn't work right, Makefiles still need to be
+	tweaked (need to add libraries to any apps that use sdl_config
+	to figure out what libs they need).
+ 
+	Only static libraries are being made, no shared ones.
+ 
+	The only hardware surface is the primary view surface.
+ 
+	Mouse events don't seem to be working right.
+ 
+	Fullscreen doesn't display correctly.
+ 
+	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).
+ 
+	The mouse cursor doesn't look right.
+
+AmigaOS:  -= NOT YET SUPPORTED =-
+	The OpenGL support isn't implemented yet.
+
+	SDL_WM_GrabInput() is not implemented.
+	Does anyone know how to do this?  SDL_WM_GrabInput() is designed
+	to prevent the user from switching input and mouse focus away from
+	the SDL application.
+
+	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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/COPYING	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,437 @@
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+    		    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CREDITS	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,51 @@
+
+Simple DirectMedia Layer CREDITS
+Thanks to everyone who made this possible, including:
+
+* Cliff Matthews, for giving me a reason to start this project. :)
+ -- Executor rocks!  *grin*
+
+* Scott Call, for making a home for SDL on the 'Net, Thanks! :)
+
+* Michael Samuel and Loki Entertainment Software, for the SDL mailing list
+
+* Patrick Trainor and Jim Boucher, for the QNX Neutrino port
+
+* Gabriele Greco, for the Amiga port
+
+* Stan Shebs, for the initial MacOS X port
+
+* Carsten Griwodz for the AIX port
+
+* Mattias Engdegerd, for help with the Solaris port and lots of other code
+
+* Kent B Mein, for a place to do the IRIX port
+
+* Ash, for a place to do the OSF/1 Alpha port
+
+* David Sowsy, for help with the BeOS port
+
+* Max Watson, Matt Slot, and Kyle for help with the MacOS port
+
+* Jon Taylor for the GGI front-end
+
+* Paulus Esterhazy, for the Visual C++ testing and libraries
+
+* Brenda Tantzen, for Metrowerks CodeWarrior on MacOS
+
+* Chris Nentwich, for the Hermes assembly blitters
+
+* Michael Vance and Jim Kutter for the X11 OpenGL support
+
+* Peter Wiklund, for the 1998 winning SDL logo,
+  and Arto Hamara, Steven Wong, and Kent Mein for other logo entries.
+
+* Stephane Peter, for the AAlib front-end and multi-threaded timer idea.
+
+ And a big hand to everyone else who gave me appreciation, advice,
+ and suggestions, especially the good folks on the SDL mailing list.
+
+THANKS! :)
+
+  -- Sam Lantinga			<slouken@libsdl.org>
+
Binary file CWprojects.sea.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/INSTALL	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+
+To compile and install SDL:
+
+    1.  Run './configure; make; make install'
+
+        If you are cross-compiling from Linux to Win32, you should read
+        the file README.Win32
+
+        If you are compiling using Visual C++ on Win32, you should read
+        the file VisualC.html
+
+    2.  Look at the example programs in ./test, and check out the HTML
+        documentation in ./docs to see how to use the SDL library.
+
+    3.  Join the SDL developer mailing list by sending E-mail to
+    	majordomo@lokigames.com
+        and including the line "subscribe sdl" in the body.
+
+
+	
+That's it!
+Sam Lantinga <slouken@libsdl.org>
Binary file MPWmake.sea.bin has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,85 @@
+# The top-level input Makefile for SDL
+
+# require automake 1.4
+AUTOMAKE_OPTIONS = 1.4
+
+## Any directories that you want built and installed should go here.
+SUBDIRS = src include docs
+
+## Any directories you want a part of the distribution should be listed
+## here, as well as have a Makefile generated at the end of configure.in
+##
+## This only works for subdirectories one level deep.
+DIST_SUBDIRS = $(SUBDIRS) docs
+
+# SDL runtime configuration script
+bin_SCRIPTS = sdl-config
+
+# All the rest of the distributed files
+EXTRA_DIST =		\
+	BUGS		\
+	TODO		\
+        COPYING		\
+        CREDITS		\
+        INSTALL		\
+        README		\
+        README-SDL.txt	\
+        README.Win32	\
+        README.WinCE	\
+        README.MacOS	\
+        README.MacOSX	\
+        VisualC.html	\
+        VisualC.zip	\
+        MPWmake.sea.bin	\
+	CWprojects.sea.bin \
+        WhatsNew	\
+        docs.html	\
+        sdl.m4		\
+        autogen.sh	\
+        strip_fPIC.sh
+
+# M4 macro file for inclusion with autoconf
+m4datadir = $(datadir)/aclocal
+m4data_DATA = sdl.m4
+
+# Rule to build tar-gzipped distribution package
+$(PACKAGE)-$(VERSION).tar.gz: dist
+
+# Rule to build RPM distribution package
+rpm: $(PACKAGE)-$(VERSION).tar.gz
+	cp $(PACKAGE)-$(VERSION).tar.gz /usr/src/redhat/SOURCES
+	rpm -ba SDL.spec
+
+# Rule to rebuild the export lists for BeOS, MacOS and Win32.
+exports:
+	(cd src/main/beos/exports; $(MAKE))
+	(cd src/main/macos/exports; $(MAKE))
+	(cd src/main/win32/exports; $(MAKE))
+
+# Rule to force automake to rebuild the library
+changed:
+	@echo "This build target is no longer necessary"
+
+# Rule to install the libraries only - prevent rebuilding apps
+install-lib:
+	cd src && $(MAKE) install-libLTLIBRARIES
+
+# Run ldconfig after installing the library:
+install-hook:
+	-ldconfig
+
+# Grab the test programs for the distribution:
+dist-hook:
+	if test -f test/Makefile; then (cd test; make distclean); fi
+	cp -rp test $(distdir)
+	rm -rf `find $(distdir) -type d -name CVS -print`
+
+# Create a CVS snapshot that people can run update -d on
+CVSROOT = :pserver:guest@cvs.lokigames.com:/cvs
+snapshot:
+	cvs -d $(CVSROOT) login
+	cvs -d $(CVSROOT) checkout -r devel_1_1_0 SDL
+	(cd SDL && ./autogen.sh)
+	mv SDL SDL-1.2
+	tar zcvf $(HOME)/SDL-1.2.tar.gz SDL-1.2
+	rm -rf SDL-1.2
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,44 @@
+
+                         Simple DirectMedia Layer
+
+                                  (SDL)
+
+                                Version 1.2
+
+---
+http://www.libsdl.org/
+
+This is the Simple DirectMedia Layer, a generic API that provides low
+level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
+and 2D framebuffer across multiple platforms.
+
+SDL is written in C, but works with C++ natively, and has bindings to
+several other languages, including Ada, Eiffel, ML, Perl, and Python. 
+
+The current version supports Linux, Windows, BeOS, MacOS, MacOS X,
+FreeBSD, Solaris, and IRIX.  The code contains support for Windows CE,
+OpenBSD, NetBSD, AIX, OSF/Tru64, and QNX, but these are not yet
+officially supported.
+
+This library is distributed under GNU LGPL version 2, which can be
+found in the file  "COPYING".  This license allows you to use SDL
+freely in commercial programs as long as you link with the dynamic
+library.
+
+The best way to learn how to use SDL is to check out the header files in
+the "include" subdirectory and the programs in the "test" subdirectory.
+The header files and test programs are well commented and always up to date.
+More documentation is available in HTML format in "./docs/index.html"
+
+The test programs in the "test" subdirectory are in the public domain.
+
+Frequently asked questions are answered online:
+	http://www.libsdl.org/faqs.html
+
+If you need help with the library, or just want to discuss SDL related
+issues, you can join the developers mailing list:
+	http://www.libsdl.org/mailing-list.html
+
+Enjoy!
+	Sam Lantinga				(slouken@libsdl.org)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README-SDL.txt	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+
+Please distribute this file with the SDL runtime environment:
+
+The Simple DirectMedia Layer (SDL for short) is a cross-platfrom library
+designed to make it easy to write multi-media software, such as games and
+emulators.
+
+The Simple DirectMedia Layer library source code is available from:
+http://www.libsdl.org/
+
+This library is distributed under the terms of the GNU LGPL license:
+http://www.gnu.org/copyleft/lesser.html
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.CVS	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+
+The latest development version of SDL is available via CVS:
+
+cvs -d :pserver:guest@cvs.lokigames.com:/cvs login
+# use the password "guest"
+cvs -d :pserver:guest@cvs.lokigames.com:/cvs checkout SDL
+
+When you check a fresh copy of SDL out of CVS, you need to generate
+the files used by make by running the "autogen.sh" script, which will
+run aclocal, automake, autoconf and then run configure.
+
+There is a web interface to cvs at http://cvs.lokigames.com/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.MacOS	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,60 @@
+
+==============================================================================
+Using the Simple DirectMedia Layer with MacOS 7,8,9 on PPC
+==============================================================================
+
+These instructions are for people using the Apple MPW environment:
+http://developer.apple.com/tools/mpw-tools/
+
+CodeWarrior projects are available in the CWprojects directory.
+
+==============================================================================
+I.  Building the Simple DirectMedia Layer libraries:
+    (This step isn't necessary if you have the SDL binary distribution)
+
+  First, unpack the MPWmake.sea.hqx archive and move SDL.make into the
+  SDL directory.
+
+  Start MPW
+
+  Set the current directory within MPW to the SDL toplevel directory.
+
+  Build "SDL"  (Type Command-B and enter "SDL" in the dialog)
+
+  If everything compiles successfully, you now have the PPC libraries
+  "SDL" and "SDLmain.o" in the 'lib' subdirectory.
+
+==============================================================================
+II. Building the Simple DirectMedia Layer test programs:
+
+  First, unpack the MPWmake.sea.hqx archive, move the new rsrc directory to
+  the main SDL directory, and move the makefiles in the new test subdirectory
+  to the SDL 'test' subdirectory.
+
+  Start MPW
+
+  Set the current directory within MPW to the SDL 'test' subdirectory.
+
+  Build the programs that have an associated MPW makefile (file ending
+  with .make), including "testwin", "testalpha", and "graywin".
+
+  Copy the SDL library file into the test directory, and run!
+
+==============================================================================
+III. Building the Simple DirectMedia Layer demo programs:
+
+  Copy one of the test program Makefiles to the demo directory
+  and modify it to match the sources in the demo.
+
+==============================================================================
+IV.  Enjoy! :)
+
+  If you have a project you'd like me to know about, or want to ask questions,
+  go ahead and join the SDL developer's mailing list by sending e-mail to:
+
+	majordomo@lokigames.com
+
+  and put the line "subscribe sdl" in the body of the message.
+  
+==============================================================================
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.MacOSX	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,44 @@
+==============================================================================
+Using the Simple DirectMedia Layer with Mac OS X
+==============================================================================
+
+These instructions are for people using Apple's Mac OS X (pronounced
+"ten").
+
+From the developer's point of view, OS X is a sort of hybrid Mac and
+Unix system, and you have the option of using either traditional
+command line tools or Apple's IDE ProjectBuilder (PB).
+
+To build using the command line, use the standard configure and make
+process:
+
+	./configure
+	make
+	make install
+
+(You may need to create the subdirs of /usr/local manually.)
+
+For some reason, libtool doesn't run ranlib properly, so do this
+manually:
+
+	ranlib /usr/local/lib/libSDL.a
+
+To use the library once it's built, you need to use the "Carbon
+framework", which is the port of the old Mac Toolbox to OS X.
+To do this, use the -F and -framework arguments for compiling
+and linking, respectively:
+
+	cc -c myprog.c -I/usr/local/include/SDL -F/System/Library/Frameworks/Carbon.framework
+	cc myprog.o -L/usr/local/lib -lSDL -framework Carbon
+
+sdl-config knows about the linking path and -framework, so it's
+recommended to use it to fill in your Makefile variables.
+
+[Add instructions for how to build using PB]
+
+As of this writing (Sep 2000), OS X is in public beta.  This means
+that while most of the APIs are frozen, things are still subject to
+change, and many of the known problems will be resolved before the
+final release comes out.
+
+Known bugs are listed in the file "BUGS"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.Win32	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,53 @@
+
+==============================================================================
+Using the Simple DirectMedia Layer with Windows 95,NT
+==============================================================================
+
+These instructions are for people using the GNU free compilers.
+If you want to use Microsoft VC++ with SDL, read "VisualC.html"
+
+==============================================================================
+I.  Building the Simple DirectMedia Layer libraries:
+    (This step isn't necessary if you have the SDL binary distribution)
+
+  First, get gcc compiler for Win32, which can be found at:
+	http://www.libsdl.org/Xmingw32/index.html
+
+  Grab the cross configure and make scripts, and then run:
+	sh cross-configure.sh
+	sh cross-make.sh install
+  If you have already built SDL natively, you must do "make distclean"
+  before you build for Win32.
+
+  If everything compiles successfully, you now have SDL.dll and gcc archive
+  libraries libSDLmain.a and libSDL.a installed in /usr/local/cross-tools/
+
+==============================================================================
+II. Building the Simple DirectMedia Layer test programs:
+
+  This is easy once you have built the libraries:
+
+	cd test; sh ../cross-configure.sh; sh ../cross-make.sh
+
+==============================================================================
+III. Building the Simple DirectMedia Layer demo programs:
+
+  Go to the directory containing the demo you want to build and type:
+
+	sh cross-configure.sh; sh cross-make.sh
+
+  Be sure to rename the demo to use the .exe extension, or Windows will
+  not be able to execute it.
+
+==============================================================================
+IV.  Enjoy! :)
+
+  If you have a project you'd like me to know about, or want to ask questions,
+  go ahead and join the SDL developer's mailing list by sending e-mail to:
+
+	majordomo@lokigames.com
+
+  and put the line "subscribe sdl" in the body of the message.
+  
+==============================================================================
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.WinCE	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+
+NOTE:
+SDL is NOT SUPPORTED on the WinCE platform!  This is for experimental
+purposes only.
+
+There are several SDL features not available in the WinCE port of SDL.
+
+- DirectX is not yet available
+- Semaphores are not available
+- Joystick support is not available
+- CD-ROM control is not available
+
+In addition, there are several features that run in "degraded" mode:
+
+Preprocessor Symbol		Effect
+===================		=================================
+
+SDL_systimer.c:
+USE_GETTICKCOUNT		Less accurate values for SDL time functions
+USE_SETTIMER			Use only a single marginally accurate timer
+
+SDL_syswm.c:
+DISABLE_ICON_SUPPORT		Can't set the runtime window icon
+
+SDL_sysmouse.c:
+USE_STATIC_CURSOR		Only the arrow cursor is available
+
+SDL_sysevents.c:
+NO_GETKEYBOARDSTATE		Can't get modifier state on keyboard focus
+
+SDL_dibevents.c:
+NO_GETKEYBOARDSTATE		Very limited keycode translation
+
+SDL_dibvideo.c:
+NO_GETDIBITS			Can't distinguish between 15 bpp and 16 bpp
+NO_CHANGEDISPLAYSETTINGS	No fullscreen support
+NO_GAMMA_SUPPORT		Gamma correction not available
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDL.spec.in	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,90 @@
+%define name @PACKAGE@
+%define version @VERSION@
+%define release 1
+
+Summary: Simple DirectMedia Layer
+Name: %{name}
+Version: %{version}
+Release: %{release}
+Source0: %{name}-%{version}.tar.gz
+URL: http://www.libsdl.org/
+Copyright: LGPL
+Group: System Environment/Libraries
+BuildRoot: /var/tmp/%{name}-buildroot
+Prefix: %{_prefix}
+
+%description
+This is the Simple DirectMedia Layer, a generic API that provides low
+level access to audio, keyboard, mouse, and display framebuffer across
+multiple platforms.
+
+%package devel
+Summary: Libraries, includes and more to develop SDL applications.
+Group: Development/Libraries
+Requires: %{name}
+
+%description devel
+This is the Simple DirectMedia Layer, a generic API that provides low
+level access to audio, keyboard, mouse, and display framebuffer across
+multiple platforms.
+
+This is the libraries, include files and other resources you can use
+to develop SDL applications.
+
+
+%prep
+rm -rf ${RPM_BUILD_ROOT}
+
+%setup -q 
+
+%build
+CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=%{prefix} --disable-video-svga --disable-video-ggi --disable-video-aalib --disable-debug --enable-xfree86-glidehack
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install prefix=$RPM_BUILD_ROOT/%{prefix}
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+%doc README-SDL.txt COPYING CREDITS BUGS
+%{prefix}/lib/lib*.so.*
+
+%files devel
+%defattr(-,root,root)
+%doc README README-SDL.txt COPYING CREDITS BUGS WhatsNew docs.html
+%doc docs/index.html docs/html
+%{prefix}/bin/*-config
+%{prefix}/lib/lib*.a
+%{prefix}/lib/lib*.so
+%{prefix}/include/SDL/
+%{prefix}/man/man3/*
+%{prefix}/share/aclocal/*
+
+%changelog
+* Wed Jan 19 2000 Sam Lantinga <slouken@libsdl.org>
+- Re-integrated spec file into SDL distribution
+- 'name' and 'version' come from configure 
+- Some of the documentation is devel specific
+- Removed SMP support from %build - it doesn't work with libtool anyway
+
+* Tue Jan 18 2000 Hakan Tandogan <hakan@iconsult.com>
+- Hacked Mandrake sdl spec to build 1.1
+
+* Sun Dec 19 1999 John Buswell <johnb@mandrakesoft.com>
+- Build Release
+
+* Sat Dec 18 1999 John Buswell <johnb@mandrakesoft.com>
+- Add symlink for libSDL-1.0.so.0 required by sdlbomber
+- Added docs
+
+* Thu Dec 09 1999 Lenny Cartier <lenny@mandrakesoft.com>
+- v 1.0.0
+
+* Mon Nov  1 1999 Chmouel Boudjnah <chmouel@mandrakesoft.com>
+- First spec file for Mandrake distribution.
+
+# end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TODO	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+
+TODO list for the 1.2 release:
+
+ * Use /etc/fb.modes, if available, like GGI does
+
+Wish list for the 1.3 development branch:
+
+ * Add mousewheel events (new unified event architecture?)
+ * DirectInput joystick support needs to be implemented
+ * Be able to enumerate and select available audio and video drivers
+ * Fullscreen video mode support for MacOS X
+ * Explicit vertical retrace wait (maybe separate from SDL_Flip?)
+ * Shaped windows, windows without borders
+ * Multiple windows, multiple display support
+ * SDL_INIT_EVENTTHREAD on Windows and MacOS?
+ * Add a timestamp to events
+ * Use RDTSC for timer resolution on x86 hardware
+ * Add audio input API
+
+In the jump from 1.2 to 1.3, we should change the SDL_Rect members to
+int and evaluate all the rest of the datatypes.  This is the only place
+we should do it though, since the 1.2 series should not break binary
+compatibility in this way.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/VisualC.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,235 @@
+<HTML>
+
+
+
+<HEAD>
+
+
+
+<TITLE> Using SDL with Microsoft Visual C++ 5 and 6 </TITLE>
+
+
+
+</HEAD>
+
+
+
+<BODY>
+
+
+
+<H1> Using SDL with Microsoft Visual C++ 5 and 6 </H1>
+
+<H3>
+     by <A HREF="mailto:snowlion@sprynet.com"> Lion Kimbro </A>
+</H3>
+
+
+
+<p>
+    You can either use the precompiled libraries from
+    <A HREF="http://www.libsdl.org/download.html">
+    the SDL Download web site </A>,
+    or you can build SDL yourself.
+</p>
+
+
+<H3> Building SDL </H3>
+
+<P>
+     Unzip the <CODE>VisualC.zip</CODE> file into the directory
+     that contains this file (<CODE>VisualC.html</CODE>).
+</P>
+
+<P>
+     Be certain that you unzip <CODE> VisualC.zip </CODE>
+     into <strong>this</strong> directory and not any other
+     directory. If you are using WinZip, be careful to
+     make sure that it extracts to <strong>this</strong>
+     folder, because it's convenient feature of
+     unzipping to a folder with the name of the
+     file currently being unzipped will get you in
+     trouble if you use it right now. And that's all
+     I have to say about that.
+</P>
+
+<P>
+     Now that it's unzipped, go into the VisualC directory
+     that is created, and double-click on the VC++
+     workspace file &quot;<CODE>SDL.dsw</CODE>&quot;.
+     This should open up VisualC.
+</P>
+
+<P>
+     You may be prompted at this point to upgrade the
+     workspace, should you be using a more recent version
+     of Visual C++. If so, allow the workspace to be
+     upgraded.
+</P>
+
+
+<P>
+     Build the <CODE>.dll</CODE> and <CODE>.lib</CODE> files.
+</P>
+
+<P>
+     This is done by right clicking on each project in turn
+     (Projects are listed in the Workspace panel in the
+     FileView tab), and selecting &quot;Build&quot;.
+</P>
+
+<P>
+     You may get a few warnings, but you should not get
+     any errors. You do have to have at least the DirectX
+     5 SDK installed, however. (I believe...) The latest
+     version of DirectX can be downloaded or purchased
+     on a cheap CD (my recommendation) from
+     <A HREF="http://www.microsoft.com"> Microsoft </A>.
+</P>
+
+<P>
+    Later, we will refer to the following .lib and .dll
+    files that have just been generated:
+</P>
+
+    <list>
+    <li> SDL.dll
+    <li> SDL.lib
+    <li> SDLmain.lib
+    </list>
+
+<P>
+    Search for these using the Windows Find (Windows-F)
+    utility, if you don't already know where they should be.
+    For those of you with a clue, look inside the Debug
+    or Release directories of the subdirectories of the
+    VisualC folder. (It might be easier to just use
+    Windows Find if this sounds confusing. And don't worry
+    about needing a clue; we all need visits from the
+    clue fairy frequently.)
+</P>
+
+
+
+<H3> Creating a Project with SDL </H3>
+
+<P>
+     Create a project as a Win32 Application.
+</P>
+
+<P>
+     Create a C++ file for your project.
+</P>
+
+<P>
+     Set the C runtime to "Multi-threaded DLL" in the menu:
+     <CODE> Project|Settings|C/C++ tab|Code Generation|Runtime Library </CODE>.
+</P>
+
+<P>
+     Add the SDL <CODE>include</CODE> directory to your list
+     of includes in the menu:
+     <CODE> Project|Settings|C/C++ tab|Preprocessor|Additional include directories </CODE>.
+</P>
+
+<P>
+     The &quot;include directory&quot; I am referring to is the
+     <CODE>include</CODE> folder within the main SDL
+     directory (the one that this HTML file located
+     within.
+</P>
+
+<P>
+     Now we're going to use the files that we had created
+     earlier in the Build SDL step.
+</P>
+
+<P>
+     Copy the following files into your Project directory:
+</P>
+
+     <list>
+     <li> SDL.dll </li>
+     </list>
+
+<P>
+     Copy the following files into your Project directory,
+     and <em>add them to your Project</em> as well:
+</P>
+
+     <list>
+     <li> SDL.lib </li>
+     <li> SDLmain.lib </li>
+     </list>
+
+<P>
+     (To add them to your project, right click on your
+     project, and select &quot;Add files to project&quot;)
+</P>
+
+<P>
+     (I believe that it's not necessary to actually
+     copy the .lib files into your directory; you only
+     have to be certain that you add them to your Project.
+     If someone is so inclined, correct this document, or
+     <A HREF="mailto:snowlion@sprynet.com">
+     e-mail me </A>,
+     and I'll fix this document.)
+</P>
+
+
+
+<H3> SDL 101, First Day of Class </H3>
+
+<P>
+     Now create the basic body of your project.
+     The body of your program should take the following form:
+
+<CODE>
+<PRE>
+#include &quot;SDL.h&quot;
+
+int main( int argc, char* argv[] )
+{
+  // Body of the program goes here.
+  return 0;
+}
+</PRE>
+</CODE>
+</P>
+
+<H3> That's it! </H3>
+
+<P>
+     I hope that this document has helped you get
+     through the most difficult part of using the
+     SDL: installing it. Suggestions for improvements
+     to this document should be sent to the writers
+     of this document.
+</P>
+
+<P>
+     Thanks to Paulus Esterhazy (pesterhazy@gmx.net), for the work on VC++ port.
+</P>
+
+<P>
+     This document was originally called &quot;VisualC.txt&quot;,
+     and was written by 
+     <A HREF="mailto:slouken@libsdl.org">Sam Lantinga</A>.
+</P>
+
+<P>
+     Later, it was converted to HTML and expanded into
+     the document that you see today by 
+     <A HREF="mailto:snowlion@sprynet.com">Lion Kimbro</A>.
+</P>
+
+
+
+</BODY>
+
+
+
+</HTML>
+
+
Binary file VisualC.zip has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WhatsNew	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,664 @@
+
+This is a list of API changes in SDL's version history.
+
+Version 1.0:
+
+1.2.0:
+	Added SDL_VIDEOEXPOSE event to signal that the screen needs to
+	be redrawn.  This is currently only delivered to OpenGL windows
+	on X11, though it may be delivered in the future when the video
+	memory is lost under DirectX.
+
+1.1.8:
+	You can pass SDL_NOFRAME to SDL_VideoMode() to create a window
+	that has no title bar or frame decoration.  Fullscreen video
+	modes automatically have this flag set.
+
+	Added a function to query the clipping rectangle for a surface:
+		void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
+
+	Added a function to query the current event filter:
+		SDL_EventFilter SDL_GetEventFilter(void)
+
+	If you pass -1 to SDL_ShowCursor(), it won't change the current
+	cursor visibility state, but will still return it.
+
+	SDL_LockSurface() and SDL_UnlockSurface() are recursive, meaning
+	you can nest them as deep as you want, as long as each lock call
+	has a matching unlock call.  The surface remains locked until the
+	last matching unlock call.
+
+	Note that you may not blit to or from a locked surface.
+
+1.1.7:
+	The SDL_SetGammaRamp() and SDL_GetGammaRamp() functions now take
+	arrays of Uint16 values instead of Uint8 values.  For the most part,
+	you can just take your old values and shift them up 8 bits to get
+	new correct values for your gamma ramps.
+
+	You can pass SDL_RLEACCEL in flags passed to SDL_ConvertSurface()
+        and SDL will try to RLE accelerate colorkey and alpha blits in the
+	resulting surface.
+
+1.1.6:
+	Added a function to return the thread ID of a specific thread:
+		Uint32 SDL_GetThreadID(SDL_Thread *thread)
+	If 'thread' is NULL, this function returns the id for this thread.
+
+1.1.5:
+	The YUV overlay structure has been changed to use an array of
+	pitches and pixels representing the planes of a YUV image, to
+	better enable hardware acceleration.  The YV12 and IYUV formats
+	each have three planes, corresponding to the Y, U, and V portions
+	of the image, while packed pixel YUV formats just have one plane.
+
+	For palettized mode (8bpp), the screen colormap is now split in
+	a physical and a logical palette. The physical palette determines
+	what colours the screen pixels will get when displayed, and the
+	logical palette controls the mapping from blits to/from the screen.
+	A new function, SDL_SetPalette() has been added to change
+	logical and physical palettes separately. SDL_SetColors() works
+	just as before, and is equivalent to calling SDL_SetPalette() with
+	a flag argument of (SDL_LOGPAL|SDL_PHYSPAL).
+
+	SDL_BlitSurface() no longer modifies the source rectangle, only the
+	destination rectangle. The width/height members of the destination
+	rectangle are ignored, only the position is used.
+
+	The old source clipping function SDL_SetClipping() has been replaced
+	with a more useful function to set the destination clipping rectangle:
+		SDL_bool SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect)
+		
+	Added a function to see what subsystems have been initialized:
+		Uint32 SDL_WasInit(Uint32 flags)
+
+	The Big Alpha Flip: SDL now treats alpha as opacity like everybody
+	else, and not as transparency:
+
+	A new cpp symbol: SDL_ALPHA_OPAQUE is defined as 255
+	A new cpp symbol: SDL_ALPHA_TRANSPARENT is defined as 0
+	Values between 0 and 255 vary from fully transparent to fully opaque.
+
+	New functions:
+	SDL_DisplayFormatAlpha()
+	    Returns a surface converted to a format with alpha-channel
+	    that can be blit efficiently to the screen. (In other words,
+	    like SDL_DisplayFormat() but the resulting surface has
+	    an alpha channel.)  This is useful for surfaces with alpha.
+	SDL_MapRGBA()
+	    Works as SDL_MapRGB() but takes an additional alpha parameter.
+	SDL_GetRGBA()
+	    Works as SDL_GetRGB() but also returns the alpha value
+	    (SDL_ALPHA_OPAQUE for formats without an alpha channel)
+
+	Both SDL_GetRGB() and SDL_GetRGBA() now always return values in
+	the [0..255] interval. Previously, SDL_GetRGB() would return
+	(0xf8, 0xfc, 0xf8) for a completely white pixel in RGB565 format.
+	(N.B.: This is broken for bit fields < 3 bits.)
+
+	SDL_MapRGB() returns pixels in which the alpha channel is set opaque.
+
+	SDL_SetAlpha() can now be used for both setting the per-surface
+	alpha, using the new way of thinking of alpha, and also to enable
+	and disable per-pixel alpha blending for surfaces with an alpha
+	channel:
+		To disable alpha blending:
+			SDL_SetAlpha(surface, 0, 0);
+		To re-enable alpha blending:
+			SDL_SetAlpha(surface, SDL_SRCALPHA, 0);
+	Surfaces with an alpha channel have blending enabled by default.
+
+	SDL_SetAlpha() now accepts SDL_RLEACCEL as a flag, which requests
+	RLE acceleration of blits, just as like with SDL_SetColorKey().
+	This flag can be set for both surfaces with an alpha channel
+	and surfaces with an alpha value set by SDL_SetAlpha().
+	As always, RLE surfaces must be locked before pixel access is
+	allowed, and unlocked before any other SDL operations are done
+	on it.
+
+	The blit semantics for surfaces with and without alpha and colorkey
+	have now been defined:
+
+	RGBA->RGB:
+	    SDL_SRCALPHA set:
+		alpha-blend (using alpha-channel).
+		SDL_SRCCOLORKEY ignored.
+	    SDL_SRCALPHA not set:
+		copy RGB.
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		RGB values of the source colour key, ignoring alpha in the
+		comparison.
+
+	RGB->RGBA:
+	    SDL_SRCALPHA set:
+		alpha-blend (using the source per-surface alpha value);
+		set destination alpha to opaque.
+	    SDL_SRCALPHA not set:
+		copy RGB, set destination alpha to opaque.
+	    both:
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		source colour key.
+
+	RGBA->RGBA:
+	    SDL_SRCALPHA set:
+		alpha-blend (using the source alpha channel) the RGB values;
+		leave destination alpha untouched. [Note: is this correct?]
+		SDL_SRCCOLORKEY ignored.
+	    SDL_SRCALPHA not set:
+		copy all of RGBA to the destination.
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		RGB values of the source colour key, ignoring alpha in the
+		comparison.
+
+	RGB->RGB: 
+	    SDL_SRCALPHA set:
+		alpha-blend (using the source per-surface alpha value).
+	    SDL_SRCALPHA not set:
+		copy RGB.
+	    both:
+		if SDL_SRCCOLORKEY set, only copy the pixels matching the
+		source colour key.
+
+	As a special case, blits from surfaces with per-surface alpha
+	value of 128 (50% transparency) are optimised and much faster
+	than other alpha values. This does not apply to surfaces with
+	alpha channels (per-pixel alpha).
+
+	New functions for manipulating the gamma of the display have
+	been added:
+		int SDL_SetGamma(float red, float green, float blue);
+		int SDL_SetGammaRamp(Uint8 *red, Uint8 *green, Uint8 *blue);
+		int SDL_GetGammaRamp(Uint8 *red, Uint8 *green, Uint8 *blue);
+	Gamma ramps are tables with 256 entries which map the screen color
+	components into actually displayed colors.  For an example of
+	implementing gamma correction and gamma fades, see test/testgamma.c
+	Gamma control is not supported on all hardware.
+
+1.1.4:
+	The size of the SDL_CDtrack structure changed from 8 to 12 bytes
+	as the size of the length member was extended to 32 bits.
+
+        You can now use SDL for 2D blitting with a GL mode by passing the
+	SDL_OPENGLBLIT flag to SDL_SetVideoMode().  You can specify 16 or
+	32 bpp, and the data in the framebuffer is put into the GL scene
+	when you call SDL_UpdateRects(), and the scene will be visible
+	when you call SDL_GL_SwapBuffers().
+
+	Run the "testgl" test program with the -logo command line option
+	to see an example of this blending of 2D and 3D in SDL.
+
+1.1.3:
+	Added SDL_FreeRW() to the API, to complement SDL_AllocRW()
+
+	Added resizable window support - just add SDL_RESIZABLE to the
+	SDL_SetVideoMode() flags, and then wait for SDL_VIDEORESIZE events.
+	See SDL_events.h for details on the new SDL_ResizeEvent structure.
+
+	Added condition variable support, based on mutexes and semaphores.
+		SDL_CreateCond()
+		SDL_DestroyCond()
+		SDL_CondSignal()
+		SDL_CondBroadcast()
+		SDL_CondWait()
+		SDL_CondTimedWait()
+	The new function prototypes are in SDL_mutex.h
+
+	Added counting semaphore support, based on the mutex primitive.
+		SDL_CreateSemaphore()
+		SDL_DestroySemaphore()
+		SDL_SemWait()
+		SDL_SemTryWait()
+		SDL_SemWaitTimeout()
+		SDL_SemPost()
+		SDL_SemValue()
+	The new function prototypes are in SDL_mutex.h
+
+	Added support for asynchronous blitting.  To take advantage of this,
+	you must set the SDL_ASYNCBLIT flag when setting the video mode and
+	creating surfaces that you want accelerated in this way.  You must
+	lock surfaces that have this flag set, and the lock will block until
+	any queued blits have completed.
+
+	Added YUV video overlay support.
+	The supported YUV formats are: YV12, IYUV, YUY2, UYVY, and YVYU.
+	This function creates an overlay surface:
+		SDL_CreateYUVOverlay()
+	You must lock and unlock the overlay to get access to the data:
+		SDL_LockYUVOverlay() SDL_UnlockYUVOverlay()
+	You can then display the overlay:
+		SDL_DisplayYUVOverlay()
+	You must free the overlay when you are done using it:
+		SDL_FreeYUVOverlay()
+	See SDL_video.h for the full function prototypes.
+
+	The joystick hat position constants have been changed:
+	Old constant            New constant
+	------------            ------------
+	     0                  SDL_HAT_CENTERED
+	     1                  SDL_HAT_UP
+	     2                  SDL_HAT_RIGHTUP
+	     3                  SDL_HAT_RIGHT
+	     4                  SDL_HAT_RIGHTDOWN
+	     5                  SDL_HAT_DOWN
+	     6                  SDL_HAT_LEFTDOWN
+	     7                  SDL_HAT_LEFT
+	     8                  SDL_HAT_LEFTUP
+	The new constants are bitmasks, so you can check for the
+	individual axes like this:
+		if ( hat_position & SDL_HAT_UP ) {
+		}
+	and you'll catch left-up, up, and right-up.
+
+1.1.2:
+	Added multiple timer support:
+		SDL_AddTimer() and SDL_RemoveTimer()
+
+	SDL_WM_SetIcon() now respects the icon colorkey if mask is NULL.
+
+1.1.0:
+	Added initial OpenGL support.
+	First set GL attributes (such as RGB depth, alpha depth, etc.)
+		SDL_GL_SetAttribute()
+	Then call SDL_SetVideoMode() with the SDL_OPENGL flag.
+	Perform all of your normal GL drawing.
+	Finally swap the buffers with the new SDL function:
+		SDL_GL_SwapBuffers()
+	See the new 'testgl' test program for an example of using GL with SDL.
+
+	You can load GL extension functions by using the function:
+		SDL_GL_LoadProcAddress()
+
+	Added functions to initialize and cleanup specific SDL subsystems:
+		SDL_InitSubSystem() and SDL_QuitSubSystem()
+
+	Added user-defined event type:
+		typedef struct {
+        		Uint8 type;
+        		int code;
+        		void *data1;
+        		void *data2;
+		} SDL_UserEvent;
+	This structure is in the "user" member of an SDL_Event.
+
+	Added a function to push events into the event queue:
+		SDL_PushEvent()
+
+	Example of using the new SDL user-defined events:
+	{
+		SDL_Event event;
+
+		event.type = SDL_USEREVENT;
+		event.user.code = my_event_code;
+		event.user.data1 = significant_data;
+		event.user.data2 = 0;
+		SDL_PushEvent(&event);
+	}
+
+	Added a function to get mouse deltas since last query:
+		SDL_GetRelativeMouseState()
+
+	Added a boolean datatype to SDL_types.h:
+		SDL_bool = { SDL_TRUE, SDL_FALSE }
+
+	Added a function to get the current audio status:
+		SDL_GetAudioState();
+	It returns one of:
+		SDL_AUDIO_STOPPED,
+		SDL_AUDIO_PLAYING,
+		SDL_AUDIO_PAUSED
+
+	Added an AAlib driver (ASCII Art) - by Stephane Peter.
+
+1.0.6:
+	The input grab state is reset after each call to SDL_SetVideoMode().
+	The input is grabbed by default in fullscreen mode, and ungrabbed in
+	windowed mode.  If you want to set input grab to a particular value,
+	you should set it after each call to SDL_SetVideoMode().
+
+1.0.5:
+	Exposed SDL_AudioInit(), SDL_VideoInit()
+	Added SDL_AudioDriverName() and SDL_VideoDriverName()
+
+	Added new window manager function:
+		SDL_WM_ToggleFullScreen()
+	This is currently implemented only on Linux
+
+	The ALT-ENTER code has been removed - it's not appropriate for a
+	lib to bind keys when they aren't even emergency escape sequences.
+
+	ALT-ENTER functionality can be implemented with the following code:
+
+	int Handle_AltEnter(const SDL_Event *event)
+	{
+	    if ( event->type == SDL_KEYDOWN ) {
+	        if ( (event->key.keysym.sym == SDLK_RETURN) &&
+	             (event->key.keysym.mod & KMOD_ALT) ) {   
+	                SDL_WM_ToggleFullScreen(SDL_GetVideoSurface());
+	                return(0);
+	        }
+	    }
+	    return(1);
+	}
+	SDL_SetEventFilter(Handle_AltEnter);
+
+1.0.3:
+	Under X11, if you grab the input and hide the mouse cursor,
+	the mouse will go into a "relative motion" mode where you
+	will always get relative motion events no matter how far in
+	each direction you move the mouse - relative motion is not
+	bounded by the edges of the window (though the absolute values
+	of the mouse positions are clamped by the size of the window).
+	The SVGAlib, framebuffer console, and DirectInput drivers all
+	have this behavior naturally, and the GDI and BWindow drivers
+	never go into "relative motion" mode.
+
+1.0.2:
+	Added a function to enable keyboard repeat:
+		SDL_EnableKeyRepeat()
+
+	Added a function to grab the mouse and keyboard input
+		SDL_WM_GrabInput()
+
+	Added a function to iconify the window.
+		SDL_WM_IconifyWindow()
+	If this function succeeds, the application will receive an event
+	signaling SDL_APPACTIVE event 
+
+1.0.1:
+	Added constants to SDL_audio.h for 16-bit native byte ordering:
+		AUDIO_U16SYS, AUDIO_S16SYS
+
+1.0.0:
+	New public release
+
+Version 0.11:
+
+0.11.5:
+	A new function SDL_GetVideoSurface() has been added, and returns
+	a pointer to the current display surface.
+
+	SDL_AllocSurface() has been renamed SDL_CreateRGBSurface(), and
+	a new function SDL_CreateRGBSurfaceFrom() has been added to allow
+	creating an SDL surface from an existing pixel data buffer.
+
+	Added SDL_GetRGB() to the headers and documentation.
+
+0.11.4:
+	SDL_SetLibraryPath() is no longer meaningful, and has been removed.
+
+0.11.3:
+	A new flag for SDL_Init(), SDL_INIT_NOPARACHUTE, prevents SDL from
+	installing fatal signal handlers on operating systems that support
+	them.
+
+Version 0.9:
+
+0.9.15:
+	SDL_CreateColorCursor() has been removed.  Color cursors should
+	be implemented as sprites, blitted by the application when the
+	cursor moves.  To get smooth color cursor updates when the app
+	is busy, pass the SDL_INIT_EVENTTHREAD flag to SDL_Init().  This
+	allows you to handle the mouse motion in another thread from an
+	event filter function, but is currently only supported by Linux
+	and BeOS.  Note that you'll have to protect the display surface
+	from multi-threaded access by using mutexes if you do this.
+
+	Thread-safe surface support has been removed from SDL.
+	This makes blitting somewhat faster, by removing SDL_MiddleBlit().
+	Code that used SDL_MiddleBlit() should use SDL_LowerBlit() instead.
+	You can make your surfaces thread-safe by allocating your own
+	mutex and making lock/unlock calls around accesses to your surface.
+
+0.9.14:
+	SDL_GetMouseState() now takes pointers to int rather than Uint16.
+
+	If you set the SDL_WINDOWID environment variable under UNIX X11,
+	SDL will use that as the main window instead of creating it's own.
+	This is an unsupported extension to SDL, and not portable at all.
+
+0.9.13:
+	Added a function SDL_SetLibraryPath() which can be used to specify
+	the directory containing the SDL dynamic libraries.  This is useful
+	for commercial applications which ship with particular versions
+	of the libraries, and for security on multi-user systems.
+	If this function is not used, the default system directories are 
+	searched using the native dynamic object loading mechanism.
+
+	In order to support C linkage under Visual C++, you must declare
+	main() without any return type:
+		main(int argc, char *argv[]) {
+			/* Do the program... */
+			return(0);
+		}
+	C++ programs should also return a value if compiled under VC++.
+
+	The blit_endian member of the SDL_VideoInfo struct has been removed.
+
+	SDL_SymToASCII() has been replaced with SDL_GetKeyName(), so there
+	is now no longer any function to translate a keysym to a character.
+
+	The SDL_keysym structure has been extended with a 'scancode' and
+	'unicode' member.  The 'scancode' is a hardware specific scancode
+	for the key that was pressed, and may be 0.  The 'unicode' member
+	is a 16-bit UNICODE translation of the key that was pressed along
+	with any modifiers or compose keys that have been pressed.
+	If no UNICODE translation exists for the key, 'unicode' will be 0.
+
+	Added a function SDL_EnableUNICODE() to enable/disable UNICODE
+	translation of character keypresses.  Translation defaults off.
+
+	To convert existing code to use the new API, change code which
+	uses SDL_SymToASCII() to get the keyname to use SDL_GetKeyName(),
+	and change code which uses it to get the ASCII value of a sym to
+	use the 'unicode' member of the event keysym.
+
+0.9.12:
+	There is partial support for 64-bit datatypes.  I don't recommend 
+	you use this if you have a choice, because 64-bit datatypes are not
+	supported on many platforms.  On platforms for which it is supported,
+	the SDL_HAS_64BIT_TYPE C preprocessor define will be enabled, and
+	you can use the Uint64 and Sint64 datatypes.
+
+	Added functions to SDL_endian.h to support 64-bit datatypes:
+	    SDL_SwapLE64(), SDL_SwapBE64(),
+	    SDL_ReadLE64(), SDL_ReadBE64(), SDL_WriteLE64(), SDL_WriteBE64()
+
+	A new member "len_ratio" has been added to the SDL_AudioCVT structure,
+	and allows you to determine either the original buffer length or the
+	converted buffer length, given the other.
+
+	A new function SDL_FreeWAV() has been added to the API to free data
+	allocated by SDL_LoadWAV_RW().  This is necessary under Win32 since
+	the gcc compiled DLL uses a different heap than VC++ compiled apps.
+
+	SDL now has initial support for international keyboards using the
+	Latin character set.
+	If a particular mapping is desired, you can set the DEFAULT_KEYBOARD
+	compile-time variable, or you can set the environment variable 
+	"SDL_KEYBOARD" to a string identifying the keyboard mapping you desire.
+	The valid values for these variables can be found in SDL_keyboard.c
+
+	Full support for German and French keyboards under X11 is implemented.
+
+0.9.11:
+	The THREADED_EVENTS compile-time define has been replaced with the
+	SDL_INIT_EVENTTHREAD flag.  If this flag is passed to SDL_Init(),
+	SDL will create a separate thread to perform input event handling.
+	If this flag is passed to SDL_Init(), and the OS doesn't support 
+	event handling in a separate thread, SDL_Init() will fail.
+	Be sure to add calls to SDL_Delay() in your main thread to allow
+	the OS to schedule your event thread, or it may starve, leading
+	to slow event delivery and/or dropped events.
+	Currently MacOS and Win32 do not support this flag, while BeOS 
+	and Linux do support it.  I recommend that your application only
+	use this flag if absolutely necessary.
+
+	The SDL thread function passed to SDL_CreateThread() now returns a
+	status.  This status can be retrieved by passing a non-NULL pointer
+	as the 'status' argument to SDL_WaitThread().
+
+	The volume parameter to SDL_MixAudio() has been increased in range
+	from (0-8) to (0-128)
+
+	SDL now has a data source abstraction which can encompass a file,
+	an area of memory, or any custom object you can envision.  It uses
+	these abstractions, SDL_RWops, in the endian read/write functions,
+	and the built-in WAV and BMP file loaders.  This means you can load
+	WAV chunks from memory mapped files, compressed archives, network
+	pipes, or anything else that has a data read abstraction.
+
+	There are three built-in data source abstractions:
+	    SDL_RWFromFile(), SDL_RWFromFP(), SDL_RWFromMem()
+	along with a generic data source allocation function:
+	    SDL_AllocRW()
+	These data sources can be used like stdio file pointers with the
+	following convenience functions:
+	    SDL_RWseek(), SDL_RWread(), SDL_RWwrite(), SDL_RWclose()
+	These functions are defined in the new header file "SDL_rwops.h"
+
+	The endian swapping functions have been turned into macros for speed
+	and SDL_CalculateEndian() has been removed.  SDL_endian.h now defines
+	SDL_BYTEORDER as either SDL_BIG_ENDIAN or SDL_LIL_ENDIAN depending on
+	the endianness of the host system.
+
+	The endian read/write functions now take an SDL_RWops pointer
+	instead of a stdio FILE pointer, to support the new data source
+	abstraction.
+
+	The SDL_*LoadWAV() functions have been replaced with a single
+	SDL_LoadWAV_RW() function that takes a SDL_RWops pointer as it's
+	first parameter, and a flag whether or not to automatically 
+	free it as the second parameter.  SDL_LoadWAV() is a macro for
+	backward compatibility and convenience:
+	    SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
+
+	The SDL_*LoadBMP()/SDL_*SaveBMP() functions have each been replaced
+	with a single function that takes a SDL_RWops pointer as it's
+	first parameter, and a flag whether or not to automatically 
+	free it as the second parameter.  SDL_LoadBMP() and SDL_SaveBMP()
+	are macros for backward compatibility and convenience:
+	    SDL_LoadBMP_RW(SDL_RWFromFile("sample.bmp", "rb"), 1, ...);
+	    SDL_SaveBMP_RW(SDL_RWFromFile("sample.bmp", "wb"), 1, ...);
+	Note that these functions use SDL_RWseek() extensively, and should
+	not be used on pipes or other non-seekable data sources.
+
+0.9.10:
+	The Linux SDL_SysWMInfo and SDL_SysWMMsg structures have been 
+	extended to support multiple types of display drivers, as well as
+        safe access to the X11 display when THREADED_EVENTS is enabled.
+        The new structures are documented in the SDL_syswm.h header file.
+
+	Thanks to John Elliott <jce@seasip.demon.co.uk>, the UK keyboard
+	should now work properly, as well as the "Windows" keys on US
+	keyboards.
+
+	The Linux CD-ROM code now reads the CD-ROM devices from /etc/fstab
+	instead of trying to open each block device on the system.
+	The CD must be listed in /etc/fstab as using the iso9660 filesystem.
+
+	On Linux, if you define THREADED_EVENTS at compile time, a separate
+	thread will be spawned to gather X events asynchronously from the
+	graphics updates.  This hasn't been extensively tested, but it does
+	provide a means of handling keyboard and mouse input in a separate
+	thread from the graphics thread.  (This is now enabled by default.)
+
+	A special access function SDL_PeepEvents() allows you to manipulate
+	the event queue in a thread-safe manner, including peeking at events,
+	removing events of a specified type, and adding new events of arbitrary
+	type to the queue (use the new 'user' member of the SDL_Event type).
+
+	If you use SDL_PeepEvents() to gather events, then the main graphics
+	thread needs to call SDL_PumpEvents() periodically to drive the event
+	loop and generate input events.  This is not necessary if SDL has been 
+	compiled with THREADED_EVENTS defined, but doesn't hurt.
+
+	A new function SDL_ThreadID() returns the identifier associated with
+	the current thread.
+
+0.9.9:
+	The AUDIO_STEREO format flag has been replaced with a new 'channels'
+	member of the SDL_AudioSpec structure.  The channels are 1 for mono
+	audio, and 2 for stereo audio.  In the future more channels may be
+	supported for 3D surround sound.
+
+	The SDL_MixAudio() function now takes an additional volume parameter,
+	which should be set to SDL_MIX_MAXVOLUME for compatibility with the
+	original function.
+
+	The CD-ROM functions which take a 'cdrom' parameter can now be
+	passed NULL, and will act on the last successfully opened CD-ROM.
+
+0.9.8:
+	No changes, bugfixes only.
+	
+0.9.7:
+	No changes, bugfixes only.
+	
+0.9.6:
+	Added a fast rectangle fill function: SDL_FillRect()
+
+	Addition of a useful function for getting info on the video hardware:
+	    const SDL_VideoInfo *SDL_GetVideoInfo(void)
+        This function replaces SDL_GetDisplayFormat().
+
+	Initial support for double-buffering:
+	  Use the SDL_DOUBLEBUF flag in SDL_SetVideoMode()
+	  Update the screen with a new function: SDL_Flip()
+
+	SDL_AllocSurface() takes two new flags:
+	SDL_SRCCOLORKEY means that the surface will be used for colorkey blits
+	  and if the hardware supports hardware acceleration of colorkey blits
+	  between two surfaces in video memory, to place the surface in video
+	  memory if possible, otherwise it will be placed in system memory.
+	SDL_SRCALPHA means that the surface will be used for alpha blits and
+	  if the hardware supports hardware acceleration of alpha blits between
+	  two surfaces in video memory, to place the surface in video memory
+	  if possible, otherwise it will be placed in system memory.
+	SDL_HWSURFACE now means that the surface will be created with the 
+	  same format as the display surface, since having surfaces in video
+	  memory is only useful for fast blitting to the screen, and you can't
+	  blit surfaces with different surface formats in video memory.
+
+0.9.5:
+	You can now pass a NULL mask to SDL_WM_SetIcon(), and it will assume
+	that the icon consists of the entire image.
+
+	SDL_LowerBlit() is back -- but don't use it on the display surface.
+	It is exactly the same as SDL_MiddleBlit(), but doesn't check for
+	thread safety.
+
+	Added SDL_FPLoadBMP(), SDL_FPSaveBMP(), SDL_FPLoadWAV(), which take
+	a FILE pointer instead of a file name.
+
+	Added CD-ROM audio control API:
+	    SDL_CDNumDrives()
+	    SDL_CDName()
+	    SDL_CDOpen()
+	    SDL_CDStatus()
+	    SDL_CDPlayTracks()
+	    SDL_CDPlay()
+	    SDL_CDPause()
+	    SDL_CDResume()
+	    SDL_CDStop()
+	    SDL_CDEject()
+	    SDL_CDClose()
+
+0.9.4:
+	No changes, bugfixes only.
+
+0.9.3:
+	Mouse motion event now includes relative motion information:
+	    Sint16 event->motion.xrel, Sint16 event->motion.yrel
+
+	X11 keyrepeat handling can be disabled by defining IGNORE_X_KEYREPEAT
+	    (Add -DIGNORE_X_KEYREPEAT to CFLAGS line in obj/x11Makefile)
+
+0.9.2:
+	No changes, bugfixes only.
+
+0.9.1:
+	Removed SDL_MapSurface() and SDL_UnmapSurface() -- surfaces are now
+	automatically mapped on blit.
+
+0.8.0:
+	SDL stable release
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/acinclude.m4	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,619 @@
+# Local macros for the SDL configure.in script
+
+dnl Function to link an architecture specific file
+dnl LINK_ARCH_SRC(source_dir, arch, source_file)
+AC_DEFUN(COPY_ARCH_SRC,
+[
+  echo "Copying $1/$2/$3 -> $1/$3"
+  old="$srcdir/$1/$2/$3"
+  new="$srcdir/$1/$3"
+  cat >$new <<__EOF__
+/* WARNING:  This file was automatically generated!
+ * Original: $old
+ */
+__EOF__
+  cat >>$new <$old
+])
+
+#
+# --- esd.m4 ---
+#
+# Configure paths for ESD
+# Manish Singh    98-9-30
+# stolen back from Frank Belew
+# stolen from Manish Singh
+# Shamelessly stolen from Owen Taylor
+
+dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
+dnl
+AC_DEFUN(AM_PATH_ESD,
+[dnl 
+dnl Get the cflags and libraries from the esd-config script
+dnl
+AC_ARG_WITH(esd-prefix,[  --with-esd-prefix=PFX   Prefix where ESD is installed (optional)],
+            esd_prefix="$withval", esd_prefix="")
+AC_ARG_WITH(esd-exec-prefix,[  --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)],
+            esd_exec_prefix="$withval", esd_exec_prefix="")
+AC_ARG_ENABLE(esdtest, [  --disable-esdtest       Do not try to compile and run a test ESD program],
+		    , enable_esdtest=yes)
+
+  if test x$esd_exec_prefix != x ; then
+     esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
+     if test x${ESD_CONFIG+set} != xset ; then
+        ESD_CONFIG=$esd_exec_prefix/bin/esd-config
+     fi
+  fi
+  if test x$esd_prefix != x ; then
+     esd_args="$esd_args --prefix=$esd_prefix"
+     if test x${ESD_CONFIG+set} != xset ; then
+        ESD_CONFIG=$esd_prefix/bin/esd-config
+     fi
+  fi
+
+  AC_PATH_PROG(ESD_CONFIG, esd-config, no)
+  min_esd_version=ifelse([$1], ,0.2.7,$1)
+  AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
+  no_esd=""
+  if test "$ESD_CONFIG" = "no" ; then
+    no_esd=yes
+  else
+    ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
+    ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
+
+    esd_major_version=`$ESD_CONFIG $esd_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    esd_minor_version=`$ESD_CONFIG $esd_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+    if test "x$enable_esdtest" = "xyes" ; then
+      ac_save_CFLAGS="$CFLAGS"
+      ac_save_LIBS="$LIBS"
+      CFLAGS="$CFLAGS $ESD_CFLAGS"
+      LIBS="$LIBS $ESD_LIBS"
+dnl
+dnl Now check if the installed ESD is sufficiently new. (Also sanity
+dnl checks the results of esd-config to some extent
+dnl
+      rm -f conf.esdtest
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <esd.h>
+
+char*
+my_strdup (char *str)
+{
+  char *new_str;
+  
+  if (str)
+    {
+      new_str = malloc ((strlen (str) + 1) * sizeof(char));
+      strcpy (new_str, str);
+    }
+  else
+    new_str = NULL;
+  
+  return new_str;
+}
+
+int main ()
+{
+  int major, minor, micro;
+  char *tmp_version;
+
+  system ("touch conf.esdtest");
+
+  /* HP/UX 9 (%@#!) writes to sscanf strings */
+  tmp_version = my_strdup("$min_esd_version");
+  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+     printf("%s, bad version string\n", "$min_esd_version");
+     exit(1);
+   }
+
+   if (($esd_major_version > major) ||
+      (($esd_major_version == major) && ($esd_minor_version > minor)) ||
+      (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
+    {
+      return 0;
+    }
+  else
+    {
+      printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
+      printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
+      printf("*** best to upgrade to the required version.\n");
+      printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
+      printf("*** to point to the correct copy of esd-config, and remove the file\n");
+      printf("*** config.cache before re-running configure\n");
+      return 1;
+    }
+}
+
+],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+  fi
+  if test "x$no_esd" = x ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$2], , :, [$2])     
+  else
+     AC_MSG_RESULT(no)
+     if test "$ESD_CONFIG" = "no" ; then
+       echo "*** The esd-config script installed by ESD could not be found"
+       echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
+       echo "*** your path, or set the ESD_CONFIG environment variable to the"
+       echo "*** full path to esd-config."
+     else
+       if test -f conf.esdtest ; then
+        :
+       else
+          echo "*** Could not run ESD test program, checking why..."
+          CFLAGS="$CFLAGS $ESD_CFLAGS"
+          LIBS="$LIBS $ESD_LIBS"
+          AC_TRY_LINK([
+#include <stdio.h>
+#include <esd.h>
+],      [ return 0; ],
+        [ echo "*** The test program compiled, but did not run. This usually means"
+          echo "*** that the run-time linker is not finding ESD or finding the wrong"
+          echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
+          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+          echo "*** is required on your system"
+	  echo "***"
+          echo "*** If you have an old version installed, it is best to remove it, although"
+          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+        [ echo "*** The test program failed to compile or link. See the file config.log for the"
+          echo "*** exact error that occured. This usually means ESD was incorrectly installed"
+          echo "*** or that you have moved ESD since it was installed. In the latter case, you"
+          echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
+          CFLAGS="$ac_save_CFLAGS"
+          LIBS="$ac_save_LIBS"
+       fi
+     fi
+     ESD_CFLAGS=""
+     ESD_LIBS=""
+     ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(ESD_CFLAGS)
+  AC_SUBST(ESD_LIBS)
+  rm -f conf.esdtest
+])
+
+## libtool.m4 - Configure libtool for the target system. -*-Shell-script-*-
+## Copyright (C) 1996-1999, 2000 Free Software Foundation, Inc.
+## Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+##
+## This program is free software; you can redistribute it and/or modify
+## it under the terms of the GNU General Public License as published by
+## the Free Software Foundation; either version 2 of the License, or
+## (at your option) any later version.
+##
+## This program is distributed in the hope that it will be useful, but
+## WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+## General Public License for more details.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+##
+## As a special exception to the GNU General Public License, if you
+## distribute this file as part of a program that contains a
+## configuration script generated by Autoconf, you may include it under
+## the same distribution terms that you use for the rest of that program.
+
+# serial 40 AC_PROG_LIBTOOL
+AC_DEFUN(AC_PROG_LIBTOOL,
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+
+# Save cache, so that ltconfig can load it
+AC_CACHE_SAVE
+
+# Actually configure libtool.  ac_aux_dir is where install-sh is found.
+CC="$CC" CFLAGS="$CFLAGS" CPPFLAGS="$CPPFLAGS" \
+LD="$LD" LDFLAGS="$LDFLAGS" LIBS="$LIBS" \
+LN_S="$LN_S" NM="$NM" RANLIB="$RANLIB" \
+DLLTOOL="$DLLTOOL" AS="$AS" OBJDUMP="$OBJDUMP" \
+${CONFIG_SHELL-/bin/sh} $ac_aux_dir/ltconfig --no-reexec \
+$libtool_flags --no-verify $ac_aux_dir/ltmain.sh $lt_target \
+|| AC_MSG_ERROR([libtool configure failed])
+
+# Reload cache, that may have been modified by ltconfig
+AC_CACHE_LOAD
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltconfig $ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Redirect the config.log output again, so that the ltconfig log is not
+# clobbered by the next message.
+exec 5>>./config.log
+])
+
+AC_DEFUN(AC_LIBTOOL_SETUP,
+[AC_PREREQ(2.13)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_RANLIB])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+dnl
+
+case "$target" in
+NONE) lt_target="$host" ;;
+*) lt_target="$target" ;;
+esac
+
+# Check for any special flags to pass to ltconfig.
+libtool_flags="--cache-file=$cache_file"
+test "$enable_shared" = no && libtool_flags="$libtool_flags --disable-shared"
+test "$enable_static" = no && libtool_flags="$libtool_flags --disable-static"
+test "$enable_fast_install" = no && libtool_flags="$libtool_flags --disable-fast-install"
+test "$ac_cv_prog_gcc" = yes && libtool_flags="$libtool_flags --with-gcc"
+test "$ac_cv_prog_gnu_ld" = yes && libtool_flags="$libtool_flags --with-gnu-ld"
+ifdef([AC_PROVIDE_AC_LIBTOOL_DLOPEN],
+[libtool_flags="$libtool_flags --enable-dlopen"])
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[libtool_flags="$libtool_flags --enable-win32-dll"])
+AC_ARG_ENABLE(libtool-lock,
+  [  --disable-libtool-lock  avoid locking (might break parallel builds)])
+test "x$enable_libtool_lock" = xno && libtool_flags="$libtool_flags --disable-lock"
+test x"$silent" = xyes && libtool_flags="$libtool_flags --silent"
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case "$lt_target" in
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case "`/usr/bin/file conftest.o`" in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+ifdef([AC_PROVIDE_AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+])
+esac
+])
+
+# AC_LIBTOOL_DLOPEN - enable checks for dlopen support
+AC_DEFUN(AC_LIBTOOL_DLOPEN, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])])
+
+# AC_LIBTOOL_WIN32_DLL - declare package support for building win32 dll's
+AC_DEFUN(AC_LIBTOOL_WIN32_DLL, [AC_BEFORE([$0], [AC_LIBTOOL_SETUP])])
+
+# AC_ENABLE_SHARED - implement the --enable-shared flag
+# Usage: AC_ENABLE_SHARED[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_SHARED, [dnl
+define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(shared,
+changequote(<<, >>)dnl
+<<  --enable-shared[=PKGS]  build shared libraries [default=>>AC_ENABLE_SHARED_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_shared=yes ;;
+no) enable_shared=no ;;
+*)
+  enable_shared=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_shared=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_shared=AC_ENABLE_SHARED_DEFAULT)dnl
+])
+
+# AC_DISABLE_SHARED - set the default shared flag to --disable-shared
+AC_DEFUN(AC_DISABLE_SHARED, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)])
+
+# AC_ENABLE_STATIC - implement the --enable-static flag
+# Usage: AC_ENABLE_STATIC[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_STATIC, [dnl
+define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(static,
+changequote(<<, >>)dnl
+<<  --enable-static[=PKGS]  build static libraries [default=>>AC_ENABLE_STATIC_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_static=yes ;;
+no) enable_static=no ;;
+*)
+  enable_static=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_static=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_static=AC_ENABLE_STATIC_DEFAULT)dnl
+])
+
+# AC_DISABLE_STATIC - set the default static flag to --disable-static
+AC_DEFUN(AC_DISABLE_STATIC, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)])
+
+
+# AC_ENABLE_FAST_INSTALL - implement the --enable-fast-install flag
+# Usage: AC_ENABLE_FAST_INSTALL[(DEFAULT)]
+#   Where DEFAULT is either `yes' or `no'.  If omitted, it defaults to
+#   `yes'.
+AC_DEFUN(AC_ENABLE_FAST_INSTALL, [dnl
+define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE(fast-install,
+changequote(<<, >>)dnl
+<<  --enable-fast-install[=PKGS]  optimize for fast installation [default=>>AC_ENABLE_FAST_INSTALL_DEFAULT],
+changequote([, ])dnl
+[p=${PACKAGE-default}
+case "$enableval" in
+yes) enable_fast_install=yes ;;
+no) enable_fast_install=no ;;
+*)
+  enable_fast_install=no
+  # Look at the argument we got.  We use all the common list separators.
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
+  for pkg in $enableval; do
+    if test "X$pkg" = "X$p"; then
+      enable_fast_install=yes
+    fi
+  done
+  IFS="$ac_save_ifs"
+  ;;
+esac],
+enable_fast_install=AC_ENABLE_FAST_INSTALL_DEFAULT)dnl
+])
+
+# AC_ENABLE_FAST_INSTALL - set the default to --disable-fast-install
+AC_DEFUN(AC_DISABLE_FAST_INSTALL, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)])
+
+# AC_PROG_LD - find the path to the GNU or non-GNU linker
+AC_DEFUN(AC_PROG_LD,
+[AC_ARG_WITH(gnu-ld,
+[  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
+test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$ac_cv_prog_gcc" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by GCC])
+  ac_prog=`($CC -print-prog-name=ld | tr -d '\r') 2>&5`
+  case "$ac_prog" in
+    # Accept absolute paths.
+changequote(,)dnl
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+changequote([,])dnl
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(ac_cv_path_LD,
+[if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      ac_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$ac_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  ac_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$ac_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])
+
+AC_DEFUN(AC_PROG_LD_GNU,
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], ac_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  ac_cv_prog_gnu_ld=yes
+else
+  ac_cv_prog_gnu_ld=no
+fi])
+])
+
+# AC_PROG_NM - find the path to a BSD-compatible name lister
+AC_DEFUN(AC_PROG_NM,
+[AC_MSG_CHECKING([for BSD-compatible nm])
+AC_CACHE_VAL(ac_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  ac_cv_path_NM="$NM"
+else
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	ac_cv_path_NM="$ac_dir/nm -B"
+	break
+      elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	ac_cv_path_NM="$ac_dir/nm -p"
+	break
+      else
+	ac_cv_path_NM=${ac_cv_path_NM="$ac_dir/nm"} # keep the first match, but
+	continue # so that we can try to find one that supports BSD flags
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+  test -z "$ac_cv_path_NM" && ac_cv_path_NM=nm
+fi])
+NM="$ac_cv_path_NM"
+AC_MSG_RESULT([$NM])
+])
+
+# AC_CHECK_LIBM - check for math library
+AC_DEFUN(AC_CHECK_LIBM,
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case "$lt_target" in
+*-*-beos* | *-*-cygwin*)
+  # These system don't have libm
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, main, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, main, LIBM="-lm")
+  ;;
+esac
+])
+
+# AC_LIBLTDL_CONVENIENCE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl convenience library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-convenience to the
+# configure arguments.  Note that LIBLTDL and INCLTDL are not
+# AC_SUBSTed, nor is AC_CONFIG_SUBDIRS called.  If DIR is not
+# provided, it is assumed to be `libltdl'.  LIBLTDL will be prefixed
+# with '${top_builddir}/' and INCLTDL will be prefixed with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+AC_DEFUN(AC_LIBLTDL_CONVENIENCE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case "$enable_ltdl_convenience" in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+])
+
+# AC_LIBLTDL_INSTALLABLE[(dir)] - sets LIBLTDL to the link flags for
+# the libltdl installable library and INCLTDL to the include flags for
+# the libltdl header and adds --enable-ltdl-install to the configure
+# arguments.  Note that LIBLTDL and INCLTDL are not AC_SUBSTed, nor is
+# AC_CONFIG_SUBDIRS called.  If DIR is not provided and an installed
+# libltdl is not found, it is assumed to be `libltdl'.  LIBLTDL will
+# be prefixed with '${top_builddir}/' and INCLTDL will be prefixed
+# with '${top_srcdir}/' (note the single quotes!).  If your package is
+# not flat and you're not using automake, define top_builddir and
+# top_srcdir appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN(AC_LIBLTDL_INSTALLABLE, [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, main,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    INCLTDL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    INCLTDL=
+  fi
+])
+
+dnl old names
+AC_DEFUN(AM_PROG_LIBTOOL, [indir([AC_PROG_LIBTOOL])])dnl
+AC_DEFUN(AM_ENABLE_SHARED, [indir([AC_ENABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_ENABLE_STATIC, [indir([AC_ENABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_DISABLE_SHARED, [indir([AC_DISABLE_SHARED], $@)])dnl
+AC_DEFUN(AM_DISABLE_STATIC, [indir([AC_DISABLE_STATIC], $@)])dnl
+AC_DEFUN(AM_PROG_LD, [indir([AC_PROG_LD])])dnl
+AC_DEFUN(AM_PROG_NM, [indir([AC_PROG_NM])])dnl
+
+dnl This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])dnl
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/autogen.sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+#!/bin/sh
+#
+echo "Generating build information using aclocal, automake and autoconf"
+echo "This may take a while ..."
+
+# Touch the timestamps on all the files since CVS messes them up
+directory=`dirname $0`
+touch $directory/configure.in
+
+# Regenerate configuration files
+aclocal
+automake --foreign --include-deps
+autoconf
+(cd test; aclocal; automake --foreign --include-deps; autoconf)
+
+# Run configure for this platform
+#./configure $*
+echo "Now you are ready to run ./configure"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.guess	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1368 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-03-16'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 93, 94, 95, 96, 97, 98, 99, 2000
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script.
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int dummy(){}" > $dummy.c
+	for c in cc gcc c89 ; do
+	  ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1
+	  if test $? = 0 ; then
+	     CC_FOR_BUILD="$c"; break
+	  fi
+	done
+	rm -f $dummy.c $dummy.o $dummy.rel
+	if test x"$CC_FOR_BUILD" = x ; then
+	  CC_FOR_BUILD=no_compiler_found
+	fi
+	;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-unknown ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format, if it has switched
+	# to ELF recently, or will in the future.
+	case "${UNAME_MACHINE}" in
+	    i386|sparc|amiga|arm*|hp300|mvme68k|vax|atari|luna68k|mac68k|news68k|next68k|pc532|sun3*|x68k)
+		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+			| grep __ELF__ >/dev/null
+		then
+		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+		    # Return netbsd for either.  FIX?
+		    os=netbsd
+		else
+		    os=netbsdelf
+		fi
+		;;
+	    *)
+	        os=netbsd
+		;;
+	esac
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
+    alpha:OSF1:*:*)
+	if test $UNAME_RELEASE = "V4.0"; then
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+	fi
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
+	.globl main
+	.align 4
+	.ent main
+main:
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
+	.end main
+EOF
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+	if test "$?" = 0 ; then
+		case `./$dummy` in
+			0-0)
+				UNAME_MACHINE="alpha"
+				;;
+			1-0)
+				UNAME_MACHINE="alphaev5"
+				;;
+			1-1)
+				UNAME_MACHINE="alphaev56"
+				;;
+			1-101)
+				UNAME_MACHINE="alphapca56"
+				;;
+			2-303)
+				UNAME_MACHINE="alphaev6"
+				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
+		esac
+	fi
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit 0 ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit 0;;
+    amiga:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit 0 ;;
+    arc64:OpenBSD:*:*)
+	echo mips64el-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    arc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    hkmips:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pmax:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sgi:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit 0;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit 0 ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit 0 ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    i86pc:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit 0 ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit 0 ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    sun3*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mac68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit 0 ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy \
+	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit 0 ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit 0 ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit 0 ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit 0 ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit 0 ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit 0 ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i?86:AIX:*:*)
+	echo i386-ibm-aix
+	exit 0 ;;
+    ia64:AIX:*:*)
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+		rm -f $dummy.c $dummy
+		echo rs6000-ibm-aix3.2.5
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit 0 ;;
+    *:AIX:*:[45])
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+              case "${HPUX_REV}" in
+                11.[0-9][0-9])
+                  if [ -x /usr/bin/getconf ]; then
+                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                        esac ;;
+                    esac
+                  fi ;;
+              esac
+              if [ "${HP_ARCH}" = "" ]; then
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	if test -z "$HP_ARCH"; then HP_ARCH=hppa; fi
+	rm -f $dummy.c $dummy
+	fi ;;
+	esac
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    ia64:HP-UX:*:*)
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ia64-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    3050*:HI-UX:*:*)
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo unknown-hitachi-hiuxwe2
+	exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit 0 ;;
+    *9??*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit 0 ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit 0 ;;
+    i?86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit 0 ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit 0 ;;
+    hppa*:OpenBSD:*:*)
+	echo hppa-unknown-openbsd
+	exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+	echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE}
+	exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+	exit 0 ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3D:*:*:*)
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY-2:*:*:*)
+	echo cray2-cray-unicos
+        exit 0 ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    hp300:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:FreeBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit 0 ;;
+    *:OpenBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	exit 0 ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit 0 ;;
+    i*:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i386-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit 0 ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    *:GNU:*:*)
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
+    arm*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    ia64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux
+	exit 0 ;;
+    m68*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    mips:Linux:*:*)
+	cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+int main (int argc, char *argv[]) {
+#else
+int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+  printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+  printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	;;
+    ppc:Linux:*:*)
+	# Determine Lib Version
+	cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+     int argc;
+     char *argv[];
+{
+#if defined(__GLIBC__)
+  printf("%s %s\n", __libc_version, __libc_release);
+#else
+  printf("unknown\n");
+#endif
+  return 0;
+}
+EOF
+	LIBC=""
+	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+	if test "$?" = 0 ; then
+		./$dummy | grep 1\.99 > /dev/null
+		if test "$?" = 0 ; then LIBC="libc1" ; fi
+	fi
+	rm -f $dummy.c $dummy
+	echo powerpc-unknown-linux-gnu${LIBC}
+	exit 0 ;;
+    alpha:Linux:*:*)
+	cat <<EOF >$dummy.s
+	  .data
+	  \$Lformat:
+		.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+	   .text
+		.globl main
+		.align 4
+		.ent main
+	    main:
+		.frame \$30,16,\$26,0
+		ldgp \$29,0(\$27)
+		.prologue 1
+		.long 0x47e03d80 # implver \$0
+		lda \$2,-1
+		.long 0x47e20c21 # amask \$2,\$1
+		lda \$16,\$Lformat
+		mov \$0,\$17
+		not \$1,\$18
+		jsr \$26,printf
+		ldgp \$29,0(\$26)
+		mov 0,\$16
+		jsr \$26,exit
+		.end main
+EOF
+	LIBC=""
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+	if test "$?" = 0 ; then
+		case `./$dummy` in
+		0-0)	UNAME_MACHINE="alpha" ;;
+		1-0)	UNAME_MACHINE="alphaev5" ;;
+		1-1)    UNAME_MACHINE="alphaev56" ;;
+		1-101)	UNAME_MACHINE="alphapca56" ;;
+		2-303)	UNAME_MACHINE="alphaev6" ;;
+		2-307)	UNAME_MACHINE="alphaev67" ;;
+		esac
+		objdump --private-headers $dummy | \
+		  grep ld.so.1 > /dev/null
+		if test "$?" = 0 ; then
+			LIBC="libc1"
+		fi
+	fi
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+	exit 0 ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+	# Look for CPU level
+	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
+	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
+	  *)    echo hppa-unknown-linux-gnu ;;
+	esac
+	exit 0 ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+	echo hppa64-unknown-linux-gnu
+	exit 0 ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+	echo ${UNAME_MACHINE}-ibm-linux
+	exit 0 ;;
+    sh*:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+	echo ${UNAME_MACHINE}-unknown-linux-gnu
+	exit 0 ;;
+    x86_64:Linux:*:*)
+	echo x86_64-unknown-linux-gnu
+	exit 0 ;;
+    i?86:Linux:*:*)
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	ld_supported_emulations=`cd /; ld --help 2>&1 \
+			 | sed -ne '/supported emulations:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported emulations: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_emulations" in
+	  i?86linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0
+		;;
+	  elf_i?86)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  i?86coff)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0
+		;;
+	esac
+	# Either a pre-BFD a.out linker (linux-gnuoldld)
+	# or one that does not give us useful --help.
+	# GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+	# If ld does not provide *any* "supported emulations:"
+	# that means it is gnuoldld.
+	test -z "$ld_supported_emulations" && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+	case "${UNAME_MACHINE}" in
+	i?86)
+	  VENDOR=pc;
+	  ;;
+	*)
+	  VENDOR=unknown;
+	  ;;
+	esac
+	# Determine whether the default compiler is a.out or elf
+	cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+#  if __GLIBC__ >= 2
+    printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+#  else
+    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+#  endif
+# else
+   printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+  printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm -f $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+	;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+    i?86:DYNIX/ptx:4*:*)
+	echo i386-sequent-sysv4
+	exit 0 ;;
+    i?86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit 0 ;;
+    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit 0 ;;
+    i?86:*:5:7*)
+        # Fixed at (any) Pentium or better
+        UNAME_MACHINE=i586
+        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+	else
+	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+	fi
+	exit 0 ;;
+    i?86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit 0 ;;
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit 0 ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit 0 ;;
+    M68*:*:R3V[567]*:*)
+	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit 0 ;;
+    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    rs6000:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:*)
+	echo powerpc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit 0 ;;
+    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                           # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes@openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit 0 ;;
+    *:*:*:FTX*)
+	# From seanf@swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit 0 ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit 0 ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit 0 ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit 0 ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    *:NonStop-UX:*:*)
+	echo mips-compaq-nonstopux
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
+    i?86:OS/2:*:*)
+	# If we were able to find `uname', then EMX Unix compatibility
+	# is probably installed.
+	echo ${UNAME_MACHINE}-pc-os2-emx
+	exit 0 ;;
+    *:TOPS-10:*:*)
+	echo pdp10-unknown-tops10
+	exit 0 ;;
+    *:TENEX:*:*)
+	echo pdp10-unknown-tenex
+	exit 0 ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+	echo pdp10-dec-tops20
+	exit 0 ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+	echo pdp10-xkl-tops20
+	exit 0 ;;
+    *:TOPS-20:*:*)
+	echo pdp10-unknown-tops20
+	exit 0 ;;
+    *:ITS:*:*)
+	echo pdp10-unknown-its
+	exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm -f $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit 0 ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit 0 ;;
+    c34*)
+	echo c34-convex-bsd
+	exit 0 ;;
+    c38*)
+	echo c38-convex-bsd
+	exit 0 ;;
+    c4*)
+	echo c4-convex-bsd
+	exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/config.sub	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1357 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+#   Free Software Foundation, Inc.
+
+timestamp='2001-03-19'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit 0 ;;
+    --version | -v )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | storm-chaos* | os2-emx*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc \
+	        | arm | arme[lb] | arm[bl]e | armv[2345] | armv[345][lb] | strongarm | xscale \
+		| pyramid | mn10200 | mn10300 | tron | a29k \
+		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle \
+		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
+		| we32k | ns16k | clipper | i370 | sh | sh[34] \
+		| powerpc | powerpcle \
+		| 1750a | dsp16xx | pdp10 | pdp11 \
+		| mips16 | mips64 | mipsel | mips64el \
+		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
+		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+		| mips64vr5000 | miprs64vr5000el | mcore | s390 | s390x \
+		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+		| thumb | d10v | d30v | fr30 | avr | openrisc | tic80 \
+		| pj | pjl | h8500)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | w65)
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i[234567]86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | c[123]* \
+	      | arm-*  | armbe-* | armle-* | armv*-* | strongarm-* | xscale-* \
+	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+	      | xmp-* | ymp-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
+	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+	      | clipper-* | orion-* \
+	      | sparclite-* | pdp10-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+	      | mips64el-* | mips64orion-* | mips64orionel-* \
+	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f30[01]-* | f700-* | s390-* | s390x-* | sv1-* | t3e-* \
+	      | [cjt]90-* \
+	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+	      | thumb-* | v850-* | d30v-* | tic30-* | tic80-* | c30-* | fr30-* \
+	      | bs2000-* | tic54x-* | c54x-* | x86_64-* | pj-* | pjl-*)
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	cray2)
+		basic_machine=cray2-cray
+		os=-unicos
+		;;
+	[cjt]90)
+		basic_machine=${basic_machine}-cray
+		os=-unicos
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	go32)
+		basic_machine=i386-pc
+		os=-go32
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i[34567]86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i[34567]86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i[34567]86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i[34567]86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	mingw32)
+		basic_machine=i386-pc
+		os=-mingw32
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mipsel*-linux*)
+		basic_machine=mipsel-unknown
+		os=-linux-gnu
+		;;
+	mips*-linux*)
+		basic_machine=mips-unknown
+		os=-linux-gnu
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	msdos)
+		basic_machine=i386-pc
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	nonstopux)
+		basic_machine=mips-compaq
+		os=-nonstopux
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+        pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pentium | p5 | k5 | k6 | nexgen)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2)
+		basic_machine=i686-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexgen-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=power-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+	        ;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+	        ;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sparclite-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=t3e-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xmp)
+		basic_machine=xmp-cray
+		os=-unicos
+		;;
+        xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	mips)
+		if [ x$os = x-linux-gnu ]; then
+			basic_machine=mips-unknown
+		else
+			basic_machine=mips-mips
+		fi
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp10)
+		# there are many clones, so DEC is not a safe bet
+		basic_machine=pdp10-unknown
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh3 | sh4)
+		basic_machine=sh-unknown
+		;;
+	sparc | sparcv9)
+		basic_machine=sparc-sun
+		;;
+        cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	c4x*)
+		basic_machine=c4x-none
+		os=-coff
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+	      | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -os2*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-ns2 )
+	        os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+        -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+	        os=-mint
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+	pdp10-*)
+		os=-tops20
+		;;
+        pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-ibm)
+		os=-aix
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+        *-gould)
+		os=-sysv
+		;;
+        *-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+        *-sgi)
+		os=-irix
+		;;
+        *-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f30[01]-fujitsu | f700-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-vxsim* | -vxworks*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+				vendor=atari
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/configure.in	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1891 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(README)
+
+dnl Set various version strings - taken gratefully from the GTk sources
+#
+# Making releases:
+# Edit include/SDL/SDL_version.h and change the version, then:
+#   SDL_MICRO_VERSION += 1;
+#   SDL_INTERFACE_AGE += 1;
+#   SDL_BINARY_AGE += 1;
+# if any functions have been added, set SDL_INTERFACE_AGE to 0.
+# if backwards compatibility has been broken,
+# set SDL_BINARY_AGE and SDL_INTERFACE_AGE to 0.
+#
+SDL_MAJOR_VERSION=1
+SDL_MINOR_VERSION=2
+SDL_MICRO_VERSION=0
+SDL_INTERFACE_AGE=0
+SDL_BINARY_AGE=0
+SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
+
+AC_SUBST(SDL_MAJOR_VERSION)
+AC_SUBST(SDL_MINOR_VERSION)
+AC_SUBST(SDL_MICRO_VERSION)
+AC_SUBST(SDL_INTERFACE_AGE)
+AC_SUBST(SDL_BINARY_AGE)
+AC_SUBST(SDL_VERSION)
+
+# libtool versioning
+LT_RELEASE=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION
+LT_CURRENT=`expr $SDL_MICRO_VERSION - $SDL_INTERFACE_AGE`
+LT_REVISION=$SDL_INTERFACE_AGE
+LT_AGE=`expr $SDL_BINARY_AGE - $SDL_INTERFACE_AGE`
+
+AC_SUBST(LT_RELEASE)
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+
+dnl Setup for automake
+AM_INIT_AUTOMAKE(SDL, $SDL_VERSION)
+
+dnl Detect the canonical host and target build environment
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+dnl Check for tools
+
+AC_LIBTOOL_WIN32_DLL
+AM_PROG_LIBTOOL
+AC_PROG_MAKE_SET
+AC_PROG_CC
+AC_C_INLINE
+AC_C_CONST
+case "$target" in
+    *-*-beos*)
+        AC_PROG_CXX
+        ;;
+    *-*-aix*)
+        AC_PROG_CXX
+        ;;
+    # This is stupid, but necessary on some versions of Linux (joysticks)
+    *-*-linux*)
+        AC_PROG_CXX
+        ;;
+esac
+AC_PROG_INSTALL
+AC_FUNC_ALLOCA
+
+dnl The alpha architecture needs special flags for binary portability
+case "$target" in
+    alpha*-*-linux*)
+        if test x$ac_cv_prog_gcc = xyes; then
+            CFLAGS="$CFLAGS -mcpu=ev4 -Wa,-mall"
+        fi
+        ;;
+esac
+
+dnl Add compiler-specific optimization flags
+
+dnl See if the user wants aggressive optimizations of the code
+AC_ARG_ENABLE(debug,
+[  --enable-debug          Disable aggressive optimizations [default=yes]],
+              , enable_debug=yes)
+if test x$enable_debug != xyes; then
+    if test x$ac_cv_prog_gcc = xyes; then
+        CFLAGS="$CFLAGS -fexpensive-optimizations"
+        # Ack! This breaks the MMX YV12 conversion on gcc 2.95.2
+        # CFLAGS="$CFLAGS -fomit-frame-pointer"
+    fi
+    case "$target" in
+        i486-*-*)
+            if test x$ac_cv_prog_gcc = xyes; then
+                CFLAGS="$CFLAGS -march=486"
+            fi
+            ;;
+        i?86-*-*)
+            if test x$ac_cv_prog_gcc = xyes; then
+                CFLAGS="$CFLAGS -march=pentium -mcpu=pentiumpro"
+            fi
+            ;;
+        *-*-osf*)
+            if test x$ac_cv_prog_gcc != xyes; then
+                CFLAGS="-g3 -fast -arch host"
+            fi
+            ;;
+    esac
+fi
+
+dnl Add verbose warnings by default, and allow ANSI compliance checking
+AC_ARG_ENABLE(strict-ansi,
+[  --enable-strict-ansi    Enable strict ANSI compliance build [default=no]],
+              , enable_strict_ansi=no)
+if test x$ac_cv_prog_gcc = xyes; then
+    CFLAGS="$CFLAGS -Wall"
+    if test x$enable_strict_ansi = xyes; then
+        CFLAGS="$CFLAGS -ansi -pedantic -D_XOPEN_SOURCE"
+    fi
+fi
+
+dnl Initialize the compiler and linker flags for SDL applications
+
+SDL_CFLAGS=""
+SDL_LIBS="-lSDL"
+
+dnl Add the math library for the new gamma correction support
+
+case "$target" in
+    *-*-cygwin* | *-*-mingw32*)
+        MATHLIB=""
+        ;;
+    *-*-beos*)
+        MATHLIB=""
+        ;;
+    *-*-darwin*)
+        MATHLIB=""
+        ;;
+    *)
+        MATHLIB="-lm"
+        ;;
+esac
+SYSTEM_LIBS="$SYSTEM_LIBS $MATHLIB"
+
+dnl Enable/disable various subsystems of the SDL library
+
+AC_ARG_ENABLE(audio,
+[  --enable-audio          Enable the audio subsystem [default=yes]],
+              , enable_audio=yes)
+if test x$enable_audio = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS audio"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS audio/libaudio.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_AUDIO"
+fi
+AC_ARG_ENABLE(video,
+[  --enable-video          Enable the video subsystem [default=yes]],
+              , enable_video=yes)
+if test x$enable_video = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS video"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS video/libvideo.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_VIDEO"
+fi
+AC_ARG_ENABLE(events,
+[  --enable-events         Enable the events subsystem [default=yes]],
+              , enable_events=yes)
+if test x$enable_video = xyes -a x$enable_events = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS events"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS events/libevents.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_EVENTS"
+fi
+AC_ARG_ENABLE(joystick,
+[  --enable-joystick       Enable the joystick subsystem [default=yes]],
+              , enable_joystick=yes)
+if test x$enable_joystick = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS joystick"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS joystick/libjoystick.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_JOYSTICK"
+fi
+AC_ARG_ENABLE(cdrom,
+[  --enable-cdrom          Enable the cdrom subsystem [default=yes]],
+              , enable_cdrom=yes)
+if test x$enable_cdrom = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS cdrom"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS cdrom/libcdrom.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_CDROM"
+fi
+AC_ARG_ENABLE(threads,
+[  --enable-threads        Enable the threading subsystem [default=yes]],
+              , enable_threads=yes)
+SDL_EXTRADIRS="$SDL_EXTRADIRS thread"
+SDL_EXTRALIBS="$SDL_EXTRALIBS thread/libthread.la"
+if test x$enable_threads != xyes; then
+    CFLAGS="$CFLAGS -DDISABLE_THREADS"
+    COPY_ARCH_SRC(src/thread, generic, SDL_systhread.c)
+    COPY_ARCH_SRC(src/thread, generic, SDL_systhread_c.h)
+    COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
+    COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+    COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+    COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+    COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+    COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+fi
+AC_ARG_ENABLE(timers,
+[  --enable-timers         Enable the timer subsystem [default=yes]],
+              , enable_timers=yes)
+if test x$enable_timers = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS timer"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS timer/libtimer.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_TIMERS"
+fi
+AC_ARG_ENABLE(endian,
+[  --enable-endian         Enable the endian subsystem [default=yes]],
+              , enable_endian=yes)
+if test x$enable_endian = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS endian"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS endian/libendian.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_ENDIAN"
+fi
+AC_ARG_ENABLE(file,
+[  --enable-file           Enable the file subsystem [default=yes]],
+              , enable_file=yes)
+if test x$enable_file = xyes; then
+    SDL_EXTRADIRS="$SDL_EXTRADIRS file"
+    SDL_EXTRALIBS="$SDL_EXTRALIBS file/libfile.la"
+else
+    CFLAGS="$CFLAGS -DDISABLE_FILE"
+fi
+
+dnl See if the OSS audio interface is supported
+CheckOSS()
+{
+    AC_ARG_ENABLE(oss,
+[  --enable-oss            support the OSS audio API [default=yes]],
+                  , enable_oss=yes)
+    if test x$enable_audio = xyes -a x$enable_oss = xyes; then
+        AC_MSG_CHECKING(for OSS audio support)
+        have_oss=no
+        AC_TRY_COMPILE([
+          #ifdef linux
+          #include <linux/soundcard.h>
+          #endif
+          #ifdef __FreeBSD__
+          #include <machine/soundcard.h>
+          #endif
+          #ifdef __bsdi__
+          #include <sys/soundcard.h>
+          #endif
+          #ifdef __USLC__
+          #include <sys/soundcard.h>
+          #endif
+        ],[
+	  int arg = SNDCTL_DSP_SETFRAGMENT;
+        ],[
+        have_oss=yes
+        ])
+        AC_MSG_RESULT($have_oss)
+        if test x$have_oss = xyes; then
+            CFLAGS="$CFLAGS -DOSS_SUPPORT"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dsp"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS dsp/libaudio_dsp.la"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dma"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS dma/libaudio_dma.la"
+        fi
+    fi
+}
+
+dnl See if the ALSA audio interface is supported
+CheckALSA()
+{
+    AC_ARG_ENABLE(alsa,
+[  --enable-alsa           support the ALSA audio API [default=yes]],
+                  , enable_alsa=yes)
+    if test x$enable_audio = xyes -a x$enable_alsa = xyes; then
+        have_alsa=no
+        AC_CHECK_HEADER(sys/asoundlib.h, have_alsa_hdr=yes)
+        AC_CHECK_LIB(asound, snd_pcm_open, have_alsa_lib=yes)
+        if test x$have_alsa_hdr = xyes -a x$have_alsa_lib = xyes; then
+            CFLAGS="$CFLAGS -DALSA_SUPPORT"
+            SYSTEM_LIBS="$SYSTEM_LIBS -lasound"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS alsa"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS alsa/libaudio_alsa.la"
+        fi
+    fi
+}
+
+dnl Find the ESD includes and libraries
+CheckESD()
+{
+    AC_ARG_ENABLE(esd,
+[  --enable-esd            support the Enlightened Sound Daemon [default=yes]],
+                  , enable_esd=yes)
+    if test x$enable_audio = xyes -a x$enable_esd = xyes; then
+        AM_PATH_ESD(0.2.8, [
+            CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS"
+            SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS esd"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS esd/libaudio_esd.la"
+        ])
+    fi
+}
+
+CheckARTSC()
+{
+    AC_ARG_ENABLE(arts,
+[  --enable-arts           support the Analog Real Time Synthesizer [default=yes]],
+                  , enable_arts=yes)
+    if test x$enable_audio = xyes -a x$enable_arts = xyes; then
+        AC_PATH_PROG(ARTSCCONFIG, artsc-config)
+        if test x$ARTSCCONFIG = x -o x$ARTSCCONFIG = x'"$ARTSCCONFIG"'; then
+            : # arts isn't installed
+        else
+            ARTSC_CFLAGS=`$ARTSCCONFIG --cflags`
+            ARTSC_LIBS=`$ARTSCCONFIG --libs`
+            AC_MSG_CHECKING(for aRts development environment)
+            audio_arts=no
+            save_CFLAGS="$CFLAGS"
+            CFLAGS="$CFLAGS $ARTSC_CFLAGS"
+            AC_TRY_COMPILE([
+             #include <artsc.h>
+            ],[
+             arts_stream_t stream;
+            ],[
+            audio_arts=yes
+            ])
+            CFLAGS="$save_CFLAGS"
+            AC_MSG_RESULT($audio_arts)
+            if test x$audio_arts = xyes; then
+                CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS"
+                SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS"
+                AUDIO_SUBDIRS="$AUDIO_SUBDIRS arts"
+                AUDIO_DRIVERS="$AUDIO_DRIVERS arts/libaudio_arts.la"
+            fi
+        fi
+    fi
+}
+
+dnl See if the NAS audio interface is supported
+CheckNAS()
+{
+    AC_ARG_ENABLE(nas,
+[  --enable-nas		support the NAS audio API [default=yes]],
+		, enable_nas=yes)
+    if test x$enable_audio = xyes -a x$enable_nas = xyes; then
+	AC_MSG_CHECKING(for NAS audio support)
+	have_nas=no
+	if test -r /usr/X11R6/include/audio/audiolib.h ; then
+		have_nas=yes
+	fi
+	AC_MSG_RESULT($have_nas)
+	if test x$have_nas = xyes; then
+	    CFLAGS="$CFLAGS -DNAS_SUPPORT"
+	    SYSTEM_LIBS="$SYSTEM_LIBS -laudio -lXt"
+	    AUDIO_SUBDIRS="$AUDIO_SUBDIRS nas"
+	    AUDIO_DRIVERS="$AUDIO_DRIVERS nas/libaudio_nas.la"
+	fi
+    fi
+}
+
+dnl See if we can use x86 assembly blitters
+CheckNASM()
+{
+    dnl Make sure we are running on an x86 platform
+    case $target in
+        i?86*)
+            ;;
+        *)
+        # Nope, bail early.
+            return
+            ;;
+    esac
+    dnl Check for NASM (for assembly blit routines)
+    AC_ARG_ENABLE(nasm,
+[  --enable-nasm           use nasm assembly blitters on x86 [default=yes]],
+                  , enable_nasm=yes)
+    if test x$enable_video = xyes -a x$enable_nasm = xyes; then
+        AC_PATH_PROG(NASM, nasm)
+        if test x$NASM = x -o x$NASM = x'"$NASM"'; then
+            : # nasm isn't installed
+        else
+            CFLAGS="$CFLAGS -DUSE_ASMBLIT -I$srcdir/hermes"
+            case $ARCH in
+              win32)
+                  NASMFLAGS="-f win32"
+                  ;;
+              *)
+                  NASMFLAGS="-f elf"
+                  ;;
+            esac
+            AC_SUBST(NASMFLAGS)
+            CFLAGS="$CFLAGS -I\$(top_srcdir)/src/hermes"
+            SDL_EXTRADIRS="$SDL_EXTRADIRS hermes"
+            SDL_EXTRALIBS="$SDL_EXTRALIBS hermes/libhermes.la"
+        fi
+    fi
+}
+
+dnl Find the X11 include and library directories
+CheckX11()
+{
+    AC_ARG_ENABLE(video-x11,
+[  --enable-video-x11      use X11 video driver [default=yes]],
+                  , enable_video_x11=yes)
+    if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
+        AC_PATH_X
+        AC_PATH_XTRA
+        if test x$have_x = xyes; then
+            CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_X11"
+            if test x$ac_cv_func_shmat != xyes; then
+                CFLAGS="$CFLAGS -DNO_SHARED_MEMORY"
+            fi
+            SYSTEM_LIBS="$SYSTEM_LIBS $X_LIBS -lX11 -lXext"
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS x11"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS x11/libvideo_x11.la"
+
+            AC_ARG_ENABLE(video-x11-vm,
+[  --enable-video-x11-vm   use X11 VM extension for fullscreen [default=yes]],
+                          , enable_video_x11_vm=yes)
+            if test x$enable_video_x11_vm = xyes; then
+                AC_MSG_CHECKING(for XFree86 VidMode 1.0 support)
+                video_x11_vm=no
+                AC_TRY_COMPILE([
+                 #include <X11/Xlib.h>
+                 #include <X11/extensions/xf86vmode.h>
+                ],[
+                ],[
+                video_x11_vm=yes
+                ])
+                AC_MSG_RESULT($video_x11_vm)
+                if test x$video_x11_vm = xyes; then
+                    CFLAGS="$CFLAGS -DXFREE86_VM"
+                    # Check for nasty XFree86 4.0/Glide hack
+                    AC_ARG_ENABLE(xfree86_glidehack,
+[  --enable-xfree86-glidehack Alternate vidmode lib for old Glide [default=no]],
+                                  , enable_xfreeglidehack=no)
+                    if test x$enable_xfree86_glidehack = xyes; then
+                        ac_save_libs="$LIBS"
+                        LIBS="$LIBS $X_LIBS -lX11 -lXext"
+                        if test x$xfree86_glidehack = x; then
+                            AC_CHECK_LIB(Xxf86vm, XF40VidModeQueryExtension, xfree86_glidehack=Xxf86vm)
+                        fi
+                        if test x$xfree86_glidehack = x; then
+                            AC_CHECK_LIB(Xxf86vm40, XF40VidModeQueryExtension, xfree86_glidehack=Xxf86vm40)
+                        fi
+                        LIBS="$ac_save_libs"
+                    fi
+                    if test x$xfree86_glidehack != x; then
+                        CFLAGS="$CFLAGS -DXFREE86_VM_DYNAMIC_HACK"
+                        SYSTEM_LIBS="$SYSTEM_LIBS -l$xfree86_glidehack"
+                    else
+                        SYSTEM_LIBS="$SYSTEM_LIBS -lXxf86vm"
+                    fi
+                    AC_MSG_CHECKING(for XFree86 VidMode gamma support)
+                    video_x11_vmgamma=no
+                    AC_TRY_COMPILE([
+                     #include <X11/Xlib.h>
+                     #include <X11/extensions/xf86vmode.h>
+                    ],[
+                     XF86VidModeGamma gamma;
+                    ],[
+                    video_x11_vmgamma=yes
+                    ])
+                    AC_MSG_RESULT($video_x11_vmgamma)
+                    if test x$video_x11_vmgamma = xyes; then
+                        CFLAGS="$CFLAGS -DXFREE86_VMGAMMA"
+                    fi
+                fi
+            fi
+            AC_ARG_ENABLE(video-x11-dgamouse,
+[  --enable-video-x11-dgamouse  use X11 DGA for mouse events [default=yes]],
+                          , enable_video_x11_dgamouse=yes)
+            AC_MSG_CHECKING(for XFree86 DGA 1.0 support)
+            video_x11_dga=no
+            AC_TRY_COMPILE([
+             #include <X11/Xlib.h>
+             #include <X11/extensions/xf86dga.h>
+            ],[
+            ],[
+            video_x11_dga=yes
+            ])
+            AC_MSG_RESULT($video_x11_dga)
+            if test x$video_x11_dga = xyes; then
+                CFLAGS="$CFLAGS -DXFREE86_DGAMOUSE"
+                if test x$enable_video_x11_dgamouse = xyes; then
+                    CFLAGS="$CFLAGS -DDEFAULT_DGAMOUSE"
+                fi
+                SYSTEM_LIBS="$SYSTEM_LIBS -lXxf86dga"
+            fi
+            AC_ARG_ENABLE(video-x11-xv,
+[  --enable-video-x11-xv   use X11 XvImage extension for video [default=yes]],
+                          , enable_video_x11_xv=yes)
+            if test x$enable_video_x11_xv = xyes; then
+                AC_MSG_CHECKING(for XFree86 XvImage support)
+                video_x11_xv=no
+                AC_TRY_COMPILE([
+                 #include <X11/Xlib.h>
+                 #include <sys/ipc.h>
+                 #include <sys/shm.h>
+                 #include <X11/extensions/XShm.h>
+                 #include <X11/extensions/Xvlib.h>
+                ],[
+                 XvImage *image;
+                ],[
+                video_x11_xv=yes
+                ])
+                AC_MSG_RESULT($video_x11_xv)
+                if test x$video_x11_xv = xyes; then
+                    CFLAGS="$CFLAGS -DXFREE86_XV"
+                    SYSTEM_LIBS="$SYSTEM_LIBS -lXv"
+                fi
+            fi
+        fi
+    fi
+}
+CheckPHOTON()
+{
+    AC_ARG_ENABLE(video-photon,
+[  --enable-video-photon   use QNX Photonvideo driver [default=yes]],
+                  , enable_video_photon=yes)
+    if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
+        AC_MSG_CHECKING(for QNX Photon support)
+        video_photon=no
+        AC_TRY_COMPILE([
+          #include <Ph.h>
+          #include <Pt.h>
+          #include <photon/Pg.h>
+          #include <photon/PdDirect.h>
+        ],[
+         PgDisplaySettings_t *visual;
+        ],[
+        video_photon=yes
+        ])
+        AC_MSG_RESULT($video_photon)
+        if test x$video_photon = xyes; then
+            SYSTEM_LIBS="$SYSTEM_LIBS -lph"
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS photon"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS photon/libvideo_photon.la"
+        fi
+    fi
+}
+
+dnl Find the X11 DGA 2.0 include and library directories
+CheckDGA()
+{
+    AC_ARG_ENABLE(video-dga,
+[  --enable-video-dga      use DGA 2.0 video driver [default=yes]],
+                  , enable_video_dga=yes)
+    if test x$video_x11_dga = xyes -a x$enable_video_dga = xyes; then
+        AC_MSG_CHECKING(for XFree86 DGA 2.0 support)
+        video_x11_dga2=no
+        AC_TRY_COMPILE([
+         #include <X11/Xlib.h>
+         #include <X11/extensions/xf86dga.h>
+        ],[
+         XDGAEvent xevent;
+        ],[
+        video_x11_dga2=yes
+        ])
+        AC_MSG_RESULT($video_x11_dga2)
+        if test x$video_x11_dga2 = xyes; then
+            CFLAGS="$CFLAGS -DENABLE_DGA"
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS dga"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS dga/libvideo_dga.la"
+        fi
+    fi
+}
+
+dnl Find the framebuffer console includes
+CheckFBCON()
+{
+    AC_ARG_ENABLE(video-fbcon,
+[  --enable-video-fbcon    use framebuffer console video driver [default=yes]],
+                  , enable_video_fbcon=yes)
+    if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
+        AC_MSG_CHECKING(for framebuffer console support)
+        video_fbcon=no
+        AC_TRY_COMPILE([
+         #include <linux/fb.h>
+         #include <linux/kd.h>
+         #include <linux/keyboard.h>
+        ],[
+        ],[
+        video_fbcon=yes
+        ])
+        AC_MSG_RESULT($video_fbcon)
+        if test x$video_fbcon = xyes; then
+            CFLAGS="$CFLAGS -DENABLE_FBCON"
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS fbcon"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS fbcon/libvideo_fbcon.la"
+        fi
+    fi
+}
+
+dnl Find the GGI includes
+CheckGGI()
+{
+    AC_ARG_ENABLE(video-ggi,
+[  --enable-video-ggi      use GGI video driver [default=no]],
+                  , enable_video_ggi=no)
+    if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
+        AC_MSG_CHECKING(for GGI support)
+        video_ggi=no
+        AC_TRY_COMPILE([
+         #include <ggi/ggi.h>
+         #include <ggi/gii.h>
+        ],[
+        ],[
+        video_ggi=yes
+        ])
+        AC_MSG_RESULT($video_ggi)
+        if test x$video_ggi = xyes; then
+            CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_GGI"
+            SYSTEM_LIBS="$SYSTEM_LIBS -lggi -lgii -lgg"
+
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS ggi"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS ggi/libvideo_ggi.la"
+        fi
+    fi
+}
+
+dnl Find the SVGAlib includes and libraries
+CheckSVGA()
+{
+    AC_ARG_ENABLE(video-svga,
+[  --enable-video-svga     use SVGAlib video driver [default=no]],
+                  , enable_video_svga=no)
+    if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
+        AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
+        video_svga=no
+        AC_TRY_COMPILE([
+         #include <vga.h>
+         #include <vgamouse.h>
+         #include <vgakeyboard.h>
+        ],[
+         if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
+             exit(0);
+         }
+        ],[
+        video_svga=yes
+        ])
+        AC_MSG_RESULT($video_svga)
+        if test x$video_svga = xyes; then
+            CFLAGS="$CFLAGS -DENABLE_SVGALIB"
+            SYSTEM_LIBS="$SYSTEM_LIBS -lvga"
+
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS svga"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS svga/libvideo_svga.la"
+        fi
+    fi
+}
+
+dnl Find the AAlib includes
+CheckAAlib()
+{
+    AC_ARG_ENABLE(video-aalib,
+[  --enable-video-aalib    use AAlib video driver [default=no]],
+                  , enable_video_aalib=no)
+    if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
+        AC_MSG_CHECKING(for AAlib support)
+        video_aalib=no
+        AC_TRY_COMPILE([
+         #include <aalib.h>
+        ],[
+        ],[
+        video_aalib=yes
+        ])
+        AC_MSG_RESULT($video_aalib)
+        if test x$video_aalib = xyes; then
+            CFLAGS="$CFLAGS -DENABLE_AALIB"
+            SYSTEM_LIBS="$SYSTEM_LIBS -laa"
+
+            VIDEO_SUBDIRS="$VIDEO_SUBDIRS aalib"
+            VIDEO_DRIVERS="$VIDEO_DRIVERS aalib/libvideo_aa.la"
+        fi
+    fi
+}
+
+dnl Check to see if OpenGL support is desired
+AC_ARG_ENABLE(video-opengl,
+[  --enable-video-opengl   include OpenGL context creation [default=yes]],
+              , enable_video_opengl=yes)
+
+dnl Find OpenGL
+CheckOpenGL()
+{
+    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
+        AC_MSG_CHECKING(for OpenGL (GLX) support)
+        video_opengl=no
+        AC_TRY_COMPILE([
+         #include <GL/gl.h>
+         #include <GL/glx.h>
+         #include <dlfcn.h> /* For loading extensions */
+        ],[
+        ],[
+        video_opengl=yes
+        ])
+        AC_MSG_RESULT($video_opengl)
+        if test x$video_opengl = xyes; then
+            CFLAGS="$CFLAGS -DHAVE_OPENGL"
+            AC_CHECK_LIB(dl, dlopen, SYSTEM_LIBS="$SYSTEM_LIBS -ldl")
+        fi
+    fi
+}
+
+dnl Check for BeOS OpenGL
+CheckBeGL()
+{
+    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
+        CFLAGS="$CFLAGS -DHAVE_OPENGL"
+        SYSTEM_LIBS="$SYSTEM_LIBS -lGL"
+    fi
+}
+
+dnl Check for MacOS OpenGL
+CheckMacGL()
+{
+    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
+        CFLAGS="$CFLAGS -DHAVE_OPENGL"
+        case "$target" in
+            *-*-darwin*)
+                SDL_LIBS="$SDL_LIBS -framework OpenGL -framework AGL"
+        esac
+    fi
+}
+
+dnl See if we can use the new unified event interface in Linux 2.4
+CheckInputEvents()
+{
+    dnl Check for Linux 2.4 unified input event interface support
+    AC_ARG_ENABLE(input-events,
+[  --enable-input-events   use Linux 2.4 unified input interface [default=yes]],
+                  , enable_input_events=yes)
+    if test x$enable_input_events = xyes; then
+        AC_MSG_CHECKING(for Linux 2.4 unified input interface)
+        use_input_events=no
+        AC_TRY_COMPILE([
+          #include <linux/input.h>
+        ],[
+          #ifndef EVIOCGNAME
+          #error EVIOCGNAME() ioctl not available
+          #endif
+        ],[
+        use_input_events=yes
+        ])
+        AC_MSG_RESULT($use_input_events)
+        if test x$use_input_events = xyes; then
+            CFLAGS="$CFLAGS -DUSE_INPUT_EVENTS"
+        fi
+    fi
+}
+
+dnl See what type of thread model to use on Linux and Solaris
+CheckPTHREAD()
+{
+    dnl Check for pthread support
+    AC_ARG_ENABLE(pthreads,
+[  --enable-pthreads       use POSIX threads for multi-threading [default=yes]],
+                  , enable_pthreads=yes)
+    dnl This is used on Linux for glibc binary compatibility (Doh!)
+    AC_ARG_ENABLE(pthread-sem,
+[    --enable-pthread-sem  use pthread semaphores [default=yes]],
+                  , enable_pthread_sem=yes)
+    ac_save_libs="$LIBS"
+    case "$target" in
+        *-*-bsdi*)
+            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
+            pthread_lib=""
+            ;;
+        *-*-darwin*)
+            pthread_cflags="-D_THREAD_SAFE"
+# causes Carbon.p complaints?
+#            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
+            ;;
+        *-*-freebsd*)
+            pthread_cflags="-D_REENTRANT -D_THREAD_SAFE"
+            pthread_lib="-pthread"
+            ;;
+        *-*-openbsd*)
+            pthread_cflags="-D_REENTRANT"
+            pthread_lib="-pthread"
+            ;;
+        *-*-solaris*)
+            pthread_cflags="-D_REENTRANT"
+            pthread_lib="-lpthread -lposix4"
+            ;;
+        *-*-sysv5*)
+            pthread_cflags="-D_REENTRANT -Kthread"
+            pthread_lib=""
+            ;;
+        *-*-irix*)
+            pthread_cflags="-D_SGI_MP_SOURCE"
+            pthread_lib="-lpthread"
+            ;;
+        *-*-aix*)
+            pthread_cflags="-D_REENTRANT -mthreads"
+            pthread_lib="-lpthread"
+            ;;
+        *-*-qnx*)
+            pthread_cflags=""
+            pthread_lib=""
+            ;;
+        *)
+            pthread_cflags="-D_REENTRANT"
+            pthread_lib="-lpthread"
+            ;;
+    esac
+    LIBS="$LIBS $pthread_lib"
+    if test x$enable_threads = xyes -a x$enable_pthreads = xyes; then
+        AC_MSG_CHECKING(for pthreads)
+        use_pthreads=no
+        AC_TRY_LINK([
+         #include <pthread.h>
+        ],[
+         pthread_attr_t type;
+         pthread_attr_init(&type);
+        ],[
+        use_pthreads=yes
+        ])
+        AC_MSG_RESULT($use_pthreads)
+        if test x$use_pthreads = xyes; then
+            CFLAGS="$CFLAGS $pthread_cflags -DSDL_USE_PTHREADS"
+            SDL_CFLAGS="$SDL_CFLAGS $pthread_cflags"
+            SDL_LIBS="$SDL_LIBS $pthread_lib"
+
+            # Check to see if recursive mutexes are available
+            AC_MSG_CHECKING(for recursive mutexes)
+            has_recursive_mutexes=no
+            AC_TRY_LINK([
+              #include <pthread.h>
+            ],[
+              pthread_mutexattr_t attr;
+              #ifdef linux
+              pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+              #else
+              pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+              #endif
+            ],[
+            has_recursive_mutexes=yes
+            ])
+            # Some systems have broken recursive mutex implementations
+            case "$target" in
+                *-*-solaris*)
+                    has_recursive_mutexes=no
+                    ;;
+            esac
+            AC_MSG_RESULT($has_recursive_mutexes)
+            if test x$has_recursive_mutexes != xyes; then
+                CFLAGS="$CFLAGS -DPTHREAD_NO_RECURSIVE_MUTEX"
+            fi
+
+            # Check to see if this is broken glibc 2.0 pthreads
+            case "$target" in
+                *-*-linux*)
+                    AC_MSG_CHECKING(for broken glibc 2.0 pthreads)
+                    glibc20_pthreads=no
+                    AC_TRY_COMPILE([
+                      #include <features.h>
+                      #if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+                      #warning Working around a bug in glibc 2.0 pthreads
+                      #else
+                      #error pthread implementation okay
+                      #endif /* glibc 2.0 */
+                    ],[
+                    ],[
+                    glibc20_pthreads=yes
+                    ])
+                    AC_MSG_RESULT($glibc20_pthreads)
+            esac
+        fi
+    fi
+    LIBS="$ac_save_libs"
+
+    AC_MSG_CHECKING(whether semun is defined in /usr/include/sys/sem.h)
+    have_semun=no
+    AC_TRY_COMPILE([
+      #include <sys/types.h>
+      #include <sys/sem.h>
+    ],[
+      union semun t;
+    ],[
+    have_semun=yes
+    ])
+    AC_MSG_RESULT($have_semun)
+    if test x$have_semun = xyes; then
+        CFLAGS="$CFLAGS -DHAVE_SEMUN"
+    fi
+
+    # See if we can use clone() on Linux directly
+    use_clone=no
+    if test x$enable_threads = xyes -a x$use_pthreads != xyes; then
+        case "$target" in
+            *-*-linux*)
+                use_clone=yes
+                ;;
+            *)
+                CFLAGS="$CFLAGS -DFORK_HACK"
+                ;;
+        esac
+    fi
+    AM_CONDITIONAL(USE_CLONE, test x$use_clone = xyes)
+}
+
+dnl Determine whether the compiler can produce Win32 executables
+CheckWIN32()
+{
+    AC_MSG_CHECKING(Win32 compiler)
+    have_win32_gcc=no
+    AC_TRY_COMPILE([
+     #include <windows.h>
+    ],[
+    ],[
+    have_win32_gcc=yes
+    ])
+    AC_MSG_RESULT($have_win32_gcc)
+    if test x$have_win32_gcc != xyes; then
+       AC_MSG_ERROR([
+*** Your compiler ($CC) does not produce Win32 executables!
+       ])
+    fi
+
+    dnl See if the user wants to redirect standard output to files
+    AC_ARG_ENABLE(stdio-redirect,
+[  --enable-stdio-redirect Redirect STDIO to files on Win32 [default=yes]],
+                  , enable_stdio_redirect=yes)
+    if test x$enable_stdio_redirect != xyes; then
+        CFLAGS="$CFLAGS -DNO_STDIO_REDIRECT"
+    fi
+}
+
+dnl Find the DirectX includes and libraries
+CheckDIRECTX()
+{
+    AC_ARG_ENABLE(directx,
+[  --enable-directx        use DirectX for Win32 audio/video [default=yes]],
+                  , enable_directx=yes)
+    if test x$enable_directx = xyes; then
+        AC_MSG_CHECKING(for DirectX headers and libraries)
+        use_directx=no
+        AC_TRY_COMPILE([
+         #include "src/video/windx5/directx.h"
+        ],[
+        ],[
+        use_directx=yes
+        ])
+        AC_MSG_RESULT($use_directx)
+    fi
+    AM_CONDITIONAL(USE_DIRECTX, test x$use_directx = xyes)
+
+    CFLAGS="$CFLAGS -I\$(top_srcdir)/src/video/wincommon"
+    SYSTEM_LIBS="$SYSTEM_LIBS -luser32 -lgdi32 -lwinmm"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS wincommon"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS wincommon/libvideo_wincommon.la"
+    # Enable the DIB driver
+    CFLAGS="$CFLAGS -DENABLE_WINDIB"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS windib"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS windib/libvideo_windib.la"
+    # See if we should enable the DirectX driver
+    if test x$use_directx = xyes; then
+        CFLAGS="$CFLAGS -DENABLE_DIRECTX"
+        SYSTEM_LIBS="$SYSTEM_LIBS -ldxguid"
+        VIDEO_SUBDIRS="$VIDEO_SUBDIRS windx5"
+        VIDEO_DRIVERS="$VIDEO_DRIVERS windx5/libvideo_windx5.la"
+    fi
+}
+
+dnl Set up the BWindow video driver on BeOS
+CheckBWINDOW()
+{
+    CFLAGS="$CFLAGS -DENABLE_BWINDOW"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS bwindow"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS bwindow/libvideo_bwindow.la"
+}
+
+dnl Set up the Mac toolbox video driver for Mac OS 7-9
+CheckTOOLBOX()
+{
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS maccommon"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la"
+}
+
+dnl Set up the Mac toolbox video driver for Mac OS X
+CheckCARBON()
+{
+    # "MACOSX" is not an official definition, but it's commonly
+    # accepted as a way to differentiate between what runs on X
+    # and what runs on older Macs - while in theory "Carbon" defns
+    # are consistent between the two, in practice Carbon is still
+    # changing. -sts Aug 2000
+    mac_autoconf_target_workaround="MAC"
+    CFLAGS="$CFLAGS -I/System/Library/Frameworks/Carbon.framework/Headers \
+      -fpascal-strings -DENABLE_TOOLBOX -DMACOSX -DTARGET_API_${mac_autoconf_target_workaround}_CARBON=1 -I\$(top_srcdir)/src/video/maccommon -I\$(top_srcdir)/src/video/macrom -I\$(top_srcdir)/src/video/macdsp"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS maccommon"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS maccommon/libvideo_maccommon.la"
+    VIDEO_SUBDIRS="$VIDEO_SUBDIRS macrom"
+    VIDEO_DRIVERS="$VIDEO_DRIVERS macrom/libvideo_macrom.la"
+}
+
+dnl Set up the kernel statistics library for Solaris
+CheckKSTAT()
+{
+    CFLAGS="$CFLAGS -DHAVE_KSTAT"
+    SYSTEM_LIBS="$SYSTEM_LIBS -lkstat"
+}
+
+case "$target" in
+    *-*-linux*)
+        ARCH=linux
+        CheckNASM
+        CheckOSS
+        CheckALSA
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckDGA
+        CheckFBCON
+        CheckGGI
+        CheckSVGA
+        CheckAAlib
+        CheckOpenGL
+        CheckInputEvents
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        # We use the OSS and ALSA API's, not the Sun audio API
+        #if test x$enable_audio = xyes; then
+        #    AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+        #    AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        #fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS linux"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS linux/libjoystick_linux.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, linux, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            if test x$use_pthreads != xyes; then
+                COPY_ARCH_SRC(src/thread, linux, clone.S)
+            fi
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            else
+                COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            fi
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            if test x$glibc20_pthreads = xyes; then
+                COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+            else
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+                COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+            fi
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-bsdi*)
+        ARCH=bsdi
+        CheckNASM
+        CheckOSS
+        CheckNAS
+        CheckX11
+        CheckDGA
+        CheckSVGA
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        # (No cdrom support yet)
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-freebsd*)
+        ARCH=freebsd
+        CheckNASM
+        CheckOSS
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckDGA
+        CheckSVGA
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        # We use the OSS and ALSA API's, not the Sun audio API
+        #if test x$enable_audio = xyes; then
+        #    AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+        #    AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        #fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, freebsd, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            else
+                COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            fi
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-netbsd*)
+        ARCH=netbsd
+        CheckNASM
+        CheckOSS
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, openbsd, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        # NetBSD does not define "unix"
+        CFLAGS="$CFLAGS -Dunix"
+        ;;
+    *-*-openbsd*)
+        ARCH=openbsd
+        CheckNASM
+        CheckOSS
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, openbsd, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            else
+                COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            fi
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-sysv5*)
+        ARCH=sysv5
+        CheckNASM
+        CheckOSS
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        CheckKSTAT
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, generic, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-solaris*)
+        ARCH=solaris
+        CheckNASM
+        CheckARTSC
+        CheckESD
+        CheckNAS
+        CheckX11
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        CheckKSTAT
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, linux, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-irix*)
+        ARCH=irix
+        CheckNAS
+        CheckX11
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS dmedia"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS dmedia/libaudio_dmedia.la"
+            LIBS="$LIBS -laudio"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        # (No CD-ROM support yet)
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            if test x$use_pthreads = xyes; then
+                COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+                COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+                if test x$enable_pthread_sem != xyes; then
+                    COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+                else
+                    COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+                fi
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+                COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+            else
+                COPY_ARCH_SRC(src/thread, irix, SDL_systhread.c)
+                COPY_ARCH_SRC(src/thread, irix, SDL_systhread_c.h)
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+                COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+                COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+                COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+            fi
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-hpux*)
+        ARCH=hpux
+        CheckNAS
+        CheckX11
+        CheckGGI
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        # (No CD-ROM support yet)
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-aix*)
+        ARCH=aix
+        CheckNAS
+        CheckX11
+        CheckGGI
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS paudio"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS paudio/libaudio_paudio.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, aix, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-osf*)
+        ARCH=osf
+        CheckNAS
+        CheckX11
+        CheckGGI
+        CheckAAlib
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        # (No joystick support yet)
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        # (No cdrom support yet)
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-qnx*)
+        ARCH=qnx
+        CheckNAS
+        CheckPHOTON
+        CheckX11
+        CheckOpenGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            CFLAGS="$CFLAGS -DALSA_SUPPORT"
+            SYSTEM_LIBS="$SYSTEM_LIBS -lasound"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS nto"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS nto/libaudio_nto.la"
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS sun"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS sun/libaudio_sun.la"
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+        # (No joystick support yet)
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, qnx, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        ;;
+    *-*-cygwin* | *-*-mingw32*)
+        ARCH=win32
+        if test "$build" != "$target"; then # cross-compiling
+            # Default cross-compile location
+            ac_default_prefix=/usr/local/cross-tools/i386-mingw32msvc
+        else
+            # Look for the location of the tools and install there
+            ac_default_prefix=$BUILD_PREFIX
+        fi
+        CheckWIN32
+        CheckDIRECTX
+        CheckNASM
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, win32, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS windib"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS windib/libaudio_windib.la"
+            if test x$use_directx = xyes; then
+    	        AUDIO_SUBDIRS="$AUDIO_SUBDIRS windx5"
+    	        AUDIO_DRIVERS="$AUDIO_DRIVERS windx5/libaudio_windx5.la"
+            fi
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS win32"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS win32/libjoystick_winmm.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, win32, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, win32, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, win32, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, win32, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, win32, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, win32, SDL_systimer.c)
+        fi
+        # The Win32 platform requires special setup
+        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
+        SDL_LIBS="-lmingw32 -lSDLmain $SDL_LIBS -mwindows"
+        ;;
+    *-*-beos*)
+        ARCH=beos
+        ac_default_prefix=/boot/develop/tools/gnupro
+        CheckNASM
+        CheckBWINDOW
+        CheckBeGL
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        COPY_ARCH_SRC(src/main, beos, SDL_BeApp.cc)
+        COPY_ARCH_SRC(src/main, beos, SDL_BeApp.h)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS baudio"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS baudio/libaudio_baudio.la"
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS beos"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS beos/libjoystick_beos.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, beos, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, beos, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, beos, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, beos, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, beos, SDL_systimer.c)
+        fi
+        # The BeOS platform requires special libraries
+        SYSTEM_LIBS="$SYSTEM_LIBS -lroot -lbe -lmedia -lgame -ldevice -ltextencoding"
+        ;;
+    *-*-macos*)
+        # This would be used if cross-compiling to MacOS 9.  No way to
+        # use it at present, but Apple is working on a X-to-9 compiler
+        # for which this case would be handy.
+        ARCH=macos
+        CheckTOOLBOX
+        CheckMacGL
+        # Set up files for the main() stub
+        COPY_ARCH_SRC(src/main, macos, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS macrom/libaudio_macrom.la"
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS macos"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS macos/libjoystick_macos.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, macos, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, macos, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, macos, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_sysmutex_c.h)
+            COPY_ARCH_SRC(src/thread, macos, SDL_syssem.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, macos, SDL_systimer.c)
+        fi
+        # The MacOS platform requires special setup
+        SDL_CFLAGS="$SDL_CFLAGS -Dmain=SDL_main"
+        SDL_LIBS="-lSDLmain $SDL_LIBS"
+        ;;
+    *-*-darwin* )
+        # Strictly speaking, we want "Mac OS X", not "Darwin", which is
+        # just the OS X kernel sans upper layers like Carbon.  But
+        # config.guess comes back with "darwin", so go with the flow.
+        ARCH=macos
+        CheckCARBON
+        CheckMacGL
+        CheckPTHREAD
+        # Set up files for the main() stub
+        # COPY_ARCH_SRC(src/main, macos, SDL_main.c)
+        COPY_ARCH_SRC(src/main, linux, SDL_main.c)
+        # Set up files for the audio library
+        if test x$enable_audio = xyes; then
+            AUDIO_SUBDIRS="$AUDIO_SUBDIRS macrom"
+            AUDIO_DRIVERS="$AUDIO_DRIVERS macrom/libaudio_macrom.la"
+        fi
+        # Set up files for the joystick library
+        if test x$enable_joystick = xyes; then
+            JOYSTICK_SUBDIRS="$JOYSTICK_SUBDIRS dummy"
+            JOYSTICK_DRIVERS="$JOYSTICK_DRIVERS dummy/libjoystick_dummy.la"
+        fi
+        # Set up files for the cdrom library
+        if test x$enable_cdrom = xyes; then
+            COPY_ARCH_SRC(src/cdrom, dummy, SDL_syscdrom.c)
+        fi
+        # Set up files for the thread library
+        if test x$enable_threads = xyes; then
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_systhread_c.h)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex.c)
+            COPY_ARCH_SRC(src/thread, linux, SDL_sysmutex_c.h)
+            if test x$use_pthreads = xyes -a x$enable_pthread_sem != xyes; then
+                COPY_ARCH_SRC(src/thread, generic, SDL_syssem.c)
+            else
+                COPY_ARCH_SRC(src/thread, linux, SDL_syssem.c)
+            fi
+            COPY_ARCH_SRC(src/thread, generic, SDL_syssem_c.h)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond.c)
+            COPY_ARCH_SRC(src/thread, generic, SDL_syscond_c.h)
+        fi
+        # Set up files for the timer library
+        if test x$enable_timers = xyes; then
+            COPY_ARCH_SRC(src/timer, linux, SDL_systimer.c)
+        fi
+        # The MacOS X platform requires special setup
+        SDL_CFLAGS="$SDL_CFLAGS -F/System/Library/Frameworks/Carbon.framework"
+        SDL_LIBS="$SDL_LIBS -framework Carbon"
+        ;;
+    *)
+        AC_MSG_ERROR(Unsupported target:  Please add to configure.in)
+        ;;
+esac
+AC_SUBST(ARCH)
+
+# Set the conditional variables for this target
+AM_CONDITIONAL(TARGET_LINUX, test $ARCH = linux)
+AM_CONDITIONAL(TARGET_SOLARIS, test $ARCH = solaris)
+AM_CONDITIONAL(TARGET_IRIX, test $ARCH = irix)
+AM_CONDITIONAL(TARGET_BSDI, test $ARCH = bsdi)
+AM_CONDITIONAL(TARGET_FREEBSD, test $ARCH = freebsd)
+AM_CONDITIONAL(TARGET_OPENBSD, test $ARCH = openbsd)
+AM_CONDITIONAL(TARGET_AIX, test $ARCH = aix)
+AM_CONDITIONAL(TARGET_WIN32, test $ARCH = win32)
+AM_CONDITIONAL(TARGET_BEOS, test $ARCH = beos)
+AM_CONDITIONAL(TARGET_MACOS, test $ARCH = macos)
+
+# Set conditional variables for shared and static library selection.
+# These are not used in any Makefile.am but in sdl-config.in.
+AM_CONDITIONAL([ENABLE_SHARED], [test "$enable_shared" = yes])
+AM_CONDITIONAL([ENABLE_STATIC], [test "$enable_static" = yes])
+
+# Set runtime shared library paths as needed
+
+if test $ARCH = linux -o $ARCH = freebsd -o $ARCH = bsdi; then
+  SDL_RLD_FLAGS="-Wl,-rpath,\${exec_prefix}/lib"
+fi
+
+if test $ARCH = solaris; then
+  SDL_RLD_FLAGS="-R\${exec_prefix}/lib"
+fi
+
+dnl Output the video drivers we use
+if test x$enable_video = xtrue; then
+    if test "$VIDEO_SUBDIRS" = ""; then
+        AC_MSG_ERROR(*** No video drivers are enabled!)
+    fi
+fi
+AC_SUBST(AUDIO_SUBDIRS)
+AC_SUBST(AUDIO_DRIVERS)
+AC_SUBST(VIDEO_SUBDIRS)
+AC_SUBST(VIDEO_DRIVERS)
+AC_SUBST(JOYSTICK_SUBDIRS)
+AC_SUBST(JOYSTICK_DRIVERS)
+AC_SUBST(SDL_EXTRADIRS)
+AC_SUBST(SDL_EXTRALIBS)
+AC_SUBST(SYSTEM_LIBS)
+
+dnl Expand the cflags and libraries needed by apps using SDL
+AC_SUBST(SDL_CFLAGS)
+AC_SUBST(SDL_LIBS)
+AC_SUBST(SDL_RLD_FLAGS)
+
+dnl Expand the libraries needed for static linking
+AC_SUBST(SYSTEM_LIBS)
+dnl Expand the include directories for building SDL
+CFLAGS="$CFLAGS -I\$(top_srcdir)/include"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/include/SDL"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src -I\$(top_srcdir)/src/$ARCH"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/main"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/audio"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/video"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/events"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/joystick"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/cdrom"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/thread"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/timer"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/endian"
+CFLAGS="$CFLAGS -I\$(top_srcdir)/src/file"
+CXXFLAGS="$CFLAGS"
+
+# Finally create all the generated files
+dnl Important: Any directory that you want to be in the distcheck should
+dnl            have a file listed here, so that configure generates the
+dnl            subdirectories on the build target.
+AC_OUTPUT([
+Makefile
+docs/Makefile
+docs/html/Makefile
+docs/man3/Makefile
+include/Makefile
+src/Makefile
+src/main/Makefile
+src/audio/Makefile
+src/audio/alsa/Makefile
+src/audio/arts/Makefile
+src/audio/baudio/Makefile
+src/audio/dma/Makefile
+src/audio/dmedia/Makefile
+src/audio/dsp/Makefile
+src/audio/esd/Makefile
+src/audio/macrom/Makefile
+src/audio/nas/Makefile
+src/audio/nto/Makefile
+src/audio/paudio/Makefile
+src/audio/sun/Makefile
+src/audio/ums/Makefile
+src/audio/windib/Makefile
+src/audio/windx5/Makefile
+src/video/Makefile
+src/video/cybergfx/Makefile
+src/video/x11/Makefile
+src/video/dga/Makefile
+src/video/fbcon/Makefile
+src/video/ggi/Makefile
+src/video/maccommon/Makefile
+src/video/macdsp/Makefile
+src/video/macrom/Makefile
+src/video/svga/Makefile
+src/video/aalib/Makefile
+src/video/wincommon/Makefile
+src/video/windib/Makefile
+src/video/windx5/Makefile
+src/video/bwindow/Makefile
+src/video/photon/Makefile
+src/events/Makefile
+src/joystick/Makefile
+src/joystick/beos/Makefile
+src/joystick/dummy/Makefile
+src/joystick/linux/Makefile
+src/joystick/macos/Makefile
+src/joystick/win32/Makefile
+src/cdrom/Makefile
+src/thread/Makefile
+src/timer/Makefile
+src/endian/Makefile
+src/file/Makefile
+src/hermes/Makefile
+sdl-config
+SDL.spec
+], [chmod +x sdl-config])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,498 @@
+<HTML>
+<HEAD><TITLE>SDL Stable Release</TITLE></HEAD>
+<BODY BGCOLOR="#FFEBCD" TEXT="#000000">
+
+<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
+<P>
+This source is in development.  It may contain API changes, and may not be
+fully tested on all supported platforms.  The current stable release may
+be found at the <A HREF="http://www.libsdl.org/"> main SDL page</A>.
+<P>
+
+<H2> <A HREF="docs/index.html">API Documentation</A> </H2>
+<P>
+
+<H2>
+Major changes since SDL 1.0.0:
+</H2>
+<UL>
+	<LI> 1.2.0: Added initial support for HP-UX (thanks Stephanie)
+	<LI> 1.2.0: Added initial support for BSDI (thanks Kurt)
+	<LI> 1.2.0: Fixed blitting 32-bit ARGB images to SDL_OPENGLBLIT screens
+	<LI> 1.2.0: Fixed automake build dependencies (thanks Markus!)
+	<LI> 1.2.0: Added 24 bpp support to software YUV display functions
+	<LI> 1.2.0: Don't bomb trying to get DGA mouse on XFree86 4.0
+	<LI> 1.2.0: Added initial support for OSF/Tru64 (thanks Anders)
+	<LI> 1.1.8: Fixed joystick hat motion on MacOS
+	<LI> 1.1.8: Don't detect mouse and keyboard as joystick on MacOS
+	<LI> 1.1.8: Check for OpenGL 1.2 before using 16-bit SDL_OPENGLBLIT
+	<LI> 1.1.8: Added support for /dev/sound/* in Linux 2.4
+	<LI> 1.1.8: Fixed crash when blitting to RLE encoded surfaces
+	<LI> 1.1.8: Fixed 8-bit audio on MacOS X
+	<LI> 1.1.8: Fixed keyboard handling on MacOS X and MacOS classic
+	<LI> 1.1.8: Fixed mouse cursor visibility when switching apps on MacOS
+	<LI> 1.1.8: Implemented semaphore support on MacOS X
+	<LI> 1.1.8: Worked around broken sem_getvalue() on MacOS X
+	<LI> 1.1.8: Fixed 16-bit big-endian audio on MacOS X and MacOS classic
+	<LI> 1.1.8: Fixed mutex locking on Linux glibc 2.0
+	<LI> 1.1.8: SDL_Quit() removes the parachute signal handlers
+	<LI> 1.1.8: Added NAS audio server support (thanks Erik!)
+	<LI> 1.1.8: Added SDL_NOFRAME for frameless windows (thanks Andreas)
+	<LI> 1.1.8: Added support for resizable windows on MacOS
+	<LI> 1.1.8: Added a function to query the surface clip rectangle
+	<LI> 1.1.8: Added a function to query the current event filter
+	<LI> 1.1.8: The X11 XVideo adapter is now locked (thanks Jeffrey)
+	<LI> 1.1.8: Improved the speed of fullscreen OpenGL on Windows
+	<LI> 1.1.8: Added ELO touchscreen support for fbcon (thanks Alex)
+	<LI> 1.1.8: Added accelerated MacOS X OpenGL support
+	<LI> 1.1.8: Surface lock and unlock operations can now be nested
+	<LI> 1.1.8: Optimized fillrect for PPC video memory (thanks Mattias)
+	<LI> 1.1.8: Work around "blackout" problem with XVideo acceleration
+	<LI> 1.1.8: Obtain correct key state on X11 focus (thanks Mattias)
+	<LI> 1.1.8: Fixed keyboard handling on the framebuffer console
+	<LI> 1.1.8: Added basic support for VGA16 framebuffer console
+	<LI> 1.1.8: Open a new virtual terminal if possible on fbcon
+	<LI> 1.1.8: Fixed default audio driver on FreeBSD (thanks Maxim)
+	<LI> 1.1.8: Fixed joystick crash on Windows (thanks Pete)
+	<LI> 1.1.7: Expanded documentation from the SDL Documentation Project
+	<LI> 1.1.7: Report X11 client message events if SYSWMEVENTS enabled
+	<LI> 1.1.7: Added support for a single hat on Windows joysticks
+	<LI> 1.1.7: The gamma ramp routines now take arrays of Uint16 values
+	<LI> 1.1.7: Added initial support for QNX RTP (thanks Patrick)
+	<LI> 1.1.7: Added ALSA sound driver (thanks Patrick Trainor)
+	<LI> 1.1.7: Added aRts UNIX sound driver (thanks Neil Stevens)
+	<LI> 1.1.7: Get keyboard modifier state on input focus on Win32
+	<LI> 1.1.7: SDL_ConvertSurface() now accepts SDL_RLEACCEL as a flag
+	<LI> 1.1.7: Added initial UnixWare 7 support (thanks rr)
+	<LI> 1.1.7: Added working YUY -> RGB conversion code (thanks Eugene)
+	<LI> 1.1.7: Fixed video initialization crash on IRIX
+	<LI> 1.1.7: Fixed MacOS fullscreen palette code (thanks Darrell)
+	<LI> 1.1.7: Fixed background brush flicker on Win32 (thanks Gautier)
+	<LI> 1.1.7: Fixed incorrect pitch when switching to window on Win32
+	<LI> 1.1.7: Fixed memory leak when switching video modes on Win32
+	<LI> 1.1.7: Init of fbcon shouldn't automatically set graphics mode
+	<LI> 1.1.6: Allow SDL_VIDEO_INIT when built without thread support
+	<LI> 1.1.6: Fixed palette problems with non-X11 fullscreen displays
+	<LI> 1.1.6: Fixed Win32 crash with SDL_OPENGLBLIT and GL functions
+	<LI> 1.1.6: Improved default MacOS millisecond time resolution
+	<LI> 1.1.6: Fixed X11 overlapping endian blit bug (thanks Mattias)
+	<LI> 1.1.6: Fixed starting directory on BeOS (thanks Samuel)
+	<LI> 1.1.6: Integrated FreeBSD SVGAlib support (thanks folks)
+	<LI> 1.1.6: Fixed middle-button handling on DirectInput
+	<LI> 1.1.6: Added SDL_GetThreadID() to get a specific thread's ID
+	<LI> 1.1.6: Worked around a crash in pthreads on RedHat 7
+	<LI> 1.1.6: Fixed a brown-bag crash in clipping code
+	<LI> 1.1.5: Convert from '/' to ':' opening files on MacOS
+	<LI> 1.1.5: Clean up empty output files on Win32 and MacOS 
+	<LI> 1.1.5: Run command dialog if command key on startup on MacOS
+	<LI> 1.1.5: Initial NetBSD support (thanks Krister Walfridsson)
+	<LI> 1.1.5: Expanded the YUV overlay to handle odd (ATI) hardware
+	<LI> 1.1.5: Fixed MacOS GL attribute selection (thanks Darrell)
+	<LI> 1.1.5: Implemented gamma correction on 8-bit hardware displays
+	<LI> 1.1.5: Performed logical/physical palette split (thanks Mattias)
+	<LI> 1.1.5: Added initial MacOS X support (thanks Stan)
+	<LI> 1.1.5: SDL_WarpMouse() now works on BeOS (thanks Christian)
+	<LI> 1.1.5: Windows GDI driver now supports 565 modes (thanks Ben)
+	<LI> 1.1.5: Correctly load OpenGL extensions on Win32 (thanks Beosil)
+	<LI> 1.1.5: Fixed crash with some threaded audio drivers
+	<LI> 1.1.5: Audio is now closed in SDL_Quit(), if necessary
+	<LI> 1.1.5: Win32 version now uses MSVC multi-threaded DLL runtime
+	<LI> 1.1.5: Replaced useless SDL_SetClipping() with SDL_SetClipRect()
+	<LI> 1.1.5: Added a flag to YUV overlays to show hardware support
+	<LI> 1.1.5: Added SDL_WasInit() to see what is currently initialized
+	<LI> 1.1.5: YUV overlays can now be accelerated with DirectX
+	<LI> 1.1.5: YUV overlays now have working pitch (thanks Vivien)
+	<LI> 1.1.5: Prompt the user if MacOS mode change may damage hardware
+	<LI> 1.1.5: Fixed DrawSprocket video mode lists and mode changes
+	<LI> 1.1.5: Added DrawSprocket acceleration of colorkey blits
+	<LI> 1.1.5: MacOS event handling is much more responsive by default
+	<LI> 1.1.5: MacOS modifier keys now generate key events
+	<LI> 1.1.5: Mattias Engdegård did the "Great Alpha Flip"
+	<LI> 1.1.5: Added SDL_DisplayFormatAlpha() for fast alpha blits
+	<LI> 1.1.5: Added SDL_MapRGBA() and SDL_GetRGBA() to handle alpha
+	<LI> 1.1.5: SDL_SetAlpha() now accepts the SDL_RLEACCEL flag
+	<LI> 1.1.5: Blit semantics involving alpha are now well defined
+	<LI> 1.1.5: Added support for X11 DirectColor visuals for gamma API
+	<LI> 1.1.5: Added initial AmigaOS support (thanks Gabriele Greco)
+	<LI> 1.1.5: Added an initial gamma correction API (thanks Daniel)
+	<LI> 1.1.5: Disable DGA mouse while X11 application is iconified
+	<LI> 1.1.5: Allow 16-bit audio on Solaris (thanks Mattias)
+	<LI> 1.1.5: Added RLE acceleration of alpha blits (thanks Mattias)
+	<LI> 1.1.5: New documentation from the SDL Documentation Project
+	<LI> 1.1.4: Work around window resize bug in KDE 1.2
+	<LI> 1.1.4: Command-click is interpreted as right click on MacOS
+	<LI> 1.1.4: Removed ESounD detection on Solaris
+	<LI> 1.1.4: Updated to libtool 1.3.5 and latest config.guess
+	<LI> 1.1.4: testgl now works on 8-bit displays under X11
+	<LI> 1.1.4: SDL_WINDOWID hack now works with OpenGL on Linux
+	<LI> 1.1.4: Builds correctly on UNIX without X11 installed
+	<LI> 1.1.4: Fixed default GL driver loading on Win32
+	<LI> 1.1.4: Implemented fullscreen toggle on BeOS (thanks David)
+	<LI> 1.1.4: No longer use DirectDraw with OpenGL modes on Win32
+	<LI> 1.1.4: Added support for 320x200x8 in SVGAlib (thanks Michele)
+	<LI> 1.1.4: Implemented resizable windows on BeOS (thanks David)
+	<LI> 1.1.4: RLE colorkey encoding reduces memory use (thanks Mattias)
+	<LI> 1.1.4: The CD track length variable is now 32-bits (thanks Martin)
+	<LI> 1.1.4: Fixed crashing bug in Win32 semaphores (thanks Markus)
+	<LI> 1.1.4: Disabled aggresive gcc optimizations on X86
+	<LI> 1.1.4: Added support for blitting with GL (thanks Daniel Vogel)
+	<LI> 1.1.4: Improved the speed of the 16-bit colorkey copy blit
+	<LI> 1.1.4: Fixed pthread condition variable timeout
+	<LI> 1.1.3: Use timeGetTime() instead of GetTickCount() on Win32
+	<LI> 1.1.3: Release mouse when popped out of fullscreen on X11
+	<LI> 1.1.3: IRIX 6.5 and FreeBSD 4.0 are now officially supported
+	<LI> 1.1.3: Added optimization flags when compiling on x86 with gcc
+	<LI> 1.1.3: On BeOS, change to app directory when launched by Tracker
+	<LI> 1.1.3: Hold the option key on launch to get dialog on MacOS
+	<LI> 1.1.3: Added DrawSprockets on MacOS (thanks Darrell Walisser)
+	<LI> 1.1.3: Added support for Linux 2.4 input interface (HID)
+	<LI> 1.1.3: Fixed 24-bpp blits on big-endian systems (thanks Mattias)
+	<LI> 1.1.3: Don't try to use DGA mouse support on XFree86 4.00
+	<LI> 1.1.3: Don't create an X11 shared memory buffer for GL displays
+	<LI> 1.1.3: Framebuffer console acceleration disabled (broken) on G200
+	<LI> 1.1.3: Allow maximize on resizable Win32 surfaces (thanks Randi)
+	<LI> 1.1.3: Much faster RLE colorkey blit (thanks Xark and Mattias)
+	<LI> 1.1.3: Fixed some problems with iconification and focus in X11
+	<LI> 1.1.3: Added IMPS/2 protocol support for framebuffer console
+	<LI> 1.1.3: Added user-resizable video mode support
+	<LI> 1.1.3: Added arbitrary scaling of YUV overlay surfaces
+	<LI> 1.1.3: Added support for semaphores and condition variables
+	<LI> 1.1.3: Added SDL_ASYNCBLIT flag for asynchronous video updates
+	<LI> 1.1.3: Don't let the WM place window in X11 fullscreen mode
+	<LI> 1.1.3: Unload GL library after X11 display has closed
+	<LI> 1.1.3: Fixed X11 error when a clipped rectangle is updated
+	<LI> 1.1.3: Fixed crash when surface memory can't be allocated
+	<LI> 1.1.3: Added a check for DirectX 5 audio (thanks Markus)
+	<LI> 1.1.3: Added inline MMX assembly for YUV -> RGB conversion
+	<LI> 1.1.3: Fixed startup crash in X11_RefreshDisplay()
+	<LI> 1.1.3: SDL_Init(SDL_INIT_AUDIO) no longer fails with no soundcard
+	<LI> 1.1.3: Initial YUV video overlay support (supports XvImages)
+	<LI> 1.1.3: Fixed BadMatch X11 error with GLX 1.3
+	<LI> 1.1.3: Worked around incompatibilities with XFree86 4.0 vidmode
+	<LI> 1.1.3: The audio Makefile no longer takes forever to create
+	<LI> 1.1.3: The joystick hat positions changed to constants
+	<LI> 1.1.3: Fixed overlapping copy blit with odd widths
+	<LI> 1.1.3: Fix for SDL_WINDOWID crash contributed by Mattias
+	<LI> 1.1.3: Speeded up 32-bit alpha channel blits by nearly 100%
+	<LI> 1.1.3: Added experimental DGA 2.0 support (set SDL_VIDEODRIVER)
+	<LI> 1.1.2: Fixed crash running on NT with a read-only filesystem
+	<LI> 1.1.2: Re-use thread creation mutex on glibc-2.0 systems
+	<LI> 1.1.2: SDL_WM_SetIcon() now uses icon colorkey if mask is NULL
+	<LI> 1.1.2: Win32 relative mouse mode fixes (thanks Randi Relander)
+	<LI> 1.1.2: Not being able to set audio frags is no longer fatal
+	<LI> 1.1.2: Added support for multiple timers (thanks Stephane Peter)
+	<LI> 1.1.2: Copy blits optimized using inline assembly on x86 Linux
+	<LI> 1.1.2: Copy blit can now handle overlapping blits
+	<LI> 1.1.2: Fixed GL direct rendering on Utah GLX (thanks John Fulmer)
+	<LI> 1.1.2: Added unofficial support for AIX (thanks Carsten Griwodz)
+	<LI> 1.1.2: Enabled X11 VidMode extension on remote displays
+	<LI> 1.1.2: Load libGL.so.1 under X11 if an app isn't linked with GL
+	<LI> 1.1.2: Don't restack windows in the X11 environment
+	<LI> 1.1.2: Multiple X11 visual support (thanks Mattias Engdegård)
+	<LI> 1.1.0: Internal event state is updated before filter is called
+	<LI> 1.1.0: Worked around DGA mouse cursor bug in Voodoo X server
+	<LI> 1.1.0: Added SDL OpenGL documentation (thanks Nicholas Vining)
+	<LI> 1.1.0: Added AAlib video driver support (thanks Stephane Peter)
+	<LI> 1.1.0: Added fullscreen support for Win32 GDI video driver
+	<LI> 1.1.0: Added SDL_GetAudioState() to get current audio status
+	<LI> 1.1.0: Added SDL_GetRelativeMouseState() to get relative motion
+	<LI> 1.1.0: Added 32-bit PII MMX optimized blitters from Hermes
+	<LI> 1.1.0: Added SDL_bool datatype for functions returning true/false
+	<LI> 1.1.0: Improved alpha blend speed (thanks Alexandre Courbot)
+	<LI> 1.1.0: Added function to queue events: SDL_PushEvent()
+	<LI> 1.1.0: Added user-defined event type to SDL_Event structure
+	<LI> 1.1.0: Added SDL_InitSubSystem() and SDL_QuitSubSystem()
+	<LI> 1.1.0: Added BDirectWindow fullscreen support on BeOS
+	<LI> 1.1.0: Added initial joystick support (Linux, Win32, BeOS, MacOS)
+	<LI> 1.1.0: The timer now runs in a separate thread if possible
+	<LI> 1.1.0: Added initial OpenGL support (Linux, Win32, BeOS, MacOS)
+	<LI> 1.0.9: Avoid potential crash in Win32 mouse handling (thanks Cliff)
+	<LI> 1.0.9: Fixed bug where /dev/dsp was incorrectly marked available
+	<LI> 1.0.9: Fixed DirectX crash if video height is larger than width
+	<LI> 1.0.9: Fixed win32 timer error message typo (thanks Martin Dvorak)
+	<LI> 1.0.8: Fixed deadlock if SDL_LockAudio() called from audio thread
+	<LI> 1.0.8: Fixed a race condition in thread creation
+	<LI> 1.0.7: Added detection for Linux supermount CD-ROM drives
+	<LI> 1.0.6: Added --static-libs option to sdl-config
+	<LI> 1.0.6: Fixed a clipping bug in the RLE colorkey blitting
+	<LI> 1.0.6: Mouse window manager routines implemented on MacOS
+	<LI> 1.0.6: Fixed SDL_HWPALETTE in fullscreen X11 video driver
+	<LI> 1.0.6: Improved relative mouse warping in X11 video driver
+	<LI> 1.0.6: DGA mouse mode is now enabled by SDL_VIDEO_X11_DGAMOUSE
+	<LI> 1.0.6: Grab input by default in fullscreen mode
+	<LI> 1.0.6: Detect hanging (incorrectly configured) Linux soundcard
+	<LI> 1.0.6: If ESPEAKER env variable is set, use ESD audio driver
+	<LI> 1.0.5: Fixed audio structure alignment for packing compilers
+	<LI> 1.0.5: Exposed SDL_AudioInit() and SDL_VideoInit()
+	<LI> 1.0.5: Added SDL_WM_ToggleFullScreen(), implemented for X11
+	<LI> 1.0.5: Removed ALT-Enter functionality - should be in apps
+	<LI> 1.0.5: The DSP audio driver is used by default on Linux
+	<LI> 1.0.4: Added optional DMA support for the Linux audio driver
+	<LI> 1.0.4: Fixed CD-ROM opening on the iBook under MacOS
+	<LI> 1.0.4: Fixed a crash in 8-bit mode when using X11 video
+	<LI> 1.0.4: Initial audio support on MacOS (thanks Darrell Walisser)
+	<LI> 1.0.4: The audio thread runs at high priority on Win32
+	<LI> 1.0.4: ESD audio support is now a separate selectable driver
+	<LI> 1.0.4: Initial OpenBSD support (thanks Federico Schwindt)
+	<LI> 1.0.4: Fixed hang when closing audio on Windows 2000
+	<LI> 1.0.4: Warn about monochrome X displays (thanks Christian Bauer)
+	<LI> 1.0.4: Fixed spurious X11 mouse focus events at ALT-ENTER
+	<LI> 1.0.4: Perform input ungrab at video quit, just in case
+	<LI> 1.0.4: Corrected X11 depth reporting in SDL_VideoModeOK()
+	<LI> 1.0.3: Disable mouse threshold when X11 mouse is in warp mode
+	<LI> 1.0.3: Fixed black-screen on exit in fbcon video driver
+	<LI> 1.0.3: Much improved console switching in fbcon video driver
+	<LI> 1.0.3: Fixed X11 UNICODE translation bug (thanks Andreas Arens)
+	<LI> 1.0.3: Fixed WaveOut mutex logic bug (thanks Markus Oberhum)
+	<LI> 1.0.3: Use X11 mouse warping when cursor hidden and input grabbed
+	<LI> 1.0.3: Doesn't try to use TrackMouseEvent() on Win95
+	<LI> 1.0.3: DirectColor support in fbcon driver (thanks Adam Meyerowitz)
+	<LI> 1.0.3: Fixed ALT-ENTER key state problem on X11
+	<LI> 1.0.2: Fixed Win32 code to run on VMWare with DIB video driver
+	<LI> 1.0.2: Added window manager function: SDL_WM_GrabInput()
+	<LI> 1.0.2: Added window manager function: SDL_WM_IconifyWindow()
+	<LI> 1.0.2: Added ALT-ENTER fullscreen toggle for X11 video driver
+	<LI> 1.0.2: X11 fullscreen mode uses DGA mouse if cursor is hidden
+	<LI> 1.0.2: New X11 fullscreen code doesn't require root
+	<LI> 1.0.2: Mouse focus and position is now updated at video mode set
+	<LI> 1.0.2: Mouse focus loss is now detected under Win32
+	<LI> 1.0.2: Menubar hiding is more robust on MacOS (thanks Matt Slott)
+	<LI> 1.0.2: Added CD-ROM support on MacOS (thanks Matt Slott)
+	<LI> 1.0.2: Added non-root fullscreen modes under X11 (thanks Stephane)
+	<LI> 1.0.2: Added docs for time functions (thanks Christian Biesinger)
+	<LI> 1.0.2: Squeezed a little more speed out of blitters (Duff's device)
+	<LI> 1.0.2: Added hardware acceleration for 3Dfx to fbcon driver.
+	<LI> 1.0.2: Added hardware acceleration for Matrox to fbcon driver.
+	<LI> 1.0.2: Windows mouse driver now recognizes the middle button.
+	<LI> 1.0.2: X11 driver now recognizes the "unix:0" display as local.
+	<LI> 1.0.2: Fixed a bug in DGA support which crashed some X servers.
+	<LI> 1.0.2: Added GPM repeater support (gpm -R) to fbcon driver
+	<LI> 1.0.2: Added support for hardware surfaces to fbcon driver
+	<LI> 1.0.2: Implemented console switching in fbcon driver
+	<LI> 1.0.2: Implemented graphics mode detection in fbcon driver
+	<LI> 1.0.2: Added SDL_EnableKeyRepeat() (thanks Jim Kutter)
+	<LI> 1.0.2: Enabled DirectSound on Windows 2000
+	<LI> 1.0.1: Fixed the frame buffer video driver on LinuxPPC
+	<LI> 1.0.1: Stopped using DirectSound on Windows NT.
+	<LI> 1.0.1: Stopped using DirectX when DINPUT.DLL is not installed.
+	<LI> 1.0.1: Added pthread detection to configure.in for FreeBSD.
+	<LI> 1.0.1: Updated the Solaris audio code for the 1.0 API
+	<LI> 1.0.1: Updated the MacOS code for the 1.0 internal API
+</UL>
+
+<H2>
+Major changes since SDL 0.10.0:
+</H2>
+<UL>
+	<LI> 0.11.5: Fixed mouse warping in fullscreen mode
+	<LI> 0.11.5: Added a new function SDL_GetVideoSurface()
+	<LI> 0.11.5: Renamed SDL_AllocSurface() SDL_CreateRGBSurface()
+	<LI> 0.11.5: Added a new function SDL_CreateRGBSurfaceFrom()
+	<LI> 0.11.4: Added support for multiple compiled-in video drivers
+	<LI> 0.11.3: Fixed 16 --> 32 bpp blitting - using C instead of Hermes. 
+	<LI> 0.11.3: Fixed double-buffering bug in the DirectX driver
+	<LI> 0.11.3: Added GGI video driver (thanks Jon Taylor)
+	<LI> 0.11.2: Added automake/aclocal/autoconf support
+	<LI> 0.11.1: Added an initial (buggy) MacOS CD-ROM driver
+	<LI> 0.11.1: Improved Linux CD-ROM detection
+	<LI> 0.11.1: Added a workaround for DGA mouse bug on Voodoo 3
+	<LI> 0.11.1: Fixed 24bpp --> 8bpp blit crash
+	<LI> 0.11.1: Fixed a bug in blit mapping when palette changed
+	<LI> 0.11.1: Added a Linux SBLive beta driver workaround
+	<LI> 0.11.1: Fixed Win32 cross-compile problem with mingw32
+	<LI> 0.11.1: Loss of keyboard focus now causes keys to be reset
+	<LI> 0.11.1: DGA DirectMouse is conditionally compiled (default off)
+</UL>
+
+<H2>
+Major changes since SDL 0.8.0:
+</H2>
+<UL>
+	<LI> 0.9.16: Made SDL error messages thread-safe
+	<LI> 0.9.15: If you have r/w access to /dev/mem, DGA works on Linux
+	<LI> 0.9.15: Added support for Linux on the ARM (Netwinder)
+	<LI> 0.9.14: Removed color cursor support, fixed b/w cursors
+	<LI> 0.9.14: Fixed long-standing X11 DGA colormap problem
+	<LI> 0.9.13: Added dynamic load function: SDL_SetLibraryPath()
+	<LI> 0.9.13: Added unofficial support for MacOS
+	<LI> 0.9.13: Added unofficial support for FreeBSD
+	<LI> 0.9.13: Added unofficial support for IRIX
+	<LI> 0.9.13: Updated support for BeOS from R3 to R4.5
+	<LI> 0.9.13: Added SDL_SetLibraryPath() function (thanks Karsten Laux)
+	<LI> 0.9.13: Fixed 8-bit audio conversion when using SDL_MixAudio()
+	<LI> 0.9.13: Fixed audio thread lingering when app dies on Linux
+	<LI> 0.9.13: Fixed color problem in X display to other-endian systems
+	<LI> 0.9.13: Finally able to detect X11 key repeat (thanks GII team!)
+	<LI> 0.9.13: Added support for Visual C++ 5.0 development environment
+	<LI> 0.9.13: Added support for Linux on the Alpha
+	<LI> 0.9.13: Added support for international keyboards (see WhatsNew)
+	<LI> 0.9.12: Added support for loading IMA ADPCM compressed WAV files
+	<LI> 0.9.12: Fixed bug when mixing 8-bit audio in SDL_MixAudio()
+	<LI> 0.9.12: Added Enlightenment Sound Daemon audio support on Linux
+	<LI> 0.9.12: Added MTRR support for Linux/X11 (thanks David Barth)
+	<LI> 0.9.12: Added support for LinuxPPC 5.0
+	<LI> 0.9.12: Fixed place where some audio conversions aren't detected
+	<LI> 0.9.12: Fixed serious bug in installation script
+	<LI> 0.9.12: Added SDL_FreeWAV() function for freeing DLL memory
+	<LI> 0.9.12: Fixed potential memory leak in SDL_LoadWAV_RW()
+	<LI> 0.9.11: Freeing video surface has no longer crashes SDL_Quit()
+	<LI> 0.9.11: Included new asm blitters from Hermes library 1.2.4
+	<LI> 0.9.11: SDL_WaitThread() now gets the thread's return status
+	<LI> 0.9.11: SDL_MixAudio() takes a larger volume range (0-128)
+	<LI> 0.9.11: SDL no longer changes the X11 keyboard repeat
+	<LI> 0.9.11: Added a data source abstraction for loading/saving data
+	<LI> 0.9.11: Added three built in data abstractions:<BR>
+	               SDL_RWFromFile(), SDL_RWFromFP(), SDL_RWFromMem()
+	<LI> 0.9.11: Added stdio-like functions for using data sources:<BR>
+	               SDL_RWseek(), SDL_RWread(), SDL_RWwrite(), SDL_RWclose()
+	<LI> 0.9.11: Replaced SDL_CalculateEndian() with SDL_BYTEORDER macro
+	<LI> 0.9.11: Endian swapping functions are now macros, for speed.
+	<LI> 0.9.11: Endian read/write functions now use data sources
+	<LI> 0.9.11: Added function SDL_LoadWAV_RW() for data sources
+	<LI> 0.9.11: Added function SDL_LoadBMP_RW() for data sources
+	<LI> 0.9.11: Added function SDL_SaveBMP_RW() for data sources
+	<LI> 0.9.10: Mixer no longer fails if timidity isn't installed
+	<LI> 0.9.10: Mixer restarts MOD files on play (thanks Bill Kendrick)
+	<LI> 0.9.10: Fixed occasional crashing of the mixer library
+	<LI> 0.9.10: Fixed icon display on Afterstep under Linux
+	<LI> 0.9.10: Fixed occasional crash in mixer example
+	<LI> 0.9.10: Linux cdrom list now comes from /etc/fstab
+	<LI> 0.9.10: Fixed support for UK keyboard (thanks John Elliott)
+	<LI> 0.9.10: The event queue is now thread-safe
+	<LI> 0.9.10: Added event queue pump function: SDL_PumpEvents()
+	<LI> 0.9.10: Added low level event function: SDL_PeepEvents()
+	<LI> 0.9.10: Added a new thread function: SDL_ThreadID()
+	<LI> 0.9.10: Fixed an audio rate conversion memory overrun
+	<LI> 0.9.10: Fixed crash with RLE acceleration on big surfaces
+	<LI> 0.9.10: Improved MacOS display driver - added fullscreen
+	<LI> 0.9.10: Removed spurious warnings from Linux X11 driver
+	<LI> 0.9.10: Fixed memory leak in SDL_InvalidateMap()
+	<LI> 0.9.10: Fixed right button of 2-button mice on Win32
+	<LI> 0.9.10: Enabled XFree86 mode changes on older servers
+	<LI> 0.9.9: SDL_LoadBMP() handles BMP files created with GIMP
+	<LI> 0.9.9: SDL_LoadWAV() handles WAV files with "LIST" chunks
+	<LI> 0.9.9: Fixed problem with audio underflow on Solaris
+	<LI> 0.9.9: Initial support for 4-speaker audio output devices
+	<LI> 0.9.8: Fixed corrupt VC++ 5.0 desktop file
+	<LI> 0.9.8: Now detects fixed version of Metro-X X11 server
+	<LI> 0.9.8: Fixed XFree86 DGA banked mode update
+	<LI> 0.9.8: Fixed mouse press viewport shift on XFree86 DGA
+	<LI> 0.9.7: Fixed problem with displaying remotely via X11
+	<LI> 0.9.7: Win32 uses software cursor when fullscreen
+	<LI> 0.9.7: Win32 mouse uses DirectInput when fullscreen
+	<LI> 0.9.7: Added OpenGL software rendering via Mesa (demos archive)
+	<LI> 0.9.7: Fixed memory leak in ADPCM WAV decoding
+	<LI> 0.9.6: Added CD-ROM audio API documentation
+	<LI> 0.9.6: Fixed potential BeOS audio-related crash
+	<LI> 0.9.6: Fixed crash when resetting the video mode in DirectX
+	<LI> 0.9.6: Fixed errors compiling with the SparcWorks compiler
+	<LI> 0.9.6: Replaced SDL_GetDisplayFormat() with SDL_GetVideoInfo()
+	<LI> 0.9.6: Added a new fast fill function: SDL_FillRect()
+	<LI> 0.9.6: Added blit acceleration flags to SDL_AllocSurface()
+	<LI> 0.9.6: Added new double-buffering function: SDL_Flip()
+	<LI> 0.9.6: Fixed problem with buggy Metro-X X11 server
+	<LI> 0.9.6: Fixed 8-bit audio on Solaris with dbri hardware
+	<LI> 0.9.6: Fixed alarm clock problem with Solaris pthreads
+	<LI> 0.9.6: Fixed BeOS compilation problem
+	<LI> 0.9.5: Added tools to create Win32 icons in directx/icon/
+	<LI> 0.9.5: You can now pass a NULL mask to SDL_WM_SetIcon()
+	<LI> 0.9.5: Added support files for compiling with VC++ 5.0
+	<LI> 0.9.5: Fixed icon color bug under Win32
+	<LI> 0.9.5: Re-added SDL_LowerBlit() - not safe for use on display
+	<LI> 0.9.5: Fixed 0.9.x cursor blit deadlock
+	<LI> 0.9.5: Added SDL_FPLoadWAV(), SDL_FPLoadBMP(), SDL_FPSaveBMP()
+	<LI> 0.9.5: Added Linux, Win32, and BeOS CD audio support
+	<LI> 0.9.5: MMX accelerated blit disabled -- temporarily broken
+	<LI> 0.9.4: Fixed endianness issue with BeOS x86 blitting
+	<LI> 0.9.4: Fixed quit interrupt delivery on BeOS
+	<LI> 0.9.4: Fixed dynamic loading on BeOS
+	<LI> 0.9.4: Fixed DirectX audio on Win98
+	<LI> 0.9.4: Fixed possible sound-related crash on Linux PPC
+	<LI> 0.9.3: Mouse motion arrives as absolute and relative coordinates
+	<LI> 0.9.3: Fixed Visual C++ structure packing
+	<LI> 0.9.3: Fixed UNIX dynamic link library installation
+	<LI> 0.9.2: DirectX audio no longer hangs when app loses focus
+	<LI> 0.9.2: Fixed DirectX HiColor crash (palette bug)
+	<LI> 0.9.1: Fixed DirectX &lt;ALT&gt; key handling
+	<LI> 0.9.1: Fixed DirectX windowed palette problems
+	<LI> 0.9.1: Removed SDL_MapSurface() and SDL_UnmapSurface()
+	<LI> 0.9.0: Initial port to IRIX 6.x
+	<LI> 0.9.0: Initial port to OSF/1 3.2       (no sound yet)
+	<LI> 0.9.0: MacOS port in progress
+</UL>
+
+<H2>
+Major changes since SDL 0.7:
+</H2>
+<UL>
+	<LI>	Separated the demos and examples into a separate archive
+	<LI>	Added support for loading Microsoft compressed WAV files
+	<LI>	Added "soft" application crash recovery (signal handlers)
+	<LI>	Fixed POSIX signal handling interaction with threads
+	<LI>	Fixed audio output on MKLinux
+	<LI>	Added dynamic library version checking
+	<LI>	Updated for DirectX 6.0
+	<LI>	Cleaned up dynamic linking and added static linking
+	<LI>	Added automatic audio format and rate conversion
+	<LI>	Optimized some blitter cases (8 --> 16/32 and 32 --> 16/8)
+	<LI>	Removed precalculated alpha blending acceleration
+	<LI>	Key and mouse button events are split into up/down events
+	<LI>	It is now much easier to set an optimal video mode
+</UL>
+
+<H2>
+Major changes since SDL 0.5:
+</H2>
+<UL>
+	<LI>	Ported to Solaris 2.6
+	<LI>	Added XFree86 Direct Graphic Access support
+	<LI>	Supports LinuxPPC without threads
+	<LI>	Completely rewritten video/surface API -- see SDL_video.h
+	<LI>	Completely rewritten event API
+	<LI>	Optimized black-white cursor creation
+	<LI>	Added support for run-length-encoded colorkeying
+	<LI>	Added support for hardware accelerated blits
+	<LI>	Added support for blitting from 1-bit surfaces (bitmaps)
+	<LI>	Added a function to simplify setting video modes
+	<LI>	Added support for loading WAV files
+	<LI>	Added endian swapping functions for memory values
+	<LI>	Added alpha blending using alpha value or channel
+	<LI>	Added precalculated alpha blending acceleration
+	<LI>	Added function to return current time in milliseconds
+	<LI>	New event type SDL_ACTIVEEVENT, to detect iconification
+	<LI>	New event type SDL_SYSWMEVENT, for custom window hooks
+	<LI>	Added a platform dependent function to get window handle
+	<LI>	Added a function to check the run-time version of SDL
+	<LI>	Added periodic timer support at 10 ms resolution
+	<LI>	Added support for the SDL_DEBUG environment variable
+	<LI>	Miscellaneous internal cleanups
+</UL>
+
+<H2>
+Major changes since SDL 0.4:
+</H2>
+<UL>
+	<LI>	SDL library code is now dynamically loaded
+	<LI>	Added support for pthreads (Linux glibc2)
+	<LI>	Removed SDL_mutexN() and SDL_mutexIncr()
+</UL>
+
+<H2>
+Major changes since SDL 0.3:
+</H2>
+<UL>
+	<LI>	Added support for DirectX 5.0
+	<LI>	Added support for surfaces in video memory
+	<LI>	Added support for source color-key blitting
+	<LI>	Added support for single-rectangle clipping
+	<LI>	Added support for warping (moving) the cursor
+	<LI>	Added support for color cursors
+	<LI>	Greatly simplified internal event queue
+	<LI>	Minor bug-fixes
+</UL>
+
+<P>
+<IMG SRC="docs/images/rainbow.gif" ALT="[separator]" WIDTH="100%">
+
+</BODY>
+</HTML>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2 @@
+Makefile.in
+Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,4 @@
+
+SUBDIRS = html man3
+
+EXTRA_DIST = index.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2 @@
+Makefile.in
+Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,199 @@
+EXTRA_DIST = \
+    audio.html \
+    cdrom.html \
+    event.html \
+    eventfunctions.html \
+    eventstructures.html \
+    general.html \
+    guide.html \
+    guideaboutsdldoc.html \
+    guideaudioexamples.html \
+    guidebasicsinit.html \
+    guidecdromexamples.html \
+    guidecredits.html \
+    guideeventexamples.html \
+    guideexamples.html \
+    guideinput.html \
+    guideinputkeyboard.html \
+    guidepreface.html \
+    guidethebasics.html \
+    guidetimeexamples.html \
+    guidevideo.html \
+    guidevideoexamples.html \
+    index.html \
+    joystick.html \
+    reference.html \
+    sdlactiveevent.html \
+    sdladdtimer.html \
+    sdlaudiocvt.html \
+    sdlaudiospec.html \
+    sdlblitsurface.html \
+    sdlbuildaudiocvt.html \
+    sdlcd.html \
+    sdlcdclose.html \
+    sdlcdeject.html \
+    sdlcdname.html \
+    sdlcdnumdrives.html \
+    sdlcdopen.html \
+    sdlcdpause.html \
+    sdlcdplay.html \
+    sdlcdplaytracks.html \
+    sdlcdresume.html \
+    sdlcdstatus.html \
+    sdlcdstop.html \
+    sdlcdtrack.html \
+    sdlcloseaudio.html \
+    sdlcolor.html \
+    sdlcondbroadcast.html \
+    sdlcondsignal.html \
+    sdlcondwait.html \
+    sdlcondwaittimeout.html \
+    sdlconvertaudio.html \
+    sdlconvertsurface.html \
+    sdlcreatecond.html \
+    sdlcreatecursor.html \
+    sdlcreatemutex.html \
+    sdlcreatergbsurface.html \
+    sdlcreatergbsurfacefrom.html \
+    sdlcreatesemaphore.html \
+    sdlcreatethread.html \
+    sdlcreateyuvoverlay.html \
+    sdldelay.html \
+    sdldestroycond.html \
+    sdldestroymutex.html \
+    sdldestroysemaphore.html \
+    sdldisplayformat.html \
+    sdldisplayformatalpha.html \
+    sdldisplayyuvoverlay.html \
+    sdlenablekeyrepeat.html \
+    sdlenableunicode.html \
+    sdlevent.html \
+    sdleventstate.html \
+    sdlfillrect.html \
+    sdlflip.html \
+    sdlfreecursor.html \
+    sdlfreesurface.html \
+    sdlfreewav.html \
+    sdlfreeyuvoverlay.html \
+    sdlgetappstate.html \
+    sdlgetaudiostatus.html \
+    sdlgetcliprect.html \
+    sdlgetcursor.html \
+    sdlgeteventfilter.html \
+    sdlgetgammaramp.html \
+    sdlgetkeyname.html \
+    sdlgetkeystate.html \
+    sdlgetmodstate.html \
+    sdlgetmousestate.html \
+    sdlgetrelativemousestate.html \
+    sdlgetrgb.html \
+    sdlgetrgba.html \
+    sdlgetthreadid.html \
+    sdlgetticks.html \
+    sdlgetvideoinfo.html \
+    sdlgetvideosurface.html \
+    sdlglattr.html \
+    sdlglgetattribute.html \
+    sdlglgetprocaddress.html \
+    sdlglloadlibrary.html \
+    sdlglsetattribute.html \
+    sdlglswapbuffers.html \
+    sdlinit.html \
+    sdlinitsubsystem.html \
+    sdljoyaxisevent.html \
+    sdljoyballevent.html \
+    sdljoybuttonevent.html \
+    sdljoyhatevent.html \
+    sdljoystickclose.html \
+    sdljoystickeventstate.html \
+    sdljoystickgetaxis.html \
+    sdljoystickgetball.html \
+    sdljoystickgetbutton.html \
+    sdljoystickgethat.html \
+    sdljoystickindex.html \
+    sdljoystickname.html \
+    sdljoysticknumaxes.html \
+    sdljoysticknumballs.html \
+    sdljoysticknumbuttons.html \
+    sdljoysticknumhats.html \
+    sdljoystickopen.html \
+    sdljoystickopened.html \
+    sdljoystickupdate.html \
+    sdlkey.html \
+    sdlkeyboardevent.html \
+    sdlkeysym.html \
+    sdlkillthread.html \
+    sdllistmodes.html \
+    sdlloadbmp.html \
+    sdlloadwav.html \
+    sdllockaudio.html \
+    sdllocksurface.html \
+    sdllockyuvoverlay.html \
+    sdlmaprgb.html \
+    sdlmaprgba.html \
+    sdlmixaudio.html \
+    sdlmousebuttonevent.html \
+    sdlmousemotionevent.html \
+    sdlmutexp.html \
+    sdlmutexv.html \
+    sdlnumjoysticks.html \
+    sdlopenaudio.html \
+    sdloverlay.html \
+    sdlpalette.html \
+    sdlpauseaudio.html \
+    sdlpeepevents.html \
+    sdlpixelformat.html \
+    sdlpollevent.html \
+    sdlpumpevents.html \
+    sdlpushevent.html \
+    sdlquit.html \
+    sdlquitevent.html \
+    sdlquitsubsystem.html \
+    sdlrect.html \
+    sdlremovetimer.html \
+    sdlresizeevent.html \
+    sdlsavebmp.html \
+    sdlsempost.html \
+    sdlsemtrywait.html \
+    sdlsemvalue.html \
+    sdlsemwait.html \
+    sdlsemwaittimeout.html \
+    sdlsetalpha.html \
+    sdlsetcliprect.html \
+    sdlsetcolorkey.html \
+    sdlsetcolors.html \
+    sdlsetcursor.html \
+    sdlseteventfilter.html \
+    sdlsetgamma.html \
+    sdlsetgammaramp.html \
+    sdlsetmodstate.html \
+    sdlsetpalette.html \
+    sdlsettimer.html \
+    sdlsetvideomode.html \
+    sdlshowcursor.html \
+    sdlsurface.html \
+    sdlsyswmevent.html \
+    sdlthreadid.html \
+    sdlunlockaudio.html \
+    sdlunlocksurface.html \
+    sdlunlockyuvoverlay.html \
+    sdlupdaterect.html \
+    sdlupdaterects.html \
+    sdluserevent.html \
+    sdlvideodrivername.html \
+    sdlvideoinfo.html \
+    sdlvideomodeok.html \
+    sdlwaitevent.html \
+    sdlwaitthread.html \
+    sdlwarpmouse.html \
+    sdlwasinit.html \
+    sdlwmgetcaption.html \
+    sdlwmgrabinput.html \
+    sdlwmiconifywindow.html \
+    sdlwmsetcaption.html \
+    sdlwmseticon.html \
+    sdlwmtogglefullscreen.html \
+    thread.html \
+    time.html \
+    video.html \
+    wm.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/audio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,234 @@
+<HTML
+><HEAD
+><TITLE
+>Audio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickClose"
+HREF="sdljoystickclose.html"><LINK
+REL="NEXT"
+TITLE="SDL_AudioSpec"
+HREF="sdlaudiospec.html"><META
+NAME="KEYWORD"
+CONTENT="audio"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickclose.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlaudiospec.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="AUDIO"
+>Chapter 10. Audio</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlaudiospec.html"
+>SDL_AudioSpec</A
+> &#8212; Audio Specification Structure</DT
+><DT
+><A
+HREF="sdlopenaudio.html"
+>SDL_OpenAudio</A
+> &#8212; Opens the audio device with the desired parameters.</DT
+><DT
+><A
+HREF="sdlpauseaudio.html"
+>SDL_PauseAudio</A
+> &#8212; Pauses and unpauses the audio callback processing</DT
+><DT
+><A
+HREF="sdlgetaudiostatus.html"
+>SDL_GetAudioStatus</A
+> &#8212; Get the current audio state</DT
+><DT
+><A
+HREF="sdlloadwav.html"
+>SDL_LoadWAV</A
+> &#8212; Load a WAVE file</DT
+><DT
+><A
+HREF="sdlfreewav.html"
+>SDL_FreeWAV</A
+> &#8212; Frees previously opened WAV data</DT
+><DT
+><A
+HREF="sdlaudiocvt.html"
+>SDL_AudioCVT</A
+> &#8212; Audio Conversion Structure</DT
+><DT
+><A
+HREF="sdlbuildaudiocvt.html"
+>SDL_BuildAudioCVT</A
+> &#8212; Initializes a SDL_AudioCVT structure for conversion</DT
+><DT
+><A
+HREF="sdlconvertaudio.html"
+>SDL_ConvertAudio</A
+> &#8212; Convert audio data to a desired audio format.</DT
+><DT
+><A
+HREF="sdlmixaudio.html"
+>SDL_MixAudio</A
+> &#8212; Mix audio data</DT
+><DT
+><A
+HREF="sdllockaudio.html"
+>SDL_LockAudio</A
+> &#8212; Lock out the callback function</DT
+><DT
+><A
+HREF="sdlunlockaudio.html"
+>SDL_UnlockAudio</A
+> &#8212; Unlock the callback function</DT
+><DT
+><A
+HREF="sdlcloseaudio.html"
+>SDL_CloseAudio</A
+> &#8212; Shuts down audio processing and closes the audio device.</DT
+></DL
+></DIV
+><P
+>Sound on the computer is translated from waves that you hear into a series of 
+values, or samples, each representing the amplitude of the wave.  When these
+samples are sent in a stream to a sound card, an approximation of the original
+wave can be recreated.  The more bits used to represent the amplitude, and the
+greater frequency these samples are gathered, the closer the approximated
+sound is to the original, and the better the quality of sound.</P
+><P
+>This library supports both 8 and 16 bit signed and unsigned sound samples,
+at frequencies ranging from 11025 Hz to 44100 Hz, depending on the 
+underlying hardware.  If the hardware doesn't support the desired audio
+format or frequency, it can be emulated if desired (See 
+<A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio()</TT
+></A
+>)</P
+><P
+>A commonly supported audio format is 16 bits per sample at 22050 Hz.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickclose.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlaudiospec.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickClose</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_AudioSpec</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/cdrom.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,252 @@
+<HTML
+><HEAD
+><TITLE
+>CD-ROM</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CloseAudio"
+HREF="sdlcloseaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDNumDrives"
+HREF="sdlcdnumdrives.html"><META
+NAME="KEYWORD"
+CONTENT="cdrom"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcloseaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdnumdrives.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="CDROM"
+>Chapter 11. CD-ROM</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlcdnumdrives.html"
+>SDL_CDNumDrives</A
+> &#8212; Returns the number of CD-ROM drives on the system.</DT
+><DT
+><A
+HREF="sdlcdname.html"
+>SDL_CDName</A
+> &#8212; Returns a human-readable, system-dependent identifier for the CD-ROM.</DT
+><DT
+><A
+HREF="sdlcdopen.html"
+>SDL_CDOpen</A
+> &#8212; Opens a CD-ROM drive for access.</DT
+><DT
+><A
+HREF="sdlcdstatus.html"
+>SDL_CDStatus</A
+> &#8212; Returns the current status of the given drive.</DT
+><DT
+><A
+HREF="sdlcdplay.html"
+>SDL_CDPlay</A
+> &#8212; Play a CD</DT
+><DT
+><A
+HREF="sdlcdplaytracks.html"
+>SDL_CDPlayTracks</A
+> &#8212; Play the given CD track(s)</DT
+><DT
+><A
+HREF="sdlcdpause.html"
+>SDL_CDPause</A
+> &#8212; Pauses a CDROM</DT
+><DT
+><A
+HREF="sdlcdresume.html"
+>SDL_CDResume</A
+> &#8212; Resumes a CDROM</DT
+><DT
+><A
+HREF="sdlcdstop.html"
+>SDL_CDStop</A
+> &#8212; Stops a CDROM</DT
+><DT
+><A
+HREF="sdlcdeject.html"
+>SDL_CDEject</A
+> &#8212; Ejects a CDROM</DT
+><DT
+><A
+HREF="sdlcdclose.html"
+>SDL_CDClose</A
+> &#8212; Closes a SDL_CD handle</DT
+><DT
+><A
+HREF="sdlcd.html"
+>SDL_CD</A
+> &#8212; CDROM Drive Information</DT
+><DT
+><A
+HREF="sdlcdtrack.html"
+>SDL_CDtrack</A
+> &#8212; CD Track Information Structure</DT
+></DL
+></DIV
+><P
+>SDL supports audio control of up to 32 local CD-ROM drives at once.</P
+><P
+>You use this API to perform all the basic functions of a CD player,
+including listing the tracks, playing, stopping, and ejecting the CD-ROM.
+(Currently, multi-changer CD drives are not supported.)</P
+><P
+>Before you call any of the SDL CD-ROM functions, you must first call
+"<TT
+CLASS="FUNCTION"
+>SDL_Init(SDL_INIT_CDROM)</TT
+>", which scans the system for
+CD-ROM drives, and sets the program up for audio control.  Check the 
+return code, which should be <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, to see if there 
+were any errors in starting up.</P
+><P
+>After you have initialized the library, you can find out how many drives
+are available using the <TT
+CLASS="FUNCTION"
+>SDL_CDNumDrives()</TT
+> function.  
+The first drive listed is the system default CD-ROM drive.  After you have 
+chosen a drive, and have opened it with <TT
+CLASS="FUNCTION"
+>SDL_CDOpen()</TT
+>, 
+you can check the status and start playing if there's a CD in the drive.</P
+><P
+>A CD-ROM is organized into one or more tracks, each consisting of a certain
+number of "frames".  Each frame is ~2K in size, and at normal playing speed,
+a CD plays 75 frames per second.  SDL works with the number of frames on a
+CD, but this can easily be converted to the more familiar minutes/seconds
+format by using the <TT
+CLASS="FUNCTION"
+>FRAMES_TO_MSF()</TT
+> macro.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcloseaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdnumdrives.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CloseAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDNumDrives</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/event.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,208 @@
+<HTML
+><HEAD
+><TITLE
+>Events</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_GrabInput"
+HREF="sdlwmgrabinput.html"><LINK
+REL="NEXT"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><META
+NAME="KEYWORD"
+CONTENT="events"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmgrabinput.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="eventstructures.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="EVENT"
+>Chapter 8. Events</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="event.html#AEN3194"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="eventstructures.html"
+>SDL Event Structures.</A
+></DT
+><DT
+><A
+HREF="eventfunctions.html"
+>Event Functions.</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="AEN3194"
+>Introduction</A
+></H1
+><P
+>Event handling allows your application to receive input from the user. Event handling is initalised (along with video) with a call to:
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_Init(SDL_INIT_VIDEO);</PRE
+>
+Interally, SDL stores all the events waiting to be handled in an event queue. Using functions like <A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+> and <A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+> you can observe and handle waiting input events.</P
+><P
+>The key to event handling in SDL is the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union. The event queue itself is composed of a series of <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> unions, one for each waiting event. <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> unions are read from the queue with the <TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+> function and it is then up to the application to process the information stored with them.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmgrabinput.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_GrabInput</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL Event Structures.</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/eventfunctions.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,236 @@
+<HTML
+><HEAD
+><TITLE
+>Event Functions.</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Events"
+HREF="event.html"><LINK
+REL="PREVIOUS"
+TITLE="SDLKey"
+HREF="sdlkey.html"><LINK
+REL="NEXT"
+TITLE="SDL_PumpEvents"
+HREF="sdlpumpevents.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlkey.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 8. Events</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpumpevents.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="EVENTFUNCTIONS"
+>Event Functions.</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlpumpevents.html"
+>SDL_PumpEvents</A
+> &#8212; Pumps the event loop, gathering events from the input devices.</DT
+><DT
+><A
+HREF="sdlpeepevents.html"
+>SDL_PeepEvents</A
+> &#8212; Checks the event queue for messages and optionally returns them.</DT
+><DT
+><A
+HREF="sdlpollevent.html"
+>SDL_PollEvent</A
+> &#8212; Polls for currently pending events.</DT
+><DT
+><A
+HREF="sdlwaitevent.html"
+>SDL_WaitEvent</A
+> &#8212; Waits indefinitely for the next available event.</DT
+><DT
+><A
+HREF="sdlpushevent.html"
+>SDL_PushEvent</A
+> &#8212; Pushes an event onto the event queue</DT
+><DT
+><A
+HREF="sdlseteventfilter.html"
+>SDL_SetEventFilter</A
+> &#8212; Sets up a filter to process all events before they are posted 
+to the event queue.</DT
+><DT
+><A
+HREF="sdlgeteventfilter.html"
+>SDL_GetEventFilter</A
+> &#8212; Retrieves a pointer to he event filter</DT
+><DT
+><A
+HREF="sdleventstate.html"
+>SDL_EventState</A
+> &#8212; This function allows you to set the state of processing certain events.</DT
+><DT
+><A
+HREF="sdlgetkeystate.html"
+>SDL_GetKeyState</A
+> &#8212; Get a snapshot of the current keyboard state</DT
+><DT
+><A
+HREF="sdlgetmodstate.html"
+>SDL_GetModState</A
+> &#8212; Get the state of modifier keys.</DT
+><DT
+><A
+HREF="sdlsetmodstate.html"
+>SDL_SetModState</A
+> &#8212; Set the current key modifier state</DT
+><DT
+><A
+HREF="sdlgetkeyname.html"
+>SDL_GetKeyName</A
+> &#8212; Get the name of an SDL virtual keysym</DT
+><DT
+><A
+HREF="sdlenableunicode.html"
+>SDL_EnableUNICODE</A
+> &#8212; Enable UNICODE translation</DT
+><DT
+><A
+HREF="sdlenablekeyrepeat.html"
+>SDL_EnableKeyRepeat</A
+> &#8212; Set keyboard repeat rate.</DT
+><DT
+><A
+HREF="sdlgetmousestate.html"
+>SDL_GetMouseState</A
+> &#8212; Retrieve the current state of the mouse</DT
+><DT
+><A
+HREF="sdlgetrelativemousestate.html"
+>SDL_GetRelativeMouseState</A
+> &#8212; Retrieve the current state of the mouse</DT
+><DT
+><A
+HREF="sdlgetappstate.html"
+>SDL_GetAppState</A
+> &#8212; Get the state of the application</DT
+><DT
+><A
+HREF="sdljoystickeventstate.html"
+>SDL_JoystickEventState</A
+> &#8212; Enable/disable joystick event polling</DT
+></DL
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlkey.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpumpevents.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDLKey</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="event.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PumpEvents</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/eventstructures.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,220 @@
+<HTML
+><HEAD
+><TITLE
+>SDL Event Structures.</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Events"
+HREF="event.html"><LINK
+REL="PREVIOUS"
+TITLE="Events"
+HREF="event.html"><LINK
+REL="NEXT"
+TITLE="SDL_Event"
+HREF="sdlevent.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="event.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 8. Events</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="EVENTSTRUCTURES"
+>SDL Event Structures.</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlevent.html"
+>SDL_Event</A
+> &#8212; General event structure</DT
+><DT
+><A
+HREF="sdlactiveevent.html"
+>SDL_ActiveEvent</A
+> &#8212; Application visibility event structure</DT
+><DT
+><A
+HREF="sdlkeyboardevent.html"
+>SDL_KeyboardEvent</A
+> &#8212; Keyboard event structure</DT
+><DT
+><A
+HREF="sdlmousemotionevent.html"
+>SDL_MouseMotionEvent</A
+> &#8212; Mouse motion event structure</DT
+><DT
+><A
+HREF="sdlmousebuttonevent.html"
+>SDL_MouseButtonEvent</A
+> &#8212; Mouse button event structure</DT
+><DT
+><A
+HREF="sdljoyaxisevent.html"
+>SDL_JoyAxisEvent</A
+> &#8212; Joystick axis motion event structure</DT
+><DT
+><A
+HREF="sdljoybuttonevent.html"
+>SDL_JoyButtonEvent</A
+> &#8212; Joystick button event structure</DT
+><DT
+><A
+HREF="sdljoyhatevent.html"
+>SDL_JoyHatEvent</A
+> &#8212; Joystick hat position change event structure</DT
+><DT
+><A
+HREF="sdljoyballevent.html"
+>SDL_JoyBallEvent</A
+> &#8212; Joystick trackball motion event structure</DT
+><DT
+><A
+HREF="sdlresizeevent.html"
+>SDL_ResizeEvent</A
+> &#8212; Window resize event structure</DT
+><DT
+><A
+HREF="sdlsyswmevent.html"
+>SDL_SysWMEvent</A
+> &#8212; Platform-dependent window manager event.</DT
+><DT
+><A
+HREF="sdluserevent.html"
+>SDL_UserEvent</A
+> &#8212; A user-defined event type</DT
+><DT
+><A
+HREF="sdlquitevent.html"
+>SDL_QuitEvent</A
+> &#8212; Quit requested event</DT
+><DT
+><A
+HREF="sdlkeysym.html"
+>SDL_keysym</A
+> &#8212; Keysym structure</DT
+><DT
+><A
+HREF="sdlkey.html"
+>SDLKey</A
+> &#8212; Keysym definitions.</DT
+></DL
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="event.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Events</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="event.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Event</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/general.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,207 @@
+<HTML
+><HEAD
+><TITLE
+>General</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="NEXT"
+TITLE="SDL_Init"
+HREF="sdlinit.html"><META
+NAME="KEYWORD"
+CONTENT="general"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="reference.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlinit.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="GENERAL"
+>Chapter 5. General</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlinit.html"
+>SDL_Init</A
+> &#8212; Initializes SDL</DT
+><DT
+><A
+HREF="sdlinitsubsystem.html"
+>SDL_InitSubSystem</A
+> &#8212; Initialize subsystems</DT
+><DT
+><A
+HREF="sdlquitsubsystem.html"
+>SDL_QuitSubSystem</A
+> &#8212; Shut down a subsystem</DT
+><DT
+><A
+HREF="sdlquit.html"
+>SDL_Quit</A
+> &#8212; Shut down SDL</DT
+><DT
+><A
+HREF="sdlwasinit.html"
+>SDL_WasInit</A
+> &#8212; Check which subsystems are initialized</DT
+></DL
+></DIV
+><P
+>Before SDL can be used in a program it must be initialized with <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>. <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> initializes all the subsystems that the user requests (video, audio, joystick, timers and/or cdrom). Once SDL is initialized with <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> subsystems can be shut down and initialized as needed using <A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+> and <A
+HREF="sdlquitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_QuitSubSystem</TT
+></A
+>.</P
+><P
+>SDL must also be shut down before the program exits to make sure it cleans up correctly. Calling <A
+HREF="sdlquit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+></A
+> shuts down all subsystems and frees any resources allocated to SDL.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlinit.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL Reference</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Init</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guide.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,167 @@
+<HTML
+><HEAD
+><TITLE
+>SDL Guide</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="NEXT"
+TITLE="Preface"
+HREF="guidepreface.html"></HEAD
+><BODY
+CLASS="PART"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="index.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidepreface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="PART"
+><A
+NAME="GUIDE"
+></A
+><DIV
+CLASS="TITLEPAGE"
+><H1
+CLASS="TITLE"
+>I. SDL Guide</H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="guidepreface.html"
+>Preface</A
+></DT
+><DT
+>1. <A
+HREF="guidethebasics.html"
+>The Basics</A
+></DT
+><DT
+>2. <A
+HREF="guidevideo.html"
+>Graphics and Video</A
+></DT
+><DT
+>3. <A
+HREF="guideinput.html"
+>Input handling</A
+></DT
+><DT
+>4. <A
+HREF="guideexamples.html"
+>Examples</A
+></DT
+></DL
+></DIV
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="index.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidepreface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL Library Documentation</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Preface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideaboutsdldoc.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,140 @@
+<HTML
+><HEAD
+><TITLE
+>About SDLdoc</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Preface"
+HREF="guidepreface.html"><LINK
+REL="PREVIOUS"
+TITLE="Preface"
+HREF="guidepreface.html"><LINK
+REL="NEXT"
+TITLE="Credits"
+HREF="guidecredits.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidepreface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Preface</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidecredits.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEABOUTSDLDOC"
+>About SDLdoc</A
+></H1
+><P
+>SDLdoc (The SDL Documentation Project) was formed to completely rewrite the SDL documentation and to keep it continually up to date. The team consists completely of volunteers ranging from proplr working with SDL in their spare time to people who use SDL in their everyday working lives.</P
+><P
+>The latest version of this documentation can always be found at the project homepage: http://sdldoc.sourceforge.net.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidepreface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidecredits.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Preface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guidepreface.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Credits</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideaudioexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,220 @@
+<HTML
+><HEAD
+><TITLE
+>Audio Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="PREVIOUS"
+TITLE="Event Examples"
+HREF="guideeventexamples.html"><LINK
+REL="NEXT"
+TITLE="CDROM Examples"
+HREF="guidecdromexamples.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideeventexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. Examples</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidecdromexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEAUDIOEXAMPLES"
+>Audio Examples</A
+></H1
+><P
+></P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN343"
+>Opening the audio device</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_AudioSpec wanted;
+    extern void fill_audio(void *udata, Uint8 *stream, int len);
+
+    /* Set the audio format */
+    wanted.freq = 22050;
+    wanted.format = AUDIO_S16;
+    wanted.channels = 2;    /* 1 = mono, 2 = stereo */
+    wanted.samples = 1024;  /* Good low-latency value for callback */
+    wanted.callback = fill_audio;
+    wanted.userdata = NULL;
+
+    /* Open the audio device, forcing the desired format */
+    if ( SDL_OpenAudio(&#38;wanted, NULL) &#60; 0 ) {
+        fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+        return(-1);
+    }
+    return(0);</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN347"
+>Playing audio</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    static Uint8 *audio_chunk;
+    static Uint32 audio_len;
+    static Uint8 *audio_pos;
+
+    /* The audio function callback takes the following parameters:
+       stream:  A pointer to the audio buffer to be filled
+       len:     The length (in bytes) of the audio buffer
+    */
+    void fill_audio(void *udata, Uint8 *stream, int len)
+    {
+        /* Only play if we have data left */
+        if ( audio_len == 0 )
+            return;
+
+        /* Mix as much data as possible */
+        len = ( len &#62; audio_len ? audio_len : len );
+        SDL_MixAudio(stream, audio_pos, len, SDL_MIX_MAXVOLUME)
+        audio_pos += len;
+        audio_len -= len;
+    }
+
+    /* Load the audio data ... */
+
+    ;;;;;
+
+    audio_pos = audio_chunk;
+
+    /* Let the callback function play the audio chunk */
+    SDL_PauseAudio(0);
+
+    /* Do some processing */
+
+    ;;;;;
+
+    /* Wait for sound to complete */
+    while ( audio_len &#62; 0 ) {
+        SDL_Delay(100);         /* Sleep 1/10 second */
+    }
+    SDL_CloseAudio();</PRE
+></P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideeventexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidecdromexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Event Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>CDROM Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidebasicsinit.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,224 @@
+<HTML
+><HEAD
+><TITLE
+>Initializing SDL</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="The Basics"
+HREF="guidethebasics.html"><LINK
+REL="PREVIOUS"
+TITLE="The Basics"
+HREF="guidethebasics.html"><LINK
+REL="NEXT"
+TITLE="Graphics and Video"
+HREF="guidevideo.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidethebasics.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 1. The Basics</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidevideo.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEBASICSINIT"
+>Initializing SDL</A
+></H1
+><P
+>SDL is composed of eight subsystems - Audio, CDROM, Event Handling, File I/O, Joystick Handling, Threading, Timers and Video. Before you can use any of these subsystems they must be initialized by calling <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+> (or <A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+>. <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> must be called before any other SDL function. It automatically initializes the Event Handling, File I/O and Threading subsystems and it takes a parameter specifying which other subsystems to initialize. So, to initialize the default subsystems and the Video subsystems you would call:
+<PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Init ( SDL_INIT_VIDEO );</PRE
+>
+To initialize the default subsystems, the Video subsystem and the Timers subsystem you would call:
+<PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Init ( SDL_INIT_VIDEO | SDL_INIT_TIMER );</PRE
+></P
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> is complemented by <A
+HREF="sdlquit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+></A
+> (and <A
+HREF="sdlquitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_QuitSubSystem</TT
+></A
+>). <TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+> shuts down all subsystems, including the default ones. It should always be called before a SDL application exits.</P
+><P
+>With <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> and <TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+> firmly embedded in your programmers toolkit you can write your first and most basic SDL application. However, we must be prepare to handle errors. Many SDL functions return a value and indicates whether the function has succeeded or failed, <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+>, for instance, returns -1 if it could not initialize a subsystem. SDL provides a useful facility that allows you to determine exactly what the problem was, every time an error occurs within SDL an error message is stored which can be retrieved using <TT
+CLASS="FUNCTION"
+>SDL_GetError</TT
+>. Use this often, you can never know too much about an error.</P
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>#include "SDL.h"   /* All SDL App's need this */
+#include &#60;stdio.h&#62;
+
+int main() {
+    
+    printf("Initializing SDL.\n");
+    
+    /* Initialize defaults, Video and Audio */
+    if((SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO)==-1)) { 
+        printf("Could not initialize SDL: %s.\n", SDL_GetError());
+        exit(-1);
+    }
+
+    printf("SDL initialized.\n");
+
+    printf("Quiting SDL.\n");
+    
+    /* Shutdown all subsystems */
+    SDL_Quit();
+    
+    printf("Quiting....\n");
+
+    exit(0);
+}&#13;</PRE
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidethebasics.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidevideo.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>The Basics</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guidethebasics.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Graphics and Video</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidecdromexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,267 @@
+<HTML
+><HEAD
+><TITLE
+>CDROM Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="PREVIOUS"
+TITLE="Audio Examples"
+HREF="guideaudioexamples.html"><LINK
+REL="NEXT"
+TITLE="Time Examples"
+HREF="guidetimeexamples.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideaudioexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. Examples</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidetimeexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDECDROMEXAMPLES"
+>CDROM Examples</A
+></H1
+><P
+></P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN354"
+>Listing CD-ROM drives</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    #include "SDL.h"
+
+    /* Initialize SDL first */
+    if ( SDL_Init(SDL_INIT_CDROM) &#60; 0 ) {
+        fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+        exit(1);
+    }
+    atexit(SDL_Quit);
+
+    /* Find out how many CD-ROM drives are connected to the system */
+    printf("Drives available: %d\n", SDL_CDNumDrives());
+    for ( i=0; i&#60;SDL_CDNumDrives(); ++i ) {
+        printf("Drive %d:  \"%s\"\n", i, SDL_CDName(i));
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN358"
+>Opening the default drive</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_CD *cdrom;
+    CDstatus status;
+    char *status_str;
+
+    cdrom = SDL_CDOpen(0);
+    if ( cdrom == NULL ) {
+        fprintf(stderr, "Couldn't open default CD-ROM drive: %s\n",
+                        SDL_GetError());
+        exit(2);
+    }
+
+    status = SDL_CDStatus(cdrom);
+    switch (status) {
+        case CD_TRAYEMPTY:
+            status_str = "tray empty";
+            break;
+        case CD_STOPPED:
+            status_str = "stopped";
+            break;
+        case CD_PLAYING:
+            status_str = "playing";
+            break;
+        case CD_PAUSED:
+            status_str = "paused";
+            break;
+        case CD_ERROR:
+            status_str = "error state";
+            break;
+    }
+    printf("Drive status: %s\n", status_str);
+    if ( status &#62;= CD_PLAYING ) {
+        int m, s, f;
+        FRAMES_TO_MSF(cdrom-&#62;cur_frame, &#38;m, &#38;s, &#38;f);
+        printf("Currently playing track %d, %d:%2.2d\n",
+        cdrom-&#62;track[cdrom-&#62;cur_track].id, m, s);
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN362"
+>Listing the tracks on a CD</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_CD *cdrom;          /* Assuming this has already been set.. */
+    int i;
+    int m, s, f;
+
+    SDL_CDStatus(cdrom);
+    printf("Drive tracks: %d\n", cdrom-&#62;numtracks);
+    for ( i=0; i&#60;cdrom-&#62;numtracks; ++i ) {
+        FRAMES_TO_MSF(cdrom-&#62;track[i].length, &#38;m, &#38;s, &#38;f);
+        if ( f &#62; 0 )
+            ++s;
+        printf("\tTrack (index %d) %d: %d:%2.2d\n", i,
+        cdrom-&#62;track[i].id, m, s);
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN366"
+>Play an entire CD</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_CD *cdrom;          /* Assuming this has already been set.. */
+
+    // Play entire CD:
+    if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
+        SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
+
+        // Play last track:
+        if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+            SDL_CDPlayTracks(cdrom, cdrom-&#62;numtracks-1, 0, 0, 0);
+        }
+
+        // Play first and second track and 10 seconds of third track:
+        if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
+            SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);</PRE
+></P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideaudioexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidetimeexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Audio Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Time Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidecredits.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,179 @@
+<HTML
+><HEAD
+><TITLE
+>Credits</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Preface"
+HREF="guidepreface.html"><LINK
+REL="PREVIOUS"
+TITLE="About SDLdoc"
+HREF="guideaboutsdldoc.html"><LINK
+REL="NEXT"
+TITLE="The Basics"
+HREF="guidethebasics.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideaboutsdldoc.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Preface</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidethebasics.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDECREDITS"
+>Credits</A
+></H1
+><P
+><P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+>Martin Donlon, akawaka@skynet.ie</TD
+></TR
+><TR
+><TD
+>Julian Peterson</TD
+></TR
+><TR
+><TD
+>Ken Jordan</TD
+></TR
+><TR
+><TD
+>Maxim Sobolev</TD
+></TR
+><TR
+><TD
+>Wesley Poole</TD
+></TR
+><TR
+><TD
+>Michael Vance</TD
+></TR
+><TR
+><TD
+>Andreas Umbach</TD
+></TR
+><TR
+><TD
+>Andreas Hofmeister</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideaboutsdldoc.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidethebasics.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>About SDLdoc</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guidepreface.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>The Basics</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideeventexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,239 @@
+<HTML
+><HEAD
+><TITLE
+>Event Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="PREVIOUS"
+TITLE="Video Examples"
+HREF="guidevideoexamples.html"><LINK
+REL="NEXT"
+TITLE="Audio Examples"
+HREF="guideaudioexamples.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidevideoexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. Examples</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideaudioexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEEVENTEXAMPLES"
+>Event Examples</A
+></H1
+><P
+></P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN336"
+>Filtering and Handling Events</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>#include &#60;stdio.h&#62;
+#include &#60;stdlib.h&#62;
+
+#include "SDL.h"
+
+/* This function may run in a separate event thread */
+int FilterEvents(const SDL_Event *event) {
+    static int boycott = 1;
+
+    /* This quit event signals the closing of the window */
+    if ( (event-&#62;type == SDL_QUIT) &#38;&#38; boycott ) {
+        printf("Quit event filtered out -- try again.\n");
+        boycott = 0;
+        return(0);
+    }
+    if ( event-&#62;type == SDL_MOUSEMOTION ) {
+        printf("Mouse moved to (%d,%d)\n",
+                event-&#62;motion.x, event-&#62;motion.y);
+        return(0);    /* Drop it, we've handled it */
+    }
+    return(1);
+}
+
+int main(int argc, char *argv[])
+{
+    SDL_Event event;
+
+    /* Initialize the SDL library (starts the event loop) */
+    if ( SDL_Init(SDL_INIT_VIDEO) &#60; 0 ) {
+        fprintf(stderr,
+                "Couldn't initialize SDL: %s\n", SDL_GetError());
+        exit(1);
+    }
+
+    /* Clean up on exit, exit on window close and interrupt */
+    atexit(SDL_Quit);
+
+    /* Ignore key events */
+    SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
+    SDL_EventState(SDL_KEYUP, SDL_IGNORE);
+
+    /* Filter quit and mouse motion events */
+    SDL_SetEventFilter(FilterEvents);
+
+    /* The mouse isn't much use unless we have a display for reference */
+    if ( SDL_SetVideoMode(640, 480, 8, 0) == NULL ) {
+        fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
+                        SDL_GetError());
+        exit(1);
+    }
+
+    /* Loop waiting for ESC+Mouse_Button */
+    while ( SDL_WaitEvent(&#38;event) &#62;= 0 ) {
+        switch (event.type) {
+            case SDL_ACTIVEEVENT: {
+                if ( event.active.state &#38; SDL_APPACTIVE ) {
+                    if ( event.active.gain ) {
+                        printf("App activated\n");
+                    } else {
+                        printf("App iconified\n");
+                    }
+                }
+            }
+            break;
+                    
+            case SDL_MOUSEBUTTONDOWN: {
+                Uint8 *keys;
+
+                keys = SDL_GetKeyState(NULL);
+                if ( keys[SDLK_ESCAPE] == SDL_PRESSED ) {
+                    printf("Bye bye...\n");
+                    exit(0);
+                }
+                printf("Mouse button pressed\n");
+            }
+            break;
+
+            case SDL_QUIT: {
+                printf("Quit requested, quitting.\n");
+                exit(0);
+            }
+            break;
+        }
+    }
+    /* This should never happen */
+    printf("SDL_WaitEvent error: %s\n", SDL_GetError());
+    exit(1);
+}</PRE
+></P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidevideoexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideaudioexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Video Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Audio Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,185 @@
+<HTML
+><HEAD
+><TITLE
+>Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="PREVIOUS"
+TITLE="Handling the Keyboard"
+HREF="guideinputkeyboard.html"><LINK
+REL="NEXT"
+TITLE="Video Examples"
+HREF="guidevideoexamples.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideinputkeyboard.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidevideoexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="GUIDEEXAMPLES"
+>Chapter 4. Examples</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="guideexamples.html#AEN297"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="guidevideoexamples.html"
+>Video Examples</A
+></DT
+><DT
+><A
+HREF="guideeventexamples.html"
+>Event Examples</A
+></DT
+><DT
+><A
+HREF="guideaudioexamples.html"
+>Audio Examples</A
+></DT
+><DT
+><A
+HREF="guidecdromexamples.html"
+>CDROM Examples</A
+></DT
+><DT
+><A
+HREF="guidetimeexamples.html"
+>Time Examples</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="AEN297"
+>Introduction</A
+></H1
+><P
+>For the moment these examples are taken directly from the old SDL documentation.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideinputkeyboard.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidevideoexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Handling the Keyboard</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Video Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideinput.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,647 @@
+<HTML
+><HEAD
+><TITLE
+>Input handling</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="PREVIOUS"
+TITLE="Graphics and Video"
+HREF="guidevideo.html"><LINK
+REL="NEXT"
+TITLE="Handling the Keyboard"
+HREF="guideinputkeyboard.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidevideo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideinputkeyboard.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="GUIDEINPUT"
+>Chapter 3. Input handling</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="guideinput.html#GUIDEINPUTJOYSTICK"
+>Handling Joysticks</A
+></DT
+><DT
+><A
+HREF="guideinputkeyboard.html"
+>Handling the Keyboard</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEINPUTJOYSTICK"
+>Handling Joysticks</A
+></H1
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN94"
+>Initialization</A
+></H2
+><P
+>The first step in using a joystick in a SDL program is to initialize the Joystick subsystems of SDL. This done by passing the <TT
+CLASS="LITERAL"
+>SDL_INIT_JOYSTICK</TT
+> flag to <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>.  The joystick flag will usually be used in conjunction with other flags (like the video flag) because the joystick is usually used to control something.
+<PRE
+CLASS="PROGRAMLISTING"
+>    if ( ! SDL_Init( SDL_INIT_VIDEO | SDL_INIT_JOYSTICK ) )
+    {
+        fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
+        exit(1);
+    }</PRE
+>
+This will attempt to start SDL with both the video and the joystick subsystems activated.</P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN101"
+>Querying</A
+></H2
+><P
+>If we have reached this point then we can safely assume that the SDL library has been initialized and that the Joystick subsystem is active. We can now call some video and/or sound functions to get things going before we need the joystick. Eventually we have to make sure that there is actually a joystick to work with. It's wise to always check even if you know a joystick will be present on the system because it can also help detect when the joystick is unplugged. The function used to check for joysticks is <A
+HREF="sdlnumjoysticks.html"
+><TT
+CLASS="FUNCTION"
+>SDL_NumJoysticks</TT
+></A
+>.</P
+><P
+>This function simply returns the number of joysticks available on the system. If it is at least one then we are in good shape. The next step is to determine which joystick the user wants to use. If the number of joysticks available is only one then it is safe to assume that one joystick is the one the user wants to use. SDL has a function to get the name of the joysticks as assigned by the operations system and that function is <A
+HREF="sdljoystickname.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickName</TT
+></A
+>.  The joystick is specified by an index where 0 is the first joystick and the last joystick is the number returned by <TT
+CLASS="FUNCTION"
+>SDL_NumJoysticks</TT
+> - 1.  In the demonstration a list of all available joysticks is printed to stdout.  
+<PRE
+CLASS="PROGRAMLISTING"
+>    printf("%i joysticks were found.\n\n", SDL_NumJoysticks() );
+    printf("The names of the joysticks are:\n");
+		
+    for( i=0; i &#60; SDL_NumJoysticks(); i++ ) 
+    {
+        printf("    %s\n", SDL_JoystickName(i));
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN111"
+>Opening a Joystick and Receiving Joystick Events</A
+></H2
+><P
+>SDL's event driven architecture makes working with joysticks a snap.  Joysticks can trigger 4 different types of events:
+<P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><A
+HREF="sdljoyaxisevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyAxisEvent</SPAN
+></A
+></TD
+><TD
+>Occurs when an axis changes</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoyballevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyBallEvent</SPAN
+></A
+></TD
+><TD
+>Occurs when a joystick trackball's position changes</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoyhatevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyHatEvent</SPAN
+></A
+></TD
+><TD
+>Occurs when a hat's position changes</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoybuttonevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyButtonEvent</SPAN
+></A
+></TD
+><TD
+>Occurs when a button is pressed or released</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></P
+><P
+>Events are received from all joysticks opened. The first thing that needs to be done in order to receive joystick events is to call <A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+> with the <TT
+CLASS="LITERAL"
+>SDL_ENABLE</TT
+> flag. Next you must open the joysticks that you want to receive envents from. This is done with the <A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+> function. For the example we are only interested in events from the first joystick on the system, regardless of what it may be. To receive events from it we would do this:
+<PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Joystick *joystick;
+
+    SDL_JoystickEventState(SDL_ENABLE);
+    joystick = SDL_JoystickOpen(0);</PRE
+>
+If we wanted to receive events for other joysticks we would open them with calls to <TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+> just like we opened joystick 0, except we would store the <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+> structure they return in a different pointer.  We only need the joystick pointer when we are querying the joysticks or when we are closing the joystick.</P
+><P
+>Up to this point all the code we have is used just to initialize the joysticks in order to read values at run time. All we need now is an event loop, which is something that all SDL programs should have anyway to receive the systems quit events. We must now add code to check the event loop for at least some of the above mentioned events. Let's assume our event loop looks like this:
+<PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Event *event;
+    /* Other initializtion code goes here */   
+
+    /* Start main game loop here */
+
+    while(SDL_PollEvent(&#38;event))
+    {  
+        switch(event.type)
+        {  
+            case SDL_KEYDOWN:
+            /* handle keyboard stuff here */				
+            break;
+
+            case SDL_QUIT:
+            /* Set whatever flags are necessary to */
+            /* end the main game loop here */
+            break;
+        }
+    }
+
+    /* End loop here */</PRE
+>
+To handle Joystick events we merely add cases for them, first we'll add axis handling code. Axis checks can get kinda of tricky because alot of the joystick events received are junk. Joystick axis have a tendency to vary just a little between polling due to the way they are designed. To compensate for this you have to set a threshold for changes and ignore the events that have'nt exceeded the threshold. 10% is usually a good threshold value.  This sounds a lot more complicated than it is. Here is the Axis event handler:
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_JOYAXISMOTION:  /* Handle Joystick Motion */
+    if ( ( event.jaxis.value &#60; -3200 ) || (event.jaxis.value &#62; 3200 ) ) 
+    {
+      /* code goes here */
+    }
+    break;</PRE
+>
+Another trick with axis events is that up-down and left-right movement are two different sets of axes. The most important axis is axis 0 (left-right) and axis 1 (up-down).  To handle them seperatly in the code we do the following:
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_JOYAXISMOTION:  /* Handle Joystick Motion */
+    if ( ( event.jaxis.value &#60; -3200 ) || (event.jaxis.value &#62; 3200 ) ) 
+    {
+        if( event.jaxis.axis == 0) 
+        {
+            /* Left-right movement code goes here */
+        }
+
+        if( event.jaxis.axis == 1) 
+        {
+            /* Up-Down movement code goes here */
+        }
+    }
+    break;</PRE
+>
+Ideally the code here should use <TT
+CLASS="STRUCTFIELD"
+><I
+>event.jaxis.value</I
+></TT
+> to scale something. For example lets assume you are using the joystick to control the movement of a spaceship. If the user is using an analog joystick and they push the stick a little bit they expect to move less than if they pushed it a lot. Designing your code for this situation is preferred because it makes the experience for users of analog controls better and remains the same for users of digital controls.</P
+><P
+>If your joystick has any additional axis then they may be used for other sticks or throttle controls and those axis return values too just with different <TT
+CLASS="STRUCTFIELD"
+><I
+>event.jaxis.axis</I
+></TT
+> values.</P
+><P
+>Button handling is simple compared to the axis checking.
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_JOYBUTTONDOWN:  /* Handle Joystick Button Presses */
+    if ( event.jbutton.button == 0 ) 
+    {
+        /* code goes here */
+    }
+    break;</PRE
+>
+
+Button checks are simpler than axis checks because a button can only be pressed or not pressed.  The <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONDOWN</TT
+> event is triggered when a button is pressed and the <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONUP</TT
+> event is fired when a button is released. We do have to know what button was pressed though, that is done by reading the <TT
+CLASS="STRUCTFIELD"
+><I
+>event.jbutton.button</I
+></TT
+> field.</P
+><P
+>Lastly when we are through using our joysticks we should close them with a call to <A
+HREF="sdljoystickclose.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickClose</TT
+></A
+>. To close our opened joystick 0 we would do this at the end of our program:
+<PRE
+CLASS="PROGRAMLISTING"
+>    SDL_JoystickClose(joystick);</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN156"
+>Advanced Joystick Functions</A
+></H2
+><P
+>That takes care of the controls that you can count on being on every joystick under the sun, but there are a few extra things that SDL can support.  Joyballs are next on our list, they are alot like axis we a few minor differences.  Joyballs store relative changes unlike the the absolute postion stored in a axis event. Also one trackball event contains both the change in x and they change in y.  Our case for it is as follows: 
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_JOYBALLMOTION:  /* Handle Joyball Motion */
+    if( event.jball.ball == 0 )
+    {
+      /* ball handling */
+    }
+    break;</PRE
+>
+The above checks the first joyball on the joystick. The change in position will be stored in <TT
+CLASS="STRUCTFIELD"
+><I
+>event.jball.xrel</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>event.jball.yrel</I
+></TT
+>.</P
+><P
+>Finally we have the hat event. Hats report only the direction they are pushed in. We check hat's position with the bitmasks:
+
+<P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_CENTERED</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_UP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHT</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_DOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFT</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+>
+
+Also there are some predefined combinations of the above:
+<P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTDOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTDOWN</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+>
+
+Our case for the hat may resemble the following:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_JOYHATMOTION:  /* Handle Hat Motion */
+    if ( event.jhat.hat | SDL_HAT_UP )
+    {
+        /* Do up stuff here */
+    }
+
+    if ( event.jhat.hat | SDL_HAT_LEFT )
+    {
+        /* Do left stuff here */
+    }
+
+    if ( event.jhat.hat | SDL_HAT_RIGHTDOWN )
+    {
+        /* Do right and down together stuff here */
+    }
+    break;</PRE
+></P
+><P
+>In addition to the queries for number of joysticks on the system and their names there are additional functions to query the capabilities of attached joysticks:
+<P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><A
+HREF="sdljoysticknumaxes.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumAxes</TT
+></A
+></TD
+><TD
+>Returns the number of joysitck axes</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoysticknumbuttons.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumButtons</TT
+></A
+></TD
+><TD
+>Returns the number of joysitck buttons</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoysticknumballs.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumBalls</TT
+></A
+></TD
+><TD
+>Returns the number of joysitck balls</TD
+></TR
+><TR
+><TD
+><A
+HREF="sdljoysticknumhats.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumHats</TT
+></A
+></TD
+><TD
+>Returns the number of joysitck hats</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+>
+
+To use these functions we just have to pass in the joystick structure we got when we opened the joystick. For Example:
+
+<PRE
+CLASS="PROGRAMLISTING"
+>    int number_of_buttons;
+    SDL_Joystick *joystick;
+
+    joystick = SDL_JoystickOpen(0);
+    number_of_buttons = SDL_JoystickNumButtons(joystick);</PRE
+>
+
+This block of code would get the number of buttons on the first joystick in the system.	</P
+></DIV
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidevideo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideinputkeyboard.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Graphics and Video</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Handling the Keyboard</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guideinputkeyboard.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,715 @@
+<HTML
+><HEAD
+><TITLE
+>Handling the Keyboard</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Input handling"
+HREF="guideinput.html"><LINK
+REL="PREVIOUS"
+TITLE="Input handling"
+HREF="guideinput.html"><LINK
+REL="NEXT"
+TITLE="Examples"
+HREF="guideexamples.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideinput.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 3. Input handling</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEINPUTKEYBOARD"
+>Handling the Keyboard</A
+></H1
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN205"
+>Keyboard Related Structures</A
+></H2
+><P
+>It should make it a lot easier to understand this tutorial is you are familiar with the data types involved in keyboard access, so I'll explain them first.</P
+><DIV
+CLASS="SECT3"
+><H3
+CLASS="SECT3"
+><A
+NAME="AEN208"
+>SDLKey</A
+></H3
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+> is an enumerated type defined in SDL/include/SDL_keysym.h and detailed <A
+HREF="sdlkey.html"
+>here</A
+>. Each <SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+> symbol represents a key, <TT
+CLASS="LITERAL"
+>SDLK_a</TT
+> corresponds to the 'a' key on a keyboard, <TT
+CLASS="LITERAL"
+>SDLK_SPACE</TT
+> corresponds to the space bar, and so on.</P
+></DIV
+><DIV
+CLASS="SECT3"
+><H3
+CLASS="SECT3"
+><A
+NAME="AEN216"
+>SDLMod</A
+></H3
+><P
+>SDLMod is an enumerated type, similar to <SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+>, however it enumerates keyboard modifiers (Control, Alt, Shift). The full list of modifier symbols is <A
+HREF="sdlkey.html#SDLMOD"
+>here</A
+>. <SPAN
+CLASS="STRUCTNAME"
+>SDLMod</SPAN
+> values can be AND'd together to represent several modifiers.</P
+></DIV
+><DIV
+CLASS="SECT3"
+><H3
+CLASS="SECT3"
+><A
+NAME="AEN222"
+>SDL_keysym</A
+></H3
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 scancode;
+  SDLKey sym;
+  SDLMod mod;
+  Uint16 unicode;
+} SDL_keysym;</PRE
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+> structure describes a key press or a key release. The <TT
+CLASS="STRUCTFIELD"
+><I
+>scancode</I
+></TT
+> field is hardware specific and should be ignored unless you know what your doing. The <TT
+CLASS="STRUCTFIELD"
+><I
+>sym</I
+></TT
+> field is the <SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+> value of the key being pressed or released. The <TT
+CLASS="STRUCTFIELD"
+><I
+>mod</I
+></TT
+> field describes the state of the keyboard modifiers at the time the key press or release occurred. So a value of <TT
+CLASS="LITERAL"
+>KMOD_NUM | KMOD_CAPS | KMOD_LSHIFT</TT
+> would mean that Numlock, Capslock and the left shift key were all press (or enabled in the case of the lock keys). Finally, the <TT
+CLASS="STRUCTFIELD"
+><I
+>unicode</I
+></TT
+> field stores the 16-bit unicode value of the key.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>It should be noted and understood that this field is only valid when the <SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+> is describing a key press, not a key release. Unicode values only make sense on a key press because the unicode value describes an international character and only key presses produce characters. More information on Unicode can be found at <A
+HREF="http://www.unicode.org"
+TARGET="_top"
+>www.unicode.org</A
+></P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Unicode translation must be enabled using the <A
+HREF="sdlenableunicode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EnableUNICODE</TT
+></A
+> function.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="SECT3"
+><H3
+CLASS="SECT3"
+><A
+NAME="AEN241"
+>SDL_KeyboardEvent</A
+></H3
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 state;
+  SDL_keysym keysym;
+} SDL_KeyboardEvent;</PRE
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+> describes a keyboard event (obviously). The <TT
+CLASS="STRUCTFIELD"
+><I
+>key</I
+></TT
+> member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union is a <SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+> structure. The <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> field specifies whether the event is a key release (<TT
+CLASS="LITERAL"
+>SDL_KEYUP</TT
+>) or a key press (<TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+>) event. The <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+> is largely redundant, it reports the same information as the <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> field but uses different values (<TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+> and <TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+>). The <TT
+CLASS="STRUCTFIELD"
+><I
+>keysym</I
+></TT
+> contains information of the key press or release that this event represents (see above).</P
+></DIV
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN258"
+>Reading Keyboard Events</A
+></H2
+><P
+>Reading keybaord events from the event queue is quite simple (the event queue and using it is described <A
+HREF="sdlevent.html"
+>here</A
+>). We read events using <A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+> in a <TT
+CLASS="LITERAL"
+>while()</TT
+> loop and check for <TT
+CLASS="LITERAL"
+>SDL_KEYUP</TT
+> and <TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+> events using a <TT
+CLASS="LITERAL"
+>switch</TT
+> statement, like so:
+<PRE
+CLASS="PROGRAMLISTING"
+>  SDL_Event event;
+  .
+  .
+  /* Poll for events. SDL_PollEvent() returns 0 when there are no  */
+  /* more events on the event queue, our while loop will exit when */
+  /* that occurs.                                                  */
+  while( SDL_PollEvent( &#38;event ) ){
+    /* We are only worried about SDL_KEYDOWN and SDL_KEYUP events */
+    switch( event.type ){
+      case SDL_KEYDOWN:
+        printf( "Key press detected\n" );
+        break;
+
+      case SDL_KEYUP:
+        printf( "Key release detected\n" );
+        break;
+
+      default:
+        break;
+    }
+  }
+  .
+  .</PRE
+>
+This is a very basic example. No information about the key press or release is interpreted. We will explore the other extreme out our first full example below - reporting all available information about a keyboard event.</P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN269"
+>A More Detailed Look</A
+></H2
+><P
+>Before we can read events SDL must be initialised with <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+> and a video mode must be set using <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>. There are, however, two other functions we must use to obtain all the information required. We must enable unicode translation by calling <TT
+CLASS="FUNCTION"
+>SDL_EnableUNICODE(1)</TT
+> and we must convert <SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+> values into something printable, using <A
+HREF="sdlgetkeyname.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetKeyName</TT
+></A
+></P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>It is useful to note that unicode values &#60; 0x80 translate directly a characters ASCII value. THis is used in the example below</P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="EXAMPLE"
+><A
+NAME="AEN282"
+></A
+><P
+><B
+>Example 3-1. keys.c - Key event information</B
+></P
+><PRE
+CLASS="PROGRAMLISTING"
+>&#13;    #include "SDL.h"
+
+    /* Function Prototypes */
+    void PrintKeyInfo( SDL_KeyboardEvent *key );
+    void PrintModifiers( SDLMod mod );
+
+    /* main */
+    int main( int argc, char *argv[] ){
+        
+        SDL_Event event;
+        int quit = 0;
+        
+        /* Initialise SDL */
+        if( SDL_Init( SDL_INIT_VIDEO ) ){
+            fprintf( stderr, "Could not initialise SDL: %s\n", SDL_GetError() );
+            exit( -1 );
+        }
+
+        /* Set a video mode */
+        if( !SDL_SetVideoMode( 320, 200, 0, 0 ) ){
+            fprintf( stderr, "Could not set video mode: %s\n", SDL_GetError() );
+            SDL_Quit();
+            exit( -1 );
+        }
+
+        /* Enable Unicode translation */
+        SDL_EnableUNICODE( 1 );
+
+        /* Loop until an SDL_QUIT event is found */
+        while( !quit ){
+
+            /* Poll for events */
+            while( SDL_PollEvent( &#38;event ) ){
+                
+                switch( event.type ){
+                    /* Keyboard event */
+                    /* Pass the event data onto PrintKeyInfo() */
+                    case SDL_KEYDOWN:
+                    case SDL_KEYUP:
+                        PrintKeyInfo( &#38;event.key );
+                        break;
+
+                    /* SDL_QUIT event (window close) */
+                    case SDL_QUIT:
+                        quit = 1;
+                        break;
+
+                    default:
+                        break;
+                }
+
+            }
+
+        }
+
+        /* Clean up */
+        SDL_Quit();
+        exit( 0 );
+    }
+
+    /* Print all information about a key event */
+    void PrintKeyInfo( SDL_KeyboardEvent *key ){
+        /* Is it a release or a press? */
+        if( key-&#62;type == SDL_KEYUP )
+            printf( "Release:- " );
+        else
+            printf( "Press:- " );
+
+        /* Print the hardware scancode first */
+        printf( "Scancode: 0x%02X", key-&#62;keysym.scancode );
+        /* Print the name of the key */
+        printf( ", Name: %s", SDL_GetKeyName( key-&#62;keysym.sym ) );
+        /* We want to print the unicode info, but we need to make */
+        /* sure its a press event first (remember, release events */
+        /* don't have unicode info                                */
+        if( key-&#62;type == SDL_KEYDOWN ){
+            /* If the Unicode value is less than 0x80 then the    */
+            /* unicode value can be used to get a printable       */
+            /* representation of the key, using (char)unicode.    */
+            printf(", Unicode: " );
+            if( key-&#62;keysym.unicode &#60; 0x80 &#38;&#38; key-&#62;keysym.unicode &#62; 0 ){
+                printf( "%c (0x%04X)", (char)key-&#62;keysym.unicode,
+                        key-&#62;keysym.unicode );
+            }
+            else{
+                printf( "? (0x%04X)", key-&#62;keysym.unicode );
+            }
+        }
+        printf( "\n" );
+        /* Print modifier info */
+        PrintModifiers( key-&#62;keysym.mod );
+    }
+
+    /* Print modifier info */
+    void PrintModifiers( SDLMod mod ){
+        printf( "Modifers: " );
+
+        /* If there are none then say so and return */
+        if( mod == KMOD_NONE ){
+            printf( "None\n" );
+            return;
+        }
+
+        /* Check for the presence of each SDLMod value */
+        /* This looks messy, but there really isn't    */
+        /* a clearer way.                              */
+        if( mod &#38; KMOD_NUM ) printf( "NUMLOCK " );
+        if( mod &#38; KMOD_CAPS ) printf( "CAPSLOCK " );
+        if( mod &#38; KMOD_LCTRL ) printf( "LCTRL " );
+        if( mod &#38; KMOD_RCTRL ) printf( "RCTRL " );
+        if( mod &#38; KMOD_RSHIFT ) printf( "RSHIFT " );
+        if( mod &#38; KMOD_LSHIFT ) printf( "LSHIFT " );
+        if( mod &#38; KMOD_RALT ) printf( "RALT " );
+        if( mod &#38; KMOD_LALT ) printf( "LALT " );
+        if( mod &#38; KMOD_CTRL ) printf( "CTRL " );
+        if( mod &#38; KMOD_SHIFT ) printf( "SHIFT " );
+        if( mod &#38; KMOD_ALT ) printf( "ALT " );
+        printf( "\n" );
+    }</PRE
+></DIV
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN285"
+>Game-type Input</A
+></H2
+><P
+>I have found that people using keyboard events for games and other interactive applications don't always understand one fundemental point.</P
+><A
+NAME="AEN288"
+></A
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+>Keyboard events <I
+CLASS="EMPHASIS"
+>only</I
+> take place when a keys state changes from being unpressed to pressed, and vice versa.</P
+></BLOCKQUOTE
+><P
+>Imagine you have an image of an alien that you wish to move around using the cursor keys - when you pressed the left arrow key you want him to slide over to the left, when you press the down key you want him to slide down the screen. Examine the following code, it highlights and error that many people have made.
+<PRE
+CLASS="PROGRAMLISTING"
+>    /* Alien screen coordinates */
+    int alien_x=0, alien_y=0;
+    .
+    .
+    /* Initialise SDL and video modes and all that */
+    .
+    /* Main game loop */
+    /* Check for events */
+    while( SDL_PollEvent( &#38;event ) ){
+        switch( event.type ){
+            /* Look for a keypress */
+            case SDL_KEYDOWN:
+                /* Check the SDLKey values and move change the coords */
+                switch( event.key.keysym.sym ){
+                    case SDLK_LEFT:
+                        alien_x -= 1;
+                        break;
+                    case SDLK_RIGHT:
+                        alien_x += 1;
+                        break;
+                    case SDLK_UP:
+                        alien_y -= 1;
+                        break;
+                    case SDLK_DOWN:
+                        alien_y += 1;
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
+    }
+    .
+    .</PRE
+>
+At first glance you may think this is a perfectly reasonable piece of code for the task, but it isn't. Like I said keyboard events only occur when a key changes state, so the user would have to press and release the left cursor key 100 times to move the alien 100 pixels to the left.</P
+><P
+>To get around this problem we must not use the events to change the position of the alien, we use the events to set flags which are then used in a seperate section of code to move the alien. Something like this:
+<PRE
+CLASS="PROGRAMLISTING"
+>    /* Alien screen coordinates */
+    int alien_x=0, alien_y=0;
+    int alien_xvel=0, alien_yvel=0;
+    .
+    .
+    /* Initialise SDL and video modes and all that */
+    .
+    /* Main game loop */
+    /* Check for events */
+    while( SDL_PollEvent( &#38;event ) ){
+        switch( event.type ){
+            /* Look for a keypress */
+            case SDL_KEYDOWN:
+                /* Check the SDLKey values and move change the coords */
+                switch( event.key.keysym.sym ){
+                    case SDLK_LEFT:
+                        alien_xvel = -1;
+                        break;
+                    case SDLK_RIGHT:
+                        alien_xvel =  1;
+                        break;
+                    case SDLK_UP:
+                        alien_yvel = -1;
+                        break;
+                    case SDLK_DOWN:
+                        alien_yvel =  1;
+                        break;
+                    default:
+                        break;
+                }
+                break;
+            /* We must also use the SDL_KEYUP events to zero the x */
+            /* and y velocity variables. But we must also be       */
+            /* careful not to zero the velocities when we shouldn't*/
+            case SDL_KEYUP:
+                switch( event.key.keysym.sym ){
+                    case SDLK_LEFT:
+                        /* We check to make sure the alien is moving */
+                        /* to the left. If it is then we zero the    */
+                        /* velocity. If the alien is moving to the   */
+                        /* right then the right key is still press   */
+                        /* so we don't tocuh the velocity            */
+                        if( alien_xvel &#60; 0 )
+                            alien_xvel = 0;
+                        break;
+                    case SDLK_RIGHT:
+                        if( alien_xvel &#62; 0 )
+                            alien_xvel = 0;
+                        break;
+                    case SDLK_UP:
+                        if( alien_yvel &#60; 0 )
+                            alien_yvel = 0;
+                        break;
+                    case SDLK_DOWN:
+                        if( alien_yvel &#62; 0 )
+                            alien_yvel = 0;
+                        break;
+                    default:
+                        break;
+                }
+                break;
+            
+            default:
+                break;
+        }
+    }
+    .
+    .
+    /* Update the alien position */
+    alien_x += alien_xvel;
+    alien_y += alien_yvel;</PRE
+>
+As can be seen, we use two extra variables, alien_xvel and alien_yvel, which represent the motion of the ship, it is these variables that we update when we detect keypresses and releases.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideinput.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Input handling</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideinput.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidepreface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,170 @@
+<HTML
+><HEAD
+><TITLE
+>Preface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="NEXT"
+TITLE="About SDLdoc"
+HREF="guideaboutsdldoc.html"></HEAD
+><BODY
+CLASS="PREFACE"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guide.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideaboutsdldoc.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="PREFACE"
+><H1
+><A
+NAME="GUIDEPREFACE"
+>Preface</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="guidepreface.html#GUIDEABOUTSDL"
+>About SDL</A
+></DT
+><DT
+><A
+HREF="guideaboutsdldoc.html"
+>About SDLdoc</A
+></DT
+><DT
+><A
+HREF="guidecredits.html"
+>Credits</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEABOUTSDL"
+>About SDL</A
+></H1
+><P
+>The SDL library is designed to make it easy to write games that run on Linux, *BSD, MacOS, Win32 and BeOS using the various native high-performance media interfaces, (for video, audio, etc) and presenting a single source-code level API to your application. SDL is a fairly low level API, but using it, completely portable applications can be written with a great deal of flexibility.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideaboutsdldoc.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL Guide</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>About SDLdoc</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidethebasics.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,165 @@
+<HTML
+><HEAD
+><TITLE
+>The Basics</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="PREVIOUS"
+TITLE="Credits"
+HREF="guidecredits.html"><LINK
+REL="NEXT"
+TITLE="Initializing SDL"
+HREF="guidebasicsinit.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidecredits.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guidebasicsinit.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="GUIDETHEBASICS"
+>Chapter 1. The Basics</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="guidethebasics.html#GUIDEINTRODUCTION"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="guidebasicsinit.html"
+>Initializing SDL</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEINTRODUCTION"
+>Introduction</A
+></H1
+><P
+>The SDL Guide section is pretty incomplete. If you feel you have anything to add mail akawaka@skynet.ie or visit http://akawaka.csn.ul.ie/tne/.</P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidecredits.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guidebasicsinit.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Credits</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Initializing SDL</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidetimeexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,173 @@
+<HTML
+><HEAD
+><TITLE
+>Time Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="PREVIOUS"
+TITLE="CDROM Examples"
+HREF="guidecdromexamples.html"><LINK
+REL="NEXT"
+TITLE="SDL Reference"
+HREF="reference.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidecdromexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. Examples</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="reference.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDETIMEEXAMPLES"
+>Time Examples</A
+></H1
+><P
+></P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN373"
+>Time based game loop</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>#define TICK_INTERVAL    30
+
+Uint32 TimeLeft(void)
+{
+    static Uint32 next_time = 0;
+    Uint32 now;
+
+    now = SDL_GetTicks();
+    if ( next_time &#60;= now ) {
+        next_time = now+TICK_INTERVAL;
+        return(0);
+    }
+    return(next_time-now);
+}
+
+
+/* main game loop
+
+    while ( game_running ) {
+        UpdateGameState();
+        SDL_Delay(TimeLeft());
+    }&#13;</PRE
+></P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidecdromexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>CDROM Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL Reference</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidevideo.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,705 @@
+<HTML
+><HEAD
+><TITLE
+>Graphics and Video</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Guide"
+HREF="guide.html"><LINK
+REL="PREVIOUS"
+TITLE="Initializing SDL"
+HREF="guidebasicsinit.html"><LINK
+REL="NEXT"
+TITLE="Input handling"
+HREF="guideinput.html"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidebasicsinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideinput.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="GUIDEVIDEO"
+>Chapter 2. Graphics and Video</A
+></H1
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEVIDEOOPENGL"
+>Using OpenGL With SDL</A
+></H1
+><P
+>SDL has the ability to create and use OpenGL contexts on several platforms(Linux/X11, Win32, BeOS, MacOS Classic/Toolbox, MacOS X, FreeBSD/X11 and Solaris/X11). This allows you to use SDL's audio, event handling, threads and times in your OpenGL applications (a function often performed by GLUT).</P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN65"
+>Initialisation</A
+></H2
+><P
+>Initialising SDL to use OpenGL is not very different to initialising SDL normally. There are three differences; you must pass <TT
+CLASS="LITERAL"
+>SDL_OPENGL</TT
+> to <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>, you must specify several GL attributes (depth buffer size, framebuffer sizes) using <A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+> and finally, if you wish to use double buffering you must specify it as a GL attribute, <I
+CLASS="EMPHASIS"
+>not</I
+> by passing the <TT
+CLASS="LITERAL"
+>SDL_DOUBLEBUF</TT
+> flag to <TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+>.
+<PRE
+CLASS="PROGRAMLISTING"
+>    /* Information about the current video settings. */
+    const SDL_VideoInfo* info = NULL;
+    /* Dimensions of our window. */
+    int width = 0;
+    int height = 0;
+    /* Color depth in bits of our window. */
+    int bpp = 0;
+    /* Flags we will pass into SDL_SetVideoMode. */
+    int flags = 0;
+
+    /* First, initialize SDL's video subsystem. */
+    if( SDL_Init( SDL_INIT_VIDEO ) &#60; 0 ) {
+        /* Failed, exit. */
+        fprintf( stderr, "Video initialization failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }
+
+    /* Let's get some video information. */
+    info = SDL_GetVideoInfo( );
+
+    if( !info ) {
+        /* This should probably never happen. */
+        fprintf( stderr, "Video query failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }
+
+    /*
+     * Set our width/height to 640/480 (you would
+     * of course let the user decide this in a normal
+     * app). We get the bpp we will request from
+     * the display. On X11, VidMode can't change
+     * resolution, so this is probably being overly
+     * safe. Under Win32, ChangeDisplaySettings
+     * can change the bpp.
+     */
+    width = 640;
+    height = 480;
+    bpp = info-&#62;vfmt-&#62;BitsPerPixel;
+
+    /*
+     * Now, we want to setup our requested
+     * window attributes for our OpenGL window.
+     * We want *at least* 5 bits of red, green
+     * and blue. We also want at least a 16-bit
+     * depth buffer.
+     *
+     * The last thing we do is request a double
+     * buffered window. '1' turns on double
+     * buffering, '0' turns it off.
+     *
+     * Note that we do not use SDL_DOUBLEBUF in
+     * the flags to SDL_SetVideoMode. That does
+     * not affect the GL attribute state, only
+     * the standard 2D blitting setup.
+     */
+    SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+
+    /*
+     * We want to request that SDL provide us
+     * with an OpenGL window, in a fullscreen
+     * video mode.
+     *
+     * EXERCISE:
+     * Make starting windowed an option, and
+     * handle the resize events properly with
+     * glViewport.
+     */
+    flags = SDL_OPENGL | SDL_FULLSCREEN;
+
+    /*
+     * Set the video mode
+     */
+    if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {
+        /* 
+         * This could happen for a variety of reasons,
+         * including DISPLAY not being set, the specified
+         * resolution not being available, etc.
+         */
+        fprintf( stderr, "Video mode set failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN77"
+>Drawing</A
+></H2
+><P
+>Apart from initialisation, using OpenGL within SDL is the same as using. However if you have request a double buffered display (using <A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+>) and one (which can be checked by using <A
+HREF="sdlglgetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetAttribute</TT
+></A
+>), then you must use <A
+HREF="sdlglswapbuffers.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SwapBuffers()</TT
+></A
+> to swap the buffers and update the display.</P
+><P
+>A full example code listing is now presented below.</P
+><DIV
+CLASS="EXAMPLE"
+><A
+NAME="AEN87"
+></A
+><P
+><B
+>Example 2-1. gl.c - SDL OpenGL Example</B
+></P
+><PRE
+CLASS="PROGRAMLISTING"
+>/*
+ * SDL OpenGL Tutorial.
+ * (c) Michael Vance, 2000
+ * briareos@lokigames.com
+ *
+ * Distributed under terms of the LGPL. 
+ */
+
+#include &#60;SDL/SDL.h&#62;
+#include &#60;GL/gl.h&#62;
+#include &#60;GL/glu.h&#62;
+
+#include &#60;stdio.h&#62;
+#include &#60;stdlib.h&#62;
+
+static GLboolean should_rotate = GL_TRUE;
+
+static void quit_tutorial( int code )
+{
+    /*
+     * Quit SDL so we can release the fullscreen
+     * mode and restore the previous video settings,
+     * etc.
+     */
+    SDL_Quit( );
+
+    /* Exit program. */
+    exit( code );
+}
+
+static void handle_key_down( SDL_keysym* keysym )
+{
+
+    /* 
+     * We're only interested if 'Esc' has
+     * been presssed.
+     *
+     * EXERCISE: 
+     * Handle the arrow keys and have that change the
+     * viewing position/angle.
+     */
+    switch( keysym-&#62;sym ) {
+    case SDLK_ESCAPE:
+        quit_tutorial( 0 );
+        break;
+    case SDLK_SPACE:
+        should_rotate = !should_rotate;
+        break;
+    default:
+        break;
+    }
+
+}
+
+static void process_events( void )
+{
+    /* Our SDL event placeholder. */
+    SDL_Event event;
+
+    /* Grab all the events off the queue. */
+    while( SDL_PollEvent( &#38;event ) ) {
+
+        switch( event.type ) {
+        case SDL_KEYDOWN:
+            /* Handle key presses. */
+            handle_key_down( &#38;event.key.keysym );
+            break;
+        case SDL_QUIT:
+            /* Handle quit requests (like Ctrl-c). */
+            quit_tutorial( 0 );
+            break;
+        }
+
+    }
+
+}
+
+static void draw_screen( void )
+{
+    /* Our angle of rotation. */
+    static float angle = 0.0f;
+
+    /*
+     * EXERCISE:
+     * Replace this awful mess with vertex
+     * arrays and a call to glDrawElements.
+     *
+     * EXERCISE:
+     * After completing the above, change
+     * it to use compiled vertex arrays.
+     *
+     * EXERCISE:
+     * Verify my windings are correct here ;).
+     */
+    static GLfloat v0[] = { -1.0f, -1.0f,  1.0f };
+    static GLfloat v1[] = {  1.0f, -1.0f,  1.0f };
+    static GLfloat v2[] = {  1.0f,  1.0f,  1.0f };
+    static GLfloat v3[] = { -1.0f,  1.0f,  1.0f };
+    static GLfloat v4[] = { -1.0f, -1.0f, -1.0f };
+    static GLfloat v5[] = {  1.0f, -1.0f, -1.0f };
+    static GLfloat v6[] = {  1.0f,  1.0f, -1.0f };
+    static GLfloat v7[] = { -1.0f,  1.0f, -1.0f };
+    static GLubyte red[]    = { 255,   0,   0, 255 };
+    static GLubyte green[]  = {   0, 255,   0, 255 };
+    static GLubyte blue[]   = {   0,   0, 255, 255 };
+    static GLubyte white[]  = { 255, 255, 255, 255 };
+    static GLubyte yellow[] = {   0, 255, 255, 255 };
+    static GLubyte black[]  = {   0,   0,   0, 255 };
+    static GLubyte orange[] = { 255, 255,   0, 255 };
+    static GLubyte purple[] = { 255,   0, 255,   0 };
+
+    /* Clear the color and depth buffers. */
+    glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+    /* We don't want to modify the projection matrix. */
+    glMatrixMode( GL_MODELVIEW );
+    glLoadIdentity( );
+
+    /* Move down the z-axis. */
+    glTranslatef( 0.0, 0.0, -5.0 );
+
+    /* Rotate. */
+    glRotatef( angle, 0.0, 1.0, 0.0 );
+
+    if( should_rotate ) {
+
+        if( ++angle &#62; 360.0f ) {
+            angle = 0.0f;
+        }
+
+    }
+
+    /* Send our triangle data to the pipeline. */
+    glBegin( GL_TRIANGLES );
+
+    glColor4ubv( red );
+    glVertex3fv( v0 );
+    glColor4ubv( green );
+    glVertex3fv( v1 );
+    glColor4ubv( blue );
+    glVertex3fv( v2 );
+
+    glColor4ubv( red );
+    glVertex3fv( v0 );
+    glColor4ubv( blue );
+    glVertex3fv( v2 );
+    glColor4ubv( white );
+    glVertex3fv( v3 );
+
+    glColor4ubv( green );
+    glVertex3fv( v1 );
+    glColor4ubv( black );
+    glVertex3fv( v5 );
+    glColor4ubv( orange );
+    glVertex3fv( v6 );
+
+    glColor4ubv( green );
+    glVertex3fv( v1 );
+    glColor4ubv( orange );
+    glVertex3fv( v6 );
+    glColor4ubv( blue );
+    glVertex3fv( v2 );
+
+    glColor4ubv( black );
+    glVertex3fv( v5 );
+    glColor4ubv( yellow );
+    glVertex3fv( v4 );
+    glColor4ubv( purple );
+    glVertex3fv( v7 );
+
+    glColor4ubv( black );
+    glVertex3fv( v5 );
+    glColor4ubv( purple );
+    glVertex3fv( v7 );
+    glColor4ubv( orange );
+    glVertex3fv( v6 );
+
+    glColor4ubv( yellow );
+    glVertex3fv( v4 );
+    glColor4ubv( red );
+    glVertex3fv( v0 );
+    glColor4ubv( white );
+    glVertex3fv( v3 );
+
+    glColor4ubv( yellow );
+    glVertex3fv( v4 );
+    glColor4ubv( white );
+    glVertex3fv( v3 );
+    glColor4ubv( purple );
+    glVertex3fv( v7 );
+
+    glColor4ubv( white );
+    glVertex3fv( v3 );
+    glColor4ubv( blue );
+    glVertex3fv( v2 );
+    glColor4ubv( orange );
+    glVertex3fv( v6 );
+
+    glColor4ubv( white );
+    glVertex3fv( v3 );
+    glColor4ubv( orange );
+    glVertex3fv( v6 );
+    glColor4ubv( purple );
+    glVertex3fv( v7 );
+
+    glColor4ubv( green );
+    glVertex3fv( v1 );
+    glColor4ubv( red );
+    glVertex3fv( v0 );
+    glColor4ubv( yellow );
+    glVertex3fv( v4 );
+
+    glColor4ubv( green );
+    glVertex3fv( v1 );
+    glColor4ubv( yellow );
+    glVertex3fv( v4 );
+    glColor4ubv( black );
+    glVertex3fv( v5 );
+
+    glEnd( );
+
+    /*
+     * EXERCISE:
+     * Draw text telling the user that 'Spc'
+     * pauses the rotation and 'Esc' quits.
+     * Do it using vetors and textured quads.
+     */
+
+    /*
+     * Swap the buffers. This this tells the driver to
+     * render the next frame from the contents of the
+     * back-buffer, and to set all rendering operations
+     * to occur on what was the front-buffer.
+     *
+     * Double buffering prevents nasty visual tearing
+     * from the application drawing on areas of the
+     * screen that are being updated at the same time.
+     */
+    SDL_GL_SwapBuffers( );
+}
+
+static void setup_opengl( int width, int height )
+{
+    float ratio = (float) width / (float) height;
+
+    /* Our shading model--Gouraud (smooth). */
+    glShadeModel( GL_SMOOTH );
+
+    /* Culling. */
+    glCullFace( GL_BACK );
+    glFrontFace( GL_CCW );
+    glEnable( GL_CULL_FACE );
+
+    /* Set the clear color. */
+    glClearColor( 0, 0, 0, 0 );
+
+    /* Setup our viewport. */
+    glViewport( 0, 0, width, height );
+
+    /*
+     * Change to the projection matrix and set
+     * our viewing volume.
+     */
+    glMatrixMode( GL_PROJECTION );
+    glLoadIdentity( );
+    /*
+     * EXERCISE:
+     * Replace this with a call to glFrustum.
+     */
+    gluPerspective( 60.0, ratio, 1.0, 1024.0 );
+}
+
+int main( int argc, char* argv[] )
+{
+    /* Information about the current video settings. */
+    const SDL_VideoInfo* info = NULL;
+    /* Dimensions of our window. */
+    int width = 0;
+    int height = 0;
+    /* Color depth in bits of our window. */
+    int bpp = 0;
+    /* Flags we will pass into SDL_SetVideoMode. */
+    int flags = 0;
+
+    /* First, initialize SDL's video subsystem. */
+    if( SDL_Init( SDL_INIT_VIDEO ) &#60; 0 ) {
+        /* Failed, exit. */
+        fprintf( stderr, "Video initialization failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }
+
+    /* Let's get some video information. */
+    info = SDL_GetVideoInfo( );
+
+    if( !info ) {
+        /* This should probably never happen. */
+        fprintf( stderr, "Video query failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }
+
+    /*
+     * Set our width/height to 640/480 (you would
+     * of course let the user decide this in a normal
+     * app). We get the bpp we will request from
+     * the display. On X11, VidMode can't change
+     * resolution, so this is probably being overly
+     * safe. Under Win32, ChangeDisplaySettings
+     * can change the bpp.
+     */
+    width = 640;
+    height = 480;
+    bpp = info-&#62;vfmt-&#62;BitsPerPixel;
+
+    /*
+     * Now, we want to setup our requested
+     * window attributes for our OpenGL window.
+     * We want *at least* 5 bits of red, green
+     * and blue. We also want at least a 16-bit
+     * depth buffer.
+     *
+     * The last thing we do is request a double
+     * buffered window. '1' turns on double
+     * buffering, '0' turns it off.
+     *
+     * Note that we do not use SDL_DOUBLEBUF in
+     * the flags to SDL_SetVideoMode. That does
+     * not affect the GL attribute state, only
+     * the standard 2D blitting setup.
+     */
+    SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
+    SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+
+    /*
+     * We want to request that SDL provide us
+     * with an OpenGL window, in a fullscreen
+     * video mode.
+     *
+     * EXERCISE:
+     * Make starting windowed an option, and
+     * handle the resize events properly with
+     * glViewport.
+     */
+    flags = SDL_OPENGL | SDL_FULLSCREEN;
+
+    /*
+     * Set the video mode
+     */
+    if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {
+        /* 
+         * This could happen for a variety of reasons,
+         * including DISPLAY not being set, the specified
+         * resolution not being available, etc.
+         */
+        fprintf( stderr, "Video mode set failed: %s\n",
+             SDL_GetError( ) );
+        quit_tutorial( 1 );
+    }
+
+    /*
+     * At this point, we should have a properly setup
+     * double-buffered window for use with OpenGL.
+     */
+    setup_opengl( width, height );
+
+    /*
+     * Now we want to begin our normal app process--
+     * an event loop with a lot of redrawing.
+     */
+    while( 1 ) {
+        /* Process incoming events. */
+        process_events( );
+        /* Draw the screen. */
+        draw_screen( );
+    }
+
+    /*
+     * EXERCISE:
+     * Record timings using SDL_GetTicks() and
+     * and print out frames per second at program
+     * end.
+     */
+
+    /* Never reached. */
+    return 0;
+}</PRE
+></DIV
+></DIV
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidebasicsinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideinput.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Initializing SDL</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Input handling</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/guidevideoexamples.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,473 @@
+<HTML
+><HEAD
+><TITLE
+>Video Examples</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="PREVIOUS"
+TITLE="Examples"
+HREF="guideexamples.html"><LINK
+REL="NEXT"
+TITLE="Event Examples"
+HREF="guideeventexamples.html"></HEAD
+><BODY
+CLASS="SECT1"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guideexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+>Chapter 4. Examples</TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="guideeventexamples.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="SECT1"
+><H1
+CLASS="SECT1"
+><A
+NAME="GUIDEVIDEOEXAMPLES"
+>Video Examples</A
+></H1
+><P
+></P
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN303"
+>Initializing the video display</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Surface *screen;
+
+    /* Initialize the SDL library */
+    if( SDL_Init(SDL_INIT_VIDEO) &#60; 0 ) {
+        fprintf(stderr,
+                "Couldn't initialize SDL: %s\n", SDL_GetError());
+        exit(1);
+    }
+
+    /* Clean up on exit */
+    atexit(SDL_Quit);
+
+    /* Initialize the display in a 640x480 8-bit palettized mode */
+    screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE);
+    if ( screen == NULL ) {
+        fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
+                        SDL_GetError());
+        exit(1);
+    }</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN307"
+>Initializing the best video mode</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    /* Have a preference for 8-bit, but accept any depth */
+    screen = SDL_SetVideoMode(640, 480, 8, SDL_SWSURFACE|SDL_ANYFORMAT);
+    if ( screen == NULL ) {
+        fprintf(stderr, "Couldn't set 640x480x8 video mode: %s\n",
+                        SDL_GetError());
+        exit(1);
+    }
+    printf("Set 640x480 at %d bits-per-pixel mode\n",
+           screen-&#62;format-&#62;BitsPerPixel);</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN311"
+>Loading and displaying a BMP file</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    SDL_Surface *image;
+    SDL_Rect dest;
+    int ncolors, i;
+    SDL_Color *colors;
+
+    /* Load the BMP file into a surface */
+    image = SDL_LoadBMP("sample.bmp");
+    if ( image == NULL ) {
+        fprintf(stderr, "Couldn't load sample.bmp: %s\n",
+                        SDL_GetError());
+        return;
+    }
+
+    /* Set the display colors -- SDL_SetColors() only does something on
+       palettized displays, but it doesn't hurt anything on HiColor or
+       TrueColor displays.
+       If the display colors have already been set, this step can be
+       skipped, and the library will automatically map the image to
+       the current display colors.
+    */
+    if ( image-&#62;format-&#62;palette ) {
+        ncolors = image-&#62;format-&#62;palette-&#62;ncolors;
+        colors  = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+        memcpy(colors, image-&#62;format-&#62;palette-&#62;colors, ncolors);
+    } 
+    else {
+        int r, g, b;
+
+        /* Allocate 256 color palette */
+        ncolors = 256;
+        colors  = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+
+        /* Set a 3,3,2 color cube */
+        for ( r=0; r&#60;8; ++r ) {
+            for ( g=0; g&#60;8; ++g ) {
+                for ( b=0; b&#60;4; ++b ) {
+                    i = ((r&#60;&#60;5)|(g&#60;&#60;2)|b);
+                    colors[i].r = r&#60;&#60;5;
+                    colors[i].g = g&#60;&#60;5;
+                    colors[i].b = b&#60;&#60;6;
+                }
+            }
+        }
+        /* Note: A better way of allocating the palette might be
+           to calculate the frequency of colors in the image
+           and create a palette based on that information.
+        */
+    }
+    /* Set colormap, try for all the colors, but don't worry about it */
+    SDL_SetColors(screen, colors, 0, ncolors);
+    free(colors);
+
+    /* Blit onto the screen surface */
+    dest.x = 0;
+    dest.y = 0;
+    dest.w = image-&#62;w;
+    dest.h = image-&#62;h;
+    SDL_BlitSurface(image, NULL, screen, &#38;dest);
+
+    SDL_UpdateRects(screen, 1, &#38;dest);
+
+    /* Free the allocated BMP surface */
+    SDL_FreeSurface(image);
+    return;</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN315"
+>Drawing directly to the display</A
+></H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>    /* Code to set a yellow pixel at the center of the screen */
+
+    Sint32   X, Y;
+    Uint32   pixel;
+    Uint8   *bits, bpp;
+
+    /* Map the color yellow to this display (R=0xFF, G=0xFF, B=0x00)
+       Note:  If the display is palettized, you must set the palette first.
+    */
+    pixel = SDL_MapRGB(screen-&#62;format, 0xFF, 0xFF, 0x00);
+
+    /* Calculate the framebuffer offset of the center of the screen */
+    if ( SDL_MUSTLOCK(screen) ) {
+        if ( SDL_LockSurface(screen) &#60; 0 )
+            return;
+    }
+    bpp = screen-&#62;format-&#62;BytesPerPixel;
+    X = screen-&#62;w/2;
+    Y = screen-&#62;h/2;
+    bits = ((Uint8 *)screen-&#62;pixels)+Y*screen-&#62;pitch+X*bpp;
+
+    /* Set the pixel */
+    switch(bpp) {
+        case 1:
+            *((Uint8 *)(bits)) = (Uint8)pixel;
+            break;
+        case 2:
+            *((Uint16 *)(bits)) = (Uint16)pixel;
+            break;
+        case 3: { /* Format/endian independent */
+            Uint8 r, g, b;
+
+            r = (pixel&#62;&#62;screen-&#62;format-&#62;Rshift)&#38;0xFF;
+            g = (pixel&#62;&#62;screen-&#62;format-&#62;Gshift)&#38;0xFF;
+            b = (pixel&#62;&#62;screen-&#62;format-&#62;Bshift)&#38;0xFF;
+            *((bits)+screen-&#62;format-&#62;Rshift/8) = r; 
+            *((bits)+screen-&#62;format-&#62;Gshift/8) = g;
+            *((bits)+screen-&#62;format-&#62;Bshift/8) = b;
+            }
+            break;
+        case 4:
+            *((Uint32 *)(bits)) = (Uint32)pixel;
+            break;
+    }
+
+    /* Update the display */
+    if ( SDL_MUSTLOCK(screen) ) {
+        SDL_UnlockSurface(screen);
+    }
+    SDL_UpdateRect(screen, X, Y, 1, 1);
+
+    return;</PRE
+></P
+></DIV
+><DIV
+CLASS="SECT2"
+><H2
+CLASS="SECT2"
+><A
+NAME="AEN319"
+>Fastest possible surface blit</A
+></H2
+><P
+>There are three different ways you can draw an image to the screen: 
+<P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+>1.Create a surface and use <A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+> to blit it to the screen</TD
+></TR
+><TR
+><TD
+>2.Create the video surface in system memory and call <A
+HREF="sdlupdaterect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+></A
+></TD
+></TR
+><TR
+><TD
+>3.Create the video surface in video memory and call <A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+>
+The best way to do this is to combine methods: 
+<PRE
+CLASS="PROGRAMLISTING"
+>#include &#60;stdio.h&#62;
+#include &#60;stdlib.h&#62;
+#include "SDL.h"
+#include "SDL_timer.h"
+
+void ComplainAndExit(void)
+{
+    fprintf(stderr, "Problem: %s\n", SDL_GetError());
+    exit(1);
+}
+
+int main(int argc, char *argv[])
+{
+    SDL_PixelFormat fmt;
+    SDL_Surface *screen, *locked;
+    SDL_Surface *imagebmp, *image;
+    SDL_Rect dstrect;
+    int i;
+    Uint8 *buffer;
+
+    /* Initialize SDL */
+    if ( SDL_Init(SDL_INIT_VIDEO) &#60; 0 ) {
+        ComplainAndExit();
+    }
+    atexit(SDL_Quit);
+
+    /* Load a BMP image into a surface */
+    imagebmp = SDL_LoadBMP("image.bmp");
+    if ( imagebmp == NULL ) {
+        ComplainAndExit();
+    }
+
+    /* Set the video mode (640x480 at native depth) */
+    screen = SDL_SetVideoMode(640, 480, 0, SDL_HWSURFACE|SDL_FULLSCREEN);
+    if ( screen == NULL ) {
+        ComplainAndExit();
+    }
+
+    /* Set the video colormap */
+    if ( imagebmp-&#62;format-&#62;palette != NULL ) {
+        SDL_SetColors(screen,
+                      imagebmp-&#62;format-&#62;palette-&#62;colors, 0,
+                      imagebmp-&#62;format-&#62;palette-&#62;ncolors);
+    }
+
+    /* Convert the image to the video format (maps colors) */
+    image = SDL_DisplayFormat(imagebmp);
+    SDL_FreeSurface(imagebmp);
+    if ( image == NULL ) {
+        ComplainAndExit();
+    }
+
+    /* Draw bands of color on the raw surface */
+    if ( SDL_MUSTLOCK(screen) ) {
+        if ( SDL_LockSurface(screen) &#60; 0 )
+            ComplainAndExit();
+    }
+    buffer=(Uint8 *)screen-&#62;pixels;
+    for ( i=0; i&#60;screen-&#62;h; ++i ) {
+        memset(buffer,(i*255)/screen-&#62;h,
+               screen-&#62;w*screen-&#62;format-&#62;BytesPerPixel);
+               buffer += screen-&#62;pitch;
+    }
+    if ( SDL_MUSTLOCK(screen) ) {
+        SDL_UnlockSurface(screen);
+    }
+
+    /* Blit the image to the center of the screen */
+    dstrect.x = (screen-&#62;w-image-&#62;w)/2;
+    dstrect.y = (screen-&#62;h-image-&#62;h)/2;
+    dstrect.w = image-&#62;w;
+    dstrect.h = image-&#62;h;
+    if ( SDL_BlitSurface(image, NULL, screen, &#38;dstrect) &#60; 0 ) {
+        SDL_FreeSurface(image);
+        ComplainAndExit();
+    }
+    SDL_FreeSurface(image);
+
+    /* Update the screen */
+    SDL_UpdateRects(screen, 1, &#38;dstrect);
+
+    SDL_Delay(5000);        /* Wait 5 seconds */
+    exit(0);
+}</PRE
+></P
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guideeventexamples.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="guideexamples.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Event Examples</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/index.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1049 @@
+<HTML
+><HEAD
+><TITLE
+></TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="NEXT"
+TITLE="SDL Guide"
+HREF="guide.html"></HEAD
+><BODY
+CLASS="BOOK"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="BOOK"
+><A
+NAME="AEN1"
+></A
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+>I. <A
+HREF="guide.html"
+>SDL Guide</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guidepreface.html"
+>Preface</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guidepreface.html#GUIDEABOUTSDL"
+>About SDL</A
+></DT
+><DT
+><A
+HREF="guideaboutsdldoc.html"
+>About SDLdoc</A
+></DT
+><DT
+><A
+HREF="guidecredits.html"
+>Credits</A
+></DT
+></DL
+></DD
+><DT
+>1. <A
+HREF="guidethebasics.html"
+>The Basics</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guidethebasics.html#GUIDEINTRODUCTION"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="guidebasicsinit.html"
+>Initializing SDL</A
+></DT
+></DL
+></DD
+><DT
+>2. <A
+HREF="guidevideo.html"
+>Graphics and Video</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guidevideo.html#GUIDEVIDEOOPENGL"
+>Using OpenGL With SDL</A
+></DT
+></DL
+></DD
+><DT
+>3. <A
+HREF="guideinput.html"
+>Input handling</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guideinput.html#GUIDEINPUTJOYSTICK"
+>Handling Joysticks</A
+></DT
+><DT
+><A
+HREF="guideinputkeyboard.html"
+>Handling the Keyboard</A
+></DT
+></DL
+></DD
+><DT
+>4. <A
+HREF="guideexamples.html"
+>Examples</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="guideexamples.html#AEN297"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="guidevideoexamples.html"
+>Video Examples</A
+></DT
+><DT
+><A
+HREF="guideeventexamples.html"
+>Event Examples</A
+></DT
+><DT
+><A
+HREF="guideaudioexamples.html"
+>Audio Examples</A
+></DT
+><DT
+><A
+HREF="guidecdromexamples.html"
+>CDROM Examples</A
+></DT
+><DT
+><A
+HREF="guidetimeexamples.html"
+>Time Examples</A
+></DT
+></DL
+></DD
+></DL
+></DD
+><DT
+>II. <A
+HREF="reference.html"
+>SDL Reference</A
+></DT
+><DD
+><DL
+><DT
+>5. <A
+HREF="general.html"
+>General</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlinit.html"
+>SDL_Init</A
+> &#8212; Initializes SDL</DT
+><DT
+><A
+HREF="sdlinitsubsystem.html"
+>SDL_InitSubSystem</A
+> &#8212; Initialize subsystems</DT
+><DT
+><A
+HREF="sdlquitsubsystem.html"
+>SDL_QuitSubSystem</A
+> &#8212; Shut down a subsystem</DT
+><DT
+><A
+HREF="sdlquit.html"
+>SDL_Quit</A
+> &#8212; Shut down SDL</DT
+><DT
+><A
+HREF="sdlwasinit.html"
+>SDL_WasInit</A
+> &#8212; Check which subsystems are initialized</DT
+></DL
+></DD
+><DT
+>6. <A
+HREF="video.html"
+>Video</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlgetvideosurface.html"
+>SDL_GetVideoSurface</A
+> &#8212; returns a pointer to the current display surface</DT
+><DT
+><A
+HREF="sdlgetvideoinfo.html"
+>SDL_GetVideoInfo</A
+> &#8212; returns a pointer to information about the video hardware</DT
+><DT
+><A
+HREF="sdlvideodrivername.html"
+>SDL_VideoDriverName</A
+> &#8212; Obtain the name of the video driver</DT
+><DT
+><A
+HREF="sdllistmodes.html"
+>SDL_ListModes</A
+> &#8212; Returns a pointer to an array of available screen dimensions for 
+the given format and video flags</DT
+><DT
+><A
+HREF="sdlvideomodeok.html"
+>SDL_VideoModeOK</A
+> &#8212; Check to see if a particular video mode is supported.</DT
+><DT
+><A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+> &#8212; Set up a video mode with the specified width, height and bits-per-pixel.</DT
+><DT
+><A
+HREF="sdlupdaterect.html"
+>SDL_UpdateRect</A
+> &#8212; Makes sure the given area is updated on the given screen.</DT
+><DT
+><A
+HREF="sdlupdaterects.html"
+>SDL_UpdateRects</A
+> &#8212; Makes sure the given list of rectangles is updated on the given screen.</DT
+><DT
+><A
+HREF="sdlflip.html"
+>SDL_Flip</A
+> &#8212; Swaps screen buffers</DT
+><DT
+><A
+HREF="sdlsetcolors.html"
+>SDL_SetColors</A
+> &#8212; Sets a portion of the colormap for the given 8-bit surface.</DT
+><DT
+><A
+HREF="sdlsetpalette.html"
+>SDL_SetPalette</A
+> &#8212; Sets the colors in the palette of an 8-bit surface.</DT
+><DT
+><A
+HREF="sdlsetgamma.html"
+>SDL_SetGamma</A
+> &#8212; Sets the color gamma function for the display</DT
+><DT
+><A
+HREF="sdlgetgammaramp.html"
+>SDL_GetGammaRamp</A
+> &#8212; Gets the color gamma lookup tables for the display</DT
+><DT
+><A
+HREF="sdlsetgammaramp.html"
+>SDL_SetGammaRamp</A
+> &#8212; Sets the color gamma lookup tables for the display</DT
+><DT
+><A
+HREF="sdlmaprgb.html"
+>SDL_MapRGB</A
+> &#8212; Map a RGB color value to a pixel format.</DT
+><DT
+><A
+HREF="sdlmaprgba.html"
+>SDL_MapRGBA</A
+> &#8212; Map a RGBA color value to a pixel format.</DT
+><DT
+><A
+HREF="sdlgetrgb.html"
+>SDL_GetRGB</A
+> &#8212; Get RGB values from a pixel in the specified pixel format.</DT
+><DT
+><A
+HREF="sdlgetrgba.html"
+>SDL_GetRGBA</A
+> &#8212; Get RGBA values from a pixel in the specified pixel format.</DT
+><DT
+><A
+HREF="sdlcreatergbsurface.html"
+>SDL_CreateRGBSurface</A
+> &#8212; Create an empty SDL_Surface</DT
+><DT
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>SDL_CreateRGBSurfaceFrom</A
+> &#8212; Create an SDL_Surface from pixel data</DT
+><DT
+><A
+HREF="sdlfreesurface.html"
+>SDL_FreeSurface</A
+> &#8212; Frees (deletes) and SDL_Surface</DT
+><DT
+><A
+HREF="sdllocksurface.html"
+>SDL_LockSurface</A
+> &#8212; Lock a surface for directly access.</DT
+><DT
+><A
+HREF="sdlunlocksurface.html"
+>SDL_UnlockSurface</A
+> &#8212; Unlocks a previously locked surface.</DT
+><DT
+><A
+HREF="sdlloadbmp.html"
+>SDL_LoadBMP</A
+> &#8212; Load a Windows BMP file into an SDL_Surface.</DT
+><DT
+><A
+HREF="sdlsavebmp.html"
+>SDL_SaveBMP</A
+> &#8212; Save an SDL_Surface as a Windows BMP file.</DT
+><DT
+><A
+HREF="sdlsetcolorkey.html"
+>SDL_SetColorKey</A
+> &#8212; Sets the color key (transparent pixel) in a blittable surface and
+RLE acceleration.</DT
+><DT
+><A
+HREF="sdlsetalpha.html"
+>SDL_SetAlpha</A
+> &#8212; Adjust the alpha properties of a surface</DT
+><DT
+><A
+HREF="sdlsetcliprect.html"
+>SDL_SetClipRect</A
+> &#8212; Sets the clipping rectangle for a surface.</DT
+><DT
+><A
+HREF="sdlgetcliprect.html"
+>SDL_GetClipRect</A
+> &#8212; Gets the clipping rectangle for a surface.</DT
+><DT
+><A
+HREF="sdlconvertsurface.html"
+>SDL_ConvertSurface</A
+> &#8212; Converts a surface to the same format as another surface.</DT
+><DT
+><A
+HREF="sdlblitsurface.html"
+>SDL_BlitSurface</A
+> &#8212; This performs a fast blit from the source surface to the destination surface.</DT
+><DT
+><A
+HREF="sdlfillrect.html"
+>SDL_FillRect</A
+> &#8212; This function performs a fast fill of the given rectangle with some color</DT
+><DT
+><A
+HREF="sdldisplayformat.html"
+>SDL_DisplayFormat</A
+> &#8212; Convert a surface to the display format</DT
+><DT
+><A
+HREF="sdldisplayformatalpha.html"
+>SDL_DisplayFormatAlpha</A
+> &#8212; Convert a surface to the display format</DT
+><DT
+><A
+HREF="sdlwarpmouse.html"
+>SDL_WarpMouse</A
+> &#8212; Set the position of the mouse cursor.</DT
+><DT
+><A
+HREF="sdlcreatecursor.html"
+>SDL_CreateCursor</A
+> &#8212; Creates a new mouse cursor.</DT
+><DT
+><A
+HREF="sdlfreecursor.html"
+>SDL_FreeCursor</A
+> &#8212; Frees a cursor created with SDL_CreateCursor.</DT
+><DT
+><A
+HREF="sdlsetcursor.html"
+>SDL_SetCursor</A
+> &#8212; Set the currently active mouse cursor.</DT
+><DT
+><A
+HREF="sdlgetcursor.html"
+>SDL_GetCursor</A
+> &#8212; Get the currently active mouse cursor.</DT
+><DT
+><A
+HREF="sdlshowcursor.html"
+>SDL_ShowCursor</A
+> &#8212; Toggle whether or not the cursor is shown on the screen.</DT
+><DT
+><A
+HREF="sdlglloadlibrary.html"
+>SDL_GL_LoadLibrary</A
+> &#8212; Specify an OpenGL library</DT
+><DT
+><A
+HREF="sdlglgetprocaddress.html"
+>SDL_GL_GetProcAddress</A
+> &#8212; Get the address of a GL function</DT
+><DT
+><A
+HREF="sdlglgetattribute.html"
+>SDL_GL_GetAttribute</A
+> &#8212; Get the value of a special SDL/OpenGL attribute</DT
+><DT
+><A
+HREF="sdlglsetattribute.html"
+>SDL_GL_SetAttribute</A
+> &#8212; Set a special SDL/OpenGL attribute</DT
+><DT
+><A
+HREF="sdlglswapbuffers.html"
+>SDL_GL_SwapBuffers</A
+> &#8212; Swap OpenGL framebuffers/Update Display</DT
+><DT
+><A
+HREF="sdlcreateyuvoverlay.html"
+>SDL_CreateYUVOverlay</A
+> &#8212; Create a YUV video overlay</DT
+><DT
+><A
+HREF="sdllockyuvoverlay.html"
+>SDL_LockYUVOverlay</A
+> &#8212; Lock an overlay</DT
+><DT
+><A
+HREF="sdlunlockyuvoverlay.html"
+>SDL_UnlockYUVOverlay</A
+> &#8212; Unlock an overlay</DT
+><DT
+><A
+HREF="sdldisplayyuvoverlay.html"
+>SDL_DisplayYUVOverlay</A
+> &#8212; Blit the overlay to the display</DT
+><DT
+><A
+HREF="sdlfreeyuvoverlay.html"
+>SDL_FreeYUVOverlay</A
+> &#8212; Free a YUV video overlay</DT
+><DT
+><A
+HREF="sdlglattr.html"
+>SDL_GLattr</A
+> &#8212; SDL GL Attributes</DT
+><DT
+><A
+HREF="sdlrect.html"
+>SDL_Rect</A
+> &#8212; Defines a rectangular area</DT
+><DT
+><A
+HREF="sdlcolor.html"
+>SDL_Color</A
+> &#8212; Format independent color description</DT
+><DT
+><A
+HREF="sdlpalette.html"
+>SDL_Palette</A
+> &#8212; Color palette for 8-bit pixel formats</DT
+><DT
+><A
+HREF="sdlpixelformat.html"
+>SDL_PixelFormat</A
+> &#8212; Stores surface format information</DT
+><DT
+><A
+HREF="sdlsurface.html"
+>SDL_Surface</A
+> &#8212; Graphical Surface Structure</DT
+><DT
+><A
+HREF="sdlvideoinfo.html"
+>SDL_VideoInfo</A
+> &#8212; Video Target information</DT
+><DT
+><A
+HREF="sdloverlay.html"
+>SDL_Overlay</A
+> &#8212; YUV video overlay</DT
+></DL
+></DD
+><DT
+>7. <A
+HREF="wm.html"
+>Window Management</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlwmsetcaption.html"
+>SDL_WM_SetCaption</A
+> &#8212; Sets the window tile and icon name.</DT
+><DT
+><A
+HREF="sdlwmgetcaption.html"
+>SDL_WM_GetCaption</A
+> &#8212; Gets the window title and icon name.</DT
+><DT
+><A
+HREF="sdlwmseticon.html"
+>SDL_WM_SetIcon</A
+> &#8212; Sets the icon for the display window.</DT
+><DT
+><A
+HREF="sdlwmiconifywindow.html"
+>SDL_WM_IconifyWindow</A
+> &#8212; Iconify/Minimise the window</DT
+><DT
+><A
+HREF="sdlwmtogglefullscreen.html"
+>SDL_WM_ToggleFullScreen</A
+> &#8212; Toggles fullscreen mode</DT
+><DT
+><A
+HREF="sdlwmgrabinput.html"
+>SDL_WM_GrabInput</A
+> &#8212; Grabs mouse and keyboard input.</DT
+></DL
+></DD
+><DT
+>8. <A
+HREF="event.html"
+>Events</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="event.html#AEN3194"
+>Introduction</A
+></DT
+><DT
+><A
+HREF="eventstructures.html"
+>SDL Event Structures.</A
+></DT
+><DT
+><A
+HREF="eventfunctions.html"
+>Event Functions.</A
+></DT
+></DL
+></DD
+><DT
+>9. <A
+HREF="joystick.html"
+>Joystick</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlnumjoysticks.html"
+>SDL_NumJoysticks</A
+> &#8212; Count available joysticks.</DT
+><DT
+><A
+HREF="sdljoystickname.html"
+>SDL_JoystickName</A
+> &#8212; Get joystick name.</DT
+><DT
+><A
+HREF="sdljoystickopen.html"
+>SDL_JoystickOpen</A
+> &#8212; Opens a joystick for use.</DT
+><DT
+><A
+HREF="sdljoystickopened.html"
+>SDL_JoystickOpened</A
+> &#8212; Determine if a joystick has been opened</DT
+><DT
+><A
+HREF="sdljoystickindex.html"
+>SDL_JoystickIndex</A
+> &#8212; Get the index of an SDL_Joystick.</DT
+><DT
+><A
+HREF="sdljoysticknumaxes.html"
+>SDL_JoystickNumAxes</A
+> &#8212; Get the number of joystick axes</DT
+><DT
+><A
+HREF="sdljoysticknumballs.html"
+>SDL_JoystickNumBalls</A
+> &#8212; Get the number of joystick trackballs</DT
+><DT
+><A
+HREF="sdljoysticknumhats.html"
+>SDL_JoystickNumHats</A
+> &#8212; Get the number of joystick hats</DT
+><DT
+><A
+HREF="sdljoysticknumbuttons.html"
+>SDL_JoystickNumButtons</A
+> &#8212; Get the number of joysitck buttons</DT
+><DT
+><A
+HREF="sdljoystickupdate.html"
+>SDL_JoystickUpdate</A
+> &#8212; Updates the state of all joysticks</DT
+><DT
+><A
+HREF="sdljoystickgetaxis.html"
+>SDL_JoystickGetAxis</A
+> &#8212; Get the current state of an axis</DT
+><DT
+><A
+HREF="sdljoystickgethat.html"
+>SDL_JoystickGetHat</A
+> &#8212; Get the current state of a joystick hat</DT
+><DT
+><A
+HREF="sdljoystickgetbutton.html"
+>SDL_JoystickGetButton</A
+> &#8212; Get the current state of a given button on a given joystick</DT
+><DT
+><A
+HREF="sdljoystickgetball.html"
+>SDL_JoystickGetBall</A
+> &#8212; Get relative trackball motion</DT
+><DT
+><A
+HREF="sdljoystickclose.html"
+>SDL_JoystickClose</A
+> &#8212; Closes a previously opened joystick</DT
+></DL
+></DD
+><DT
+>10. <A
+HREF="audio.html"
+>Audio</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlaudiospec.html"
+>SDL_AudioSpec</A
+> &#8212; Audio Specification Structure</DT
+><DT
+><A
+HREF="sdlopenaudio.html"
+>SDL_OpenAudio</A
+> &#8212; Opens the audio device with the desired parameters.</DT
+><DT
+><A
+HREF="sdlpauseaudio.html"
+>SDL_PauseAudio</A
+> &#8212; Pauses and unpauses the audio callback processing</DT
+><DT
+><A
+HREF="sdlgetaudiostatus.html"
+>SDL_GetAudioStatus</A
+> &#8212; Get the current audio state</DT
+><DT
+><A
+HREF="sdlloadwav.html"
+>SDL_LoadWAV</A
+> &#8212; Load a WAVE file</DT
+><DT
+><A
+HREF="sdlfreewav.html"
+>SDL_FreeWAV</A
+> &#8212; Frees previously opened WAV data</DT
+><DT
+><A
+HREF="sdlaudiocvt.html"
+>SDL_AudioCVT</A
+> &#8212; Audio Conversion Structure</DT
+><DT
+><A
+HREF="sdlbuildaudiocvt.html"
+>SDL_BuildAudioCVT</A
+> &#8212; Initializes a SDL_AudioCVT structure for conversion</DT
+><DT
+><A
+HREF="sdlconvertaudio.html"
+>SDL_ConvertAudio</A
+> &#8212; Convert audio data to a desired audio format.</DT
+><DT
+><A
+HREF="sdlmixaudio.html"
+>SDL_MixAudio</A
+> &#8212; Mix audio data</DT
+><DT
+><A
+HREF="sdllockaudio.html"
+>SDL_LockAudio</A
+> &#8212; Lock out the callback function</DT
+><DT
+><A
+HREF="sdlunlockaudio.html"
+>SDL_UnlockAudio</A
+> &#8212; Unlock the callback function</DT
+><DT
+><A
+HREF="sdlcloseaudio.html"
+>SDL_CloseAudio</A
+> &#8212; Shuts down audio processing and closes the audio device.</DT
+></DL
+></DD
+><DT
+>11. <A
+HREF="cdrom.html"
+>CD-ROM</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlcdnumdrives.html"
+>SDL_CDNumDrives</A
+> &#8212; Returns the number of CD-ROM drives on the system.</DT
+><DT
+><A
+HREF="sdlcdname.html"
+>SDL_CDName</A
+> &#8212; Returns a human-readable, system-dependent identifier for the CD-ROM.</DT
+><DT
+><A
+HREF="sdlcdopen.html"
+>SDL_CDOpen</A
+> &#8212; Opens a CD-ROM drive for access.</DT
+><DT
+><A
+HREF="sdlcdstatus.html"
+>SDL_CDStatus</A
+> &#8212; Returns the current status of the given drive.</DT
+><DT
+><A
+HREF="sdlcdplay.html"
+>SDL_CDPlay</A
+> &#8212; Play a CD</DT
+><DT
+><A
+HREF="sdlcdplaytracks.html"
+>SDL_CDPlayTracks</A
+> &#8212; Play the given CD track(s)</DT
+><DT
+><A
+HREF="sdlcdpause.html"
+>SDL_CDPause</A
+> &#8212; Pauses a CDROM</DT
+><DT
+><A
+HREF="sdlcdresume.html"
+>SDL_CDResume</A
+> &#8212; Resumes a CDROM</DT
+><DT
+><A
+HREF="sdlcdstop.html"
+>SDL_CDStop</A
+> &#8212; Stops a CDROM</DT
+><DT
+><A
+HREF="sdlcdeject.html"
+>SDL_CDEject</A
+> &#8212; Ejects a CDROM</DT
+><DT
+><A
+HREF="sdlcdclose.html"
+>SDL_CDClose</A
+> &#8212; Closes a SDL_CD handle</DT
+><DT
+><A
+HREF="sdlcd.html"
+>SDL_CD</A
+> &#8212; CDROM Drive Information</DT
+><DT
+><A
+HREF="sdlcdtrack.html"
+>SDL_CDtrack</A
+> &#8212; CD Track Information Structure</DT
+></DL
+></DD
+><DT
+>12. <A
+HREF="thread.html"
+>Multi-threaded Programming</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlcreatethread.html"
+>SDL_CreateThread</A
+> &#8212; Creates a new thread of execution that shares its parent's properties.</DT
+><DT
+><A
+HREF="sdlthreadid.html"
+>SDL_ThreadID</A
+> &#8212; Get the 32-bit thread identifier for the current thread.</DT
+><DT
+><A
+HREF="sdlgetthreadid.html"
+>SDL_GetThreadID</A
+> &#8212; Get the SDL thread ID of a SDL_Thread</DT
+><DT
+><A
+HREF="sdlwaitthread.html"
+>SDL_WaitThread</A
+> &#8212; Wait for a thread to finish.</DT
+><DT
+><A
+HREF="sdlkillthread.html"
+>SDL_KillThread</A
+> &#8212; Gracelessly terminates the thread.</DT
+><DT
+><A
+HREF="sdlcreatemutex.html"
+>SDL_CreateMutex</A
+> &#8212; Create a mutex</DT
+><DT
+><A
+HREF="sdldestroymutex.html"
+>SDL_DestroyMutex</A
+> &#8212; Destroy a mutex</DT
+><DT
+><A
+HREF="sdlmutexp.html"
+>SDL_mutexP</A
+> &#8212; Lock a mutex</DT
+><DT
+><A
+HREF="sdlmutexv.html"
+>SDL_mutexV</A
+> &#8212; Unlock a mutex</DT
+><DT
+><A
+HREF="sdlcreatesemaphore.html"
+>SDL_CreateSemaphore</A
+> &#8212; Creates a new semaphore and assigns an initial value to it.</DT
+><DT
+><A
+HREF="sdldestroysemaphore.html"
+>SDL_DestroySemaphore</A
+> &#8212; Destroys a semaphore that was created by <A
+HREF="sdlcreatesemaphore.html"
+>SDL_CreateSemaphore</A
+>.</DT
+><DT
+><A
+HREF="sdlsemwait.html"
+>SDL_SemWait</A
+> &#8212; Lock a semaphore and suspend the thread if the semaphore value is zero.</DT
+><DT
+><A
+HREF="sdlsemtrywait.html"
+>SDL_SemTryWait</A
+> &#8212; Attempt to lock a semaphore but don't suspend the thread.</DT
+><DT
+><A
+HREF="sdlsemwaittimeout.html"
+>SDL_SemWaitTimeout</A
+> &#8212; Lock a semaphore, but only wait up to a specified maximum time.</DT
+><DT
+><A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+> &#8212; Unlock a semaphore.</DT
+><DT
+><A
+HREF="sdlsemvalue.html"
+>SDL_SemValue</A
+> &#8212; Return the current value of a semaphore.</DT
+><DT
+><A
+HREF="sdlcreatecond.html"
+>SDL_CreateCond</A
+> &#8212; Create a condition variable</DT
+><DT
+><A
+HREF="sdldestroycond.html"
+>SDL_DestroyCond</A
+> &#8212; Destroy a condition variable</DT
+><DT
+><A
+HREF="sdlcondsignal.html"
+>SDL_CondSignal</A
+> &#8212; Restart a thread wait on a condition variable</DT
+><DT
+><A
+HREF="sdlcondbroadcast.html"
+>SDL_CondBroadcast</A
+> &#8212; Restart all threads waiting on a condition variable</DT
+><DT
+><A
+HREF="sdlcondwait.html"
+>SDL_CondWait</A
+> &#8212; Wait on a condition variable</DT
+><DT
+><A
+HREF="sdlcondwaittimeout.html"
+>SDL_CondWaitTimeout</A
+> &#8212; Wait on a condition variable, with timeout</DT
+></DL
+></DD
+><DT
+>13. <A
+HREF="time.html"
+>Time</A
+></DT
+><DD
+><DL
+><DT
+><A
+HREF="sdlgetticks.html"
+>SDL_GetTicks</A
+> &#8212; Get the number of milliseconds since the SDL library initialization.</DT
+><DT
+><A
+HREF="sdldelay.html"
+>SDL_Delay</A
+> &#8212; Wait a specified number of milliseconds before returning.</DT
+><DT
+><A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+> &#8212; Add a timer which will call a callback after the specified number of milliseconds has
+elapsed.</DT
+><DT
+><A
+HREF="sdlremovetimer.html"
+>SDL_RemoveTimer</A
+> &#8212; Remove a timer which was added with
+<A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+>.</DT
+><DT
+><A
+HREF="sdlsettimer.html"
+>SDL_SetTimer</A
+> &#8212; Set a callback to run after the specified number of milliseconds has
+elapsed.</DT
+></DL
+></DD
+></DL
+></DD
+></DL
+></DIV
+><DIV
+CLASS="LOT"
+><DL
+CLASS="LOT"
+><DT
+><B
+>List of Tables</B
+></DT
+><DT
+>8-1. <A
+HREF="sdlkey.html#AEN4177"
+>SDL Keysym definitions</A
+></DT
+><DT
+>8-2. <A
+HREF="sdlkey.html#SDLMOD"
+>SDL modifier definitions</A
+></DT
+></DL
+></DIV
+><DIV
+CLASS="LOT"
+><DL
+CLASS="LOT"
+><DT
+><B
+>List of Examples</B
+></DT
+><DT
+>2-1. <A
+HREF="guidevideo.html#AEN87"
+>gl.c - SDL OpenGL Example</A
+></DT
+><DT
+>3-1. <A
+HREF="guideinputkeyboard.html#AEN282"
+>keys.c - Key event information</A
+></DT
+></DL
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="guide.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL Guide</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/joystick.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,285 @@
+<HTML
+><HEAD
+><TITLE
+>Joystick</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickEventState"
+HREF="sdljoystickeventstate.html"><LINK
+REL="NEXT"
+TITLE="SDL_NumJoysticks"
+HREF="sdlnumjoysticks.html"><META
+NAME="KEYWORD"
+CONTENT="joystick"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickeventstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlnumjoysticks.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="JOYSTICK"
+>Chapter 9. Joystick</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlnumjoysticks.html"
+>SDL_NumJoysticks</A
+> &#8212; Count available joysticks.</DT
+><DT
+><A
+HREF="sdljoystickname.html"
+>SDL_JoystickName</A
+> &#8212; Get joystick name.</DT
+><DT
+><A
+HREF="sdljoystickopen.html"
+>SDL_JoystickOpen</A
+> &#8212; Opens a joystick for use.</DT
+><DT
+><A
+HREF="sdljoystickopened.html"
+>SDL_JoystickOpened</A
+> &#8212; Determine if a joystick has been opened</DT
+><DT
+><A
+HREF="sdljoystickindex.html"
+>SDL_JoystickIndex</A
+> &#8212; Get the index of an SDL_Joystick.</DT
+><DT
+><A
+HREF="sdljoysticknumaxes.html"
+>SDL_JoystickNumAxes</A
+> &#8212; Get the number of joystick axes</DT
+><DT
+><A
+HREF="sdljoysticknumballs.html"
+>SDL_JoystickNumBalls</A
+> &#8212; Get the number of joystick trackballs</DT
+><DT
+><A
+HREF="sdljoysticknumhats.html"
+>SDL_JoystickNumHats</A
+> &#8212; Get the number of joystick hats</DT
+><DT
+><A
+HREF="sdljoysticknumbuttons.html"
+>SDL_JoystickNumButtons</A
+> &#8212; Get the number of joysitck buttons</DT
+><DT
+><A
+HREF="sdljoystickupdate.html"
+>SDL_JoystickUpdate</A
+> &#8212; Updates the state of all joysticks</DT
+><DT
+><A
+HREF="sdljoystickgetaxis.html"
+>SDL_JoystickGetAxis</A
+> &#8212; Get the current state of an axis</DT
+><DT
+><A
+HREF="sdljoystickgethat.html"
+>SDL_JoystickGetHat</A
+> &#8212; Get the current state of a joystick hat</DT
+><DT
+><A
+HREF="sdljoystickgetbutton.html"
+>SDL_JoystickGetButton</A
+> &#8212; Get the current state of a given button on a given joystick</DT
+><DT
+><A
+HREF="sdljoystickgetball.html"
+>SDL_JoystickGetBall</A
+> &#8212; Get relative trackball motion</DT
+><DT
+><A
+HREF="sdljoystickclose.html"
+>SDL_JoystickClose</A
+> &#8212; Closes a previously opened joystick</DT
+></DL
+></DIV
+><P
+>Joysticks, and other similar input devices, have a very strong role in game playing and SDL provides comprehensive support for them. Axes, Buttons, POV Hats and trackballs are all supported.</P
+><P
+>Joystick support is initialized by passed the <TT
+CLASS="LITERAL"
+>SDL_INIT_JOYSTICK</TT
+> flag to <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>. Once initilized joysticks must be opened using <A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+>.</P
+><P
+>While using the functions describe in this secton may seem like the best way to access and read from joysticks, in most cases they aren't. Ideally joysticks should be read using the <A
+HREF="event.html"
+>event</A
+> system. To enable this, you must set the joystick event processing state with <A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+>. Joysticks must be <A
+HREF="sdljoystickopen.html"
+>opened</A
+> before they can be used of course.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>If you are <I
+CLASS="EMPHASIS"
+>not</I
+> handling the joystick via the event queue then you must explicitly request a joystick update by calling <A
+HREF="sdljoystickupdate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickUpdate</TT
+></A
+>.</P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Force Feedback is not yet support. Sam (slouken@libsdl.org) is soliciting suggestions from people with force-feedback experience on the best wat to desgin the API.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickeventstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlnumjoysticks.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickEventState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_NumJoysticks</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/reference.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,187 @@
+<HTML
+><HEAD
+><TITLE
+>SDL Reference</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="PREVIOUS"
+TITLE="Time Examples"
+HREF="guidetimeexamples.html"><LINK
+REL="NEXT"
+TITLE="General"
+HREF="general.html"></HEAD
+><BODY
+CLASS="PART"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="guidetimeexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="general.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="PART"
+><A
+NAME="REFERENCE"
+></A
+><DIV
+CLASS="TITLEPAGE"
+><H1
+CLASS="TITLE"
+>II. SDL Reference</H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+>5. <A
+HREF="general.html"
+>General</A
+></DT
+><DT
+>6. <A
+HREF="video.html"
+>Video</A
+></DT
+><DT
+>7. <A
+HREF="wm.html"
+>Window Management</A
+></DT
+><DT
+>8. <A
+HREF="event.html"
+>Events</A
+></DT
+><DT
+>9. <A
+HREF="joystick.html"
+>Joystick</A
+></DT
+><DT
+>10. <A
+HREF="audio.html"
+>Audio</A
+></DT
+><DT
+>11. <A
+HREF="cdrom.html"
+>CD-ROM</A
+></DT
+><DT
+>12. <A
+HREF="thread.html"
+>Multi-threaded Programming</A
+></DT
+><DT
+>13. <A
+HREF="time.html"
+>Time</A
+></DT
+></DL
+></DIV
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="guidetimeexamples.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="general.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Time Examples</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>General</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlactiveevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,327 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ActiveEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Event"
+HREF="sdlevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_KeyboardEvent"
+HREF="sdlkeyboardevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlkeyboardevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLACTIVEEVENT"
+>SDL_ActiveEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3447"
+></A
+><H2
+>Name</H2
+>SDL_ActiveEvent&nbsp;--&nbsp;Application visibility event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3450"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 gain;
+  Uint8 state;
+} SDL_ActiveEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3453"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3455"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_ACTIVEEVENT.</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>0 if the event is a loss or 1 if it is a gain.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_APPMOUSEFOCUS</TT
+> if mouse focus was gained or lost, <TT
+CLASS="LITERAL"
+>SDL_APPINPUTFOCUS</TT
+> if input focus was gained or lost, or <TT
+CLASS="LITERAL"
+>SDL_APPACTIVE</TT
+> if the application was iconified (<TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+>=0) or restored(<TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+>=1).</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3476"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_ActiveEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_ACTIVEEVENT</TT
+> is reported.</P
+><P
+>When the mouse leaves or enters the window area a <TT
+CLASS="LITERAL"
+>SDL_APPMOUSEFOCUS</TT
+> type activation event occurs, if the mouse entered the window then <TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+> will be 1, otherwise <TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+> will be 0. A <TT
+CLASS="LITERAL"
+>SDL_APPINPUTFOCUS</TT
+> type activation event occurs when the application loses or gains keyboard focus. This usually occurs when another application is made active. Finally, a <TT
+CLASS="LITERAL"
+>SDL_APPACTIVE</TT
+> type event occurs when the application is either minimised/iconified (<TT
+CLASS="STRUCTFIELD"
+><I
+>gain</I
+></TT
+>=0) or restored.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>This event does not occur when an application window is first created.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3492"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlgetappstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetAppState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlkeyboardevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Event</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_KeyboardEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdladdtimer.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,275 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_AddTimer</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Delay"
+HREF="sdldelay.html"><LINK
+REL="NEXT"
+TITLE="SDL_RemoveTimer"
+HREF="sdlremovetimer.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldelay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlremovetimer.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLADDTIMER"
+>SDL_AddTimer</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7854"
+></A
+><H2
+>Name</H2
+>SDL_AddTimer&nbsp;--&nbsp;Add a timer which will call a callback after the specified number of milliseconds has
+elapsed.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7857"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7858"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_TimerID <B
+CLASS="FSFUNC"
+>SDL_AddTimer</B
+></CODE
+>(Uint32 interval, SDL_NewTimerCallback callback, void *param);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="SDLNEWTIMERCALLBACK"
+></A
+><H2
+>Callback</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* type definition for the "new" timer callback function */
+typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7867"
+></A
+><H2
+>Description</H2
+><P
+>Adds a callback function to be run after the specified number of
+milliseconds has elapsed. The callback function is passed the current
+timer interval and the user supplied parameter from the
+<TT
+CLASS="FUNCTION"
+>SDL_AddTimer</TT
+> call and returns the next timer
+interval. If the returned value from the callback is the same as the one
+passed in, the periodic alarm continues, otherwise a new alarm is
+scheduled.</P
+><P
+>To cancel a currently running timer call
+<A
+HREF="sdlremovetimer.html"
+>SDL_RemoveTimer</A
+> with the
+timer ID returned from
+<TT
+CLASS="FUNCTION"
+>SDL_AddTimer</TT
+>.</P
+><P
+>The timer callback function may run in a different thread than your
+main program, and so shouldn't call any functions from within itself.</P
+><P
+>The maximum resolution of this timer is 10 ms, which means that if
+you request a 16 ms timer, your callback will run approximately 20 ms
+later on an unloaded system.  If you wanted to set a flag signaling
+a frame update at 30 frames per second (every 33 ms), you might set a
+timer for 30 ms (see example below).
+
+If you use this function, you need to pass <TT
+CLASS="LITERAL"
+>SDL_INIT_TIMER</TT
+>
+to <A
+HREF="sdlinit.html"
+>SDL_Init</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7878"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns an ID value for the added timer or
+<SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+> if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7882"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>my_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7886"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlremovetimer.html"
+><TT
+CLASS="FUNCTION"
+>SDL_RemoveTimer</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldelay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlremovetimer.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Delay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="time.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_RemoveTimer</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlaudiocvt.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,548 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_AudioCVT</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_FreeWAV"
+HREF="sdlfreewav.html"><LINK
+REL="NEXT"
+TITLE="SDL_BuildAudioCVT"
+HREF="sdlbuildaudiocvt.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlfreewav.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlbuildaudiocvt.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLAUDIOCVT"
+>SDL_AudioCVT</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6262"
+></A
+><H2
+>Name</H2
+>SDL_AudioCVT&nbsp;--&nbsp;Audio Conversion Structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6265"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  int needed;
+  Uint16 src_format;
+  Uint16 dest_format;
+  double rate_incr;
+  Uint8 *buf;
+  int len;
+  int len_cvt;
+  int len_mult;
+  double len_ratio;
+  void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+  int filter_index;
+} SDL_AudioCVT;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6268"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN6270"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>needed</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Set to one if the conversion is possible</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>src_format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio format of the source</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>dest_format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio format of the destination</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>rate_incr</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Rate conversion increment</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio buffer</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Length of the original audio buffer in bytes</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>len_cvt</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Length of converted audio buffer in bytes (calculated)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> must be <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+> bytes in size(calculated)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>len_ratio</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Final audio size is <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>len_ratio</I
+></TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>filters[10](..)</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pointers to functions needed for this conversion</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>filter_index</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Current conversion function</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6322"
+></A
+><H2
+>Description</H2
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+> is used to convert audio data between different formats. A <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+> structure is created with the <A
+HREF="sdlbuildaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BuildAudioCVT</TT
+></A
+> function, while the actual conversion is done by the <A
+HREF="sdlconvertaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+></A
+> function.</P
+><P
+>Many of the fields in the <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+> structure should be considered private and their function will not be discussed here.</P
+><P
+></P
+><DIV
+CLASS="VARIABLELIST"
+><DL
+><DT
+><SPAN
+CLASS="TYPE"
+>Uint8 *</SPAN
+><TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+></DT
+><DD
+><P
+>This points to the audio data that will be used in the conversion. It is both the source and the destination, which means the converted audio data overwrites the original data. It also means that the converted data may be larger than the original data (if you were converting from 8-bit to 16-bit, for instance), so you must ensure <TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> is large enough. See below.</P
+></DD
+><DT
+><SPAN
+CLASS="TYPE"
+>int</SPAN
+> <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+></DT
+><DD
+><P
+>This is the length of the original audio data in bytes.</P
+></DD
+><DT
+><SPAN
+CLASS="TYPE"
+>int</SPAN
+> <TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+></DT
+><DD
+><P
+>As explained above, the audio buffer needs to be big enough to store the converted data, which may be bigger than the original audio data. The length of <TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> should be <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+>.</P
+></DD
+><DT
+><SPAN
+CLASS="TYPE"
+>double</SPAN
+> <TT
+CLASS="STRUCTFIELD"
+><I
+>len_ratio</I
+></TT
+></DT
+><DD
+><P
+>When you have finished converting your audio data, you need to know how much of your audio buffer is valid. <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>len_ratio</I
+></TT
+> is the size of the converted audio data in bytes. This is very similar to <TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+>, however when the convert audio data is shorter than the original <TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+> would be 1. <TT
+CLASS="STRUCTFIELD"
+><I
+>len_ratio</I
+></TT
+>, on the other hand, would be a fractional number between 0 and 1.</P
+></DD
+></DL
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6367"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlbuildaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BuildAudioCVT</TT
+></A
+>,
+<A
+HREF="sdlconvertaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+></A
+>,
+<A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlfreewav.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlbuildaudiocvt.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_FreeWAV</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_BuildAudioCVT</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlaudiospec.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,581 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_AudioSpec</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="NEXT"
+TITLE="SDL_OpenAudio"
+HREF="sdlopenaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="audio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlopenaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLAUDIOSPEC"
+>SDL_AudioSpec</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5885"
+></A
+><H2
+>Name</H2
+>SDL_AudioSpec&nbsp;--&nbsp;Audio Specification Structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5888"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  int freq;
+  Uint16 format;
+  Uint8 channels;
+  Uint8 silence;
+  Uint16 samples;
+  Uint32 size;
+  void (*callback)(void *userdata, Uint8 *stream, int len);
+  void *userdata;
+} SDL_AudioSpec;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5891"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN5893"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>freq</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio frequency in samples per second</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio data format</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>channels</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Number of channels: 1 mono, 2 stereo</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>silence</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio buffer silence value (calculated)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>samples</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio buffer size in samples</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>size</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Audio buffer size in bytes (calculated)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>callback(..)</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Callback function for filling the audio buffer</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>userdata</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pointer the user data which is passed to the callback function</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5928"
+></A
+><H2
+>Description</H2
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+> structure is used to describe the format of some audio data. This structure is used by <A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+> and <A
+HREF="sdlloadwav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+></A
+>. While all fields are used by <TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+> only <TT
+CLASS="STRUCTFIELD"
+><I
+>freq</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>samples</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>channels</I
+></TT
+> are used by <TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+>. We will detail these common members here.</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN5942"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>freq</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The number of samples sent to the sound device every second. Common values are 11025, 22050 and 44100. The higher the better.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>Specifies the size and type of each sample element
+<P
+></P
+><DIV
+CLASS="VARIABLELIST"
+><DL
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_U8</TT
+></DT
+><DD
+><P
+>Unsigned 8-bit samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_S8</TT
+></DT
+><DD
+><P
+>Signed 8-bit samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_U16</TT
+> or <TT
+CLASS="LITERAL"
+>AUDIO_U16LSB</TT
+></DT
+><DD
+><P
+>Unsigned 16-bit little-endian samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_S16</TT
+> or <TT
+CLASS="LITERAL"
+>AUDIO_S16LSB</TT
+></DT
+><DD
+><P
+>Signed 16-bit little-endian samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_U16MSB</TT
+></DT
+><DD
+><P
+>Unsigned 16-bit big-endian samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_S16MSB</TT
+></DT
+><DD
+><P
+>Signed 16-bit big-endian samples</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_U16SYS</TT
+></DT
+><DD
+><P
+>Either <TT
+CLASS="LITERAL"
+>AUDIO_U16LSB</TT
+> or <TT
+CLASS="LITERAL"
+>AUDIO_U16MSB</TT
+> depending on you systems endianness</P
+></DD
+><DT
+><TT
+CLASS="LITERAL"
+>AUDIO_S16SYS</TT
+></DT
+><DD
+><P
+>Either <TT
+CLASS="LITERAL"
+>AUDIO_S16LSB</TT
+> or <TT
+CLASS="LITERAL"
+>AUDIO_S16MSB</TT
+> depending on you systems endianness</P
+></DD
+></DL
+></DIV
+></P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>channels</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The number of seperate sound channels. 1 is mono (single channel), 2 is stereo (dual channel).</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>samples</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>When used with <A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+> this refers to the size of the audio buffer in samples. A sample a chunk of audio data of the size specified in <TT
+CLASS="PARAMETER"
+><I
+>format</I
+></TT
+> mulitplied by the number of channels. When the <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+> is used with <A
+HREF="sdlloadwav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+></A
+> <TT
+CLASS="STRUCTFIELD"
+><I
+>samples</I
+></TT
+> is set to 4096.</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6017"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+>,
+<A
+HREF="sdlloadwav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlopenaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Audio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_OpenAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlblitsurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,322 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_BlitSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ConvertSurface"
+HREF="sdlconvertsurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_FillRect"
+HREF="sdlfillrect.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlconvertsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlfillrect.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLBLITSURFACE"
+>SDL_BlitSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1806"
+></A
+><H2
+>Name</H2
+>SDL_BlitSurface&nbsp;--&nbsp;This performs a fast blit from the source surface to the destination surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1809"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1810"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_BlitSurface</B
+></CODE
+>(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1816"
+></A
+><H2
+>Description</H2
+><P
+>This performs a fast blit from the source surface to the destination surface.</P
+><P
+>Only the position is used in the <TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+> (the
+width and height are ignored).</P
+><P
+>If either <TT
+CLASS="PARAMETER"
+><I
+>srcrect</I
+></TT
+> or
+<TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+> are <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the entire
+surface (<TT
+CLASS="PARAMETER"
+><I
+>src</I
+></TT
+> or <TT
+CLASS="PARAMETER"
+><I
+>dst</I
+></TT
+>) is
+copied.</P
+><P
+>The final blit rectangle is saved in
+<TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+> after all clipping is performed
+(<TT
+CLASS="PARAMETER"
+><I
+>srcrect</I
+></TT
+> is not modified).</P
+><P
+>The blit function should not be called on a locked surface.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>The results of blitting operations vary greatly depending on whether <TT
+CLASS="LITERAL"
+>SDL_SRCAPLHA</TT
+> is set or not. See <A
+HREF="sdlsetalpha.html"
+>SDL_SetAlpha</A
+>.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1835"
+></A
+><H2
+>Return Value</H2
+><P
+>If the blit is successful, it returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>,
+otherwise it returns <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+>.</P
+><P
+>If either of the surfaces were in video memory, and the blit returns
+<SPAN
+CLASS="RETURNVALUE"
+>-2</SPAN
+>, the video memory was lost, so it should be
+reloaded with artwork and re-blitted:
+<PRE
+CLASS="PROGRAMLISTING"
+>        while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
+                while ( SDL_LockSurface(image)) &#60; 0 )
+                        Sleep(10);
+                -- Write image pixels to image-&#62;pixels --
+                SDL_UnlockSurface(image);
+        }</PRE
+>
+This happens under DirectX 5.0 when the system switches away from your
+fullscreen application.  Locking the surface will also fail until you
+have access to the video memory again.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1843"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+>,
+<A
+HREF="sdlfillrect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FillRect</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlconvertsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlfillrect.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ConvertSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_FillRect</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlbuildaudiocvt.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,283 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_BuildAudioCVT</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_AudioCVT"
+HREF="sdlaudiocvt.html"><LINK
+REL="NEXT"
+TITLE="SDL_ConvertAudio"
+HREF="sdlconvertaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlaudiocvt.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlconvertaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLBUILDAUDIOCVT"
+>SDL_BuildAudioCVT</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6380"
+></A
+><H2
+>Name</H2
+>SDL_BuildAudioCVT&nbsp;--&nbsp;Initializes a SDL_AudioCVT structure for conversion</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6383"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6384"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_BuildAudioCVT</B
+></CODE
+>(SDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6390"
+></A
+><H2
+>Description</H2
+><P
+>Before an <A
+HREF="sdlaudiocvt.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+></A
+> structure can be used to convert audio data it must be initialized with source and destination information. </P
+><P
+><TT
+CLASS="PARAMETER"
+><I
+>src_format</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>dst_format</I
+></TT
+> are the source and destination format of the conversion. (For information on audio formats see <A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+> SDL_AudioSpec</SPAN
+></A
+>). <TT
+CLASS="PARAMETER"
+><I
+>src_channels</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>dst_channels</I
+></TT
+> are the number of channels in the source and destination formats. Finally, <TT
+CLASS="PARAMETER"
+><I
+>src_rate</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>dst_rate</I
+></TT
+> are the frequency or samples-per-second of the source and destination formats. Once again, see <A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6406"
+></A
+><H2
+>Return Values</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if the filter could not be built or 1 if it could.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6410"
+></A
+><H2
+>Examples</H2
+><P
+>See <A
+HREF="sdlconvertaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6415"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlconvertaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+></A
+>,
+<A
+HREF="sdlaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AudioCVT</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlaudiocvt.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlconvertaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_AudioCVT</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ConvertAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcd.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,351 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CD</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDClose"
+HREF="sdlcdclose.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDtrack"
+HREF="sdlcdtrack.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdclose.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdtrack.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCD"
+>SDL_CD</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6941"
+></A
+><H2
+>Name</H2
+>SDL_CD&nbsp;--&nbsp;CDROM Drive Information</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6944"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  int id;
+  CDstatus status;
+  int numtracks;
+  int cur_track;
+  int cur_frame;
+  SDL_CDtrack track[SDL_MAX_TRACKS+1];
+} SDL_CD;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6947"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN6949"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>id</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Private drive identifier</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>status</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Drive <A
+HREF="sdlcdstatus.html"
+>status</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>numtracks</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Number of tracks on the CD</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>cur_track</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Current track</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>cur_frame</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Current frame offset within the track</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>track</I
+></TT
+>[SDL_MAX_TRACKS+1]</TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Array of track descriptions. (see <A
+HREF="sdlcdtrack.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CDtrack</SPAN
+></A
+>)</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6979"
+></A
+><H2
+>Description</H2
+><P
+>An <SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+> structure is returned by <A
+HREF="sdlcdopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDOpen</TT
+></A
+>. It represents an opened CDROM device and stores information on the layout of the tracks on the disc.</P
+><P
+>A frame is the base data unit of a CD. <TT
+CLASS="LITERAL"
+>CD_FPS</TT
+> frames is equal to 1 second of music. SDL provides two macros for converting between time and frames: <TT
+CLASS="LITERAL"
+>FRAMES_TO_MSF(f, M,S,F)</TT
+> and <TT
+CLASS="LITERAL"
+>MSF_TO_FRAMES</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6989"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>int min, sec, frame;
+int frame_offset;
+
+FRAMES_TO_MSF(cdrom-&#62;cur_frame, &#38;min, &#38;sec, &#38;frame);
+printf("Current Position: %d minutes, %d seconds, %d frames\n", min, sec, frame);
+
+frame_offset=MSF_TO_FRAMES(min, sec, frame);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6992"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDOpen</TT
+></A
+>,
+<A
+HREF="sdlcdtrack.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CDtrack</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdclose.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdtrack.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDClose</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDtrack</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdclose.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,209 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDClose</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDEject"
+HREF="sdlcdeject.html"><LINK
+REL="NEXT"
+TITLE="SDL_CD"
+HREF="sdlcd.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdeject.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcd.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDCLOSE"
+>SDL_CDClose</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6916"
+></A
+><H2
+>Name</H2
+>SDL_CDClose&nbsp;--&nbsp;Closes a SDL_CD handle</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6919"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6920"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_CDClose</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6926"
+></A
+><H2
+>Description</H2
+><P
+>Closes the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+> handle.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6930"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDOpen</TT
+></A
+>,
+<A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdeject.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcd.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDEject</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CD</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdeject.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,218 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDEject</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDStop"
+HREF="sdlcdstop.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDClose"
+HREF="sdlcdclose.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdstop.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdclose.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDEJECT"
+>SDL_CDEject</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6888"
+></A
+><H2
+>Name</H2
+>SDL_CDEject&nbsp;--&nbsp;Ejects a CDROM</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6891"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6892"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDEject</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6898"
+></A
+><H2
+>Description</H2
+><P
+>Ejects the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6902"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6907"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdstop.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdclose.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDStop</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDClose</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdname.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,231 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDName</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDNumDrives"
+HREF="sdlcdnumdrives.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDOpen"
+HREF="sdlcdopen.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdnumdrives.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdopen.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDNAME"
+>SDL_CDName</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6615"
+></A
+><H2
+>Name</H2
+>SDL_CDName&nbsp;--&nbsp;Returns a human-readable, system-dependent identifier for the CD-ROM.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6618"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6619"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>const char *<B
+CLASS="FSFUNC"
+>SDL_CDName</B
+></CODE
+>(int drive);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6625"
+></A
+><H2
+>Description</H2
+><P
+>Returns a human-readable, system-dependent identifier for the CD-ROM. <TT
+CLASS="PARAMETER"
+><I
+>drive</I
+></TT
+> is the index of the drive. Drive indices start to 0 and end at <TT
+CLASS="FUNCTION"
+>SDL_CDNumDrives()</TT
+>-1.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6630"
+></A
+><H2
+>Examples</H2
+><P
+><P
+></P
+><UL
+><LI
+><P
+>"/dev/cdrom"</P
+></LI
+><LI
+><P
+>"E:"</P
+></LI
+><LI
+><P
+>"/dev/disk/ide/1/master"</P
+></LI
+></UL
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6640"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdnumdrives.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDNumDrives</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdnumdrives.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdopen.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDNumDrives</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDOpen</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdnumdrives.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,197 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDNumDrives</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDName"
+HREF="sdlcdname.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="cdrom.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdname.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDNUMDRIVES"
+>SDL_CDNumDrives</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6593"
+></A
+><H2
+>Name</H2
+>SDL_CDNumDrives&nbsp;--&nbsp;Returns the number of CD-ROM drives on the system.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6596"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6597"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDNumDrives</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6603"
+></A
+><H2
+>Description</H2
+><P
+>Returns the number of CD-ROM drives on the system.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6606"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdname.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>CD-ROM</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDName</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdopen.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,267 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDOpen</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDName"
+HREF="sdlcdname.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDStatus"
+HREF="sdlcdstatus.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdstatus.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDOPEN"
+>SDL_CDOpen</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6649"
+></A
+><H2
+>Name</H2
+>SDL_CDOpen&nbsp;--&nbsp;Opens a CD-ROM drive for access.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6652"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6653"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_CD *<B
+CLASS="FSFUNC"
+>SDL_CDOpen</B
+></CODE
+>(int drive);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6659"
+></A
+><H2
+>Description</H2
+><P
+>Opens a CD-ROM drive for access.  It returns a <A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+> structure on success, or <TT
+CLASS="LITERAL"
+>NULL</TT
+> if the drive was invalid or busy.  This newly opened CD-ROM becomes the default CD used when other CD functions are passed a <TT
+CLASS="LITERAL"
+>NULL</TT
+> CD-ROM handle. </P
+><P
+>Drives are numbered starting with 0.  
+Drive 0 is the system default CD-ROM.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6667"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_CD *cdrom;
+int cur_track;
+int min, sec, frame;
+SDL_Init(SDL_INIT_CDROM);
+atexit(SDL_Quit);
+
+/* Check for CD drives */
+if(!SDL_CDNumDrives()){
+  /* None found */
+  fprintf(stderr, "No CDROM devices available\n");
+  exit(-1);
+}
+
+/* Open the default drive */
+cdrom=SDL_CDOpen(0);
+
+/* Did if open? Check if cdrom is NULL */
+if(!cdrom){
+  fprintf(stderr, "Couldn't open drive: %s\n", SDL_GetError());
+  exit(-1);
+}
+
+/* Print Volume info */
+printf("Name: %s\n", SDL_CDName(0));
+printf("Tracks: %d\n", cdrom-&#62;numtracks);
+for(cur_track=0;cur_track &#60; cdrom-&#62;numtracks; cur_track++){
+  FRAMES_TO_MSF(cdrom-&#62;track[cur_track].length, &#38;min, &#38;sec, &#38;frame);
+  printf("\tTrack %d: Length %d:%d\n", cur_track, min, sec);
+}
+
+SDL_CDClose(cdrom);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6670"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+>,
+<A
+HREF="sdlcdtrack.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CDtrack</SPAN
+></A
+>,
+<A
+HREF="sdlcdclose.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDClose</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdstatus.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDName</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDStatus</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdpause.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,225 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDPause</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDPlayTracks"
+HREF="sdlcdplaytracks.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDResume"
+HREF="sdlcdresume.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdplaytracks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdresume.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDPAUSE"
+>SDL_CDPause</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6800"
+></A
+><H2
+>Name</H2
+>SDL_CDPause&nbsp;--&nbsp;Pauses a CDROM</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6803"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6804"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDPause</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6810"
+></A
+><H2
+>Description</H2
+><P
+>Pauses play on the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6814"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6819"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdplay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlay</TT
+></A
+>,
+<A
+HREF="sdlcdresume.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDResume</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdplaytracks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdresume.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDPlayTracks</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDResume</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdplay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,235 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDPlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDStatus"
+HREF="sdlcdstatus.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDPlayTracks"
+HREF="sdlcdplaytracks.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdstatus.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdplaytracks.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDPLAY"
+>SDL_CDPlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6718"
+></A
+><H2
+>Name</H2
+>SDL_CDPlay&nbsp;--&nbsp;Play a CD</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6721"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6722"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDPlay</B
+></CODE
+>(SDL_CD *cdrom, int start, int length);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6728"
+></A
+><H2
+>Description</H2
+><P
+>Plays the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+>, starting a frame <TT
+CLASS="PARAMETER"
+><I
+>start</I
+></TT
+> for <TT
+CLASS="PARAMETER"
+><I
+>length</I
+></TT
+> frames.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6734"
+></A
+><H2
+>Return Values</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6739"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdplaytracks.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlayTracks</TT
+></A
+>,
+<A
+HREF="sdlcdstop.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDStop</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdstatus.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdplaytracks.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDStatus</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDPlayTracks</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdplaytracks.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,317 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDPlayTracks</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDPlay"
+HREF="sdlcdplay.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDPause"
+HREF="sdlcdpause.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdplay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdpause.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDPLAYTRACKS"
+>SDL_CDPlayTracks</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6750"
+></A
+><H2
+>Name</H2
+>SDL_CDPlayTracks&nbsp;--&nbsp;Play the given CD track(s)</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6753"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6754"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDPlayTracks</B
+></CODE
+>(SDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes));</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6760"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlayTracks</TT
+> plays the given CD starting at track
+<TT
+CLASS="PARAMETER"
+><I
+>start_track</I
+></TT
+>, for <TT
+CLASS="PARAMETER"
+><I
+>ntracks</I
+></TT
+> tracks.  </P
+><P
+><TT
+CLASS="PARAMETER"
+><I
+>start_frame</I
+></TT
+> is the frame offset, from the beginning of the <TT
+CLASS="PARAMETER"
+><I
+>start_track</I
+></TT
+>, at which to start. <TT
+CLASS="PARAMETER"
+><I
+>nframes</I
+></TT
+> is the frame offset, from the beginning of the last track (<TT
+CLASS="PARAMETER"
+><I
+>start_track</I
+></TT
+>+<TT
+CLASS="PARAMETER"
+><I
+>ntracks</I
+></TT
+>), at which to end playing.</P
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlayTracks</TT
+> should only be called after calling 
+<A
+HREF="sdlcdstatus.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDStatus</TT
+></A
+> 
+to get track information about the CD.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Data tracks are ignored.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6778"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> 
+if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6783"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>/* assuming cdrom is a previously opened device */
+/* Play the entire CD */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
+
+/* Play the first track */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 0, 0, 1, 0);
+
+/* Play first 15 seconds of the 2nd track */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 1, 0, 0, CD_FPS*15);</PRE
+>
+&#13;</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6787"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdplay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlay</TT
+></A
+>,
+<A
+HREF="sdlcdstatus.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDStatus</TT
+></A
+>,
+<A
+HREF="sdlcd.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CD</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdplay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdpause.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDPlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDPause</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdresume.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,225 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDResume</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDPause"
+HREF="sdlcdpause.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDStop"
+HREF="sdlcdstop.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdpause.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdstop.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDRESUME"
+>SDL_CDResume</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6830"
+></A
+><H2
+>Name</H2
+>SDL_CDResume&nbsp;--&nbsp;Resumes a CDROM</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6833"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6834"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDResume</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6840"
+></A
+><H2
+>Description</H2
+><P
+>Resumes play on the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6844"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6849"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdplay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlay</TT
+></A
+>,
+<A
+HREF="sdlcdpause.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPause</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdpause.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdstop.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDPause</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDStop</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdstatus.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,265 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDStatus</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDOpen"
+HREF="sdlcdopen.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDPlay"
+HREF="sdlcdplay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdopen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdplay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDSTATUS"
+>SDL_CDStatus</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6683"
+></A
+><H2
+>Name</H2
+>SDL_CDStatus&nbsp;--&nbsp;Returns the current status of the given drive.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6686"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6687"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>CDstatus <B
+CLASS="FSFUNC"
+>SDL_CDStatus</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>/* Given a status, returns true if there's a disk in the drive */
+#define CD_INDRIVE(status)      ((int)status &#62; 0)</PRE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6694"
+></A
+><H2
+>Description</H2
+><P
+>This function returns the current status of the given drive. Status is described like so:
+<PRE
+CLASS="PROGRAMLISTING"
+>typedef enum {
+  CD_TRAYEMPTY,
+  CD_STOPPED,
+  CD_PLAYING,
+  CD_PAUSED,
+  CD_ERROR = -1
+} CDstatus;</PRE
+></P
+><P
+>If the drive has a CD in it, the table of contents of the CD and current
+play position of the CD will be stored in the SDL_CD structure.</P
+><P
+>The macro <TT
+CLASS="LITERAL"
+>CD_INDRIVE</TT
+> is provided for convenience, 
+and given a status returns true if there's a disk in the drive.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+><TT
+CLASS="FUNCTION"
+>SDL_CDStatus</TT
+> also updates the <A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+> structure passed to it.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6706"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>int playTrack(int track)
+{
+  int playing = 0;
+
+  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+  /* clamp to the actual number of tracks on the CD */
+    if (track &#62;= cdrom-&#62;numtracks) {
+      track = cdrom-&#62;numtracks-1;
+    }
+
+    if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) {
+      playing = 1;
+    }
+  }
+  return playing;
+}</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6709"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcd.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CD</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdopen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdplay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDOpen</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDPlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdstop.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,218 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDStop</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDResume"
+HREF="sdlcdresume.html"><LINK
+REL="NEXT"
+TITLE="SDL_CDEject"
+HREF="sdlcdeject.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdresume.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcdeject.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDSTOP"
+>SDL_CDStop</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6860"
+></A
+><H2
+>Name</H2
+>SDL_CDStop&nbsp;--&nbsp;Stops a CDROM</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6863"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6864"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CDStop</B
+></CODE
+>(SDL_CD *cdrom);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6870"
+></A
+><H2
+>Description</H2
+><P
+>Stops play on the given <TT
+CLASS="PARAMETER"
+><I
+>cdrom</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6874"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6879"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcdplay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CDPlay</TT
+></A
+>,</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdresume.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcdeject.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDResume</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CDEject</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcdtrack.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,305 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CDtrack</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="CD-ROM"
+HREF="cdrom.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CD"
+HREF="sdlcd.html"><LINK
+REL="NEXT"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcd.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="thread.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCDTRACK"
+>SDL_CDtrack</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7003"
+></A
+><H2
+>Name</H2
+>SDL_CDtrack&nbsp;--&nbsp;CD Track Information Structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7006"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 id;
+  Uint8 type;
+  Uint32 length;
+  Uint32 offset;
+} SDL_CDtrack;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7009"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN7011"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>id</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Track number (0-99)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_AUDIO_TRACK</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_DATA_TRACK</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>length</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Length, in frames, of this track</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>offset</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Frame offset to the beginning of this track</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7032"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CDtrack</SPAN
+> stores data on each track on a CD, its fields should be pretty self explainatory. It is a member a the <A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+> structure.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Frames can be converted to standard timings. There are <TT
+CLASS="LITERAL"
+>CD_FPS</TT
+> frames per second, so <SPAN
+CLASS="STRUCTNAME"
+>SDL_CDtrack</SPAN
+>.<TT
+CLASS="STRUCTFIELD"
+><I
+>length</I
+></TT
+>/<TT
+CLASS="LITERAL"
+>CD_FPS</TT
+>=length_in_seconds.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7044"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcd.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_CD</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcd.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CD</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Multi-threaded Programming</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcloseaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,197 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CloseAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UnlockAudio"
+HREF="sdlunlockaudio.html"><LINK
+REL="NEXT"
+TITLE="CD-ROM"
+HREF="cdrom.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlunlockaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="cdrom.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCLOSEAUDIO"
+>SDL_CloseAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6555"
+></A
+><H2
+>Name</H2
+>SDL_CloseAudio&nbsp;--&nbsp;Shuts down audio processing and closes the audio device.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6558"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6559"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_CloseAudio</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6565"
+></A
+><H2
+>Description</H2
+><P
+>This function shuts down audio processing and closes the audio device.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6568"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+> </P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlunlockaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="cdrom.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UnlockAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>CD-ROM</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcolor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,292 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Color</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Rect"
+HREF="sdlrect.html"><LINK
+REL="NEXT"
+TITLE="SDL_Palette"
+HREF="sdlpalette.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlrect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpalette.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCOLOR"
+>SDL_Color</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2581"
+></A
+><H2
+>Name</H2
+>SDL_Color&nbsp;--&nbsp;Format independent color description</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2584"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 r;
+  Uint8 g;
+  Uint8 b;
+  Uint8 unused;
+} SDL_Color;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2587"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2589"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>r</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Red intensity</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>g</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Green intensity</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>b</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Blue intensity</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>unused</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Unused</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2608"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+> describes a color in a format independent way. You can convert a <SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+> to a pixel value for a certain pixel format using <A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2615"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>,
+<A
+HREF="sdlsetcolors.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+></A
+>,
+<A
+HREF="sdlpalette.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Palette</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlrect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpalette.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Rect</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Palette</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcondbroadcast.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,216 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CondBroadcast</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CondSignal"
+HREF="sdlcondsignal.html"><LINK
+REL="NEXT"
+TITLE="SDL_CondWait"
+HREF="sdlcondwait.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcondsignal.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcondwait.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONDBROADCAST"
+>SDL_CondBroadcast</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7712"
+></A
+><H2
+>Name</H2
+>SDL_CondBroadcast&nbsp;--&nbsp;Restart all threads waiting on a condition variable</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7715"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7716"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CondBroadcast</B
+></CODE
+>(SDL_cond *cond);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7722"
+></A
+><H2
+>Description</H2
+><P
+>Restarts all threads that are waiting on the condition variable, <TT
+CLASS="PARAMETER"
+><I
+>cond</I
+></TT
+>. Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7728"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcondsignal.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondSignal</TT
+></A
+>,
+<A
+HREF="sdlcondwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondWait</TT
+></A
+>&#13;</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcondsignal.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcondwait.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CondSignal</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CondWait</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcondsignal.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,216 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CondSignal</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DestroyCond"
+HREF="sdldestroycond.html"><LINK
+REL="NEXT"
+TITLE="SDL_CondBroadcast"
+HREF="sdlcondbroadcast.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldestroycond.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcondbroadcast.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONDSIGNAL"
+>SDL_CondSignal</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7685"
+></A
+><H2
+>Name</H2
+>SDL_CondSignal&nbsp;--&nbsp;Restart a thread wait on a condition variable</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7688"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7689"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CondSignal</B
+></CODE
+>(SDL_cond *cond);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7695"
+></A
+><H2
+>Description</H2
+><P
+>Restart one of the threads that are waiting on the condition variable, <TT
+CLASS="PARAMETER"
+><I
+>cond</I
+></TT
+>. Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success of <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7701"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcondwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondWait</TT
+></A
+>,
+<A
+HREF="sdlcondbroadcast.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondBroadcast</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldestroycond.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcondbroadcast.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DestroyCond</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CondBroadcast</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcondwait.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CondWait</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CondBroadcast"
+HREF="sdlcondbroadcast.html"><LINK
+REL="NEXT"
+TITLE="SDL_CondWaitTimeout"
+HREF="sdlcondwaittimeout.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcondbroadcast.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcondwaittimeout.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONDWAIT"
+>SDL_CondWait</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7739"
+></A
+><H2
+>Name</H2
+>SDL_CondWait&nbsp;--&nbsp;Wait on a condition variable</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7742"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7743"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CondWait</B
+></CODE
+>(SDL_cond *cond, SDL_mutex *mut);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7749"
+></A
+><H2
+>Description</H2
+><P
+>Wait on the condition variable <TT
+CLASS="PARAMETER"
+><I
+>cond</I
+></TT
+> and unlock the provided mutex. The mutex must the locked before entering this function. Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> when it is signalled, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7755"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcondwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlcondsignal.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondSignal</TT
+></A
+>,
+<A
+HREF="sdlmutexp.html"
+><TT
+CLASS="FUNCTION"
+>SDL_mutexP</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcondbroadcast.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcondwaittimeout.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CondBroadcast</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CondWaitTimeout</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcondwaittimeout.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,222 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CondWaitTimeout</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CondWait"
+HREF="sdlcondwait.html"><LINK
+REL="NEXT"
+TITLE="Time"
+HREF="time.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcondwait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="time.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONDWAITTIMEOUT"
+>SDL_CondWaitTimeout</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7768"
+></A
+><H2
+>Name</H2
+>SDL_CondWaitTimeout&nbsp;--&nbsp;Wait on a condition variable, with timeout</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7771"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7772"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_CondWaitTimeout</B
+></CODE
+>(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7778"
+></A
+><H2
+>Description</H2
+><P
+>Wait on the condition variable <TT
+CLASS="PARAMETER"
+><I
+>cond</I
+></TT
+> for, at most, <TT
+CLASS="PARAMETER"
+><I
+>ms</I
+></TT
+> milliseconds. <TT
+CLASS="PARAMETER"
+><I
+>mut</I
+></TT
+> is unlocked so it must be locked when the function is called. Returns <TT
+CLASS="LITERAL"
+>SDL_MUTEX_TIMEDOUT</TT
+> if the condition is not signalled in the allotted time, <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if it was signalled or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7787"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcondwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondWait</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcondwait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="time.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CondWait</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Time</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlconvertaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,399 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ConvertAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_BuildAudioCVT"
+HREF="sdlbuildaudiocvt.html"><LINK
+REL="NEXT"
+TITLE="SDL_MixAudio"
+HREF="sdlmixaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlbuildaudiocvt.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmixaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONVERTAUDIO"
+>SDL_ConvertAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6426"
+></A
+><H2
+>Name</H2
+>SDL_ConvertAudio&nbsp;--&nbsp;Convert audio data to a desired audio format.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6429"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6430"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_ConvertAudio</B
+></CODE
+>(SDL_AudioCVT *cvt);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6436"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+> takes one parameter, <TT
+CLASS="PARAMETER"
+><I
+>cvt</I
+></TT
+>, which was previously initilized. Initilizing a <A
+HREF="sdlaudiocvt.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+></A
+> is a two step process. First of all, the structure must be passed to <A
+HREF="sdlbuildaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BuildAudioCVT</TT
+></A
+> along with source and destination format parameters. Secondly, the <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> and <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+> fields must be setup. <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> should point to the audio data and <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+> should be set to the length of the audio data in bytes. Remember, the length of the buffer pointed to by <TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+> show be <TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>len_mult</I
+></TT
+> bytes in length.</P
+><P
+>Once the <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+>structure is initilized then we can pass it to <TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+>, which will convert the audio data pointer to by <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+>. If <TT
+CLASS="FUNCTION"
+>SDL_ConvertAudio</TT
+> returned <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> then the conversion was completed successfully, otherwise <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> is returned.</P
+><P
+>If the conversion completed successfully then the converted audio data can be read from <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>buf</I
+></TT
+>. The amount of valid, converted, audio data in the buffer is equal to <SPAN
+CLASS="STRUCTNAME"
+>cvt</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>len</I
+></TT
+>*<TT
+CLASS="STRUCTFIELD"
+><I
+>cvt</I
+></TT
+>-&#62;<SPAN
+CLASS="STRUCTNAME"
+>len_ratio</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6471"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Converting some WAV data to hardware format */
+void my_audio_callback(void *userdata, Uint8 *stream, int len);
+
+SDL_AudioSpec *desired, *obtained;
+SDL_AudioSpec wav_spec;
+SDL_AudioCVT  wav_cvt;
+Uint32 wav_len;
+Uint8 *wav_buf;
+int ret;
+
+/* Allocated audio specs */
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+obtained=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* Set desired format */
+desired-&#62;freq=22050;
+desired-&#62;format=AUDIO_S16LSB;
+desired-&#62;samples=8192;
+desired-&#62;callback=my_audio_callback;
+desired-&#62;userdata=NULL;
+
+/* Open the audio device */
+if ( SDL_OpenAudio(desired, obtained) &#60; 0 ){
+  fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+  exit(-1);
+}
+        
+free(desired);
+
+/* Load the test.wav */
+if( SDL_LoadWAV("test.wav", &#38;wav_spec, &#38;wav_buf, &#38;wav_len) == NULL ){
+  fprintf(stderr, "Could not open test.wav: %s\n", SDL_GetError());
+  SDL_CloseAudio();
+  free(obtained);
+  exit(-1);
+}
+                                            
+/* Build AudioCVT */
+ret = SDL_BuildAudioCVT(&#38;wav_cvt,
+                        wav_spec.format, wav_spec.channels, wav_spec.freq,
+                        obtained-&#62;format, obtained-&#62;channels, obtained-&#62;freq);
+
+/* Check that the convert was built */
+if(ret==-1){
+  fprintf(stderr, "Couldn't build converter!\n");
+  SDL_CloseAudio();
+  free(obtained);
+  SDL_FreeWAV(wav_buf);
+}
+
+/* Setup for conversion */
+wav_cvt.buf=(Uint8 *)malloc(wav_len*wav_cvt.len_mult);
+wav_cvt.len=wav_len;
+memcpy(wav_cvt.buf, wav_buf, wav_len);
+
+/* We can delete to original WAV data now */
+SDL_FreeWAV(wav_buf);
+
+/* And now we're ready to convert */
+SDL_ConvertAudio(&#38;wav_cvt);
+
+/* do whatever */
+.
+.
+.
+.
+&#13;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6474"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlbuildaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BuildAudioCVT</TT
+></A
+>,
+<A
+HREF="sdlaudiocvt.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AudioCVT</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlbuildaudiocvt.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmixaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_BuildAudioCVT</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_MixAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlconvertsurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,261 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ConvertSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetClipRect"
+HREF="sdlgetcliprect.html"><LINK
+REL="NEXT"
+TITLE="SDL_BlitSurface"
+HREF="sdlblitsurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetcliprect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlblitsurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCONVERTSURFACE"
+>SDL_ConvertSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1766"
+></A
+><H2
+>Name</H2
+>SDL_ConvertSurface&nbsp;--&nbsp;Converts a surface to the same format as another surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1769"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1770"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_ConvertSurface</B
+></CODE
+>(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1776"
+></A
+><H2
+>Description</H2
+><P
+>Creates a new surface of the specified format, and then copies and maps
+the given surface to it.  If this function fails, it returns
+<TT
+CLASS="LITERAL"
+>NULL</TT
+>.</P
+><P
+>The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> parameter is passed to 
+<A
+HREF="sdlcreatergbsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurface</TT
+></A
+>
+and has those semantics.</P
+><P
+>This function is used internally by 
+<A
+HREF="sdldisplayformat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayFormat</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1787"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns either a pointer to the new surface, or
+<TT
+CLASS="LITERAL"
+>NULL</TT
+> on error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1791"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatergbsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurface</TT
+></A
+>,
+<A
+HREF="sdldisplayformat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayFormat</TT
+></A
+>,
+<A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetcliprect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlblitsurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetClipRect</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_BlitSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatecond.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,232 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateCond</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SemValue"
+HREF="sdlsemvalue.html"><LINK
+REL="NEXT"
+TITLE="SDL_DestroyCond"
+HREF="sdldestroycond.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsemvalue.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldestroycond.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATECOND"
+>SDL_CreateCond</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7634"
+></A
+><H2
+>Name</H2
+>SDL_CreateCond&nbsp;--&nbsp;Create a condition variable</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7637"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7638"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_cond *<B
+CLASS="FSFUNC"
+>SDL_CreateCond</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7644"
+></A
+><H2
+>Description</H2
+><P
+>Creates a condition variable.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7647"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_cond *cond;
+
+cond=SDL_CreateCond();
+.
+.
+/* Do stuff */
+
+.
+.
+SDL_DestroyCond(cond);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7650"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdldestroycond.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroyCond</TT
+></A
+>,
+<A
+HREF="sdlcondwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondWait</TT
+></A
+>,
+<A
+HREF="sdlcondsignal.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CondSignal</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsemvalue.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldestroycond.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SemValue</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DestroyCond</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatecursor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,390 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateCursor</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WarpMouse"
+HREF="sdlwarpmouse.html"><LINK
+REL="NEXT"
+TITLE="SDL_FreeCursor"
+HREF="sdlfreecursor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwarpmouse.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlfreecursor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATECURSOR"
+>SDL_CreateCursor</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1989"
+></A
+><H2
+>Name</H2
+>SDL_CreateCursor&nbsp;--&nbsp;Creates a new mouse cursor.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1992"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1993"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Cursor *<B
+CLASS="FSFUNC"
+>SDL_CreateCursor</B
+></CODE
+>(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1999"
+></A
+><H2
+>Description</H2
+><P
+>Create a cursor using the specified <TT
+CLASS="PARAMETER"
+><I
+>data</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>mask</I
+></TT
+> (in MSB format).
+The cursor width must be a multiple of 8 bits.</P
+><P
+>The cursor is created in black and white according to the following:
+<DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2005"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><THEAD
+><TR
+><TH
+ALIGN="LEFT"
+VALIGN="TOP"
+>Data / Mask</TH
+><TH
+ALIGN="LEFT"
+VALIGN="TOP"
+>Resulting pixel on screen</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>0 / 1</TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>White</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>1 / 1</TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Black</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>0 / 0</TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Transparent</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>1 / 0</TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Inverted color if possible, black if not.</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></P
+><P
+>Cursors created with this function must be freed with
+<A
+HREF="sdlfreecursor.html"
+>SDL_FreeCursor</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2026"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Stolen from the mailing list */
+/* Creates a new mouse cursor from an XPM */
+
+
+/* XPM */
+static const char *arrow[] = {
+  /* width height num_colors chars_per_pixel */
+  "    32    32        3            1",
+  /* colors */
+  "X c #000000",
+  ". c #ffffff",
+  "  c None",
+  /* pixels */
+  "X                               ",
+  "XX                              ",
+  "X.X                             ",
+  "X..X                            ",
+  "X...X                           ",
+  "X....X                          ",
+  "X.....X                         ",
+  "X......X                        ",
+  "X.......X                       ",
+  "X........X                      ",
+  "X.....XXXXX                     ",
+  "X..X..X                         ",
+  "X.X X..X                        ",
+  "XX  X..X                        ",
+  "X    X..X                       ",
+  "     X..X                       ",
+  "      X..X                      ",
+  "      X..X                      ",
+  "       XX                       ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "0,0"
+};
+
+static SDL_Cursor *init_system_cursor(const char *image[])
+{
+  int i, row, col;
+  Uint8 data[4*32];
+  Uint8 mask[4*32];
+  int hot_x, hot_y;
+
+  i = -1;
+  for ( row=0; row&#60;32; ++row ) {
+    for ( col=0; col&#60;32; ++col ) {
+      if ( col % 8 ) {
+        data[i] &#60;&#60;= 1;
+        mask[i] &#60;&#60;= 1;
+      } else {
+        ++i;
+        data[i] = mask[i] = 0;
+      }
+      switch (image[4+row][col]) {
+        case 'X':
+          data[i] |= 0x01;
+          k[i] |= 0x01;
+          break;
+        case '.':
+          mask[i] |= 0x01;
+          break;
+        case ' ':
+          break;
+      }
+    }
+  }
+  sscanf(image[4+row], "%d,%d", &#38;hot_x, &#38;hot_y);
+  return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
+}</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2029"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlfreecursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeCursor</TT
+></A
+>,
+<A
+HREF="sdlsetcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetCursor</TT
+></A
+>,
+<A
+HREF="sdlshowcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ShowCursor</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwarpmouse.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlfreecursor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WarpMouse</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_FreeCursor</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatemutex.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,241 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateMutex</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_KillThread"
+HREF="sdlkillthread.html"><LINK
+REL="NEXT"
+TITLE="SDL_DestroyMutex"
+HREF="sdldestroymutex.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlkillthread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldestroymutex.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATEMUTEX"
+>SDL_CreateMutex</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7195"
+></A
+><H2
+>Name</H2
+>SDL_CreateMutex&nbsp;--&nbsp;Create a mutex</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7198"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7199"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_mutex *<B
+CLASS="FSFUNC"
+>SDL_CreateMutex</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7205"
+></A
+><H2
+>Description</H2
+><P
+>Create a new, unlocked mutex.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7208"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_mutex *mut;
+
+mut=SDL_CreateMutex();
+.
+.
+if(SDL_mutexP(mut)==-1){
+  fprintf(stderr, "Couldn't lock mutex\n");
+  exit(-1);
+}
+.
+/* Do stuff while mutex is locked */
+.
+.
+if(SDL_mutexV(mut)==-1){
+  fprintf(stderr, "Couldn't unlock mutex\n");
+  exit(-1);
+}
+
+SDL_DestroyMutex(mut);&#13;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7211"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlmutexp.html"
+><TT
+CLASS="FUNCTION"
+>SDL_mutexP</TT
+></A
+>,
+<A
+HREF="sdlmutexv.html"
+><TT
+CLASS="FUNCTION"
+>SDL_mutexV</TT
+></A
+>,
+<A
+HREF="sdldestroymutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroyMutex</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlkillthread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldestroymutex.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_KillThread</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DestroyMutex</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatergbsurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,332 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateRGBSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetRGBA"
+HREF="sdlgetrgba.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateRGBSurfaceFrom"
+HREF="sdlcreatergbsurfacefrom.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetrgba.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATERGBSURFACE"
+>SDL_CreateRGBSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1316"
+></A
+><H2
+>Name</H2
+>SDL_CreateRGBSurface&nbsp;--&nbsp;Create an empty SDL_Surface</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1319"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1320"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_CreateRGBSurface</B
+></CODE
+>(Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1326"
+></A
+><H2
+>Description</H2
+><P
+>Allocate an empty surface (must be called after <A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+>)</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>depth</I
+></TT
+> is 8 bits an empty palette is allocated for the surface, otherwise a 'packed-pixel' <A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+> is created using the <TT
+CLASS="PARAMETER"
+><I
+>[RGBA]mask</I
+></TT
+>'s provided (see <A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>). The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> specifies the type of surface that should be created, it is an OR'd combination of the following possible values.</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN1338"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDL will create the surface in system memory. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDL will attempt to create the surface in video memory. This will allow SDL to take advantage of Video-&#62;Video blits (which are often accelerated).</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware colorkey blitting support.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware alpha support</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1357"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurfaceFrom</TT
+></A
+>,
+<A
+HREF="sdlfreesurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeSurface</TT
+></A
+>,
+<A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+>,
+<A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetrgba.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetRGBA</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateRGBSurfaceFrom</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatergbsurfacefrom.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,235 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateRGBSurfaceFrom</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateRGBSurface"
+HREF="sdlcreatergbsurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_FreeSurface"
+HREF="sdlfreesurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatergbsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlfreesurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATERGBSURFACEFROM"
+>SDL_CreateRGBSurfaceFrom</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1376"
+></A
+><H2
+>Name</H2
+>SDL_CreateRGBSurfaceFrom&nbsp;--&nbsp;Create an SDL_Surface from pixel data</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1379"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1380"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_CreateRGBSurfaceFrom</B
+></CODE
+>(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1386"
+></A
+><H2
+>Description</H2
+><P
+>Creates an SDL_Surface from the provided pixel data.</P
+><P
+>The data stored in <TT
+CLASS="PARAMETER"
+><I
+>pixels</I
+></TT
+> is assumed to be of the <TT
+CLASS="PARAMETER"
+><I
+>depth</I
+></TT
+> specified in the parameter list. The pixel data is not copied into the <SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+> structure so it should no be freed until the surface has been freed with a called to <A
+HREF="sdlfreesurface.html"
+>SDL_FreeSurface</A
+>. <TT
+CLASS="PARAMETER"
+><I
+>pitch</I
+></TT
+> is the length of each scanline in bytes.  </P
+><P
+>See <A
+HREF="sdlcreatergbsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurface</TT
+></A
+> for a more detailed description of the other parameters.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1398"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatergbsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurface</TT
+></A
+>,
+<A
+HREF="sdlfreesurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatergbsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlfreesurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateRGBSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_FreeSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatesemaphore.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,295 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateSemaphore</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_mutexV"
+HREF="sdlmutexv.html"><LINK
+REL="NEXT"
+TITLE="SDL_DestroySemaphore"
+HREF="sdldestroysemaphore.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmutexv.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldestroysemaphore.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATESEMAPHORE"
+>SDL_CreateSemaphore</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7311"
+></A
+><H2
+>Name</H2
+>SDL_CreateSemaphore&nbsp;--&nbsp;Creates a new semaphore and assigns an initial value to it.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7314"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7315"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_sem *<B
+CLASS="FSFUNC"
+>SDL_CreateSemaphore</B
+></CODE
+>(Uint32 initial_value);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7321"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore()</TT
+> creates a new semaphore and
+initializes it with the value <TT
+CLASS="PARAMETER"
+><I
+>initial_value</I
+></TT
+>.
+Each locking operation on the semaphore by
+<A
+HREF="sdlsemwait.html"
+>SDL_SemWait</A
+>,
+<A
+HREF="sdlsemtrywait.html"
+>SDL_SemTryWait</A
+> or
+<A
+HREF="sdlsemwaittimeout.html"
+>SDL_SemWaitTimeout</A
+>
+will atomically decrement the semaphore value. The locking operation will be blocked
+if the semaphore value is not positive (greater than zero). Each unlock operation by
+<A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+>
+will atomically increment the semaphore value.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7330"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a pointer to an initialized semaphore or
+<SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+> if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7334"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_sem *my_sem;
+
+my_sem = SDL_CreateSemaphore(INITIAL_SEM_VALUE);
+
+if (my_sem == NULL) {
+        return CREATE_SEM_FAILED;
+}</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7338"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmutexv.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldestroysemaphore.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_mutexV</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DestroySemaphore</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreatethread.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,215 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateThread</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="NEXT"
+TITLE="SDL_ThreadID"
+HREF="sdlthreadid.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="thread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlthreadid.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATETHREAD"
+>SDL_CreateThread</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7076"
+></A
+><H2
+>Name</H2
+>SDL_CreateThread&nbsp;--&nbsp;Creates a new thread of execution that shares its parent's properties.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7079"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7080"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Thread *<B
+CLASS="FSFUNC"
+>SDL_CreateThread</B
+></CODE
+>(int (*fn)(void *), void *data);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7086"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_CreateThread</TT
+> creates a new thread of execution 
+that shares all of its parent's global memory, signal handlers, 
+file descriptors, etc, and runs the function <TT
+CLASS="PARAMETER"
+><I
+>fn</I
+></TT
+>
+passed the void pointer <TT
+CLASS="PARAMETER"
+><I
+>data</I
+></TT
+>
+The thread quits when this function returns.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7092"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlkillthread.html"
+><TT
+CLASS="FUNCTION"
+>SDL_KillThread</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlthreadid.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Multi-threaded Programming</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ThreadID</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlcreateyuvoverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,248 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_CreateYUVOverlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GL_SwapBuffers"
+HREF="sdlglswapbuffers.html"><LINK
+REL="NEXT"
+TITLE="SDL_LockYUVOverlay"
+HREF="sdllockyuvoverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglswapbuffers.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdllockyuvoverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLCREATEYUVOVERLAY"
+>SDL_CreateYUVOverlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2310"
+></A
+><H2
+>Name</H2
+>SDL_CreateYUVOverlay&nbsp;--&nbsp;Create a YUV video overlay</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2313"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2314"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Overlay *<B
+CLASS="FSFUNC"
+>SDL_CreateYUVOverlay</B
+></CODE
+>(int width, int height, Uint32 format, SDL_Surface *display);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2320"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+> creates a YUV overlay of the specified <TT
+CLASS="PARAMETER"
+><I
+>width</I
+></TT
+>, <TT
+CLASS="PARAMETER"
+><I
+>height</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>format</I
+></TT
+> (see <A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+> for a list of available formats), for the provided <TT
+CLASS="PARAMETER"
+><I
+>display</I
+></TT
+>. A <A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+> structure is returned.</P
+><P
+>The term 'overlay' is a misnomer since, unless the overlay is created in hardware, the contents for the display surface underneath the area where the overlay is shown will be overwritten when the overlay is displayed.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2333"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+>,
+<A
+HREF="sdldisplayyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlfreeyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeYUVOverlay</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglswapbuffers.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdllockyuvoverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GL_SwapBuffers</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_LockYUVOverlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldelay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,203 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Delay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetTicks"
+HREF="sdlgetticks.html"><LINK
+REL="NEXT"
+TITLE="SDL_AddTimer"
+HREF="sdladdtimer.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetticks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdladdtimer.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDELAY"
+>SDL_Delay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7830"
+></A
+><H2
+>Name</H2
+>SDL_Delay&nbsp;--&nbsp;Wait a specified number of milliseconds before returning.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7833"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7834"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_Delay</B
+></CODE
+>(Uint32 ms);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7840"
+></A
+><H2
+>Description</H2
+><P
+>Wait a specified number of milliseconds before returning. <TT
+CLASS="FUNCTION"
+>SDL_Delay</TT
+> will wait at <I
+CLASS="EMPHASIS"
+>least</I
+> the specified time, but possible longer due to OS scheduling.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7845"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdladdtimer.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AddTimer</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetticks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdladdtimer.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetTicks</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="time.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_AddTimer</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldestroycond.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,198 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DestroyCond</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateCond"
+HREF="sdlcreatecond.html"><LINK
+REL="NEXT"
+TITLE="SDL_CondSignal"
+HREF="sdlcondsignal.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatecond.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcondsignal.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDESTROYCOND"
+>SDL_DestroyCond</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7663"
+></A
+><H2
+>Name</H2
+>SDL_DestroyCond&nbsp;--&nbsp;Destroy a condition variable</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7666"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7667"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_DestroyCond</B
+></CODE
+>(SDL_cond *cond);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7673"
+></A
+><H2
+>Description</H2
+><P
+>Destroys a condition variable.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7676"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatecond.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateCond</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatecond.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcondsignal.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateCond</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CondSignal</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldestroymutex.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,201 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DestroyMutex</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateMutex"
+HREF="sdlcreatemutex.html"><LINK
+REL="NEXT"
+TITLE="SDL_mutexP"
+HREF="sdlmutexp.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatemutex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmutexp.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDESTROYMUTEX"
+>SDL_DestroyMutex</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7224"
+></A
+><H2
+>Name</H2
+>SDL_DestroyMutex&nbsp;--&nbsp;Destroy a mutex</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7227"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7228"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_DestroyMutex</B
+></CODE
+>(SDL_mutex *mutex);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7234"
+></A
+><H2
+>Description</H2
+><P
+>Destroy a previously <A
+HREF="sdlcreatemutex.html"
+>created</A
+> mutex.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7238"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatemutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateMutex</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatemutex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmutexp.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateMutex</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_mutexP</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldestroysemaphore.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,270 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DestroySemaphore</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateSemaphore"
+HREF="sdlcreatesemaphore.html"><LINK
+REL="NEXT"
+TITLE="SDL_SemWait"
+HREF="sdlsemwait.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatesemaphore.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsemwait.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDESTROYSEMAPHORE"
+>SDL_DestroySemaphore</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7357"
+></A
+><H2
+>Name</H2
+>SDL_DestroySemaphore&nbsp;--&nbsp;Destroys a semaphore that was created by <A
+HREF="sdlcreatesemaphore.html"
+>SDL_CreateSemaphore</A
+>.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7361"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7362"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_DestroySemaphore</B
+></CODE
+>(SDL_sem *sem);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7368"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+> destroys the semaphore pointed to
+by <TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+> that was created by
+<A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>.
+It is not safe to destroy a semaphore if there are threads currently blocked
+waiting on it.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7375"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>if (my_sem != NULL) {
+        SDL_DestroySemaphore(my_sem);
+        my_sem = NULL;
+}</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7379"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatesemaphore.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsemwait.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateSemaphore</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SemWait</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldisplayformat.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,254 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DisplayFormat</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_FillRect"
+HREF="sdlfillrect.html"><LINK
+REL="NEXT"
+TITLE="SDL_DisplayFormatAlpha"
+HREF="sdldisplayformatalpha.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlfillrect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldisplayformatalpha.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDISPLAYFORMAT"
+>SDL_DisplayFormat</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1898"
+></A
+><H2
+>Name</H2
+>SDL_DisplayFormat&nbsp;--&nbsp;Convert a surface to the display format</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1901"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1902"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_DisplayFormat</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1908"
+></A
+><H2
+>Description</H2
+><P
+>This function takes a surface and copies it to a new surface of the
+pixel format and colors of the video framebuffer, suitable for fast
+blitting onto the display surface.  It calls
+<A
+HREF="sdlconvertsurface.html"
+>SDL_ConvertSurface</A
+></P
+><P
+>If you want to take advantage of hardware colorkey or alpha blit
+acceleration, you should set the colorkey and alpha value before
+calling this function.</P
+><P
+>If you want an alpha channel, see <A
+HREF="sdldisplayformatalpha.html"
+>SDL_DisplayFormatAlpha</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1915"
+></A
+><H2
+>Return Value</H2
+><P
+>If the conversion fails or runs out of memory, it returns
+<SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1919"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlconvertsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ConvertSurface</TT
+></A
+>,
+<A
+HREF="sdldisplayformatalpha.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayFormatAlpha</TT
+></A
+>
+<A
+HREF="sdlsetalpha.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetAlpha</TT
+></A
+>,
+<A
+HREF="sdlsetcolorkey.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColorKey</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlfillrect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldisplayformatalpha.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_FillRect</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DisplayFormatAlpha</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldisplayformatalpha.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,234 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DisplayFormatAlpha</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DisplayFormat"
+HREF="sdldisplayformat.html"><LINK
+REL="NEXT"
+TITLE="SDL_WarpMouse"
+HREF="sdlwarpmouse.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldisplayformat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwarpmouse.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDISPLAYFORMATALPHA"
+>SDL_DisplayFormatAlpha</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1936"
+></A
+><H2
+>Name</H2
+>SDL_DisplayFormatAlpha&nbsp;--&nbsp;Convert a surface to the display format</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1939"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1940"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_DisplayFormatAlpha</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1946"
+></A
+><H2
+>Description</H2
+><P
+>This function takes a surface and copies it to a new surface of the
+pixel format and colors of the video framebuffer plus an alpha channel,
+suitable for fast blitting onto the display surface.  It calls
+<A
+HREF="sdlconvertsurface.html"
+>SDL_ConvertSurface</A
+></P
+><P
+>If you want to take advantage of hardware colorkey or alpha blit
+acceleration, you should set the colorkey and alpha value before
+calling this function.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1951"
+></A
+><H2
+>Return Value</H2
+><P
+>If the conversion fails or runs out of memory, it returns
+<SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1955"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlconvertsurface.html"
+>SDL_ConvertSurface</A
+>,
+<A
+HREF="sdlsetalpha.html"
+>SDL_SetAlpha</A
+>,
+<A
+HREF="sdlsetcolorkey.html"
+>SDL_SetColorKey</A
+>,
+<A
+HREF="sdldisplayformat.html"
+>SDL_DisplayFormat</A
+>,
+<A
+HREF="sdlsurface.html"
+>SDL_Surface</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldisplayformat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwarpmouse.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DisplayFormat</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WarpMouse</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdldisplayyuvoverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,228 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_DisplayYUVOverlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UnlockYUVOverlay"
+HREF="sdlunlockyuvoverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_FreeYUVOverlay"
+HREF="sdlfreeyuvoverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlunlockyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlfreeyuvoverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLDISPLAYYUVOVERLAY"
+>SDL_DisplayYUVOverlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2410"
+></A
+><H2
+>Name</H2
+>SDL_DisplayYUVOverlay&nbsp;--&nbsp;Blit the overlay to the display</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2413"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2414"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_DisplayYUVOverlay</B
+></CODE
+>(SDL_Overlay *overlay, SDL_Rect *dstrect);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2420"
+></A
+><H2
+>Description</H2
+><P
+>Blit the <TT
+CLASS="PARAMETER"
+><I
+>overlay</I
+></TT
+> to the surface specified when it was <A
+HREF="sdlcreateyuvoverlay.html"
+>created</A
+>. The <A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+> structure, <TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+>, specifies the position and size of the destination. If the <TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+> is a larger or smaller than the overlay then the overlay will be scaled, this is optimized for 2x scaling.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2429"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+>,
+<A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlunlockyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlfreeyuvoverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UnlockYUVOverlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_FreeYUVOverlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlenablekeyrepeat.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,230 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_EnableKeyRepeat</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_EnableUNICODE"
+HREF="sdlenableunicode.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetMouseState"
+HREF="sdlgetmousestate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlenableunicode.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetmousestate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLENABLEKEYREPEAT"
+>SDL_EnableKeyRepeat</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5217"
+></A
+><H2
+>Name</H2
+>SDL_EnableKeyRepeat&nbsp;--&nbsp;Set keyboard repeat rate.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5220"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5221"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_EnableKeyRepeat</B
+></CODE
+>(int delay, int interval);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5227"
+></A
+><H2
+>Description</H2
+><P
+>Enables or disables the keyboard repeat rate. <TT
+CLASS="PARAMETER"
+><I
+>delay</I
+></TT
+> specifies how long the key must be pressed before it begins repeating, it then repeats at the speed specified by <TT
+CLASS="PARAMETER"
+><I
+>interval</I
+></TT
+>. Both <TT
+CLASS="PARAMETER"
+><I
+>delay</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>interval</I
+></TT
+> are expressed in milliseconds.</P
+><P
+>Setting <TT
+CLASS="PARAMETER"
+><I
+>delay</I
+></TT
+> to 0 disables key repeating completely. Good default values are <TT
+CLASS="LITERAL"
+>SDL_DEFAULT_REPEAT_DELAY</TT
+> and <SPAN
+CLASS="SYMBOL"
+>SDL_DEFAULT_REPEAT_INTERVAL</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5238"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success and <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on failure.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlenableunicode.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetmousestate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_EnableUNICODE</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetMouseState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlenableunicode.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,228 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_EnableUNICODE</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetKeyName"
+HREF="sdlgetkeyname.html"><LINK
+REL="NEXT"
+TITLE="SDL_EnableKeyRepeat"
+HREF="sdlenablekeyrepeat.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetkeyname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlenablekeyrepeat.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLENABLEUNICODE"
+>SDL_EnableUNICODE</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5187"
+></A
+><H2
+>Name</H2
+>SDL_EnableUNICODE&nbsp;--&nbsp;Enable UNICODE translation</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5190"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5191"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_EnableUNICODE</B
+></CODE
+>(int enable);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5197"
+></A
+><H2
+>Description</H2
+><P
+>Enables/Disables UNICODE keyboard translation.</P
+><P
+>If you wish to translate a keysym to it's printable representation, you need to enable UNICODE translation
+using this function (<TT
+CLASS="PARAMETER"
+><I
+>enable</I
+></TT
+>=0) and then look in the <TT
+CLASS="STRUCTFIELD"
+><I
+>unicode</I
+></TT
+> member
+of the <A
+HREF="sdlkeysym.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+></A
+> structure. This value will be zero for keysyms
+that do not have a printable representation. UNICODE translation is disabled by default as the conversion can cause a slight overhead.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5205"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns the previous translation mode.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5208"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlkeysym.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetkeyname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlenablekeyrepeat.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetKeyName</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_EnableKeyRepeat</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,942 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Event</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="NEXT"
+TITLE="SDL_ActiveEvent"
+HREF="sdlactiveevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="eventstructures.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlactiveevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLEVENT"
+>SDL_Event</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3214"
+></A
+><H2
+>Name</H2
+>SDL_Event&nbsp;--&nbsp;General event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3217"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef union{
+  Uint8 type;
+  SDL_ActiveEvent active;
+  SDL_KeyboardEvent key;
+  SDL_MouseMotionEvent motion;
+  SDL_MouseButtonEvent button;
+  SDL_JoyAxisEvent jaxis;
+  SDL_JoyBallEvent jball;
+  SDL_JoyHatEvent jhat;
+  SDL_JoyButtonEvent jbutton;
+  SDL_ResizeEvent resize;
+  SDL_QuitEvent quit;
+  SDL_UserEvent user;
+  SDL_SywWMEvent syswm;
+} SDL_Event;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3220"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3222"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The type of event</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>active</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlactiveevent.html"
+>Activation event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>key</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlkeyboardevent.html"
+>Keyboard event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>motion</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlmousemotionevent.html"
+>Mouse motion event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>button</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlmousebuttonevent.html"
+>Mouse button event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>jaxis</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyaxisevent.html"
+>Joystick axis motion event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>jball</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyballevent.html"
+>Joystick trackball motion event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>jhat</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyhatevent.html"
+>Joystick hat motion event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>jbutton</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoybuttonevent.html"
+>Joystick button event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>resize</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlresizeevent.html"
+>Application window resize event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>quit</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlquitevent.html"
+>Application quit request event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>user</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdluserevent.html"
+>User defined event</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>syswm</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlsyswmevent.html"
+>Undefined window manager event</A
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3289"
+></A
+><H2
+>Description</H2
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> union is the core to all event handling is SDL, its probably the most important structure after <SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+>. <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+>.</P
+><P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3297"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><THEAD
+><TR
+><TH
+ALIGN="LEFT"
+VALIGN="TOP"
+>Event <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TH
+><TH
+ALIGN="LEFT"
+VALIGN="TOP"
+>Event Structure</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="MIDDLE"
+><TT
+CLASS="LITERAL"
+>SDL_ACTIVEEVENT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="MIDDLE"
+><A
+HREF="sdlactiveevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_ActiveEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_KEYDOWN/UP</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlkeyboardevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlmousemotionevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseMotionEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_MOUSEBUTTONDOWN/UP</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlmousebuttonevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseButtonEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYAXISMOTION</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyaxisevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyAxisEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYBALLMOTION</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyballevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyBallEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYHATMOTION</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoyhatevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyHatEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONDOWN/UP</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdljoybuttonevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyButtonEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_QUIT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlquitevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_QuitEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SYSWMEVENT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlsyswmevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_SysWMEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlresizeevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_ResizeEvent</SPAN
+></A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_USEREVENT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdluserevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_UserEvent</SPAN
+></A
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3377"
+></A
+><H2
+>Use</H2
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> structure has two uses</P
+><P
+></P
+><UL
+COMPACT="COMPACT"
+><LI
+><P
+>Reading events on the event queue</P
+></LI
+><LI
+><P
+>Placing events on the event queue</P
+></LI
+></UL
+><P
+>Reading events from the event queue is done with either <A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+> or <A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+>. We'll use <TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+> and step through an example.</P
+><P
+>First off, we create an empty <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> structure.
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_Event test_event;</PRE
+>
+<TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+> removes the next event from the event queue, if there are no events on the queue it returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> otherwise it returns <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>. We use a <TT
+CLASS="FUNCTION"
+>while</TT
+> loop to process each event in turn.
+<PRE
+CLASS="PROGRAMLISTING"
+>while(SDL_PollEvent(&#38;test_event)) {</PRE
+>
+The <TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+> function take a pointer to an <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+> structure that is to be filled with event information. We know that if <TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+> removes an event from the queue then the event information will be placed in our <SPAN
+CLASS="STRUCTNAME"
+>test_event</SPAN
+> structure, but we also know that the <I
+CLASS="EMPHASIS"
+>type</I
+> of event will be placed in the <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> member of <SPAN
+CLASS="STRUCTNAME"
+>test_event</SPAN
+>. So to handle each event <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> seperately we use a <TT
+CLASS="FUNCTION"
+>switch</TT
+> statement.
+<PRE
+CLASS="PROGRAMLISTING"
+>  switch(test_event.type) {</PRE
+>
+We need to know what kind of events we're looking for <I
+CLASS="EMPHASIS"
+>and</I
+> the event <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+>'s of those events. So lets assume we want to detect where the user is moving the mouse pointer within our application. We look through our event types and notice that <TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+> is, more than likely, the event we're looking for. A little <A
+HREF="sdlmousemotionevent.html"
+>more</A
+> research tells use that <TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+> events are handled within the <A
+HREF="sdlmousemotionevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseMotionEvent</SPAN
+></A
+> structure which is the <TT
+CLASS="STRUCTFIELD"
+><I
+>motion</I
+></TT
+> member of <SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+>. We can check for the <TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+> event <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> within our <TT
+CLASS="FUNCTION"
+>switch</TT
+> statement like so:
+<PRE
+CLASS="PROGRAMLISTING"
+>    case SDL_MOUSEMOTION:</PRE
+>
+All we need do now is read the information out of the <TT
+CLASS="STRUCTFIELD"
+><I
+>motion</I
+></TT
+> member of <SPAN
+CLASS="STRUCTNAME"
+>test_event</SPAN
+>.
+<PRE
+CLASS="PROGRAMLISTING"
+>      printf("We got a motion event.\n");
+      printf("Current mouse position is: (%d, %d)\n", test_event.motion.x, test_event.motion.y);
+      break;
+    default:
+      printf("Unhandled Event!\n");
+      break;
+  }
+}
+printf("Event queue empty.\n");</PRE
+></P
+><P
+>It is also possible to push events onto the event queue and so use it as a two-way communication path. Both <A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+> and <A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+> allow you to place events onto the event queue. This is usually used to place a <TT
+CLASS="LITERAL"
+>SDL_USEREVENT</TT
+> on the event queue, however you could use it to post fake input events if you wished. Creating your own events is a simple matter of choosing the event type you want, setting the <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> member and filling the appropriate member structure with information.
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_Event user_event;
+
+user_event.type=SDL_USEREVENT;
+user_event.user.code=2;
+user_event.user.data1=NULL;
+user_event.user.data2=NULL;
+SDL_PushEvent(&#38;user_event);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3434"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+>,
+<A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+>,
+<A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlactiveevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL Event Structures.</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ActiveEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdleventstate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,268 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_EventState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetEventFilter"
+HREF="sdlgeteventfilter.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetKeyState"
+HREF="sdlgetkeystate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgeteventfilter.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetkeystate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLEVENTSTATE"
+>SDL_EventState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5028"
+></A
+><H2
+>Name</H2
+>SDL_EventState&nbsp;--&nbsp;This function allows you to set the state of processing certain events.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5031"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5032"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_EventState</B
+></CODE
+>(Uint8 type, int state);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5038"
+></A
+><H2
+>Description</H2
+><P
+>This function allows you to set the state of processing certain event <TT
+CLASS="PARAMETER"
+><I
+>type</I
+></TT
+>'s.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is set to <TT
+CLASS="LITERAL"
+>SDL_IGNORE</TT
+>, 
+that event <TT
+CLASS="PARAMETER"
+><I
+>type</I
+></TT
+> will be automatically dropped from the event queue and will 
+not be filtered.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is set to <TT
+CLASS="LITERAL"
+>SDL_ENABLE</TT
+>, 
+that event <TT
+CLASS="PARAMETER"
+><I
+>type</I
+></TT
+> will be processed normally.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is set to <TT
+CLASS="LITERAL"
+>SDL_QUERY</TT
+>,
+<TT
+CLASS="FUNCTION"
+>SDL_EventState</TT
+> will return the current processing 
+state of the specified event <TT
+CLASS="PARAMETER"
+><I
+>type</I
+></TT
+>.</P
+><P
+>A list of event <TT
+CLASS="PARAMETER"
+><I
+>type</I
+></TT
+>'s can be found in the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> section.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5059"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgeteventfilter.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetkeystate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetEventFilter</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetKeyState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlfillrect.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,270 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_FillRect</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_BlitSurface"
+HREF="sdlblitsurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_DisplayFormat"
+HREF="sdldisplayformat.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlblitsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldisplayformat.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFILLRECT"
+>SDL_FillRect</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1858"
+></A
+><H2
+>Name</H2
+>SDL_FillRect&nbsp;--&nbsp;This function performs a fast fill of the given rectangle with some color</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1861"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1862"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_FillRect</B
+></CODE
+>(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1868"
+></A
+><H2
+>Description</H2
+><P
+>This function performs a fast fill of the given rectangle with
+<TT
+CLASS="PARAMETER"
+><I
+>color</I
+></TT
+>.  If <TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+>
+is <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the whole surface will be filled with
+<TT
+CLASS="PARAMETER"
+><I
+>color</I
+></TT
+>.</P
+><P
+>The color should be a pixel of the format used by the surface, and
+can be generated by the
+<A
+HREF="sdlmaprgb.html"
+>SDL_MapRGB</A
+>
+function.</P
+><P
+>If there is a clip rectangle set on the destination (set via
+<A
+HREF="sdlsetcliprect.html"
+>SDL_SetClipRect</A
+>) then this
+function will clip based on the intersection of the clip rectangle and
+the <TT
+CLASS="PARAMETER"
+><I
+>dstrect</I
+></TT
+> rectangle.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1880"
+></A
+><H2
+>Return Value</H2
+><P
+>This function returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1885"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+>,
+<A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+>,
+<A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlblitsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldisplayformat.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_BlitSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DisplayFormat</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlflip.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,251 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Flip</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UpdateRects"
+HREF="sdlupdaterects.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetColors"
+HREF="sdlsetcolors.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlupdaterects.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetcolors.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFLIP"
+>SDL_Flip</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN969"
+></A
+><H2
+>Name</H2
+>SDL_Flip&nbsp;--&nbsp;Swaps screen buffers</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN972"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN973"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_Flip</B
+></CODE
+>(SDL_Surface *screen);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN979"
+></A
+><H2
+>Description</H2
+><P
+>On hardware that supports double-buffering, this function sets up a flip
+and returns.  The hardware will wait for vertical retrace, and then swap
+video buffers before the next video surface blit or lock will return.
+On hardware that doesn't support double-buffering, this is equivalent
+to calling <A
+HREF="sdlupdaterect.html"
+>SDL_UpdateRect</A
+><TT
+CLASS="PARAMETER"
+><I
+>(screen, 0, 0, 0, 0)</I
+></TT
+></P
+><P
+>The <TT
+CLASS="LITERAL"
+>SDL_DOUBLEBUF</TT
+> flag must have been passed to 
+<A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+>,
+ when
+setting the video mode for this function to perform hardware flipping.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN987"
+></A
+><H2
+>Return Value</H2
+><P
+>This function returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if successful, or 
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN992"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlupdaterect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlupdaterects.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetcolors.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UpdateRects</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetColors</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlfreecursor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,201 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_FreeCursor</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateCursor"
+HREF="sdlcreatecursor.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetCursor"
+HREF="sdlsetcursor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatecursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetcursor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFREECURSOR"
+>SDL_FreeCursor</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2042"
+></A
+><H2
+>Name</H2
+>SDL_FreeCursor&nbsp;--&nbsp;Frees a cursor created with SDL_CreateCursor.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2045"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2046"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_FreeCursor</B
+></CODE
+>(SDL_Cursor *cursor);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2052"
+></A
+><H2
+>Description</H2
+><P
+>Frees a <SPAN
+CLASS="STRUCTNAME"
+>SDL_Cursor</SPAN
+> that was created using
+<A
+HREF="sdlcreatecursor.html"
+>SDL_CreateCursor</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2057"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatecursor.html"
+>SDL_CreateCursor</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatecursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetcursor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateCursor</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetCursor</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlfreesurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_FreeSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateRGBSurfaceFrom"
+HREF="sdlcreatergbsurfacefrom.html"><LINK
+REL="NEXT"
+TITLE="SDL_LockSurface"
+HREF="sdllocksurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdllocksurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFREESURFACE"
+>SDL_FreeSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1409"
+></A
+><H2
+>Name</H2
+>SDL_FreeSurface&nbsp;--&nbsp;Frees (deletes) and SDL_Surface</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1412"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1413"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_FreeSurface</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1419"
+></A
+><H2
+>Description</H2
+><P
+>Frees the resources used by a previously created <SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+>. If the surface was created using 
+<A
+HREF="sdlcreatergbsurfacefrom.html"
+>SDL_CreateRGBSurfaceFrom</A
+> then the pixel data is not freed.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1424"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatergbsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurface</TT
+></A
+>
+<A
+HREF="sdlcreatergbsurfacefrom.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateRGBSurfaceFrom</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdllocksurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateRGBSurfaceFrom</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_LockSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlfreewav.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_FreeWAV</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_LoadWAV"
+HREF="sdlloadwav.html"><LINK
+REL="NEXT"
+TITLE="SDL_AudioCVT"
+HREF="sdlaudiocvt.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlloadwav.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlaudiocvt.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFREEWAV"
+>SDL_FreeWAV</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6235"
+></A
+><H2
+>Name</H2
+>SDL_FreeWAV&nbsp;--&nbsp;Frees previously opened WAV data</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6238"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6239"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_FreeWAV</B
+></CODE
+>(Uint8 *audio_buf);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6245"
+></A
+><H2
+>Description</H2
+><P
+>After a WAVE file has been opened with <A
+HREF="sdlloadwav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+></A
+> its data can eventually be freed with <TT
+CLASS="FUNCTION"
+>SDL_FreeWAV</TT
+>. <TT
+CLASS="PARAMETER"
+><I
+>audio_buf</I
+></TT
+> is a pointer to the buffer created by <TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6253"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlloadwav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlloadwav.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlaudiocvt.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_LoadWAV</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_AudioCVT</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlfreeyuvoverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,225 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_FreeYUVOverlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DisplayYUVOverlay"
+HREF="sdldisplayyuvoverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_GLattr"
+HREF="sdlglattr.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldisplayyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglattr.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLFREEYUVOVERLAY"
+>SDL_FreeYUVOverlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2440"
+></A
+><H2
+>Name</H2
+>SDL_FreeYUVOverlay&nbsp;--&nbsp;Free a YUV video overlay</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2443"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2444"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_FreeYUVOverlay</B
+></CODE
+>(SDL_Overlay *overlay);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2450"
+></A
+><H2
+>Description</H2
+><P
+>Frees and <A
+HREF="sdloverlay.html"
+><TT
+CLASS="PARAMETER"
+><I
+>overlay</I
+></TT
+></A
+> created by <A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2457"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+>,
+<A
+HREF="sdldisplayyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeYUVOverlay</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldisplayyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglattr.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DisplayYUVOverlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GLattr</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetappstate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,255 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetAppState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetRelativeMouseState"
+HREF="sdlgetrelativemousestate.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickEventState"
+HREF="sdljoystickeventstate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetrelativemousestate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickeventstate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETAPPSTATE"
+>SDL_GetAppState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5309"
+></A
+><H2
+>Name</H2
+><TT
+CLASS="FUNCTION"
+>SDL_GetAppState</TT
+>&nbsp;--&nbsp;Get the state of the application</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5313"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5314"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_GetAppState</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5320"
+></A
+><H2
+>Description</H2
+><P
+>This function returns the current state of the application. The value returned is a bitwise combination of:</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN5323"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_APPMOUSEFOCUS</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The application has mouse focus.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_APPINPUTFOCUS</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The application has keyboard focus</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_APPACTIVE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The application is visible</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5338"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlactiveevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_ActiveEvent</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetrelativemousestate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickeventstate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetRelativeMouseState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickEventState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetaudiostatus.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,213 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetAudioStatus</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PauseAudio"
+HREF="sdlpauseaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_LoadWAV"
+HREF="sdlloadwav.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpauseaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlloadwav.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETAUDIOSTATUS"
+>SDL_GetAudioStatus</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6168"
+></A
+><H2
+>Name</H2
+>SDL_GetAudioStatus&nbsp;--&nbsp;Get the current audio state</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6171"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6172"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_audiostatus<B
+CLASS="FSFUNC"
+>SDL_GetAudioStatus</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6178"
+></A
+><H2
+>Description</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef enum{
+  SDL_AUDIO_STOPPED,
+  SDL_AUDIO_PAUSED,
+  SDL_AUDIO_PLAYING
+} SDL_audiostatus;</PRE
+><P
+>Returns either <TT
+CLASS="LITERAL"
+>SDL_AUDIO_STOPPED</TT
+>, <TT
+CLASS="LITERAL"
+>SDL_AUDIO_PAUSED</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_AUDIO_PLAYING</TT
+> depending on the current audio state.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6185"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpauseaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PauseAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpauseaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlloadwav.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PauseAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_LoadWAV</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetcliprect.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,221 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetClipRect</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetClipRect"
+HREF="sdlsetcliprect.html"><LINK
+REL="NEXT"
+TITLE="SDL_ConvertSurface"
+HREF="sdlconvertsurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetcliprect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlconvertsurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETCLIPRECT"
+>SDL_GetClipRect</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1738"
+></A
+><H2
+>Name</H2
+>SDL_GetClipRect&nbsp;--&nbsp;Gets the clipping rectangle for a surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1741"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1742"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_GetClipRect</B
+></CODE
+>(SDL_Surface *surface, SDL_Rect *rect);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1748"
+></A
+><H2
+>Description</H2
+><P
+>Gets the clipping rectangle for a surface.  When this surface is the
+destination of a blit, only the area within the clip rectangle is
+drawn into.</P
+><P
+>The rectangle pointed to by <TT
+CLASS="PARAMETER"
+><I
+>rect</I
+></TT
+> will be
+filled with the clipping rectangle of the surface.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1753"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetcliprect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetClipRect</TT
+></A
+>,
+<A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetcliprect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlconvertsurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetClipRect</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ConvertSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetcursor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetCursor</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetCursor"
+HREF="sdlsetcursor.html"><LINK
+REL="NEXT"
+TITLE="SDL_ShowCursor"
+HREF="sdlshowcursor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlshowcursor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETCURSOR"
+>SDL_GetCursor</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2091"
+></A
+><H2
+>Name</H2
+>SDL_GetCursor&nbsp;--&nbsp;Get the currently active mouse cursor.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2094"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2095"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Cursor *<B
+CLASS="FSFUNC"
+>SDL_GetCursor</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2101"
+></A
+><H2
+>Description</H2
+><P
+>Returns the currently active mouse cursor.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2104"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetCursor</TT
+></A
+>,
+<A
+HREF="sdlcreatecursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateCursor</TT
+></A
+>,
+<A
+HREF="sdlshowcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ShowCursor</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlshowcursor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetCursor</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ShowCursor</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgeteventfilter.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,227 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetEventFilter</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetEventFilter"
+HREF="sdlseteventfilter.html"><LINK
+REL="NEXT"
+TITLE="SDL_EventState"
+HREF="sdleventstate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlseteventfilter.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdleventstate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETEVENTFILTER"
+>SDL_GetEventFilter</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4997"
+></A
+><H2
+>Name</H2
+>SDL_GetEventFilter&nbsp;--&nbsp;Retrieves a pointer to he event filter</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5000"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5001"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_EventFilter <B
+CLASS="FSFUNC"
+>SDL_GetEventFilter</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5007"
+></A
+><H2
+>Description</H2
+><P
+>This function retrieces a pointer to the event filter that was previously set using <A
+HREF="sdlseteventfilter.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetEventFilter</TT
+></A
+>. An SDL_EventFilter function is defined as:
+<PRE
+CLASS="PROGRAMLISTING"
+>typedef int (*SDL_EventFilter)(const SDL_Event *event);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5013"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a pointer to the event filter or <TT
+CLASS="LITERAL"
+>NULL</TT
+> if no filter has been set.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5017"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlseteventfilter.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetEventFilter</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlseteventfilter.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdleventstate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetEventFilter</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_EventState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetgammaramp.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetGammaRamp</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetGamma"
+HREF="sdlsetgamma.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetGammaRamp"
+HREF="sdlsetgammaramp.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetgamma.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetgammaramp.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETGAMMARAMP"
+>SDL_GetGammaRamp</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1141"
+></A
+><H2
+>Name</H2
+>SDL_GetGammaRamp&nbsp;--&nbsp;Gets the color gamma lookup tables for the display</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1144"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1145"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_GetGammaRamp</B
+></CODE
+>(Uint16 *redtable, Uint16 *greentable, Uint16 *bluetable);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1151"
+></A
+><H2
+>Description</H2
+><P
+>Gets the gamma translation lookup tables currently used by the display.
+Each table is an array of 256 Uint16 values.</P
+><P
+>Not all display hardware is able to change gamma.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1155"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns -1 on error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1158"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetgamma.html"
+>SDL_SetGamma</A
+>
+<A
+HREF="sdlsetgammaramp.html"
+>SDL_SetGammaRamp</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetgamma.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetgammaramp.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetGamma</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetGammaRamp</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetkeyname.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,208 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetKeyName</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetModState"
+HREF="sdlsetmodstate.html"><LINK
+REL="NEXT"
+TITLE="SDL_EnableUNICODE"
+HREF="sdlenableunicode.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetmodstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlenableunicode.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETKEYNAME"
+>SDL_GetKeyName</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5162"
+></A
+><H2
+>Name</H2
+>SDL_GetKeyName&nbsp;--&nbsp;Get the name of an SDL virtual keysym</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5165"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5166"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>char *<B
+CLASS="FSFUNC"
+>SDL_GetKeyName</B
+></CODE
+>(SDLKey key);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5172"
+></A
+><H2
+>Description</H2
+><P
+>Returns the SDL-defined name of the <A
+HREF="sdlkey.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+></A
+> <TT
+CLASS="PARAMETER"
+><I
+>key</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5178"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlkey.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetmodstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlenableunicode.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetModState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_EnableUNICODE</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetkeystate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,245 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetKeyState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_EventState"
+HREF="sdleventstate.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetModState"
+HREF="sdlgetmodstate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdleventstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetmodstate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETKEYSTATE"
+>SDL_GetKeyState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5068"
+></A
+><H2
+>Name</H2
+>SDL_GetKeyState&nbsp;--&nbsp;Get a snapshot of the current keyboard state</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5071"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5072"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 *<B
+CLASS="FSFUNC"
+>SDL_GetKeyState</B
+></CODE
+>(int *numkeys);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5078"
+></A
+><H2
+>Description</H2
+><P
+>Gets a snapshot of the current keyboard state. The current state is return as a pointer to an array, the size of this array is stored in <TT
+CLASS="PARAMETER"
+><I
+>numkeys</I
+></TT
+>. The array is indexed by the <A
+HREF="sdlkey.html"
+><TT
+CLASS="LITERAL"
+>SDLK_*</TT
+></A
+> symbols. A value of 1 means the key is pressed and a value of 0 means its not.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Use <A
+HREF="sdlpumpevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+></A
+> to update the state array.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5088"
+></A
+><H2
+>Example</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>Uint8 *keystate = SDL_GetKeyState(NULL);
+if ( keystate[SDLK_RETURN] ) printf("Return Key Pressed.\n");</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5092"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlkey.html"
+><TT
+CLASS="LITERAL"
+>SDL Key Symbols</TT
+></A
+>,
+<A
+HREF="sdlpumpevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdleventstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetmodstate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_EventState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetModState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetmodstate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,249 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetModState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetKeyState"
+HREF="sdlgetkeystate.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetModState"
+HREF="sdlsetmodstate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetkeystate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetmodstate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETMODSTATE"
+>SDL_GetModState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5103"
+></A
+><H2
+>Name</H2
+>SDL_GetModState&nbsp;--&nbsp;Get the state of modifier keys.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5106"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5107"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDLMod <B
+CLASS="FSFUNC"
+>SDL_GetModState</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5113"
+></A
+><H2
+>Description</H2
+><P
+>Returns the current of the modifier keys (CTRL, ALT, etc.).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5116"
+></A
+><H2
+>Return Value</H2
+><P
+>The return value can be an OR'd combination of the SDLMod enum.</P
+><P
+><A
+NAME="AEN5120"
+></A
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><P
+><B
+>SDLMod</B
+></P
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef enum {
+  KMOD_NONE  = 0x0000,
+  KMOD_LSHIFT= 0x0001,
+  KMOD_RSHIFT= 0x0002,
+  KMOD_LCTRL = 0x0040,
+  KMOD_RCTRL = 0x0080,
+  KMOD_LALT  = 0x0100,
+  KMOD_RALT  = 0x0200,
+  KMOD_LMETA = 0x0400,
+  KMOD_RMETA = 0x0800,
+  KMOD_NUM   = 0x1000,
+  KMOD_CAPS  = 0x2000,
+  KMOD_MODE  = 0x4000,
+} SDLMod;</PRE
+></BLOCKQUOTE
+>
+SDL also defines the following symbols for convenience:
+<A
+NAME="AEN5123"
+></A
+><BLOCKQUOTE
+CLASS="BLOCKQUOTE"
+><PRE
+CLASS="PROGRAMLISTING"
+>#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
+#define KMOD_SHIFT  (KMOD_LSHIFT|KMOD_RSHIFT)
+#define KMOD_ALT  (KMOD_LALT|KMOD_RALT)
+#define KMOD_META (KMOD_LMETA|KMOD_RMETA)</PRE
+></BLOCKQUOTE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5125"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetkeystate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetKeyState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetkeystate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetmodstate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetKeyState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetModState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetmousestate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,245 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetMouseState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_EnableKeyRepeat"
+HREF="sdlenablekeyrepeat.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetRelativeMouseState"
+HREF="sdlgetrelativemousestate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlenablekeyrepeat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetrelativemousestate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETMOUSESTATE"
+>SDL_GetMouseState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5247"
+></A
+><H2
+>Name</H2
+>SDL_GetMouseState&nbsp;--&nbsp;Retrieve the current state of the mouse</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5250"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5251"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_GetMouseState</B
+></CODE
+>(int *x, int *y);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5257"
+></A
+><H2
+>Description</H2
+><P
+>The current button state is returned as a button bitmask, which can
+be tested using the <TT
+CLASS="LITERAL"
+>SDL_BUTTON(X)</TT
+> macros, and <TT
+CLASS="PARAMETER"
+><I
+>x</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>y</I
+></TT
+> are set to the
+current mouse cursor position.  You can pass <TT
+CLASS="LITERAL"
+>NULL</TT
+> for either <TT
+CLASS="PARAMETER"
+><I
+>x</I
+></TT
+> or <TT
+CLASS="PARAMETER"
+><I
+>y</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5266"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_PumpEvents();
+if(SDL_GetMouseState(NULL, NULL)&#38;SDL_BUTTON(1))
+  printf("Mouse Button 1(left) is pressed.\n");</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5269"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetrelativemousestate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetRelativeMouseState</TT
+></A
+>,
+<A
+HREF="sdlpumpevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlenablekeyrepeat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetrelativemousestate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_EnableKeyRepeat</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetRelativeMouseState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetrelativemousestate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,227 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetRelativeMouseState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetMouseState"
+HREF="sdlgetmousestate.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetAppState"
+HREF="sdlgetappstate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetmousestate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetappstate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETRELATIVEMOUSESTATE"
+>SDL_GetRelativeMouseState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5280"
+></A
+><H2
+>Name</H2
+>SDL_GetRelativeMouseState&nbsp;--&nbsp;Retrieve the current state of the mouse</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5283"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5284"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_GetRelativeMouseState</B
+></CODE
+>(int *x, int *y);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5290"
+></A
+><H2
+>Description</H2
+><P
+>The current button state is returned as a button bitmask, which can
+be tested using the <TT
+CLASS="LITERAL"
+>SDL_BUTTON(X)</TT
+> macros, and <TT
+CLASS="PARAMETER"
+><I
+>x</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>y</I
+></TT
+> are set to the change in the mouse position since the last call to <TT
+CLASS="FUNCTION"
+>SDL_GetRelativeMouseState</TT
+> or since event initialization.  You can pass <TT
+CLASS="LITERAL"
+>NULL</TT
+> for either <TT
+CLASS="PARAMETER"
+><I
+>x</I
+></TT
+> or <TT
+CLASS="PARAMETER"
+><I
+>y</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5300"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetmousestate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetMouseState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetmousestate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetappstate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetMouseState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetAppState</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetrgb.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetRGB</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_MapRGBA"
+HREF="sdlmaprgba.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetRGBA"
+HREF="sdlgetrgba.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmaprgba.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetrgba.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETRGB"
+>SDL_GetRGB</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1261"
+></A
+><H2
+>Name</H2
+>SDL_GetRGB&nbsp;--&nbsp;Get RGB values from a pixel in the specified pixel format.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1264"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1265"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_GetRGB</B
+></CODE
+>(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1271"
+></A
+><H2
+>Description</H2
+><P
+>Get RGB component values from a pixel stored in the specified pixel format.</P
+><P
+>This function uses the entire 8-bit [0..255] range when converting color
+components from pixel formats with less than 8-bits per RGB component
+(e.g., a completely white pixel in 16-bit RGB565 format would return
+[0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1275"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetrgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetRGBA</TT
+></A
+>,
+<A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+>,
+<A
+HREF="sdlmaprgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGBA</TT
+></A
+>,
+<A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmaprgba.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetrgba.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_MapRGBA</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetRGBA</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetrgba.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetRGBA</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetRGB"
+HREF="sdlgetrgb.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateRGBSurface"
+HREF="sdlcreatergbsurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetrgb.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatergbsurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETRGBA"
+>SDL_GetRGBA</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1290"
+></A
+><H2
+>Name</H2
+>SDL_GetRGBA&nbsp;--&nbsp;Get RGBA values from a pixel in the specified pixel format.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1293"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1294"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_GetRGBA</B
+></CODE
+>(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1300"
+></A
+><H2
+>Description</H2
+><P
+>Get RGBA component values from a pixel stored in the specified pixel format.</P
+><P
+>This function uses the entire 8-bit [0..255] range when converting color
+components from pixel formats with less than 8-bits per RGB component
+(e.g., a completely white pixel in 16-bit RGB565 format would return
+[0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8]).</P
+><P
+>If the surface has no alpha component, the alpha will be returned as 0xff
+(100% opaque).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1305"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetrgb.html"
+>SDL_GetRGB</A
+>,
+<A
+HREF="sdlmaprgb.html"
+>SDL_MapRGB</A
+>,
+<A
+HREF="sdlmaprgba.html"
+>SDL_MapRGBA</A
+>,
+<A
+HREF="sdlpixelformat.html"
+>SDL_PixelFormat</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetrgb.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatergbsurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetRGB</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateRGBSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetthreadid.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,201 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetThreadID</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ThreadID"
+HREF="sdlthreadid.html"><LINK
+REL="NEXT"
+TITLE="SDL_WaitThread"
+HREF="sdlwaitthread.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlthreadid.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwaitthread.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETTHREADID"
+>SDL_GetThreadID</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7118"
+></A
+><H2
+>Name</H2
+>SDL_GetThreadID&nbsp;--&nbsp;Get the SDL thread ID of a SDL_Thread</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7121"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7122"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_GetThreadID</B
+></CODE
+>(SDL_Thread *thread);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7128"
+></A
+><H2
+>Description</H2
+><P
+>Returns the ID of a <SPAN
+CLASS="STRUCTNAME"
+>SDL_Thread</SPAN
+> created by <A
+HREF="sdlcreatethread.html"
+>SDL_CreateThread</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7133"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatethread.html"
+>SDL_CreateThread</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlthreadid.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwaitthread.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ThreadID</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WaitThread</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetticks.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,198 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetTicks</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="PREVIOUS"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="NEXT"
+TITLE="SDL_Delay"
+HREF="sdldelay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="time.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldelay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETTICKS"
+>SDL_GetTicks</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7808"
+></A
+><H2
+>Name</H2
+>SDL_GetTicks&nbsp;--&nbsp;Get the number of milliseconds since the SDL library initialization.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7811"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7812"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_GetTicks</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7818"
+></A
+><H2
+>Description</H2
+><P
+>Get the number of milliseconds since the SDL library initialization.
+Note that this value wraps if the program runs for more than ~49 days.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7821"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdldelay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Delay</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="time.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldelay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Time</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="time.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Delay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetvideoinfo.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,218 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetVideoInfo</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetVideoSurface"
+HREF="sdlgetvideosurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_VideoDriverName"
+HREF="sdlvideodrivername.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetvideosurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlvideodrivername.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETVIDEOINFO"
+>SDL_GetVideoInfo</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN656"
+></A
+><H2
+>Name</H2
+>SDL_GetVideoInfo&nbsp;--&nbsp;returns a pointer to information about the video hardware</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN659"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN660"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_VideoInfo *<B
+CLASS="FSFUNC"
+>SDL_GetVideoInfo</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN666"
+></A
+><H2
+>Description</H2
+><P
+>This function returns a read-only pointer to <A
+HREF="sdlvideoinfo.html"
+>information</A
+> about the video
+hardware.  If this is called before <A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+>, the
+<TT
+CLASS="STRUCTFIELD"
+><I
+>vfmt</I
+></TT
+> member of the returned structure will contain the
+pixel format of the "best" video mode.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN672"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlvideoinfo.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_VideoInfo</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetvideosurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlvideodrivername.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetVideoSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_VideoDriverName</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlgetvideosurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,200 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GetVideoSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetVideoInfo"
+HREF="sdlgetvideoinfo.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="video.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetvideoinfo.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGETVIDEOSURFACE"
+>SDL_GetVideoSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN634"
+></A
+><H2
+>Name</H2
+>SDL_GetVideoSurface&nbsp;--&nbsp;returns a pointer to the current display surface</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN637"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN638"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_GetVideoSurface</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN644"
+></A
+><H2
+>Description</H2
+><P
+>This function returns a pointer to the current display surface.
+If SDL is doing format conversion on the display surface, this
+function returns the publicly visible surface, not the real video
+surface.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN647"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="video.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetvideoinfo.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Video</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetVideoInfo</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglattr.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,368 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GLattr</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_FreeYUVOverlay"
+HREF="sdlfreeyuvoverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_Rect"
+HREF="sdlrect.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlfreeyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlrect.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLATTR"
+>SDL_GLattr</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2470"
+></A
+><H2
+>Name</H2
+>SDL_GLattr&nbsp;--&nbsp;SDL GL Attributes</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2473"
+></A
+><H2
+>Attributes</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2475"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_RED_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the framebuffer red component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_GREEN_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the framebuffer green component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_BLUE_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the framebuffer blue component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_ALPHA_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the framebuffer alpha component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_DOUBLEBUFFER</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>0 or 1, enable or disable double buffering</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_BUFFER_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the framebuffer, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_DEPTH_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the depth buffer, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_STENCIL_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the stencil buffer, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_ACCUM_RED_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the accumulation buffer red component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_ACCUM_GREEN_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the accumulation buffer green component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_ACCUM_BLUE_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the accumulation buffer blue component, in bits</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_GL_ACCUM_ALPHA_SIZE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Size of the accumulation buffer alpha component, in bits</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2526"
+></A
+><H2
+>Description</H2
+><P
+>While you can set most OpenGL attributes normally, the attributes list above must be known <I
+CLASS="EMPHASIS"
+>before</I
+> SDL sets the video mode. These attributes a set and read with <A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+> and <A
+HREF="sdlglgetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetAttribute</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2534"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+>,
+<A
+HREF="sdlglgetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetAttribute</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlfreeyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlrect.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_FreeYUVOverlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Rect</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglgetattribute.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,239 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GL_GetAttribute</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GL_GetProcAddress"
+HREF="sdlglgetprocaddress.html"><LINK
+REL="NEXT"
+TITLE="SDL_GL_SetAttribute"
+HREF="sdlglsetattribute.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglgetprocaddress.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglsetattribute.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLGETATTRIBUTE"
+>SDL_GL_GetAttribute</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2210"
+></A
+><H2
+>Name</H2
+>SDL_GL_GetAttribute&nbsp;--&nbsp;Get the value of a special SDL/OpenGL attribute</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2213"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2214"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_GL_GetAttribute</B
+></CODE
+>(SDLGLattr attr, int *value);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2220"
+></A
+><H2
+>Description</H2
+><P
+>Places the value of the SDL/OpenGL <A
+HREF="sdlglattr.html"
+>attribute</A
+> <TT
+CLASS="PARAMETER"
+><I
+>attr</I
+></TT
+> into <TT
+CLASS="PARAMETER"
+><I
+>value</I
+></TT
+>. This is useful after a call to <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+> to check whether your attributes have been <A
+HREF="sdlglsetattribute.html"
+>set</A
+> as you expected.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2229"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2234"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+>,
+<A
+HREF="sdlglattr.html"
+>GL Attributes</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglgetprocaddress.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglsetattribute.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GL_GetProcAddress</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GL_SetAttribute</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglgetprocaddress.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,251 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GL_GetProcAddress</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GL_LoadLibrary"
+HREF="sdlglloadlibrary.html"><LINK
+REL="NEXT"
+TITLE="SDL_GL_GetAttribute"
+HREF="sdlglgetattribute.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglloadlibrary.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglgetattribute.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLGETPROCADDRESS"
+>SDL_GL_GetProcAddress</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2180"
+></A
+><H2
+>Name</H2
+>SDL_GL_GetProcAddress&nbsp;--&nbsp;Get the address of a GL function</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2183"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2184"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void *<B
+CLASS="FSFUNC"
+>SDL_GL_GetProcAddress</B
+></CODE
+>(const char* proc);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2190"
+></A
+><H2
+>Description</H2
+><P
+>Returns the address of the GL function <TT
+CLASS="PARAMETER"
+><I
+>proc</I
+></TT
+>, or <SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+> if the function is not found. If the GL library is loaded at runtime, with <A
+HREF="sdlglloadlibrary.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_LoadLibrary</TT
+></A
+>, then <I
+CLASS="EMPHASIS"
+>all</I
+> GL functions must be retrieved this way. Usually this is used to retrieve function pointers to OpenGL extensions.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2198"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef void (*GL_ActiveTextureARB_Func)(unsigned int);
+GL_ActiveTextureARB_Func glActiveTextureARB_ptr = 0;
+int has_multitexture=1;
+.
+.
+.
+/* Get function pointer */
+glActiveTextureARB_ptr=(GL_ActiveTextureARB_Func) SDL_GL_GetProcAddress("glActiveTextureARB");
+
+/* Check for a valid function ptr */
+if(!glActiveTextureARB_ptr){
+  fprintf(stderr, "Multitexture Extensions not present.\n");
+  has_multitexture=0;
+}
+.
+.
+.
+.
+if(has_multitexture){
+  glActiveTextureARB_ptr(GL_TEXTURE0_ARB);
+  .
+  .
+}
+else{
+  .
+  .
+}</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2201"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlglloadlibrary.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_LoadLibrary</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglloadlibrary.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglgetattribute.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GL_LoadLibrary</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GL_GetAttribute</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglloadlibrary.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GL_LoadLibrary</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ShowCursor"
+HREF="sdlshowcursor.html"><LINK
+REL="NEXT"
+TITLE="SDL_GL_GetProcAddress"
+HREF="sdlglgetprocaddress.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlshowcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglgetprocaddress.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLLOADLIBRARY"
+>SDL_GL_LoadLibrary</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2150"
+></A
+><H2
+>Name</H2
+>SDL_GL_LoadLibrary&nbsp;--&nbsp;Specify an OpenGL library</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2153"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2154"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_GL_LoadLibrary</B
+></CODE
+>(const char *path);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2160"
+></A
+><H2
+>Description</H2
+><P
+>If you wish, you may load the OpenGL library at runtime, this must be done before <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+> is called. The <TT
+CLASS="PARAMETER"
+><I
+>path</I
+></TT
+> of the GL library is passed to <TT
+CLASS="FUNCTION"
+>SDL_GL_LoadLibrary</TT
+> and it returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error. You must then use <A
+HREF="sdlglgetprocaddress.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetProcAddress</TT
+></A
+> to retrieve function pointers to GL functions.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2171"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlglgetprocaddress.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetProcAddress</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlshowcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglgetprocaddress.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ShowCursor</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GL_GetProcAddress</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglsetattribute.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,278 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GL_SetAttribute</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GL_GetAttribute"
+HREF="sdlglgetattribute.html"><LINK
+REL="NEXT"
+TITLE="SDL_GL_SwapBuffers"
+HREF="sdlglswapbuffers.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglgetattribute.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglswapbuffers.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLSETATTRIBUTE"
+>SDL_GL_SetAttribute</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2244"
+></A
+><H2
+>Name</H2
+>SDL_GL_SetAttribute&nbsp;--&nbsp;Set a special SDL/OpenGL attribute</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2247"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2248"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_GL_SetAttribute</B
+></CODE
+>(SDL_GLattr attr, int value);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2254"
+></A
+><H2
+>Description</H2
+><P
+>Sets the OpenGL <A
+HREF="sdlglattr.html"
+>attribute</A
+> <TT
+CLASS="PARAMETER"
+><I
+>attr</I
+></TT
+> to <TT
+CLASS="PARAMETER"
+><I
+>value</I
+></TT
+>. The attributes you set don't take effect until after a call to <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>. You should use <A
+HREF="sdlglgetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetAttribute</TT
+></A
+> to check the values after a <TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+> call.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2265"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2270"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+if ( (screen=SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL )) == NULL ) {
+  fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
+  SDL_Quit();
+  return;
+}</PRE
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>The <TT
+CLASS="LITERAL"
+>SDL_DOUBLEBUF</TT
+> flag is not required to enable double buffering when setting an OpenGL video mode. Double buffering is enabled or disabled using the SDL_GL_DOUBLEBUFFER attribute.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2276"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlglgetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_GetAttribute</TT
+></A
+>,
+<A
+HREF="sdlglattr.html"
+>GL Attributes</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglgetattribute.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglswapbuffers.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GL_GetAttribute</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GL_SwapBuffers</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlglswapbuffers.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,204 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_GL_SwapBuffers</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GL_SetAttribute"
+HREF="sdlglsetattribute.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateYUVOverlay"
+HREF="sdlcreateyuvoverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglsetattribute.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreateyuvoverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLGLSWAPBUFFERS"
+>SDL_GL_SwapBuffers</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2286"
+></A
+><H2
+>Name</H2
+>SDL_GL_SwapBuffers&nbsp;--&nbsp;Swap OpenGL framebuffers/Update Display</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2289"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2290"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_GL_SwapBuffers</B
+></CODE
+>(void );</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2296"
+></A
+><H2
+>Description</H2
+><P
+>Swap the OpenGL buffers, if double-buffering is supported.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2299"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglsetattribute.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreateyuvoverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GL_SetAttribute</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateYUVOverlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlinit.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,360 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Init</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="General"
+HREF="general.html"><LINK
+REL="PREVIOUS"
+TITLE="General"
+HREF="general.html"><LINK
+REL="NEXT"
+TITLE="SDL_InitSubSystem"
+HREF="sdlinitsubsystem.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="general.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlinitsubsystem.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLINIT"
+>SDL_Init</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN401"
+></A
+><H2
+>Name</H2
+>SDL_Init&nbsp;--&nbsp;Initializes SDL</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN404"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN405"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_Init</B
+></CODE
+>(Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN411"
+></A
+><H2
+>Description</H2
+><P
+>Initializes SDL. This should be called before all other SDL functions. The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> parameter specifies what part(s) of SDL to initialize.</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN415"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_TIMER</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initializes the <A
+HREF="time.html"
+>timer</A
+> subsystem.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_AUDIO</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initializes the <A
+HREF="audio.html"
+>audio</A
+> subsystem.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_VIDEO</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initializes the <A
+HREF="video.html"
+>video</A
+> subsystem.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_CDROM</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initializes the <A
+HREF="cdrom.html"
+>cdrom</A
+> subsystem.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_JOYSTICK</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initializes the <A
+HREF="joystick.html"
+>joystick</A
+> subsystem.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_EVERYTHING</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Initialize all of the above.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_NOPARACHUTE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Prevents SDL from catching fatal signals.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_INIT_EVENTTHREAD</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN455"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN460"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlquit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+></A
+>,
+<A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="general.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlinitsubsystem.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>General</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="general.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_InitSubSystem</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlinitsubsystem.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,275 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_InitSubSystem</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="General"
+HREF="general.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Init"
+HREF="sdlinit.html"><LINK
+REL="NEXT"
+TITLE="SDL_QuitSubSystem"
+HREF="sdlquitsubsystem.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlquitsubsystem.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLINITSUBSYSTEM"
+>SDL_InitSubSystem</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN471"
+></A
+><H2
+>Name</H2
+>SDL_InitSubSystem&nbsp;--&nbsp;Initialize subsystems</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN474"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN475"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_InitSubSystem</B
+></CODE
+>(Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN481"
+></A
+><H2
+>Description</H2
+><P
+>After SDL has been initialized with <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+> you may initialize uninitialized subsystems with <TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+>. The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> parameter is the same as that used in <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN490"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Seperating Joystick and Video initialization. */
+SDL_Init(SDL_INIT_VIDEO);
+.
+.
+SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN);
+.
+/* Do Some Video stuff */
+.
+.
+/* Initialize the joystick subsystem */
+SDL_InitSubSystem(SDL_INIT_JOYSTICK);
+
+/* Do some stuff with video and joystick */
+.
+.
+.
+/* Shut them both down */
+SDL_Quit();</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN493"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN498"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>,
+<A
+HREF="sdlquit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+></A
+>,
+<A
+HREF="sdlquitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_QuitSubSystem</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlquitsubsystem.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Init</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="general.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_QuitSubSystem</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoyaxisevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,322 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoyAxisEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_MouseButtonEvent"
+HREF="sdlmousebuttonevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoyButtonEvent"
+HREF="sdljoybuttonevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmousebuttonevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoybuttonevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYAXISEVENT"
+>SDL_JoyAxisEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3695"
+></A
+><H2
+>Name</H2
+>SDL_JoyAxisEvent&nbsp;--&nbsp;Joystick axis motion event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3698"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 axis;
+  Sint16 value;
+} SDL_JoyAxisEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3701"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3703"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYAXISMOTION</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick device index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>axis</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick axis index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>value</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Axis value (range: -32768 to 32767)</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3723"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyAxisEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_JOYAXISMOTION</TT
+> is reported.</P
+><P
+>A <TT
+CLASS="LITERAL"
+>SDL_JOYAXISMOTION</TT
+> event occurs when ever a user moves an axis on the joystick. The field <TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+> is the index of the joystick that reported the event and <TT
+CLASS="STRUCTFIELD"
+><I
+>axis</I
+></TT
+> is the index of the axis (for a more detailed explaination see the <A
+HREF="joystick.html"
+>Joystick section</A
+>). <TT
+CLASS="STRUCTFIELD"
+><I
+>value</I
+></TT
+> is the current position of the axis.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3736"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="joystick.html"
+>Joystick Functions</A
+>,
+<A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+>,
+<A
+HREF="sdljoystickgetaxis.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetAxis</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmousebuttonevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoybuttonevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_MouseButtonEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoyButtonEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoyballevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,332 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoyBallEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoyHatEvent"
+HREF="sdljoyhatevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_ResizeEvent"
+HREF="sdlresizeevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoyhatevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlresizeevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYBALLEVENT"
+>SDL_JoyBallEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3888"
+></A
+><H2
+>Name</H2
+>SDL_JoyBallEvent&nbsp;--&nbsp;Joystick trackball motion event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3891"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 ball;
+  Sint16 xrel, yrel;
+} SDL_JoyBallEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3894"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3896"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYBALLMOTION</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick device index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>ball</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick trackball index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>xrel</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>yrel</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The relative motion in the X/Y direction</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3917"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyBallEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_JOYBALLMOTION</TT
+> is reported.</P
+><P
+>A <TT
+CLASS="LITERAL"
+>SDL_JOYBALLMOTION</TT
+> event occurs when a user moves a trackball on the joystick. The field <TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+> is the index of the joystick that reported the event and <TT
+CLASS="STRUCTFIELD"
+><I
+>ball</I
+></TT
+> is the index of the trackball (for a more detailed explaination see the <A
+HREF="joystick.html"
+>Joystick section</A
+>). Trackballs only return relative motion, this is the change in position on the ball since it was last polled (last cycle of the event loop) and it is stored in <TT
+CLASS="STRUCTFIELD"
+><I
+>xrel</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>yrel</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3931"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="joystick.html"
+>Joystick Functions</A
+>,
+<A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+>,
+<A
+HREF="sdljoystickgetball.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetBall</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoyhatevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlresizeevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoyHatEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ResizeEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoybuttonevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,343 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoyButtonEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoyAxisEvent"
+HREF="sdljoyaxisevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoyHatEvent"
+HREF="sdljoyhatevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoyaxisevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoyhatevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYBUTTONEVENT"
+>SDL_JoyButtonEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3750"
+></A
+><H2
+>Name</H2
+>SDL_JoyButtonEvent&nbsp;--&nbsp;Joystick button event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3753"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 button;
+  Uint8 state;
+} SDL_JoyButtonEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3756"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3758"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONUP</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick device index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>button</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick button index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3781"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyButtonEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONUP</TT
+> is reported.</P
+><P
+>A <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_JOYBUTTONUP</TT
+> event occurs when ever a user presses or releases a button on a joystick. The field <TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+> is the index of the joystick that reported the event and <TT
+CLASS="STRUCTFIELD"
+><I
+>button</I
+></TT
+> is the index of the button (for a more detailed explaination see the <A
+HREF="joystick.html"
+>Joystick section</A
+>). <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+> is the current state or the button which is either <TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3798"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="joystick.html"
+>Joystick Functions</A
+>,
+<A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+>,
+<A
+HREF="sdljoystickgetbutton.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetButton</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoyaxisevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoyhatevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoyAxisEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoyHatEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoyhatevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,405 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoyHatEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoyButtonEvent"
+HREF="sdljoybuttonevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoyBallEvent"
+HREF="sdljoyballevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoybuttonevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoyballevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYHATEVENT"
+>SDL_JoyHatEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3812"
+></A
+><H2
+>Name</H2
+>SDL_JoyHatEvent&nbsp;--&nbsp;Joystick hat position change event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3815"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 hat;
+  Uint8 value;
+} SDL_JoyHatEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3818"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3820"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_JOY</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick device index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>hat</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Joystick hat index</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>value</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Hat position</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3840"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyHatEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_JOYHATMOTION</TT
+> is reported.</P
+><P
+>A <TT
+CLASS="LITERAL"
+>SDL_JOYHATMOTION</TT
+> event occurs when ever a user moves a hat on the joystick. The field <TT
+CLASS="STRUCTFIELD"
+><I
+>which</I
+></TT
+> is the index of the joystick that reported the event and <TT
+CLASS="STRUCTFIELD"
+><I
+>hat</I
+></TT
+> is the index of the hat (for a more detailed exlaination see the <A
+HREF="joystick.html"
+>Joystick section</A
+>). <TT
+CLASS="STRUCTFIELD"
+><I
+>value</I
+></TT
+> is the current position of the hat. It is a logically OR'd combination of the following values (whose meanings should be pretty obvious:) :</P
+><P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_CENTERED</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_UP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHT</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_DOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFT</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+><P
+>The following defines are also provided:</P
+><P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTDOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTDOWN</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3874"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="joystick.html"
+>Joystick Functions</A
+>,
+<A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+>,
+<A
+HREF="sdljoystickgetball.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetHat</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoybuttonevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoyballevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoyButtonEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoyBallEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickclose.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,215 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickClose</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickGetBall"
+HREF="sdljoystickgetball.html"><LINK
+REL="NEXT"
+TITLE="Audio"
+HREF="audio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetball.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="audio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKCLOSE"
+>SDL_JoystickClose</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5847"
+></A
+><H2
+>Name</H2
+>SDL_JoystickClose&nbsp;--&nbsp;Closes a previously opened joystick</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5850"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5851"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_JoystickClose</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5857"
+></A
+><H2
+>Description</H2
+><P
+>Close a <TT
+CLASS="PARAMETER"
+><I
+>joystick</I
+></TT
+> that was previously opened with <A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5863"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+>,
+<A
+HREF="sdljoystickopened.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpened</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickgetball.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickGetBall</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Audio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickeventstate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,282 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickEventState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetAppState"
+HREF="sdlgetappstate.html"><LINK
+REL="NEXT"
+TITLE="Joystick"
+HREF="joystick.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetappstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="joystick.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKEVENTSTATE"
+>SDL_JoystickEventState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5347"
+></A
+><H2
+>Name</H2
+>SDL_JoystickEventState&nbsp;--&nbsp;Enable/disable joystick event polling</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5350"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5351"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickEventState</B
+></CODE
+>(int state);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5357"
+></A
+><H2
+>Description</H2
+><P
+>This function is used to enable or disable joystick event processing. With joystick event processing disabled you will have to update joystick states with <A
+HREF="sdljoystickupdate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickUpdate</TT
+></A
+> and read the joystick information manually. <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is either <TT
+CLASS="LITERAL"
+>SDL_QUERY</TT
+>, <TT
+CLASS="LITERAL"
+>SDL_ENABLE</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_IGNORE</TT
+>.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Joystick event handling is prefered</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5368"
+></A
+><H2
+>Return Value</H2
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_QUERY</TT
+> then the current state is returned, otherwise the new processing <TT
+CLASS="PARAMETER"
+><I
+>state</I
+></TT
+> is returned.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5374"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="joystick.html"
+>SDL Joystick Functions</A
+>,
+<A
+HREF="sdljoystickupdate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickUpdate</TT
+></A
+>,
+<A
+HREF="sdljoyaxisevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyAxisEvent</SPAN
+></A
+>,
+<A
+HREF="sdljoyballevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyBallEvent</SPAN
+></A
+>,
+<A
+HREF="sdljoybuttonevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyButtonEvent</SPAN
+></A
+>,
+<A
+HREF="sdljoyhatevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_JoyHatEvent</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetappstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetAppState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Joystick</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickgetaxis.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,263 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickGetAxis</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickUpdate"
+HREF="sdljoystickupdate.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickGetHat"
+HREF="sdljoystickgethat.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickupdate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgethat.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKGETAXIS"
+>SDL_JoystickGetAxis</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5698"
+></A
+><H2
+>Name</H2
+>SDL_JoystickGetAxis&nbsp;--&nbsp;Get the current state of an axis</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5701"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5702"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Sint16 <B
+CLASS="FSFUNC"
+>SDL_JoystickGetAxis</B
+></CODE
+>(SDL_Joystick *joystick, int axis);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5708"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetAxis</TT
+> returns the current state of the given <TT
+CLASS="PARAMETER"
+><I
+>axis</I
+></TT
+> on the given <TT
+CLASS="PARAMETER"
+><I
+>joystick</I
+></TT
+>.</P
+><P
+>On most modern joysticks the X axis is usually represented by <TT
+CLASS="PARAMETER"
+><I
+>axis</I
+></TT
+> 0 and the Y axis by <TT
+CLASS="PARAMETER"
+><I
+>axis</I
+></TT
+> 1. The value returned by <TT
+CLASS="FUNCTION"
+>SDL_JoystickGetAxis</TT
+> is a signed integer (-32768 to 32768) representing the current position of the <TT
+CLASS="PARAMETER"
+><I
+>axis</I
+></TT
+>, it maybe necessary to impose certain tolerances on these values to account for jitter. It is worth noting that some joysticks use axes 2 and 3 for extra buttons.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5719"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a 16-bit signed integer representing the current position of the <TT
+CLASS="PARAMETER"
+><I
+>axis</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5723"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>Sint16 x_move, y_move;
+SDL_Joystick *joy1;
+.
+.
+x_move=SDL_JoystickGetAxis(joy1, 0);
+y_move=SDL_JoystickGetAxis(joy1, 1);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5727"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoysticknumaxes.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumAxes</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickupdate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickgethat.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickUpdate</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickGetHat</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickgetball.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,254 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickGetBall</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickGetButton"
+HREF="sdljoystickgetbutton.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickClose"
+HREF="sdljoystickclose.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetbutton.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickclose.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKGETBALL"
+>SDL_JoystickGetBall</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5811"
+></A
+><H2
+>Name</H2
+>SDL_JoystickGetBall&nbsp;--&nbsp;Get relative trackball motion</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5814"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5815"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickGetBall</B
+></CODE
+>(SDL_Joystick *joystick, int ball, int *dx, int *dy);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5821"
+></A
+><H2
+>Description</H2
+><P
+>Get the <TT
+CLASS="PARAMETER"
+><I
+>ball</I
+></TT
+> axis change.</P
+><P
+>Trackballs can only return relative motion since the last call to <TT
+CLASS="FUNCTION"
+>SDL_JoystickGetBall</TT
+>, these motion deltas a placed into <TT
+CLASS="PARAMETER"
+><I
+>dx</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>dy</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5829"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on failure</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5834"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>int delta_x, delta_y;
+SDL_Joystick *joy;
+.
+.
+.
+SDL_JoystickUpdate();
+if(SDL_JoystickGetBall(joy, 0, &#38;delta_x, &#38;delta_y)==-1)
+  printf("TrackBall Read Error!\n");
+printf("Trackball Delta- X:%d, Y:%d\n", delta_x, delta_y);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5838"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoysticknumballs.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumBalls</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickgetbutton.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickclose.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickGetButton</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickClose</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickgetbutton.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickGetButton</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickGetHat"
+HREF="sdljoystickgethat.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickGetBall"
+HREF="sdljoystickgetball.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgethat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetball.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKGETBUTTON"
+>SDL_JoystickGetButton</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5782"
+></A
+><H2
+>Name</H2
+>SDL_JoystickGetButton&nbsp;--&nbsp;Get the current state of a given button on a given joystick</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5785"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5786"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_JoystickGetButton</B
+></CODE
+>(SDL_Joystick *joystick, int button);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5792"
+></A
+><H2
+>Description</H2
+><P
+>SDL_JoystickGetButton returns the current state of the given <TT
+CLASS="PARAMETER"
+><I
+>button</I
+></TT
+> on the given <TT
+CLASS="PARAMETER"
+><I
+>joystick</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5797"
+></A
+><H2
+>Return Value</H2
+><P
+><SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+> if the button is pressed. Otherwise, <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5802"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoysticknumbuttons.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumButtons</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickgethat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickgetball.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickGetHat</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickGetBall</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickgethat.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,289 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickGetHat</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickGetAxis"
+HREF="sdljoystickgetaxis.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickGetButton"
+HREF="sdljoystickgetbutton.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetaxis.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetbutton.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKGETHAT"
+>SDL_JoystickGetHat</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5736"
+></A
+><H2
+>Name</H2
+>SDL_JoystickGetHat&nbsp;--&nbsp;Get the current state of a joystick hat</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5739"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5740"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint8 <B
+CLASS="FSFUNC"
+>SDL_JoystickGetHat</B
+></CODE
+>(SDL_Joystick *joystick, int hat);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5746"
+></A
+><H2
+>Description</H2
+><P
+>SDL_JoystickGetHat returns the current state of the given <TT
+CLASS="PARAMETER"
+><I
+>hat</I
+></TT
+> on the given <TT
+CLASS="PARAMETER"
+><I
+>joystick</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5751"
+></A
+><H2
+>Return Value</H2
+><P
+>The current state is returned as a Uint8 which is defined as an OR'd combination of one or more of the following</P
+><P
+></P
+><TABLE
+BORDER="0"
+><TBODY
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_CENTERED</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_UP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHT</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_DOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFT</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_RIGHTDOWN</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTUP</TT
+></TD
+></TR
+><TR
+><TD
+><TT
+CLASS="LITERAL"
+>SDL_HAT_LEFTDOWN</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5773"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoysticknumhats.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickNumHats</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickgetaxis.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickgetbutton.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickGetAxis</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickGetButton</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickindex.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,210 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickIndex</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickOpened"
+HREF="sdljoystickopened.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickNumAxes"
+HREF="sdljoysticknumaxes.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickopened.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumaxes.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKINDEX"
+>SDL_JoystickIndex</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5536"
+></A
+><H2
+>Name</H2
+>SDL_JoystickIndex&nbsp;--&nbsp;Get the index of an SDL_Joystick.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5539"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5540"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickIndex</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5546"
+></A
+><H2
+>Description</H2
+><P
+>Returns the index of a given <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+> structure.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5550"
+></A
+><H2
+>Return Value</H2
+><P
+>Index number of the joystick.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5553"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickopened.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoysticknumaxes.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickOpened</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickNumAxes</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickname.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,230 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickName</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_NumJoysticks"
+HREF="sdlnumjoysticks.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickOpen"
+HREF="sdljoystickopen.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlnumjoysticks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickopen.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKNAME"
+>SDL_JoystickName</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5444"
+></A
+><H2
+>Name</H2
+>SDL_JoystickName&nbsp;--&nbsp;Get joystick name.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5447"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5448"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>const char *<B
+CLASS="FSFUNC"
+>SDL_JoystickName</B
+></CODE
+>(int index);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5454"
+></A
+><H2
+>Description</H2
+><P
+>Get the implementation dependent name of joystick. The <TT
+CLASS="PARAMETER"
+><I
+>index</I
+></TT
+> parameter refers to the N'th joystick on the system.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5458"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a char pointer to the joystick name.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5461"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Print the names of all attached joysticks */
+int num_joy, i;
+num_joy=SDL_NumJoysticks();
+printf("%d joysticks found\n", num_joy);
+for(i=0;i&#60;num_joy;i++)
+  printf("%s\n", SDL_JoystickName(i);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5465"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlnumjoysticks.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickopen.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_NumJoysticks</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickOpen</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoysticknumaxes.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickNumAxes</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickIndex"
+HREF="sdljoystickindex.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickNumBalls"
+HREF="sdljoysticknumballs.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickindex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumballs.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKNUMAXES"
+>SDL_JoystickNumAxes</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5562"
+></A
+><H2
+>Name</H2
+>SDL_JoystickNumAxes&nbsp;--&nbsp;Get the number of joystick axes</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5565"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5566"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickNumAxes</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5572"
+></A
+><H2
+>Description</H2
+><P
+>Return the number of axes available from a previously opened <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5576"
+></A
+><H2
+>Return Value</H2
+><P
+>Number of axes.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5579"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickgetaxis.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetAxis</TT
+></A
+>,
+<A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickindex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoysticknumballs.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickIndex</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickNumBalls</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoysticknumballs.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickNumBalls</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickNumAxes"
+HREF="sdljoysticknumaxes.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickNumHats"
+HREF="sdljoysticknumhats.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumaxes.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumhats.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKNUMBALLS"
+>SDL_JoystickNumBalls</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5590"
+></A
+><H2
+>Name</H2
+>SDL_JoystickNumBalls&nbsp;--&nbsp;Get the number of joystick trackballs</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5593"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5594"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickNumBalls</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5600"
+></A
+><H2
+>Description</H2
+><P
+>Return the number of trackballs available from a previously opened <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5604"
+></A
+><H2
+>Return Value</H2
+><P
+>Number of trackballs.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5607"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickgetball.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetBall</TT
+></A
+>,
+<A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoysticknumaxes.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoysticknumhats.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickNumAxes</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickNumHats</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoysticknumbuttons.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickNumButtons</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickNumHats"
+HREF="sdljoysticknumhats.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickUpdate"
+HREF="sdljoystickupdate.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumhats.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickupdate.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKNUMBUTTONS"
+>SDL_JoystickNumButtons</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5646"
+></A
+><H2
+>Name</H2
+>SDL_JoystickNumButtons&nbsp;--&nbsp;Get the number of joysitck buttons</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5649"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5650"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickNumButtons</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5656"
+></A
+><H2
+>Description</H2
+><P
+>Return the number of buttons available from a previously opened <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5660"
+></A
+><H2
+>Return Value</H2
+><P
+>Number of buttons.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5663"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickgetbutton.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetButton</TT
+></A
+>,
+<A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoysticknumhats.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickupdate.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickNumHats</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickUpdate</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoysticknumhats.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickNumHats</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickNumBalls"
+HREF="sdljoysticknumballs.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickNumButtons"
+HREF="sdljoysticknumbuttons.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumballs.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumbuttons.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKNUMHATS"
+>SDL_JoystickNumHats</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5618"
+></A
+><H2
+>Name</H2
+>SDL_JoystickNumHats&nbsp;--&nbsp;Get the number of joystick hats</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5621"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5622"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickNumHats</B
+></CODE
+>(SDL_Joystick *joystick);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5628"
+></A
+><H2
+>Description</H2
+><P
+>Return the number of hats available from a previously opened <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5632"
+></A
+><H2
+>Return Value</H2
+><P
+>Number of hats.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5635"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickgethat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickGetHat</TT
+></A
+>,
+<A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoysticknumballs.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoysticknumbuttons.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickNumBalls</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickNumButtons</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickopen.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,251 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickOpen</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickName"
+HREF="sdljoystickname.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickOpened"
+HREF="sdljoystickopened.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickopened.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKOPEN"
+>SDL_JoystickOpen</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5474"
+></A
+><H2
+>Name</H2
+>SDL_JoystickOpen&nbsp;--&nbsp;Opens a joystick for use.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5477"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5478"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Joystick *<B
+CLASS="FSFUNC"
+>SDL_JoystickOpen</B
+></CODE
+>(int index);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5484"
+></A
+><H2
+>Description</H2
+><P
+>Opens a joystick for use within SDL. The <TT
+CLASS="PARAMETER"
+><I
+>index</I
+></TT
+> refers to the N'th joystick in the system. A joystick must be opened before it game be used.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5488"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a <SPAN
+CLASS="STRUCTNAME"
+>SDL_Joystick</SPAN
+> structure on success. <SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+> on failure.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5493"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_Joystick *joy;
+// Check for joystick
+if(SDL_NumJoysticks()&#62;0){
+  // Open joystick
+  joy=SDL_JoystickOpen(0);
+  
+  if(joy)
+  {
+    printf("Opened Joystick 0\n");
+    printf("Name: %s\n", SDL_JoystickName(0));
+    printf("Number of Axes: %s\n", SDL_JoystickNumAxes(joy));
+    printf("Number of Buttons: %s\n", SDL_JoystickNumButtons(joy));
+    printf("Number of Balls: %s\n", SDL_JoystickNumBalls(joy));
+  }
+  else
+    printf("Couldn't open Joystick 0\n");
+  
+  // Close if opened
+  if(SDL_JoystickOpened(0))
+    SDL_JoystickClose(joy);
+}</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5497"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickclose.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickClose</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickname.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickopened.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickName</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickOpened</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickopened.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,225 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickOpened</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickOpen"
+HREF="sdljoystickopen.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickIndex"
+HREF="sdljoystickindex.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoystickopen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickindex.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKOPENED"
+>SDL_JoystickOpened</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5506"
+></A
+><H2
+>Name</H2
+>SDL_JoystickOpened&nbsp;--&nbsp;Determine if a joystick has been opened</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5509"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5510"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_JoystickOpened</B
+></CODE
+>(int index);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5516"
+></A
+><H2
+>Description</H2
+><P
+>Determines whether a joystick has already been opened within the application. <TT
+CLASS="PARAMETER"
+><I
+>index</I
+></TT
+> refers to the N'th joystick on the system.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5520"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+> if the joystick has been opened, or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if it has not.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5525"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+>,
+<A
+HREF="sdljoystickclose.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickClose</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoystickopen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickindex.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickOpen</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickIndex</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdljoystickupdate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,203 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_JoystickUpdate</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoystickNumButtons"
+HREF="sdljoysticknumbuttons.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickGetAxis"
+HREF="sdljoystickgetaxis.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoysticknumbuttons.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickgetaxis.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLJOYSTICKUPDATE"
+>SDL_JoystickUpdate</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5674"
+></A
+><H2
+>Name</H2
+>SDL_JoystickUpdate&nbsp;--&nbsp;Updates the state of all joysticks</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5677"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5678"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_JoystickUpdate</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5684"
+></A
+><H2
+>Description</H2
+><P
+>Updates the state(position, buttons, etc.) of all open joysticks. If joystick events have been enabled with <A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+> then this is called automatically in the event loop.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5689"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickeventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickEventState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoysticknumbuttons.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickgetaxis.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoystickNumButtons</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickGetAxis</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlkey.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2622 @@
+<HTML
+><HEAD
+><TITLE
+>SDLKey</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_keysym"
+HREF="sdlkeysym.html"><LINK
+REL="NEXT"
+TITLE="Event Functions."
+HREF="eventfunctions.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlkeysym.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="eventfunctions.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLKEY"
+>SDLKey</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4171"
+></A
+><H2
+>Name</H2
+>SDLKey&nbsp;--&nbsp;Keysym definitions.</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4174"
+></A
+><H2
+>Description</H2
+><P
+>&#13;<DIV
+CLASS="TABLE"
+><A
+NAME="AEN4177"
+></A
+><P
+><B
+>Table 8-1. SDL Keysym definitions</B
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><THEAD
+><TR
+><TH
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLKey</TH
+><TH
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>ASCII value</TH
+><TH
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Common name</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_BACKSPACE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'\b'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>backspace</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_TAB</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'\t'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>tab</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_CLEAR</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>clear</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RETURN</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'\r'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>return</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PAUSE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>pause</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_ESCAPE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'^['</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>escape</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_SPACE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>' '</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>space</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_EXCLAIM</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'!'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>exclaim</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_QUOTEDBL</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'"'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>quotedbl</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_HASH</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'#'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>hash</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_DOLLAR</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'$'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>dollar</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_AMPERSAND</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'&#38;'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>ampersand</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_QUOTE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'''</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>quote</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LEFTPAREN</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'('</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left parenthesis</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RIGHTPAREN</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>')'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right parenthesis</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_ASTERISK</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'*'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>asterisk</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PLUS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'+'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>plus sign</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_COMMA</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>','</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>comma</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_MINUS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'-'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>minus sign</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PERIOD</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'.'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>period</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_SLASH</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'/'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>forward slash</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_0</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'0'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>0</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_1</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'1'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>1</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_2</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'2'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>2</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_3</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'3'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>3</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_4</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'4'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>4</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_5</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'5'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>5</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_6</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'6'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>6</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_7</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'7'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>7</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_8</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'8'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>8</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_9</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'9'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>9</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_COLON</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>':'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>colon</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_SEMICOLON</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>';'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>semicolon</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LESS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'&lt;'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>less-than sign</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_EQUALS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'='</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>equals sign</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_GREATER</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'&gt;'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>greater-than sign</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_QUESTION</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'?'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>question mark</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_AT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'@'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>at</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LEFTBRACKET</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'['</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left bracket</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_BACKSLASH</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'\'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>backslash</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RIGHTBRACKET</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>']'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right bracket</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_CARET</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'^'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>caret</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_UNDERSCORE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'_'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>underscore</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_BACKQUOTE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'`'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>grave</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_a</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'a'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>a</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_b</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'b'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>b</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_c</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'c'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>c</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_d</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'d'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>d</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_e</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'e'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>e</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_f</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'f'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>f</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_g</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'g'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>g</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_h</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'h'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>h</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_i</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'i'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>i</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_j</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'j'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>j</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_k</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'k'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>k</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_l</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'l'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>l</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_m</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'m'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>m</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_n</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'n'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>n</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_o</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'o'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>o</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_p</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'p'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>p</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_q</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'q'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>q</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_r</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'r'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>r</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_s</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'s'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>s</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_t</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'t'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>t</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_u</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'u'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>u</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_v</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'v'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>v</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_w</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'w'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>w</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_x</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'x'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>x</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_y</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'y'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>y</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_z</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'z'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>z</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_DELETE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'^?'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>delete</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP0</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 0</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP1</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 1</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP2</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 2</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP3</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 3</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP4</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 4</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP5</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 5</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP6</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 6</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP7</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 7</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP8</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 8</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP9</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad 9</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_PERIOD</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'.'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad period</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_DIVIDE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'/'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad divide</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_MULTIPLY</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'*'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad multiply</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_MINUS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'-'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad minus</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_PLUS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'+'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad plus</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_ENTER</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'\r'</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad enter</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_KP_EQUALS</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>'='</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>keypad equals</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_UP</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>up arrow</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_DOWN</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>down arrow</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RIGHT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right arrow</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LEFT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left arrow</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_INSERT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>insert</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_HOME</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>home</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_END</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>end</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PAGEUP</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>page up</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PAGEDOWN</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>page down</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F1</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F1</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F2</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F2</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F3</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F3</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F4</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F4</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F5</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F5</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F6</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F6</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F7</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F7</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F8</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F8</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F9</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F9</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F10</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F10</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F11</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F11</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F12</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F12</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F13</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F13</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F14</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F14</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_F15</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>F15</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_NUMLOCK</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>numlock</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_CAPSLOCK</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>capslock</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_SCROLLOCK</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>scrollock</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RSHIFT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right shift</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LSHIFT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left shift</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RCTRL</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right ctrl</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LCTRL</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left ctrl</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RALT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right alt</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LALT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left alt</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RMETA</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right meta</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LMETA</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left meta</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_LSUPER</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>left windows key</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_RSUPER</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>right windows key</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_MODE</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>mode shift</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_HELP</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>help</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_PRINT</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>print-screen</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_SYSREQ</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SysRq</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_BREAK</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>break</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_MENU</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>menu</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_POWER</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>power</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDLK_EURO</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>&nbsp;</TD
+><TD
+WIDTH="33%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>euro</TD
+></TR
+></TBODY
+></TABLE
+></DIV
+>
+
+<DIV
+CLASS="TABLE"
+><A
+NAME="SDLMOD"
+></A
+><P
+><B
+>Table 8-2. SDL modifier definitions</B
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><THEAD
+><TR
+><TH
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDL Modifier</TH
+><TH
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Meaning</TH
+></TR
+></THEAD
+><TBODY
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_NONE</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>No modifiers applicable</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_NUM</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Numlock is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_CAPS</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Capslock is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_LCTRL</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Left Control is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_RCTRL</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Right Control is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_RSHIFT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Right Shift is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_LSHIFT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Left Shift is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_RALT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Right Alt is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_LALT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>Left Alt is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_CTRL</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>A Control key is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_SHIFT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>A Shift key is down</TD
+></TR
+><TR
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>KMOD_ALT</TD
+><TD
+WIDTH="50%"
+ALIGN="LEFT"
+VALIGN="TOP"
+>An Alt key is down</TD
+></TR
+></TBODY
+></TABLE
+></DIV
+>&#13;</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlkeysym.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_keysym</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Event Functions.</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlkeyboardevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,367 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_KeyboardEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ActiveEvent"
+HREF="sdlactiveevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_MouseMotionEvent"
+HREF="sdlmousemotionevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlactiveevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmousemotionevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLKEYBOARDEVENT"
+>SDL_KeyboardEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3503"
+></A
+><H2
+>Name</H2
+>SDL_KeyboardEvent&nbsp;--&nbsp;Keyboard event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3506"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 state;
+  SDL_keysym keysym;
+} SDL_KeyboardEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3509"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3511"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_KEYUP</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>keysym</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Contains key press information</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3530"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_KEYUP</TT
+> is reported.</P
+><P
+>The <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+> actually report the same information, they just use different values to do it! A keyboard event occurs when a key is released (<TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+>=<TT
+CLASS="LITERAL"
+>SDK_KEYUP</TT
+> or <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+>=<TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+>) and when a key is pressed (<TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+>=<TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+> or <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+>=<TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+>). The information on what key was pressed or released is in the <A
+HREF="sdlkeysym.html"
+><SPAN
+CLASS="STRUCTNAME"
+>keysym</SPAN
+></A
+> structure.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Repeating <TT
+CLASS="LITERAL"
+>SDL_KEYDOWN</TT
+> events will occur if key repeat is enabled (see <A
+HREF="sdlenablekeyrepeat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EnableKeyRepeat</TT
+></A
+>).</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3556"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlkeysym.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+></A
+>,
+<A
+HREF="sdlenablekeyrepeat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EnableKeyRepeat</TT
+></A
+>,
+<A
+HREF="sdlenableunicode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EnableUNICODE</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlactiveevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmousemotionevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ActiveEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_MouseMotionEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlkeysym.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,347 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_keysym</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_QuitEvent"
+HREF="sdlquitevent.html"><LINK
+REL="NEXT"
+TITLE="SDLKey"
+HREF="sdlkey.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlquitevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlkey.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLKEYSYM"
+>SDL_keysym</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4116"
+></A
+><H2
+>Name</H2
+>SDL_keysym&nbsp;--&nbsp;Keysym structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4119"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 scancode;
+  SDLKey sym;
+  SDLMod mod;
+  Uint16 unicode;
+} SDL_keysym;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4122"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN4124"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>scancode</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Hardware specific scancode</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>sym</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDL virtual keysym</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>mod</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Current key modifiers</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>unicode</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Translated character</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4143"
+></A
+><H2
+>Description</H2
+><P
+>The <SPAN
+CLASS="STRUCTNAME"
+>SDL_keysym</SPAN
+> structure is used by reporting key presses and releases since it is a part of the <A
+HREF="sdlkeyboardevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+></A
+>.</P
+><P
+>The <TT
+CLASS="STRUCTFIELD"
+><I
+>scancode</I
+></TT
+> field should generally be left alone, it is the hardware dependent scancode returned by the keyboard. The <TT
+CLASS="STRUCTFIELD"
+><I
+>sym</I
+></TT
+> field is extremely useful. It is the SDL-defined value of the key (see <A
+HREF="sdlkey.html"
+>SDL Key Syms</A
+>. This field is very useful when you are checking for certain key presses, like so:
+<PRE
+CLASS="PROGRAMLISTING"
+>.
+.
+while(SDL_PollEvent(&#38;event)){
+  switch(event.type){
+    case SDL_KEYDOWN:
+      if(event.key.keysym.sym==SDLK_LEFT)
+        move_left();
+      break;
+    .
+    .
+    .
+  }
+}
+.
+.</PRE
+>
+<TT
+CLASS="STRUCTFIELD"
+><I
+>mod</I
+></TT
+> stores the current state of the keyboard modifiers as explained in <A
+HREF="sdlgetmodstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetModState</TT
+></A
+>. The <TT
+CLASS="STRUCTFIELD"
+><I
+>unicode</I
+></TT
+> is only used when UNICODE translation is enabled with <A
+HREF="sdlenableunicode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EnableUNICODE</TT
+></A
+>. If <TT
+CLASS="STRUCTFIELD"
+><I
+>unicode</I
+></TT
+> is non-zero then this a the UNICODE character corresponding to the keypress. If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character:
+<PRE
+CLASS="PROGRAMLISTING"
+>char ch;
+if ( (keysym.unicode &#38; 0xFF80) == 0 ) {
+  ch = keysym.unicode &#38; 0x7F;
+}
+else {
+  printf("An International Character.\n");
+}</PRE
+>
+UNICODE translation does have a slight overhead so don't enable it unless its needed.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4162"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlkey.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDLKey</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlquitevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlkey.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_QuitEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDLKey</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlkillthread.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,215 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_KillThread</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WaitThread"
+HREF="sdlwaitthread.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateMutex"
+HREF="sdlcreatemutex.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwaitthread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatemutex.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLKILLTHREAD"
+>SDL_KillThread</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7169"
+></A
+><H2
+>Name</H2
+>SDL_KillThread&nbsp;--&nbsp;Gracelessly terminates the thread.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7172"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7173"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_KillThread</B
+></CODE
+>(SDL_Thread *thread);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7179"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_KillThread</TT
+> gracelessly terminates the thread 
+associated with <TT
+CLASS="PARAMETER"
+><I
+>thread</I
+></TT
+>.  If possible, you should 
+use some other form of IPC to signal the thread to quit.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7184"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatethread.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateThread</TT
+></A
+>,
+<A
+HREF="sdlwaitthread.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WaitThread</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwaitthread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatemutex.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WaitThread</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateMutex</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdllistmodes.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,302 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ListModes</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_VideoDriverName"
+HREF="sdlvideodrivername.html"><LINK
+REL="NEXT"
+TITLE="SDL_VideoModeOK"
+HREF="sdlvideomodeok.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlvideodrivername.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlvideomodeok.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLISTMODES"
+>SDL_ListModes</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN715"
+></A
+><H2
+>Name</H2
+>SDL_ListModes&nbsp;--&nbsp;Returns a pointer to an array of available screen dimensions for 
+the given format and video flags</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN718"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN719"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Rect **<B
+CLASS="FSFUNC"
+>SDL_ListModes</B
+></CODE
+>(SDL_PixelFormat *format, Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN725"
+></A
+><H2
+>Description</H2
+><P
+>Return a pointer to an array of available screen dimensions for the given
+format and video flags, sorted largest to smallest.  Returns
+<TT
+CLASS="LITERAL"
+>NULL</TT
+> if there are no dimensions available for a particular
+format, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if any dimension is okay for
+the given format.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>format</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the mode list
+will be for the format returned by <A
+HREF="sdlgetvideoinfo.html"
+>SDL_GetVideoInfo()</A
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>vfmt</I
+></TT
+>. The <TT
+CLASS="PARAMETER"
+><I
+>flag</I
+></TT
+> parameter is an OR'd combination of <A
+HREF="sdlsurface.html"
+>surface</A
+> flags. The flags are the same as those used <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+> and they play a strong role in deciding what modes are valid. For instance, if you pass <TT
+CLASS="LITERAL"
+>SDL_HWSURFACE</TT
+> as a flag only modes that support hardware video surfaces will be returned.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN740"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_Rect **modes;
+int i;
+.
+.
+.
+
+/* Get available fullscreen/hardware modes */
+modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
+
+/* Check is there are any modes available */
+if(modes == (SDL_Rect **)0){
+  printf("No modes available!\n");
+  exit(-1);
+}
+
+/* Check if or resolution is restricted */
+if(modes == (SDL_Rect **)-1){
+  printf("All resolutions available.\n");
+}
+else{
+  /* Print valid modes */
+  printf("Available Modes\n");
+  for(i=0;modes[i];++i)
+    printf("  %d x %d\n", modes[i]-&#62;w, modes[i]-&#62;h);
+}
+.
+.</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN743"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlgetvideoinfo.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetVideoInfo</TT
+></A
+>,
+<A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+>,
+<A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlvideodrivername.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlvideomodeok.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_VideoDriverName</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_VideoModeOK</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlloadbmp.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_LoadBMP</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UnlockSurface"
+HREF="sdlunlocksurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_SaveBMP"
+HREF="sdlsavebmp.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlunlocksurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsavebmp.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLOADBMP"
+>SDL_LoadBMP</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1505"
+></A
+><H2
+>Name</H2
+>SDL_LoadBMP&nbsp;--&nbsp;Load a Windows BMP file into an SDL_Surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1508"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1509"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_LoadBMP</B
+></CODE
+>(const char *file);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1515"
+></A
+><H2
+>Description</H2
+><P
+>Loads a surface from a named Windows BMP file.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1518"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns the new surface, or <TT
+CLASS="LITERAL"
+>NULL</TT
+> 
+if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1522"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsavebmp.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SaveBMP</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlunlocksurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsavebmp.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UnlockSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SaveBMP</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlloadwav.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,288 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_LoadWAV</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetAudioStatus"
+HREF="sdlgetaudiostatus.html"><LINK
+REL="NEXT"
+TITLE="SDL_FreeWAV"
+HREF="sdlfreewav.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetaudiostatus.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlfreewav.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLOADWAV"
+>SDL_LoadWAV</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6194"
+></A
+><H2
+>Name</H2
+>SDL_LoadWAV&nbsp;--&nbsp;Load a WAVE file</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6197"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6198"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_AudioSpec *<B
+CLASS="FSFUNC"
+>SDL_LoadWAV</B
+></CODE
+>(const char *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6204"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_LoadWAV</TT
+>
+This function loads a WAVE <TT
+CLASS="PARAMETER"
+><I
+>file</I
+></TT
+> into memory.</P
+><P
+>If this function succeeds, it returns the given 
+<A
+HREF="sdlaudiospec.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AudioSpec</TT
+></A
+>, 
+filled with the audio data format of the wave data, and sets 
+<TT
+CLASS="PARAMETER"
+><I
+>audio_buf</I
+></TT
+> to a <TT
+CLASS="FUNCTION"
+>malloc</TT
+>'d 
+buffer containing the audio data, and sets <TT
+CLASS="PARAMETER"
+><I
+>audio_len</I
+></TT
+> 
+to the length of that audio buffer, in bytes.  You need to free the audio 
+buffer with <A
+HREF="sdlfreewav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeWAV</TT
+></A
+> when you are
+done with it.</P
+><P
+>This function returns <TT
+CLASS="LITERAL"
+>NULL</TT
+> and sets the SDL 
+error message if the wave file cannot be opened, uses an unknown data format, 
+or is corrupt.  Currently raw, MS-ADPCM and IMA-ADPCM WAVE files are supported.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6219"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_AudioSpec wav_spec;
+Uint32 wav_length;
+Uint8 *wav_buffer;
+
+/* Load the WAV */
+if( SDL_LoadWAV("test.wav", &#38;wav_spec, &#38;wav_buffer, &#38;wav_length) == NULL ){
+  fprintf(stderr, "Could not open test.wav: %s\n", SDL_GetError());
+  exit(-1);
+}
+.
+.
+.
+/* Do stuff with the WAV */
+.
+.
+/* Free It */
+SDL_FreeWAV(wav_buffer);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6222"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+></A
+>,
+<A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+>,
+<A
+HREF="sdlfreewav.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeWAV</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetaudiostatus.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlfreewav.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetAudioStatus</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_FreeWAV</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdllockaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,200 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_LockAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_MixAudio"
+HREF="sdlmixaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_UnlockAudio"
+HREF="sdlunlockaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmixaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlunlockaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLOCKAUDIO"
+>SDL_LockAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6509"
+></A
+><H2
+>Name</H2
+>SDL_LockAudio&nbsp;--&nbsp;Lock out the callback function</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6512"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6513"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_LockAudio</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6519"
+></A
+><H2
+>Description</H2
+><P
+>The lock manipulated by these functions protects the callback function.
+During a LockAudio period, you can be guaranteed that the
+callback function is not running.  Do not call these from the callback
+function or you will cause deadlock.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6522"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmixaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlunlockaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_MixAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UnlockAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdllocksurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,299 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_LockSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_FreeSurface"
+HREF="sdlfreesurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_UnlockSurface"
+HREF="sdlunlocksurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlfreesurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlunlocksurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLOCKSURFACE"
+>SDL_LockSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1435"
+></A
+><H2
+>Name</H2
+>SDL_LockSurface&nbsp;--&nbsp;Lock a surface for directly access.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1438"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1439"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_LockSurface</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1445"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+> sets up a surface for directly 
+accessing the pixels.  Between calls to <TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+>
+and <TT
+CLASS="FUNCTION"
+>SDL_UnlockSurface</TT
+>, you can write to and read from 
+<TT
+CLASS="PARAMETER"
+><I
+>surface-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+></I
+></TT
+>, using the pixel format stored in
+<TT
+CLASS="PARAMETER"
+><I
+>surface-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></I
+></TT
+>.  Once you are done accessing the
+surface, you should use <TT
+CLASS="FUNCTION"
+>SDL_UnlockSurface</TT
+> to release it.</P
+><P
+>Not all surfaces require locking.  
+If <TT
+CLASS="LITERAL"
+>SDL_MUSTLOCK</TT
+>(<TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+>)
+evaluates to <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, then you can read and write to the 
+surface at any time, and the pixel format of the surface will not change. </P
+><P
+>No operating system or library calls should be made between lock/unlock
+pairs, as critical system locks may be held during this time.</P
+><P
+>It should be noted, that since SDL 1.1.8 surface locks are recursive. This means that you can lock a surface multiple times, but each lock must have a match unlock.
+<PRE
+CLASS="PROGRAMLISTING"
+>    .
+    .
+    SDL_LockSurface( surface );
+    .
+    /* Surface is locked */
+    /* Direct pixel access on surface here */
+    .
+    SDL_LockSurface( surface );
+    .
+    /* More direct pixel access on surface */
+    .
+    SDL_UnlockSurface( surface );
+    /* Surface is still locked */
+    /* Note: Is versions &#60; 1.1.8, the surface would have been */
+    /* no longer locked at this stage                         */
+    .
+    SDL_UnlockSurface( surface );
+    /* Surface is now unlocked */
+    .
+    .</PRE
+>
+ </P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1463"
+></A
+><H2
+>Return Value</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+> returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, 
+or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if the surface couldn't be locked.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1469"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlunlocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlfreesurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlunlocksurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_FreeSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UnlockSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdllockyuvoverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,244 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_LockYUVOverlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateYUVOverlay"
+HREF="sdlcreateyuvoverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_UnlockYUVOverlay"
+HREF="sdlunlockyuvoverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreateyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlunlockyuvoverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLLOCKYUVOVERLAY"
+>SDL_LockYUVOverlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2346"
+></A
+><H2
+>Name</H2
+>SDL_LockYUVOverlay&nbsp;--&nbsp;Lock an overlay</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2349"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2350"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_LockYUVOverlay</B
+></CODE
+>(SDL_Overlay *overlay);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2356"
+></A
+><H2
+>Description</H2
+><P
+>Much the same as <A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+>, <TT
+CLASS="FUNCTION"
+>SDL_LockYUVOverlay</TT
+> locks the <A
+HREF="sdloverlay.html"
+><TT
+CLASS="PARAMETER"
+><I
+>overlay</I
+></TT
+></A
+> for direct access to pixel data.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2364"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2369"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlunlockyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreateyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlunlockyuvoverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateYUVOverlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UnlockYUVOverlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmaprgb.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,246 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_MapRGB</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetGammaRamp"
+HREF="sdlsetgammaramp.html"><LINK
+REL="NEXT"
+TITLE="SDL_MapRGBA"
+HREF="sdlmaprgba.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetgammaramp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmaprgba.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMAPRGB"
+>SDL_MapRGB</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1195"
+></A
+><H2
+>Name</H2
+>SDL_MapRGB&nbsp;--&nbsp;Map a RGB color value to a pixel format.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1198"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1199"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_MapRGB</B
+></CODE
+>(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1205"
+></A
+><H2
+>Description</H2
+><P
+>Maps the RGB color value to the specified pixel format and returns the
+pixel value as a 32-bit int.</P
+><P
+>If the format has a palette (8-bit) the index of the closest matching
+color in the palette will be returned.</P
+><P
+>If the specified pixel format has an alpha component it will be returned
+as all 1 bits (fully opaque).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1210"
+></A
+><H2
+>Return Value</H2
+><P
+>A pixel value best approximating the given RGB color value for a given
+pixel format. If the pixel format bpp (color depth) is less than 32-bpp
+then the unused upper bits of the return value can safely be ignored
+(e.g., with a 16-bpp format the return value can be assigned to a
+<SPAN
+CLASS="TYPE"
+>Uint16</SPAN
+>, and similarly a <SPAN
+CLASS="TYPE"
+>Uint8</SPAN
+> for an 8-bpp
+format).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1215"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetrgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetRGB</TT
+></A
+>,
+<A
+HREF="sdlgetrgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetRGBA</TT
+></A
+>,
+<A
+HREF="sdlmaprgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGBA</TT
+></A
+>,
+<A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetgammaramp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmaprgba.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetGammaRamp</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_MapRGBA</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmaprgba.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,234 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_MapRGBA</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_MapRGB"
+HREF="sdlmaprgb.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetRGB"
+HREF="sdlgetrgb.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmaprgb.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetrgb.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMAPRGBA"
+>SDL_MapRGBA</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1230"
+></A
+><H2
+>Name</H2
+>SDL_MapRGBA&nbsp;--&nbsp;Map a RGBA color value to a pixel format.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1233"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1234"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_MapRGBA</B
+></CODE
+>(SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b, Uint8 a);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1240"
+></A
+><H2
+>Description</H2
+><P
+>Maps the RGBA color value to the specified pixel format and returns the
+pixel value as a 32-bit int.</P
+><P
+>If the format has a palette (8-bit) the index of the closest matching
+color in the palette will be returned.</P
+><P
+>If the specified pixel format has no alpha component the alpha value
+will be ignored (as it will be in formats with a palette).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1245"
+></A
+><H2
+>Return Value</H2
+><P
+>A pixel value best approximating the given RGBA color value for a given
+pixel format. If the pixel format bpp (color depth) is less than 32-bpp
+then the unused upper bits of the return value can safely be ignored
+(e.g., with a 16-bpp format the return value can be assigned to a
+<SPAN
+CLASS="TYPE"
+>Uint16</SPAN
+>, and similarly a <SPAN
+CLASS="TYPE"
+>Uint8</SPAN
+> for an 8-bpp
+format).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1250"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetrgb.html"
+>SDL_GetRGB</A
+>,
+<A
+HREF="sdlgetrgba.html"
+>SDL_GetRGBA</A
+>,
+<A
+HREF="sdlmaprgb.html"
+>SDL_MapRGB</A
+>,
+<A
+HREF="sdlpixelformat.html"
+>SDL_PixelFormat</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmaprgb.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetrgb.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_MapRGB</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetRGB</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmixaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,210 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_MixAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ConvertAudio"
+HREF="sdlconvertaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_LockAudio"
+HREF="sdllockaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlconvertaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdllockaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMIXAUDIO"
+>SDL_MixAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6485"
+></A
+><H2
+>Name</H2
+>SDL_MixAudio&nbsp;--&nbsp;Mix audio data</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6488"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6489"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_MixAudio</B
+></CODE
+>(Uint8 *dst, Uint8 *src, Uint32 len, int volume);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6495"
+></A
+><H2
+>Description</H2
+><P
+>This takes two audio buffers of the playing audio format and mixes
+them, performing addition, volume adjustment, and overflow clipping.
+The <TT
+CLASS="PARAMETER"
+><I
+>volume</I
+></TT
+> ranges from 0 - 128, 
+and should be set to <TT
+CLASS="LITERAL"
+>SDL_MIX_MAXVOLUME</TT
+>
+for full audio volume.  Note this does not change hardware volume.
+This is provided for convenience -- you can mix your own audio data.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6500"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlconvertaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdllockaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ConvertAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_LockAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmousebuttonevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,338 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_MouseButtonEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_MouseMotionEvent"
+HREF="sdlmousemotionevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoyAxisEvent"
+HREF="sdljoyaxisevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmousemotionevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoyaxisevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMOUSEBUTTONEVENT"
+>SDL_MouseButtonEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3636"
+></A
+><H2
+>Name</H2
+>SDL_MouseButtonEvent&nbsp;--&nbsp;Mouse button event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3639"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 button;
+  Uint8 state;
+  Uint16 x, y;
+} SDL_MouseButtonEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3642"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3644"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_MOUSEBUTTONDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_MOUSEBUTTONUP</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>button</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The mouse button index (SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_PRESSED</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_RELEASED</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>x</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>y</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The X/Y coordinates of the mouse at press/release time</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3668"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseButtonEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_MOUSEBUTTONDOWN</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_MOUSEBUTTONUP</TT
+> is reported.</P
+><P
+>When a mouse button press or release is detected then number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into <TT
+CLASS="STRUCTFIELD"
+><I
+>button</I
+></TT
+>, the position of the mouse when this event occured is stored in the <TT
+CLASS="STRUCTFIELD"
+><I
+>x</I
+></TT
+> and the <TT
+CLASS="STRUCTFIELD"
+><I
+>y</I
+></TT
+> fields. Like <A
+HREF="sdlkeyboardevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_KeyboardEvent</SPAN
+></A
+>, information on whether the event was a press or a release event is stored in both the <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+> fields, but this should be obvious.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3684"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlmousemotionevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseMotionEvent</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmousemotionevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoyaxisevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_MouseMotionEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoyAxisEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmousemotionevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,357 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_MouseMotionEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_KeyboardEvent"
+HREF="sdlkeyboardevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_MouseButtonEvent"
+HREF="sdlmousebuttonevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlkeyboardevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmousebuttonevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMOUSEMOTIONEVENT"
+>SDL_MouseMotionEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3571"
+></A
+><H2
+>Name</H2
+>SDL_MouseMotionEvent&nbsp;--&nbsp;Mouse motion event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3574"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  Uint8 state;
+  Uint16 x, y;
+  Sint16 xrel, yrel;
+} SDL_MouseMotionEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3577"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3579"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The current button state</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>x</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>y</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The X/Y coordinates of the mouse</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>xrel</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>yrel</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Relative motion in the X/Y direction</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3601"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseMotionEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+> is reported.</P
+><P
+>Simply put, a <TT
+CLASS="LITERAL"
+>SDL_MOUSEMOTION</TT
+> type event occurs when a user moves the mouse within the application window or when <A
+HREF="sdlwarpmouse.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WarpMouse</TT
+></A
+> is called. Both the absolute (<TT
+CLASS="STRUCTFIELD"
+><I
+>x</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>y</I
+></TT
+>) and relative (<TT
+CLASS="STRUCTFIELD"
+><I
+>xrel</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>yrel</I
+></TT
+>) coordinates are reported along with the current button states (<TT
+CLASS="STRUCTFIELD"
+><I
+>state</I
+></TT
+>). The button state can be interpreted using the <TT
+CLASS="LITERAL"
+>SDL_BUTTON</TT
+> macro (see <A
+HREF="sdlgetmousestate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetMouseState</TT
+></A
+>).</P
+><P
+>If the cursor is hidden (<A
+HREF="sdlshowcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ShowCursor</TT
+>(0)</A
+>) and the input is grabbed (<A
+HREF="sdlwmgrabinput.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_GrabInput</TT
+>(SDL_GRAB_ON)</A
+>), then the mouse will give relative motion events even when the cursor reaches the edge fo the screen. This is currently only implemented on Windows and Linux/Unix-a-likes.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3625"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlmousebuttonevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseButtonEvent</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlkeyboardevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmousebuttonevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_KeyboardEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_MouseButtonEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmutexp.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,233 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_mutexP</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DestroyMutex"
+HREF="sdldestroymutex.html"><LINK
+REL="NEXT"
+TITLE="SDL_mutexV"
+HREF="sdlmutexv.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldestroymutex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmutexv.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMUTEXP"
+>SDL_mutexP</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7247"
+></A
+><H2
+>Name</H2
+>SDL_mutexP&nbsp;--&nbsp;Lock a mutex</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7250"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7251"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_mutexP</B
+></CODE
+>(SDL_mutex *mutex);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7257"
+></A
+><H2
+>Description</H2
+><P
+>Locks the <TT
+CLASS="PARAMETER"
+><I
+>mutex</I
+></TT
+>, which was previously created with <A
+HREF="sdlcreatemutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateMutex</TT
+></A
+>. If the mutex is already locked then <TT
+CLASS="FUNCTION"
+>SDL_mutexP</TT
+> will not return until it is <A
+HREF="sdlmutexv.html"
+>unlocked</A
+>. Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+><P
+>SDL also defines a macro <TT
+CLASS="LITERAL"
+>#define SDL_LockMutex(m) SDL_mutexP(m)</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7269"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatemutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateMutex</TT
+></A
+>,
+<A
+HREF="sdlmutexv.html"
+><TT
+CLASS="FUNCTION"
+>SDL_mutexV</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldestroymutex.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmutexv.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DestroyMutex</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_mutexV</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlmutexv.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,227 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_mutexV</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_mutexP"
+HREF="sdlmutexp.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateSemaphore"
+HREF="sdlcreatesemaphore.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlmutexp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatesemaphore.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLMUTEXV"
+>SDL_mutexV</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7280"
+></A
+><H2
+>Name</H2
+>SDL_mutexV&nbsp;--&nbsp;Unlock a mutex</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7283"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7284"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_mutexV</B
+></CODE
+>(SDL_mutex *mutex);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7290"
+></A
+><H2
+>Description</H2
+><P
+>Unlocks the <TT
+CLASS="PARAMETER"
+><I
+>mutex</I
+></TT
+>, which was previously created with <A
+HREF="sdlcreatemutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateMutex</TT
+></A
+>. Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success, or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> on an error.</P
+><P
+>SDL also defines a macro <TT
+CLASS="LITERAL"
+>#define SDL_UnlockMutex(m) SDL_mutexV(m)</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7300"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatemutex.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateMutex</TT
+></A
+>,
+<A
+HREF="sdlmutexp.html"
+><TT
+CLASS="FUNCTION"
+>SDL_mutexP</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlmutexp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatesemaphore.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_mutexP</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateSemaphore</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlnumjoysticks.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_NumJoysticks</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="PREVIOUS"
+TITLE="Joystick"
+HREF="joystick.html"><LINK
+REL="NEXT"
+TITLE="SDL_JoystickName"
+HREF="sdljoystickname.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="joystick.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdljoystickname.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLNUMJOYSTICKS"
+>SDL_NumJoysticks</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5417"
+></A
+><H2
+>Name</H2
+>SDL_NumJoysticks&nbsp;--&nbsp;Count available joysticks.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5420"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5421"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_NumJoysticks</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5427"
+></A
+><H2
+>Description</H2
+><P
+>Counts the number of joysticks attached to the system.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5430"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns the number of attached joysticks</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5433"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdljoystickname.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickName</TT
+></A
+>,
+<A
+HREF="sdljoystickopen.html"
+><TT
+CLASS="FUNCTION"
+>SDL_JoystickOpen</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdljoystickname.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Joystick</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="joystick.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_JoystickName</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlopenaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,567 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_OpenAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_AudioSpec"
+HREF="sdlaudiospec.html"><LINK
+REL="NEXT"
+TITLE="SDL_PauseAudio"
+HREF="sdlpauseaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlaudiospec.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpauseaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLOPENAUDIO"
+>SDL_OpenAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6028"
+></A
+><H2
+>Name</H2
+>SDL_OpenAudio&nbsp;--&nbsp;Opens the audio device with the desired parameters.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6031"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6032"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_OpenAudio</B
+></CODE
+>(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6038"
+></A
+><H2
+>Description</H2
+><P
+>This function opens the audio device with the <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> parameters, and
+returns 0 if successful, placing the actual hardware parameters in the
+structure pointed to by <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+>.  If <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+> is NULL, the audio
+data passed to the callback function will be guaranteed to be in the
+requested format, and will be automatically converted to the hardware
+audio format if necessary.  This function returns -1 if it failed 
+to open the audio device, or couldn't set up the audio thread.</P
+><P
+>To open the audio device a <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> <A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+></A
+> must be created.
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_AudioSpec *desired;
+.
+.
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));</PRE
+>
+You must then fill this structure with your desired audio specifications.</P
+><P
+></P
+><DIV
+CLASS="VARIABLELIST"
+><DL
+><DT
+><SPAN
+CLASS="STRUCTNAME"
+>desired</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>freq</I
+></TT
+></DT
+><DD
+><P
+>The desired audio frequency in samples-per-second.</P
+></DD
+><DT
+><SPAN
+CLASS="STRUCTNAME"
+>desired</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></DT
+><DD
+><P
+>The desired audio format (see <A
+HREF="sdlaudiospec.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+></A
+>)</P
+></DD
+><DT
+><SPAN
+CLASS="STRUCTNAME"
+>desired</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>samples</I
+></TT
+></DT
+><DD
+><P
+>The desired size of the audio buffer in samples. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware.  Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed.  Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time.  A stereo sample consists of both right and left channels in LR ordering.  Note that the number of samples is directly related to time by the following formula:  ms = (samples*1000)/freq</P
+></DD
+><DT
+><SPAN
+CLASS="STRUCTNAME"
+>desired</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>callback</I
+></TT
+></DT
+><DD
+><P
+>This should be set to a function that will be called when the audio device is ready for more data.  It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling <A
+HREF="sdllockaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockAudio</TT
+></A
+> and <A
+HREF="sdlunlockaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockAudio</TT
+></A
+> in your code. The callback prototype is:
+<PRE
+CLASS="PROGRAMLISTING"
+>void callback(void *userdata, Uint8 *stream, int len);</PRE
+>
+<TT
+CLASS="PARAMETER"
+><I
+>userdata</I
+></TT
+> is the pointer stored in <TT
+CLASS="STRUCTFIELD"
+><I
+>userdata</I
+></TT
+> field of the <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+>. <TT
+CLASS="PARAMETER"
+><I
+>stream</I
+></TT
+> is a pointer to the audio buffer you want to fill with information and <TT
+CLASS="PARAMETER"
+><I
+>len</I
+></TT
+> is the length of the audio buffer in bytes.</P
+></DD
+><DT
+><SPAN
+CLASS="STRUCTNAME"
+>desired</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>userdata</I
+></TT
+></DT
+><DD
+><P
+>This pointer is passed as the first parameter to the <TT
+CLASS="FUNCTION"
+>callback</TT
+> function.</P
+></DD
+></DL
+></DIV
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+> reads these fields from the <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+> structure pass to the function and attempts to find an audio configuration matching your <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+>. As mentioned above, if the <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+> parameter is <TT
+CLASS="LITERAL"
+>NULL</TT
+> then SDL with convert from your <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> audio settings to the hardware settings as it plays.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>NULL</TT
+> then the <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+> is your working specification, otherwise the <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+> <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioSpec</SPAN
+> becomes the working specification and the <TT
+CLASS="PARAMETER"
+><I
+>desirec</I
+></TT
+> specification can be deleted. The data in the working specification is used when building <SPAN
+CLASS="STRUCTNAME"
+>SDL_AudioCVT</SPAN
+>'s for converting loaded data to the hardware format.</P
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+> calculates the <TT
+CLASS="STRUCTFIELD"
+><I
+>size</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>silence</I
+></TT
+> fields for both the <TT
+CLASS="PARAMETER"
+><I
+>desired</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>obtained</I
+></TT
+> specifications. The <TT
+CLASS="STRUCTFIELD"
+><I
+>size</I
+></TT
+> field stores the total size of the audio buffer in bytes, while the <TT
+CLASS="STRUCTFIELD"
+><I
+>silence</I
+></TT
+> stores the value used to represent silence in the audio buffer</P
+><P
+>The audio device starts out playing <TT
+CLASS="STRUCTFIELD"
+><I
+>silence</I
+></TT
+> when it's opened, and should be enabled for playing by calling <A
+HREF="sdlpauseaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PauseAudio</TT
+>(<TT
+CLASS="PARAMETER"
+><I
+>0</I
+></TT
+>)</A
+> when you are ready for your audio <TT
+CLASS="STRUCTFIELD"
+><I
+>callback</I
+></TT
+> function to be called.  Since the audio driver may modify the requested <TT
+CLASS="STRUCTFIELD"
+><I
+>size</I
+></TT
+> of the audio buffer, you should allocate any local mixing buffers after you open the audio device.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6125"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Prototype of our callback function */
+void my_audio_callback(void *userdata, Uint8 *stream, int len);
+
+/* Open the audio device */
+SDL_AudioSpec *desired, *obtained;
+SDL_AudioSpec *hardware_spec;
+
+/* Allocate a desired SDL_AudioSpec */
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* Allocate space for the obtained SDL_AudioSpec */
+obtained=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* 22050Hz - FM Radio quality */
+desired-&#62;freq=22050;
+
+/* 16-bit signed audio */
+desired-&#62;format=AUDIO_S16LSB;
+
+/* Large audio buffer reduces risk of dropouts but increases response time */
+desired-&#62;samples=8192;
+
+/* Our callback function */
+desired-&#62;callback=my_audio_callback;
+
+desired-&#62;userdata=NULL;
+
+/* Open the audio device */
+if ( SDL_OpenAudio(desired, obtained) &#60; 0 ){
+  fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+  exit(-1);
+}
+/* desired spec is no longer needed */
+free(desired);
+hardware_spec=obtained;
+.
+.
+/* Prepare callback for playing */
+.
+.
+.
+/* Start playing */
+SDL_PauseAudio(0);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6128"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlaudiospec.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AudioSpec</TT
+></A
+>,
+<A
+HREF="sdllockaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockAudio</TT
+></A
+>,
+<A
+HREF="sdlunlockaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockAudio</TT
+></A
+>,
+<A
+HREF="sdlpauseaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PauseAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlaudiospec.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpauseaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_AudioSpec</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PauseAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdloverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,354 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Overlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_VideoInfo"
+HREF="sdlvideoinfo.html"><LINK
+REL="NEXT"
+TITLE="Window Management"
+HREF="wm.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlvideoinfo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="wm.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLOVERLAY"
+>SDL_Overlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2967"
+></A
+><H2
+>Name</H2
+>SDL_Overlay&nbsp;--&nbsp;YUV video overlay</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2970"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint32 format;
+  int w, h;
+  int planes;
+  Uint16 *pitches;
+  Uint8 **pixels;
+  Uint32 hw_overlay:1;
+} SDL_Overlay;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2973"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2975"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Overlay format (see below)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>w, h</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Width and height of overlay</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>planes</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Number of planes in the overlay. Usually either 1 or 3</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>pitches</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>An array of pitches, one for each plane. Pitch is the length of a row in bytes.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>An array of pointers to teh data of each plane. The overlay should be locked before these pointers are used.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>hw_overlay</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>This will be set to 1 if the overlay is hardware accelerated.</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3002"
+></A
+><H2
+>Description</H2
+><P
+>A <SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+> is similar to a <A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+> except it stores a YUV overlay. All the fields are read only, except for <TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+> which should be <A
+HREF="sdllockyuvoverlay.html"
+>locked</A
+> before use. The <TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+> field stores the format of the overlay which is one of the following:
+<PRE
+CLASS="PROGRAMLISTING"
+>#define SDL_YV12_OVERLAY  0x32315659  /* Planar mode: Y + V + U */
+#define SDL_IYUV_OVERLAY  0x56555949  /* Planar mode: Y + U + V */
+#define SDL_YUY2_OVERLAY  0x32595559  /* Packed mode: Y0+U0+Y1+V0 */
+#define SDL_UYVY_OVERLAY  0x59565955  /* Packed mode: U0+Y0+V0+Y1 */
+#define SDL_YVYU_OVERLAY  0x55595659  /* Packed mode: Y0+V0+Y1+U0 */</PRE
+>
+More information on YUV formats can be found at <A
+HREF="http://www.webartz.com/fourcc/indexyuv.htm"
+TARGET="_top"
+>http://www.webartz.com/fourcc/indexyuv.htm</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3013"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdllockyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlunlockyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlfreeyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_FreeYUVOverlay</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlvideoinfo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_VideoInfo</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Window Management</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpalette.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,293 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Palette</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Color"
+HREF="sdlcolor.html"><LINK
+REL="NEXT"
+TITLE="SDL_PixelFormat"
+HREF="sdlpixelformat.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcolor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpixelformat.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPALETTE"
+>SDL_Palette</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2628"
+></A
+><H2
+>Name</H2
+>SDL_Palette&nbsp;--&nbsp;Color palette for 8-bit pixel formats</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2631"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  int ncolors;
+  SDL_Color *colors;
+} SDL_Palette;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2634"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2636"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>ncolors</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Number of colors used in this palette</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>colors</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pointer to <A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+> structures that make up the palette.</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2649"
+></A
+><H2
+>Description</H2
+><P
+>Each pixel in an 8-bit surface is an index into the <TT
+CLASS="STRUCTFIELD"
+><I
+>colors</I
+></TT
+> field of the <SPAN
+CLASS="STRUCTNAME"
+>SDL_Palette</SPAN
+> structure store in <A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>. A <SPAN
+CLASS="STRUCTNAME"
+>SDL_Palette</SPAN
+> should never need to be created manually. It is automatically created when SDL allocates a <SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+> for a surface. The colors values of a <A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>s palette can be set with the <A
+HREF="sdlsetcolors.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2662"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdlsetcolors.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+></A
+>
+<A
+HREF="sdlsetpalette.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetPalette</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcolor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpixelformat.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Color</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PixelFormat</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpauseaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,213 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PauseAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_OpenAudio"
+HREF="sdlopenaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetAudioStatus"
+HREF="sdlgetaudiostatus.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlopenaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetaudiostatus.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPAUSEAUDIO"
+>SDL_PauseAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6143"
+></A
+><H2
+>Name</H2
+>SDL_PauseAudio&nbsp;--&nbsp;Pauses and unpauses the audio callback processing</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6146"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6147"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_PauseAudio</B
+></CODE
+>(int pause_on);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6153"
+></A
+><H2
+>Description</H2
+><P
+>This function pauses and unpauses the audio callback processing.
+It should be called with <TT
+CLASS="PARAMETER"
+><I
+>pause_on</I
+></TT
+>=0 after opening the audio
+device to start playing sound.  This is so you can safely initialize
+data for your callback function after opening the audio device.
+Silence will be written to the audio device during the pause.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6157"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetaudiostatus.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetAudioStatus</TT
+></A
+>,
+<A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlopenaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetaudiostatus.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_OpenAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetAudioStatus</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpeepevents.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,296 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PeepEvents</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PumpEvents"
+HREF="sdlpumpevents.html"><LINK
+REL="NEXT"
+TITLE="SDL_PollEvent"
+HREF="sdlpollevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpumpevents.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpollevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPEEPEVENTS"
+>SDL_PeepEvents</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4807"
+></A
+><H2
+>Name</H2
+>SDL_PeepEvents&nbsp;--&nbsp;Checks the event queue for messages and optionally returns them.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4810"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4811"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_PeepEvents</B
+></CODE
+>(SDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4817"
+></A
+><H2
+>Description</H2
+><P
+>Checks the event queue for messages and optionally returns them.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>action</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_ADDEVENT</TT
+>, up to 
+<TT
+CLASS="PARAMETER"
+><I
+>numevents</I
+></TT
+> events will be added to the back of the event
+ queue.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>action</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_PEEKEVENT</TT
+>, up to
+<TT
+CLASS="PARAMETER"
+><I
+>numevents</I
+></TT
+> events at the front of the event queue, 
+matching <A
+HREF="sdlevent.html"
+><TT
+CLASS="PARAMETER"
+><I
+>mask</I
+></TT
+></A
+>, 
+will be returned and will not be removed from the queue.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>action</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_GETEVENT</TT
+>, up to 
+<TT
+CLASS="PARAMETER"
+><I
+>numevents</I
+></TT
+> events at the front of the event queue, 
+matching <A
+HREF="sdlevent.html"
+><TT
+CLASS="PARAMETER"
+><I
+>mask</I
+></TT
+></A
+>, 
+will be returned and will be removed from the queue.</P
+><P
+>This function is thread-safe.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4837"
+></A
+><H2
+>Return Value</H2
+><P
+>This function returns the number of events actually stored, or 
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if there was an error.  </P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4841"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+>,
+<A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpumpevents.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpollevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PumpEvents</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PollEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpixelformat.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,514 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PixelFormat</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Palette"
+HREF="sdlpalette.html"><LINK
+REL="NEXT"
+TITLE="SDL_Surface"
+HREF="sdlsurface.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpalette.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPIXELFORMAT"
+>SDL_PixelFormat</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2677"
+></A
+><H2
+>Name</H2
+>SDL_PixelFormat&nbsp;--&nbsp;Stores surface format information</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2680"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  SDL_Palette *palette;
+  Uint8  BitsPerPixel;
+  Uint8  BytesPerPixel;
+  Uint32 Rmask, Gmask, Bmask, Amask;
+  Uint8  Rshift, Gshift, Bshift, Ashift;
+  Uint8  Rloss, Gloss, Bloss, Aloss;
+  Uint32 colorkey;
+  Uint8  alpha;
+} SDL_PixelFormat;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2683"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2685"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>palette</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pointer to the <A
+HREF="sdlpalette.html"
+>palette</A
+>, or <TT
+CLASS="LITERAL"
+>NULL</TT
+> if the <TT
+CLASS="STRUCTFIELD"
+><I
+>BitsPerPixel</I
+></TT
+>&#62;8</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>BitsPerPixel</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The number of bits used to represent each pixel in a surface. Usually 8, 16, 24 or 32.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>BytesPerPixel</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The number of bytes used to represent each pixel in a surface. Usually one to four.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>[RGBA]mask</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Binary mask used to retrieve individual color values</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>[RGBA]loss</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Precision loss of each color component (2<SUP
+>[RGBA]loss</SUP
+>)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>[RGBA]shift</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Binary left shift of each color component in the pixel value</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>colorkey</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pixel value of transparent pixels</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>alpha</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Overall surface alpha value</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2724"
+></A
+><H2
+>Description</H2
+><P
+>A <SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+> describes the format of the pixel data stored at the <TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+> field of a <A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>. Every surface stores a <SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+> in the <TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+> field.</P
+><P
+>If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential.</P
+><P
+>8-bit pixel formats are the easiest to understand. Since its an 8-bit format, we have 8 <TT
+CLASS="STRUCTFIELD"
+><I
+>BitsPerPixel</I
+></TT
+> and 1 <TT
+CLASS="STRUCTFIELD"
+><I
+>BytesPerPixel</I
+></TT
+>. Since <TT
+CLASS="STRUCTFIELD"
+><I
+>BytesPerPixel</I
+></TT
+> is 1, all pixels are represented by a Uint8 which contains an index into <TT
+CLASS="STRUCTFIELD"
+><I
+>palette</I
+></TT
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>colors</I
+></TT
+>. So, to determine the color of a pixel in a 8-bit surface: we read the color index from <SPAN
+CLASS="STRUCTNAME"
+>surface</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+> and we use that index to read the <A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+> structure from <SPAN
+CLASS="STRUCTNAME"
+>surface</SPAN
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>palette</I
+></TT
+>-&#62;<TT
+CLASS="STRUCTFIELD"
+><I
+>colors</I
+></TT
+>. Like so:
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_Surface *surface;
+SDL_PixelFormat *fmt;
+SDL_Color *color;
+Uint8 index;
+
+.
+.
+
+/* Create surface */
+.
+.
+fmt=surface-&#62;format;
+
+/* Check the bitdepth of the surface */
+if(fmt-&#62;BitsPerPixel!=8){
+  fprintf(stderr, "Not an 8-bit surface.\n");
+  return(-1);
+}
+
+/* Lock the surface */
+SDL_LockSurface(surface);
+
+/* Get the topleft pixel */
+index=*(Uint8 *)surface-&#62;pixels;
+color=fmt-&#62;palette-&#62;colors[index];
+
+/* Unlock the surface */
+SDL_UnlockSurface(surface);
+printf("Pixel Color-&#62; Red: %d, Green: %d, Blue: %d. Index: %d\n",
+          color-&#62;r, color-&#62;g, color-&#62;b, index);
+.
+.</PRE
+></P
+><P
+>Pixel formats above 8-bit are an entirely different experience. They are considered to be "TrueColor" formats and the color information is stored in the pixels themselves, not in a palette (packed-pixel). The mask, shift and loss fields tell us how the color information is encoded. The mask fields allow us to isolate each color component, the shift fields tell us how far left we have to shift the masked value and the loss fields tell us for far right we have to shift the final value to convert it to a full 8-bit color component.
+<PRE
+CLASS="PROGRAMLISTING"
+>/* Extracting color components from a 32-bit color value */
+SDL_PixelFormat *fmt;
+SDL_Surface *surface;
+Uint32 temp, pixel;
+Uint8 red, green, blue, alpha;
+.
+.
+.
+fmt=surface-&#62;format;
+SDL_LockSurface(surface);
+pixel=(Uint32*)surface-&#62;pixels;
+SDL_UnlockSurface(surface);
+
+/* Get Red component */
+temp=pixel&#38;fmt-&#62;Rmask; /* Isolate red component */
+temp=temp&#62;&#62;fmt-&#62;Rshift;/* Shift it down to 8-bit */
+temp=temp&#60;&#60;fmt-&#62;Rloss; /* Expand to a full 8-bit number */
+red=(Uint8)temp;
+
+/* Get Green component */
+temp=pixel&#38;fmt-&#62;Gmask; /* Isolate green component */
+temp=temp&#62;&#62;fmt-&#62;Gshift;/* Shift it down to 8-bit */
+temp=temp&#60;&#60;fmt-&#62;Gloss; /* Expand to a full 8-bit number */
+green=(Uint8)temp;
+
+/* Get Blue component */
+temp=pixel&#38;fmt-&#62;Bmask; /* Isolate blue component */
+temp=temp&#62;&#62;fmt-&#62;Bshift;/* Shift it down to 8-bit */
+temp=temp&#60;&#60;fmt-&#62;Bloss; /* Expand to a full 8-bit number */
+blue=(Uint8)temp;
+
+/* Get Alpha component */
+temp=pixel&#38;fmt-&#62;Amask; /* Isolate alpha component */
+temp=temp&#62;&#62;fmt-&#62;Ashift;/* Shift it down to 8-bit */
+temp=temp&#60;&#60;fmt-&#62;Aloss; /* Expand to a full 8-bit number */
+alpha=(Uint8)temp;
+
+printf("Pixel Color -&#62; R: %d,  G: %d,  B: %d,  A: %d\n", red, green, blue, alpha);
+.
+.
+.</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2751"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpalette.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Palette</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Surface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpollevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,261 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PollEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PeepEvents"
+HREF="sdlpeepevents.html"><LINK
+REL="NEXT"
+TITLE="SDL_WaitEvent"
+HREF="sdlwaitevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpeepevents.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwaitevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPOLLEVENT"
+>SDL_PollEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4854"
+></A
+><H2
+>Name</H2
+>SDL_PollEvent&nbsp;--&nbsp;Polls for currently pending events.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4857"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4858"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_PollEvent</B
+></CODE
+>(SDL_Event *event);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4864"
+></A
+><H2
+>Description</H2
+><P
+>Polls for currently pending events, and returns <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+> 
+if there are any pending events, or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if there 
+are none available.  </P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>event</I
+></TT
+> is not <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the next 
+event is removed from the queue and stored in that area.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4872"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_Event event; /* Event structure */
+
+.
+.
+.
+/* Check for events */
+while(SDL_PollEvent(&#38;event)){  /* Loop until there are no events left on the queue */
+  switch(event.type){  /* Process the appropiate event type */
+    case SDL_KEYDOWN:  /* Handle a KEYDOWN event */         
+      printf("Oh! Key press\n");
+      break;
+    case SDL_MOUSEMOTION:
+      .
+      .
+      .
+    default: /* Report an unhandled event */
+      printf("I don't know what this event is!\n");
+  }
+}</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4876"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlwaitevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WaitEvent</TT
+></A
+>,
+<A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpeepevents.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwaitevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PeepEvents</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WaitEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpumpevents.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,236 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PumpEvents</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="NEXT"
+TITLE="SDL_PeepEvents"
+HREF="sdlpeepevents.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="eventfunctions.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpeepevents.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPUMPEVENTS"
+>SDL_PumpEvents</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4773"
+></A
+><H2
+>Name</H2
+>SDL_PumpEvents&nbsp;--&nbsp;Pumps the event loop, gathering events from the input devices.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4776"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4777"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_PumpEvents</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4783"
+></A
+><H2
+>Description</H2
+><P
+>Pumps the event loop, gathering events from the input devices.</P
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+> gathers all the pending input information from devices and places it on the event queue. Without calls to <TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+> no events would ever be placed on the queue. Often calls the need for <TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+> is hidden from the user since <A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+> and <A
+HREF="sdlwaitevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WaitEvent</TT
+></A
+> implicitly call <TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+>. However, if you are not polling or waiting for events (e.g. your filtering them), then you must call <TT
+CLASS="FUNCTION"
+>SDL_PumpEvents</TT
+> to force an event queue update.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>You can only call this function in the thread that set the video mode.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4798"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpeepevents.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Event Functions.</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PeepEvents</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlpushevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,258 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_PushEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WaitEvent"
+HREF="sdlwaitevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetEventFilter"
+HREF="sdlseteventfilter.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwaitevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlseteventfilter.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLPUSHEVENT"
+>SDL_PushEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4918"
+></A
+><H2
+>Name</H2
+>SDL_PushEvent&nbsp;--&nbsp;Pushes an event onto the event queue</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4921"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4922"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_PushEvent</B
+></CODE
+>(SDL_Event *event);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4928"
+></A
+><H2
+>Description</H2
+><P
+>The event queue can actually be used as a two way communication channel. Not only can events be read from the queue, but the user can also push their own events onto it. <TT
+CLASS="PARAMETER"
+><I
+>event</I
+></TT
+> is a pointer to the event structure you wish to push onto the queue.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Pushing device input events onto the queue doesn't modify the state of the device within SDL.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4934"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on success or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if the event couldn't be pushed.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4939"
+></A
+><H2
+>Examples</H2
+><P
+>See <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4944"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+>,
+<A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+>,
+<A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwaitevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlseteventfilter.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WaitEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetEventFilter</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlquit.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,236 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Quit</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="General"
+HREF="general.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_QuitSubSystem"
+HREF="sdlquitsubsystem.html"><LINK
+REL="NEXT"
+TITLE="SDL_WasInit"
+HREF="sdlwasinit.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlquitsubsystem.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwasinit.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLQUIT"
+>SDL_Quit</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN546"
+></A
+><H2
+>Name</H2
+>SDL_Quit&nbsp;--&nbsp;Shut down SDL</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN549"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN550"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_Quit</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN556"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+> shuts down all SDL subsystems and frees the resources allocated to them. This should always be called before you exit. For the sake of simplicity you can set <TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+> as your <TT
+CLASS="FUNCTION"
+>atexit</TT
+> call, like:
+<PRE
+CLASS="PROGRAMLISTING"
+>SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
+atexit(SDL_Quit);
+.
+.</PRE
+></P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>While using <TT
+CLASS="FUNCTION"
+>atexit</TT
+> maybe be fine for small programs, more advanced users should shut down SDL in their own cleanup code. Plus, using <TT
+CLASS="FUNCTION"
+>atexit</TT
+> in a library is a sure way to crash dynamically loaded code</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN567"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlquitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_QuitSubsystem</TT
+></A
+>,
+<A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlquitsubsystem.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwasinit.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_QuitSubSystem</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="general.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WasInit</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlquitevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,255 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_QuitEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UserEvent"
+HREF="sdluserevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_keysym"
+HREF="sdlkeysym.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdluserevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlkeysym.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLQUITEVENT"
+>SDL_QuitEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4078"
+></A
+><H2
+>Name</H2
+>SDL_QuitEvent&nbsp;--&nbsp;Quit requested event</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4081"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type
+} SDL_QuitEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4084"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN4086"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_QUIT</TT
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4094"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_QuitEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used whan an event of type <TT
+CLASS="LITERAL"
+>SDL_QUIT</TT
+> is reported.</P
+><P
+>As can be seen, the SDL_QuitEvent structure serves no useful purpose. The event itself, on the other hand, is very important. If you filter out or ignore a quit event then it is impossible for the user to close the window. On the other hand, if you do accept a quit event then the application window will be closed, and screen updates will still report success event though the application will no longer be visible.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>The macro <TT
+CLASS="FUNCTION"
+>SDL_QuitRequested</TT
+> will return non-zero if a quit event is pending</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4105"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlseteventfilter.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetEventFilter</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdluserevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlkeysym.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UserEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_keysym</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlquitsubsystem.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,240 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_QuitSubSystem</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="General"
+HREF="general.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_InitSubSystem"
+HREF="sdlinitsubsystem.html"><LINK
+REL="NEXT"
+TITLE="SDL_Quit"
+HREF="sdlquit.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlinitsubsystem.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlquit.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLQUITSUBSYSTEM"
+>SDL_QuitSubSystem</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN511"
+></A
+><H2
+>Name</H2
+>SDL_QuitSubSystem&nbsp;--&nbsp;Shut down a subsystem</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN514"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN515"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_QuitSubSystem</B
+></CODE
+>(Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN521"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_QuitSubSystem</TT
+> allows you to shut down a subsystem that has been previously initialized by <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+> or <A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+>. The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> tells <TT
+CLASS="FUNCTION"
+>SDL_QuitSubSystem</TT
+> which subsystems to shut down, it uses the same values that are passed to <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN533"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlquit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Quit</TT
+></A
+>,
+<A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>,
+<A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlinitsubsystem.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlquit.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_InitSubSystem</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="general.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Quit</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlrect.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,250 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Rect</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GLattr"
+HREF="sdlglattr.html"><LINK
+REL="NEXT"
+TITLE="SDL_Color"
+HREF="sdlcolor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlglattr.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcolor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLRECT"
+>SDL_Rect</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2545"
+></A
+><H2
+>Name</H2
+>SDL_Rect&nbsp;--&nbsp;Defines a rectangular area</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2548"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Sint16 x, y;
+  Uint16 w, h;
+} SDL_Rect;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2551"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2553"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>x, y</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Position of the upper-left corner of the rectangle</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>w, h</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>The width and height of the rectangle</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2564"
+></A
+><H2
+>Description</H2
+><P
+>A <SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+> defines a rectangular area of pixels. It is used by <A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+> to define blitting regions and by several other video functions.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2570"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+>,
+<A
+HREF="sdlupdaterect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlglattr.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcolor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GLattr</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Color</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlremovetimer.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,228 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_RemoveTimer</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_AddTimer"
+HREF="sdladdtimer.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetTimer"
+HREF="sdlsettimer.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdladdtimer.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsettimer.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLREMOVETIMER"
+>SDL_RemoveTimer</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7895"
+></A
+><H2
+>Name</H2
+>SDL_RemoveTimer&nbsp;--&nbsp;Remove a timer which was added with
+<A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+>.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7899"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7900"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_bool <B
+CLASS="FSFUNC"
+>SDL_RemoveTimer</B
+></CODE
+>(SDL_TimerID id);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7906"
+></A
+><H2
+>Description</H2
+><P
+>Removes a timer callback previously added with
+<A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7910"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns a boolean value indicating success.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7913"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_RemoveTimer(my_timer_id);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7917"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdladdtimer.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AddTimer</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdladdtimer.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsettimer.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_AddTimer</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="time.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetTimer</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlresizeevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,299 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ResizeEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_JoyBallEvent"
+HREF="sdljoyballevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_SysWMEvent"
+HREF="sdlsyswmevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdljoyballevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsyswmevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLRESIZEEVENT"
+>SDL_ResizeEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3945"
+></A
+><H2
+>Name</H2
+>SDL_ResizeEvent&nbsp;--&nbsp;Window resize event structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3948"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  int w, h;
+} SDL_ResizeEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3951"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN3953"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>w</I
+></TT
+>, <TT
+CLASS="STRUCTFIELD"
+><I
+>h</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>New width and height of the window</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3966"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_ResizeEvent</SPAN
+> is a member of the <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+> union and is used when an event of type <TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+> is reported.</P
+><P
+>When <TT
+CLASS="LITERAL"
+>SDL_RESIZABLE</TT
+> is passed as a <TT
+CLASS="PARAMETER"
+><I
+>flag</I
+></TT
+> to <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+> the user is allowed to resize the applications window. When the window is resized an <TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+> is report, with the new window width and height values stored in <TT
+CLASS="STRUCTFIELD"
+><I
+>w</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>h</I
+></TT
+>, respectively. When an <TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+> is recieved the window should be resized to the new dimensions using <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3984"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdljoyballevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsyswmevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_JoyBallEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SysWMEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsavebmp.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,228 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SaveBMP</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_LoadBMP"
+HREF="sdlloadbmp.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetColorKey"
+HREF="sdlsetcolorkey.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlloadbmp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetcolorkey.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSAVEBMP"
+>SDL_SaveBMP</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1531"
+></A
+><H2
+>Name</H2
+>SDL_SaveBMP&nbsp;--&nbsp;Save an SDL_Surface as a Windows BMP file.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1534"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1535"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SaveBMP</B
+></CODE
+>(SDL_Surface *surface, const char *file);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1541"
+></A
+><H2
+>Description</H2
+><P
+>Saves the <SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+> <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> as a Windows BMP file named <TT
+CLASS="PARAMETER"
+><I
+>file</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1547"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if successful or
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+>
+if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1552"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlloadbmp.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LoadBMP</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlloadbmp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetcolorkey.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_LoadBMP</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetColorKey</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsempost.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,291 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SemPost</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SemWaitTimeout"
+HREF="sdlsemwaittimeout.html"><LINK
+REL="NEXT"
+TITLE="SDL_SemValue"
+HREF="sdlsemvalue.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsemwaittimeout.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsemvalue.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSEMPOST"
+>SDL_SemPost</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7545"
+></A
+><H2
+>Name</H2
+>SDL_SemPost&nbsp;--&nbsp;Unlock a semaphore.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7548"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7549"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SemPost</B
+></CODE
+>(SDL_sem *sem);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7555"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+> unlocks the semaphore pointed to by
+<TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+> and atomically increments the semaphores value.
+Threads that were blocking on the semaphore may be scheduled after this call
+succeeds.</P
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+> should be called after a semaphore is locked by a successful call to
+<A
+HREF="sdlsemwait.html"
+>SDL_SemWait</A
+>,
+<A
+HREF="sdlsemtrywait.html"
+>SDL_SemTryWait</A
+> or
+<A
+HREF="sdlsemwaittimeout.html"
+>SDL_SemWaitTimeout</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7565"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if successful or
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if there was an error (leaving the semaphore unchanged).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7570"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_SemPost(my_sem);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7574"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsemwaittimeout.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsemvalue.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SemWaitTimeout</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SemValue</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsemtrywait.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,311 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SemTryWait</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SemWait"
+HREF="sdlsemwait.html"><LINK
+REL="NEXT"
+TITLE="SDL_SemWaitTimeout"
+HREF="sdlsemwaittimeout.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsemwait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsemwaittimeout.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSEMTRYWAIT"
+>SDL_SemTryWait</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7444"
+></A
+><H2
+>Name</H2
+>SDL_SemTryWait&nbsp;--&nbsp;Attempt to lock a semaphore but don't suspend the thread.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7447"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7448"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SemTryWait</B
+></CODE
+>(SDL_sem *sem);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7454"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+> is a non-blocking varient of
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>. If the value of the semaphore
+pointed to by <TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+> is positive it will atomically
+decrement the semaphore value and return 0, otherwise it will return
+<SPAN
+CLASS="RETURNVALUE"
+>SDL_MUTEX_TIMEOUT</SPAN
+> instead of suspending the thread.</P
+><P
+>After <TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+> is successful, the semaphore
+can be released and its count atomically incremented by a successful call to
+<A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7465"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if the semaphore was successfully locked or
+either <SPAN
+CLASS="RETURNVALUE"
+>SDL_MUTEX_TIMEOUT</SPAN
+> or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+>
+if the thread would have suspended or there was an error, respectivly.</P
+><P
+>If the semaphore was not successfully locked, the semaphore will be unchanged.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7472"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>res = SDL_SemTryWait(my_sem);
+
+if (res == SDL_MUTEX_TIMEOUT) {
+        return TRY_AGAIN;
+}
+if (res == -1) {
+        return WAIT_ERROR;
+}
+
+...
+
+SDL_SemPost(my_sem);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7476"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsemwait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsemwaittimeout.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SemWait</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SemWaitTimeout</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsemvalue.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,265 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SemValue</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SemPost"
+HREF="sdlsempost.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateCond"
+HREF="sdlcreatecond.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsempost.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatecond.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSEMVALUE"
+>SDL_SemValue</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7593"
+></A
+><H2
+>Name</H2
+>SDL_SemValue&nbsp;--&nbsp;Return the current value of a semaphore.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7596"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7597"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL/SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_SemValue</B
+></CODE
+>(SDL_sem *sem);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7603"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue()</TT
+> returns the current semaphore value from
+the semaphore pointed to by <TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7608"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns current value of the semaphore.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7611"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>  sem_value = SDL_SemValue(my_sem);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7615"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsempost.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatecond.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SemPost</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateCond</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsemwait.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,290 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SemWait</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DestroySemaphore"
+HREF="sdldestroysemaphore.html"><LINK
+REL="NEXT"
+TITLE="SDL_SemTryWait"
+HREF="sdlsemtrywait.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldestroysemaphore.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsemtrywait.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSEMWAIT"
+>SDL_SemWait</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7398"
+></A
+><H2
+>Name</H2
+>SDL_SemWait&nbsp;--&nbsp;Lock a semaphore and suspend the thread if the semaphore value is zero.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7401"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7402"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SemWait</B
+></CODE
+>(SDL_sem *sem);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7408"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait()</TT
+> suspends the calling thread until either
+the semaphore pointed to by <TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+> has a positive value,
+the call is interrupted by a signal or error. If the call is successful it
+will atomically decrement the semaphore value.</P
+><P
+>After <TT
+CLASS="FUNCTION"
+>SDL_SemWait()</TT
+> is successful, the semaphore
+can be released and its count atomically incremented by a successful call to
+<A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7416"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if successful or
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if there was an error (leaving the semaphore unchanged).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7421"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>if (SDL_SemWait(my_sem) == -1) {
+        return WAIT_FAILED;
+}
+
+...
+
+SDL_SemPost(my_sem);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7425"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsemwaittimeout.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldestroysemaphore.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsemtrywait.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DestroySemaphore</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SemTryWait</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsemwaittimeout.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,314 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SemWaitTimeout</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SemTryWait"
+HREF="sdlsemtrywait.html"><LINK
+REL="NEXT"
+TITLE="SDL_SemPost"
+HREF="sdlsempost.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsemtrywait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsempost.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSEMWAITTIMEOUT"
+>SDL_SemWaitTimeout</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7495"
+></A
+><H2
+>Name</H2
+>SDL_SemWaitTimeout&nbsp;--&nbsp;Lock a semaphore, but only wait up to a specified maximum time.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7498"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7499"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SemWaitTimeout</B
+></CODE
+>(SDL_sem *sem, Uint32 timeout);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7505"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout()</TT
+> is a varient of
+<A
+HREF="sdlsemwait.html"
+>SDL_SemWait</A
+>
+with a maximum timeout value.
+If the value of the semaphore pointed to by <TT
+CLASS="PARAMETER"
+><I
+>sem</I
+></TT
+> is
+positive (greater than zero) it will atomically decrement the semaphore value
+and return 0, otherwise it will wait up to <TT
+CLASS="PARAMETER"
+><I
+>timeout</I
+></TT
+>
+milliseconds trying to lock the semaphore. This function is to be avoided if
+possible since on some platforms it is implemented by polling the semaphore
+every millisecond in a busy loop.</P
+><P
+>After <TT
+CLASS="FUNCTION"
+>SDL_SemWaitTimeout()</TT
+> is successful, the semaphore
+can be released and its count atomically incremented by a successful call to
+<A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7515"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if the semaphore was successfully locked or
+either <SPAN
+CLASS="RETURNVALUE"
+>SDL_MUTEX_TIMEOUT</SPAN
+> or <SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+>
+if the timeout period was exceeded or there was an error, respectivly.</P
+><P
+>If the semaphore was not successfully locked, the semaphore will be unchanged.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7522"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>res = SDL_SemWaitTimeout(my_sem, WAIT_TIMEOUT_MILLISEC);
+
+if (res == SDL_MUTEX_TIMEOUT) {
+        return TRY_AGAIN;
+}
+if (res == -1) {
+        return WAIT_ERROR;
+}
+
+...
+
+SDL_SemPost(my_sem);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7526"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatesemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateSemaphore</TT
+></A
+>,
+<A
+HREF="sdldestroysemaphore.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DestroySemaphore</TT
+></A
+>,
+<A
+HREF="sdlsemwait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemWait</TT
+></A
+>,
+<A
+HREF="sdlsemtrywait.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemTryWait</TT
+></A
+>,
+<A
+HREF="sdlsempost.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemPost</TT
+></A
+>,
+<A
+HREF="sdlsemvalue.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SemValue</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsemtrywait.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsempost.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SemTryWait</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SemPost</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetalpha.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,440 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetAlpha</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetColorKey"
+HREF="sdlsetcolorkey.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetClipRect"
+HREF="sdlsetcliprect.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetcolorkey.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetcliprect.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETALPHA"
+>SDL_SetAlpha</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1612"
+></A
+><H2
+>Name</H2
+>SDL_SetAlpha&nbsp;--&nbsp;Adjust the alpha properties of a surface</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1615"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1616"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetAlpha</B
+></CODE
+>(SDL_Surface *surface, Uint32 flag, Uint8 alpha);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1622"
+></A
+><H2
+>Description</H2
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>This function and the semantics of SDL alpha blending have changed since version 1.1.4. Up until version 1.1.5, an alpha value of 0 was considered opaque and a value of 255 was considered transparent. This has now been inverted: 0 (<TT
+CLASS="LITERAL"
+>SDL_ALPHA_TRANSPARENT</TT
+>) is now considered transparent and 255 (<TT
+CLASS="LITERAL"
+>SDL_ALPHA_OPAQUE</TT
+>) is now considered opaque.</P
+></BLOCKQUOTE
+></DIV
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_SetAlpha</TT
+> is used for setting the per-surface alpha and/or enabling and disabling per-pixel alpha blending.</P
+><P
+>The <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> parameter specifies which surface whose alpha attributes you wish to adjust. <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> is used to specify whether alpha blending should be used (<TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+>) and whether the surface should use RLE acceleration for blitting (<TT
+CLASS="LITERAL"
+>SDL_RLEACCEL</TT
+>). <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> can be an OR'd combination of these two options, one of these options or 0. If <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+> is not passed as a flag then all alpha information is ignored when blitting the surface. The <TT
+CLASS="PARAMETER"
+><I
+>alpha</I
+></TT
+> parameter is the per-surface alpha value, a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with <TT
+CLASS="LITERAL"
+>SDL_RLEACCEL</TT
+>. Setting the per-surface alpha value to 0 disables per-surface alpha blending.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>The per-surface alpha value of 128 is considered a special case and is optimised, so it's much faster than other per-surface values.</P
+></BLOCKQUOTE
+></DIV
+><P
+>Alpha effects surface blitting in the following ways:</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN1642"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGBA-&#62;RGB with <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The source is alpha-blended with the destination, using the alpha channel. <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> and the per-surface alpha are ignored.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGBA-&#62;RGB without <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The RGB data is copied from the source. The source alpha channel and the per-surface alpha value are ignored.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGB-&#62;RGBA with <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The source is alpha-blended with the destination using the per-surface alpha value. If <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+>literal&#62; is set, only the pixels not matching the colorkey value are copied.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGB-&#62;RGBA without <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The RGB data is copied from the source and the destination alpha is zero to opaque. If <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> is set, only the pixels not matching the colorkey value are copied.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGBA-&#62;RGBA with <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The source is alpha-blended with the destination using the source alpha channel. The alpha channel in the destination surface is left untouched. <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> is ignored.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGBA-&#62;RGBA without <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The RGBA data is copied to the destination surface. If <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> is set, only the pixels not matching the colorkey value are copied.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGB-&#62;RGB with <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The source is alpha-blended with the destination using the per-surface alpha value. If <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> is set, only the pixels not matching the colorkey value are copied.</P
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>RGB-&#62;RGB without <TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><P
+>The RGB data is copied from the source. If <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> is set, only the pixels not matching the colorkey value are copied.</P
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1692"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlmaprgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGBA</TT
+></A
+>,
+<A
+HREF="sdlgetrgba.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetRGBA</TT
+></A
+>,
+<A
+HREF="sdldisplayformatalpha.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayFormatAlpha</TT
+></A
+>,
+<A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetcolorkey.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetcliprect.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetColorKey</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetClipRect</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetcliprect.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,233 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetClipRect</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetAlpha"
+HREF="sdlsetalpha.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetClipRect"
+HREF="sdlgetcliprect.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetalpha.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetcliprect.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETCLIPRECT"
+>SDL_SetClipRect</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1707"
+></A
+><H2
+>Name</H2
+>SDL_SetClipRect&nbsp;--&nbsp;Sets the clipping rectangle for a surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1710"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1711"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_SetClipRect</B
+></CODE
+>(SDL_Surface *surface, SDL_Rect *rect);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1717"
+></A
+><H2
+>Description</H2
+><P
+>Sets the clipping rectangle for a surface.  When this surface is the
+destination of a blit, only the area within the clip rectangle will be
+drawn into.</P
+><P
+>The rectangle pointed to by <TT
+CLASS="PARAMETER"
+><I
+>rect</I
+></TT
+> will be
+clipped to the edges of the surface so that the clip rectangle for a
+surface can never fall outside the edges of the surface.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>rect</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>NULL</TT
+> the clipping
+rectangle will be set to the full size of the surface.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1725"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetcliprect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetClipRect</TT
+></A
+>,
+<A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetalpha.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetcliprect.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetAlpha</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetClipRect</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetcolorkey.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,313 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetColorKey</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SaveBMP"
+HREF="sdlsavebmp.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetAlpha"
+HREF="sdlsetalpha.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsavebmp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetalpha.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETCOLORKEY"
+>SDL_SetColorKey</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1561"
+></A
+><H2
+>Name</H2
+>SDL_SetColorKey&nbsp;--&nbsp;Sets the color key (transparent pixel) in a blittable surface and
+RLE acceleration.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1564"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1565"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetColorKey</B
+></CODE
+>(SDL_Surface *surface, Uint32 flag, Uint32 key);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1571"
+></A
+><H2
+>Description</H2
+><P
+> Sets the color key (transparent pixel) in a blittable surface and enables or
+ disables RLE blit acceleration.</P
+><P
+>RLE acceleration can substantially speed up blitting of images with large
+horizontal runs of transparent pixels (i.e., pixels that match the
+<TT
+CLASS="PARAMETER"
+><I
+>key</I
+></TT
+> value). The <TT
+CLASS="PARAMETER"
+><I
+>key</I
+></TT
+> must be of the same pixel format as the <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+>, <A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+> is often useful for obtaining an acceptable value.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>flag</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_SRCCOLORKEY</TT
+> then
+<TT
+CLASS="PARAMETER"
+><I
+>key</I
+></TT
+> is the transparent pixel value in the source image of a
+blit.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>flag</I
+></TT
+> is OR'd with
+<TT
+CLASS="LITERAL"
+>SDL_RLEACCEL</TT
+> then the surface will be draw using RLE
+acceleration when drawn with
+<A
+HREF="sdlblitsurface.html"
+>SDL_BlitSurface</A
+>.  The surface will
+actually be encoded for RLE acceleration the first time
+<A
+HREF="sdlblitsurface.html"
+>SDL_BlitSurface</A
+> or
+<A
+HREF="sdldisplayformat.html"
+>SDL_DisplayFormat</A
+> is called on the
+surface.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>flag</I
+></TT
+> is 0, this function clears
+any current color key.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1592"
+></A
+><H2
+>Return Value</H2
+><P
+>This function returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, or
+<SPAN
+CLASS="RETURNVALUE"
+>-1</SPAN
+> if there was an error.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1597"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlblitsurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_BlitSurface</TT
+></A
+>,
+<A
+HREF="sdldisplayformat.html"
+><TT
+CLASS="FUNCTION"
+>SDL_DisplayFormat</TT
+></A
+>,
+<A
+HREF="sdlmaprgb.html"
+><TT
+CLASS="FUNCTION"
+>SDL_MapRGB</TT
+></A
+>,
+<A
+HREF="sdlsetalpha.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetAlpha</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsavebmp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetalpha.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SaveBMP</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetAlpha</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetcolors.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,350 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetColors</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Flip"
+HREF="sdlflip.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetPalette"
+HREF="sdlsetpalette.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlflip.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetpalette.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETCOLORS"
+>SDL_SetColors</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1005"
+></A
+><H2
+>Name</H2
+>SDL_SetColors&nbsp;--&nbsp;Sets a portion of the colormap for the given 8-bit surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1008"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1009"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetColors</B
+></CODE
+>(SDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1015"
+></A
+><H2
+>Description</H2
+><P
+>Sets a portion of the colormap for the given 8-bit surface.</P
+><P
+>When <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> is the surface associated with the current
+display, the display colormap will be updated with the requested colors.  If
+<TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+> was set in <A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+> flags,
+<TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+> will always return <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>,
+and the palette is guaranteed to be set the way you desire, even if the window
+colormap has to be warped or run under emulation.</P
+><P
+>The color components of a
+<A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+>
+structure are 8-bits in size, giving you a total of 256<SUP
+>3</SUP
+>
+=16777216 colors.</P
+><P
+>Palettized (8-bit) screen surfaces with the <TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+>
+flag have two palettes, a logical palette that is used for mapping blits
+to/from the surface and a physical palette (that determines how the
+hardware will map the colors to the display). <TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+>
+modifies both palettes (if present), and is equivalent to calling
+<A
+HREF="sdlsetpalette.html"
+>SDL_SetPalette</A
+> with the
+<TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> set to
+<TT
+CLASS="LITERAL"
+>(SDL_LOGPAL | SDL_PHYSPAL)</TT
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1034"
+></A
+><H2
+>Return Value</H2
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> is not a palettized surface, this function
+does nothing, returning <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>.  If all of the colors were set
+as passed to <TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+>, it will return
+<SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>.  If not all the color entries were set exactly as
+given, it will return <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, and you should look at the
+surface palette to determine the actual color palette.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1042"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>/* Create a display surface with a grayscale palette */
+SDL_Surface *screen;
+SDL_Color colors[256];
+int i;
+.
+.
+.
+/* Fill colors with color information */
+for(i=0;i&#60;256;i++){
+  colors[i].r=i;
+  colors[i].g=i;
+  colors[i].b=i;
+}
+
+/* Create display */
+screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
+if(!screen){
+  printf("Couldn't set video mode: %s\n", SDL_GetError());
+  exit(-1);
+}
+
+/* Set palette */
+SDL_SetColors(screen, colors, 0, 256);
+.
+.
+.
+.</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1045"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+>
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdlsetpalette.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetPalette</TT
+></A
+>,
+<A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlflip.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetpalette.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Flip</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetPalette</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetcursor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetCursor</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_FreeCursor"
+HREF="sdlfreecursor.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetCursor"
+HREF="sdlgetcursor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlfreecursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetcursor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETCURSOR"
+>SDL_SetCursor</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2065"
+></A
+><H2
+>Name</H2
+>SDL_SetCursor&nbsp;--&nbsp;Set the currently active mouse cursor.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2068"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2069"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void *<B
+CLASS="FSFUNC"
+>SDL_SetCursor</B
+></CODE
+>(SDL_Cursor *cursor);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2075"
+></A
+><H2
+>Description</H2
+><P
+>Sets the currently active cursor to 
+the specified one.
+If the cursor is currently visible, the change will be immediately 
+represented on the display.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2078"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetCursor</TT
+></A
+>,
+<A
+HREF="sdlcreatecursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateCursor</TT
+></A
+>,
+<A
+HREF="sdlshowcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_ShowCursor</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlfreecursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetcursor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_FreeCursor</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetCursor</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlseteventfilter.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,273 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetEventFilter</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PushEvent"
+HREF="sdlpushevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetEventFilter"
+HREF="sdlgeteventfilter.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpushevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgeteventfilter.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETEVENTFILTER"
+>SDL_SetEventFilter</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4957"
+></A
+><H2
+>Name</H2
+>SDL_SetEventFilter&nbsp;--&nbsp;Sets up a filter to process all events before they are posted 
+to the event queue.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4960"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4961"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_SetEventFilter</B
+></CODE
+>(SDL_EventFilter filter);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4967"
+></A
+><H2
+>Description</H2
+><P
+>This function sets up a filter to process all events before they are posted 
+to the event queue.  This is a very powerful and flexible feature.  The filter 
+is prototyped as:
+<PRE
+CLASS="PROGRAMLISTING"
+>typedef int (*SDL_EventFilter)(const SDL_Event *event);</PRE
+>
+If the filter returns <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>, then the event will be 
+added to the internal queue.  If it returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, 
+then the event will be dropped from the queue.  This allows selective
+filtering of dynamically.</P
+><P
+>There is one caveat when dealing with the <TT
+CLASS="LITERAL"
+>SDL_QUITEVENT</TT
+> event type.  The
+event filter is only called when the window manager desires to close the
+application window.  If the event filter returns 1, then the window will
+be closed, otherwise the window will remain open if possible.
+If the quit event is generated by an interrupt signal, it will bypass the
+internal queue and be delivered to the application at the next event poll.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Events pushed onto the queue with <A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+> or <A
+HREF="sdlpeepevents.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PeepEvents</TT
+></A
+> do not get passed through the event filter.</P
+></BLOCKQUOTE
+></DIV
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+><I
+CLASS="EMPHASIS"
+>Be Careful!</I
+> The event filter function may run in a different thread so be careful what you do within it.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4984"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlgeteventfilter.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetEventFilter</TT
+></A
+>,
+<A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpushevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgeteventfilter.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PushEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetEventFilter</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetgamma.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetGamma</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetPalette"
+HREF="sdlsetpalette.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetGammaRamp"
+HREF="sdlgetgammaramp.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetpalette.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetgammaramp.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETGAMMA"
+>SDL_SetGamma</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1112"
+></A
+><H2
+>Name</H2
+>SDL_SetGamma&nbsp;--&nbsp;Sets the color gamma function for the display</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1115"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1116"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetGamma</B
+></CODE
+>(float redgamma, float greengamma, float bluegamma);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1122"
+></A
+><H2
+>Description</H2
+><P
+>Sets the "gamma function" for the display of each color component.  Gamma
+controls the brightness/contrast of colors displayed on the screen.
+A gamma value of <TT
+CLASS="CONSTANT"
+>1.0</TT
+> is identity (i.e., no adjustment
+is made).</P
+><P
+>This function adjusts the gamma based on the "gamma function" parameter,
+you can directly specify lookup tables for gamma adjustment with
+<A
+HREF="sdlsetgammaramp.html"
+>SDL_SetGammaRamp</A
+>.</P
+><P
+>Not all display hardware is able to change gamma.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1129"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns -1 on error (or if gamma adjustment is not supported).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1132"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetgammaramp.html"
+>SDL_GetGammaRamp</A
+>
+<A
+HREF="sdlsetgammaramp.html"
+>SDL_SetGammaRamp</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetpalette.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetgammaramp.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetPalette</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetGammaRamp</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetgammaramp.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,222 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetGammaRamp</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetGammaRamp"
+HREF="sdlgetgammaramp.html"><LINK
+REL="NEXT"
+TITLE="SDL_MapRGB"
+HREF="sdlmaprgb.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetgammaramp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlmaprgb.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETGAMMARAMP"
+>SDL_SetGammaRamp</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1167"
+></A
+><H2
+>Name</H2
+>SDL_SetGammaRamp&nbsp;--&nbsp;Sets the color gamma lookup tables for the display</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1170"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1171"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetGammaRamp</B
+></CODE
+>(Uint16 *redtable, Uint16 *greentable, Uint16 *bluetable);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1177"
+></A
+><H2
+>Description</H2
+><P
+>Sets the gamma lookup tables for the display for each color component.
+Each table is an array of 256 Uint16 values, representing a mapping
+between the input and output for that channel. The input is the index
+into the array, and the output is the 16-bit gamma value at that index,
+scaled to the output color precision. You may pass NULL to any of the
+channels to leave them unchanged.</P
+><P
+>This function adjusts the gamma based on lookup tables, you can also
+have the gamma calculated based on a "gamma function" parameter with
+<A
+HREF="sdlsetgamma.html"
+>SDL_SetGamma</A
+>.</P
+><P
+>Not all display hardware is able to change gamma.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1183"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns -1 on error (or if gamma adjustment is not supported).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1186"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetgamma.html"
+>SDL_SetGamma</A
+>
+<A
+HREF="sdlgetgammaramp.html"
+>SDL_GetGammaRamp</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetgammaramp.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlmaprgb.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetGammaRamp</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_MapRGB</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetmodstate.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,229 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetModState</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetModState"
+HREF="sdlgetmodstate.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetKeyName"
+HREF="sdlgetkeyname.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetmodstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetkeyname.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETMODSTATE"
+>SDL_SetModState</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN5134"
+></A
+><H2
+>Name</H2
+>SDL_SetModState&nbsp;--&nbsp;Set the current key modifier state</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN5137"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN5138"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_SetModState</B
+></CODE
+>(SDLMod modstate);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5144"
+></A
+><H2
+>Description</H2
+><P
+>The inverse of <A
+HREF="sdlgetmodstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetModState</TT
+></A
+>, <TT
+CLASS="FUNCTION"
+>SDL_SetModState</TT
+> allows you to impose modifier key states on your application.</P
+><P
+>Simply pass your desired modifier states into <TT
+CLASS="PARAMETER"
+><I
+>modstate</I
+></TT
+>. This value my be a logical OR'd combination of the following:</P
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef enum {
+  KMOD_NONE  = 0x0000,
+  KMOD_LSHIFT= 0x0001,
+  KMOD_RSHIFT= 0x0002,
+  KMOD_LCTRL = 0x0040,
+  KMOD_RCTRL = 0x0080,
+  KMOD_LALT  = 0x0100,
+  KMOD_RALT  = 0x0200,
+  KMOD_LMETA = 0x0400,
+  KMOD_RMETA = 0x0800,
+  KMOD_NUM   = 0x1000,
+  KMOD_CAPS  = 0x2000,
+  KMOD_MODE  = 0x4000,
+} SDLMod;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN5153"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlgetmodstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetModState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetmodstate.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetkeyname.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetModState</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetKeyName</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetpalette.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,344 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetPalette</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetColors"
+HREF="sdlsetcolors.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetGamma"
+HREF="sdlsetgamma.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetcolors.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetgamma.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETPALETTE"
+>SDL_SetPalette</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1060"
+></A
+><H2
+>Name</H2
+>SDL_SetPalette&nbsp;--&nbsp;Sets the colors in the palette of an 8-bit surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1063"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1064"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetPalette</B
+></CODE
+>(SDL_Surface *surface, int flags, int SDL_Color *colors, int firstcolor, int ncolors);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1070"
+></A
+><H2
+>Description</H2
+><P
+>Sets a portion of the palette for the given 8-bit surface.</P
+><P
+>Palettized (8-bit) screen surfaces with the
+<TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+> flag have two palettes, a logical
+palette that is used for mapping blits to/from the surface and a
+physical palette (that determines how the hardware will map the colors
+to the display). <A
+HREF="sdlblitsurface.html"
+>SDL_BlitSurface</A
+>
+always uses the logical palette when blitting surfaces (if it has to
+convert between surface pixel formats). Because of this, it is often
+useful to modify only one or the other palette to achieve various
+special color effects (e.g., screen fading, color flashes, screen dimming).</P
+><P
+>This function can modify either the logical or physical palette by
+specifing <TT
+CLASS="LITERAL"
+>SDL_LOGPAL</TT
+> or
+<TT
+CLASS="LITERAL"
+>SDL_PHYSPAL</TT
+>the in the <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+>
+parameter.</P
+><P
+>When <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> is the surface associated with the current
+display, the display colormap will be updated with the requested colors.  If
+<TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+> was set in <A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+> flags,
+<TT
+CLASS="FUNCTION"
+>SDL_SetPalette</TT
+> will always return <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>,
+and the palette is guaranteed to be set the way you desire, even if the window
+colormap has to be warped or run under emulation.</P
+><P
+>The color components of a
+<A
+HREF="sdlcolor.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Color</SPAN
+></A
+> structure
+are 8-bits in size, giving you a total of
+256<SUP
+>3</SUP
+>=16777216 colors.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1090"
+></A
+><H2
+>Return Value</H2
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>surface</I
+></TT
+> is not a palettized surface, this function
+does nothing, returning <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>.  If all of the colors were set
+as passed to <TT
+CLASS="FUNCTION"
+>SDL_SetPalette</TT
+>, it will return
+<SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>.  If not all the color entries were set exactly as
+given, it will return <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, and you should look at the
+surface palette to determine the actual color palette.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1098"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>        /* Create a display surface with a grayscale palette */
+        SDL_Surface *screen;
+        SDL_Color colors[256];
+        int i;
+        .
+        .
+        .
+        /* Fill colors with color information */
+        for(i=0;i&#60;256;i++){
+          colors[i].r=i;
+          colors[i].g=i;
+          colors[i].b=i;
+        }
+
+        /* Create display */
+        screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
+        if(!screen){
+          printf("Couldn't set video mode: %s\n", SDL_GetError());
+          exit(-1);
+        }
+
+        /* Set palette */
+        SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
+        .
+        .
+        .
+        .</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1101"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetcolors.html"
+>SDL_SetColors</A
+>,
+<A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+>,
+<A
+HREF="sdlsurface.html"
+>SDL_Surface</A
+>,
+<A
+HREF="sdlcolor.html"
+>SDL_Color</A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetcolors.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetgamma.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetColors</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetGamma</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsettimer.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,261 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetTimer</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Time"
+HREF="time.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_RemoveTimer"
+HREF="sdlremovetimer.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlremovetimer.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+>&nbsp;</TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETTIMER"
+>SDL_SetTimer</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7926"
+></A
+><H2
+>Name</H2
+>SDL_SetTimer&nbsp;--&nbsp;Set a callback to run after the specified number of milliseconds has
+elapsed.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7929"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7930"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_SetTimer</B
+></CODE
+>(Uint32 interval, SDL_TimerCallback callback);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="SDLTIMERCALLBACK"
+></A
+><H2
+>Callback</H2
+><P
+>/* Function prototype for the timer callback function */
+typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7939"
+></A
+><H2
+>Description</H2
+><P
+>Set a callback to run after the specified number of milliseconds has
+elapsed. The callback function is passed the current timer interval
+and returns the next timer interval.  If the returned value is the
+same as the one passed in, the periodic alarm continues, otherwise a
+new alarm is scheduled.</P
+><P
+>To cancel a currently running timer, call
+<TT
+CLASS="FUNCTION"
+>SDL_SetTimer(0, NULL);</TT
+></P
+><P
+>The timer callback function may run in a different thread than your
+main constant, and so shouldn't call any functions from within itself.</P
+><P
+>The maximum resolution of this timer is 10 ms, which means that if
+you request a 16 ms timer, your callback will run approximately 20 ms
+later on an unloaded system.  If you wanted to set a flag signaling
+a frame update at 30 frames per second (every 33 ms), you might set a
+timer for 30 ms (see example below).</P
+><P
+>If you use this function, you need to pass <TT
+CLASS="LITERAL"
+>SDL_INIT_TIMER</TT
+>
+to <TT
+CLASS="FUNCTION"
+>SDL_Init()</TT
+>.</P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>This function is kept for compatibility but has been superceeded
+by the new timer functions
+<A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+> and
+<A
+HREF="sdlremovetimer.html"
+>SDL_RemoveTimer</A
+> which support
+multiple timers.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7953"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_SetTimer((33/10)*10, my_callback);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7957"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdladdtimer.html"
+><TT
+CLASS="FUNCTION"
+>SDL_AddTimer</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlremovetimer.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>&nbsp;</TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_RemoveTimer</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="time.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>&nbsp;</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsetvideomode.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,486 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SetVideoMode</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_VideoModeOK"
+HREF="sdlvideomodeok.html"><LINK
+REL="NEXT"
+TITLE="SDL_UpdateRect"
+HREF="sdlupdaterect.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlvideomodeok.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlupdaterect.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSETVIDEOMODE"
+>SDL_SetVideoMode</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN795"
+></A
+><H2
+>Name</H2
+>SDL_SetVideoMode&nbsp;--&nbsp;Set up a video mode with the specified width, height and bits-per-pixel.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN798"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN799"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_Surface *<B
+CLASS="FSFUNC"
+>SDL_SetVideoMode</B
+></CODE
+>(int width, int height, int bpp, Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN805"
+></A
+><H2
+>Description</H2
+><P
+>Set up a video mode with the specified width, height and bits-per-pixel.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>bpp</I
+></TT
+> is 0, it is treated as the 
+current display bits per pixel.</P
+><P
+>The <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> parameter is the same as the <TT
+CLASS="STRUCTFIELD"
+><I
+>flags</I
+></TT
+> field of the <A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+> structure. OR'd combinations of the following values are valid.</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN815"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Create the video surface in system memory</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Create the video surface in video memory</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_ASYNCBLIT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Enables the use of asynchronous to the display surface. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_ANYFORMAT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Normally, if a video surface of the requested depth (<TT
+CLASS="PARAMETER"
+><I
+>bpp</I
+></TT
+>) is not available, SDL will emulate one with a shadow surface. Passing <TT
+CLASS="LITERAL"
+>SDL_ANYFORMAT</TT
+> prevents this and causes SDL to use the video surface, regardless of its depth.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Give SDL exclusive palette access. Without this flag you may not always get the the colors you request with <A
+HREF="sdlsetcolors.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+></A
+>.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_DOUBLEBUF</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Enable double buffering. Calling <A
+HREF="sdlflip.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Flip</TT
+></A
+> will flip the buffers and update the screen. If double buffering could not be enabled then <TT
+CLASS="FUNCTION"
+>SDL_Flip</TT
+> will just perform a <A
+HREF="sdlupdaterect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+></A
+> on the entire screen.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_FULLSCREEN</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>SDL will attempt to use a fullscreen mode</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_OPENGL</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Create an OpenGL rendering context. You should have previously set OpenGL video attributes with <A
+HREF="sdlglsetattribute.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GL_SetAttribute</TT
+></A
+>.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_OPENGLBLIT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Create an OpenGL rendering context, like above, but allow normal blitting operations.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_RESIZABLE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Create a resizable window. When the window is resized by the user a <A
+HREF="sdlresizeevent.html"
+><TT
+CLASS="LITERAL"
+>SDL_VIDEORESIZE</TT
+></A
+> event is generated and <TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+> can be called again with the new size.</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_NOFRAME</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>If possible, <TT
+CLASS="LITERAL"
+>SDL_NOFRAME</TT
+> causes SDL to create a window with no title bar or frame decoration. Fullscreen modes automatically have this flag set.</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>Whatever <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> <TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+> could satisfy are set in the <TT
+CLASS="STRUCTFIELD"
+><I
+>flags</I
+></TT
+> member of the returned surface.</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN882"
+></A
+><H2
+>Return Value</H2
+><P
+>The framebuffer surface, or <SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+> if it fails.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN886"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+>,
+<A
+HREF="sdlsetcolors.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetColors</TT
+></A
+>,
+<A
+HREF="sdlflip.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Flip</TT
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlvideomodeok.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlupdaterect.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_VideoModeOK</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UpdateRect</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlshowcursor.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,231 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ShowCursor</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetCursor"
+HREF="sdlgetcursor.html"><LINK
+REL="NEXT"
+TITLE="SDL_GL_LoadLibrary"
+HREF="sdlglloadlibrary.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlglloadlibrary.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSHOWCURSOR"
+>SDL_ShowCursor</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2117"
+></A
+><H2
+>Name</H2
+>SDL_ShowCursor&nbsp;--&nbsp;Toggle whether or not the cursor is shown on the screen.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2120"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2121"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_ShowCursor</B
+></CODE
+>(int toggle);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2127"
+></A
+><H2
+>Description</H2
+><P
+>Toggle whether or not the cursor is shown on the screen. Passing <TT
+CLASS="LITERAL"
+>SDL_ENABLE</TT
+> displays the cursor and passing <TT
+CLASS="LITERAL"
+>SDL_DISABLE</TT
+> hides it. The current state of the mouse cursor can be queried by passing <TT
+CLASS="LITERAL"
+>SDL_QUERY</TT
+>, either <TT
+CLASS="LITERAL"
+>SDL_DISABLE</TT
+> or <TT
+CLASS="LITERAL"
+>SDL_ENABLE</TT
+> will be returned.</P
+><P
+>The cursor starts off displayed, but can be turned off.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2136"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns the current state of the cursor.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2139"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatecursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateCursor</TT
+></A
+>,
+<A
+HREF="sdlsetcursor.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetCursor</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetcursor.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlglloadlibrary.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetCursor</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GL_LoadLibrary</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,614 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_Surface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PixelFormat"
+HREF="sdlpixelformat.html"><LINK
+REL="NEXT"
+TITLE="SDL_VideoInfo"
+HREF="sdlvideoinfo.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpixelformat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlvideoinfo.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSURFACE"
+>SDL_Surface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2762"
+></A
+><H2
+>Name</H2
+>SDL_Surface&nbsp;--&nbsp;Graphical Surface Structure</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2765"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct SDL_Surface {
+        Uint32 flags;                           /* Read-only */
+        SDL_PixelFormat *format;                /* Read-only */
+        int w, h;                               /* Read-only */
+        Uint16 pitch;                           /* Read-only */
+        void *pixels;                           /* Read-write */
+        int offset;                             /* Private */
+
+        /* Hardware-specific surface info */
+        struct private_hwdata *hwdata;
+
+        /* clipping information */
+        SDL_Rect clip_rect;                     /* Read-only */
+        Uint32 unused1;                         /* for binary compatibility */
+        Uint32 unused2;                         /* for binary compatibility */
+
+        /* info for fast blit mapping to other surfaces */
+        struct SDL_BlitMap *map;                /* Private */
+
+        /* format version, bumped at every change to invalidate blit maps */
+        unsigned int format_version;            /* Private */
+
+        /* Reference count -- used when freeing surface */
+        int refcount;                           /* Read-mostly */
+} SDL_Surface;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2768"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2770"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>flags</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface flags</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>format</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pixel <A
+HREF="sdlpixelformat.html"
+>format</A
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>w, h</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Width and height of the surface</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>pitch</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Length of a surface scanline in bytes</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Pointer to the actual pixel data</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>clip_minx, clip_maxx</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>X clip coords</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>clip_rect</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>surface clip <A
+HREF="sdlrect.html"
+>rectangle</A
+></TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2803"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+>'s represent areas of "graphical"
+memory, memory that can be drawn to. The video framebuffer is returned
+as a <SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+> by
+<A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>
+and <A
+HREF="sdlgetvideosurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetVideoSurface</TT
+></A
+>.
+Most of the fields should be pretty obvious.
+<TT
+CLASS="STRUCTFIELD"
+><I
+>w</I
+></TT
+> and <TT
+CLASS="STRUCTFIELD"
+><I
+>h</I
+></TT
+> are the
+width and height of the surface in pixels.
+<TT
+CLASS="STRUCTFIELD"
+><I
+>pixels</I
+></TT
+> is a pointer to the actual pixel data,
+the surface should be <A
+HREF="sdllocksurface.html"
+>locked</A
+>
+before accessing this field. The <TT
+CLASS="STRUCTFIELD"
+><I
+>clip_rect</I
+></TT
+> field
+is the clipping rectangle as set by
+<A
+HREF="sdlsetcliprect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetClipRect</TT
+></A
+>.</P
+><P
+>The following are supported in the
+<TT
+CLASS="STRUCTFIELD"
+><I
+>flags</I
+></TT
+> field.</P
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2821"
+></A
+><P
+></P
+><TABLE
+BORDER="1"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface is stored in system memory</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWSURFACE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface is stored in video memory</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_ASYNCBLIT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface uses asynchronous blits if possible</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_ANYFORMAT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Allows any pixel-format (Display surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWPALETTE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface has exclusive palette</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_DOUBLEBUF</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface is double buffered (Display surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_FULLSCREEN</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface is full screen (Display Surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_OPENGL</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface has an OpenGL context (Display Surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_OPENGLBLIT</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface supports OpenGL blitting (Display Surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_RESIZABLE</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface is resizable (Display Surface)</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_HWACCEL</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface blit uses hardware acceleration</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SRCOLORKEY</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface use colorkey blitting</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_RLEACCEL</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Colorkey blitting is accelerated with RLE</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_SRCALPHA</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface blit uses alpha blending</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_PREALLOC</TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Surface uses preallocated memory</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2884"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpixelformat.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlvideoinfo.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PixelFormat</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_VideoInfo</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlsyswmevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,224 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_SysWMEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ResizeEvent"
+HREF="sdlresizeevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_UserEvent"
+HREF="sdluserevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlresizeevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdluserevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLSYSWMEVENT"
+>SDL_SysWMEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3995"
+></A
+><H2
+>Name</H2
+>SDL_SysWMEvent&nbsp;--&nbsp;Platform-dependent window manager event.</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3998"
+></A
+><H2
+>Description</H2
+><P
+>The system window manager event contains a pointer to system-specific 
+information about unknown window manager events.  If you enable this event
+using 
+<A
+HREF="sdleventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EventState()</TT
+></A
+>, 
+it will be generated whenever unhandled events are received from the window 
+manager.  This can be used, for example, to implement cut-and-paste in your 
+application.
+
+<PRE
+CLASS="PROGRAMLISTING"
+>typedef struct {
+         Uint8 type;   /* Always SDL_SysWM */
+ } SDL_SysWMEvent;</PRE
+>
+
+If you want to obtain system-specific information about the window manager,
+you can fill the version member of a <SPAN
+CLASS="STRUCTNAME"
+>SDL_SysWMinfo</SPAN
+> 
+structure (details can be found in <TT
+CLASS="FILENAME"
+>SDL_syswm.h</TT
+>, which must be included) using the <TT
+CLASS="FUNCTION"
+>SDL_VERSION()</TT
+> macro found in 
+<TT
+CLASS="FILENAME"
+>SDL_version.h</TT
+>, and pass it to the 
+function:
+<DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4008"
+></A
+><P
+></P
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_GetWMInfo</B
+></CODE
+>(SDL_SysWMinfo *info);</CODE
+></P
+><P
+></P
+></DIV
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4013"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdleventstate.html"
+><TT
+CLASS="FUNCTION"
+>SDL_EventState</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlresizeevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdluserevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ResizeEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UserEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlthreadid.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,182 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_ThreadID</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CreateThread"
+HREF="sdlcreatethread.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetThreadID"
+HREF="sdlgetthreadid.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcreatethread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetthreadid.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLTHREADID"
+>SDL_ThreadID</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7101"
+></A
+><H2
+>Name</H2
+>SDL_ThreadID&nbsp;--&nbsp;Get the 32-bit thread identifier for the current thread.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7104"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7105"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_ThreadID</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7111"
+></A
+><H2
+>Description</H2
+><P
+>Get the 32-bit thread identifier for the current thread.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcreatethread.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetthreadid.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CreateThread</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetThreadID</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlunlockaudio.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,203 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UnlockAudio</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Audio"
+HREF="audio.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_LockAudio"
+HREF="sdllockaudio.html"><LINK
+REL="NEXT"
+TITLE="SDL_CloseAudio"
+HREF="sdlcloseaudio.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdllockaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcloseaudio.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUNLOCKAUDIO"
+>SDL_UnlockAudio</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN6531"
+></A
+><H2
+>Name</H2
+>SDL_UnlockAudio&nbsp;--&nbsp;Unlock the callback function</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN6534"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN6535"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_UnlockAudio</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6541"
+></A
+><H2
+>Description</H2
+><P
+>Unlocks a previous <A
+HREF="sdllockaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockAudio</TT
+></A
+> call.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN6546"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlopenaudio.html"
+><TT
+CLASS="FUNCTION"
+>SDL_OpenAudio</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdllockaudio.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcloseaudio.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_LockAudio</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="audio.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CloseAudio</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlunlocksurface.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UnlockSurface</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_LockSurface"
+HREF="sdllocksurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_LoadBMP"
+HREF="sdlloadbmp.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdllocksurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlloadbmp.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUNLOCKSURFACE"
+>SDL_UnlockSurface</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1478"
+></A
+><H2
+>Name</H2
+>SDL_UnlockSurface&nbsp;--&nbsp;Unlocks a previously locked surface.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1481"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1482"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_UnlockSurface</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1488"
+></A
+><H2
+>Description</H2
+><P
+>Surfaces that were previously locked using <TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+> must be unlocked with <TT
+CLASS="FUNCTION"
+>SDL_UnlockSurface</TT
+>. Surfaces should be unlocked as soon as possible.</P
+><P
+>It should be noted that since 1.1.8, surface locks are recursive. See <A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1496"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdllocksurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlloadbmp.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_LockSurface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_LoadBMP</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlunlockyuvoverlay.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UnlockYUVOverlay</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_LockYUVOverlay"
+HREF="sdllockyuvoverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_DisplayYUVOverlay"
+HREF="sdldisplayyuvoverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdllockyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdldisplayyuvoverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUNLOCKYUVOVERLAY"
+>SDL_UnlockYUVOverlay</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2382"
+></A
+><H2
+>Name</H2
+>SDL_UnlockYUVOverlay&nbsp;--&nbsp;Unlock an overlay</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN2385"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN2386"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_UnlockYUVOverlay</B
+></CODE
+>(SDL_Overlay *overlay);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2392"
+></A
+><H2
+>Description</H2
+><P
+>The opposite to <A
+HREF="sdllockyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockYUVOverlay</TT
+></A
+>. Unlocks a previously locked overlay. An overlay must be unlocked before it can be displayed.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2397"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdllockyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UnlockYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdlcreateyuvoverlay.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateYUVOverlay</TT
+></A
+>,
+<A
+HREF="sdloverlay.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Overlay</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdllockyuvoverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdldisplayyuvoverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_LockYUVOverlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_DisplayYUVOverlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlupdaterect.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,257 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UpdateRect</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SetVideoMode"
+HREF="sdlsetvideomode.html"><LINK
+REL="NEXT"
+TITLE="SDL_UpdateRects"
+HREF="sdlupdaterects.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsetvideomode.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlupdaterects.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUPDATERECT"
+>SDL_UpdateRect</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN901"
+></A
+><H2
+>Name</H2
+>SDL_UpdateRect&nbsp;--&nbsp;Makes sure the given area is updated on the given screen.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN904"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN905"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_UpdateRect</B
+></CODE
+>(SDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN911"
+></A
+><H2
+>Description</H2
+><P
+>Makes sure the given area is updated on the given screen.</P
+><P
+>If '<TT
+CLASS="PARAMETER"
+><I
+>x</I
+></TT
+>', '<TT
+CLASS="PARAMETER"
+><I
+>y</I
+></TT
+>', '<TT
+CLASS="PARAMETER"
+><I
+>w</I
+></TT
+>'
+and '<TT
+CLASS="PARAMETER"
+><I
+>h</I
+></TT
+>' are all 0,
+<TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+> will update the
+entire screen.</P
+><P
+>This function should not be called while '<TT
+CLASS="PARAMETER"
+><I
+>screen</I
+></TT
+>' is
+<A
+HREF="sdllocksurface.html"
+>locked</A
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN923"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlupdaterects.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRects</TT
+></A
+>,
+<A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsetvideomode.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlupdaterects.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SetVideoMode</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_UpdateRects</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlupdaterects.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,229 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UpdateRects</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_UpdateRect"
+HREF="sdlupdaterect.html"><LINK
+REL="NEXT"
+TITLE="SDL_Flip"
+HREF="sdlflip.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlupdaterect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlflip.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUPDATERECTS"
+>SDL_UpdateRects</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN938"
+></A
+><H2
+>Name</H2
+>SDL_UpdateRects&nbsp;--&nbsp;Makes sure the given list of rectangles is updated on the given screen.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN941"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN942"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_UpdateRects</B
+></CODE
+>(SDL_Surface *screen, int numrects, SDL_Rect *rects);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN948"
+></A
+><H2
+>Description</H2
+><P
+>Makes sure the given list of rectangles is updated on the given screen.</P
+><P
+>This function should not be called while <TT
+CLASS="PARAMETER"
+><I
+>screen</I
+></TT
+> is
+<A
+HREF="sdllocksurface.html"
+>locked</A
+>.&#13;</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN954"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlupdaterect.html"
+><TT
+CLASS="FUNCTION"
+>SDL_UpdateRect</TT
+></A
+>,
+<A
+HREF="sdlrect.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Rect</SPAN
+></A
+>,
+<A
+HREF="sdlsurface.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Surface</SPAN
+></A
+>,
+<A
+HREF="sdllocksurface.html"
+><TT
+CLASS="FUNCTION"
+>SDL_LockSurface</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlupdaterect.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlflip.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_UpdateRect</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Flip</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdluserevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,329 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_UserEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Event Structures."
+HREF="eventstructures.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_SysWMEvent"
+HREF="sdlsyswmevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_QuitEvent"
+HREF="sdlquitevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsyswmevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlquitevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLUSEREVENT"
+>SDL_UserEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4022"
+></A
+><H2
+>Name</H2
+>SDL_UserEvent&nbsp;--&nbsp;A user-defined event type</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4025"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint8 type;
+  int code;
+  void *data1;
+  void *data2;
+} SDL_UserEvent;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4028"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN4030"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="LITERAL"
+>SDL_USEREVENT</TT
+> through to <TT
+CLASS="LITERAL"
+>SDL_NUMEVENTS-1</TT
+></TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>code</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>User defined event code</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>data1</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>User defined data pointer</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>data2</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>User defined data pointer</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4051"
+></A
+><H2
+>Description</H2
+><P
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_UserEvent</SPAN
+> is in the <TT
+CLASS="STRUCTFIELD"
+><I
+>user</I
+></TT
+> member of the structure <A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>. This event is unique, it is never created by SDL but only by the user. The event can be pushed onto the event queue using <A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+>. The contents of the structure members or completely up to the programmer, the only requirement is that <TT
+CLASS="STRUCTFIELD"
+><I
+>type</I
+></TT
+> is a value from <TT
+CLASS="LITERAL"
+>SDL_USEREVENT</TT
+> to <TT
+CLASS="LITERAL"
+>SDL_NUMEVENTS-1</TT
+> (inclusive).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4063"
+></A
+><H2
+>Examples</H2
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_Event event;
+
+event.type = SDL_USEREVENT;
+event.user.code = my_event_code;
+event.user.data1 = significant_data;
+event.user.data2 = 0;
+SDL_PushEvent(&#38;event);</PRE
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4067"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlpushevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PushEvent</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsyswmevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlquitevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_SysWMEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventstructures.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_QuitEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlvideodrivername.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,235 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_VideoDriverName</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetVideoInfo"
+HREF="sdlgetvideoinfo.html"><LINK
+REL="NEXT"
+TITLE="SDL_ListModes"
+HREF="sdllistmodes.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetvideoinfo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdllistmodes.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLVIDEODRIVERNAME"
+>SDL_VideoDriverName</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN683"
+></A
+><H2
+>Name</H2
+>SDL_VideoDriverName&nbsp;--&nbsp;Obtain the name of the video driver</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN686"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN687"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>char *<B
+CLASS="FSFUNC"
+>SDL_VideoDriverName</B
+></CODE
+>(char *namebuf, int maxlen);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN693"
+></A
+><H2
+>Description</H2
+><P
+>The buffer pointed to by <TT
+CLASS="PARAMETER"
+><I
+>namebuf</I
+></TT
+> is filled up to a maximum of <TT
+CLASS="PARAMETER"
+><I
+>maxlen</I
+></TT
+> characters (include the NULL terminator) with the name of the initialised video driver. The driver name is a simple one word identifier like "x11" or "windib".</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN698"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <TT
+CLASS="LITERAL"
+>NULL</TT
+> if video has not been initialised with <TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+> or a pointer to <TT
+CLASS="PARAMETER"
+><I
+>namebuf</I
+></TT
+> otherwise.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN704"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>
+<A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_InitSubSystem</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetvideoinfo.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdllistmodes.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetVideoInfo</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_ListModes</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlvideoinfo.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,400 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_VideoInfo</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Surface"
+HREF="sdlsurface.html"><LINK
+REL="NEXT"
+TITLE="SDL_Overlay"
+HREF="sdloverlay.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdloverlay.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLVIDEOINFO"
+>SDL_VideoInfo</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN2893"
+></A
+><H2
+>Name</H2
+>SDL_VideoInfo&nbsp;--&nbsp;Video Target information</DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2896"
+></A
+><H2
+>Structure Definition</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef struct{
+  Uint32 hw_available:1;
+  Uint32 wm_available:1;
+  Uint32 blit_hw:1;
+  Uint32 blit_hw_CC:1;
+  Uint32 blit_hw_A:1;
+  Uint32 blit_sw:1;
+  Uint32 blit_sw_CC:1;
+  Uint32 blit_sw_A:1;
+  Uint32 blit_fill;
+  Uint32 video_mem;
+  SDL_PixelFormat *vfmt;
+} SDL_VideoInfo;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2899"
+></A
+><H2
+>Structure Data</H2
+><DIV
+CLASS="INFORMALTABLE"
+><A
+NAME="AEN2901"
+></A
+><P
+></P
+><TABLE
+BORDER="0"
+CLASS="CALSTABLE"
+><TBODY
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>hw_available</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Is it possible to create hardware surfaces?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>wm_available</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Is there a window manager available</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_hw</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are hardware to hardware blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_hw_CC</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are hardware to hardware colorkey blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_hw_A</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are hardware to hardware alpha blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_sw</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are software to hardware blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_sw_CC</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are software to hardware colorkey blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_sw_A</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are software to hardware alpha blits accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>blit_fill</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Are color fills accelerated?</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>video_mem</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+>Total amount of video memory in Kilobytes</TD
+></TR
+><TR
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><TT
+CLASS="STRUCTFIELD"
+><I
+>vfmt</I
+></TT
+></TD
+><TD
+ALIGN="LEFT"
+VALIGN="TOP"
+><A
+HREF="sdlpixelformat.html"
+>Pixel format</A
+> of the video device</TD
+></TR
+></TBODY
+></TABLE
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2949"
+></A
+><H2
+>Description</H2
+><P
+>This (read-only) structure is returned by <A
+HREF="sdlgetvideoinfo.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetVideoInfo</TT
+></A
+>. It contains information on either the 'best' available mode  (if called before <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>) or the current video mode.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN2956"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlpixelformat.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_PixelFormat</SPAN
+></A
+>,
+<A
+HREF="sdlgetvideoinfo.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetVideoInfo</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlsurface.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdloverlay.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Surface</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_Overlay</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlvideomodeok.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,262 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_VideoModeOK</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_ListModes"
+HREF="sdllistmodes.html"><LINK
+REL="NEXT"
+TITLE="SDL_SetVideoMode"
+HREF="sdlsetvideomode.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdllistmodes.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlsetvideomode.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLVIDEOMODEOK"
+>SDL_VideoModeOK</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN758"
+></A
+><H2
+>Name</H2
+>SDL_VideoModeOK&nbsp;--&nbsp;Check to see if a particular video mode is supported.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN761"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN762"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_VideoModeOK</B
+></CODE
+>(int width, int height, int bpp, Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN768"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_VideoModeOK</TT
+> returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> 
+if the requested mode is not supported under any bit depth, or returns the 
+bits-per-pixel of the closest available mode with the given width, height and requested <A
+HREF="sdlsurface.html"
+>surface</A
+> flags (see <A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>).</P
+><P
+>The bits-per-pixel value returned is only a suggested mode. You can usually request and bpp you want when <A
+HREF="sdlsetvideomode.html"
+>setting</A
+>  the video mode and SDL will emulate that color depth with a shadow video surface.</P
+><P
+>The arguments to <TT
+CLASS="FUNCTION"
+>SDL_VideoModeOK</TT
+> are the same ones you 
+would pass to <A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+></P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN781"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_Surface *screen;
+Uint32 bpp;
+.
+.
+.
+printf("Checking mode 640x480@16bpp.\n");
+bpp=SDL_VideoModeOK(640, 480, 16, SDL_HWSURFACE);
+
+if(!bpp){
+  printf("Mode not available.\n");
+  exit(-1);
+}
+
+printf("SDL Recommends 640x480@%dbpp.\n", bpp);
+screen=SDL_SetVideoMode(640, 480, bpp, SDL_HWSURFACE);
+.
+.</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN784"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlgetvideoinfo.html"
+><TT
+CLASS="FUNCTION"
+>SDL_GetVideoInfo</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdllistmodes.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlsetvideomode.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_ListModes</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_SetVideoMode</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwaitevent.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WaitEvent</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Event Functions."
+HREF="eventfunctions.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_PollEvent"
+HREF="sdlpollevent.html"><LINK
+REL="NEXT"
+TITLE="SDL_PushEvent"
+HREF="sdlpushevent.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlpollevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlpushevent.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWAITEVENT"
+>SDL_WaitEvent</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN4889"
+></A
+><H2
+>Name</H2
+>SDL_WaitEvent&nbsp;--&nbsp;Waits indefinitely for the next available event.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN4892"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN4893"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_WaitEvent</B
+></CODE
+>(SDL_Event *event);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4899"
+></A
+><H2
+>Description</H2
+><P
+>Waits indefinitely for the next available event, returning 
+<SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+>, or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if there was 
+an error while waiting for events.  </P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>event</I
+></TT
+> is not <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the next 
+event is removed from the queue and stored in that area.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN4907"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_Event</SPAN
+></A
+>,
+<A
+HREF="sdlpollevent.html"
+><TT
+CLASS="FUNCTION"
+>SDL_PollEvent</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlpollevent.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlpushevent.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_PollEvent</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="eventfunctions.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_PushEvent</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwaitthread.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WaitThread</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Multi-threaded Programming"
+HREF="thread.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_GetThreadID"
+HREF="sdlgetthreadid.html"><LINK
+REL="NEXT"
+TITLE="SDL_KillThread"
+HREF="sdlkillthread.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlgetthreadid.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlkillthread.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWAITTHREAD"
+>SDL_WaitThread</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN7141"
+></A
+><H2
+>Name</H2
+>SDL_WaitThread&nbsp;--&nbsp;Wait for a thread to finish.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN7144"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN7145"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"
+#include "SDL_thread.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_WaitThread</B
+></CODE
+>(SDL_Thread *thread, int *status);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7151"
+></A
+><H2
+>Description</H2
+><P
+>Wait for a thread to finish (timeouts are not supported).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7154"
+></A
+><H2
+>Return Value</H2
+><P
+>The return code for the thread function is placed in the area pointed to by
+<TT
+CLASS="PARAMETER"
+><I
+>status</I
+></TT
+>, if <TT
+CLASS="PARAMETER"
+><I
+>status</I
+></TT
+> is not
+<SPAN
+CLASS="RETURNVALUE"
+>NULL</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN7160"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlcreatethread.html"
+><TT
+CLASS="FUNCTION"
+>SDL_CreateThread</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlgetthreadid.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlkillthread.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_GetThreadID</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="thread.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_KillThread</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwarpmouse.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,197 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WarpMouse</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Video"
+HREF="video.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_DisplayFormatAlpha"
+HREF="sdldisplayformatalpha.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateCursor"
+HREF="sdlcreatecursor.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdldisplayformatalpha.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatecursor.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWARPMOUSE"
+>SDL_WarpMouse</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN1967"
+></A
+><H2
+>Name</H2
+>SDL_WarpMouse&nbsp;--&nbsp;Set the position of the mouse cursor.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN1970"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN1971"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_WarpMouse</B
+></CODE
+>(Uint16 x, Uint16 y);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1977"
+></A
+><H2
+>Description</H2
+><P
+>Set the position of the mouse cursor (generates a mouse motion event).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN1980"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlmousemotionevent.html"
+><SPAN
+CLASS="STRUCTNAME"
+>SDL_MouseMotionEvent</SPAN
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdldisplayformatalpha.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatecursor.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_DisplayFormatAlpha</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="video.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateCursor</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwasinit.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,276 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WasInit</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="General"
+HREF="general.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Quit"
+HREF="sdlquit.html"><LINK
+REL="NEXT"
+TITLE="Video"
+HREF="video.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlquit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="video.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWASINIT"
+>SDL_WasInit</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN578"
+></A
+><H2
+>Name</H2
+>SDL_WasInit&nbsp;--&nbsp;Check which subsystems are initialized</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN581"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN582"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>Uint32 <B
+CLASS="FSFUNC"
+>SDL_WasInit</B
+></CODE
+>(Uint32 flags);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN588"
+></A
+><H2
+>Description</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_WasInit</TT
+> allows you to see which SDL subsytems have been <A
+HREF="sdlinit.html"
+>initialized</A
+>. <TT
+CLASS="PARAMETER"
+><I
+>flags</I
+></TT
+> is a bitwise OR'd combination of the subsystems you wish to check (see <A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+> for a list of subsystem flags).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN596"
+></A
+><H2
+>Return Value</H2
+><P
+><TT
+CLASS="FUNCTION"
+>SDL_WasInit</TT
+> returns a bitwised OR'd combination of the initialized subsystems.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN600"
+></A
+><H2
+>Examples</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>&#13;/* Here are several ways you can use SDL_WasInit() */
+
+/* Get init data on all the subsystems */
+Uint32 subsystem_init;
+
+subsystem_init=SDL_WasInit(SDL_INIT_EVERYTHING);
+
+if(subsystem_init&#38;SDL_INIT_VIDEO)
+  printf("Video is initialized.\n");
+else
+  printf("Video is not initialized.\n");
+
+
+
+/* Just check for one specfic subsystem */
+
+if(SDL_WasInit(SDL_INIT_VIDEO)!=0)
+  printf("Video is initialized.\n");
+else
+  printf("Video is not initialized.\n");
+
+
+
+
+/* Check for two subsystems */
+
+Uint32 subsystem_mask=SDL_INIT_VIDEO|SDL_INIT_AUDIO;
+
+if(SDL_WasInit(subsystem_mask)==subsystem_mask)
+  printf("Video and Audio initialized.\n");
+else
+  printf("Video and Audio not initialized.\n");&#13;</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN603"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlinit.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Init</TT
+></A
+>,
+<A
+HREF="sdlinitsubsystem.html"
+><TT
+CLASS="FUNCTION"
+>SDL_Subsystem</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlquit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="video.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Quit</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="general.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Video</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmgetcaption.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_GetCaption</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_SetCaption"
+HREF="sdlwmsetcaption.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_SetIcon"
+HREF="sdlwmseticon.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmsetcaption.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmseticon.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMGETCAPTION"
+>SDL_WM_GetCaption</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3059"
+></A
+><H2
+>Name</H2
+>SDL_WM_GetCaption&nbsp;--&nbsp;Gets the window title and icon name.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3062"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3063"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_WM_GetCaption</B
+></CODE
+>(char **title, char **icon);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3069"
+></A
+><H2
+>Description</H2
+><P
+>Set pointers to the window <TT
+CLASS="PARAMETER"
+><I
+>title</I
+></TT
+> and <TT
+CLASS="PARAMETER"
+><I
+>icon</I
+></TT
+> name.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3074"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlwmsetcaption.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_SetCaption</TT
+></A
+>,
+<A
+HREF="sdlwmseticon.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_SetIcon</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmsetcaption.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmseticon.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_SetCaption</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_SetIcon</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmgrabinput.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,216 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_GrabInput</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_ToggleFullScreen"
+HREF="sdlwmtogglefullscreen.html"><LINK
+REL="NEXT"
+TITLE="Events"
+HREF="event.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmtogglefullscreen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="event.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMGRABINPUT"
+>SDL_WM_GrabInput</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3166"
+></A
+><H2
+>Name</H2
+>SDL_WM_GrabInput&nbsp;--&nbsp;Grabs mouse and keyboard input.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3169"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3170"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>SDL_GrabMode <B
+CLASS="FSFUNC"
+>SDL_WM_GrabInput</B
+></CODE
+>(SDL_GrabMode mode);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3176"
+></A
+><H2
+>Description</H2
+><P
+>Grabbing means that the mouse is confined to the application window,
+and nearly all keyboard input is passed directly to the application,
+and not interpreted by a window manager, if any.</P
+><P
+>When <TT
+CLASS="PARAMETER"
+><I
+>mode</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>SDL_GRAB_QUERY</TT
+> the grab mode is not changed, but the current grab mode is returned.</P
+><P
+><PRE
+CLASS="PROGRAMLISTING"
+>typedef enum {
+  SDL_GRAB_QUERY,
+  SDL_GRAB_OFF,
+  SDL_GRAB_ON
+} SDL_GrabMode;</PRE
+>
+                    </P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3184"
+></A
+><H2
+>Return Value</H2
+><P
+>The current/new <SPAN
+CLASS="STRUCTNAME"
+>SDL_GrabMode</SPAN
+>.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmtogglefullscreen.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="event.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_ToggleFullScreen</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>Events</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmiconifywindow.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,203 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_IconifyWindow</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_SetIcon"
+HREF="sdlwmseticon.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_ToggleFullScreen"
+HREF="sdlwmtogglefullscreen.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmseticon.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmtogglefullscreen.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMICONIFYWINDOW"
+>SDL_WM_IconifyWindow</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3120"
+></A
+><H2
+>Name</H2
+>SDL_WM_IconifyWindow&nbsp;--&nbsp;Iconify/Minimise the window</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3123"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3124"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_WM_IconifyWindow</B
+></CODE
+>(void);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3130"
+></A
+><H2
+>Description</H2
+><P
+>If the application is running in a window managed environment SDL attempts to iconify/minimise it. If <TT
+CLASS="FUNCTION"
+>SDL_WM_IconifyWindow</TT
+> is successful, the application will receive a <A
+HREF="sdlactiveevent.html"
+><TT
+CLASS="LITERAL"
+>SDL_APPACTIVE</TT
+></A
+> loss event.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3136"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns non-zero on success or <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> if iconification is not support or was refused by the window manager.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmseticon.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmtogglefullscreen.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_SetIcon</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_ToggleFullScreen</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmsetcaption.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,204 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_SetCaption</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_GetCaption"
+HREF="sdlwmgetcaption.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="wm.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmgetcaption.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMSETCAPTION"
+>SDL_WM_SetCaption</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3035"
+></A
+><H2
+>Name</H2
+>SDL_WM_SetCaption&nbsp;--&nbsp;Sets the window tile and icon name.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3038"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3039"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_WM_SetCaption</B
+></CODE
+>(const char *title, const char *icon);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3045"
+></A
+><H2
+>Description</H2
+><P
+>Sets the title-bar and icon name of the display window.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3048"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlwmgetcaption.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_GetCaption</TT
+></A
+>,
+<A
+HREF="sdlwmseticon.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_SetIcon</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmgetcaption.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>Window Management</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_GetCaption</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmseticon.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,244 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_SetIcon</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_GetCaption"
+HREF="sdlwmgetcaption.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_IconifyWindow"
+HREF="sdlwmiconifywindow.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmgetcaption.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmiconifywindow.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMSETICON"
+>SDL_WM_SetIcon</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3085"
+></A
+><H2
+>Name</H2
+>SDL_WM_SetIcon&nbsp;--&nbsp;Sets the icon for the display window.</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3088"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3089"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>void <B
+CLASS="FSFUNC"
+>SDL_WM_SetIcon</B
+></CODE
+>(SDL_Surface *icon, Uint8 *mask);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3095"
+></A
+><H2
+>Description</H2
+><P
+>Sets the icon for the display window.</P
+><P
+>This function must be called before the first call to 
+<A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+>.</P
+><P
+>It takes an <TT
+CLASS="PARAMETER"
+><I
+>icon</I
+></TT
+> surface, and a <TT
+CLASS="PARAMETER"
+><I
+>mask</I
+></TT
+> in MSB format.</P
+><P
+>If <TT
+CLASS="PARAMETER"
+><I
+>mask</I
+></TT
+> is <TT
+CLASS="LITERAL"
+>NULL</TT
+>, the entire 
+icon surface will be used as the icon.</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3106"
+></A
+><H2
+>Example</H2
+><PRE
+CLASS="PROGRAMLISTING"
+>SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);</PRE
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3109"
+></A
+><H2
+>See Also</H2
+><P
+><A
+HREF="sdlsetvideomode.html"
+><TT
+CLASS="FUNCTION"
+>SDL_SetVideoMode</TT
+></A
+>,
+<A
+HREF="sdlwmsetcaption.html"
+><TT
+CLASS="FUNCTION"
+>SDL_WM_SetCaption</TT
+></A
+></P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmgetcaption.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmiconifywindow.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_GetCaption</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_IconifyWindow</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/sdlwmtogglefullscreen.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,197 @@
+<HTML
+><HEAD
+><TITLE
+>SDL_WM_ToggleFullScreen</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="Window Management"
+HREF="wm.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WM_IconifyWindow"
+HREF="sdlwmiconifywindow.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_GrabInput"
+HREF="sdlwmgrabinput.html"></HEAD
+><BODY
+CLASS="REFENTRY"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwmiconifywindow.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmgrabinput.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><H1
+><A
+NAME="SDLWMTOGGLEFULLSCREEN"
+>SDL_WM_ToggleFullScreen</A
+></H1
+><DIV
+CLASS="REFNAMEDIV"
+><A
+NAME="AEN3144"
+></A
+><H2
+>Name</H2
+>SDL_WM_ToggleFullScreen&nbsp;--&nbsp;Toggles fullscreen mode</DIV
+><DIV
+CLASS="REFSYNOPSISDIV"
+><A
+NAME="AEN3147"
+></A
+><H2
+>Synopsis</H2
+><DIV
+CLASS="FUNCSYNOPSIS"
+><A
+NAME="AEN3148"
+></A
+><P
+></P
+><PRE
+CLASS="FUNCSYNOPSISINFO"
+>#include "SDL.h"</PRE
+><P
+><CODE
+><CODE
+CLASS="FUNCDEF"
+>int <B
+CLASS="FSFUNC"
+>SDL_WM_ToggleFullScreen</B
+></CODE
+>(SDL_Surface *surface);</CODE
+></P
+><P
+></P
+></DIV
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3154"
+></A
+><H2
+>Description</H2
+><P
+>Toggles the application between windowed and fullscreen mode, if supported. (X11 is the only target currently supported, BeOS support is experimental).</P
+></DIV
+><DIV
+CLASS="REFSECT1"
+><A
+NAME="AEN3157"
+></A
+><H2
+>Return Value</H2
+><P
+>Returns <SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+> on failure or <SPAN
+CLASS="RETURNVALUE"
+>1</SPAN
+> on success.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwmiconifywindow.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmgrabinput.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WM_IconifyWindow</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="wm.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_GrabInput</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/thread.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,305 @@
+<HTML
+><HEAD
+><TITLE
+>Multi-threaded Programming</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CDtrack"
+HREF="sdlcdtrack.html"><LINK
+REL="NEXT"
+TITLE="SDL_CreateThread"
+HREF="sdlcreatethread.html"><META
+NAME="KEYWORD"
+CONTENT="threads"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcdtrack.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlcreatethread.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="THREAD"
+>Chapter 12. Multi-threaded Programming</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlcreatethread.html"
+>SDL_CreateThread</A
+> &#8212; Creates a new thread of execution that shares its parent's properties.</DT
+><DT
+><A
+HREF="sdlthreadid.html"
+>SDL_ThreadID</A
+> &#8212; Get the 32-bit thread identifier for the current thread.</DT
+><DT
+><A
+HREF="sdlgetthreadid.html"
+>SDL_GetThreadID</A
+> &#8212; Get the SDL thread ID of a SDL_Thread</DT
+><DT
+><A
+HREF="sdlwaitthread.html"
+>SDL_WaitThread</A
+> &#8212; Wait for a thread to finish.</DT
+><DT
+><A
+HREF="sdlkillthread.html"
+>SDL_KillThread</A
+> &#8212; Gracelessly terminates the thread.</DT
+><DT
+><A
+HREF="sdlcreatemutex.html"
+>SDL_CreateMutex</A
+> &#8212; Create a mutex</DT
+><DT
+><A
+HREF="sdldestroymutex.html"
+>SDL_DestroyMutex</A
+> &#8212; Destroy a mutex</DT
+><DT
+><A
+HREF="sdlmutexp.html"
+>SDL_mutexP</A
+> &#8212; Lock a mutex</DT
+><DT
+><A
+HREF="sdlmutexv.html"
+>SDL_mutexV</A
+> &#8212; Unlock a mutex</DT
+><DT
+><A
+HREF="sdlcreatesemaphore.html"
+>SDL_CreateSemaphore</A
+> &#8212; Creates a new semaphore and assigns an initial value to it.</DT
+><DT
+><A
+HREF="sdldestroysemaphore.html"
+>SDL_DestroySemaphore</A
+> &#8212; Destroys a semaphore that was created by <A
+HREF="sdlcreatesemaphore.html"
+>SDL_CreateSemaphore</A
+>.</DT
+><DT
+><A
+HREF="sdlsemwait.html"
+>SDL_SemWait</A
+> &#8212; Lock a semaphore and suspend the thread if the semaphore value is zero.</DT
+><DT
+><A
+HREF="sdlsemtrywait.html"
+>SDL_SemTryWait</A
+> &#8212; Attempt to lock a semaphore but don't suspend the thread.</DT
+><DT
+><A
+HREF="sdlsemwaittimeout.html"
+>SDL_SemWaitTimeout</A
+> &#8212; Lock a semaphore, but only wait up to a specified maximum time.</DT
+><DT
+><A
+HREF="sdlsempost.html"
+>SDL_SemPost</A
+> &#8212; Unlock a semaphore.</DT
+><DT
+><A
+HREF="sdlsemvalue.html"
+>SDL_SemValue</A
+> &#8212; Return the current value of a semaphore.</DT
+><DT
+><A
+HREF="sdlcreatecond.html"
+>SDL_CreateCond</A
+> &#8212; Create a condition variable</DT
+><DT
+><A
+HREF="sdldestroycond.html"
+>SDL_DestroyCond</A
+> &#8212; Destroy a condition variable</DT
+><DT
+><A
+HREF="sdlcondsignal.html"
+>SDL_CondSignal</A
+> &#8212; Restart a thread wait on a condition variable</DT
+><DT
+><A
+HREF="sdlcondbroadcast.html"
+>SDL_CondBroadcast</A
+> &#8212; Restart all threads waiting on a condition variable</DT
+><DT
+><A
+HREF="sdlcondwait.html"
+>SDL_CondWait</A
+> &#8212; Wait on a condition variable</DT
+><DT
+><A
+HREF="sdlcondwaittimeout.html"
+>SDL_CondWaitTimeout</A
+> &#8212; Wait on a condition variable, with timeout</DT
+></DL
+></DIV
+><P
+>SDL provides functions for creating threads, mutexes, semphores and condition variables.</P
+><P
+>In general, you must be very aware of concurrency and data integrity issues
+when writing multi-threaded programs.  Some good guidelines include:
+<P
+></P
+><UL
+><LI
+><P
+>Don't call SDL video/event functions from separate threads</P
+></LI
+><LI
+><P
+>Don't use any library functions in separate threads</P
+></LI
+><LI
+><P
+>Don't perform any memory management in separate threads</P
+></LI
+><LI
+><P
+>Lock global variables which may be accessed by multiple threads</P
+></LI
+><LI
+><P
+>Never terminate threads, always set a flag and wait for them to quit</P
+></LI
+><LI
+><P
+>Think very carefully about all possible ways your code may interact</P
+></LI
+></UL
+></P
+><DIV
+CLASS="NOTE"
+><BLOCKQUOTE
+CLASS="NOTE"
+><P
+><B
+>Note: </B
+>SDL's threading is not implemented on MacOS, due to that lack of preemptive thread support (eck!)</P
+></BLOCKQUOTE
+></DIV
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcdtrack.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlcreatethread.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CDtrack</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_CreateThread</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/time.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,198 @@
+<HTML
+><HEAD
+><TITLE
+>Time</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_CondWaitTimeout"
+HREF="sdlcondwaittimeout.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetTicks"
+HREF="sdlgetticks.html"><META
+NAME="KEYWORD"
+CONTENT="time"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlcondwaittimeout.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetticks.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="TIME"
+>Chapter 13. Time</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlgetticks.html"
+>SDL_GetTicks</A
+> &#8212; Get the number of milliseconds since the SDL library initialization.</DT
+><DT
+><A
+HREF="sdldelay.html"
+>SDL_Delay</A
+> &#8212; Wait a specified number of milliseconds before returning.</DT
+><DT
+><A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+> &#8212; Add a timer which will call a callback after the specified number of milliseconds has
+elapsed.</DT
+><DT
+><A
+HREF="sdlremovetimer.html"
+>SDL_RemoveTimer</A
+> &#8212; Remove a timer which was added with
+<A
+HREF="sdladdtimer.html"
+>SDL_AddTimer</A
+>.</DT
+><DT
+><A
+HREF="sdlsettimer.html"
+>SDL_SetTimer</A
+> &#8212; Set a callback to run after the specified number of milliseconds has
+elapsed.</DT
+></DL
+></DIV
+><P
+>SDL provides several cross-platform functions for dealing with time.
+It provides a way to get the current time, a way to wait a little while,
+and a simple timer mechanism.  These functions give you two ways of moving an
+object every x milliseconds:
+
+<P
+></P
+><UL
+><LI
+><P
+>Use a timer callback function.  This may have the bad effect that it runs in a seperate thread or uses alarm signals, but it's easier to implement.</P
+></LI
+><LI
+><P
+>Or you can get the number of milliseconds passed, and move the object if, for example, 30 ms passed.</P
+></LI
+></UL
+>&#13;</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlcondwaittimeout.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetticks.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_CondWaitTimeout</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetTicks</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/video.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,499 @@
+<HTML
+><HEAD
+><TITLE
+>Video</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_WasInit"
+HREF="sdlwasinit.html"><LINK
+REL="NEXT"
+TITLE="SDL_GetVideoSurface"
+HREF="sdlgetvideosurface.html"><META
+NAME="KEYWORD"
+CONTENT="video"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdlwasinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlgetvideosurface.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="VIDEO"
+>Chapter 6. Video</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlgetvideosurface.html"
+>SDL_GetVideoSurface</A
+> &#8212; returns a pointer to the current display surface</DT
+><DT
+><A
+HREF="sdlgetvideoinfo.html"
+>SDL_GetVideoInfo</A
+> &#8212; returns a pointer to information about the video hardware</DT
+><DT
+><A
+HREF="sdlvideodrivername.html"
+>SDL_VideoDriverName</A
+> &#8212; Obtain the name of the video driver</DT
+><DT
+><A
+HREF="sdllistmodes.html"
+>SDL_ListModes</A
+> &#8212; Returns a pointer to an array of available screen dimensions for 
+the given format and video flags</DT
+><DT
+><A
+HREF="sdlvideomodeok.html"
+>SDL_VideoModeOK</A
+> &#8212; Check to see if a particular video mode is supported.</DT
+><DT
+><A
+HREF="sdlsetvideomode.html"
+>SDL_SetVideoMode</A
+> &#8212; Set up a video mode with the specified width, height and bits-per-pixel.</DT
+><DT
+><A
+HREF="sdlupdaterect.html"
+>SDL_UpdateRect</A
+> &#8212; Makes sure the given area is updated on the given screen.</DT
+><DT
+><A
+HREF="sdlupdaterects.html"
+>SDL_UpdateRects</A
+> &#8212; Makes sure the given list of rectangles is updated on the given screen.</DT
+><DT
+><A
+HREF="sdlflip.html"
+>SDL_Flip</A
+> &#8212; Swaps screen buffers</DT
+><DT
+><A
+HREF="sdlsetcolors.html"
+>SDL_SetColors</A
+> &#8212; Sets a portion of the colormap for the given 8-bit surface.</DT
+><DT
+><A
+HREF="sdlsetpalette.html"
+>SDL_SetPalette</A
+> &#8212; Sets the colors in the palette of an 8-bit surface.</DT
+><DT
+><A
+HREF="sdlsetgamma.html"
+>SDL_SetGamma</A
+> &#8212; Sets the color gamma function for the display</DT
+><DT
+><A
+HREF="sdlgetgammaramp.html"
+>SDL_GetGammaRamp</A
+> &#8212; Gets the color gamma lookup tables for the display</DT
+><DT
+><A
+HREF="sdlsetgammaramp.html"
+>SDL_SetGammaRamp</A
+> &#8212; Sets the color gamma lookup tables for the display</DT
+><DT
+><A
+HREF="sdlmaprgb.html"
+>SDL_MapRGB</A
+> &#8212; Map a RGB color value to a pixel format.</DT
+><DT
+><A
+HREF="sdlmaprgba.html"
+>SDL_MapRGBA</A
+> &#8212; Map a RGBA color value to a pixel format.</DT
+><DT
+><A
+HREF="sdlgetrgb.html"
+>SDL_GetRGB</A
+> &#8212; Get RGB values from a pixel in the specified pixel format.</DT
+><DT
+><A
+HREF="sdlgetrgba.html"
+>SDL_GetRGBA</A
+> &#8212; Get RGBA values from a pixel in the specified pixel format.</DT
+><DT
+><A
+HREF="sdlcreatergbsurface.html"
+>SDL_CreateRGBSurface</A
+> &#8212; Create an empty SDL_Surface</DT
+><DT
+><A
+HREF="sdlcreatergbsurfacefrom.html"
+>SDL_CreateRGBSurfaceFrom</A
+> &#8212; Create an SDL_Surface from pixel data</DT
+><DT
+><A
+HREF="sdlfreesurface.html"
+>SDL_FreeSurface</A
+> &#8212; Frees (deletes) and SDL_Surface</DT
+><DT
+><A
+HREF="sdllocksurface.html"
+>SDL_LockSurface</A
+> &#8212; Lock a surface for directly access.</DT
+><DT
+><A
+HREF="sdlunlocksurface.html"
+>SDL_UnlockSurface</A
+> &#8212; Unlocks a previously locked surface.</DT
+><DT
+><A
+HREF="sdlloadbmp.html"
+>SDL_LoadBMP</A
+> &#8212; Load a Windows BMP file into an SDL_Surface.</DT
+><DT
+><A
+HREF="sdlsavebmp.html"
+>SDL_SaveBMP</A
+> &#8212; Save an SDL_Surface as a Windows BMP file.</DT
+><DT
+><A
+HREF="sdlsetcolorkey.html"
+>SDL_SetColorKey</A
+> &#8212; Sets the color key (transparent pixel) in a blittable surface and
+RLE acceleration.</DT
+><DT
+><A
+HREF="sdlsetalpha.html"
+>SDL_SetAlpha</A
+> &#8212; Adjust the alpha properties of a surface</DT
+><DT
+><A
+HREF="sdlsetcliprect.html"
+>SDL_SetClipRect</A
+> &#8212; Sets the clipping rectangle for a surface.</DT
+><DT
+><A
+HREF="sdlgetcliprect.html"
+>SDL_GetClipRect</A
+> &#8212; Gets the clipping rectangle for a surface.</DT
+><DT
+><A
+HREF="sdlconvertsurface.html"
+>SDL_ConvertSurface</A
+> &#8212; Converts a surface to the same format as another surface.</DT
+><DT
+><A
+HREF="sdlblitsurface.html"
+>SDL_BlitSurface</A
+> &#8212; This performs a fast blit from the source surface to the destination surface.</DT
+><DT
+><A
+HREF="sdlfillrect.html"
+>SDL_FillRect</A
+> &#8212; This function performs a fast fill of the given rectangle with some color</DT
+><DT
+><A
+HREF="sdldisplayformat.html"
+>SDL_DisplayFormat</A
+> &#8212; Convert a surface to the display format</DT
+><DT
+><A
+HREF="sdldisplayformatalpha.html"
+>SDL_DisplayFormatAlpha</A
+> &#8212; Convert a surface to the display format</DT
+><DT
+><A
+HREF="sdlwarpmouse.html"
+>SDL_WarpMouse</A
+> &#8212; Set the position of the mouse cursor.</DT
+><DT
+><A
+HREF="sdlcreatecursor.html"
+>SDL_CreateCursor</A
+> &#8212; Creates a new mouse cursor.</DT
+><DT
+><A
+HREF="sdlfreecursor.html"
+>SDL_FreeCursor</A
+> &#8212; Frees a cursor created with SDL_CreateCursor.</DT
+><DT
+><A
+HREF="sdlsetcursor.html"
+>SDL_SetCursor</A
+> &#8212; Set the currently active mouse cursor.</DT
+><DT
+><A
+HREF="sdlgetcursor.html"
+>SDL_GetCursor</A
+> &#8212; Get the currently active mouse cursor.</DT
+><DT
+><A
+HREF="sdlshowcursor.html"
+>SDL_ShowCursor</A
+> &#8212; Toggle whether or not the cursor is shown on the screen.</DT
+><DT
+><A
+HREF="sdlglloadlibrary.html"
+>SDL_GL_LoadLibrary</A
+> &#8212; Specify an OpenGL library</DT
+><DT
+><A
+HREF="sdlglgetprocaddress.html"
+>SDL_GL_GetProcAddress</A
+> &#8212; Get the address of a GL function</DT
+><DT
+><A
+HREF="sdlglgetattribute.html"
+>SDL_GL_GetAttribute</A
+> &#8212; Get the value of a special SDL/OpenGL attribute</DT
+><DT
+><A
+HREF="sdlglsetattribute.html"
+>SDL_GL_SetAttribute</A
+> &#8212; Set a special SDL/OpenGL attribute</DT
+><DT
+><A
+HREF="sdlglswapbuffers.html"
+>SDL_GL_SwapBuffers</A
+> &#8212; Swap OpenGL framebuffers/Update Display</DT
+><DT
+><A
+HREF="sdlcreateyuvoverlay.html"
+>SDL_CreateYUVOverlay</A
+> &#8212; Create a YUV video overlay</DT
+><DT
+><A
+HREF="sdllockyuvoverlay.html"
+>SDL_LockYUVOverlay</A
+> &#8212; Lock an overlay</DT
+><DT
+><A
+HREF="sdlunlockyuvoverlay.html"
+>SDL_UnlockYUVOverlay</A
+> &#8212; Unlock an overlay</DT
+><DT
+><A
+HREF="sdldisplayyuvoverlay.html"
+>SDL_DisplayYUVOverlay</A
+> &#8212; Blit the overlay to the display</DT
+><DT
+><A
+HREF="sdlfreeyuvoverlay.html"
+>SDL_FreeYUVOverlay</A
+> &#8212; Free a YUV video overlay</DT
+><DT
+><A
+HREF="sdlglattr.html"
+>SDL_GLattr</A
+> &#8212; SDL GL Attributes</DT
+><DT
+><A
+HREF="sdlrect.html"
+>SDL_Rect</A
+> &#8212; Defines a rectangular area</DT
+><DT
+><A
+HREF="sdlcolor.html"
+>SDL_Color</A
+> &#8212; Format independent color description</DT
+><DT
+><A
+HREF="sdlpalette.html"
+>SDL_Palette</A
+> &#8212; Color palette for 8-bit pixel formats</DT
+><DT
+><A
+HREF="sdlpixelformat.html"
+>SDL_PixelFormat</A
+> &#8212; Stores surface format information</DT
+><DT
+><A
+HREF="sdlsurface.html"
+>SDL_Surface</A
+> &#8212; Graphical Surface Structure</DT
+><DT
+><A
+HREF="sdlvideoinfo.html"
+>SDL_VideoInfo</A
+> &#8212; Video Target information</DT
+><DT
+><A
+HREF="sdloverlay.html"
+>SDL_Overlay</A
+> &#8212; YUV video overlay</DT
+></DL
+></DIV
+><P
+>SDL presents a very simple interface to the display framebuffer.  The
+framebuffer is represented as an offscreen surface to which you can write
+directly.  If you want the screen to show what you have written, call the <A
+HREF="sdlupdaterects.html"
+>update</A
+> function which will
+guarantee that the desired portion of the screen is updated.</P
+><P
+>Before you call any of the SDL video functions, you must first call
+<SPAN
+CLASS="TOKEN"
+>SDL_Init(SDL_INIT_VIDEO)</SPAN
+>, which initializes the video
+and events in the SDL library.  Check the return code, which should be
+<SPAN
+CLASS="RETURNVALUE"
+>0</SPAN
+>, to see if there were any errors in starting up.</P
+><P
+>If you use both sound and video in your application, you need to call
+<SPAN
+CLASS="TOKEN"
+>SDL_Init(SDL_INIT_AUDIO | SDL_INIT_VIDEO)</SPAN
+> before opening the
+sound device, otherwise under Win32 DirectX, you won't be able to set
+full-screen display modes.</P
+><P
+>After you have initialized the library, you can start up the video display in a
+number of ways.  The easiest way is to pick a common screen resolution and
+depth and just initialize the video, checking for errors.  You will probably
+get what you want, but SDL may be emulating your requested mode and converting
+the display on update.  The best way is to
+<A
+HREF="sdlgetvideoinfo.html"
+>query</A
+>, for the best
+video mode closest to the desired one, and then
+<A
+HREF="sdldisplayformat.html"
+>convert</A
+>
+your images to that pixel format.</P
+><P
+>SDL currently supports any bit depth &gt;= 8 bits per pixel.  8 bpp formats are
+considered 8-bit palettized modes, while 12, 15, 16, 24, and 32 bits per pixel
+are considered "packed pixel" modes, meaning each pixel contains the RGB color
+components packed in the bits of the pixel.</P
+><P
+>After you have initialized your video mode, you can take the surface that was
+returned, and write to it like any other framebuffer, calling the update
+routine as you go.</P
+><P
+>When you have finished your video access and are ready to quit your
+application, you should call "<SPAN
+CLASS="TOKEN"
+>SDL_Quit()</SPAN
+>" to shutdown the
+video and events.</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdlwasinit.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlgetvideosurface.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_WasInit</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_GetVideoSurface</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/html/wm.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,180 @@
+<HTML
+><HEAD
+><TITLE
+>Window Management</TITLE
+><META
+NAME="GENERATOR"
+CONTENT="Modular DocBook HTML Stylesheet Version 1.61
+"><LINK
+REL="HOME"
+TITLE="SDL Library Documentation"
+HREF="index.html"><LINK
+REL="UP"
+TITLE="SDL Reference"
+HREF="reference.html"><LINK
+REL="PREVIOUS"
+TITLE="SDL_Overlay"
+HREF="sdloverlay.html"><LINK
+REL="NEXT"
+TITLE="SDL_WM_SetCaption"
+HREF="sdlwmsetcaption.html"><META
+NAME="KEYWORD"
+CONTENT="wm"><META
+NAME="KEYWORD"
+CONTENT="function"></HEAD
+><BODY
+CLASS="CHAPTER"
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TH
+COLSPAN="3"
+ALIGN="center"
+>SDL Library Documentation</TH
+></TR
+><TR
+><TD
+WIDTH="10%"
+ALIGN="left"
+VALIGN="bottom"
+><A
+HREF="sdloverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="80%"
+ALIGN="center"
+VALIGN="bottom"
+></TD
+><TD
+WIDTH="10%"
+ALIGN="right"
+VALIGN="bottom"
+><A
+HREF="sdlwmsetcaption.html"
+>Next</A
+></TD
+></TR
+></TABLE
+><HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="CHAPTER"
+><H1
+><A
+NAME="WM"
+>Chapter 7. Window Management</A
+></H1
+><DIV
+CLASS="TOC"
+><DL
+><DT
+><B
+>Table of Contents</B
+></DT
+><DT
+><A
+HREF="sdlwmsetcaption.html"
+>SDL_WM_SetCaption</A
+> &#8212; Sets the window tile and icon name.</DT
+><DT
+><A
+HREF="sdlwmgetcaption.html"
+>SDL_WM_GetCaption</A
+> &#8212; Gets the window title and icon name.</DT
+><DT
+><A
+HREF="sdlwmseticon.html"
+>SDL_WM_SetIcon</A
+> &#8212; Sets the icon for the display window.</DT
+><DT
+><A
+HREF="sdlwmiconifywindow.html"
+>SDL_WM_IconifyWindow</A
+> &#8212; Iconify/Minimise the window</DT
+><DT
+><A
+HREF="sdlwmtogglefullscreen.html"
+>SDL_WM_ToggleFullScreen</A
+> &#8212; Toggles fullscreen mode</DT
+><DT
+><A
+HREF="sdlwmgrabinput.html"
+>SDL_WM_GrabInput</A
+> &#8212; Grabs mouse and keyboard input.</DT
+></DL
+></DIV
+><P
+>SDL provides a small set of window management functions which allow applications to change their title and toggle from windowed mode to fullscreen (if available)</P
+></DIV
+><DIV
+CLASS="NAVFOOTER"
+><HR
+ALIGN="LEFT"
+WIDTH="100%"><TABLE
+WIDTH="100%"
+BORDER="0"
+CELLPADDING="0"
+CELLSPACING="0"
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+><A
+HREF="sdloverlay.html"
+>Prev</A
+></TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="index.html"
+>Home</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+><A
+HREF="sdlwmsetcaption.html"
+>Next</A
+></TD
+></TR
+><TR
+><TD
+WIDTH="33%"
+ALIGN="left"
+VALIGN="top"
+>SDL_Overlay</TD
+><TD
+WIDTH="34%"
+ALIGN="center"
+VALIGN="top"
+><A
+HREF="reference.html"
+>Up</A
+></TD
+><TD
+WIDTH="33%"
+ALIGN="right"
+VALIGN="top"
+>SDL_WM_SetCaption</TD
+></TR
+></TABLE
+></DIV
+></BODY
+></HTML
+>
\ No newline at end of file
Binary file docs/images/rainbow.gif has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/index.html	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,121 @@
+<!DOCTYPE HTML PUBLIC "-//Norman Walsh//DTD DocBook HTML 1.0//EN">
+<HTML
+><HEAD
+><TITLE
+>Introduction</TITLE
+>
+</HEAD
+><BODY
+BGCOLOR="#FFF8DC"
+TEXT="#000000"
+LINK="#0000ee"
+VLINK="#551a8b"
+ALINK="#ff0000"
+><DIV
+CLASS="NAVHEADER"
+>
+<HR
+ALIGN="LEFT"
+WIDTH="100%"></DIV
+><DIV
+CLASS="PREFACE"
+><H1
+><A
+NAME="AEN8"
+>Introduction</A
+></H1
+><P
+>This library is designed to make it easy to write games that run on Linux,
+Win32 and BeOS using the various native high-performance media interfaces,
+(for video, audio, etc) and presenting a single source-code level API to
+your application.  This is a fairly low level API, but using this, completely
+portable applications can be written with a great deal of flexibility.</P
+><P
+>The library is loaded as a dynamically linked library on its native
+platform, and is currently compiled natively for Linux, compiled for
+Win32 using a Linux hosted GCC
+<A
+HREF="http://www.libsdl.org/Xmingw32/"
+TARGET="_top"
+>cross-compilation</A
+>
+environment, and compiled using the EGCS C++ compiler under BeOS.</P
+><P
+>An introduction to SDL can be found online at:
+<A
+HREF="http://www.libsdl.org/intro/toc.html"
+TARGET="_top"
+>http://www.libsdl.org/intro/</A
+>&#13;</P
+><P
+>There are code examples on each of the main library pages, and there are
+fully fleshed example C++ classes and programs in the examples archive,
+available on the
+<A
+HREF="http://www.libsdl.org/download.html"
+TARGET="_top"
+>SDL download page</A
+>.</P
+><P
+>For an introduction to basic multi-media programming concepts, you might try
+some of the following links:
+<P
+></P
+><UL
+><LI
+><P
+><A
+HREF="http://www.ziron.com/links/"
+TARGET="_top"
+>Game Programming Links</A
+></P
+></LI
+><LI
+><P
+><A
+HREF="http://developer.dungeon-crawl.com/"
+TARGET="_top"
+>Game Developer Search Engine</A
+></P
+></LI
+></UL
+></P
+><P
+>Enjoy!</P
+><P
+>&nbsp;&nbsp;&nbsp; Sam Lantinga
+<TT
+CLASS="EMAIL"
+>&#60;<A
+HREF="mailto:slouken@libsdl.org"
+><A
+HREF="mailto:slouken@libsdl.org"
+TARGET="_top"
+>slouken@libsdl.org</A
+></A
+>&#62;</TT
+></P
+>
+<P>
+<br><br><HR>
+<H1>Table of Contents</H1>
+<UL>
+<LI><A HREF="html/index.html">Full Table of Contents</A></LI>
+<LI><A HREF="html/guide.html">The SDL Guide</A></LI>
+<LI><A HREF="html/reference.html">The SDL Reference</A></LI>
+<UL>
+<LI><A HREF="html/general.html">Initialization</A></LI>
+<LI><A HREF="html/video.html">Video</A></LI>
+<LI><A HREF="html/wm.html">Window Manager</A></LI>
+<LI><A HREF="html/event.html">Event Handling</A></LI>
+<LI><A HREF="html/joystick.html">Joystick</A></LI>
+<LI><A HREF="html/audio.html">Audio</A></LI>
+<LI><A HREF="html/cdrom.html">CDROM</A></LI>
+<LI><A HREF="html/thread.html">Threads</A></LI>
+<LI><A HREF="html/time.html">Timers</A></LI>
+</UL>
+</UL>
+</DIV
+></BODY
+></HTML
+>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2 @@
+Makefile.in
+Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,174 @@
+man_MANS =  \
+    SDLKey.3 \
+    SDL_ActiveEvent.3 \
+    SDL_AddTimer.3 \
+    SDL_AudioCVT.3 \
+    SDL_AudioSpec.3 \
+    SDL_BlitSurface.3 \
+    SDL_BuildAudioCVT.3 \
+    SDL_CD.3 \
+    SDL_CDClose.3 \
+    SDL_CDEject.3 \
+    SDL_CDName.3 \
+    SDL_CDNumDrives.3 \
+    SDL_CDOpen.3 \
+    SDL_CDPause.3 \
+    SDL_CDPlay.3 \
+    SDL_CDPlayTracks.3 \
+    SDL_CDResume.3 \
+    SDL_CDStatus.3 \
+    SDL_CDStop.3 \
+    SDL_CDtrack.3 \
+    SDL_CloseAudio.3 \
+    SDL_Color.3 \
+    SDL_CondBroadcast.3 \
+    SDL_CondSignal.3 \
+    SDL_CondWait.3 \
+    SDL_CondWaitTimeout.3 \
+    SDL_ConvertAudio.3 \
+    SDL_ConvertSurface.3 \
+    SDL_CreateCond.3 \
+    SDL_CreateCursor.3 \
+    SDL_CreateMutex.3 \
+    SDL_CreateRGBSurface.3 \
+    SDL_CreateRGBSurfaceFrom.3 \
+    SDL_CreateSemaphore.3 \
+    SDL_CreateThread.3 \
+    SDL_CreateYUVOverlay.3 \
+    SDL_Delay.3 \
+    SDL_DestroyCond.3 \
+    SDL_DestroyMutex.3 \
+    SDL_DestroySemaphore.3 \
+    SDL_DisplayFormat.3 \
+    SDL_DisplayFormatAlpha.3 \
+    SDL_DisplayYUVOverlay.3 \
+    SDL_EnableKeyRepeat.3 \
+    SDL_EnableUNICODE.3 \
+    SDL_Event.3 \
+    SDL_EventState.3 \
+    SDL_FillRect.3 \
+    SDL_Flip.3 \
+    SDL_FreeCursor.3 \
+    SDL_FreeSurface.3 \
+    SDL_FreeWAV.3 \
+    SDL_FreeYUVOverlay.3 \
+    SDL_GL_GetAttribute.3 \
+    SDL_GL_GetProcAddress.3 \
+    SDL_GL_LoadLibrary.3 \
+    SDL_GL_SetAttribute.3 \
+    SDL_GL_SwapBuffers.3 \
+    SDL_GLattr.3 \
+    SDL_GetAppState.3 \
+    SDL_GetAudioStatus.3 \
+    SDL_GetClipRect.3 \
+    SDL_GetCursor.3 \
+    SDL_GetEventFilter.3 \
+    SDL_GetGamma.3 \
+    SDL_GetGammaRamp.3 \
+    SDL_GetKeyName.3 \
+    SDL_GetKeyState.3 \
+    SDL_GetModState.3 \
+    SDL_GetMouseState.3 \
+    SDL_GetRGB.3 \
+    SDL_GetRGBA.3 \
+    SDL_GetRelativeMouseState.3 \
+    SDL_GetThreadID.3 \
+    SDL_GetTicks.3 \
+    SDL_GetVideoInfo.3 \
+    SDL_GetVideoSurface.3 \
+    SDL_Init.3 \
+    SDL_InitSubSystem.3 \
+    SDL_JoyAxisEvent.3 \
+    SDL_JoyBallEvent.3 \
+    SDL_JoyButtonEvent.3 \
+    SDL_JoyHatEvent.3 \
+    SDL_JoystickClose.3 \
+    SDL_JoystickEventState.3 \
+    SDL_JoystickGetAxis.3 \
+    SDL_JoystickGetBall.3 \
+    SDL_JoystickGetButton.3 \
+    SDL_JoystickGetHat.3 \
+    SDL_JoystickIndex.3 \
+    SDL_JoystickName.3 \
+    SDL_JoystickNumAxes.3 \
+    SDL_JoystickNumBalls.3 \
+    SDL_JoystickNumButtons.3 \
+    SDL_JoystickNumHats.3 \
+    SDL_JoystickOpen.3 \
+    SDL_JoystickOpened.3 \
+    SDL_JoystickUpdate.3 \
+    SDL_KeyboardEvent.3 \
+    SDL_KillThread.3 \
+    SDL_ListModes.3 \
+    SDL_LoadBMP.3 \
+    SDL_LoadWAV.3 \
+    SDL_LockAudio.3 \
+    SDL_LockSurface.3 \
+    SDL_LockYUVOverlay.3 \
+    SDL_MapRGB.3 \
+    SDL_MapRGBA.3 \
+    SDL_MixAudio.3 \
+    SDL_MouseButtonEvent.3 \
+    SDL_MouseMotionEvent.3 \
+    SDL_NumJoysticks.3 \
+    SDL_OpenAudio.3 \
+    SDL_Overlay.3 \
+    SDL_Palette.3 \
+    SDL_PauseAudio.3 \
+    SDL_PeepEvents.3 \
+    SDL_PixelFormat.3 \
+    SDL_PollEvent.3 \
+    SDL_PumpEvents.3 \
+    SDL_PushEvent.3 \
+    SDL_Quit.3 \
+    SDL_QuitEvent.3 \
+    SDL_QuitSubSystem.3 \
+    SDL_RWFromFile.3 \
+    SDL_Rect.3 \
+    SDL_RemoveTimer.3 \
+    SDL_ResizeEvent.3 \
+    SDL_SaveBMP.3 \
+    SDL_SemPost.3 \
+    SDL_SemTryWait.3 \
+    SDL_SemValue.3 \
+    SDL_SemWait.3 \
+    SDL_SemWaitTimeout.3 \
+    SDL_SetAlpha.3 \
+    SDL_SetClipRect.3 \
+    SDL_SetColorKey.3 \
+    SDL_SetColors.3 \
+    SDL_SetCursor.3 \
+    SDL_SetEventFilter.3 \
+    SDL_SetGamma.3 \
+    SDL_SetGammaRamp.3 \
+    SDL_SetModState.3 \
+    SDL_SetPalette.3 \
+    SDL_SetTimer.3 \
+    SDL_SetVideoMode.3 \
+    SDL_ShowCursor.3 \
+    SDL_Surface.3 \
+    SDL_SysWMEvent.3 \
+    SDL_ThreadID.3 \
+    SDL_UnlockAudio.3 \
+    SDL_UnlockSurface.3 \
+    SDL_UnlockYUVOverlay.3 \
+    SDL_UpdateRect.3 \
+    SDL_UpdateRects.3 \
+    SDL_UserEvent.3 \
+    SDL_VideoDriverName.3 \
+    SDL_VideoInfo.3 \
+    SDL_VideoModeOK.3 \
+    SDL_WM_GetCaption.3 \
+    SDL_WM_GrabInput.3 \
+    SDL_WM_IconifyWindow.3 \
+    SDL_WM_SetCaption.3 \
+    SDL_WM_SetIcon.3 \
+    SDL_WM_ToggleFullScreen.3 \
+    SDL_WaitEvent.3 \
+    SDL_WaitThread.3 \
+    SDL_WarpMouse.3 \
+    SDL_WasInit.3 \
+    SDL_keysym.3 \
+    SDL_mutexP.3 \
+    SDL_mutexV.3
+EXTRA_DIST = $(man_MANS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDLKey.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,161 @@
+.TH "SDLKey" "3" "Wed 11 Oct 2000, 22:28" "SDL" "SDL API Reference"
+.SH "NAME"
+SDLKey\- SDL Keysym Definitions
+.SH "SDL Keysym definitions"
+.PP
+\fBSDLKey               ASCII value    Common Name\fR
+.nf
+\f(CWSDLK_BACKSPACE       '\\b'           backspace
+SDLK_TAB             '\\t'           tab
+SDLK_CLEAR                          clear
+SDLK_RETURN          '\\r'           return
+SDLK_PAUSE                          pause
+SDLK_ESCAPE          '^['           escape
+SDLK_SPACE           ' '            space
+SDLK_EXCLAIM         '!'            exclaim
+SDLK_QUOTEDBL        '"'            quotedbl
+SDLK_HASH            '#'            hash
+SDLK_DOLLAR          '$'            dollar
+SDLK_AMPERSAND       '&'            ampersand
+SDLK_QUOTE           '''            quote
+SDLK_LEFTPAREN       '('            left parenthesis
+SDLK_RIGHTPAREN      ')'            right parenthesis
+SDLK_ASTERISK        '*'            asterisk
+SDLK_PLUS            '+'            plus sign
+SDLK_COMMA           ','            comma
+SDLK_MINUS           '-'            minus sign
+SDLK_PERIOD          '.'            period
+SDLK_SLASH           '/'            forward slash
+SDLK_0               '0'            0
+SDLK_1               '1'            1
+SDLK_2               '2'            2
+SDLK_3               '3'            3
+SDLK_4               '4'            4
+SDLK_5               '5'            5
+SDLK_6               '6'            6
+SDLK_7               '7'            7
+SDLK_8               '8'            8
+SDLK_9               '9'            9
+SDLK_COLON           ':'            colon
+SDLK_SEMICOLON       ';'            semicolon
+SDLK_LESS            '<'            less-than sign
+SDLK_EQUALS          '='            equals sign
+SDLK_GREATER         '>'            greater-than sign
+SDLK_QUESTION        '?'            question mark
+SDLK_AT              '@'            at
+SDLK_LEFTBRACKET     '['            left bracket
+SDLK_BACKSLASH       '\\'            backslash
+SDLK_RIGHTBRACKET    ']'            right bracket
+SDLK_CARET           '^'            caret
+SDLK_UNDERSCORE      '_'            underscore
+SDLK_BACKQUOTE       '`'            grave
+SDLK_a               'a'            a
+SDLK_b               'b'            b
+SDLK_c               'c'            c
+SDLK_d               'd'            d
+SDLK_e               'e'            e
+SDLK_f               'f'            f
+SDLK_g               'g'            g
+SDLK_h               'h'            h
+SDLK_i               'i'            i
+SDLK_j               'j'            j
+SDLK_k               'k'            k
+SDLK_l               'l'            l
+SDLK_m               'm'            m
+SDLK_n               'n'            n
+SDLK_o               'o'            o
+SDLK_p               'p'            p
+SDLK_q               'q'            q
+SDLK_r               'r'            r
+SDLK_s               's'            s
+SDLK_t               't'            t
+SDLK_u               'u'            u
+SDLK_v               'v'            v
+SDLK_w               'w'            w
+SDLK_x               'x'            x
+SDLK_y               'y'            y
+SDLK_z               'z'            z
+SDLK_DELETE          '^?'           delete
+SDLK_KP0                            keypad 0
+SDLK_KP1                            keypad 1
+SDLK_KP2                            keypad 2
+SDLK_KP3                            keypad 3
+SDLK_KP4                            keypad 4
+SDLK_KP5                            keypad 5
+SDLK_KP6                            keypad 6
+SDLK_KP7                            keypad 7
+SDLK_KP8                            keypad 8
+SDLK_KP9                            keypad 9
+SDLK_KP_PERIOD       '.'            keypad period
+SDLK_KP_DIVIDE       '/'            keypad divide
+SDLK_KP_MULTIPLY     '*'            keypad multiply
+SDLK_KP_MINUS        '-'            keypad minus
+SDLK_KP_PLUS         '+'            keypad plus
+SDLK_KP_ENTER        '\\r'           keypad enter
+SDLK_KP_EQUALS       '='            keypad equals
+SDLK_UP                             up arrow
+SDLK_DOWN                           down arrow
+SDLK_RIGHT                          right arrow
+SDLK_LEFT                           left arrow
+SDLK_INSERT                         insert
+SDLK_HOME                           home
+SDLK_END                            end
+SDLK_PAGEUP                         page up
+SDLK_PAGEDOWN                       page down
+SDLK_F1                             F1
+SDLK_F2                             F2
+SDLK_F3                             F3
+SDLK_F4                             F4
+SDLK_F5                             F5
+SDLK_F6                             F6
+SDLK_F7                             F7
+SDLK_F8                             F8
+SDLK_F9                             F9
+SDLK_F10                            F10
+SDLK_F11                            F11
+SDLK_F12                            F12
+SDLK_F13                            F13
+SDLK_F14                            F14
+SDLK_F15                            F15
+SDLK_NUMLOCK                        numlock
+SDLK_CAPSLOCK                       capslock
+SDLK_SCROLLOCK                      scrollock
+SDLK_RSHIFT                         right shift
+SDLK_LSHIFT                         left shift
+SDLK_RCTRL                          right ctrl
+SDLK_LCTRL                          left ctrl
+SDLK_RALT                           right alt
+SDLK_LALT                           left alt
+SDLK_RMETA                          right meta
+SDLK_LMETA                          left meta
+SDLK_LSUPER                         left windows key
+SDLK_RSUPER                         right windows key
+SDLK_MODE                           mode shift
+SDLK_HELP                           help
+SDLK_PRINT                          print-screen
+SDLK_SYSREQ                         SysRq
+SDLK_BREAK                          break
+SDLK_MENU                           menu
+SDLK_POWER                          power
+SDLK_EURO                           euro\fR
+.fi
+
+
+.SH "SDL modifier definitions"
+.PP
+\fBSDL Modifier    Meaning\fR
+.nf
+\f(CWKMOD_NONE       No modifiers applicable
+KMOD_NUM        Numlock is down
+KMOD_CAPS       Capslock is down
+KMOD_LCTRL      Left Control is down
+KMOD_RCTRL      Right Control is down
+KMOD_RSHIFT     Right Shift is down
+KMOD_LSHIFT     Left Shift is down
+KMOD_RALT       Right Alt is down
+KMOD_LALT       Left Alt is down
+KMOD_CTRL       A Control key is down
+KMOD_SHIFT      A Shift key is down
+KMOD_ALT        An Alt key is down\fR
+.fi
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ActiveEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+.TH "SDL_ActiveEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ActiveEvent\- Application visibility event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 gain;
+  Uint8 state;
+} SDL_ActiveEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_ACTIVEEVENT\&.\fP
+.TP 20
+\fBgain\fR
+0 if the event is a loss or 1 if it is a gain\&.
+.TP 20
+\fBstate\fR
+\fBSDL_APPMOUSEFOCUS\fP if mouse focus was gained or lost, \fBSDL_APPINPUTFOCUS\fP if input focus was gained or lost, or \fBSDL_APPACTIVE\fP if the application was iconified (\fBgain\fR=0) or restored(\fBgain\fR=1)\&.
+.SH "DESCRIPTION"
+.PP
+\fBSDL_ActiveEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_ACTIVEEVENT\fP is reported\&.
+.PP
+When the mouse leaves or enters the window area a \fBSDL_APPMOUSEFOCUS\fP type activation event occurs, if the mouse entered the window then \fBgain\fR will be 1, otherwise \fBgain\fR will be 0\&. A \fBSDL_APPINPUTFOCUS\fP type activation event occurs when the application loses or gains keyboard focus\&. This usually occurs when another application is made active\&. Finally, a \fBSDL_APPACTIVE\fP type event occurs when the application is either minimised/iconified (\fBgain\fR=0) or restored\&.
+.PP
+.RS
+\fBNote:  
+.PP
+This event does not occur when an application window is first created\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_GetAppState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_AddTimer.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+.TH "SDL_AddTimer" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_AddTimer\- Add a timer which will call a callback after the specified number of milliseconds has elapsed\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_TimerID \fBSDL_AddTimer\fP\fR(\fBUint32 interval, SDL_NewTimerCallback callback, void *param\fR);
+.SH "CALLBACK"
+.PP
+.nf
+\f(CW/* type definition for the "new" timer callback function */
+typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);\fR
+.fi
+.PP
+.SH "DESCRIPTION"
+.PP
+Adds a callback function to be run after the specified number of milliseconds has elapsed\&. The callback function is passed the current timer interval and the user supplied parameter from the \fBSDL_AddTimer\fP call and returns the next timer interval\&. If the returned value from the callback is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled\&.
+.PP
+To cancel a currently running timer call \fISDL_RemoveTimer\fR with the timer ID returned from \fBSDL_AddTimer\fP\&.
+.PP
+The timer callback function may run in a different thread than your main program, and so shouldn\&'t call any functions from within itself\&.
+.PP
+The maximum resolution of this timer is 10 ms, which means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system\&. If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below)\&. If you use this function, you need to pass \fBSDL_INIT_TIMER\fP to \fISDL_Init\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns an ID value for the added timer or \fBNULL\fR if there was an error\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWmy_timer_id = SDL_AddTimer((33/10)*10, my_callbackfunc, my_callback_param);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_RemoveTimer\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_AudioCVT.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,68 @@
+.TH "SDL_AudioCVT" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_AudioCVT\- Audio Conversion Structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  int needed;
+  Uint16 src_format;
+  Uint16 dest_format;
+  double rate_incr;
+  Uint8 *buf;
+  int len;
+  int len_cvt;
+  int len_mult;
+  double len_ratio;
+  void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+  int filter_index;
+} SDL_AudioCVT;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBneeded\fR
+Set to one if the conversion is possible
+.TP 20
+\fBsrc_format\fR
+Audio format of the source
+.TP 20
+\fBdest_format\fR
+Audio format of the destination
+.TP 20
+\fBrate_incr\fR
+Rate conversion increment
+.TP 20
+\fBbuf\fR
+Audio buffer
+.TP 20
+\fBlen\fR
+Length of the original audio buffer in bytes
+.TP 20
+\fBlen_cvt\fR
+Length of converted audio buffer in bytes (calculated)
+.TP 20
+\fBlen_mult\fR
+\fBbuf\fR must be \fBlen\fR*\fBlen_mult\fR bytes in size(calculated)
+.TP 20
+\fBlen_ratio\fR
+Final audio size is \fBlen\fR*\fBlen_ratio\fR
+.TP 20
+\fBfilters[10](\&.\&.)\fR
+Pointers to functions needed for this conversion
+.TP 20
+\fBfilter_index\fR
+Current conversion function
+.SH "DESCRIPTION"
+.PP
+The \fBSDL_AudioCVT\fR is used to convert audio data between different formats\&. A \fBSDL_AudioCVT\fR structure is created with the \fI\fBSDL_BuildAudioCVT\fP\fR function, while the actual conversion is done by the \fI\fBSDL_ConvertAudio\fP\fR function\&.
+.PP
+Many of the fields in the \fBSDL_AudioCVT\fR structure should be considered private and their function will not be discussed here\&.
+.IP "\fBUint8 *\fP\fBbuf\fR" 10This points to the audio data that will be used in the conversion\&. It is both the source and the destination, which means the converted audio data overwrites the original data\&. It also means that the converted data may be larger than the original data (if you were converting from 8-bit to 16-bit, for instance), so you must ensure \fBbuf\fR is large enough\&. See below\&.
+.IP "\fBint\fP \fBlen\fR" 10This is the length of the original audio data in bytes\&.
+.IP "\fBint\fP \fBlen_mult\fR" 10As explained above, the audio buffer needs to be big enough to store the converted data, which may be bigger than the original audio data\&. The length of \fBbuf\fR should be \fBlen\fR*\fBlen_mult\fR\&.
+.IP "\fBdouble\fP \fBlen_ratio\fR" 10When you have finished converting your audio data, you need to know how much of your audio buffer is valid\&. \fBlen\fR*\fBlen_ratio\fR is the size of the converted audio data in bytes\&. This is very similar to \fBlen_mult\fR, however when the convert audio data is shorter than the original \fBlen_mult\fR would be 1\&. \fBlen_ratio\fR, on the other hand, would be a fractional number between 0 and 1\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_BuildAudioCVT\fP\fR, \fI\fBSDL_ConvertAudio\fP\fR, \fI\fBSDL_AudioSpec\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_AudioSpec.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,70 @@
+.TH "SDL_AudioSpec" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_AudioSpec\- Audio Specification Structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  int freq;
+  Uint16 format;
+  Uint8 channels;
+  Uint8 silence;
+  Uint16 samples;
+  Uint32 size;
+  void (*callback)(void *userdata, Uint8 *stream, int len);
+  void *userdata;
+} SDL_AudioSpec;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBfreq\fR
+Audio frequency in samples per second
+.TP 20
+\fBformat\fR
+Audio data format
+.TP 20
+\fBchannels\fR
+Number of channels: 1 mono, 2 stereo
+.TP 20
+\fBsilence\fR
+Audio buffer silence value (calculated)
+.TP 20
+\fBsamples\fR
+Audio buffer size in samples
+.TP 20
+\fBsize\fR
+Audio buffer size in bytes (calculated)
+.TP 20
+\fBcallback(\&.\&.)\fR
+Callback function for filling the audio buffer
+.TP 20
+\fBuserdata\fR
+Pointer the user data which is passed to the callback function
+.SH "DESCRIPTION"
+.PP
+The \fBSDL_AudioSpec\fR structure is used to describe the format of some audio data\&. This structure is used by \fI\fBSDL_OpenAudio\fP\fR and \fI\fBSDL_LoadWAV\fP\fR\&. While all fields are used by \fBSDL_OpenAudio\fP only \fBfreq\fR, \fBformat\fR, \fBsamples\fR and \fBchannels\fR are used by \fBSDL_LoadWAV\fP\&. We will detail these common members here\&.
+.TP 20
+\fBfreq\fR
+The number of samples sent to the sound device every second\&. Common values are 11025, 22050 and 44100\&. The higher the better\&.
+.TP 20
+\fBformat\fR
+Specifies the size and type of each sample element 
+.IP "\fBAUDIO_U8\fP" 10Unsigned 8-bit samples
+.IP "\fBAUDIO_S8\fP" 10Signed 8-bit samples
+.IP "\fBAUDIO_U16\fP or \fBAUDIO_U16LSB\fP" 10Unsigned 16-bit little-endian samples
+.IP "\fBAUDIO_S16\fP or \fBAUDIO_S16LSB\fP" 10Signed 16-bit little-endian samples
+.IP "\fBAUDIO_U16MSB\fP" 10Unsigned 16-bit big-endian samples
+.IP "\fBAUDIO_S16MSB\fP" 10Signed 16-bit big-endian samples
+.IP "\fBAUDIO_U16SYS\fP" 10Either \fBAUDIO_U16LSB\fP or \fBAUDIO_U16MSB\fP depending on you systems endianness
+.IP "\fBAUDIO_S16SYS\fP" 10Either \fBAUDIO_S16LSB\fP or \fBAUDIO_S16MSB\fP depending on you systems endianness
+.TP 20
+\fBchannels\fR
+The number of seperate sound channels\&. 1 is mono (single channel), 2 is stereo (dual channel)\&.
+.TP 20
+\fBsamples\fR
+When used with \fI\fBSDL_OpenAudio\fP\fR this refers to the size of the audio buffer in samples\&. A sample a chunk of audio data of the size specified in \fBformat\fR mulitplied by the number of channels\&. When the \fBSDL_AudioSpec\fR is used with \fI\fBSDL_LoadWAV\fP\fR \fBsamples\fR is set to 4096\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_OpenAudio\fP\fR, \fI\fBSDL_LoadWAV\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_BlitSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,45 @@
+.TH "SDL_BlitSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_BlitSurface\- This performs a fast blit from the source surface to the destination surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_BlitSurface\fP\fR(\fBSDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect\fR);
+.SH "DESCRIPTION"
+.PP
+This performs a fast blit from the source surface to the destination surface\&.
+.PP
+Only the position is used in the \fBdstrect\fR (the width and height are ignored)\&.
+.PP
+If either \fBsrcrect\fR or \fBdstrect\fR are \fBNULL\fP, the entire surface (\fBsrc\fR or \fBdst\fR) is copied\&.
+.PP
+The final blit rectangle is saved in \fBdstrect\fR after all clipping is performed (\fBsrcrect\fR is not modified)\&.
+.PP
+The blit function should not be called on a locked surface\&.
+.PP
+.RS
+\fBNote:  
+.PP
+The results of blitting operations vary greatly depending on whether \fBSDL_SRCAPLHA\fP is set or not\&. See \fISDL_SetAlpha\fR\&.
+.RE
+.SH "RETURN VALUE"
+.PP
+If the blit is successful, it returns \fB0\fR, otherwise it returns \fB-1\fR\&.
+.PP
+If either of the surfaces were in video memory, and the blit returns \fB-2\fR, the video memory was lost, so it should be reloaded with artwork and re-blitted: 
+.PP
+.nf
+\f(CW        while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
+                while ( SDL_LockSurface(image)) < 0 )
+                        Sleep(10);
+                -- Write image pixels to image->pixels --
+                SDL_UnlockSurface(image);
+        }\fR
+.fi
+.PP
+ This happens under DirectX 5\&.0 when the system switches away from your fullscreen application\&. Locking the surface will also fail until you have access to the video memory again\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_LockSurface\fP\fR, \fI\fBSDL_FillRect\fP\fR, \fI\fBSDL_Surface\fR\fR, \fI\fBSDL_Rect\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_BuildAudioCVT.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+.TH "SDL_BuildAudioCVT" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_BuildAudioCVT\- Initializes a SDL_AudioCVT structure for conversion
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_BuildAudioCVT\fP\fR(\fBSDL_AudioCVT *cvt, Uint16 src_format, Uint8 src_channels, int src_rate, Uint16 dst_format, Uint8 dst_channels, int dst_rate\fR);
+.SH "DESCRIPTION"
+.PP
+Before an \fI\fBSDL_AudioCVT\fR\fR structure can be used to convert audio data it must be initialized with source and destination information\&. 
+.PP
+\fBsrc_format\fR and \fBdst_format\fR are the source and destination format of the conversion\&. (For information on audio formats see \fI\fB SDL_AudioSpec\fR\fR)\&. \fBsrc_channels\fR and \fBdst_channels\fR are the number of channels in the source and destination formats\&. Finally, \fBsrc_rate\fR and \fBdst_rate\fR are the frequency or samples-per-second of the source and destination formats\&. Once again, see \fI\fBSDL_AudioSpec\fR\fR\&.
+.SH "RETURN VALUES"
+.PP
+Returns \fB-1\fR if the filter could not be built or 1 if it could\&.
+.SH "EXAMPLES"
+.PP
+See \fI\fBSDL_ConvertAudio\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_ConvertAudio\fP\fR, \fI\fBSDL_AudioCVT\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CD.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,57 @@
+.TH "SDL_CD" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CD\- CDROM Drive Information
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  int id;
+  CDstatus status;
+  int numtracks;
+  int cur_track;
+  int cur_frame;
+  SDL_CDtrack track[SDL_MAX_TRACKS+1];
+} SDL_CD;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBid\fR
+Private drive identifier
+.TP 20
+\fBstatus\fR
+Drive \fIstatus\fR
+.TP 20
+\fBnumtracks\fR
+Number of tracks on the CD
+.TP 20
+\fBcur_track\fR
+Current track
+.TP 20
+\fBcur_frame\fR
+Current frame offset within the track
+.TP 20
+\fBtrack\fR[SDL_MAX_TRACKS+1]
+Array of track descriptions\&. (see \fI\fBSDL_CDtrack\fR\fR)
+.SH "DESCRIPTION"
+.PP
+An \fBSDL_CD\fR structure is returned by \fI\fBSDL_CDOpen\fP\fR\&. It represents an opened CDROM device and stores information on the layout of the tracks on the disc\&.
+.PP
+A frame is the base data unit of a CD\&. \fBCD_FPS\fP frames is equal to 1 second of music\&. SDL provides two macros for converting between time and frames: \fBFRAMES_TO_MSF(f, M,S,F)\fP and \fBMSF_TO_FRAMES\fP\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CWint min, sec, frame;
+int frame_offset;
+
+FRAMES_TO_MSF(cdrom->cur_frame, &min, &sec, &frame);
+printf("Current Position: %d minutes, %d seconds, %d frames
+", min, sec, frame);
+
+frame_offset=MSF_TO_FRAMES(min, sec, frame);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDOpen\fP\fR, \fI\fBSDL_CDtrack\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDClose.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_CDClose" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDClose\- Closes a SDL_CD handle
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_CDClose\fP\fR(\fBSDL_CD *cdrom\fR);
+.SH "DESCRIPTION"
+.PP
+Closes the given \fBcdrom\fR handle\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDOpen\fP\fR, \fI\fBSDL_CD\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDEject.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_CDEject" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDEject\- Ejects a CDROM
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDEject\fP\fR(\fBSDL_CD *cdrom\fR);
+.SH "DESCRIPTION"
+.PP
+Ejects the given \fBcdrom\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CD\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDName.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+.TH "SDL_CDName" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDName\- Returns a human-readable, system-dependent identifier for the CD-ROM\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBconst char *\fBSDL_CDName\fP\fR(\fBint drive\fR);
+.SH "DESCRIPTION"
+.PP
+Returns a human-readable, system-dependent identifier for the CD-ROM\&. \fBdrive\fR is the index of the drive\&. Drive indices start to 0 and end at \fBSDL_CDNumDrives()\fP-1\&.
+.SH "EXAMPLES"
+.PP
+.IP "   \(bu" 6
+"/dev/cdrom"
+.IP "   \(bu" 6
+"E:"
+.IP "   \(bu" 6
+"/dev/disk/ide/1/master"
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDNumDrives\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDNumDrives.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_CDNumDrives" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDNumDrives\- Returns the number of CD-ROM drives on the system\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDNumDrives\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+Returns the number of CD-ROM drives on the system\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDOpen.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,58 @@
+.TH "SDL_CDOpen" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDOpen\- Opens a CD-ROM drive for access\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_CD *\fBSDL_CDOpen\fP\fR(\fBint drive\fR);
+.SH "DESCRIPTION"
+.PP
+Opens a CD-ROM drive for access\&. It returns a \fI\fBSDL_CD\fR\fR structure on success, or \fBNULL\fP if the drive was invalid or busy\&. This newly opened CD-ROM becomes the default CD used when other CD functions are passed a \fBNULL\fP CD-ROM handle\&. 
+.PP
+Drives are numbered starting with 0\&. Drive 0 is the system default CD-ROM\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CWSDL_CD *cdrom;
+int cur_track;
+int min, sec, frame;
+SDL_Init(SDL_INIT_CDROM);
+atexit(SDL_Quit);
+
+/* Check for CD drives */
+if(!SDL_CDNumDrives()){
+  /* None found */
+  fprintf(stderr, "No CDROM devices available
+");
+  exit(-1);
+}
+
+/* Open the default drive */
+cdrom=SDL_CDOpen(0);
+
+/* Did if open? Check if cdrom is NULL */
+if(!cdrom){
+  fprintf(stderr, "Couldn\&'t open drive: %s
+", SDL_GetError());
+  exit(-1);
+}
+
+/* Print Volume info */
+printf("Name: %s
+", SDL_CDName(0));
+printf("Tracks: %d
+", cdrom->numtracks);
+for(cur_track=0;cur_track < cdrom->numtracks; cur_track++){
+  FRAMES_TO_MSF(cdrom->track[cur_track]\&.length, &min, &sec, &frame);
+  printf("	Track %d: Length %d:%d
+", cur_track, min, sec);
+}
+
+SDL_CDClose(cdrom);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CD\fR\fR, \fI\fBSDL_CDtrack\fR\fR, \fI\fBSDL_CDClose\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDPause.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_CDPause" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDPause\- Pauses a CDROM
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDPause\fP\fR(\fBSDL_CD *cdrom\fR);
+.SH "DESCRIPTION"
+.PP
+Pauses play on the given \fBcdrom\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDPlay\fP\fR, \fI\fBSDL_CDResume\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDPlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_CDPlay" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDPlay\- Play a CD
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDPlay\fP\fR(\fBSDL_CD *cdrom, int start, int length\fR);
+.SH "DESCRIPTION"
+.PP
+Plays the given \fBcdrom\fR, starting a frame \fBstart\fR for \fBlength\fR frames\&.
+.SH "RETURN VALUES"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDPlayTracks\fP\fR, \fI\fBSDL_CDStop\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDPlayTracks.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,47 @@
+.TH "SDL_CDPlayTracks" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDPlayTracks\- Play the given CD track(s)
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDPlayTracks\fP\fR(\fBSDL_CD *cdrom, int start_track, int start_frame, int ntracks, int nframes)\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_CDPlayTracks\fP plays the given CD starting at track \fBstart_track\fR, for \fBntracks\fR tracks\&. 
+.PP
+\fBstart_frame\fR is the frame offset, from the beginning of the \fBstart_track\fR, at which to start\&. \fBnframes\fR is the frame offset, from the beginning of the last track (\fBstart_track\fR+\fBntracks\fR), at which to end playing\&.
+.PP
+\fBSDL_CDPlayTracks\fP should only be called after calling \fI\fBSDL_CDStatus\fP\fR to get track information about the CD\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Data tracks are ignored\&.
+.RE
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR, or \fB-1\fR if there was an error\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CW/* assuming cdrom is a previously opened device */
+/* Play the entire CD */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
+
+/* Play the first track */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 0, 0, 1, 0);
+
+/* Play first 15 seconds of the 2nd track */
+if(CD_INDRIVE(SDL_CDStatus(cdrom)))
+  SDL_CDPlayTracks(cdrom, 1, 0, 0, CD_FPS*15);\fR
+.fi
+.PP
+ 
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDPlay\fP\fR, \fI\fBSDL_CDStatus\fP\fR, \fI\fBSDL_CD\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDResume.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_CDResume" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDResume\- Resumes a CDROM
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDResume\fP\fR(\fBSDL_CD *cdrom\fR);
+.SH "DESCRIPTION"
+.PP
+Resumes play on the given \fBcdrom\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDPlay\fP\fR, \fI\fBSDL_CDPause\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDStatus.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,59 @@
+.TH "SDL_CDStatus" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDStatus\- Returns the current status of the given drive\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBCDstatus \fBSDL_CDStatus\fP\fR(\fBSDL_CD *cdrom\fR);
+\fB/* Given a status, returns true if there\&'s a disk in the drive */
+#define CD_INDRIVE(status)      ((int)status > 0)
+.SH "DESCRIPTION"
+.PP
+This function returns the current status of the given drive\&. Status is described like so: 
+.PP
+.nf
+\f(CWtypedef enum {
+  CD_TRAYEMPTY,
+  CD_STOPPED,
+  CD_PLAYING,
+  CD_PAUSED,
+  CD_ERROR = -1
+} CDstatus;\fR
+.fi
+.PP
+.PP
+If the drive has a CD in it, the table of contents of the CD and current play position of the CD will be stored in the SDL_CD structure\&.
+.PP
+The macro \fBCD_INDRIVE\fP is provided for convenience, and given a status returns true if there\&'s a disk in the drive\&.
+.PP
+.RS
+\fBNote:  
+.PP
+\fBSDL_CDStatus\fP also updates the \fI\fBSDL_CD\fR\fR structure passed to it\&.
+.RE
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWint playTrack(int track)
+{
+  int playing = 0;
+
+  if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+  /* clamp to the actual number of tracks on the CD */
+    if (track >= cdrom->numtracks) {
+      track = cdrom->numtracks-1;
+    }
+
+    if ( SDL_CDPlayTracks(cdrom, track, 0, 1, 0) == 0 ) {
+      playing = 1;
+    }
+  }
+  return playing;
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CD\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDStop.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_CDStop" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDStop\- Stops a CDROM
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_CDStop\fP\fR(\fBSDL_CD *cdrom\fR);
+.SH "DESCRIPTION"
+.PP
+Stops play on the given \fBcdrom\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CDPlay\fP\fR,
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CDtrack.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+.TH "SDL_CDtrack" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CDtrack\- CD Track Information Structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 id;
+  Uint8 type;
+  Uint32 length;
+  Uint32 offset;
+} SDL_CDtrack;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBid\fR
+Track number (0-99)
+.TP 20
+\fBtype\fR
+\fBSDL_AUDIO_TRACK\fP or \fBSDL_DATA_TRACK\fP
+.TP 20
+\fBlength\fR
+Length, in frames, of this track
+.TP 20
+\fBoffset\fR
+Frame offset to the beginning of this track
+.SH "DESCRIPTION"
+.PP
+\fBSDL_CDtrack\fR stores data on each track on a CD, its fields should be pretty self explainatory\&. It is a member a the \fI\fBSDL_CD\fR\fR structure\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Frames can be converted to standard timings\&. There are \fBCD_FPS\fP frames per second, so \fBSDL_CDtrack\fR\&.\fBlength\fR/\fBCD_FPS\fP=length_in_seconds\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CD\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CloseAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_CloseAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CloseAudio\- Shuts down audio processing and closes the audio device\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_CloseAudio\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+This function shuts down audio processing and closes the audio device\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_OpenAudio\fP\fR 
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Color.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,34 @@
+.TH "SDL_Color" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Color\- Format independent color description
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 r;
+  Uint8 g;
+  Uint8 b;
+  Uint8 unused;
+} SDL_Color;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBr\fR
+Red intensity
+.TP 20
+\fBg\fR
+Green intensity
+.TP 20
+\fBb\fR
+Blue intensity
+.TP 20
+\fBunused\fR
+Unused
+.SH "DESCRIPTION"
+.PP
+\fBSDL_Color\fR describes a color in a format independent way\&. You can convert a \fBSDL_Color\fR to a pixel value for a certain pixel format using \fI\fBSDL_MapRGB\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PixelFormat\fR\fR, \fI\fBSDL_SetColors\fP\fR, \fI\fBSDL_Palette\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CondBroadcast.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_CondBroadcast" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CondBroadcast\- Restart all threads waiting on a condition variable
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_CondBroadcast\fP\fR(\fBSDL_cond *cond\fR);
+.SH "DESCRIPTION"
+.PP
+Restarts all threads that are waiting on the condition variable, \fBcond\fR\&. Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CondSignal\fP\fR, \fI\fBSDL_CondWait\fP\fR 
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CondSignal.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_CondSignal" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CondSignal\- Restart a thread wait on a condition variable
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_CondSignal\fP\fR(\fBSDL_cond *cond\fR);
+.SH "DESCRIPTION"
+.PP
+Restart one of the threads that are waiting on the condition variable, \fBcond\fR\&. Returns \fB0\fR on success of \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CondWait\fP\fR, \fI\fBSDL_CondBroadcast\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CondWait.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_CondWait" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CondWait\- Wait on a condition variable
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_CondWait\fP\fR(\fBSDL_cond *cond, SDL_mutex *mut\fR);
+.SH "DESCRIPTION"
+.PP
+Wait on the condition variable \fBcond\fR and unlock the provided mutex\&. The mutex must the locked before entering this function\&. Returns \fB0\fR when it is signalled, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CondWaitTimeout\fP\fR, \fI\fBSDL_CondSignal\fP\fR, \fI\fBSDL_mutexP\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CondWaitTimeout.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_CondWaitTimeout" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CondWaitTimeout\- Wait on a condition variable, with timeout
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_CondWaitTimeout\fP\fR(\fBSDL_cond *cond, SDL_mutex *mutex, Uint32 ms\fR);
+.SH "DESCRIPTION"
+.PP
+Wait on the condition variable \fBcond\fR for, at most, \fBms\fR milliseconds\&. \fBmut\fR is unlocked so it must be locked when the function is called\&. Returns \fBSDL_MUTEX_TIMEDOUT\fP if the condition is not signalled in the allotted time, \fB0\fR if it was signalled or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CondWait\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ConvertAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,95 @@
+.TH "SDL_ConvertAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ConvertAudio\- Convert audio data to a desired audio format\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_ConvertAudio\fP\fR(\fBSDL_AudioCVT *cvt\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_ConvertAudio\fP takes one parameter, \fBcvt\fR, which was previously initilized\&. Initilizing a \fI\fBSDL_AudioCVT\fR\fR is a two step process\&. First of all, the structure must be passed to \fI\fBSDL_BuildAudioCVT\fP\fR along with source and destination format parameters\&. Secondly, the \fBcvt\fR->\fBbuf\fR and \fBcvt\fR->\fBlen\fR fields must be setup\&. \fBcvt\fR->\fBbuf\fR should point to the audio data and \fBcvt\fR->\fBlen\fR should be set to the length of the audio data in bytes\&. Remember, the length of the buffer pointed to by \fBbuf\fR show be \fBlen\fR*\fBlen_mult\fR bytes in length\&.
+.PP
+Once the \fBSDL_AudioCVT\fRstructure is initilized then we can pass it to \fBSDL_ConvertAudio\fP, which will convert the audio data pointer to by \fBcvt\fR->\fBbuf\fR\&. If \fBSDL_ConvertAudio\fP returned \fB0\fR then the conversion was completed successfully, otherwise \fB-1\fR is returned\&.
+.PP
+If the conversion completed successfully then the converted audio data can be read from \fBcvt\fR->\fBbuf\fR\&. The amount of valid, converted, audio data in the buffer is equal to \fBcvt\fR->\fBlen\fR*\fBcvt\fR->\fBlen_ratio\fR\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CW/* Converting some WAV data to hardware format */
+void my_audio_callback(void *userdata, Uint8 *stream, int len);
+
+SDL_AudioSpec *desired, *obtained;
+SDL_AudioSpec wav_spec;
+SDL_AudioCVT  wav_cvt;
+Uint32 wav_len;
+Uint8 *wav_buf;
+int ret;
+
+/* Allocated audio specs */
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+obtained=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* Set desired format */
+desired->freq=22050;
+desired->format=AUDIO_S16LSB;
+desired->samples=8192;
+desired->callback=my_audio_callback;
+desired->userdata=NULL;
+
+/* Open the audio device */
+if ( SDL_OpenAudio(desired, obtained) < 0 ){
+  fprintf(stderr, "Couldn\&'t open audio: %s
+", SDL_GetError());
+  exit(-1);
+}
+        
+free(desired);
+
+/* Load the test\&.wav */
+if( SDL_LoadWAV("test\&.wav", &wav_spec, &wav_buf, &wav_len) == NULL ){
+  fprintf(stderr, "Could not open test\&.wav: %s
+", SDL_GetError());
+  SDL_CloseAudio();
+  free(obtained);
+  exit(-1);
+}
+                                            
+/* Build AudioCVT */
+ret = SDL_BuildAudioCVT(&wav_cvt,
+                        wav_spec\&.format, wav_spec\&.channels, wav_spec\&.freq,
+                        obtained->format, obtained->channels, obtained->freq);
+
+/* Check that the convert was built */
+if(ret==-1){
+  fprintf(stderr, "Couldn\&'t build converter!
+");
+  SDL_CloseAudio();
+  free(obtained);
+  SDL_FreeWAV(wav_buf);
+}
+
+/* Setup for conversion */
+wav_cvt\&.buf=(Uint8 *)malloc(wav_len*wav_cvt\&.len_mult);
+wav_cvt\&.len=wav_len;
+memcpy(wav_cvt\&.buf, wav_buf, wav_len);
+
+/* We can delete to original WAV data now */
+SDL_FreeWAV(wav_buf);
+
+/* And now we\&'re ready to convert */
+SDL_ConvertAudio(&wav_cvt);
+
+/* do whatever */
+\&.
+\&.
+\&.
+\&.
+
+\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_BuildAudioCVT\fP\fR, \fI\fBSDL_AudioCVT\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ConvertSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_ConvertSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ConvertSurface\- Converts a surface to the same format as another surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_ConvertSurface\fP\fR(\fBSDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+Creates a new surface of the specified format, and then copies and maps the given surface to it\&. If this function fails, it returns \fBNULL\fP\&.
+.PP
+The \fBflags\fR parameter is passed to \fI\fBSDL_CreateRGBSurface\fP\fR and has those semantics\&.
+.PP
+This function is used internally by \fI\fBSDL_DisplayFormat\fP\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns either a pointer to the new surface, or \fBNULL\fP on error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateRGBSurface\fP\fR, \fI\fBSDL_DisplayFormat\fP\fR, \fI\fBSDL_PixelFormat\fR\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateCond.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,31 @@
+.TH "SDL_CreateCond" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateCond\- Create a condition variable
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBSDL_cond *\fBSDL_CreateCond\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Creates a condition variable\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CWSDL_cond *cond;
+
+cond=SDL_CreateCond();
+\&.
+\&.
+/* Do stuff */
+
+\&.
+\&.
+SDL_DestroyCond(cond);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_DestroyCond\fP\fR, \fI\fBSDL_CondWait\fP\fR, \fI\fBSDL_CondSignal\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateCursor.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,120 @@
+.TH "SDL_CreateCursor" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateCursor\- Creates a new mouse cursor\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Cursor *\fBSDL_CreateCursor\fP\fR(\fBUint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y\fR);
+.SH "DESCRIPTION"
+.PP
+Create a cursor using the specified \fBdata\fR and \fBmask\fR (in MSB format)\&. The cursor width must be a multiple of 8 bits\&.
+.PP
+The cursor is created in black and white according to the following: 
+.TP 20
+\fBData / Mask\fR
+\fBResulting pixel on screen\fR
+.TP 20
+0 / 1
+White
+.TP 20
+1 / 1
+Black
+.TP 20
+0 / 0
+Transparent
+.TP 20
+1 / 0
+Inverted color if possible, black if not\&.
+.PP
+Cursors created with this function must be freed with \fISDL_FreeCursor\fR\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CW/* Stolen from the mailing list */
+/* Creates a new mouse cursor from an XPM */
+
+
+/* XPM */
+static const char *arrow[] = {
+  /* width height num_colors chars_per_pixel */
+  "    32    32        3            1",
+  /* colors */
+  "X c #000000",
+  "\&. c #ffffff",
+  "  c None",
+  /* pixels */
+  "X                               ",
+  "XX                              ",
+  "X\&.X                             ",
+  "X\&.\&.X                            ",
+  "X\&.\&.\&.X                           ",
+  "X\&.\&.\&.\&.X                          ",
+  "X\&.\&.\&.\&.\&.X                         ",
+  "X\&.\&.\&.\&.\&.\&.X                        ",
+  "X\&.\&.\&.\&.\&.\&.\&.X                       ",
+  "X\&.\&.\&.\&.\&.\&.\&.\&.X                      ",
+  "X\&.\&.\&.\&.\&.XXXXX                     ",
+  "X\&.\&.X\&.\&.X                         ",
+  "X\&.X X\&.\&.X                        ",
+  "XX  X\&.\&.X                        ",
+  "X    X\&.\&.X                       ",
+  "     X\&.\&.X                       ",
+  "      X\&.\&.X                      ",
+  "      X\&.\&.X                      ",
+  "       XX                       ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "                                ",
+  "0,0"
+};
+
+static SDL_Cursor *init_system_cursor(const char *image[])
+{
+  int i, row, col;
+  Uint8 data[4*32];
+  Uint8 mask[4*32];
+  int hot_x, hot_y;
+
+  i = -1;
+  for ( row=0; row<32; ++row ) {
+    for ( col=0; col<32; ++col ) {
+      if ( col % 8 ) {
+        data[i] <<= 1;
+        mask[i] <<= 1;
+      } else {
+        ++i;
+        data[i] = mask[i] = 0;
+      }
+      switch (image[4+row][col]) {
+        case \&'X\&':
+          data[i] |= 0x01;
+          k[i] |= 0x01;
+          break;
+        case \&'\&.\&':
+          mask[i] |= 0x01;
+          break;
+        case \&' \&':
+          break;
+      }
+    }
+  }
+  sscanf(image[4+row], "%d,%d", &hot_x, &hot_y);
+  return SDL_CreateCursor(data, mask, 32, 32, hot_x, hot_y);
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_FreeCursor\fP\fR, \fI\fBSDL_SetCursor\fP\fR, \fI\fBSDL_ShowCursor\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateMutex.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,43 @@
+.TH "SDL_CreateMutex" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateMutex\- Create a mutex
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBSDL_mutex *\fBSDL_CreateMutex\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Create a new, unlocked mutex\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CWSDL_mutex *mut;
+
+mut=SDL_CreateMutex();
+\&.
+\&.
+if(SDL_mutexP(mut)==-1){
+  fprintf(stderr, "Couldn\&'t lock mutex
+");
+  exit(-1);
+}
+\&.
+/* Do stuff while mutex is locked */
+\&.
+\&.
+if(SDL_mutexV(mut)==-1){
+  fprintf(stderr, "Couldn\&'t unlock mutex
+");
+  exit(-1);
+}
+
+SDL_DestroyMutex(mut);
+\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_mutexP\fP\fR, \fI\fBSDL_mutexV\fP\fR, \fI\fBSDL_DestroyMutex\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateRGBSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,29 @@
+.TH "SDL_CreateRGBSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateRGBSurface\- Create an empty SDL_Surface
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_CreateRGBSurface\fP\fR(\fBUint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask\fR);
+.SH "DESCRIPTION"
+.PP
+Allocate an empty surface (must be called after \fISDL_SetVideoMode\fR)
+.PP
+If \fBdepth\fR is 8 bits an empty palette is allocated for the surface, otherwise a \&'packed-pixel\&' \fI\fBSDL_PixelFormat\fR\fR is created using the \fB[RGBA]mask\fR\&'s provided (see \fI\fBSDL_PixelFormat\fR\fR)\&. The \fBflags\fR specifies the type of surface that should be created, it is an OR\&'d combination of the following possible values\&.
+.TP 20
+\fBSDL_SWSURFACE\fP
+SDL will create the surface in system memory\&. This improves the performance of pixel level access, however you may not be able to take advantage of some types of hardware blitting\&.
+.TP 20
+\fBSDL_HWSURFACE\fP
+SDL will attempt to create the surface in video memory\&. This will allow SDL to take advantage of Video->Video blits (which are often accelerated)\&.
+.TP 20
+\fBSDL_SRCCOLORKEY\fP
+With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware colorkey blitting support\&.
+.TP 20
+\fBSDL_SRCALPHA\fP
+With this flag SDL will attempt to find the best location for this surface, either in system memory or video memory, to obtain hardware alpha support
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateRGBSurfaceFrom\fP\fR, \fI\fBSDL_FreeSurface\fP\fR, \fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_LockSurface\fP\fR, \fI\fBSDL_PixelFormat\fR\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateRGBSurfaceFrom.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+.TH "SDL_CreateRGBSurfaceFrom" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateRGBSurfaceFrom\- Create an SDL_Surface from pixel data
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_CreateRGBSurfaceFrom\fP\fR(\fBvoid *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask\fR);
+.SH "DESCRIPTION"
+.PP
+Creates an SDL_Surface from the provided pixel data\&.
+.PP
+The data stored in \fBpixels\fR is assumed to be of the \fBdepth\fR specified in the parameter list\&. The pixel data is not copied into the \fBSDL_Surface\fR structure so it should no be freed until the surface has been freed with a called to \fISDL_FreeSurface\fR\&. \fBpitch\fR is the length of each scanline in bytes\&. 
+.PP
+See \fI\fBSDL_CreateRGBSurface\fP\fR for a more detailed description of the other parameters\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateRGBSurface\fP\fR, \fI\fBSDL_FreeSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateSemaphore.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+.TH "SDL_CreateSemaphore" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateSemaphore\- Creates a new semaphore and assigns an initial value to it\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBSDL_sem *\fBSDL_CreateSemaphore\fP\fR(\fBUint32 initial_value\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_CreateSemaphore()\fP creates a new semaphore and initializes it with the value \fBinitial_value\fR\&. Each locking operation on the semaphore by \fISDL_SemWait\fR, \fISDL_SemTryWait\fR or \fISDL_SemWaitTimeout\fR will atomically decrement the semaphore value\&. The locking operation will be blocked if the semaphore value is not positive (greater than zero)\&. Each unlock operation by \fISDL_SemPost\fR will atomically increment the semaphore value\&.
+.SH "RETURN VALUE"
+.PP
+Returns a pointer to an initialized semaphore or \fBNULL\fR if there was an error\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_sem *my_sem;
+
+my_sem = SDL_CreateSemaphore(INITIAL_SEM_VALUE);
+
+if (my_sem == NULL) {
+        return CREATE_SEM_FAILED;
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemPost\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateThread.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_CreateThread" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateThread\- Creates a new thread of execution that shares its parent\&'s properties\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBSDL_Thread *\fBSDL_CreateThread\fP\fR(\fBint (*fn)(void *), void *data\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_CreateThread\fP creates a new thread of execution that shares all of its parent\&'s global memory, signal handlers, file descriptors, etc, and runs the function \fBfn\fR passed the void pointer \fBdata\fR The thread quits when this function returns\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_KillThread\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_CreateYUVOverlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_CreateYUVOverlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_CreateYUVOverlay\- Create a YUV video overlay
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Overlay *\fBSDL_CreateYUVOverlay\fP\fR(\fBint width, int height, Uint32 format, SDL_Surface *display\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_CreateYUVOverlay\fP creates a YUV overlay of the specified \fBwidth\fR, \fBheight\fR and \fBformat\fR (see \fI\fBSDL_Overlay\fR\fR for a list of available formats), for the provided \fBdisplay\fR\&. A \fI\fBSDL_Overlay\fR\fR structure is returned\&.
+.PP
+The term \&'overlay\&' is a misnomer since, unless the overlay is created in hardware, the contents for the display surface underneath the area where the overlay is shown will be overwritten when the overlay is displayed\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Overlay\fR\fR, \fI\fBSDL_DisplayYUVOverlay\fP\fR, \fI\fBSDL_FreeYUVOverlay\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Delay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_Delay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Delay\- Wait a specified number of milliseconds before returning\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_Delay\fP\fR(\fBUint32 ms\fR);
+.SH "DESCRIPTION"
+.PP
+Wait a specified number of milliseconds before returning\&. \fBSDL_Delay\fP will wait at \fIleast\fP the specified time, but possible longer due to OS scheduling\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_AddTimer\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DestroyCond.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_DestroyCond" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DestroyCond\- Destroy a condition variable
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBvoid \fBSDL_DestroyCond\fP\fR(\fBSDL_cond *cond\fR);
+.SH "DESCRIPTION"
+.PP
+Destroys a condition variable\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateCond\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DestroyMutex.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_DestroyMutex" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DestroyMutex\- Destroy a mutex
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBvoid \fBSDL_DestroyMutex\fP\fR(\fBSDL_mutex *mutex\fR);
+.SH "DESCRIPTION"
+.PP
+Destroy a previously \fIcreated\fR mutex\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateMutex\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DestroySemaphore.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_DestroySemaphore" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DestroySemaphore\- Destroys a semaphore that was created by \fISDL_CreateSemaphore\fR\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBvoid \fBSDL_DestroySemaphore\fP\fR(\fBSDL_sem *sem\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_DestroySemaphore\fP destroys the semaphore pointed to by \fBsem\fR that was created by \fI\fBSDL_CreateSemaphore\fP\fR\&. It is not safe to destroy a semaphore if there are threads currently blocked waiting on it\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWif (my_sem != NULL) {
+        SDL_DestroySemaphore(my_sem);
+        my_sem = NULL;
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemPost\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DisplayFormat.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_DisplayFormat" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DisplayFormat\- Convert a surface to the display format
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_DisplayFormat\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer, suitable for fast blitting onto the display surface\&. It calls \fISDL_ConvertSurface\fR
+.PP
+If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function\&.
+.PP
+If you want an alpha channel, see \fISDL_DisplayFormatAlpha\fR\&.
+.SH "RETURN VALUE"
+.PP
+If the conversion fails or runs out of memory, it returns \fBNULL\fR
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_ConvertSurface\fP\fR, \fI\fBSDL_DisplayFormatAlpha\fP\fR \fI\fBSDL_SetAlpha\fP\fR, \fI\fBSDL_SetColorKey\fP\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DisplayFormatAlpha.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+.TH "SDL_DisplayFormatAlpha" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DisplayFormatAlpha\- Convert a surface to the display format
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_DisplayFormatAlpha\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+This function takes a surface and copies it to a new surface of the pixel format and colors of the video framebuffer plus an alpha channel, suitable for fast blitting onto the display surface\&. It calls \fISDL_ConvertSurface\fR
+.PP
+If you want to take advantage of hardware colorkey or alpha blit acceleration, you should set the colorkey and alpha value before calling this function\&.
+.SH "RETURN VALUE"
+.PP
+If the conversion fails or runs out of memory, it returns \fBNULL\fR
+.SH "SEE ALSO"
+.PP
+\fISDL_ConvertSurface\fR, \fISDL_SetAlpha\fR, \fISDL_SetColorKey\fR, \fISDL_DisplayFormat\fR, \fISDL_Surface\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_DisplayYUVOverlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_DisplayYUVOverlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_DisplayYUVOverlay\- Blit the overlay to the display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_DisplayYUVOverlay\fP\fR(\fBSDL_Overlay *overlay, SDL_Rect *dstrect\fR);
+.SH "DESCRIPTION"
+.PP
+Blit the \fBoverlay\fR to the surface specified when it was \fIcreated\fR\&. The \fI\fBSDL_Rect\fR\fR structure, \fBdstrect\fR, specifies the position and size of the destination\&. If the \fBdstrect\fR is a larger or smaller than the overlay then the overlay will be scaled, this is optimized for 2x scaling\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Overlay\fR\fR, \fI\fBSDL_CreateYUVOverlay\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_EnableKeyRepeat.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_EnableKeyRepeat" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_EnableKeyRepeat\- Set keyboard repeat rate\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_EnableKeyRepeat\fP\fR(\fBint delay, int interval\fR);
+.SH "DESCRIPTION"
+.PP
+Enables or disables the keyboard repeat rate\&. \fBdelay\fR specifies how long the key must be pressed before it begins repeating, it then repeats at the speed specified by \fBinterval\fR\&. Both \fBdelay\fR and \fBinterval\fR are expressed in milliseconds\&.
+.PP
+Setting \fBdelay\fR to 0 disables key repeating completely\&. Good default values are \fBSDL_DEFAULT_REPEAT_DELAY\fP and \fISDL_DEFAULT_REPEAT_INTERVAL\fP\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success and \fB-1\fR on failure\&.
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_EnableUNICODE.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+.TH "SDL_EnableUNICODE" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_EnableUNICODE\- Enable UNICODE translation
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_EnableUNICODE\fP\fR(\fBint enable\fR);
+.SH "DESCRIPTION"
+.PP
+Enables/Disables UNICODE keyboard translation\&.
+.PP
+If you wish to translate a keysym to it\&'s printable representation, you need to enable UNICODE translation using this function (\fBenable\fR=0) and then look in the \fBunicode\fR member of the \fI\fBSDL_keysym\fR\fR structure\&. This value will be zero for keysyms that do not have a printable representation\&. UNICODE translation is disabled by default as the conversion can cause a slight overhead\&.
+.SH "RETURN VALUE"
+.PP
+Returns the previous translation mode\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_keysym\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Event.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,175 @@
+.TH "SDL_Event" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Event\- General event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef union{
+  Uint8 type;
+  SDL_ActiveEvent active;
+  SDL_KeyboardEvent key;
+  SDL_MouseMotionEvent motion;
+  SDL_MouseButtonEvent button;
+  SDL_JoyAxisEvent jaxis;
+  SDL_JoyBallEvent jball;
+  SDL_JoyHatEvent jhat;
+  SDL_JoyButtonEvent jbutton;
+  SDL_ResizeEvent resize;
+  SDL_QuitEvent quit;
+  SDL_UserEvent user;
+  SDL_SywWMEvent syswm;
+} SDL_Event;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+The type of event
+.TP 20
+\fBactive\fR
+\fIActivation event\fR
+.TP 20
+\fBkey\fR
+\fIKeyboard event\fR
+.TP 20
+\fBmotion\fR
+\fIMouse motion event\fR
+.TP 20
+\fBbutton\fR
+\fIMouse button event\fR
+.TP 20
+\fBjaxis\fR
+\fIJoystick axis motion event\fR
+.TP 20
+\fBjball\fR
+\fIJoystick trackball motion event\fR
+.TP 20
+\fBjhat\fR
+\fIJoystick hat motion event\fR
+.TP 20
+\fBjbutton\fR
+\fIJoystick button event\fR
+.TP 20
+\fBresize\fR
+\fIApplication window resize event\fR
+.TP 20
+\fBquit\fR
+\fIApplication quit request event\fR
+.TP 20
+\fBuser\fR
+\fIUser defined event\fR
+.TP 20
+\fBsyswm\fR
+\fIUndefined window manager event\fR
+.SH "DESCRIPTION"
+.PP
+The \fBSDL_Event\fR union is the core to all event handling is SDL, its probably the most important structure after \fBSDL_Surface\fR\&. \fBSDL_Event\fR is a union of all event structures used in SDL, using it is a simple matter of knowing which union member relates to which event \fBtype\fR\&.
+.PP
+.TP 20
+\fBEvent \fBtype\fR\fR
+\fBEvent Structure\fR
+.TP 20
+\fBSDL_ACTIVEEVENT\fP
+\fI\fBSDL_ActiveEvent\fR\fR
+.TP 20
+\fBSDL_KEYDOWN/UP\fP
+\fI\fBSDL_KeyboardEvent\fR\fR
+.TP 20
+\fBSDL_MOUSEMOTION\fP
+\fI\fBSDL_MouseMotionEvent\fR\fR
+.TP 20
+\fBSDL_MOUSEBUTTONDOWN/UP\fP
+\fI\fBSDL_MouseButtonEvent\fR\fR
+.TP 20
+\fBSDL_JOYAXISMOTION\fP
+\fI\fBSDL_JoyAxisEvent\fR\fR
+.TP 20
+\fBSDL_JOYBALLMOTION\fP
+\fI\fBSDL_JoyBallEvent\fR\fR
+.TP 20
+\fBSDL_JOYHATMOTION\fP
+\fI\fBSDL_JoyHatEvent\fR\fR
+.TP 20
+\fBSDL_JOYBUTTONDOWN/UP\fP
+\fI\fBSDL_JoyButtonEvent\fR\fR
+.TP 20
+\fBSDL_QUIT\fP
+\fI\fBSDL_QuitEvent\fR\fR
+.TP 20
+\fBSDL_SYSWMEVENT\fP
+\fI\fBSDL_SysWMEvent\fR\fR
+.TP 20
+\fBSDL_VIDEORESIZE\fP
+\fI\fBSDL_ResizeEvent\fR\fR
+.TP 20
+\fBSDL_USEREVENT\fP
+\fI\fBSDL_UserEvent\fR\fR
+.SH "USE"
+.PP
+The \fBSDL_Event\fR structure has two uses
+.IP "   \(bu" 6
+Reading events on the event queue
+.IP "   \(bu" 6
+Placing events on the event queue
+.PP
+Reading events from the event queue is done with either \fI\fBSDL_PollEvent\fP\fR or \fI\fBSDL_PeepEvents\fP\fR\&. We\&'ll use \fBSDL_PollEvent\fP and step through an example\&.
+.PP
+First off, we create an empty \fBSDL_Event\fR structure\&. 
+.PP
+.nf
+\f(CWSDL_Event test_event;\fR
+.fi
+.PP
+ \fBSDL_PollEvent\fP removes the next event from the event queue, if there are no events on the queue it returns \fB0\fR otherwise it returns \fB1\fR\&. We use a \fBwhile\fP loop to process each event in turn\&. 
+.PP
+.nf
+\f(CWwhile(SDL_PollEvent(&test_event)) {\fR
+.fi
+.PP
+ The \fBSDL_PollEvent\fP function take a pointer to an \fBSDL_Event\fR structure that is to be filled with event information\&. We know that if \fBSDL_PollEvent\fP removes an event from the queue then the event information will be placed in our \fBtest_event\fR structure, but we also know that the \fItype\fP of event will be placed in the \fBtype\fR member of \fBtest_event\fR\&. So to handle each event \fBtype\fR seperately we use a \fBswitch\fP statement\&. 
+.PP
+.nf
+\f(CW  switch(test_event\&.type) {\fR
+.fi
+.PP
+ We need to know what kind of events we\&'re looking for \fIand\fP the event \fBtype\fR\&'s of those events\&. So lets assume we want to detect where the user is moving the mouse pointer within our application\&. We look through our event types and notice that \fBSDL_MOUSEMOTION\fP is, more than likely, the event we\&'re looking for\&. A little \fImore\fR research tells use that \fBSDL_MOUSEMOTION\fP events are handled within the \fI\fBSDL_MouseMotionEvent\fR\fR structure which is the \fBmotion\fR member of \fBSDL_Event\fR\&. We can check for the \fBSDL_MOUSEMOTION\fP event \fBtype\fR within our \fBswitch\fP statement like so: 
+.PP
+.nf
+\f(CW    case SDL_MOUSEMOTION:\fR
+.fi
+.PP
+ All we need do now is read the information out of the \fBmotion\fR member of \fBtest_event\fR\&. 
+.PP
+.nf
+\f(CW      printf("We got a motion event\&.
+");
+      printf("Current mouse position is: (%d, %d)
+", test_event\&.motion\&.x, test_event\&.motion\&.y);
+      break;
+    default:
+      printf("Unhandled Event!
+");
+      break;
+  }
+}
+printf("Event queue empty\&.
+");\fR
+.fi
+.PP
+.PP
+It is also possible to push events onto the event queue and so use it as a two-way communication path\&. Both \fI\fBSDL_PushEvent\fP\fR and \fI\fBSDL_PeepEvents\fP\fR allow you to place events onto the event queue\&. This is usually used to place a \fBSDL_USEREVENT\fP on the event queue, however you could use it to post fake input events if you wished\&. Creating your own events is a simple matter of choosing the event type you want, setting the \fBtype\fR member and filling the appropriate member structure with information\&. 
+.PP
+.nf
+\f(CWSDL_Event user_event;
+
+user_event\&.type=SDL_USEREVENT;
+user_event\&.user\&.code=2;
+user_event\&.user\&.data1=NULL;
+user_event\&.user\&.data2=NULL;
+SDL_PushEvent(&user_event);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PollEvent\fP\fR, \fI\fBSDL_PushEvent\fP\fR, \fI\fBSDL_PeepEvents\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_EventState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+.TH "SDL_EventState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_EventState\- This function allows you to set the state of processing certain events\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_EventState\fP\fR(\fBUint8 type, int state\fR);
+.SH "DESCRIPTION"
+.PP
+This function allows you to set the state of processing certain event \fBtype\fR\&'s\&.
+.PP
+If \fBstate\fR is set to \fBSDL_IGNORE\fP, that event \fBtype\fR will be automatically dropped from the event queue and will not be filtered\&.
+.PP
+If \fBstate\fR is set to \fBSDL_ENABLE\fP, that event \fBtype\fR will be processed normally\&.
+.PP
+If \fBstate\fR is set to \fBSDL_QUERY\fP, \fBSDL_EventState\fP will return the current processing state of the specified event \fBtype\fR\&.
+.PP
+A list of event \fBtype\fR\&'s can be found in the \fI\fBSDL_Event\fR\fR section\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_FillRect.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_FillRect" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FillRect\- This function performs a fast fill of the given rectangle with some color
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_FillRect\fP\fR(\fBSDL_Surface *dst, SDL_Rect *dstrect, Uint32 color\fR);
+.SH "DESCRIPTION"
+.PP
+This function performs a fast fill of the given rectangle with \fBcolor\fR\&. If \fBdstrect\fR is \fBNULL\fP, the whole surface will be filled with \fBcolor\fR\&.
+.PP
+The color should be a pixel of the format used by the surface, and can be generated by the \fISDL_MapRGB\fR function\&.
+.PP
+If there is a clip rectangle set on the destination (set via \fISDL_SetClipRect\fR) then this function will clip based on the intersection of the clip rectangle and the \fBdstrect\fR rectangle\&.
+.SH "RETURN VALUE"
+.PP
+This function returns \fB0\fR on success, or \fB-1\fR on error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_MapRGB\fP\fR, \fI\fBSDL_BlitSurface\fP\fR, \fI\fBSDL_Rect\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Flip.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+.TH "SDL_Flip" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Flip\- Swaps screen buffers
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_Flip\fP\fR(\fBSDL_Surface *screen\fR);
+.SH "DESCRIPTION"
+.PP
+On hardware that supports double-buffering, this function sets up a flip and returns\&. The hardware will wait for vertical retrace, and then swap video buffers before the next video surface blit or lock will return\&. On hardware that doesn\&'t support double-buffering, this is equivalent to calling \fISDL_UpdateRect\fR\fB(screen, 0, 0, 0, 0)\fR
+.PP
+The \fBSDL_DOUBLEBUF\fP flag must have been passed to \fISDL_SetVideoMode\fR, when setting the video mode for this function to perform hardware flipping\&.
+.SH "RETURN VALUE"
+.PP
+This function returns \fB0\fR if successful, or \fB-1\fR if there was an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_UpdateRect\fP\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_FreeCursor.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_FreeCursor" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FreeCursor\- Frees a cursor created with SDL_CreateCursor\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_FreeCursor\fP\fR(\fBSDL_Cursor *cursor\fR);
+.SH "DESCRIPTION"
+.PP
+Frees a \fBSDL_Cursor\fR that was created using \fISDL_CreateCursor\fR\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_CreateCursor\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_FreeSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_FreeSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FreeSurface\- Frees (deletes) and SDL_Surface
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_FreeSurface\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+Frees the resources used by a previously created \fBSDL_Surface\fR\&. If the surface was created using \fISDL_CreateRGBSurfaceFrom\fR then the pixel data is not freed\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateRGBSurface\fP\fR \fI\fBSDL_CreateRGBSurfaceFrom\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_FreeWAV.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_FreeWAV" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FreeWAV\- Frees previously opened WAV data
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_FreeWAV\fP\fR(\fBUint8 *audio_buf\fR);
+.SH "DESCRIPTION"
+.PP
+After a WAVE file has been opened with \fI\fBSDL_LoadWAV\fP\fR its data can eventually be freed with \fBSDL_FreeWAV\fP\&. \fBaudio_buf\fR is a pointer to the buffer created by \fBSDL_LoadWAV\fP\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_LoadWAV\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_FreeYUVOverlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_FreeYUVOverlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FreeYUVOverlay\- Free a YUV video overlay
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_FreeYUVOverlay\fP\fR(\fBSDL_Overlay *overlay\fR);
+.SH "DESCRIPTION"
+.PP
+Frees and \fI\fBoverlay\fR\fR created by \fI\fBSDL_CreateYUVOverlay\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Overlay\fR\fR, \fI\fBSDL_DisplayYUVOverlay\fP\fR, \fI\fBSDL_FreeYUVOverlay\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GL_GetAttribute.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_GL_GetAttribute" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GL_GetAttribute\- Get the value of a special SDL/OpenGL attribute
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_GL_GetAttribute\fP\fR(\fBSDLGLattr attr, int *value\fR);
+.SH "DESCRIPTION"
+.PP
+Places the value of the SDL/OpenGL \fIattribute\fR \fBattr\fR into \fBvalue\fR\&. This is useful after a call to \fI\fBSDL_SetVideoMode\fP\fR to check whether your attributes have been \fIset\fR as you expected\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GL_SetAttribute\fP\fR, \fIGL Attributes\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GL_GetProcAddress.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+.TH "SDL_GL_GetProcAddress" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GL_GetProcAddress\- Get the address of a GL function
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid *\fBSDL_GL_GetProcAddress\fP\fR(\fBconst char* proc\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the address of the GL function \fBproc\fR, or \fBNULL\fR if the function is not found\&. If the GL library is loaded at runtime, with \fI\fBSDL_GL_LoadLibrary\fP\fR, then \fIall\fP GL functions must be retrieved this way\&. Usually this is used to retrieve function pointers to OpenGL extensions\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWtypedef void (*GL_ActiveTextureARB_Func)(unsigned int);
+GL_ActiveTextureARB_Func glActiveTextureARB_ptr = 0;
+int has_multitexture=1;
+\&.
+\&.
+\&.
+/* Get function pointer */
+glActiveTextureARB_ptr=(GL_ActiveTextureARB_Func) SDL_GL_GetProcAddress("glActiveTextureARB");
+
+/* Check for a valid function ptr */
+if(!glActiveTextureARB_ptr){
+  fprintf(stderr, "Multitexture Extensions not present\&.
+");
+  has_multitexture=0;
+}
+\&.
+\&.
+\&.
+\&.
+if(has_multitexture){
+  glActiveTextureARB_ptr(GL_TEXTURE0_ARB);
+  \&.
+  \&.
+}
+else{
+  \&.
+  \&.
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GL_LoadLibrary\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GL_LoadLibrary.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GL_LoadLibrary" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GL_LoadLibrary\- Specify an OpenGL library
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_GL_LoadLibrary\fP\fR(\fBconst char *path\fR);
+.SH "DESCRIPTION"
+.PP
+If you wish, you may load the OpenGL library at runtime, this must be done before \fI\fBSDL_SetVideoMode\fP\fR is called\&. The \fBpath\fR of the GL library is passed to \fBSDL_GL_LoadLibrary\fP and it returns \fB0\fR on success, or \fB-1\fR on an error\&. You must then use \fI\fBSDL_GL_GetProcAddress\fP\fR to retrieve function pointers to GL functions\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GL_GetProcAddress\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GL_SetAttribute.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+.TH "SDL_GL_SetAttribute" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GL_SetAttribute\- Set a special SDL/OpenGL attribute
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_GL_SetAttribute\fP\fR(\fBSDL_GLattr attr, int value\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the OpenGL \fIattribute\fR \fBattr\fR to \fBvalue\fR\&. The attributes you set don\&'t take effect until after a call to \fI\fBSDL_SetVideoMode\fP\fR\&. You should use \fI\fBSDL_GL_GetAttribute\fP\fR to check the values after a \fBSDL_SetVideoMode\fP call\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on error\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
+SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+if ( (screen=SDL_SetVideoMode( 640, 480, 16, SDL_OPENGL )) == NULL ) {
+  fprintf(stderr, "Couldn\&'t set GL mode: %s
+", SDL_GetError());
+  SDL_Quit();
+  return;
+}\fR
+.fi
+.PP
+.PP
+.RS
+\fBNote:  
+.PP
+The \fBSDL_DOUBLEBUF\fP flag is not required to enable double buffering when setting an OpenGL video mode\&. Double buffering is enabled or disabled using the SDL_GL_DOUBLEBUFFER attribute\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GL_GetAttribute\fP\fR, \fIGL Attributes\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GL_SwapBuffers.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GL_SwapBuffers" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GL_SwapBuffers\- Swap OpenGL framebuffers/Update Display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_GL_SwapBuffers\fP\fR(\fBvoid \fR);
+.SH "DESCRIPTION"
+.PP
+Swap the OpenGL buffers, if double-buffering is supported\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_GL_SetAttribute\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GLattr.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,47 @@
+.TH "SDL_GLattr" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GLattr\- SDL GL Attributes
+.SH "ATTRIBUTES"
+.TP 20
+\fBSDL_GL_RED_SIZE\fP
+Size of the framebuffer red component, in bits
+.TP 20
+\fBSDL_GL_GREEN_SIZE\fP
+Size of the framebuffer green component, in bits
+.TP 20
+\fBSDL_GL_BLUE_SIZE\fP
+Size of the framebuffer blue component, in bits
+.TP 20
+\fBSDL_GL_ALPHA_SIZE\fP
+Size of the framebuffer alpha component, in bits
+.TP 20
+\fBSDL_GL_DOUBLEBUFFER\fP
+0 or 1, enable or disable double buffering
+.TP 20
+\fBSDL_GL_BUFFER_SIZE\fP
+Size of the framebuffer, in bits
+.TP 20
+\fBSDL_GL_DEPTH_SIZE\fP
+Size of the depth buffer, in bits
+.TP 20
+\fBSDL_GL_STENCIL_SIZE\fP
+Size of the stencil buffer, in bits
+.TP 20
+\fBSDL_GL_ACCUM_RED_SIZE\fP
+Size of the accumulation buffer red component, in bits
+.TP 20
+\fBSDL_GL_ACCUM_GREEN_SIZE\fP
+Size of the accumulation buffer green component, in bits
+.TP 20
+\fBSDL_GL_ACCUM_BLUE_SIZE\fP
+Size of the accumulation buffer blue component, in bits
+.TP 20
+\fBSDL_GL_ACCUM_ALPHA_SIZE\fP
+Size of the accumulation buffer alpha component, in bits
+.SH "DESCRIPTION"
+.PP
+While you can set most OpenGL attributes normally, the attributes list above must be known \fIbefore\fP SDL sets the video mode\&. These attributes a set and read with \fI\fBSDL_GL_SetAttribute\fP\fR and \fI\fBSDL_GL_GetAttribute\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GL_SetAttribute\fP\fR, \fI\fBSDL_GL_GetAttribute\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetAppState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,24 @@
+.TH "SDL_GetAppState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+\fBSDL_GetAppState\fP\- Get the state of the application
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_GetAppState\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+This function returns the current state of the application\&. The value returned is a bitwise combination of:
+.TP 20
+\fBSDL_APPMOUSEFOCUS\fP
+The application has mouse focus\&.
+.TP 20
+\fBSDL_APPINPUTFOCUS\fP
+The application has keyboard focus
+.TP 20
+\fBSDL_APPACTIVE\fP
+The application is visible
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_ActiveEvent\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetAudioStatus.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,24 @@
+.TH "SDL_GetAudioStatus" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetAudioStatus\- Get the current audio state
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_audiostatus\fBSDL_GetAudioStatus\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+.nf
+\f(CWtypedef enum{
+  SDL_AUDIO_STOPPED,
+  SDL_AUDIO_PAUSED,
+  SDL_AUDIO_PLAYING
+} SDL_audiostatus;\fR
+.fi
+.PP
+.PP
+Returns either \fBSDL_AUDIO_STOPPED\fP, \fBSDL_AUDIO_PAUSED\fP or \fBSDL_AUDIO_PLAYING\fP depending on the current audio state\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PauseAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetClipRect.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_GetClipRect" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetClipRect\- Gets the clipping rectangle for a surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_GetClipRect\fP\fR(\fBSDL_Surface *surface, SDL_Rect *rect\fR);
+.SH "DESCRIPTION"
+.PP
+Gets the clipping rectangle for a surface\&. When this surface is the destination of a blit, only the area within the clip rectangle is drawn into\&.
+.PP
+The rectangle pointed to by \fBrect\fR will be filled with the clipping rectangle of the surface\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetClipRect\fP\fR, \fI\fBSDL_BlitSurface\fP\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetCursor.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetCursor" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetCursor\- Get the currently active mouse cursor\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Cursor *\fBSDL_GetCursor\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the currently active mouse cursor\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetCursor\fP\fR, \fI\fBSDL_CreateCursor\fP\fR, \fI\fBSDL_ShowCursor\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetEventFilter.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+.TH "SDL_GetEventFilter" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetEventFilter\- Retrieves a pointer to he event filter
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_EventFilter \fBSDL_GetEventFilter\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+This function retrieces a pointer to the event filter that was previously set using \fI\fBSDL_SetEventFilter\fP\fR\&. An SDL_EventFilter function is defined as: 
+.PP
+.nf
+\f(CWtypedef int (*SDL_EventFilter)(const SDL_Event *event);\fR
+.fi
+.PP
+.SH "RETURN VALUE"
+.PP
+Returns a pointer to the event filter or \fBNULL\fP if no filter has been set\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_SetEventFilter\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetGamma.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,21 @@
+.TH "SDL_GetGamma" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetGamma\- Gets the gamma of the display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_GetGamma\fP\fR(\fBfloat *red, float *green, float *blue\fR);
+.SH "DESCRIPTION"
+.PP
+Gets the color gamma of the display\&. The gamma value for each color component will be place in the parameters \fBred\fR, \fBgreen\fR and \fBblue\fR\&. The values can range from 0\&.1 to 10\&.
+.PP
+.RS
+\fBNote:  
+.PP
+This function currently only works on XFreee 4\&.0 and up\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetGamma\fP\fR, \fI\fBSDL_SetVideoMode\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetGammaRamp.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+.TH "SDL_GetGammaRamp" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetGammaRamp\- Gets the color gamma lookup tables for the display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_GetGammaRamp\fP\fR(\fBUint16 *redtable, Uint16 *greentable, Uint16 *bluetable\fR);
+.SH "DESCRIPTION"
+.PP
+Gets the gamma translation lookup tables currently used by the display\&. Each table is an array of 256 Uint16 values\&.
+.PP
+Not all display hardware is able to change gamma\&.
+.SH "RETURN VALUE"
+.PP
+Returns -1 on error\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_SetGamma\fR \fISDL_SetGammaRamp\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetKeyName.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetKeyName" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetKeyName\- Get the name of an SDL virtual keysym
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBchar *\fBSDL_GetKeyName\fP\fR(\fBSDLKey key\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the SDL-defined name of the \fI\fBSDLKey\fR\fR \fBkey\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDLKey\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetKeyState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+.TH "SDL_GetKeyState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetKeyState\- Get a snapshot of the current keyboard state
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 *\fBSDL_GetKeyState\fP\fR(\fBint *numkeys\fR);
+.SH "DESCRIPTION"
+.PP
+Gets a snapshot of the current keyboard state\&. The current state is return as a pointer to an array, the size of this array is stored in \fBnumkeys\fR\&. The array is indexed by the \fI\fBSDLK_*\fP\fR symbols\&. A value of 1 means the key is pressed and a value of 0 means its not\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Use \fI\fBSDL_PumpEvents\fP\fR to update the state array\&.
+.RE
+.SH "EXAMPLE"
+.PP
+.PP
+.nf
+\f(CWUint8 *keystate = SDL_GetKeyState(NULL);
+if ( keystate[SDLK_RETURN] ) printf("Return Key Pressed\&.
+");\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL Key Symbols\fP\fR, \fI\fBSDL_PumpEvents\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetModState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,54 @@
+.TH "SDL_GetModState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetModState\- Get the state of modifier keys\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDLMod \fBSDL_GetModState\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the current of the modifier keys (CTRL, ALT, etc\&.)\&.
+.SH "RETURN VALUE"
+.PP
+The return value can be an OR\&'d combination of the SDLMod enum\&.
+.PP
+.PP
+.RS
+\fBSDLMod\fR
+.PP
+.PP
+.nf
+\f(CWtypedef enum {
+  KMOD_NONE  = 0x0000,
+  KMOD_LSHIFT= 0x0001,
+  KMOD_RSHIFT= 0x0002,
+  KMOD_LCTRL = 0x0040,
+  KMOD_RCTRL = 0x0080,
+  KMOD_LALT  = 0x0100,
+  KMOD_RALT  = 0x0200,
+  KMOD_LMETA = 0x0400,
+  KMOD_RMETA = 0x0800,
+  KMOD_NUM   = 0x1000,
+  KMOD_CAPS  = 0x2000,
+  KMOD_MODE  = 0x4000,
+} SDLMod;\fR
+.fi
+.PP
+.RE
+ SDL also defines the following symbols for convenience: 
+.PP
+.RS
+.PP
+.nf
+\f(CW#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
+#define KMOD_SHIFT  (KMOD_LSHIFT|KMOD_RSHIFT)
+#define KMOD_ALT  (KMOD_LALT|KMOD_RALT)
+#define KMOD_META (KMOD_LMETA|KMOD_RMETA)\fR
+.fi
+.PP
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetKeyState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetMouseState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,24 @@
+.TH "SDL_GetMouseState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetMouseState\- Retrieve the current state of the mouse
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_GetMouseState\fP\fR(\fBint *x, int *y\fR);
+.SH "DESCRIPTION"
+.PP
+The current button state is returned as a button bitmask, which can be tested using the \fBSDL_BUTTON(X)\fP macros, and \fBx\fR and \fBy\fR are set to the current mouse cursor position\&. You can pass \fBNULL\fP for either \fBx\fR or \fBy\fR\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_PumpEvents();
+if(SDL_GetMouseState(NULL, NULL)&SDL_BUTTON(1))
+  printf("Mouse Button 1(left) is pressed\&.
+");\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetRelativeMouseState\fP\fR, \fI\fBSDL_PumpEvents\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetRGB.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_GetRGB" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetRGB\- Get RGB values from a pixel in the specified pixel format\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_GetRGB\fP\fR(\fBUint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b\fR);
+.SH "DESCRIPTION"
+.PP
+Get RGB component values from a pixel stored in the specified pixel format\&.
+.PP
+This function uses the entire 8-bit [0\&.\&.255] range when converting color components from pixel formats with less than 8-bits per RGB component (e\&.g\&., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8])\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetRGBA\fP\fR, \fI\fBSDL_MapRGB\fP\fR, \fI\fBSDL_MapRGBA\fP\fR, \fI\fBSDL_PixelFormat\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetRGBA.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+.TH "SDL_GetRGBA" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetRGBA\- Get RGBA values from a pixel in the specified pixel format\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_GetRGBA\fP\fR(\fBUint32 pixel, SDL_PixelFormat *fmt, Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a\fR);
+.SH "DESCRIPTION"
+.PP
+Get RGBA component values from a pixel stored in the specified pixel format\&.
+.PP
+This function uses the entire 8-bit [0\&.\&.255] range when converting color components from pixel formats with less than 8-bits per RGB component (e\&.g\&., a completely white pixel in 16-bit RGB565 format would return [0xff, 0xff, 0xff] not [0xf8, 0xfc, 0xf8])\&.
+.PP
+If the surface has no alpha component, the alpha will be returned as 0xff (100% opaque)\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_GetRGB\fR, \fISDL_MapRGB\fR, \fISDL_MapRGBA\fR, \fISDL_PixelFormat\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetRelativeMouseState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetRelativeMouseState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetRelativeMouseState\- Retrieve the current state of the mouse
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_GetRelativeMouseState\fP\fR(\fBint *x, int *y\fR);
+.SH "DESCRIPTION"
+.PP
+The current button state is returned as a button bitmask, which can be tested using the \fBSDL_BUTTON(X)\fP macros, and \fBx\fR and \fBy\fR are set to the change in the mouse position since the last call to \fBSDL_GetRelativeMouseState\fP or since event initialization\&. You can pass \fBNULL\fP for either \fBx\fR or \fBy\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetMouseState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetThreadID.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_GetThreadID" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetThreadID\- Get the SDL thread ID of a SDL_Thread
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBUint32 \fBSDL_GetThreadID\fP\fR(\fBSDL_Thread *thread\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the ID of a \fBSDL_Thread\fR created by \fISDL_CreateThread\fR\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_CreateThread\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetTicks.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetTicks" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetTicks\- Get the number of milliseconds since the SDL library initialization\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint32 \fBSDL_GetTicks\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+Get the number of milliseconds since the SDL library initialization\&. Note that this value wraps if the program runs for more than ~49 days\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Delay\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetVideoInfo.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetVideoInfo" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetVideoInfo\- returns a pointer to information about the video hardware
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_VideoInfo *\fBSDL_GetVideoInfo\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+This function returns a read-only pointer to \fIinformation\fR about the video hardware\&. If this is called before \fISDL_SetVideoMode\fR, the \fBvfmt\fR member of the returned structure will contain the pixel format of the "best" video mode\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_VideoInfo\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_GetVideoSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_GetVideoSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_GetVideoSurface\- returns a pointer to the current display surface
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_GetVideoSurface\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+This function returns a pointer to the current display surface\&. If SDL is doing format conversion on the display surface, this function returns the publicly visible surface, not the real video surface\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Init.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+.TH "SDL_Init" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Init\- Initializes SDL
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_Init\fP\fR(\fBUint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+Initializes SDL\&. This should be called before all other SDL functions\&. The \fBflags\fR parameter specifies what part(s) of SDL to initialize\&.
+.TP 20
+\fBSDL_INIT_TIMER\fP
+Initializes the \fItimer\fR subsystem\&.
+.TP 20
+\fBSDL_INIT_AUDIO\fP
+Initializes the \fIaudio\fR subsystem\&.
+.TP 20
+\fBSDL_INIT_VIDEO\fP
+Initializes the \fIvideo\fR subsystem\&.
+.TP 20
+\fBSDL_INIT_CDROM\fP
+Initializes the \fIcdrom\fR subsystem\&.
+.TP 20
+\fBSDL_INIT_JOYSTICK\fP
+Initializes the \fIjoystick\fR subsystem\&.
+.TP 20
+\fBSDL_INIT_EVERYTHING\fP
+Initialize all of the above\&.
+.TP 20
+\fBSDL_INIT_NOPARACHUTE\fP
+Prevents SDL from catching fatal signals\&.
+.TP 20
+\fBSDL_INIT_EVENTTHREAD\fP
+.SH "RETURN VALUE"
+.PP
+Returns \fB-1\fR on an error or \fB0\fR on success\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Quit\fP\fR, \fI\fBSDL_InitSubSystem\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_InitSubSystem.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+.TH "SDL_InitSubSystem" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_InitSubSystem\- Initialize subsystems
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_InitSubSystem\fP\fR(\fBUint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+After SDL has been initialized with \fI\fBSDL_Init\fP\fR you may initialize uninitialized subsystems with \fBSDL_InitSubSystem\fP\&. The \fBflags\fR parameter is the same as that used in \fI\fBSDL_Init\fP\fR\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CW/* Seperating Joystick and Video initialization\&. */
+SDL_Init(SDL_INIT_VIDEO);
+\&.
+\&.
+SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF|SDL_FULLSCREEN);
+\&.
+/* Do Some Video stuff */
+\&.
+\&.
+/* Initialize the joystick subsystem */
+SDL_InitSubSystem(SDL_INIT_JOYSTICK);
+
+/* Do some stuff with video and joystick */
+\&.
+\&.
+\&.
+/* Shut them both down */
+SDL_Quit();\fR
+.fi
+.PP
+.SH "RETURN VALUE"
+.PP
+Returns \fB-1\fR on an error or \fB0\fR on success\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Init\fP\fR, \fI\fBSDL_Quit\fP\fR, \fI\fBSDL_QuitSubSystem\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoyAxisEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+.TH "SDL_JoyAxisEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoyAxisEvent\- Joystick axis motion event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 axis;
+  Sint16 value;
+} SDL_JoyAxisEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_JOYAXISMOTION\fP
+.TP 20
+\fBwhich\fR
+Joystick device index
+.TP 20
+\fBaxis\fR
+Joystick axis index
+.TP 20
+\fBvalue\fR
+Axis value (range: -32768 to 32767)
+.SH "DESCRIPTION"
+.PP
+\fBSDL_JoyAxisEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_JOYAXISMOTION\fP is reported\&.
+.PP
+A \fBSDL_JOYAXISMOTION\fP event occurs when ever a user moves an axis on the joystick\&. The field \fBwhich\fR is the index of the joystick that reported the event and \fBaxis\fR is the index of the axis (for a more detailed explaination see the \fIJoystick section\fR)\&. \fBvalue\fR is the current position of the axis\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fIJoystick Functions\fR, \fI\fBSDL_JoystickEventState\fP\fR, \fI\fBSDL_JoystickGetAxis\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoyBallEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+.TH "SDL_JoyBallEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoyBallEvent\- Joystick trackball motion event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 ball;
+  Sint16 xrel, yrel;
+} SDL_JoyBallEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_JOYBALLMOTION\fP
+.TP 20
+\fBwhich\fR
+Joystick device index
+.TP 20
+\fBball\fR
+Joystick trackball index
+.TP 20
+\fBxrel\fR, \fByrel\fR
+The relative motion in the X/Y direction
+.SH "DESCRIPTION"
+.PP
+\fBSDL_JoyBallEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_JOYBALLMOTION\fP is reported\&.
+.PP
+A \fBSDL_JOYBALLMOTION\fP event occurs when a user moves a trackball on the joystick\&. The field \fBwhich\fR is the index of the joystick that reported the event and \fBball\fR is the index of the trackball (for a more detailed explaination see the \fIJoystick section\fR)\&. Trackballs only return relative motion, this is the change in position on the ball since it was last polled (last cycle of the event loop) and it is stored in \fBxrel\fR and \fByrel\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fIJoystick Functions\fR, \fI\fBSDL_JoystickEventState\fP\fR, \fI\fBSDL_JoystickGetBall\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoyButtonEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+.TH "SDL_JoyButtonEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoyButtonEvent\- Joystick button event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 button;
+  Uint8 state;
+} SDL_JoyButtonEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_JOYBUTTONDOWN\fP or \fBSDL_JOYBUTTONUP\fP
+.TP 20
+\fBwhich\fR
+Joystick device index
+.TP 20
+\fBbutton\fR
+Joystick button index
+.TP 20
+\fBstate\fR
+\fBSDL_PRESSED\fP or \fBSDL_RELEASED\fP
+.SH "DESCRIPTION"
+.PP
+\fBSDL_JoyButtonEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_JOYBUTTONDOWN\fP or \fBSDL_JOYBUTTONUP\fP is reported\&.
+.PP
+A \fBSDL_JOYBUTTONDOWN\fP or \fBSDL_JOYBUTTONUP\fP event occurs when ever a user presses or releases a button on a joystick\&. The field \fBwhich\fR is the index of the joystick that reported the event and \fBbutton\fR is the index of the button (for a more detailed explaination see the \fIJoystick section\fR)\&. \fBstate\fR is the current state or the button which is either \fBSDL_PRESSED\fP or \fBSDL_RELEASED\fP\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fIJoystick Functions\fR, \fI\fBSDL_JoystickEventState\fP\fR, \fI\fBSDL_JoystickGetButton\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoyHatEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,56 @@
+.TH "SDL_JoyHatEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoyHatEvent\- Joystick hat position change event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 which;
+  Uint8 hat;
+  Uint8 value;
+} SDL_JoyHatEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_JOY\fP
+.TP 20
+\fBwhich\fR
+Joystick device index
+.TP 20
+\fBhat\fR
+Joystick hat index
+.TP 20
+\fBvalue\fR
+Hat position
+.SH "DESCRIPTION"
+.PP
+\fBSDL_JoyHatEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_JOYHATMOTION\fP is reported\&.
+.PP
+A \fBSDL_JOYHATMOTION\fP event occurs when ever a user moves a hat on the joystick\&. The field \fBwhich\fR is the index of the joystick that reported the event and \fBhat\fR is the index of the hat (for a more detailed exlaination see the \fIJoystick section\fR)\&. \fBvalue\fR is the current position of the hat\&. It is a logically OR\&'d combination of the following values (whose meanings should be pretty obvious:) :
+.IP "" 10
+\fBSDL_HAT_CENTERED\fP
+.IP "" 10
+\fBSDL_HAT_UP\fP
+.IP "" 10
+\fBSDL_HAT_RIGHT\fP
+.IP "" 10
+\fBSDL_HAT_DOWN\fP
+.IP "" 10
+\fBSDL_HAT_LEFT\fP
+.PP
+The following defines are also provided:
+.IP "" 10
+\fBSDL_HAT_RIGHTUP\fP
+.IP "" 10
+\fBSDL_HAT_RIGHTDOWN\fP
+.IP "" 10
+\fBSDL_HAT_LEFTUP\fP
+.IP "" 10
+\fBSDL_HAT_LEFTDOWN\fP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fIJoystick Functions\fR, \fI\fBSDL_JoystickEventState\fP\fR, \fI\fBSDL_JoystickGetHat\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickClose.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_JoystickClose" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickClose\- Closes a previously opened joystick
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_JoystickClose\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Close a \fBjoystick\fR that was previously opened with \fI\fBSDL_JoystickOpen\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickOpen\fP\fR, \fI\fBSDL_JoystickOpened\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickEventState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,24 @@
+.TH "SDL_JoystickEventState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickEventState\- Enable/disable joystick event polling
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickEventState\fP\fR(\fBint state\fR);
+.SH "DESCRIPTION"
+.PP
+This function is used to enable or disable joystick event processing\&. With joystick event processing disabled you will have to update joystick states with \fI\fBSDL_JoystickUpdate\fP\fR and read the joystick information manually\&. \fBstate\fR is either \fBSDL_QUERY\fP, \fBSDL_ENABLE\fP or \fBSDL_IGNORE\fP\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Joystick event handling is prefered
+.RE
+.SH "RETURN VALUE"
+.PP
+If \fBstate\fR is \fBSDL_QUERY\fP then the current state is returned, otherwise the new processing \fBstate\fR is returned\&.
+.SH "SEE ALSO"
+.PP
+\fISDL Joystick Functions\fR, \fI\fBSDL_JoystickUpdate\fP\fR, \fI\fBSDL_JoyAxisEvent\fR\fR, \fI\fBSDL_JoyBallEvent\fR\fR, \fI\fBSDL_JoyButtonEvent\fR\fR, \fI\fBSDL_JoyHatEvent\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickGetAxis.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+.TH "SDL_JoystickGetAxis" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickGetAxis\- Get the current state of an axis
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSint16 \fBSDL_JoystickGetAxis\fP\fR(\fBSDL_Joystick *joystick, int axis\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_JoystickGetAxis\fP returns the current state of the given \fBaxis\fR on the given \fBjoystick\fR\&.
+.PP
+On most modern joysticks the X axis is usually represented by \fBaxis\fR 0 and the Y axis by \fBaxis\fR 1\&. The value returned by \fBSDL_JoystickGetAxis\fP is a signed integer (-32768 to 32768) representing the current position of the \fBaxis\fR, it maybe necessary to impose certain tolerances on these values to account for jitter\&. It is worth noting that some joysticks use axes 2 and 3 for extra buttons\&.
+.SH "RETURN VALUE"
+.PP
+Returns a 16-bit signed integer representing the current position of the \fBaxis\fR\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSint16 x_move, y_move;
+SDL_Joystick *joy1;
+\&.
+\&.
+x_move=SDL_JoystickGetAxis(joy1, 0);
+y_move=SDL_JoystickGetAxis(joy1, 1);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickNumAxes\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickGetBall.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+.TH "SDL_JoystickGetBall" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickGetBall\- Get relative trackball motion
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickGetBall\fP\fR(\fBSDL_Joystick *joystick, int ball, int *dx, int *dy\fR);
+.SH "DESCRIPTION"
+.PP
+Get the \fBball\fR axis change\&.
+.PP
+Trackballs can only return relative motion since the last call to \fBSDL_JoystickGetBall\fP, these motion deltas a placed into \fBdx\fR and \fBdy\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success or \fB-1\fR on failure
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWint delta_x, delta_y;
+SDL_Joystick *joy;
+\&.
+\&.
+\&.
+SDL_JoystickUpdate();
+if(SDL_JoystickGetBall(joy, 0, &delta_x, &delta_y)==-1)
+  printf("TrackBall Read Error!
+");
+printf("Trackball Delta- X:%d, Y:%d
+", delta_x, delta_y);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickNumBalls\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickGetButton.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickGetButton" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickGetButton\- Get the current state of a given button on a given joystick
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_JoystickGetButton\fP\fR(\fBSDL_Joystick *joystick, int button\fR);
+.SH "DESCRIPTION"
+.PP
+SDL_JoystickGetButton returns the current state of the given \fBbutton\fR on the given \fBjoystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+\fB1\fR if the button is pressed\&. Otherwise, \fB0\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickNumButtons\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickGetHat.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+.TH "SDL_JoystickGetHat" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickGetHat\- Get the current state of a joystick hat
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint8 \fBSDL_JoystickGetHat\fP\fR(\fBSDL_Joystick *joystick, int hat\fR);
+.SH "DESCRIPTION"
+.PP
+SDL_JoystickGetHat returns the current state of the given \fBhat\fR on the given \fBjoystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+The current state is returned as a Uint8 which is defined as an OR\&'d combination of one or more of the following
+.IP "" 10
+\fBSDL_HAT_CENTERED\fP
+.IP "" 10
+\fBSDL_HAT_UP\fP
+.IP "" 10
+\fBSDL_HAT_RIGHT\fP
+.IP "" 10
+\fBSDL_HAT_DOWN\fP
+.IP "" 10
+\fBSDL_HAT_LEFT\fP
+.IP "" 10
+\fBSDL_HAT_RIGHTUP\fP
+.IP "" 10
+\fBSDL_HAT_RIGHTDOWN\fP
+.IP "" 10
+\fBSDL_HAT_LEFTUP\fP
+.IP "" 10
+\fBSDL_HAT_LEFTDOWN\fP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickNumHats\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickIndex.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickIndex" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickIndex\- Get the index of an SDL_Joystick\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickIndex\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Returns the index of a given \fBSDL_Joystick\fR structure\&.
+.SH "RETURN VALUE"
+.PP
+Index number of the joystick\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickName.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+.TH "SDL_JoystickName" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickName\- Get joystick name\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBconst char *\fBSDL_JoystickName\fP\fR(\fBint index\fR);
+.SH "DESCRIPTION"
+.PP
+Get the implementation dependent name of joystick\&. The \fBindex\fR parameter refers to the N\&'th joystick on the system\&.
+.SH "RETURN VALUE"
+.PP
+Returns a char pointer to the joystick name\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CW/* Print the names of all attached joysticks */
+int num_joy, i;
+num_joy=SDL_NumJoysticks();
+printf("%d joysticks found
+", num_joy);
+for(i=0;i<num_joy;i++)
+  printf("%s
+", SDL_JoystickName(i);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickNumAxes.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickNumAxes" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickNumAxes\- Get the number of joystick axes
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickNumAxes\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Return the number of axes available from a previously opened \fBSDL_Joystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+Number of axes\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickGetAxis\fP\fR, \fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickNumBalls.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickNumBalls" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickNumBalls\- Get the number of joystick trackballs
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickNumBalls\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Return the number of trackballs available from a previously opened \fBSDL_Joystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+Number of trackballs\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickGetBall\fP\fR, \fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickNumButtons.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickNumButtons" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickNumButtons\- Get the number of joysitck buttons
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickNumButtons\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Return the number of buttons available from a previously opened \fBSDL_Joystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+Number of buttons\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickGetButton\fP\fR, \fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickNumHats.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickNumHats" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickNumHats\- Get the number of joystick hats
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickNumHats\fP\fR(\fBSDL_Joystick *joystick\fR);
+.SH "DESCRIPTION"
+.PP
+Return the number of hats available from a previously opened \fBSDL_Joystick\fR\&.
+.SH "RETURN VALUE"
+.PP
+Number of hats\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickGetHat\fP\fR, \fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickOpen.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,51 @@
+.TH "SDL_JoystickOpen" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickOpen\- Opens a joystick for use\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Joystick *\fBSDL_JoystickOpen\fP\fR(\fBint index\fR);
+.SH "DESCRIPTION"
+.PP
+Opens a joystick for use within SDL\&. The \fBindex\fR refers to the N\&'th joystick in the system\&. A joystick must be opened before it game be used\&.
+.SH "RETURN VALUE"
+.PP
+Returns a \fBSDL_Joystick\fR structure on success\&. \fBNULL\fR on failure\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_Joystick *joy;
+// Check for joystick
+if(SDL_NumJoysticks()>0){
+  // Open joystick
+  joy=SDL_JoystickOpen(0);
+  
+  if(joy)
+  {
+    printf("Opened Joystick 0
+");
+    printf("Name: %s
+", SDL_JoystickName(0));
+    printf("Number of Axes: %s
+", SDL_JoystickNumAxes(joy));
+    printf("Number of Buttons: %s
+", SDL_JoystickNumButtons(joy));
+    printf("Number of Balls: %s
+", SDL_JoystickNumBalls(joy));
+  }
+  else
+    printf("Couldn\&'t open Joystick 0
+");
+  
+  // Close if opened
+  if(SDL_JoystickOpened(0))
+    SDL_JoystickClose(joy);
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickClose\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickOpened.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_JoystickOpened" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickOpened\- Determine if a joystick has been opened
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_JoystickOpened\fP\fR(\fBint index\fR);
+.SH "DESCRIPTION"
+.PP
+Determines whether a joystick has already been opened within the application\&. \fBindex\fR refers to the N\&'th joystick on the system\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB1\fR if the joystick has been opened, or \fB0\fR if it has not\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickOpen\fP\fR, \fI\fBSDL_JoystickClose\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_JoystickUpdate.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_JoystickUpdate" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_JoystickUpdate\- Updates the state of all joysticks
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_JoystickUpdate\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Updates the state(position, buttons, etc\&.) of all open joysticks\&. If joystick events have been enabled with \fI\fBSDL_JoystickEventState\fP\fR then this is called automatically in the event loop\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickEventState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_KeyboardEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+.TH "SDL_KeyboardEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_KeyboardEvent\- Keyboard event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 state;
+  SDL_keysym keysym;
+} SDL_KeyboardEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_KEYDOWN\fP or \fBSDL_KEYUP\fP
+.TP 20
+\fBstate\fR
+\fBSDL_PRESSED\fP or \fBSDL_RELEASED\fP
+.TP 20
+\fBkeysym\fR
+Contains key press information
+.SH "DESCRIPTION"
+.PP
+\fBSDL_KeyboardEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_KEYDOWN\fP or \fBSDL_KEYUP\fP is reported\&.
+.PP
+The \fBtype\fR and \fBstate\fR actually report the same information, they just use different values to do it! A keyboard event occurs when a key is released (\fBtype\fR=\fBSDK_KEYUP\fP or \fBstate\fR=\fBSDL_RELEASED\fP) and when a key is pressed (\fBtype\fR=\fBSDL_KEYDOWN\fP or \fBstate\fR=\fBSDL_PRESSED\fP)\&. The information on what key was pressed or released is in the \fI\fBkeysym\fR\fR structure\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Repeating \fBSDL_KEYDOWN\fP events will occur if key repeat is enabled (see \fI\fBSDL_EnableKeyRepeat\fP\fR)\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_keysym\fR\fR, \fI\fBSDL_EnableKeyRepeat\fP\fR, \fI\fBSDL_EnableUNICODE\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_KillThread.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+.TH "SDL_KillThread" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_KillThread\- Gracelessly terminates the thread\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBvoid \fBSDL_KillThread\fP\fR(\fBSDL_Thread *thread\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_KillThread\fP gracelessly terminates the thread associated with \fBthread\fR\&. If possible, you should use some other form of IPC to signal the thread to quit\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateThread\fP\fR, \fI\fBSDL_WaitThread\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ListModes.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,53 @@
+.TH "SDL_ListModes" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ListModes\- Returns a pointer to an array of available screen dimensions for the given format and video flags
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Rect **\fBSDL_ListModes\fP\fR(\fBSDL_PixelFormat *format, Uint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+Return a pointer to an array of available screen dimensions for the given format and video flags, sorted largest to smallest\&. Returns \fBNULL\fP if there are no dimensions available for a particular format, or \fB-1\fR if any dimension is okay for the given format\&.
+.PP
+If \fBformat\fR is \fBNULL\fP, the mode list will be for the format returned by \fISDL_GetVideoInfo()\fR->\fBvfmt\fR\&. The \fBflag\fR parameter is an OR\&'d combination of \fIsurface\fR flags\&. The flags are the same as those used \fI\fBSDL_SetVideoMode\fP\fR and they play a strong role in deciding what modes are valid\&. For instance, if you pass \fBSDL_HWSURFACE\fP as a flag only modes that support hardware video surfaces will be returned\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_Rect **modes;
+int i;
+\&.
+\&.
+\&.
+
+/* Get available fullscreen/hardware modes */
+modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
+
+/* Check is there are any modes available */
+if(modes == (SDL_Rect **)0){
+  printf("No modes available!
+");
+  exit(-1);
+}
+
+/* Check if or resolution is restricted */
+if(modes == (SDL_Rect **)-1){
+  printf("All resolutions available\&.
+");
+}
+else{
+  /* Print valid modes */
+  printf("Available Modes
+");
+  for(i=0;modes[i];++i)
+    printf("  %d x %d
+", modes[i]->w, modes[i]->h);
+}
+\&.
+\&.\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_GetVideoInfo\fP\fR, \fI\fBSDL_Rect\fR\fR, \fI\fBSDL_PixelFormat\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_LoadBMP.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_LoadBMP" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_LoadBMP\- Load a Windows BMP file into an SDL_Surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_LoadBMP\fP\fR(\fBconst char *file\fR);
+.SH "DESCRIPTION"
+.PP
+Loads a surface from a named Windows BMP file\&.
+.SH "RETURN VALUE"
+.PP
+Returns the new surface, or \fBNULL\fP if there was an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SaveBMP\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_LoadWAV.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+.TH "SDL_LoadWAV" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_LoadWAV\- Load a WAVE file
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_AudioSpec *\fBSDL_LoadWAV\fP\fR(\fBconst char *file, SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_LoadWAV\fP This function loads a WAVE \fBfile\fR into memory\&.
+.PP
+If this function succeeds, it returns the given \fI\fBSDL_AudioSpec\fP\fR, filled with the audio data format of the wave data, and sets \fBaudio_buf\fR to a \fBmalloc\fP\&'d buffer containing the audio data, and sets \fBaudio_len\fR to the length of that audio buffer, in bytes\&. You need to free the audio buffer with \fI\fBSDL_FreeWAV\fP\fR when you are done with it\&.
+.PP
+This function returns \fBNULL\fP and sets the SDL error message if the wave file cannot be opened, uses an unknown data format, or is corrupt\&. Currently raw, MS-ADPCM and IMA-ADPCM WAVE files are supported\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_AudioSpec wav_spec;
+Uint32 wav_length;
+Uint8 *wav_buffer;
+
+/* Load the WAV */
+if( SDL_LoadWAV("test\&.wav", &wav_spec, &wav_buffer, &wav_length) == NULL ){
+  fprintf(stderr, "Could not open test\&.wav: %s
+", SDL_GetError());
+  exit(-1);
+}
+\&.
+\&.
+\&.
+/* Do stuff with the WAV */
+\&.
+\&.
+/* Free It */
+SDL_FreeWAV(wav_buffer);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_AudioSpec\fR\fR, \fI\fBSDL_OpenAudio\fP\fR, \fI\fBSDL_FreeWAV\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_LockAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_LockAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_LockAudio\- Lock out the callback function
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_LockAudio\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+The lock manipulated by these functions protects the callback function\&. During a LockAudio period, you can be guaranteed that the callback function is not running\&. Do not call these from the callback function or you will cause deadlock\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_OpenAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_LockSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+.TH "SDL_LockSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_LockSurface\- Lock a surface for directly access\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_LockSurface\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_LockSurface\fP sets up a surface for directly accessing the pixels\&. Between calls to \fBSDL_LockSurface\fP and \fBSDL_UnlockSurface\fP, you can write to and read from \fBsurface->\fBpixels\fR\fR, using the pixel format stored in \fBsurface->\fBformat\fR\fR\&. Once you are done accessing the surface, you should use \fBSDL_UnlockSurface\fP to release it\&.
+.PP
+Not all surfaces require locking\&. If \fBSDL_MUSTLOCK\fP(\fBsurface\fR) evaluates to \fB0\fR, then you can read and write to the surface at any time, and the pixel format of the surface will not change\&. 
+.PP
+No operating system or library calls should be made between lock/unlock pairs, as critical system locks may be held during this time\&.
+.PP
+It should be noted, that since SDL 1\&.1\&.8 surface locks are recursive\&. This means that you can lock a surface multiple times, but each lock must have a match unlock\&. 
+.PP
+.nf
+\f(CW    \&.
+    \&.
+    SDL_LockSurface( surface );
+    \&.
+    /* Surface is locked */
+    /* Direct pixel access on surface here */
+    \&.
+    SDL_LockSurface( surface );
+    \&.
+    /* More direct pixel access on surface */
+    \&.
+    SDL_UnlockSurface( surface );
+    /* Surface is still locked */
+    /* Note: Is versions < 1\&.1\&.8, the surface would have been */
+    /* no longer locked at this stage                         */
+    \&.
+    SDL_UnlockSurface( surface );
+    /* Surface is now unlocked */
+    \&.
+    \&.\fR
+.fi
+.PP
+ 
+.SH "RETURN VALUE"
+.PP
+\fBSDL_LockSurface\fP returns \fB0\fR, or \fB-1\fR if the surface couldn\&'t be locked\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_UnlockSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_LockYUVOverlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_LockYUVOverlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_LockYUVOverlay\- Lock an overlay
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_LockYUVOverlay\fP\fR(\fBSDL_Overlay *overlay\fR);
+.SH "DESCRIPTION"
+.PP
+Much the same as \fI\fBSDL_LockSurface\fP\fR, \fBSDL_LockYUVOverlay\fP locks the \fI\fBoverlay\fR\fR for direct access to pixel data\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_UnlockYUVOverlay\fP\fR, \fI\fBSDL_CreateYUVOverlay\fP\fR, \fI\fBSDL_Overlay\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_MapRGB.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_MapRGB" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_MapRGB\- Map a RGB color value to a pixel format\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint32 \fBSDL_MapRGB\fP\fR(\fBSDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b\fR);
+.SH "DESCRIPTION"
+.PP
+Maps the RGB color value to the specified pixel format and returns the pixel value as a 32-bit int\&.
+.PP
+If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned\&.
+.PP
+If the specified pixel format has an alpha component it will be returned as all 1 bits (fully opaque)\&.
+.SH "RETURN VALUE"
+.PP
+A pixel value best approximating the given RGB color value for a given pixel format\&. If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e\&.g\&., with a 16-bpp format the return value can be assigned to a \fBUint16\fP, and similarly a \fBUint8\fP for an 8-bpp format)\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetRGB\fP\fR, \fI\fBSDL_GetRGBA\fP\fR, \fI\fBSDL_MapRGBA\fP\fR, \fI\fBSDL_PixelFormat\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_MapRGBA.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_MapRGBA" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_MapRGBA\- Map a RGBA color value to a pixel format\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint32 \fBSDL_MapRGBA\fP\fR(\fBSDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b, Uint8 a\fR);
+.SH "DESCRIPTION"
+.PP
+Maps the RGBA color value to the specified pixel format and returns the pixel value as a 32-bit int\&.
+.PP
+If the format has a palette (8-bit) the index of the closest matching color in the palette will be returned\&.
+.PP
+If the specified pixel format has no alpha component the alpha value will be ignored (as it will be in formats with a palette)\&.
+.SH "RETURN VALUE"
+.PP
+A pixel value best approximating the given RGBA color value for a given pixel format\&. If the pixel format bpp (color depth) is less than 32-bpp then the unused upper bits of the return value can safely be ignored (e\&.g\&., with a 16-bpp format the return value can be assigned to a \fBUint16\fP, and similarly a \fBUint8\fP for an 8-bpp format)\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_GetRGB\fR, \fISDL_GetRGBA\fR, \fISDL_MapRGB\fR, \fISDL_PixelFormat\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_MixAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_MixAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_MixAudio\- Mix audio data
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_MixAudio\fP\fR(\fBUint8 *dst, Uint8 *src, Uint32 len, int volume\fR);
+.SH "DESCRIPTION"
+.PP
+This takes two audio buffers of the playing audio format and mixes them, performing addition, volume adjustment, and overflow clipping\&. The \fBvolume\fR ranges from 0 - 128, and should be set to \fBSDL_MIX_MAXVOLUME\fP for full audio volume\&. Note this does not change hardware volume\&. This is provided for convenience -- you can mix your own audio data\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_OpenAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_MouseButtonEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+.TH "SDL_MouseButtonEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_MouseButtonEvent\- Mouse button event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 button;
+  Uint8 state;
+  Uint16 x, y;
+} SDL_MouseButtonEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_MOUSEBUTTONDOWN\fP or \fBSDL_MOUSEBUTTONUP\fP
+.TP 20
+\fBbutton\fR
+The mouse button index (SDL_BUTTON_LEFT, SDL_BUTTON_MIDDLE, SDL_BUTTON_RIGHT)
+.TP 20
+\fBstate\fR
+\fBSDL_PRESSED\fP or \fBSDL_RELEASED\fP
+.TP 20
+\fBx\fR, \fBy\fR
+The X/Y coordinates of the mouse at press/release time
+.SH "DESCRIPTION"
+.PP
+\fBSDL_MouseButtonEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_MOUSEBUTTONDOWN\fP or \fBSDL_MOUSEBUTTONUP\fP is reported\&.
+.PP
+When a mouse button press or release is detected then number of the button pressed (from 1 to 255, with 1 usually being the left button and 2 the right) is placed into \fBbutton\fR, the position of the mouse when this event occured is stored in the \fBx\fR and the \fBy\fR fields\&. Like \fI\fBSDL_KeyboardEvent\fR\fR, information on whether the event was a press or a release event is stored in both the \fBtype\fR and \fBstate\fR fields, but this should be obvious\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_MouseMotionEvent\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_MouseMotionEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+.TH "SDL_MouseMotionEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_MouseMotionEvent\- Mouse motion event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  Uint8 state;
+  Uint16 x, y;
+  Sint16 xrel, yrel;
+} SDL_MouseMotionEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_MOUSEMOTION\fP
+.TP 20
+\fBstate\fR
+The current button state
+.TP 20
+\fBx\fR, \fBy\fR
+The X/Y coordinates of the mouse
+.TP 20
+\fBxrel\fR, \fByrel\fR
+Relative motion in the X/Y direction
+.SH "DESCRIPTION"
+.PP
+\fBSDL_MouseMotionEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_MOUSEMOTION\fP is reported\&.
+.PP
+Simply put, a \fBSDL_MOUSEMOTION\fP type event occurs when a user moves the mouse within the application window or when \fI\fBSDL_WarpMouse\fP\fR is called\&. Both the absolute (\fBx\fR and \fBy\fR) and relative (\fBxrel\fR and \fByrel\fR) coordinates are reported along with the current button states (\fBstate\fR)\&. The button state can be interpreted using the \fBSDL_BUTTON\fP macro (see \fI\fBSDL_GetMouseState\fP\fR)\&.
+.PP
+If the cursor is hidden (\fI\fBSDL_ShowCursor\fP(0)\fR) and the input is grabbed (\fI\fBSDL_WM_GrabInput\fP(SDL_GRAB_ON)\fR), then the mouse will give relative motion events even when the cursor reaches the edge fo the screen\&. This is currently only implemented on Windows and Linux/Unix-a-likes\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_MouseButtonEvent\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_NumJoysticks.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_NumJoysticks" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_NumJoysticks\- Count available joysticks\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_NumJoysticks\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Counts the number of joysticks attached to the system\&.
+.SH "RETURN VALUE"
+.PP
+Returns the number of attached joysticks
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_JoystickName\fP\fR, \fI\fBSDL_JoystickOpen\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_OpenAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,94 @@
+.TH "SDL_OpenAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_OpenAudio\- Opens the audio device with the desired parameters\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_OpenAudio\fP\fR(\fBSDL_AudioSpec *desired, SDL_AudioSpec *obtained\fR);
+.SH "DESCRIPTION"
+.PP
+This function opens the audio device with the \fBdesired\fR parameters, and returns 0 if successful, placing the actual hardware parameters in the structure pointed to by \fBobtained\fR\&. If \fBobtained\fR is NULL, the audio data passed to the callback function will be guaranteed to be in the requested format, and will be automatically converted to the hardware audio format if necessary\&. This function returns -1 if it failed to open the audio device, or couldn\&'t set up the audio thread\&.
+.PP
+To open the audio device a \fBdesired\fR \fI\fBSDL_AudioSpec\fR\fR must be created\&. 
+.PP
+.nf
+\f(CWSDL_AudioSpec *desired;
+\&.
+\&.
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));\fR
+.fi
+.PP
+ You must then fill this structure with your desired audio specifications\&.
+.IP "\fBdesired\fR->\fBfreq\fR" 10The desired audio frequency in samples-per-second\&.
+.IP "\fBdesired\fR->\fBformat\fR" 10The desired audio format (see \fI\fBSDL_AudioSpec\fR\fR)
+.IP "\fBdesired\fR->\fBsamples\fR" 10The desired size of the audio buffer in samples\&. This number should be a power of two, and may be adjusted by the audio driver to a value more suitable for the hardware\&. Good values seem to range between 512 and 8192 inclusive, depending on the application and CPU speed\&. Smaller values yield faster response time, but can lead to underflow if the application is doing heavy processing and cannot fill the audio buffer in time\&. A stereo sample consists of both right and left channels in LR ordering\&. Note that the number of samples is directly related to time by the following formula: ms = (samples*1000)/freq
+.IP "\fBdesired\fR->\fBcallback\fR" 10This should be set to a function that will be called when the audio device is ready for more data\&. It is passed a pointer to the audio buffer, and the length in bytes of the audio buffer\&. This function usually runs in a separate thread, and so you should protect data structures that it accesses by calling \fI\fBSDL_LockAudio\fP\fR and \fI\fBSDL_UnlockAudio\fP\fR in your code\&. The callback prototype is: 
+.PP
+.nf
+\f(CWvoid callback(void *userdata, Uint8 *stream, int len);\fR
+.fi
+.PP
+ \fBuserdata\fR is the pointer stored in \fBuserdata\fR field of the \fBSDL_AudioSpec\fR\&. \fBstream\fR is a pointer to the audio buffer you want to fill with information and \fBlen\fR is the length of the audio buffer in bytes\&.
+.IP "\fBdesired\fR->\fBuserdata\fR" 10This pointer is passed as the first parameter to the \fBcallback\fP function\&.
+.PP
+\fBSDL_OpenAudio\fP reads these fields from the \fBdesired\fR \fBSDL_AudioSpec\fR structure pass to the function and attempts to find an audio configuration matching your \fBdesired\fR\&. As mentioned above, if the \fBobtained\fR parameter is \fBNULL\fP then SDL with convert from your \fBdesired\fR audio settings to the hardware settings as it plays\&.
+.PP
+If \fBobtained\fR is \fBNULL\fP then the \fBdesired\fR \fBSDL_AudioSpec\fR is your working specification, otherwise the \fBobtained\fR \fBSDL_AudioSpec\fR becomes the working specification and the \fBdesirec\fR specification can be deleted\&. The data in the working specification is used when building \fBSDL_AudioCVT\fR\&'s for converting loaded data to the hardware format\&.
+.PP
+\fBSDL_OpenAudio\fP calculates the \fBsize\fR and \fBsilence\fR fields for both the \fBdesired\fR and \fBobtained\fR specifications\&. The \fBsize\fR field stores the total size of the audio buffer in bytes, while the \fBsilence\fR stores the value used to represent silence in the audio buffer
+.PP
+The audio device starts out playing \fBsilence\fR when it\&'s opened, and should be enabled for playing by calling \fI\fBSDL_PauseAudio\fP(\fB0\fR)\fR when you are ready for your audio \fBcallback\fR function to be called\&. Since the audio driver may modify the requested \fBsize\fR of the audio buffer, you should allocate any local mixing buffers after you open the audio device\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CW/* Prototype of our callback function */
+void my_audio_callback(void *userdata, Uint8 *stream, int len);
+
+/* Open the audio device */
+SDL_AudioSpec *desired, *obtained;
+SDL_AudioSpec *hardware_spec;
+
+/* Allocate a desired SDL_AudioSpec */
+desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* Allocate space for the obtained SDL_AudioSpec */
+obtained=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec));
+
+/* 22050Hz - FM Radio quality */
+desired->freq=22050;
+
+/* 16-bit signed audio */
+desired->format=AUDIO_S16LSB;
+
+/* Large audio buffer reduces risk of dropouts but increases response time */
+desired->samples=8192;
+
+/* Our callback function */
+desired->callback=my_audio_callback;
+
+desired->userdata=NULL;
+
+/* Open the audio device */
+if ( SDL_OpenAudio(desired, obtained) < 0 ){
+  fprintf(stderr, "Couldn\&'t open audio: %s
+", SDL_GetError());
+  exit(-1);
+}
+/* desired spec is no longer needed */
+free(desired);
+hardware_spec=obtained;
+\&.
+\&.
+/* Prepare callback for playing */
+\&.
+\&.
+\&.
+/* Start playing */
+SDL_PauseAudio(0);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_AudioSpec\fP\fR, \fI\fBSDL_LockAudio\fP\fR, \fI\fBSDL_UnlockAudio\fP\fR, \fI\fBSDL_PauseAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Overlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,52 @@
+.TH "SDL_Overlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Overlay\- YUV video overlay
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint32 format;
+  int w, h;
+  int planes;
+  Uint16 *pitches;
+  Uint8 **pixels;
+  Uint32 hw_overlay:1;
+} SDL_Overlay;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBformat\fR
+Overlay format (see below)
+.TP 20
+\fBw, h\fR
+Width and height of overlay
+.TP 20
+\fBplanes\fR
+Number of planes in the overlay\&. Usually either 1 or 3
+.TP 20
+\fBpitches\fR
+An array of pitches, one for each plane\&. Pitch is the length of a row in bytes\&.
+.TP 20
+\fBpixels\fR
+An array of pointers to teh data of each plane\&. The overlay should be locked before these pointers are used\&.
+.TP 20
+\fBhw_overlay\fR
+This will be set to 1 if the overlay is hardware accelerated\&.
+.SH "DESCRIPTION"
+.PP
+A \fBSDL_Overlay\fR is similar to a \fI\fBSDL_Surface\fR\fR except it stores a YUV overlay\&. All the fields are read only, except for \fBpixels\fR which should be \fIlocked\fR before use\&. The \fBformat\fR field stores the format of the overlay which is one of the following: 
+.PP
+.nf
+\f(CW#define SDL_YV12_OVERLAY  0x32315659  /* Planar mode: Y + V + U */
+#define SDL_IYUV_OVERLAY  0x56555949  /* Planar mode: Y + U + V */
+#define SDL_YUY2_OVERLAY  0x32595559  /* Packed mode: Y0+U0+Y1+V0 */
+#define SDL_UYVY_OVERLAY  0x59565955  /* Packed mode: U0+Y0+V0+Y1 */
+#define SDL_YVYU_OVERLAY  0x55595659  /* Packed mode: Y0+V0+Y1+U0 */\fR
+.fi
+.PP
+ More information on YUV formats can be found at \fIhttp://www\&.webartz\&.com/fourcc/indexyuv\&.htm (link to URL http://www.webartz.com/fourcc/indexyuv.htm) \fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateYUVOverlay\fP\fR, \fI\fBSDL_LockYUVOverlay\fP\fR, \fI\fBSDL_UnlockYUVOverlay\fP\fR, \fI\fBSDL_FreeYUVOverlay\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Palette.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_Palette" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Palette\- Color palette for 8-bit pixel formats
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  int ncolors;
+  SDL_Color *colors;
+} SDL_Palette;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBncolors\fR
+Number of colors used in this palette
+.TP 20
+\fBcolors\fR
+Pointer to \fI\fBSDL_Color\fR\fR structures that make up the palette\&.
+.SH "DESCRIPTION"
+.PP
+Each pixel in an 8-bit surface is an index into the \fBcolors\fR field of the \fBSDL_Palette\fR structure store in \fI\fBSDL_PixelFormat\fR\fR\&. A \fBSDL_Palette\fR should never need to be created manually\&. It is automatically created when SDL allocates a \fBSDL_PixelFormat\fR for a surface\&. The colors values of a \fI\fBSDL_Surface\fR\fRs palette can be set with the \fI\fBSDL_SetColors\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Color\fR\fR, \fI\fBSDL_Surface\fR\fR, \fI\fBSDL_SetColors\fP\fR \fI\fBSDL_SetPalette\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PauseAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_PauseAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PauseAudio\- Pauses and unpauses the audio callback processing
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_PauseAudio\fP\fR(\fBint pause_on\fR);
+.SH "DESCRIPTION"
+.PP
+This function pauses and unpauses the audio callback processing\&. It should be called with \fBpause_on\fR=0 after opening the audio device to start playing sound\&. This is so you can safely initialize data for your callback function after opening the audio device\&. Silence will be written to the audio device during the pause\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetAudioStatus\fP\fR, \fI\fBSDL_OpenAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PeepEvents.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_PeepEvents" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PeepEvents\- Checks the event queue for messages and optionally returns them\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_PeepEvents\fP\fR(\fBSDL_Event *events, int numevents, SDL_eventaction action, Uint32 mask\fR);
+.SH "DESCRIPTION"
+.PP
+Checks the event queue for messages and optionally returns them\&.
+.PP
+If \fBaction\fR is \fBSDL_ADDEVENT\fP, up to \fBnumevents\fR events will be added to the back of the event queue\&.
+.PP
+If \fBaction\fR is \fBSDL_PEEKEVENT\fP, up to \fBnumevents\fR events at the front of the event queue, matching \fI\fBmask\fR\fR, will be returned and will not be removed from the queue\&.
+.PP
+If \fBaction\fR is \fBSDL_GETEVENT\fP, up to \fBnumevents\fR events at the front of the event queue, matching \fI\fBmask\fR\fR, will be returned and will be removed from the queue\&.
+.PP
+This function is thread-safe\&.
+.SH "RETURN VALUE"
+.PP
+This function returns the number of events actually stored, or \fB-1\fR if there was an error\&. 
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_PollEvent\fP\fR, \fI\fBSDL_PushEvent\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PixelFormat.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,140 @@
+.TH "SDL_PixelFormat" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PixelFormat\- Stores surface format information
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  SDL_Palette *palette;
+  Uint8  BitsPerPixel;
+  Uint8  BytesPerPixel;
+  Uint32 Rmask, Gmask, Bmask, Amask;
+  Uint8  Rshift, Gshift, Bshift, Ashift;
+  Uint8  Rloss, Gloss, Bloss, Aloss;
+  Uint32 colorkey;
+  Uint8  alpha;
+} SDL_PixelFormat;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBpalette\fR
+Pointer to the \fIpalette\fR, or \fBNULL\fP if the \fBBitsPerPixel\fR>8
+.TP 20
+\fBBitsPerPixel\fR
+The number of bits used to represent each pixel in a surface\&. Usually 8, 16, 24 or 32\&.
+.TP 20
+\fBBytesPerPixel\fR
+The number of bytes used to represent each pixel in a surface\&. Usually one to four\&.
+.TP 20
+\fB[RGBA]mask\fR
+Binary mask used to retrieve individual color values
+.TP 20
+\fB[RGBA]loss\fR
+Precision loss of each color component (2^[RGBA]loss)
+.TP 20
+\fB[RGBA]shift\fR
+Binary left shift of each color component in the pixel value
+.TP 20
+\fBcolorkey\fR
+Pixel value of transparent pixels
+.TP 20
+\fBalpha\fR
+Overall surface alpha value
+.SH "DESCRIPTION"
+.PP
+A \fBSDL_PixelFormat\fR describes the format of the pixel data stored at the \fBpixels\fR field of a \fI\fBSDL_Surface\fR\fR\&. Every surface stores a \fBSDL_PixelFormat\fR in the \fBformat\fR field\&.
+.PP
+If you wish to do pixel level modifications on a surface, then understanding how SDL stores its color information is essential\&.
+.PP
+8-bit pixel formats are the easiest to understand\&. Since its an 8-bit format, we have 8 \fBBitsPerPixel\fR and 1 \fBBytesPerPixel\fR\&. Since \fBBytesPerPixel\fR is 1, all pixels are represented by a Uint8 which contains an index into \fBpalette\fR->\fBcolors\fR\&. So, to determine the color of a pixel in a 8-bit surface: we read the color index from \fBsurface\fR->\fBpixels\fR and we use that index to read the \fI\fBSDL_Color\fR\fR structure from \fBsurface\fR->\fBformat\fR->\fBpalette\fR->\fBcolors\fR\&. Like so: 
+.PP
+.nf
+\f(CWSDL_Surface *surface;
+SDL_PixelFormat *fmt;
+SDL_Color *color;
+Uint8 index;
+
+\&.
+\&.
+
+/* Create surface */
+\&.
+\&.
+fmt=surface->format;
+
+/* Check the bitdepth of the surface */
+if(fmt->BitsPerPixel!=8){
+  fprintf(stderr, "Not an 8-bit surface\&.
+");
+  return(-1);
+}
+
+/* Lock the surface */
+SDL_LockSurface(surface);
+
+/* Get the topleft pixel */
+index=*(Uint8 *)surface->pixels;
+color=fmt->palette->colors[index];
+
+/* Unlock the surface */
+SDL_UnlockSurface(surface);
+printf("Pixel Color-> Red: %d, Green: %d, Blue: %d\&. Index: %d
+",
+          color->r, color->g, color->b, index);
+\&.
+\&.\fR
+.fi
+.PP
+.PP
+Pixel formats above 8-bit are an entirely different experience\&. They are considered to be "TrueColor" formats and the color information is stored in the pixels themselves, not in a palette (packed-pixel)\&. The mask, shift and loss fields tell us how the color information is encoded\&. The mask fields allow us to isolate each color component, the shift fields tell us how far left we have to shift the masked value and the loss fields tell us for far right we have to shift the final value to convert it to a full 8-bit color component\&. 
+.PP
+.nf
+\f(CW/* Extracting color components from a 32-bit color value */
+SDL_PixelFormat *fmt;
+SDL_Surface *surface;
+Uint32 temp, pixel;
+Uint8 red, green, blue, alpha;
+\&.
+\&.
+\&.
+fmt=surface->format;
+SDL_LockSurface(surface);
+pixel=(Uint32*)surface->pixels;
+SDL_UnlockSurface(surface);
+
+/* Get Red component */
+temp=pixel&fmt->Rmask; /* Isolate red component */
+temp=temp>>fmt->Rshift;/* Shift it down to 8-bit */
+temp=temp<<fmt->Rloss; /* Expand to a full 8-bit number */
+red=(Uint8)temp;
+
+/* Get Green component */
+temp=pixel&fmt->Gmask; /* Isolate green component */
+temp=temp>>fmt->Gshift;/* Shift it down to 8-bit */
+temp=temp<<fmt->Gloss; /* Expand to a full 8-bit number */
+green=(Uint8)temp;
+
+/* Get Blue component */
+temp=pixel&fmt->Bmask; /* Isolate blue component */
+temp=temp>>fmt->Bshift;/* Shift it down to 8-bit */
+temp=temp<<fmt->Bloss; /* Expand to a full 8-bit number */
+blue=(Uint8)temp;
+
+/* Get Alpha component */
+temp=pixel&fmt->Amask; /* Isolate alpha component */
+temp=temp>>fmt->Ashift;/* Shift it down to 8-bit */
+temp=temp<<fmt->Aloss; /* Expand to a full 8-bit number */
+alpha=(Uint8)temp;
+
+printf("Pixel Color -> R: %d,  G: %d,  B: %d,  A: %d
+", red, green, blue, alpha);
+\&.
+\&.
+\&.\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Surface\fR\fR, \fI\fBSDL_MapRGB\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PollEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,44 @@
+.TH "SDL_PollEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PollEvent\- Polls for currently pending events\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_PollEvent\fP\fR(\fBSDL_Event *event\fR);
+.SH "DESCRIPTION"
+.PP
+Polls for currently pending events, and returns \fB1\fR if there are any pending events, or \fB0\fR if there are none available\&. 
+.PP
+If \fBevent\fR is not \fBNULL\fP, the next event is removed from the queue and stored in that area\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_Event event; /* Event structure */
+
+\&.
+\&.
+\&.
+/* Check for events */
+while(SDL_PollEvent(&event)){  /* Loop until there are no events left on the queue */
+  switch(event\&.type){  /* Process the appropiate event type */
+    case SDL_KEYDOWN:  /* Handle a KEYDOWN event */         
+      printf("Oh! Key press
+");
+      break;
+    case SDL_MOUSEMOTION:
+      \&.
+      \&.
+      \&.
+    default: /* Report an unhandled event */
+      printf("I don\&'t know what this event is!
+");
+  }
+}\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_WaitEvent\fP\fR, \fI\fBSDL_PeepEvents\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PumpEvents.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+.TH "SDL_PumpEvents" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PumpEvents\- Pumps the event loop, gathering events from the input devices\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_PumpEvents\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+Pumps the event loop, gathering events from the input devices\&.
+.PP
+\fBSDL_PumpEvents\fP gathers all the pending input information from devices and places it on the event queue\&. Without calls to \fBSDL_PumpEvents\fP no events would ever be placed on the queue\&. Often calls the need for \fBSDL_PumpEvents\fP is hidden from the user since \fI\fBSDL_PollEvent\fP\fR and \fI\fBSDL_WaitEvent\fP\fR implicitly call \fBSDL_PumpEvents\fP\&. However, if you are not polling or waiting for events (e\&.g\&. your filtering them), then you must call \fBSDL_PumpEvents\fP to force an event queue update\&.
+.PP
+.RS
+\fBNote:  
+.PP
+You can only call this function in the thread that set the video mode\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PollEvent\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_PushEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+.TH "SDL_PushEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_PushEvent\- Pushes an event onto the event queue
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_PushEvent\fP\fR(\fBSDL_Event *event\fR);
+.SH "DESCRIPTION"
+.PP
+The event queue can actually be used as a two way communication channel\&. Not only can events be read from the queue, but the user can also push their own events onto it\&. \fBevent\fR is a pointer to the event structure you wish to push onto the queue\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Pushing device input events onto the queue doesn\&'t modify the state of the device within SDL\&.
+.RE
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on success or \fB-1\fR if the event couldn\&'t be pushed\&.
+.SH "EXAMPLES"
+.PP
+See \fI\fBSDL_Event\fR\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PollEvent\fP\fR, \fI\fBSDL_PeepEvents\fP\fR, \fI\fBSDL_Event\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Quit.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,29 @@
+.TH "SDL_Quit" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Quit\- Shut down SDL
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_Quit\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_Quit\fP shuts down all SDL subsystems and frees the resources allocated to them\&. This should always be called before you exit\&. For the sake of simplicity you can set \fBSDL_Quit\fP as your \fBatexit\fP call, like: 
+.PP
+.nf
+\f(CWSDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
+atexit(SDL_Quit);
+\&.
+\&.\fR
+.fi
+.PP
+.PP
+.RS
+\fBNote:  
+.PP
+While using \fBatexit\fP maybe be fine for small programs, more advanced users should shut down SDL in their own cleanup code\&. Plus, using \fBatexit\fP in a library is a sure way to crash dynamically loaded code
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_QuitSubsystem\fP\fR, \fI\fBSDL_Init\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_QuitEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+.TH "SDL_QuitEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_QuitEvent\- Quit requested event
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type
+} SDL_QuitEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_QUIT\fP
+.SH "DESCRIPTION"
+.PP
+\fBSDL_QuitEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used whan an event of type \fBSDL_QUIT\fP is reported\&.
+.PP
+As can be seen, the SDL_QuitEvent structure serves no useful purpose\&. The event itself, on the other hand, is very important\&. If you filter out or ignore a quit event then it is impossible for the user to close the window\&. On the other hand, if you do accept a quit event then the application window will be closed, and screen updates will still report success event though the application will no longer be visible\&.
+.PP
+.RS
+\fBNote:  
+.PP
+The macro \fBSDL_QuitRequested\fP will return non-zero if a quit event is pending
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_SetEventFilter\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_QuitSubSystem.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_QuitSubSystem" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_QuitSubSystem\- Shut down a subsystem
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_QuitSubSystem\fP\fR(\fBUint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_QuitSubSystem\fP allows you to shut down a subsystem that has been previously initialized by \fI\fBSDL_Init\fP\fR or \fI\fBSDL_InitSubSystem\fP\fR\&. The \fBflags\fR tells \fBSDL_QuitSubSystem\fP which subsystems to shut down, it uses the same values that are passed to \fI\fBSDL_Init\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Quit\fP\fR, \fI\fBSDL_Init\fP\fR, \fI\fBSDL_InitSubSystem\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_RWFromFile.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_FunctionName" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_FunctionName\- Short description of function
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBreturn type\fBSDL_FunctionName\fP\fR(\fBparameter\fR);
+.SH "DESCRIPTION"
+.PP
+Full description
+.SH "EXAMPLES"
+.PP
+examples here
+.SH "SEE ALSO"
+.PP
+\fISDL_AnotherFunction\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Rect.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_Rect" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Rect\- Defines a rectangular area
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Sint16 x, y;
+  Uint16 w, h;
+} SDL_Rect;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBx, y\fR
+Position of the upper-left corner of the rectangle
+.TP 20
+\fBw, h\fR
+The width and height of the rectangle
+.SH "DESCRIPTION"
+.PP
+A \fBSDL_Rect\fR defines a rectangular area of pixels\&. It is used by \fI\fBSDL_BlitSurface\fP\fR to define blitting regions and by several other video functions\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_BlitSurface\fP\fR, \fI\fBSDL_UpdateRect\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_RemoveTimer.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,25 @@
+.TH "SDL_RemoveTimer" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_RemoveTimer\- Remove a timer which was added with \fISDL_AddTimer\fR\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_bool \fBSDL_RemoveTimer\fP\fR(\fBSDL_TimerID id\fR);
+.SH "DESCRIPTION"
+.PP
+Removes a timer callback previously added with \fISDL_AddTimer\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns a boolean value indicating success\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_RemoveTimer(my_timer_id);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_AddTimer\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ResizeEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,28 @@
+.TH "SDL_ResizeEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ResizeEvent\- Window resize event structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  int w, h;
+} SDL_ResizeEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_VIDEORESIZE\fP
+.TP 20
+\fBw\fR, \fBh\fR
+New width and height of the window
+.SH "DESCRIPTION"
+.PP
+\fBSDL_ResizeEvent\fR is a member of the \fI\fBSDL_Event\fR\fR union and is used when an event of type \fBSDL_VIDEORESIZE\fP is reported\&.
+.PP
+When \fBSDL_RESIZABLE\fP is passed as a \fBflag\fR to \fI\fBSDL_SetVideoMode\fP\fR the user is allowed to resize the applications window\&. When the window is resized an \fBSDL_VIDEORESIZE\fP is report, with the new window width and height values stored in \fBw\fR and \fBh\fR, respectively\&. When an \fBSDL_VIDEORESIZE\fP is recieved the window should be resized to the new dimensions using \fI\fBSDL_SetVideoMode\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_SetVideoMode\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SaveBMP.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_SaveBMP" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SaveBMP\- Save an SDL_Surface as a Windows BMP file\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SaveBMP\fP\fR(\fBSDL_Surface *surface, const char *file\fR);
+.SH "DESCRIPTION"
+.PP
+Saves the \fBSDL_Surface\fR \fBsurface\fR as a Windows BMP file named \fBfile\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR if successful or \fB-1\fR if there was an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_LoadBMP\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SemPost.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,28 @@
+.TH "SDL_SemPost" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SemPost\- Unlock a semaphore\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_SemPost\fP\fR(\fBSDL_sem *sem\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_SemPost\fP unlocks the semaphore pointed to by \fBsem\fR and atomically increments the semaphores value\&. Threads that were blocking on the semaphore may be scheduled after this call succeeds\&.
+.PP
+\fBSDL_SemPost\fP should be called after a semaphore is locked by a successful call to \fISDL_SemWait\fR, \fISDL_SemTryWait\fR or \fISDL_SemWaitTimeout\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR if successful or \fB-1\fR if there was an error (leaving the semaphore unchanged)\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_SemPost(my_sem);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SemTryWait.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+.TH "SDL_SemTryWait" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SemTryWait\- Attempt to lock a semaphore but don\&'t suspend the thread\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_SemTryWait\fP\fR(\fBSDL_sem *sem\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_SemTryWait\fP is a non-blocking varient of \fI\fBSDL_SemWait\fP\fR\&. If the value of the semaphore pointed to by \fBsem\fR is positive it will atomically decrement the semaphore value and return 0, otherwise it will return \fBSDL_MUTEX_TIMEOUT\fR instead of suspending the thread\&.
+.PP
+After \fBSDL_SemTryWait\fP is successful, the semaphore can be released and its count atomically incremented by a successful call to \fISDL_SemPost\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR if the semaphore was successfully locked or either \fBSDL_MUTEX_TIMEOUT\fR or \fB-1\fR if the thread would have suspended or there was an error, respectivly\&.
+.PP
+If the semaphore was not successfully locked, the semaphore will be unchanged\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWres = SDL_SemTryWait(my_sem);
+
+if (res == SDL_MUTEX_TIMEOUT) {
+        return TRY_AGAIN;
+}
+if (res == -1) {
+        return WAIT_ERROR;
+}
+
+\&.\&.\&.
+
+SDL_SemPost(my_sem);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemPost\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SemValue.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_SemValue" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SemValue\- Return the current value of a semaphore\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL/SDL_thread\&.h"
+.sp
+\fBUint32 \fBSDL_SemValue\fP\fR(\fBSDL_sem *sem\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_SemValue()\fP returns the current semaphore value from the semaphore pointed to by \fBsem\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns current value of the semaphore\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CW  sem_value = SDL_SemValue(my_sem);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemPost\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SemWait.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,34 @@
+.TH "SDL_SemWait" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SemWait\- Lock a semaphore and suspend the thread if the semaphore value is zero\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_SemWait\fP\fR(\fBSDL_sem *sem\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_SemWait()\fP suspends the calling thread until either the semaphore pointed to by \fBsem\fR has a positive value, the call is interrupted by a signal or error\&. If the call is successful it will atomically decrement the semaphore value\&.
+.PP
+After \fBSDL_SemWait()\fP is successful, the semaphore can be released and its count atomically incremented by a successful call to \fISDL_SemPost\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR if successful or \fB-1\fR if there was an error (leaving the semaphore unchanged)\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWif (SDL_SemWait(my_sem) == -1) {
+        return WAIT_FAILED;
+}
+
+\&.\&.\&.
+
+SDL_SemPost(my_sem);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemWaitTimeout\fP\fR, \fI\fBSDL_SemPost\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SemWaitTimeout.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+.TH "SDL_SemWaitTimeout" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SemWaitTimeout\- Lock a semaphore, but only wait up to a specified maximum time\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_SemWaitTimeout\fP\fR(\fBSDL_sem *sem, Uint32 timeout\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_SemWaitTimeout()\fP is a varient of \fISDL_SemWait\fR with a maximum timeout value\&. If the value of the semaphore pointed to by \fBsem\fR is positive (greater than zero) it will atomically decrement the semaphore value and return 0, otherwise it will wait up to \fBtimeout\fR milliseconds trying to lock the semaphore\&. This function is to be avoided if possible since on some platforms it is implemented by polling the semaphore every millisecond in a busy loop\&.
+.PP
+After \fBSDL_SemWaitTimeout()\fP is successful, the semaphore can be released and its count atomically incremented by a successful call to \fISDL_SemPost\fR\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR if the semaphore was successfully locked or either \fBSDL_MUTEX_TIMEOUT\fR or \fB-1\fR if the timeout period was exceeded or there was an error, respectivly\&.
+.PP
+If the semaphore was not successfully locked, the semaphore will be unchanged\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWres = SDL_SemWaitTimeout(my_sem, WAIT_TIMEOUT_MILLISEC);
+
+if (res == SDL_MUTEX_TIMEOUT) {
+        return TRY_AGAIN;
+}
+if (res == -1) {
+        return WAIT_ERROR;
+}
+
+\&.\&.\&.
+
+SDL_SemPost(my_sem);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateSemaphore\fP\fR, \fI\fBSDL_DestroySemaphore\fP\fR, \fI\fBSDL_SemWait\fP\fR, \fI\fBSDL_SemTryWait\fP\fR, \fI\fBSDL_SemPost\fP\fR, \fI\fBSDL_SemValue\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetAlpha.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,55 @@
+.TH "SDL_SetAlpha" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetAlpha\- Adjust the alpha properties of a surface
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetAlpha\fP\fR(\fBSDL_Surface *surface, Uint32 flag, Uint8 alpha\fR);
+.SH "DESCRIPTION"
+.PP
+.RS
+\fBNote:  
+.PP
+This function and the semantics of SDL alpha blending have changed since version 1\&.1\&.4\&. Up until version 1\&.1\&.5, an alpha value of 0 was considered opaque and a value of 255 was considered transparent\&. This has now been inverted: 0 (\fBSDL_ALPHA_TRANSPARENT\fP) is now considered transparent and 255 (\fBSDL_ALPHA_OPAQUE\fP) is now considered opaque\&.
+.RE
+.PP
+\fBSDL_SetAlpha\fP is used for setting the per-surface alpha and/or enabling and disabling per-pixel alpha blending\&.
+.PP
+The \fBsurface\fR parameter specifies which surface whose alpha attributes you wish to adjust\&. \fBflags\fR is used to specify whether alpha blending should be used (\fBSDL_SRCALPHA\fP) and whether the surface should use RLE acceleration for blitting (\fBSDL_RLEACCEL\fP)\&. \fBflags\fR can be an OR\&'d combination of these two options, one of these options or 0\&. If \fBSDL_SRCALPHA\fP is not passed as a flag then all alpha information is ignored when blitting the surface\&. The \fBalpha\fR parameter is the per-surface alpha value, a surface need not have an alpha channel to use per-surface alpha and blitting can still be accelerated with \fBSDL_RLEACCEL\fP\&. Setting the per-surface alpha value to 0 disables per-surface alpha blending\&.
+.PP
+.RS
+\fBNote:  
+.PP
+The per-surface alpha value of 128 is considered a special case and is optimised, so it\&'s much faster than other per-surface values\&.
+.RE
+.PP
+Alpha effects surface blitting in the following ways:
+.TP 20
+RGBA->RGB with \fBSDL_SRCALPHA\fP
+The source is alpha-blended with the destination, using the alpha channel\&. \fBSDL_SRCCOLORKEY\fP and the per-surface alpha are ignored\&.
+.TP 20
+RGBA->RGB without \fBSDL_SRCALPHA\fP
+The RGB data is copied from the source\&. The source alpha channel and the per-surface alpha value are ignored\&.
+.TP 20
+RGB->RGBA with \fBSDL_SRCALPHA\fP
+The source is alpha-blended with the destination using the per-surface alpha value\&. If \fBSDL_SRCCOLORKEY\fPliteral> is set, only the pixels not matching the colorkey value are copied\&.
+.TP 20
+RGB->RGBA without \fBSDL_SRCALPHA\fP
+The RGB data is copied from the source and the destination alpha is zero to opaque\&. If \fBSDL_SRCCOLORKEY\fP is set, only the pixels not matching the colorkey value are copied\&.
+.TP 20
+RGBA->RGBA with \fBSDL_SRCALPHA\fP
+The source is alpha-blended with the destination using the source alpha channel\&. The alpha channel in the destination surface is left untouched\&. \fBSDL_SRCCOLORKEY\fP is ignored\&.
+.TP 20
+RGBA->RGBA without \fBSDL_SRCALPHA\fP
+The RGBA data is copied to the destination surface\&. If \fBSDL_SRCCOLORKEY\fP is set, only the pixels not matching the colorkey value are copied\&.
+.TP 20
+RGB->RGB with \fBSDL_SRCALPHA\fP
+The source is alpha-blended with the destination using the per-surface alpha value\&. If \fBSDL_SRCCOLORKEY\fP is set, only the pixels not matching the colorkey value are copied\&.
+.TP 20
+RGB->RGB without \fBSDL_SRCALPHA\fP
+The RGB data is copied from the source\&. If \fBSDL_SRCCOLORKEY\fP is set, only the pixels not matching the colorkey value are copied\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_MapRGBA\fP\fR, \fI\fBSDL_GetRGBA\fP\fR, \fI\fBSDL_DisplayFormatAlpha\fP\fR, \fI\fBSDL_BlitSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetClipRect.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+.TH "SDL_SetClipRect" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetClipRect\- Sets the clipping rectangle for a surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_SetClipRect\fP\fR(\fBSDL_Surface *surface, SDL_Rect *rect\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the clipping rectangle for a surface\&. When this surface is the destination of a blit, only the area within the clip rectangle will be drawn into\&.
+.PP
+The rectangle pointed to by \fBrect\fR will be clipped to the edges of the surface so that the clip rectangle for a surface can never fall outside the edges of the surface\&.
+.PP
+If \fBrect\fR is \fBNULL\fP the clipping rectangle will be set to the full size of the surface\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetClipRect\fP\fR, \fI\fBSDL_BlitSurface\fP\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetColorKey.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+.TH "SDL_SetColorKey" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetColorKey\- Sets the color key (transparent pixel) in a blittable surface and RLE acceleration\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetColorKey\fP\fR(\fBSDL_Surface *surface, Uint32 flag, Uint32 key\fR);
+.SH "DESCRIPTION"
+.PP
+ Sets the color key (transparent pixel) in a blittable surface and enables or disables RLE blit acceleration\&.
+.PP
+RLE acceleration can substantially speed up blitting of images with large horizontal runs of transparent pixels (i\&.e\&., pixels that match the \fBkey\fR value)\&. The \fBkey\fR must be of the same pixel format as the \fBsurface\fR, \fI\fBSDL_MapRGB\fP\fR is often useful for obtaining an acceptable value\&.
+.PP
+If \fBflag\fR is \fBSDL_SRCCOLORKEY\fP then \fBkey\fR is the transparent pixel value in the source image of a blit\&.
+.PP
+If \fBflag\fR is OR\&'d with \fBSDL_RLEACCEL\fP then the surface will be draw using RLE acceleration when drawn with \fISDL_BlitSurface\fR\&. The surface will actually be encoded for RLE acceleration the first time \fISDL_BlitSurface\fR or \fISDL_DisplayFormat\fR is called on the surface\&.
+.PP
+If \fBflag\fR is 0, this function clears any current color key\&.
+.SH "RETURN VALUE"
+.PP
+This function returns \fB0\fR, or \fB-1\fR if there was an error\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_BlitSurface\fP\fR, \fI\fBSDL_DisplayFormat\fP\fR, \fI\fBSDL_MapRGB\fP\fR, \fI\fBSDL_SetAlpha\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetColors.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,57 @@
+.TH "SDL_SetColors" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetColors\- Sets a portion of the colormap for the given 8-bit surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetColors\fP\fR(\fBSDL_Surface *surface, SDL_Color *colors, int firstcolor, int ncolors\fR);
+.SH "DESCRIPTION"
+.PP
+Sets a portion of the colormap for the given 8-bit surface\&.
+.PP
+When \fBsurface\fR is the surface associated with the current display, the display colormap will be updated with the requested colors\&. If \fBSDL_HWPALETTE\fP was set in \fISDL_SetVideoMode\fR flags, \fBSDL_SetColors\fP will always return \fB1\fR, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation\&.
+.PP
+The color components of a \fI\fBSDL_Color\fR\fR structure are 8-bits in size, giving you a total of 256^3 =16777216 colors\&.
+.PP
+Palettized (8-bit) screen surfaces with the \fBSDL_HWPALETTE\fP flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display)\&. \fBSDL_SetColors\fP modifies both palettes (if present), and is equivalent to calling \fISDL_SetPalette\fR with the \fBflags\fR set to \fB(SDL_LOGPAL | SDL_PHYSPAL)\fP\&.
+.SH "RETURN VALUE"
+.PP
+If \fBsurface\fR is not a palettized surface, this function does nothing, returning \fB0\fR\&. If all of the colors were set as passed to \fBSDL_SetColors\fP, it will return \fB1\fR\&. If not all the color entries were set exactly as given, it will return \fB0\fR, and you should look at the surface palette to determine the actual color palette\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CW/* Create a display surface with a grayscale palette */
+SDL_Surface *screen;
+SDL_Color colors[256];
+int i;
+\&.
+\&.
+\&.
+/* Fill colors with color information */
+for(i=0;i<256;i++){
+  colors[i]\&.r=i;
+  colors[i]\&.g=i;
+  colors[i]\&.b=i;
+}
+
+/* Create display */
+screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
+if(!screen){
+  printf("Couldn\&'t set video mode: %s
+", SDL_GetError());
+  exit(-1);
+}
+
+/* Set palette */
+SDL_SetColors(screen, colors, 0, 256);
+\&.
+\&.
+\&.
+\&.\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Color\fR\fR \fI\fBSDL_Surface\fR\fR, \fI\fBSDL_SetPalette\fP\fR, \fI\fBSDL_SetVideoMode\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetCursor.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_SetCursor" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetCursor\- Set the currently active mouse cursor\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid *\fBSDL_SetCursor\fP\fR(\fBSDL_Cursor *cursor\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the currently active cursor to the specified one\&. If the cursor is currently visible, the change will be immediately represented on the display\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetCursor\fP\fR, \fI\fBSDL_CreateCursor\fP\fR, \fI\fBSDL_ShowCursor\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetEventFilter.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+.TH "SDL_SetEventFilter" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetEventFilter\- Sets up a filter to process all events before they are posted to the event queue\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_SetEventFilter\fP\fR(\fBSDL_EventFilter filter\fR);
+.SH "DESCRIPTION"
+.PP
+This function sets up a filter to process all events before they are posted to the event queue\&. This is a very powerful and flexible feature\&. The filter is prototyped as: 
+.PP
+.nf
+\f(CWtypedef int (*SDL_EventFilter)(const SDL_Event *event);\fR
+.fi
+.PP
+ If the filter returns \fB1\fR, then the event will be added to the internal queue\&. If it returns \fB0\fR, then the event will be dropped from the queue\&. This allows selective filtering of dynamically\&.
+.PP
+There is one caveat when dealing with the \fBSDL_QUITEVENT\fP event type\&. The event filter is only called when the window manager desires to close the application window\&. If the event filter returns 1, then the window will be closed, otherwise the window will remain open if possible\&. If the quit event is generated by an interrupt signal, it will bypass the internal queue and be delivered to the application at the next event poll\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Events pushed onto the queue with \fI\fBSDL_PushEvent\fP\fR or \fI\fBSDL_PeepEvents\fP\fR do not get passed through the event filter\&.
+.RE
+.PP
+.RS
+\fBNote:  
+.PP
+\fIBe Careful!\fP The event filter function may run in a different thread so be careful what you do within it\&.
+.RE
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_GetEventFilter\fP\fR, \fI\fBSDL_PushEvent\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetGamma.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_SetGamma" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetGamma\- Sets the color gamma function for the display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetGamma\fP\fR(\fBfloat redgamma, float greengamma, float bluegamma\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the "gamma function" for the display of each color component\&. Gamma controls the brightness/contrast of colors displayed on the screen\&. A gamma value of 1\&.0 is identity (i\&.e\&., no adjustment is made)\&.
+.PP
+This function adjusts the gamma based on the "gamma function" parameter, you can directly specify lookup tables for gamma adjustment with \fISDL_SetGammaRamp\fR\&.
+.PP
+Not all display hardware is able to change gamma\&.
+.SH "RETURN VALUE"
+.PP
+Returns -1 on error (or if gamma adjustment is not supported)\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_GetGammaRamp\fR \fISDL_SetGammaRamp\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetGammaRamp.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+.TH "SDL_SetGammaRamp" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetGammaRamp\- Sets the color gamma lookup tables for the display
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetGammaRamp\fP\fR(\fBUint16 *redtable, Uint16 *greentable, Uint16 *bluetable\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the gamma lookup tables for the display for each color component\&. Each table is an array of 256 Uint16 values, representing a mapping between the input and output for that channel\&. The input is the index into the array, and the output is the 16-bit gamma value at that index, scaled to the output color precision\&. You may pass NULL to any of the channels to leave them unchanged\&.
+.PP
+This function adjusts the gamma based on lookup tables, you can also have the gamma calculated based on a "gamma function" parameter with \fISDL_SetGamma\fR\&.
+.PP
+Not all display hardware is able to change gamma\&.
+.SH "RETURN VALUE"
+.PP
+Returns -1 on error (or if gamma adjustment is not supported)\&.
+.SH "SEE ALSO"
+.PP
+\fISDL_SetGamma\fR \fISDL_GetGammaRamp\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetModState.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+.TH "SDL_SetModState" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetModState\- Set the current key modifier state
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_SetModState\fP\fR(\fBSDLMod modstate\fR);
+.SH "DESCRIPTION"
+.PP
+The inverse of \fI\fBSDL_GetModState\fP\fR, \fBSDL_SetModState\fP allows you to impose modifier key states on your application\&.
+.PP
+Simply pass your desired modifier states into \fBmodstate\fR\&. This value my be a logical OR\&'d combination of the following:
+.PP
+.nf
+\f(CWtypedef enum {
+  KMOD_NONE  = 0x0000,
+  KMOD_LSHIFT= 0x0001,
+  KMOD_RSHIFT= 0x0002,
+  KMOD_LCTRL = 0x0040,
+  KMOD_RCTRL = 0x0080,
+  KMOD_LALT  = 0x0100,
+  KMOD_RALT  = 0x0200,
+  KMOD_LMETA = 0x0400,
+  KMOD_RMETA = 0x0800,
+  KMOD_NUM   = 0x1000,
+  KMOD_CAPS  = 0x2000,
+  KMOD_MODE  = 0x4000,
+} SDLMod;\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_GetModState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetPalette.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,59 @@
+.TH "SDL_SetPalette" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetPalette\- Sets the colors in the palette of an 8-bit surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetPalette\fP\fR(\fBSDL_Surface *surface, int flags, int SDL_Color *colors, int firstcolor, int ncolors\fR);
+.SH "DESCRIPTION"
+.PP
+Sets a portion of the palette for the given 8-bit surface\&.
+.PP
+Palettized (8-bit) screen surfaces with the \fBSDL_HWPALETTE\fP flag have two palettes, a logical palette that is used for mapping blits to/from the surface and a physical palette (that determines how the hardware will map the colors to the display)\&. \fISDL_BlitSurface\fR always uses the logical palette when blitting surfaces (if it has to convert between surface pixel formats)\&. Because of this, it is often useful to modify only one or the other palette to achieve various special color effects (e\&.g\&., screen fading, color flashes, screen dimming)\&.
+.PP
+This function can modify either the logical or physical palette by specifing \fBSDL_LOGPAL\fP or \fBSDL_PHYSPAL\fPthe in the \fBflags\fR parameter\&.
+.PP
+When \fBsurface\fR is the surface associated with the current display, the display colormap will be updated with the requested colors\&. If \fBSDL_HWPALETTE\fP was set in \fISDL_SetVideoMode\fR flags, \fBSDL_SetPalette\fP will always return \fB1\fR, and the palette is guaranteed to be set the way you desire, even if the window colormap has to be warped or run under emulation\&.
+.PP
+The color components of a \fI\fBSDL_Color\fR\fR structure are 8-bits in size, giving you a total of 256^3=16777216 colors\&.
+.SH "RETURN VALUE"
+.PP
+If \fBsurface\fR is not a palettized surface, this function does nothing, returning \fB0\fR\&. If all of the colors were set as passed to \fBSDL_SetPalette\fP, it will return \fB1\fR\&. If not all the color entries were set exactly as given, it will return \fB0\fR, and you should look at the surface palette to determine the actual color palette\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CW        /* Create a display surface with a grayscale palette */
+        SDL_Surface *screen;
+        SDL_Color colors[256];
+        int i;
+        \&.
+        \&.
+        \&.
+        /* Fill colors with color information */
+        for(i=0;i<256;i++){
+          colors[i]\&.r=i;
+          colors[i]\&.g=i;
+          colors[i]\&.b=i;
+        }
+
+        /* Create display */
+        screen=SDL_SetVideoMode(640, 480, 8, SDL_HWPALETTE);
+        if(!screen){
+          printf("Couldn\&'t set video mode: %s
+", SDL_GetError());
+          exit(-1);
+        }
+
+        /* Set palette */
+        SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
+        \&.
+        \&.
+        \&.
+        \&.\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fISDL_SetColors\fR, \fISDL_SetVideoMode\fR, \fISDL_Surface\fR, \fISDL_Color\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetTimer.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+.TH "SDL_SetTimer" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetTimer\- Set a callback to run after the specified number of milliseconds has elapsed\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_SetTimer\fP\fR(\fBUint32 interval, SDL_TimerCallback callback\fR);
+.SH "CALLBACK"
+.PP
+/* Function prototype for the timer callback function */ typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);
+.SH "DESCRIPTION"
+.PP
+Set a callback to run after the specified number of milliseconds has elapsed\&. The callback function is passed the current timer interval and returns the next timer interval\&. If the returned value is the same as the one passed in, the periodic alarm continues, otherwise a new alarm is scheduled\&.
+.PP
+To cancel a currently running timer, call \fBSDL_SetTimer(0, NULL);\fP
+.PP
+The timer callback function may run in a different thread than your main constant, and so shouldn\&'t call any functions from within itself\&.
+.PP
+The maximum resolution of this timer is 10 ms, which means that if you request a 16 ms timer, your callback will run approximately 20 ms later on an unloaded system\&. If you wanted to set a flag signaling a frame update at 30 frames per second (every 33 ms), you might set a timer for 30 ms (see example below)\&.
+.PP
+If you use this function, you need to pass \fBSDL_INIT_TIMER\fP to \fBSDL_Init()\fP\&.
+.PP
+.RS
+\fBNote:  
+.PP
+This function is kept for compatibility but has been superceeded by the new timer functions \fISDL_AddTimer\fR and \fISDL_RemoveTimer\fR which support multiple timers\&.
+.RE
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_SetTimer((33/10)*10, my_callback);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_AddTimer\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SetVideoMode.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+.TH "SDL_SetVideoMode" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SetVideoMode\- Set up a video mode with the specified width, height and bits-per-pixel\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_Surface *\fBSDL_SetVideoMode\fP\fR(\fBint width, int height, int bpp, Uint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+Set up a video mode with the specified width, height and bits-per-pixel\&.
+.PP
+If \fBbpp\fR is 0, it is treated as the current display bits per pixel\&.
+.PP
+The \fBflags\fR parameter is the same as the \fBflags\fR field of the \fI\fBSDL_Surface\fR\fR structure\&. OR\&'d combinations of the following values are valid\&.
+.TP 20
+\fBSDL_SWSURFACE\fP
+Create the video surface in system memory
+.TP 20
+\fBSDL_HWSURFACE\fP
+Create the video surface in video memory
+.TP 20
+\fBSDL_ASYNCBLIT\fP
+Enables the use of asynchronous to the display surface\&. This will usually slow down blitting on single CPU machines, but may provide a speed increase on SMP systems\&.
+.TP 20
+\fBSDL_ANYFORMAT\fP
+Normally, if a video surface of the requested depth (\fBbpp\fR) is not available, SDL will emulate one with a shadow surface\&. Passing \fBSDL_ANYFORMAT\fP prevents this and causes SDL to use the video surface, regardless of its depth\&.
+.TP 20
+\fBSDL_HWPALETTE\fP
+Give SDL exclusive palette access\&. Without this flag you may not always get the the colors you request with \fI\fBSDL_SetColors\fP\fR\&.
+.TP 20
+\fBSDL_DOUBLEBUF\fP
+Enable double buffering\&. Calling \fI\fBSDL_Flip\fP\fR will flip the buffers and update the screen\&. If double buffering could not be enabled then \fBSDL_Flip\fP will just perform a \fI\fBSDL_UpdateRect\fP\fR on the entire screen\&.
+.TP 20
+\fBSDL_FULLSCREEN\fP
+SDL will attempt to use a fullscreen mode
+.TP 20
+\fBSDL_OPENGL\fP
+Create an OpenGL rendering context\&. You should have previously set OpenGL video attributes with \fI\fBSDL_GL_SetAttribute\fP\fR\&.
+.TP 20
+\fBSDL_OPENGLBLIT\fP
+Create an OpenGL rendering context, like above, but allow normal blitting operations\&.
+.TP 20
+\fBSDL_RESIZABLE\fP
+Create a resizable window\&. When the window is resized by the user a \fI\fBSDL_VIDEORESIZE\fP\fR event is generated and \fBSDL_SetVideoMode\fP can be called again with the new size\&.
+.TP 20
+\fBSDL_NOFRAME\fP
+If possible, \fBSDL_NOFRAME\fP causes SDL to create a window with no title bar or frame decoration\&. Fullscreen modes automatically have this flag set\&.
+.PP
+.RS
+\fBNote:  
+.PP
+Whatever \fBflags\fR \fBSDL_SetVideoMode\fP could satisfy are set in the \fBflags\fR member of the returned surface\&.
+.RE
+.SH "RETURN VALUE"
+.PP
+The framebuffer surface, or \fBNULL\fR if it fails\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_LockSurface\fP\fR, \fI\fBSDL_SetColors\fP\fR, \fI\fBSDL_Flip\fP\fR, \fI\fBSDL_Surface\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ShowCursor.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+.TH "SDL_ShowCursor" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ShowCursor\- Toggle whether or not the cursor is shown on the screen\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_ShowCursor\fP\fR(\fBint toggle\fR);
+.SH "DESCRIPTION"
+.PP
+Toggle whether or not the cursor is shown on the screen\&. Passing \fBSDL_ENABLE\fP displays the cursor and passing \fBSDL_DISABLE\fP hides it\&. The current state of the mouse cursor can be queried by passing \fBSDL_QUERY\fP, either \fBSDL_DISABLE\fP or \fBSDL_ENABLE\fP will be returned\&.
+.PP
+The cursor starts off displayed, but can be turned off\&.
+.SH "RETURN VALUE"
+.PP
+Returns the current state of the cursor\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateCursor\fP\fR, \fI\fBSDL_SetCursor\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_Surface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,109 @@
+.TH "SDL_Surface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_Surface\- Graphical Surface Structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct SDL_Surface {
+        Uint32 flags;                           /* Read-only */
+        SDL_PixelFormat *format;                /* Read-only */
+        int w, h;                               /* Read-only */
+        Uint16 pitch;                           /* Read-only */
+        void *pixels;                           /* Read-write */
+        int offset;                             /* Private */
+
+        /* Hardware-specific surface info */
+        struct private_hwdata *hwdata;
+
+        /* clipping information */
+        SDL_Rect clip_rect;                     /* Read-only */
+        Uint32 unused1;                         /* for binary compatibility */
+        Uint32 unused2;                         /* for binary compatibility */
+
+        /* info for fast blit mapping to other surfaces */
+        struct SDL_BlitMap *map;                /* Private */
+
+        /* format version, bumped at every change to invalidate blit maps */
+        unsigned int format_version;            /* Private */
+
+        /* Reference count -- used when freeing surface */
+        int refcount;                           /* Read-mostly */
+} SDL_Surface;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBflags\fR
+Surface flags
+.TP 20
+\fBformat\fR
+Pixel \fIformat\fR
+.TP 20
+\fBw, h\fR
+Width and height of the surface
+.TP 20
+\fBpitch\fR
+Length of a surface scanline in bytes
+.TP 20
+\fBpixels\fR
+Pointer to the actual pixel data
+.TP 20
+\fBclip_minx, clip_maxx\fR
+X clip coords
+.TP 20
+\fBclip_rect\fR
+surface clip \fIrectangle\fR
+.SH "DESCRIPTION"
+.PP
+\fBSDL_Surface\fR\&'s represent areas of "graphical" memory, memory that can be drawn to\&. The video framebuffer is returned as a \fBSDL_Surface\fR by \fI\fBSDL_SetVideoMode\fP\fR and \fI\fBSDL_GetVideoSurface\fP\fR\&. Most of the fields should be pretty obvious\&. \fBw\fR and \fBh\fR are the width and height of the surface in pixels\&. \fBpixels\fR is a pointer to the actual pixel data, the surface should be \fIlocked\fR before accessing this field\&. The \fBclip_rect\fR field is the clipping rectangle as set by \fI\fBSDL_SetClipRect\fP\fR\&.
+.PP
+The following are supported in the \fBflags\fR field\&.
+.TP 20
+\fBSDL_SWSURFACE\fP
+Surface is stored in system memory
+.TP 20
+\fBSDL_HWSURFACE\fP
+Surface is stored in video memory
+.TP 20
+\fBSDL_ASYNCBLIT\fP
+Surface uses asynchronous blits if possible
+.TP 20
+\fBSDL_ANYFORMAT\fP
+Allows any pixel-format (Display surface)
+.TP 20
+\fBSDL_HWPALETTE\fP
+Surface has exclusive palette
+.TP 20
+\fBSDL_DOUBLEBUF\fP
+Surface is double buffered (Display surface)
+.TP 20
+\fBSDL_FULLSCREEN\fP
+Surface is full screen (Display Surface)
+.TP 20
+\fBSDL_OPENGL\fP
+Surface has an OpenGL context (Display Surface)
+.TP 20
+\fBSDL_OPENGLBLIT\fP
+Surface supports OpenGL blitting (Display Surface)
+.TP 20
+\fBSDL_RESIZABLE\fP
+Surface is resizable (Display Surface)
+.TP 20
+\fBSDL_HWACCEL\fP
+Surface blit uses hardware acceleration
+.TP 20
+\fBSDL_SRCOLORKEY\fP
+Surface use colorkey blitting
+.TP 20
+\fBSDL_RLEACCEL\fP
+Colorkey blitting is accelerated with RLE
+.TP 20
+\fBSDL_SRCALPHA\fP
+Surface blit uses alpha blending
+.TP 20
+\fBSDL_PREALLOC\fP
+Surface uses preallocated memory
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PixelFormat\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_SysWMEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,21 @@
+.TH "SDL_SysWMEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_SysWMEvent\- Platform-dependent window manager event\&.
+.SH "DESCRIPTION"
+.PP
+The system window manager event contains a pointer to system-specific information about unknown window manager events\&. If you enable this event using \fI\fBSDL_EventState()\fP\fR, it will be generated whenever unhandled events are received from the window manager\&. This can be used, for example, to implement cut-and-paste in your application\&. 
+.PP
+.nf
+\f(CWtypedef struct {
+         Uint8 type;   /* Always SDL_SysWM */
+ } SDL_SysWMEvent;\fR
+.fi
+.PP
+ If you want to obtain system-specific information about the window manager, you can fill the version member of a \fBSDL_SysWMinfo\fR structure (details can be found in \fBSDL_syswm\&.h\fP, which must be included) using the \fBSDL_VERSION()\fP macro found in \fBSDL_version\&.h\fP, and pass it to the function: 
+.PP
+.sp
+\fBint \fBSDL_GetWMInfo\fP\fR(\fBSDL_SysWMinfo *info\fR);
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_EventState\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_ThreadID.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+.TH "SDL_ThreadID" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_ThreadID\- Get the 32-bit thread identifier for the current thread\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBUint32 \fBSDL_ThreadID\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+Get the 32-bit thread identifier for the current thread\&.
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UnlockAudio.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_UnlockAudio" "3" "Mon 12 Mar 2001, 01:02" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UnlockAudio\- Unlock the callback function
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_UnlockAudio\fP\fR(\fBvoid\fR)
+.SH "DESCRIPTION"
+.PP
+Unlocks a previous \fI\fBSDL_LockAudio\fP\fR call\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_OpenAudio\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:02
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UnlockSurface.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_UnlockSurface" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UnlockSurface\- Unlocks a previously locked surface\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_UnlockSurface\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+Surfaces that were previously locked using \fBSDL_LockSurface\fP must be unlocked with \fBSDL_UnlockSurface\fP\&. Surfaces should be unlocked as soon as possible\&.
+.PP
+It should be noted that since 1\&.1\&.8, surface locks are recursive\&. See \fI\fBSDL_LockSurface\fP\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_LockSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UnlockYUVOverlay.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_UnlockYUVOverlay" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UnlockYUVOverlay\- Unlock an overlay
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_UnlockYUVOverlay\fP\fR(\fBSDL_Overlay *overlay\fR);
+.SH "DESCRIPTION"
+.PP
+The opposite to \fI\fBSDL_LockYUVOverlay\fP\fR\&. Unlocks a previously locked overlay\&. An overlay must be unlocked before it can be displayed\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_UnlockYUVOverlay\fP\fR, \fI\fBSDL_CreateYUVOverlay\fP\fR, \fI\fBSDL_Overlay\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UpdateRect.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+.TH "SDL_UpdateRect" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UpdateRect\- Makes sure the given area is updated on the given screen\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_UpdateRect\fP\fR(\fBSDL_Surface *screen, Sint32 x, Sint32 y, Sint32 w, Sint32 h\fR);
+.SH "DESCRIPTION"
+.PP
+Makes sure the given area is updated on the given screen\&.
+.PP
+If \&'\fBx\fR\&', \&'\fBy\fR\&', \&'\fBw\fR\&' and \&'\fBh\fR\&' are all 0, \fBSDL_UpdateRect\fP will update the entire screen\&.
+.PP
+This function should not be called while \&'\fBscreen\fR\&' is \fIlocked\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_UpdateRects\fP\fR, \fI\fBSDL_Rect\fR\fR, \fI\fBSDL_Surface\fR\fR, \fI\fBSDL_LockSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UpdateRects.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_UpdateRects" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UpdateRects\- Makes sure the given list of rectangles is updated on the given screen\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_UpdateRects\fP\fR(\fBSDL_Surface *screen, int numrects, SDL_Rect *rects\fR);
+.SH "DESCRIPTION"
+.PP
+Makes sure the given list of rectangles is updated on the given screen\&.
+.PP
+This function should not be called while \fBscreen\fR is \fIlocked\fR\&. 
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_UpdateRect\fP\fR, \fI\fBSDL_Rect\fR\fR, \fI\fBSDL_Surface\fR\fR, \fI\fBSDL_LockSurface\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_UserEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,47 @@
+.TH "SDL_UserEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_UserEvent\- A user-defined event type
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 type;
+  int code;
+  void *data1;
+  void *data2;
+} SDL_UserEvent;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBtype\fR
+\fBSDL_USEREVENT\fP through to \fBSDL_NUMEVENTS-1\fP
+.TP 20
+\fBcode\fR
+User defined event code
+.TP 20
+\fBdata1\fR
+User defined data pointer
+.TP 20
+\fBdata2\fR
+User defined data pointer
+.SH "DESCRIPTION"
+.PP
+\fBSDL_UserEvent\fR is in the \fBuser\fR member of the structure \fI\fBSDL_Event\fR\fR\&. This event is unique, it is never created by SDL but only by the user\&. The event can be pushed onto the event queue using \fI\fBSDL_PushEvent\fP\fR\&. The contents of the structure members or completely up to the programmer, the only requirement is that \fBtype\fR is a value from \fBSDL_USEREVENT\fP to \fBSDL_NUMEVENTS-1\fP (inclusive)\&.
+.SH "EXAMPLES"
+.PP
+.PP
+.nf
+\f(CWSDL_Event event;
+
+event\&.type = SDL_USEREVENT;
+event\&.user\&.code = my_event_code;
+event\&.user\&.data1 = significant_data;
+event\&.user\&.data2 = 0;
+SDL_PushEvent(&event);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_PushEvent\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_VideoDriverName.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_VideoDriverName" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_VideoDriverName\- Obtain the name of the video driver
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBchar *\fBSDL_VideoDriverName\fP\fR(\fBchar *namebuf, int maxlen\fR);
+.SH "DESCRIPTION"
+.PP
+The buffer pointed to by \fBnamebuf\fR is filled up to a maximum of \fBmaxlen\fR characters (include the NULL terminator) with the name of the initialised video driver\&. The driver name is a simple one word identifier like "x11" or "windib"\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fBNULL\fP if video has not been initialised with \fBSDL_Init\fP or a pointer to \fBnamebuf\fR otherwise\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Init\fP\fR \fI\fBSDL_InitSubSystem\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_VideoInfo.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,62 @@
+.TH "SDL_VideoInfo" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_VideoInfo\- Video Target information
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint32 hw_available:1;
+  Uint32 wm_available:1;
+  Uint32 blit_hw:1;
+  Uint32 blit_hw_CC:1;
+  Uint32 blit_hw_A:1;
+  Uint32 blit_sw:1;
+  Uint32 blit_sw_CC:1;
+  Uint32 blit_sw_A:1;
+  Uint32 blit_fill;
+  Uint32 video_mem;
+  SDL_PixelFormat *vfmt;
+} SDL_VideoInfo;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBhw_available\fR
+Is it possible to create hardware surfaces?
+.TP 20
+\fBwm_available\fR
+Is there a window manager available
+.TP 20
+\fBblit_hw\fR
+Are hardware to hardware blits accelerated?
+.TP 20
+\fBblit_hw_CC\fR
+Are hardware to hardware colorkey blits accelerated?
+.TP 20
+\fBblit_hw_A\fR
+Are hardware to hardware alpha blits accelerated?
+.TP 20
+\fBblit_sw\fR
+Are software to hardware blits accelerated?
+.TP 20
+\fBblit_sw_CC\fR
+Are software to hardware colorkey blits accelerated?
+.TP 20
+\fBblit_sw_A\fR
+Are software to hardware alpha blits accelerated?
+.TP 20
+\fBblit_fill\fR
+Are color fills accelerated?
+.TP 20
+\fBvideo_mem\fR
+Total amount of video memory in Kilobytes
+.TP 20
+\fBvfmt\fR
+\fIPixel format\fR of the video device
+.SH "DESCRIPTION"
+.PP
+This (read-only) structure is returned by \fI\fBSDL_GetVideoInfo\fP\fR\&. It contains information on either the \&'best\&' available mode (if called before \fI\fBSDL_SetVideoMode\fP\fR) or the current video mode\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_PixelFormat\fR\fR, \fI\fBSDL_GetVideoInfo\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_VideoModeOK.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,44 @@
+.TH "SDL_VideoModeOK" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_VideoModeOK\- Check to see if a particular video mode is supported\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_VideoModeOK\fP\fR(\fBint width, int height, int bpp, Uint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_VideoModeOK\fP returns \fB0\fR if the requested mode is not supported under any bit depth, or returns the bits-per-pixel of the closest available mode with the given width, height and requested \fIsurface\fR flags (see \fI\fBSDL_SetVideoMode\fP\fR)\&.
+.PP
+The bits-per-pixel value returned is only a suggested mode\&. You can usually request and bpp you want when \fIsetting\fR the video mode and SDL will emulate that color depth with a shadow video surface\&.
+.PP
+The arguments to \fBSDL_VideoModeOK\fP are the same ones you would pass to \fISDL_SetVideoMode\fR
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_Surface *screen;
+Uint32 bpp;
+\&.
+\&.
+\&.
+printf("Checking mode 640x480@16bpp\&.
+");
+bpp=SDL_VideoModeOK(640, 480, 16, SDL_HWSURFACE);
+
+if(!bpp){
+  printf("Mode not available\&.
+");
+  exit(-1);
+}
+
+printf("SDL Recommends 640x480@%dbpp\&.
+", bpp);
+screen=SDL_SetVideoMode(640, 480, bpp, SDL_HWSURFACE);
+\&.
+\&.\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_GetVideoInfo\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_GetCaption.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_WM_GetCaption" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_GetCaption\- Gets the window title and icon name\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_WM_GetCaption\fP\fR(\fBchar **title, char **icon\fR);
+.SH "DESCRIPTION"
+.PP
+Set pointers to the window \fBtitle\fR and \fBicon\fR name\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_WM_SetCaption\fP\fR, \fI\fBSDL_WM_SetIcon\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_GrabInput.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,28 @@
+.TH "SDL_WM_GrabInput" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_GrabInput\- Grabs mouse and keyboard input\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBSDL_GrabMode \fBSDL_WM_GrabInput\fP\fR(\fBSDL_GrabMode mode\fR);
+.SH "DESCRIPTION"
+.PP
+Grabbing means that the mouse is confined to the application window, and nearly all keyboard input is passed directly to the application, and not interpreted by a window manager, if any\&.
+.PP
+When \fBmode\fR is \fBSDL_GRAB_QUERY\fP the grab mode is not changed, but the current grab mode is returned\&.
+.PP
+.PP
+.nf
+\f(CWtypedef enum {
+  SDL_GRAB_QUERY,
+  SDL_GRAB_OFF,
+  SDL_GRAB_ON
+} SDL_GrabMode;\fR
+.fi
+.PP
+ 
+.SH "RETURN VALUE"
+.PP
+The current/new \fBSDL_GrabMode\fR\&.
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_IconifyWindow.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_WM_IconifyWindow" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_IconifyWindow\- Iconify/Minimise the window
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_WM_IconifyWindow\fP\fR(\fBvoid\fR);
+.SH "DESCRIPTION"
+.PP
+If the application is running in a window managed environment SDL attempts to iconify/minimise it\&. If \fBSDL_WM_IconifyWindow\fP is successful, the application will receive a \fI\fBSDL_APPACTIVE\fP\fR loss event\&.
+.SH "RETURN VALUE"
+.PP
+Returns non-zero on success or \fB0\fR if iconification is not support or was refused by the window manager\&.
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_SetCaption.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_WM_SetCaption" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_SetCaption\- Sets the window tile and icon name\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_WM_SetCaption\fP\fR(\fBconst char *title, const char *icon\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the title-bar and icon name of the display window\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_WM_GetCaption\fP\fR, \fI\fBSDL_WM_SetIcon\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_SetIcon.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+.TH "SDL_WM_SetIcon" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_SetIcon\- Sets the icon for the display window\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_WM_SetIcon\fP\fR(\fBSDL_Surface *icon, Uint8 *mask\fR);
+.SH "DESCRIPTION"
+.PP
+Sets the icon for the display window\&.
+.PP
+This function must be called before the first call to \fISDL_SetVideoMode\fR\&.
+.PP
+It takes an \fBicon\fR surface, and a \fBmask\fR in MSB format\&.
+.PP
+If \fBmask\fR is \fBNULL\fP, the entire icon surface will be used as the icon\&.
+.SH "EXAMPLE"
+.PP
+.nf
+\f(CWSDL_WM_SetIcon(SDL_LoadBMP("icon\&.bmp"), NULL);\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_SetVideoMode\fP\fR, \fI\fBSDL_WM_SetCaption\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WM_ToggleFullScreen.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_WM_ToggleFullScreen" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WM_ToggleFullScreen\- Toggles fullscreen mode
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_WM_ToggleFullScreen\fP\fR(\fBSDL_Surface *surface\fR);
+.SH "DESCRIPTION"
+.PP
+Toggles the application between windowed and fullscreen mode, if supported\&. (X11 is the only target currently supported, BeOS support is experimental)\&.
+.SH "RETURN VALUE"
+.PP
+Returns \fB0\fR on failure or \fB1\fR on success\&.
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WaitEvent.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+.TH "SDL_WaitEvent" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WaitEvent\- Waits indefinitely for the next available event\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBint \fBSDL_WaitEvent\fP\fR(\fBSDL_Event *event\fR);
+.SH "DESCRIPTION"
+.PP
+Waits indefinitely for the next available event, returning \fB1\fR, or \fB0\fR if there was an error while waiting for events\&. 
+.PP
+If \fBevent\fR is not \fBNULL\fP, the next event is removed from the queue and stored in that area\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Event\fR\fR, \fI\fBSDL_PollEvent\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WaitThread.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+.TH "SDL_WaitThread" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WaitThread\- Wait for a thread to finish\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBvoid \fBSDL_WaitThread\fP\fR(\fBSDL_Thread *thread, int *status\fR);
+.SH "DESCRIPTION"
+.PP
+Wait for a thread to finish (timeouts are not supported)\&.
+.SH "RETURN VALUE"
+.PP
+The return code for the thread function is placed in the area pointed to by \fBstatus\fR, if \fBstatus\fR is not \fBNULL\fR\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateThread\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WarpMouse.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+.TH "SDL_WarpMouse" "3" "Mon 12 Mar 2001, 01:05" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WarpMouse\- Set the position of the mouse cursor\&.
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBvoid \fBSDL_WarpMouse\fP\fR(\fBUint16 x, Uint16 y\fR);
+.SH "DESCRIPTION"
+.PP
+Set the position of the mouse cursor (generates a mouse motion event)\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_MouseMotionEvent\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_WasInit.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,63 @@
+.TH "SDL_WasInit" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_WasInit\- Check which subsystems are initialized
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+.sp
+\fBUint32 \fBSDL_WasInit\fP\fR(\fBUint32 flags\fR);
+.SH "DESCRIPTION"
+.PP
+\fBSDL_WasInit\fP allows you to see which SDL subsytems have been \fIinitialized\fR\&. \fBflags\fR is a bitwise OR\&'d combination of the subsystems you wish to check (see \fI\fBSDL_Init\fP\fR for a list of subsystem flags)\&.
+.SH "RETURN VALUE"
+.PP
+\fBSDL_WasInit\fP returns a bitwised OR\&'d combination of the initialized subsystems\&.
+.SH "EXAMPLES"
+.PP
+.nf
+\f(CW
+/* Here are several ways you can use SDL_WasInit() */
+
+/* Get init data on all the subsystems */
+Uint32 subsystem_init;
+
+subsystem_init=SDL_WasInit(SDL_INIT_EVERYTHING);
+
+if(subsystem_init&SDL_INIT_VIDEO)
+  printf("Video is initialized\&.
+");
+else
+  printf("Video is not initialized\&.
+");
+
+
+
+/* Just check for one specfic subsystem */
+
+if(SDL_WasInit(SDL_INIT_VIDEO)!=0)
+  printf("Video is initialized\&.
+");
+else
+  printf("Video is not initialized\&.
+");
+
+
+
+
+/* Check for two subsystems */
+
+Uint32 subsystem_mask=SDL_INIT_VIDEO|SDL_INIT_AUDIO;
+
+if(SDL_WasInit(subsystem_mask)==subsystem_mask)
+  printf("Video and Audio initialized\&.
+");
+else
+  printf("Video and Audio not initialized\&.
+");
+\fR
+.fi
+.PP
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_Init\fP\fR, \fI\fBSDL_Subsystem\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_keysym.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,69 @@
+.TH "SDL_keysym" "3" "Mon 12 Mar 2001, 01:03" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_keysym\- Keysym structure
+.SH "STRUCTURE DEFINITION"
+.PP
+.nf
+\f(CWtypedef struct{
+  Uint8 scancode;
+  SDLKey sym;
+  SDLMod mod;
+  Uint16 unicode;
+} SDL_keysym;\fR
+.fi
+.PP
+.SH "STRUCTURE DATA"
+.TP 20
+\fBscancode\fR
+Hardware specific scancode
+.TP 20
+\fBsym\fR
+SDL virtual keysym
+.TP 20
+\fBmod\fR
+Current key modifiers
+.TP 20
+\fBunicode\fR
+Translated character
+.SH "DESCRIPTION"
+.PP
+The \fBSDL_keysym\fR structure is used by reporting key presses and releases since it is a part of the \fI\fBSDL_KeyboardEvent\fR\fR\&.
+.PP
+The \fBscancode\fR field should generally be left alone, it is the hardware dependent scancode returned by the keyboard\&. The \fBsym\fR field is extremely useful\&. It is the SDL-defined value of the key (see \fISDL Key Syms\fR\&. This field is very useful when you are checking for certain key presses, like so: 
+.PP
+.nf
+\f(CW\&.
+\&.
+while(SDL_PollEvent(&event)){
+  switch(event\&.type){
+    case SDL_KEYDOWN:
+      if(event\&.key\&.keysym\&.sym==SDLK_LEFT)
+        move_left();
+      break;
+    \&.
+    \&.
+    \&.
+  }
+}
+\&.
+\&.\fR
+.fi
+.PP
+ \fBmod\fR stores the current state of the keyboard modifiers as explained in \fI\fBSDL_GetModState\fP\fR\&. The \fBunicode\fR is only used when UNICODE translation is enabled with \fI\fBSDL_EnableUNICODE\fP\fR\&. If \fBunicode\fR is non-zero then this a the UNICODE character corresponding to the keypress\&. If the high 9 bits of the character are 0, then this maps to the equivalent ASCII character: 
+.PP
+.nf
+\f(CWchar ch;
+if ( (keysym\&.unicode & 0xFF80) == 0 ) {
+  ch = keysym\&.unicode & 0x7F;
+}
+else {
+  printf("An International Character\&.
+");
+}\fR
+.fi
+.PP
+ UNICODE translation does have a slight overhead so don\&'t enable it unless its needed\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDLKey\fR\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:03
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_mutexP.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_mutexP" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_mutexP\- Lock a mutex
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_mutexP\fP\fR(\fBSDL_mutex *mutex\fR);
+.SH "DESCRIPTION"
+.PP
+Locks the \fBmutex\fR, which was previously created with \fI\fBSDL_CreateMutex\fP\fR\&. If the mutex is already locked then \fBSDL_mutexP\fP will not return until it is \fIunlocked\fR\&. Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.PP
+SDL also defines a macro \fB#define SDL_LockMutex(m) SDL_mutexP(m)\fP\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateMutex\fP\fR, \fI\fBSDL_mutexV\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/docs/man3/SDL_mutexV.3	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+.TH "SDL_mutexV" "3" "Mon 12 Mar 2001, 01:04" "SDL" "SDL API Reference" 
+.SH "NAME"
+SDL_mutexV\- Unlock a mutex
+.SH "SYNOPSIS"
+.PP
+\fB#include "SDL\&.h"
+#include "SDL_thread\&.h"
+.sp
+\fBint \fBSDL_mutexV\fP\fR(\fBSDL_mutex *mutex\fR);
+.SH "DESCRIPTION"
+.PP
+Unlocks the \fBmutex\fR, which was previously created with \fI\fBSDL_CreateMutex\fP\fR\&. Returns \fB0\fR on success, or \fB-1\fR on an error\&.
+.PP
+SDL also defines a macro \fB#define SDL_UnlockMutex(m) SDL_mutexV(m)\fP\&.
+.SH "SEE ALSO"
+.PP
+\fI\fBSDL_CreateMutex\fP\fR, \fI\fBSDL_mutexP\fP\fR
+...\" created by instant / docbook-to-man, Mon 12 Mar 2001, 01:04
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2 @@
+Makefile.in
+Makefile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+# The input Makefile for SDL header files
+
+# The directory where the include files will be installed
+libSDLincludedir = $(includedir)/SDL
+
+# Which header files to install
+libSDLinclude_HEADERS =		\
+	SDL.h			\
+	SDL_active.h		\
+	SDL_audio.h		\
+	SDL_byteorder.h		\
+	SDL_cdrom.h		\
+	SDL_copying.h		\
+	SDL_endian.h		\
+	SDL_error.h		\
+	SDL_events.h		\
+	SDL_getenv.h		\
+	SDL_joystick.h		\
+	SDL_keyboard.h		\
+	SDL_keysym.h		\
+	SDL_main.h		\
+	SDL_mouse.h		\
+	SDL_mutex.h		\
+	SDL_quit.h		\
+	SDL_rwops.h		\
+	SDL_syswm.h		\
+	SDL_thread.h		\
+	SDL_timer.h		\
+	SDL_types.h		\
+	SDL_version.h		\
+	SDL_video.h		\
+	begin_code.h		\
+	close_code.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,97 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Main include header for the SDL library */
+
+#ifndef _SDL_H
+#define _SDL_H
+
+#include "SDL_main.h"
+#include "SDL_types.h"
+#include "SDL_getenv.h"
+#include "SDL_error.h"
+#include "SDL_rwops.h"
+#include "SDL_timer.h"
+#include "SDL_audio.h"
+#include "SDL_cdrom.h"
+#include "SDL_joystick.h"
+#include "SDL_events.h"
+#include "SDL_video.h"
+#include "SDL_byteorder.h"
+#include "SDL_version.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* As of version 0.5, SDL is loaded dynamically into the application */
+
+/* These are the flags which may be passed to SDL_Init() -- you should
+   specify the subsystems which you will be using in your application.
+*/
+#define	SDL_INIT_TIMER		0x00000001
+#define SDL_INIT_AUDIO		0x00000010
+#define SDL_INIT_VIDEO		0x00000020
+#define SDL_INIT_CDROM		0x00000100
+#define SDL_INIT_JOYSTICK	0x00000200
+#define SDL_INIT_NOPARACHUTE	0x00100000	/* Don't catch fatal signals */
+#define SDL_INIT_EVENTTHREAD	0x01000000	/* Not supported on all OS's */
+#define SDL_INIT_EVERYTHING	0x0000FFFF
+
+/* This function loads the SDL dynamically linked library and initializes 
+ * the subsystems specified by 'flags' (and those satisfying dependencies)
+ * Unless the SDL_INIT_NOPARACHUTE flag is set, it will install cleanup
+ * signal handlers for some commonly ignored fatal signals (like SIGSEGV)
+ */
+extern DECLSPEC int SDL_Init(Uint32 flags);
+
+/* This function initializes specific SDL subsystems */
+extern DECLSPEC int SDL_InitSubSystem(Uint32 flags);
+
+/* This function cleans up specific SDL subsystems */
+extern DECLSPEC void SDL_QuitSubSystem(Uint32 flags);
+
+/* This function returns mask of the specified subsystems which have
+   been initialized.
+   If 'flags' is 0, it returns a mask of all initialized subsystems.
+*/
+extern DECLSPEC Uint32 SDL_WasInit(Uint32 flags);
+
+/* This function cleans up all initialized subsystems and unloads the
+ * dynamically linked library.  You should call it upon all exit conditions.
+ */
+extern DECLSPEC void SDL_Quit(void);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_active.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,60 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL application focus event handling */
+
+#ifndef _SDL_active_h
+#define _SDL_active_h
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The available application states */
+#define SDL_APPMOUSEFOCUS	0x01		/* The app has mouse coverage */
+#define SDL_APPINPUTFOCUS	0x02		/* The app has input focus */
+#define SDL_APPACTIVE		0x04		/* The application is active */
+
+/* Function prototypes */
+/* 
+ * This function returns the current state of the application, which is a
+ * bitwise combination of SDL_APPMOUSEFOCUS, SDL_APPINPUTFOCUS, and
+ * SDL_APPACTIVE.  If SDL_APPACTIVE is set, then the user is able to
+ * see your application, otherwise it has been iconified or disabled.
+ */
+extern DECLSPEC Uint8 SDL_GetAppState(void);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_active_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_audio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,260 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Access to the raw audio mixing buffer for the SDL library */
+
+#ifndef _SDL_audio_h
+#define _SDL_audio_h
+
+#include <stdio.h>
+
+#include "SDL_main.h"
+#include "SDL_types.h"
+#include "SDL_error.h"
+#include "SDL_rwops.h"
+#include "SDL_byteorder.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The calculated values in this structure are calculated by SDL_OpenAudio() */
+typedef struct {
+	int freq;		/* DSP frequency -- samples per second */
+	Uint16 format;		/* Audio data format */
+	Uint8  channels;	/* Number of channels: 1 mono, 2 stereo */
+	Uint8  silence;		/* Audio buffer silence value (calculated) */
+	Uint16 samples;		/* Audio buffer size in samples */
+	Uint16 padding;		/* Necessary for some compile environments */
+	Uint32 size;		/* Audio buffer size in bytes (calculated) */
+	/* This function is called when the audio device needs more data.
+	   'stream' is a pointer to the audio data buffer
+	   'len' is the length of that buffer in bytes.
+	   Once the callback returns, the buffer will no longer be valid.
+	   Stereo samples are stored in a LRLRLR ordering.
+	*/
+	void (*callback)(void *userdata, Uint8 *stream, int len);
+	void  *userdata;
+} SDL_AudioSpec;
+
+/* Audio format flags (defaults to LSB byte order) */
+#define AUDIO_U8	0x0008	/* Unsigned 8-bit samples */
+#define AUDIO_S8	0x8008	/* Signed 8-bit samples */
+#define AUDIO_U16LSB	0x0010	/* Unsigned 16-bit samples */
+#define AUDIO_S16LSB	0x8010	/* Signed 16-bit samples */
+#define AUDIO_U16MSB	0x1010	/* As above, but big-endian byte order */
+#define AUDIO_S16MSB	0x9010	/* As above, but big-endian byte order */
+#define AUDIO_U16	AUDIO_U16LSB
+#define AUDIO_S16	AUDIO_S16LSB
+
+/* Native audio byte ordering */
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+#define AUDIO_U16SYS	AUDIO_U16LSB
+#define AUDIO_S16SYS	AUDIO_S16LSB
+#else
+#define AUDIO_U16SYS	AUDIO_U16MSB
+#define AUDIO_S16SYS	AUDIO_S16MSB
+#endif
+
+
+/* A structure to hold a set of audio conversion filters and buffers */
+typedef struct SDL_AudioCVT {
+	int needed;			/* Set to 1 if conversion possible */
+	Uint16 src_format;		/* Source audio format */
+	Uint16 dst_format;		/* Target audio format */
+	double rate_incr;		/* Rate conversion increment */
+	Uint8 *buf;			/* Buffer to hold entire audio data */
+	int    len;			/* Length of original audio buffer */
+	int    len_cvt;			/* Length of converted audio buffer */
+	int    len_mult;		/* buffer must be len*len_mult big */
+	double len_ratio; 	/* Given len, final size is len*len_ratio */
+	void (*filters[10])(struct SDL_AudioCVT *cvt, Uint16 format);
+	int filter_index;		/* Current audio conversion function */
+} SDL_AudioCVT;
+
+
+/* Function prototypes */
+
+/* These functions are used internally, and should not be used unless you
+ * have a specific need to specify the audio driver you want to use.
+ * You should normally use SDL_Init() or SDL_InitSubSystem().
+ */
+extern DECLSPEC int SDL_AudioInit(const char *driver_name);
+extern DECLSPEC void SDL_AudioQuit(void);
+
+/* This function fills the given character buffer with the name of the
+ * current audio driver, and returns a pointer to it if the audio driver has
+ * been initialized.  It returns NULL if no driver has been initialized.
+ */
+extern DECLSPEC char *SDL_AudioDriverName(char *namebuf, int maxlen);
+
+/*
+ * This function opens the audio device with the desired parameters, and
+ * returns 0 if successful, placing the actual hardware parameters in the
+ * structure pointed to by 'obtained'.  If 'obtained' is NULL, the audio
+ * data passed to the callback function will be guaranteed to be in the
+ * requested format, and will be automatically converted to the hardware
+ * audio format if necessary.  This function returns -1 if it failed 
+ * to open the audio device, or couldn't set up the audio thread.
+ *
+ * When filling in the desired audio spec structure,
+ *  'desired->freq' should be the desired audio frequency in samples-per-second.
+ *  'desired->format' should be the desired audio format.
+ *  'desired->samples' is the desired size of the audio buffer, in samples.
+ *     This number should be a power of two, and may be adjusted by the audio
+ *     driver to a value more suitable for the hardware.  Good values seem to
+ *     range between 512 and 8096 inclusive, depending on the application and
+ *     CPU speed.  Smaller values yield faster response time, but can lead
+ *     to underflow if the application is doing heavy processing and cannot
+ *     fill the audio buffer in time.  A stereo sample consists of both right
+ *     and left channels in LR ordering.
+ *     Note that the number of samples is directly related to time by the
+ *     following formula:  ms = (samples*1000)/freq
+ *  'desired->size' is the size in bytes of the audio buffer, and is
+ *     calculated by SDL_OpenAudio().
+ *  'desired->silence' is the value used to set the buffer to silence,
+ *     and is calculated by SDL_OpenAudio().
+ *  'desired->callback' should be set to a function that will be called
+ *     when the audio device is ready for more data.  It is passed a pointer
+ *     to the audio buffer, and the length in bytes of the audio buffer.
+ *     This function usually runs in a separate thread, and so you should
+ *     protect data structures that it accesses by calling SDL_LockAudio()
+ *     and SDL_UnlockAudio() in your code.
+ *  'desired->userdata' is passed as the first parameter to your callback
+ *     function.
+ *
+ * The audio device starts out playing silence when it's opened, and should
+ * be enabled for playing by calling SDL_PauseAudio(0) when you are ready
+ * for your audio callback function to be called.  Since the audio driver
+ * may modify the requested size of the audio buffer, you should allocate
+ * any local mixing buffers after you open the audio device.
+ */
+extern DECLSPEC int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained);
+
+/*
+ * Get the current audio state:
+ */
+typedef enum {
+	SDL_AUDIO_STOPPED = 0,
+	SDL_AUDIO_PLAYING,
+	SDL_AUDIO_PAUSED
+} SDL_audiostatus;
+extern DECLSPEC SDL_audiostatus SDL_GetAudioStatus(void);
+
+/*
+ * This function pauses and unpauses the audio callback processing.
+ * It should be called with a parameter of 0 after opening the audio
+ * device to start playing sound.  This is so you can safely initialize
+ * data for your callback function after opening the audio device.
+ * Silence will be written to the audio device during the pause.
+ */
+extern DECLSPEC void SDL_PauseAudio(int pause_on);
+
+/*
+ * This function loads a WAVE from the data source, automatically freeing
+ * that source if 'freesrc' is non-zero.  For example, to load a WAVE file,
+ * you could do:
+ *	SDL_LoadWAV_RW(SDL_RWFromFile("sample.wav", "rb"), 1, ...);
+ *
+ * If this function succeeds, it returns the given SDL_AudioSpec,
+ * filled with the audio data format of the wave data, and sets
+ * 'audio_buf' to a malloc()'d buffer containing the audio data,
+ * and sets 'audio_len' to the length of that audio buffer, in bytes.
+ * You need to free the audio buffer with SDL_FreeWAV() when you are 
+ * done with it.
+ *
+ * This function returns NULL and sets the SDL error message if the 
+ * wave file cannot be opened, uses an unknown data format, or is 
+ * corrupt.  Currently raw and MS-ADPCM WAVE files are supported.
+ */
+extern DECLSPEC SDL_AudioSpec *SDL_LoadWAV_RW(SDL_RWops *src, int freesrc,
+		 SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len);
+
+/* Compatibility convenience function -- loads a WAV from a file */
+#define SDL_LoadWAV(file, spec, audio_buf, audio_len) \
+	SDL_LoadWAV_RW(SDL_RWFromFile(file, "rb"),1, spec,audio_buf,audio_len)
+
+/*
+ * This function frees data previously allocated with SDL_LoadWAV_RW()
+ */
+extern DECLSPEC void SDL_FreeWAV(Uint8 *audio_buf);
+
+/*
+ * This function takes a source format and rate and a destination format
+ * and rate, and initializes the 'cvt' structure with information needed
+ * by SDL_ConvertAudio() to convert a buffer of audio data from one format
+ * to the other.
+ * This function returns 0, or -1 if there was an error.
+ */
+extern DECLSPEC int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
+		Uint16 src_format, Uint8 src_channels, int src_rate,
+		Uint16 dst_format, Uint8 dst_channels, int dst_rate);
+
+/* Once you have initialized the 'cvt' structure using SDL_BuildAudioCVT(),
+ * created an audio buffer cvt->buf, and filled it with cvt->len bytes of
+ * audio data in the source format, this function will convert it in-place
+ * to the desired format.
+ * The data conversion may expand the size of the audio data, so the buffer
+ * cvt->buf should be allocated after the cvt structure is initialized by
+ * SDL_BuildAudioCVT(), and should be cvt->len*cvt->len_mult bytes long.
+ */
+extern DECLSPEC int SDL_ConvertAudio(SDL_AudioCVT *cvt);
+
+/*
+ * This takes two audio buffers of the playing audio format and mixes
+ * them, performing addition, volume adjustment, and overflow clipping.
+ * The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
+ * for full audio volume.  Note this does not change hardware volume.
+ * This is provided for convenience -- you can mix your own audio data.
+ */
+#define SDL_MIX_MAXVOLUME 128
+extern DECLSPEC void SDL_MixAudio(Uint8 *dst, Uint8 *src, Uint32 len, int volume);
+
+/*
+ * The lock manipulated by these functions protects the callback function.
+ * During a LockAudio/UnlockAudio pair, you can be guaranteed that the
+ * callback function is not running.  Do not call these from the callback
+ * function or you will cause deadlock.
+ */
+extern DECLSPEC void SDL_LockAudio(void);
+extern DECLSPEC void SDL_UnlockAudio(void);
+
+/*
+ * This function shuts down audio processing and closes the audio device.
+ */
+extern DECLSPEC void SDL_CloseAudio(void);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_audio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_byteorder.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,51 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Macros for determining the byte-order of this platform */
+
+#ifndef _SDL_byteorder_h
+#define _SDL_byteorder_h
+
+/* The two types of endianness */
+#define SDL_LIL_ENDIAN	1234
+#define SDL_BIG_ENDIAN	4321
+
+/* Pardon the mess, I'm trying to determine the endianness of this host.
+   I'm doing it by preprocessor defines rather than some sort of configure
+   script so that application code can use this too.  The "right" way would
+   be to dynamically generate this file on install, but that's a lot of work.
+ */
+#if  defined(__i386__) || defined(WIN32) || \
+    (defined(__alpha__) || defined(__alpha)) || \
+     defined(__arm__) || \
+    (defined(__mips__) && defined(__MIPSEL__))
+#define SDL_BYTEORDER	SDL_LIL_ENDIAN
+#else
+#define SDL_BYTEORDER	SDL_BIG_ENDIAN
+#endif
+
+#endif /* _SDL_byteorder_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_cdrom.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,175 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the CD-audio control API for Simple DirectMedia Layer */
+
+#ifndef _SDL_cdrom_h
+#define _SDL_cdrom_h
+
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* In order to use these functions, SDL_Init() must have been called
+   with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
+   for CD-ROM drives, and load appropriate drivers.
+*/
+
+/* The maximum number of CD-ROM tracks on a disk */
+#define SDL_MAX_TRACKS	99
+
+/* The types of CD-ROM track possible */
+#define SDL_AUDIO_TRACK	0x00
+#define SDL_DATA_TRACK	0x04
+
+/* The possible states which a CD-ROM drive can be in. */
+typedef enum {
+	CD_TRAYEMPTY,
+	CD_STOPPED,
+	CD_PLAYING,
+	CD_PAUSED,
+	CD_ERROR = -1
+} CDstatus;
+
+/* Given a status, returns true if there's a disk in the drive */
+#define CD_INDRIVE(status)	((int)status > 0)
+
+typedef struct {
+	Uint8 id;		/* Track number */
+	Uint8 type;		/* Data or audio track */
+	Uint16 unused;
+	Uint32 length;		/* Length, in frames, of this track */
+	Uint32 offset;		/* Offset, in frames, from start of disk */
+} SDL_CDtrack;
+
+/* This structure is only current as of the last call to SDL_CDStatus() */
+typedef struct SDL_CD {
+	int id;			/* Private drive identifier */
+	CDstatus status;	/* Current drive status */
+
+	/* The rest of this structure is only valid if there's a CD in drive */
+	int numtracks;		/* Number of tracks on disk */
+	int cur_track;		/* Current track position */
+	int cur_frame;		/* Current frame offset within current track */
+	SDL_CDtrack track[SDL_MAX_TRACKS+1];
+} SDL_CD;
+
+/* Conversion functions from frames to Minute/Second/Frames and vice versa */
+#define CD_FPS	75
+#define FRAMES_TO_MSF(f, M,S,F)	{					\
+	int value = f;							\
+	*(F) = value%CD_FPS;						\
+	value /= CD_FPS;						\
+	*(S) = value%60;						\
+	value /= 60;							\
+	*(M) = value;							\
+}
+#define MSF_TO_FRAMES(M, S, F)	((M)*60*CD_FPS+(S)*CD_FPS+(F))
+
+/* CD-audio API functions: */
+
+/* Returns the number of CD-ROM drives on the system, or -1 if
+   SDL_Init() has not been called with the SDL_INIT_CDROM flag.
+ */
+extern DECLSPEC int SDL_CDNumDrives(void);
+
+/* Returns a human-readable, system-dependent identifier for the CD-ROM.
+   Example:
+	"/dev/cdrom"
+	"E:"
+	"/dev/disk/ide/1/master"
+*/
+extern DECLSPEC const char * SDL_CDName(int drive);
+
+/* Opens a CD-ROM drive for access.  It returns a drive handle on success,
+   or NULL if the drive was invalid or busy.  This newly opened CD-ROM
+   becomes the default CD used when other CD functions are passed a NULL
+   CD-ROM handle.
+   Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
+*/
+extern DECLSPEC SDL_CD * SDL_CDOpen(int drive);
+
+/* This function returns the current status of the given drive.
+   If the drive has a CD in it, the table of contents of the CD and current
+   play position of the CD will be stored in the SDL_CD structure.
+*/
+extern DECLSPEC CDstatus SDL_CDStatus(SDL_CD *cdrom);
+
+/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
+   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play 
+   until the end of the CD.  This function will skip data tracks.
+   This function should only be called after calling SDL_CDStatus() to 
+   get track information about the CD.
+   For example:
+	// Play entire CD:
+	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
+		SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
+	// Play last track:
+	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+		SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
+	}
+	// Play first and second track and 10 seconds of third track:
+	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
+		SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
+
+   This function returns 0, or -1 if there was an error.
+*/
+extern DECLSPEC int SDL_CDPlayTracks(SDL_CD *cdrom,
+		int start_track, int start_frame, int ntracks, int nframes);
+
+/* Play the given CD starting at 'start' frame for 'length' frames.
+   It returns 0, or -1 if there was an error.
+*/
+extern DECLSPEC int SDL_CDPlay(SDL_CD *cdrom, int start, int length);
+
+/* Pause play -- returns 0, or -1 on error */
+extern DECLSPEC int SDL_CDPause(SDL_CD *cdrom);
+
+/* Resume play -- returns 0, or -1 on error */
+extern DECLSPEC int SDL_CDResume(SDL_CD *cdrom);
+
+/* Stop play -- returns 0, or -1 on error */
+extern DECLSPEC int SDL_CDStop(SDL_CD *cdrom);
+
+/* Eject CD-ROM -- returns 0, or -1 on error */
+extern DECLSPEC int SDL_CDEject(SDL_CD *cdrom);
+
+/* Closes the handle for the CD-ROM drive */
+extern DECLSPEC void SDL_CDClose(SDL_CD *cdrom);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_copying.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_endian.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,149 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for reading and writing endian-specific values */
+
+#ifndef _SDL_endian_h
+#define _SDL_endian_h
+
+/* These functions read and write data of the specified endianness, 
+   dynamically translating to the host machine endianness.
+
+   e.g.: If you want to read a 16 bit value on big-endian machine from
+         an open file containing little endian values, you would use:
+		value = SDL_ReadLE16(rp);
+         Note that the read/write functions use SDL_RWops pointers
+         instead of FILE pointers.  This allows you to read and write
+         endian values from large chunks of memory as well as files 
+         and other data sources.
+*/
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_rwops.h"
+#include "SDL_byteorder.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The macros used to swap values */
+/* Try to use superfast macros on systems that support them */
+#ifdef linux
+#include <asm/byteorder.h>
+#ifdef __arch__swab16
+#define SDL_Swap16  __arch__swab16
+#endif
+#ifdef __arch__swab32
+#define SDL_Swap32  __arch__swab32
+#endif
+#endif /* linux */
+/* Use inline functions for compilers that support them, and static
+   functions for those that do not.  Because these functions become
+   static for compilers that do not support inline functions, this
+   header should only be included in files that actually use them.
+*/
+#ifndef SDL_Swap16
+static __inline__ Uint16 SDL_Swap16(Uint16 D) {
+	return((D<<8)|(D>>8));
+}
+#endif
+#ifndef SDL_Swap32
+static __inline__ Uint32 SDL_Swap32(Uint32 D) {
+	return((D<<24)|((D<<8)&0x00FF0000)|((D>>8)&0x0000FF00)|(D>>24));
+}
+#endif
+#ifdef SDL_HAS_64BIT_TYPE
+#ifndef SDL_Swap64
+static __inline__ Uint64 SDL_Swap64(Uint64 val) {
+	Uint32 hi, lo;
+
+	/* Separate into high and low 32-bit values and swap them */
+	lo = (Uint32)(val&0xFFFFFFFF);
+	val >>= 32;
+	hi = (Uint32)(val&0xFFFFFFFF);
+	val = SDL_Swap32(lo);
+	val <<= 32;
+	val |= SDL_Swap32(hi);
+	return(val);
+}
+#endif
+#else
+#ifndef SDL_Swap64
+/* This is mainly to keep compilers from complaining in SDL code.
+   If there is no real 64-bit datatype, then compilers will complain about
+   the fake 64-bit datatype that SDL provides when it compiles user code.
+*/
+#define SDL_Swap64(X)	(X)
+#endif
+#endif /* SDL_HAS_64BIT_TYPE */
+
+
+/* Byteswap item from the specified endianness to the native endianness */
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+#define SDL_SwapLE16(X)	(X)
+#define SDL_SwapLE32(X)	(X)
+#define SDL_SwapLE64(X)	(X)
+#define SDL_SwapBE16(X)	SDL_Swap16(X)
+#define SDL_SwapBE32(X)	SDL_Swap32(X)
+#define SDL_SwapBE64(X)	SDL_Swap64(X)
+#else
+#define SDL_SwapLE16(X)	SDL_Swap16(X)
+#define SDL_SwapLE32(X)	SDL_Swap32(X)
+#define SDL_SwapLE64(X)	SDL_Swap64(X)
+#define SDL_SwapBE16(X)	(X)
+#define SDL_SwapBE32(X)	(X)
+#define SDL_SwapBE64(X)	(X)
+#endif
+
+/* Read an item of the specified endianness and return in native format */
+extern DECLSPEC Uint16 SDL_ReadLE16(SDL_RWops *src);
+extern DECLSPEC Uint16 SDL_ReadBE16(SDL_RWops *src);
+extern DECLSPEC Uint32 SDL_ReadLE32(SDL_RWops *src);
+extern DECLSPEC Uint32 SDL_ReadBE32(SDL_RWops *src);
+extern DECLSPEC Uint64 SDL_ReadLE64(SDL_RWops *src);
+extern DECLSPEC Uint64 SDL_ReadBE64(SDL_RWops *src);
+
+/* Write an item of native format to the specified endianness */
+extern DECLSPEC int SDL_WriteLE16(SDL_RWops *dst, Uint16 value);
+extern DECLSPEC int SDL_WriteBE16(SDL_RWops *dst, Uint16 value);
+extern DECLSPEC int SDL_WriteLE32(SDL_RWops *dst, Uint32 value);
+extern DECLSPEC int SDL_WriteBE32(SDL_RWops *dst, Uint32 value);
+extern DECLSPEC int SDL_WriteLE64(SDL_RWops *dst, Uint64 value);
+extern DECLSPEC int SDL_WriteBE64(SDL_RWops *dst, Uint64 value);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_endian_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_error.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,62 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Simple error message routines for SDL */
+
+#ifndef _SDL_error_h
+#define _SDL_error_h
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Public functions */
+extern DECLSPEC void SDL_SetError(const char *fmt, ...);
+extern DECLSPEC char * SDL_GetError(void);
+extern DECLSPEC void SDL_ClearError(void);
+
+/* Private error message function - used internally */
+#define SDL_OutOfMemory()	SDL_Error(SDL_ENOMEM)
+typedef enum {
+	SDL_ENOMEM,
+	SDL_EFREAD,
+	SDL_EFWRITE,
+	SDL_EFSEEK,
+	SDL_LASTERROR
+} SDL_errorcode;
+extern void SDL_Error(SDL_errorcode code);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_error_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_events.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,334 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL event handling */
+
+#ifndef _SDL_events_h
+#define _SDL_events_h
+
+#include "SDL_types.h"
+#include "SDL_active.h"
+#include "SDL_keyboard.h"
+#include "SDL_mouse.h"
+#include "SDL_joystick.h"
+#include "SDL_quit.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Event enumerations */
+enum { SDL_NOEVENT = 0,			/* Unused (do not remove) */
+       SDL_ACTIVEEVENT,			/* Application loses/gains visibility */
+       SDL_KEYDOWN,			/* Keys pressed */
+       SDL_KEYUP,			/* Keys released */
+       SDL_MOUSEMOTION,			/* Mouse moved */
+       SDL_MOUSEBUTTONDOWN,		/* Mouse button pressed */
+       SDL_MOUSEBUTTONUP,		/* Mouse button released */
+       SDL_JOYAXISMOTION,		/* Joystick axis motion */
+       SDL_JOYBALLMOTION,		/* Joystick trackball motion */
+       SDL_JOYHATMOTION,		/* Joystick hat position change */
+       SDL_JOYBUTTONDOWN,		/* Joystick button pressed */
+       SDL_JOYBUTTONUP,			/* Joystick button released */
+       SDL_QUIT,			/* User-requested quit */
+       SDL_SYSWMEVENT,			/* System specific event */
+       SDL_EVENT_RESERVEDA,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVEDB,		/* Reserved for future use.. */
+       SDL_VIDEORESIZE,			/* User resized video mode */
+       SDL_VIDEOEXPOSE,			/* Screen needs to be redrawn */
+       SDL_EVENT_RESERVED2,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVED3,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVED4,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVED5,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVED6,		/* Reserved for future use.. */
+       SDL_EVENT_RESERVED7,		/* Reserved for future use.. */
+       /* Events SDL_USEREVENT through SDL_MAXEVENTS-1 are for your use */
+       SDL_USEREVENT = 24,
+       /* This last event is only for bounding internal arrays
+	  It is the number of bits in the event mask datatype -- Uint32
+        */
+       SDL_NUMEVENTS = 32
+};
+
+/* Predefined event masks */
+#define SDL_EVENTMASK(X)	(1<<(X))
+enum {
+	SDL_ACTIVEEVENTMASK	= SDL_EVENTMASK(SDL_ACTIVEEVENT),
+	SDL_KEYDOWNMASK		= SDL_EVENTMASK(SDL_KEYDOWN),
+	SDL_KEYUPMASK		= SDL_EVENTMASK(SDL_KEYUP),
+	SDL_MOUSEMOTIONMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION),
+	SDL_MOUSEBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN),
+	SDL_MOUSEBUTTONUPMASK	= SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
+	SDL_MOUSEEVENTMASK	= SDL_EVENTMASK(SDL_MOUSEMOTION)|
+	                          SDL_EVENTMASK(SDL_MOUSEBUTTONDOWN)|
+	                          SDL_EVENTMASK(SDL_MOUSEBUTTONUP),
+	SDL_JOYAXISMOTIONMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION),
+	SDL_JOYBALLMOTIONMASK	= SDL_EVENTMASK(SDL_JOYBALLMOTION),
+	SDL_JOYHATMOTIONMASK	= SDL_EVENTMASK(SDL_JOYHATMOTION),
+	SDL_JOYBUTTONDOWNMASK	= SDL_EVENTMASK(SDL_JOYBUTTONDOWN),
+	SDL_JOYBUTTONUPMASK	= SDL_EVENTMASK(SDL_JOYBUTTONUP),
+	SDL_JOYEVENTMASK	= SDL_EVENTMASK(SDL_JOYAXISMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYBALLMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYHATMOTION)|
+	                          SDL_EVENTMASK(SDL_JOYBUTTONDOWN)|
+	                          SDL_EVENTMASK(SDL_JOYBUTTONUP),
+	SDL_VIDEORESIZEMASK	= SDL_EVENTMASK(SDL_VIDEORESIZE),
+	SDL_VIDEOEXPOSEMASK	= SDL_EVENTMASK(SDL_VIDEOEXPOSE),
+	SDL_QUITMASK		= SDL_EVENTMASK(SDL_QUIT),
+	SDL_SYSWMEVENTMASK	= SDL_EVENTMASK(SDL_SYSWMEVENT)
+};
+#define SDL_ALLEVENTS		0xFFFFFFFF
+
+/* Application visibility event structure */
+typedef struct {
+	Uint8 type;	/* SDL_ACTIVEEVENT */
+	Uint8 gain;	/* Whether given states were gained or lost (1/0) */
+	Uint8 state;	/* A mask of the focus states */
+} SDL_ActiveEvent;
+
+/* Keyboard event structure */
+typedef struct {
+	Uint8 type;	/* SDL_KEYDOWN or SDL_KEYUP */
+	Uint8 which;	/* The keyboard device index */
+	Uint8 state;	/* SDL_PRESSED or SDL_RELEASED */
+	SDL_keysym keysym;
+} SDL_KeyboardEvent;
+
+/* Mouse motion event structure */
+typedef struct {
+	Uint8 type;	/* SDL_MOUSEMOTION */
+	Uint8 which;	/* The mouse device index */
+	Uint8 state;	/* The current button state */
+	Uint16 x, y;	/* The X/Y coordinates of the mouse */
+	Sint16 xrel;	/* The relative motion in the X direction */
+	Sint16 yrel;	/* The relative motion in the Y direction */
+} SDL_MouseMotionEvent;
+
+/* Mouse button event structure */
+typedef struct {
+	Uint8 type;	/* SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP */
+	Uint8 which;	/* The mouse device index */
+	Uint8 button;	/* The mouse button index */
+	Uint8 state;	/* SDL_PRESSED or SDL_RELEASED */
+	Uint16 x, y;	/* The X/Y coordinates of the mouse at press time */
+} SDL_MouseButtonEvent;
+
+/* Joystick axis motion event structure */
+typedef struct {
+	Uint8 type;	/* SDL_JOYAXISMOTION */
+	Uint8 which;	/* The joystick device index */
+	Uint8 axis;	/* The joystick axis index */
+	Sint16 value;	/* The axis value (range: -32768 to 32767) */
+} SDL_JoyAxisEvent;
+
+/* Joystick trackball motion event structure */
+typedef struct {
+	Uint8 type;	/* SDL_JOYBALLMOTION */
+	Uint8 which;	/* The joystick device index */
+	Uint8 ball;	/* The joystick trackball index */
+	Sint16 xrel;	/* The relative motion in the X direction */
+	Sint16 yrel;	/* The relative motion in the Y direction */
+} SDL_JoyBallEvent;
+
+/* Joystick hat position change event structure */
+typedef struct {
+	Uint8 type;	/* SDL_JOYHATMOTION */
+	Uint8 which;	/* The joystick device index */
+	Uint8 hat;	/* The joystick hat index */
+	Uint8 value;	/* The hat position value:
+				8   1   2
+				7   0   3
+				6   5   4
+			   Note that zero means the POV is centered.
+			*/
+} SDL_JoyHatEvent;
+
+/* Joystick button event structure */
+typedef struct {
+	Uint8 type;	/* SDL_JOYBUTTONDOWN or SDL_JOYBUTTONUP */
+	Uint8 which;	/* The joystick device index */
+	Uint8 button;	/* The joystick button index */
+	Uint8 state;	/* SDL_PRESSED or SDL_RELEASED */
+} SDL_JoyButtonEvent;
+
+/* The "window resized" event
+   When you get this event, you are responsible for setting a new video
+   mode with the new width and height.
+ */
+typedef struct {
+	Uint8 type;	/* SDL_VIDEORESIZE */
+	int w;		/* New width */
+	int h;		/* New height */
+} SDL_ResizeEvent;
+
+/* The "screen redraw" event */
+typedef struct {
+	Uint8 type;	/* SDL_VIDEOEXPOSE */
+} SDL_ExposeEvent;
+
+/* The "quit requested" event */
+typedef struct {
+	Uint8 type;	/* SDL_QUIT */
+} SDL_QuitEvent;
+
+/* A user-defined event type */
+typedef struct {
+	Uint8 type;	/* SDL_USEREVENT through SDL_NUMEVENTS-1 */
+	int code;	/* User defined event code */
+	void *data1;	/* User defined data pointer */
+	void *data2;	/* User defined data pointer */
+} SDL_UserEvent;
+
+/* If you want to use this event, you should include SDL_syswm.h */
+struct SDL_SysWMmsg;
+typedef struct SDL_SysWMmsg SDL_SysWMmsg;
+typedef struct {
+	Uint8 type;
+	SDL_SysWMmsg *msg;
+} SDL_SysWMEvent;
+
+/* General event structure */
+typedef union {
+	Uint8 type;
+	SDL_ActiveEvent active;
+	SDL_KeyboardEvent key;
+	SDL_MouseMotionEvent motion;
+	SDL_MouseButtonEvent button;
+	SDL_JoyAxisEvent jaxis;
+	SDL_JoyBallEvent jball;
+	SDL_JoyHatEvent jhat;
+	SDL_JoyButtonEvent jbutton;
+	SDL_ResizeEvent resize;
+	SDL_ExposeEvent expose;
+	SDL_QuitEvent quit;
+	SDL_UserEvent user;
+	SDL_SysWMEvent syswm;
+} SDL_Event;
+
+
+/* Function prototypes */
+
+/* Pumps the event loop, gathering events from the input devices.
+   This function updates the event queue and internal input device state.
+   This should only be run in the thread that sets the video mode.
+*/
+extern DECLSPEC void SDL_PumpEvents(void);
+
+/* Checks the event queue for messages and optionally returns them.
+   If 'action' is SDL_ADDEVENT, up to 'numevents' events will be added to
+   the back of the event queue.
+   If 'action' is SDL_PEEKEVENT, up to 'numevents' events at the front
+   of the event queue, matching 'mask', will be returned and will not
+   be removed from the queue.
+   If 'action' is SDL_GETEVENT, up to 'numevents' events at the front 
+   of the event queue, matching 'mask', will be returned and will be
+   removed from the queue.
+   This function returns the number of events actually stored, or -1
+   if there was an error.  This function is thread-safe.
+*/
+typedef enum {
+	SDL_ADDEVENT,
+	SDL_PEEKEVENT,
+	SDL_GETEVENT
+} SDL_eventaction;
+/* */
+extern DECLSPEC int SDL_PeepEvents(SDL_Event *events, int numevents,
+				SDL_eventaction action, Uint32 mask);
+
+/* Polls for currently pending events, and returns 1 if there are any pending
+   events, or 0 if there are none available.  If 'event' is not NULL, the next
+   event is removed from the queue and stored in that area.
+ */
+extern DECLSPEC int SDL_PollEvent(SDL_Event *event);
+
+/* Waits indefinitely for the next available event, returning 1, or 0 if there
+   was an error while waiting for events.  If 'event' is not NULL, the next
+   event is removed from the queue and stored in that area.
+ */
+extern DECLSPEC int SDL_WaitEvent(SDL_Event *event);
+
+/* Add an event to the event queue.
+   This function returns 0, or -1 if the event couldn't be added to
+   the event queue.  If the event queue is full, this function fails.
+ */
+extern DECLSPEC int SDL_PushEvent(SDL_Event *event);
+
+/*
+  This function sets up a filter to process all events before they
+  change internal state and are posted to the internal event queue.
+
+  The filter is protypted as:
+*/
+typedef int (*SDL_EventFilter)(const SDL_Event *event);
+/*
+  If the filter returns 1, then the event will be added to the internal queue.
+  If it returns 0, then the event will be dropped from the queue, but the 
+  internal state will still be updated.  This allows selective filtering of
+  dynamically arriving events.
+
+  WARNING:  Be very careful of what you do in the event filter function, as 
+            it may run in a different thread!
+
+  There is one caveat when dealing with the SDL_QUITEVENT event type.  The
+  event filter is only called when the window manager desires to close the
+  application window.  If the event filter returns 1, then the window will
+  be closed, otherwise the window will remain open if possible.
+  If the quit event is generated by an interrupt signal, it will bypass the
+  internal queue and be delivered to the application at the next event poll.
+*/
+extern DECLSPEC void SDL_SetEventFilter(SDL_EventFilter filter);
+
+/*
+  Return the current event filter - can be used to "chain" filters.
+  If there is no event filter set, this function returns NULL.
+*/
+extern DECLSPEC SDL_EventFilter SDL_GetEventFilter(void);
+
+/*
+  This function allows you to set the state of processing certain events.
+  If 'state' is set to SDL_IGNORE, that event will be automatically dropped
+  from the event queue and will not event be filtered.
+  If 'state' is set to SDL_ENABLE, that event will be processed normally.
+  If 'state' is set to SDL_QUERY, SDL_EventState() will return the 
+  current processing state of the specified event.
+*/
+#define SDL_QUERY	-1
+#define SDL_IGNORE	 0
+#define SDL_DISABLE	 0
+#define SDL_ENABLE	 1
+extern DECLSPEC Uint8 SDL_EventState(Uint8 type, int state);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_events_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_getenv.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+
+/* Not all environments have a working getenv()/putenv() */
+
+#if defined(macintosh) || defined(_WIN32_WCE)
+#define NEED_SDL_GETENV
+#endif
+
+#ifdef NEED_SDL_GETENV
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Put a variable of the form "name=value" into the environment */
+extern DECLSPEC int SDL_putenv(const char *variable);
+#define putenv(X)   SDL_putenv(X)
+
+/* Retrieve a variable named "name" from the environment */
+extern DECLSPEC char *SDL_getenv(const char *name);
+#define getenv(X)     SDL_getenv(X)
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* NEED_GETENV */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_joystick.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,171 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL joystick event handling */
+
+#ifndef _SDL_joystick_h
+#define _SDL_joystick_h
+
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* In order to use these functions, SDL_Init() must have been called
+   with the SDL_INIT_JOYSTICK flag.  This causes SDL to scan the system
+   for joysticks, and load appropriate drivers.
+*/
+
+/* The joystick structure used to identify an SDL joystick */
+struct _SDL_Joystick;
+typedef struct _SDL_Joystick SDL_Joystick;
+
+
+/* Function prototypes */
+/*
+ * Count the number of joysticks attached to the system
+ */
+extern DECLSPEC int SDL_NumJoysticks(void);
+
+/*
+ * Get the implementation dependent name of a joystick.
+ * This can be called before any joysticks are opened.
+ * If no name can be found, this function returns NULL.
+ */
+extern DECLSPEC const char *SDL_JoystickName(int device_index);
+
+/*
+ * Open a joystick for use - the index passed as an argument refers to
+ * the N'th joystick on the system.  This index is the value which will
+ * identify this joystick in future joystick events.
+ *
+ * This function returns a joystick identifier, or NULL if an error occurred.
+ */
+extern DECLSPEC SDL_Joystick *SDL_JoystickOpen(int device_index);
+
+/*
+ * Returns 1 if the joystick has been opened, or 0 if it has not.
+ */
+extern DECLSPEC int SDL_JoystickOpened(int device_index);
+
+/*
+ * Get the device index of an opened joystick.
+ */
+extern DECLSPEC int SDL_JoystickIndex(SDL_Joystick *joystick);
+
+/*
+ * Get the number of general axis controls on a joystick
+ */
+extern DECLSPEC int SDL_JoystickNumAxes(SDL_Joystick *joystick);
+
+/*
+ * Get the number of trackballs on a joystick
+ * Joystick trackballs have only relative motion events associated
+ * with them and their state cannot be polled.
+ */
+extern DECLSPEC int SDL_JoystickNumBalls(SDL_Joystick *joystick);
+
+/*
+ * Get the number of POV hats on a joystick
+ */
+extern DECLSPEC int SDL_JoystickNumHats(SDL_Joystick *joystick);
+
+/*
+ * Get the number of buttons on a joystick
+ */
+extern DECLSPEC int SDL_JoystickNumButtons(SDL_Joystick *joystick);
+
+/*
+ * Update the current state of the open joysticks.
+ * This is called automatically by the event loop if any joystick
+ * events are enabled.
+ */
+extern DECLSPEC void SDL_JoystickUpdate(void);
+
+/*
+ * Enable/disable joystick event polling.
+ * If joystick events are disabled, you must call SDL_JoystickUpdate()
+ * yourself and check the state of the joystick when you want joystick
+ * information.
+ * The state can be one of SDL_QUERY, SDL_ENABLE or SDL_IGNORE.
+ */
+extern DECLSPEC int SDL_JoystickEventState(int state);
+
+/*
+ * Get the current state of an axis control on a joystick
+ * The state is a value ranging from -32768 to 32767.
+ * The axis indices start at index 0.
+ */
+extern DECLSPEC Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis);
+
+/*
+ * Get the current state of a POV hat on a joystick
+ * The return value is one of the following positions:
+ */
+#define SDL_HAT_CENTERED	0x00
+#define SDL_HAT_UP		0x01
+#define SDL_HAT_RIGHT		0x02
+#define SDL_HAT_DOWN		0x04
+#define SDL_HAT_LEFT		0x08
+#define SDL_HAT_RIGHTUP		(SDL_HAT_RIGHT|SDL_HAT_UP)
+#define SDL_HAT_RIGHTDOWN	(SDL_HAT_RIGHT|SDL_HAT_DOWN)
+#define SDL_HAT_LEFTUP		(SDL_HAT_LEFT|SDL_HAT_UP)
+#define SDL_HAT_LEFTDOWN	(SDL_HAT_LEFT|SDL_HAT_DOWN)
+/*
+ * The hat indices start at index 0.
+ */
+extern DECLSPEC Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat);
+
+/*
+ * Get the ball axis change since the last poll
+ * This returns 0, or -1 if you passed it invalid parameters.
+ * The ball indices start at index 0.
+ */
+extern DECLSPEC int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy);
+
+/*
+ * Get the current state of a button on a joystick
+ * The button indices start at index 0.
+ */
+extern DECLSPEC Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button);
+
+/*
+ * Close a joystick previously opened with SDL_JoystickOpen()
+ */
+extern DECLSPEC void SDL_JoystickClose(SDL_Joystick *joystick);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_joystick_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_keyboard.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,124 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL keyboard event handling */
+
+#ifndef _SDL_keyboard_h
+#define _SDL_keyboard_h
+
+#include "SDL_types.h"
+#include "SDL_keysym.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Keysym structure
+   - The scancode is hardware dependent, and should not be used by general
+     applications.  If no hardware scancode is available, it will be 0.
+
+   - The 'unicode' translated character is only available when character
+     translation is enabled by the SDL_EnableUNICODE() API.  If non-zero,
+     this is a UNICODE character corresponding to the keypress.  If the
+     high 9 bits of the character are 0, then this maps to the equivalent
+     ASCII character:
+	char ch;
+	if ( (keysym.unicode & 0xFF80) == 0 ) {
+		ch = keysym.unicode & 0x7F;
+	} else {
+		An international character..
+	}
+ */
+typedef struct {
+	Uint8 scancode;			/* hardware specific scancode */
+	SDLKey sym;			/* SDL virtual keysym */
+	SDLMod mod;			/* current key modifiers */
+	Uint16 unicode;			/* translated character */
+} SDL_keysym;
+
+/* This is the mask which refers to all hotkey bindings */
+#define SDL_ALL_HOTKEYS		0xFFFFFFFF
+
+/* Function prototypes */
+/*
+ * Enable/Disable UNICODE translation of keyboard input.
+ * This translation has some overhead, so translation defaults off.
+ * If 'enable' is 1, translation is enabled.
+ * If 'enable' is 0, translation is disabled.
+ * If 'enable' is -1, the translation state is not changed.
+ * It returns the previous state of keyboard translation.
+ */
+extern DECLSPEC int SDL_EnableUNICODE(int enable);
+
+/*
+ * Enable/Disable keyboard repeat.  Keyboard repeat defaults to off.
+ * 'delay' is the initial delay in ms between the time when a key is
+ * pressed, and keyboard repeat begins.
+ * 'interval' is the time in ms between keyboard repeat events.
+ */
+#define SDL_DEFAULT_REPEAT_DELAY	500
+#define SDL_DEFAULT_REPEAT_INTERVAL	30
+/*
+ * If 'delay' is set to 0, keyboard repeat is disabled.
+ */
+extern DECLSPEC int SDL_EnableKeyRepeat(int delay, int interval);
+
+/*
+ * Get a snapshot of the current state of the keyboard.
+ * Returns an array of keystates, indexed by the SDLK_* syms.
+ * Used:
+ * 	Uint8 *keystate = SDL_GetKeyState(NULL);
+ *	if ( keystate[SDLK_RETURN] ) ... <RETURN> is pressed.
+ */
+extern DECLSPEC Uint8 * SDL_GetKeyState(int *numkeys);
+
+/*
+ * Get the current key modifier state
+ */
+extern DECLSPEC SDLMod SDL_GetModState(void);
+
+/*
+ * Set the current key modifier state
+ * This does not change the keyboard state, only the key modifier flags.
+ */
+extern DECLSPEC void SDL_SetModState(SDLMod modstate);
+
+/*
+ * Get the name of an SDL virtual keysym
+ */
+extern DECLSPEC char * SDL_GetKeyName(SDLKey key);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_keyboard_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_keysym.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,315 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_keysym_h
+#define _SDL_keysym_h
+
+/* What we really want is a mapping of every raw key on the keyboard.
+   To support international keyboards, we use the range 0xA1 - 0xFF
+   as international virtual keycodes.  We'll follow in the footsteps of X11...
+   The names of the keys
+ */
+ 
+typedef enum {
+	/* The keyboard syms have been cleverly chosen to map to ASCII */
+	SDLK_UNKNOWN		= 0,
+	SDLK_FIRST		= 0,
+	SDLK_BACKSPACE		= 8,
+	SDLK_TAB		= 9,
+	SDLK_CLEAR		= 12,
+	SDLK_RETURN		= 13,
+	SDLK_PAUSE		= 19,
+	SDLK_ESCAPE		= 27,
+	SDLK_SPACE		= 32,
+	SDLK_EXCLAIM		= 33,
+	SDLK_QUOTEDBL		= 34,
+	SDLK_HASH		= 35,
+	SDLK_DOLLAR		= 36,
+	SDLK_AMPERSAND		= 38,
+	SDLK_QUOTE		= 39,
+	SDLK_LEFTPAREN		= 40,
+	SDLK_RIGHTPAREN		= 41,
+	SDLK_ASTERISK		= 42,
+	SDLK_PLUS		= 43,
+	SDLK_COMMA		= 44,
+	SDLK_MINUS		= 45,
+	SDLK_PERIOD		= 46,
+	SDLK_SLASH		= 47,
+	SDLK_0			= 48,
+	SDLK_1			= 49,
+	SDLK_2			= 50,
+	SDLK_3			= 51,
+	SDLK_4			= 52,
+	SDLK_5			= 53,
+	SDLK_6			= 54,
+	SDLK_7			= 55,
+	SDLK_8			= 56,
+	SDLK_9			= 57,
+	SDLK_COLON		= 58,
+	SDLK_SEMICOLON		= 59,
+	SDLK_LESS		= 60,
+	SDLK_EQUALS		= 61,
+	SDLK_GREATER		= 62,
+	SDLK_QUESTION		= 63,
+	SDLK_AT			= 64,
+	/* 
+	   Skip uppercase letters
+	 */
+	SDLK_LEFTBRACKET	= 91,
+	SDLK_BACKSLASH		= 92,
+	SDLK_RIGHTBRACKET	= 93,
+	SDLK_CARET		= 94,
+	SDLK_UNDERSCORE		= 95,
+	SDLK_BACKQUOTE		= 96,
+	SDLK_a			= 97,
+	SDLK_b			= 98,
+	SDLK_c			= 99,
+	SDLK_d			= 100,
+	SDLK_e			= 101,
+	SDLK_f			= 102,
+	SDLK_g			= 103,
+	SDLK_h			= 104,
+	SDLK_i			= 105,
+	SDLK_j			= 106,
+	SDLK_k			= 107,
+	SDLK_l			= 108,
+	SDLK_m			= 109,
+	SDLK_n			= 110,
+	SDLK_o			= 111,
+	SDLK_p			= 112,
+	SDLK_q			= 113,
+	SDLK_r			= 114,
+	SDLK_s			= 115,
+	SDLK_t			= 116,
+	SDLK_u			= 117,
+	SDLK_v			= 118,
+	SDLK_w			= 119,
+	SDLK_x			= 120,
+	SDLK_y			= 121,
+	SDLK_z			= 122,
+	SDLK_DELETE		= 127,
+	/* End of ASCII mapped keysyms */
+
+	/* International keyboard syms */
+	SDLK_WORLD_0		= 160,		/* 0xA0 */
+	SDLK_WORLD_1		= 161,
+	SDLK_WORLD_2		= 162,
+	SDLK_WORLD_3		= 163,
+	SDLK_WORLD_4		= 164,
+	SDLK_WORLD_5		= 165,
+	SDLK_WORLD_6		= 166,
+	SDLK_WORLD_7		= 167,
+	SDLK_WORLD_8		= 168,
+	SDLK_WORLD_9		= 169,
+	SDLK_WORLD_10		= 170,
+	SDLK_WORLD_11		= 171,
+	SDLK_WORLD_12		= 172,
+	SDLK_WORLD_13		= 173,
+	SDLK_WORLD_14		= 174,
+	SDLK_WORLD_15		= 175,
+	SDLK_WORLD_16		= 176,
+	SDLK_WORLD_17		= 177,
+	SDLK_WORLD_18		= 178,
+	SDLK_WORLD_19		= 179,
+	SDLK_WORLD_20		= 180,
+	SDLK_WORLD_21		= 181,
+	SDLK_WORLD_22		= 182,
+	SDLK_WORLD_23		= 183,
+	SDLK_WORLD_24		= 184,
+	SDLK_WORLD_25		= 185,
+	SDLK_WORLD_26		= 186,
+	SDLK_WORLD_27		= 187,
+	SDLK_WORLD_28		= 188,
+	SDLK_WORLD_29		= 189,
+	SDLK_WORLD_30		= 190,
+	SDLK_WORLD_31		= 191,
+	SDLK_WORLD_32		= 192,
+	SDLK_WORLD_33		= 193,
+	SDLK_WORLD_34		= 194,
+	SDLK_WORLD_35		= 195,
+	SDLK_WORLD_36		= 196,
+	SDLK_WORLD_37		= 197,
+	SDLK_WORLD_38		= 198,
+	SDLK_WORLD_39		= 199,
+	SDLK_WORLD_40		= 200,
+	SDLK_WORLD_41		= 201,
+	SDLK_WORLD_42		= 202,
+	SDLK_WORLD_43		= 203,
+	SDLK_WORLD_44		= 204,
+	SDLK_WORLD_45		= 205,
+	SDLK_WORLD_46		= 206,
+	SDLK_WORLD_47		= 207,
+	SDLK_WORLD_48		= 208,
+	SDLK_WORLD_49		= 209,
+	SDLK_WORLD_50		= 210,
+	SDLK_WORLD_51		= 211,
+	SDLK_WORLD_52		= 212,
+	SDLK_WORLD_53		= 213,
+	SDLK_WORLD_54		= 214,
+	SDLK_WORLD_55		= 215,
+	SDLK_WORLD_56		= 216,
+	SDLK_WORLD_57		= 217,
+	SDLK_WORLD_58		= 218,
+	SDLK_WORLD_59		= 219,
+	SDLK_WORLD_60		= 220,
+	SDLK_WORLD_61		= 221,
+	SDLK_WORLD_62		= 222,
+	SDLK_WORLD_63		= 223,
+	SDLK_WORLD_64		= 224,
+	SDLK_WORLD_65		= 225,
+	SDLK_WORLD_66		= 226,
+	SDLK_WORLD_67		= 227,
+	SDLK_WORLD_68		= 228,
+	SDLK_WORLD_69		= 229,
+	SDLK_WORLD_70		= 230,
+	SDLK_WORLD_71		= 231,
+	SDLK_WORLD_72		= 232,
+	SDLK_WORLD_73		= 233,
+	SDLK_WORLD_74		= 234,
+	SDLK_WORLD_75		= 235,
+	SDLK_WORLD_76		= 236,
+	SDLK_WORLD_77		= 237,
+	SDLK_WORLD_78		= 238,
+	SDLK_WORLD_79		= 239,
+	SDLK_WORLD_80		= 240,
+	SDLK_WORLD_81		= 241,
+	SDLK_WORLD_82		= 242,
+	SDLK_WORLD_83		= 243,
+	SDLK_WORLD_84		= 244,
+	SDLK_WORLD_85		= 245,
+	SDLK_WORLD_86		= 246,
+	SDLK_WORLD_87		= 247,
+	SDLK_WORLD_88		= 248,
+	SDLK_WORLD_89		= 249,
+	SDLK_WORLD_90		= 250,
+	SDLK_WORLD_91		= 251,
+	SDLK_WORLD_92		= 252,
+	SDLK_WORLD_93		= 253,
+	SDLK_WORLD_94		= 254,
+	SDLK_WORLD_95		= 255,		/* 0xFF */
+
+	/* Numeric keypad */
+	SDLK_KP0		= 256,
+	SDLK_KP1		= 257,
+	SDLK_KP2		= 258,
+	SDLK_KP3		= 259,
+	SDLK_KP4		= 260,
+	SDLK_KP5		= 261,
+	SDLK_KP6		= 262,
+	SDLK_KP7		= 263,
+	SDLK_KP8		= 264,
+	SDLK_KP9		= 265,
+	SDLK_KP_PERIOD		= 266,
+	SDLK_KP_DIVIDE		= 267,
+	SDLK_KP_MULTIPLY	= 268,
+	SDLK_KP_MINUS		= 269,
+	SDLK_KP_PLUS		= 270,
+	SDLK_KP_ENTER		= 271,
+	SDLK_KP_EQUALS		= 272,
+
+	/* Arrows + Home/End pad */
+	SDLK_UP			= 273,
+	SDLK_DOWN		= 274,
+	SDLK_RIGHT		= 275,
+	SDLK_LEFT		= 276,
+	SDLK_INSERT		= 277,
+	SDLK_HOME		= 278,
+	SDLK_END		= 279,
+	SDLK_PAGEUP		= 280,
+	SDLK_PAGEDOWN		= 281,
+
+	/* Function keys */
+	SDLK_F1			= 282,
+	SDLK_F2			= 283,
+	SDLK_F3			= 284,
+	SDLK_F4			= 285,
+	SDLK_F5			= 286,
+	SDLK_F6			= 287,
+	SDLK_F7			= 288,
+	SDLK_F8			= 289,
+	SDLK_F9			= 290,
+	SDLK_F10		= 291,
+	SDLK_F11		= 292,
+	SDLK_F12		= 293,
+	SDLK_F13		= 294,
+	SDLK_F14		= 295,
+	SDLK_F15		= 296,
+
+	/* Key state modifier keys */
+	SDLK_NUMLOCK		= 300,
+	SDLK_CAPSLOCK		= 301,
+	SDLK_SCROLLOCK		= 302,
+	SDLK_RSHIFT		= 303,
+	SDLK_LSHIFT		= 304,
+	SDLK_RCTRL		= 305,
+	SDLK_LCTRL		= 306,
+	SDLK_RALT		= 307,
+	SDLK_LALT		= 308,
+	SDLK_RMETA		= 309,
+	SDLK_LMETA		= 310,
+	SDLK_LSUPER		= 311,		/* Left "Windows" key */
+	SDLK_RSUPER		= 312,		/* Right "Windows" key */
+	SDLK_MODE		= 313,		/* "Alt Gr" key */
+	SDLK_COMPOSE		= 314,		/* Multi-key compose key */
+
+	/* Miscellaneous function keys */
+	SDLK_HELP		= 315,
+	SDLK_PRINT		= 316,
+	SDLK_SYSREQ		= 317,
+	SDLK_BREAK		= 318,
+	SDLK_MENU		= 319,
+	SDLK_POWER		= 320,		/* Power Macintosh power key */
+	SDLK_EURO		= 321,		/* Some european keyboards */
+
+	/* Add any other keys here */
+
+	SDLK_LAST
+} SDLKey;
+
+/* Enumeration of valid key mods (possibly OR'd together) */
+typedef enum {
+	KMOD_NONE  = 0x0000,
+	KMOD_LSHIFT= 0x0001,
+	KMOD_RSHIFT= 0x0002,
+	KMOD_LCTRL = 0x0040,
+	KMOD_RCTRL = 0x0080,
+	KMOD_LALT  = 0x0100,
+	KMOD_RALT  = 0x0200,
+	KMOD_LMETA = 0x0400,
+	KMOD_RMETA = 0x0800,
+	KMOD_NUM   = 0x1000,
+	KMOD_CAPS  = 0x2000,
+	KMOD_MODE  = 0x4000,
+	KMOD_RESERVED = 0x8000
+} SDLMod;
+
+#define KMOD_CTRL	(KMOD_LCTRL|KMOD_RCTRL)
+#define KMOD_SHIFT	(KMOD_LSHIFT|KMOD_RSHIFT)
+#define KMOD_ALT	(KMOD_LALT|KMOD_RALT)
+#define KMOD_META	(KMOD_LMETA|KMOD_RMETA)
+
+#endif /* _SDL_keysym_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_main.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,97 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_main_h
+#define _SDL_main_h
+
+/* Redefine main() on Win32 and MacOS so that it is called by winmain.c */
+
+#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \
+    defined(macintosh)
+
+#ifdef __cplusplus
+#define C_LINKAGE	"C"
+#else
+#define C_LINKAGE
+#endif /* __cplusplus */
+
+/* The application's main() function must be called with C linkage,
+   and should be declared like this:
+#ifdef __cplusplus
+extern "C"
+#endif
+	int main(int argc, char *argv[])
+	{
+	}
+ */
+#define main	SDL_main
+
+/* The prototype for the application's main() function */
+extern C_LINKAGE int SDL_main(int argc, char *argv[]);
+
+
+/* From the SDL library code -- needed for registering the app on Win32 */
+#if defined(WIN32)
+#include "SDL_types.h"
+#include "begin_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This should be called from your WinMain() function, if any */
+extern DECLSPEC int SDL_RegisterApp(char *name, Uint32 style, void *hInst);
+
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+#endif
+
+/* From the SDL library code -- needed for registering QuickDraw on MacOS */
+#if defined(macintosh)
+#include "begin_code.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Forward declaration so we don't need to include QuickDraw.h */
+struct QDGlobals;
+
+/* This should be called from your main() function, if any */
+extern DECLSPEC void SDL_InitQuickDraw(struct QDGlobals *the_qd);
+
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+#endif
+
+#endif /* Need to redefine main()? */
+
+#endif /* _SDL_main_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_mouse.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,136 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL mouse event handling */
+
+#ifndef _SDL_mouse_h
+#define _SDL_mouse_h
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct WMcursor WMcursor;	/* Implementation dependent */
+typedef struct {
+	SDL_Rect area;			/* The area of the mouse cursor */
+	Sint16 hot_x, hot_y;		/* The "tip" of the cursor */
+	Uint8 *data;			/* B/W cursor data */
+	Uint8 *mask;			/* B/W cursor mask */
+	Uint8 *save[2];			/* Place to save cursor area */
+	WMcursor *wm_cursor;		/* Window-manager cursor */
+} SDL_Cursor;
+
+/* Function prototypes */
+/*
+ * Retrieve the current state of the mouse.
+ * The current button state is returned as a button bitmask, which can
+ * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
+ * current mouse cursor position.  You can pass NULL for either x or y.
+ */
+extern DECLSPEC Uint8 SDL_GetMouseState(int *x, int *y);
+
+/*
+ * Retrieve the current state of the mouse.
+ * The current button state is returned as a button bitmask, which can
+ * be tested using the SDL_BUTTON(X) macros, and x and y are set to the
+ * mouse deltas since the last call to SDL_GetRelativeMouseState().
+ */
+extern DECLSPEC Uint8 SDL_GetRelativeMouseState(int *x, int *y);
+
+/*
+ * Set the position of the mouse cursor (generates a mouse motion event)
+ */
+extern DECLSPEC void SDL_WarpMouse(Uint16 x, Uint16 y);
+
+/*
+ * Create a cursor using the specified data and mask (in MSB format).
+ * The cursor width must be a multiple of 8 bits.
+ *
+ * The cursor is created in black and white according to the following:
+ * data  mask    resulting pixel on screen
+ *  0     1       White
+ *  1     1       Black
+ *  0     0       Transparent
+ *  1     0       Inverted color if possible, black if not.
+ *
+ * Cursors created with this function must be freed with SDL_FreeCursor().
+ */
+extern DECLSPEC SDL_Cursor *SDL_CreateCursor
+		(Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+
+/*
+ * Set the currently active cursor to the specified one.
+ * If the cursor is currently visible, the change will be immediately 
+ * represented on the display.
+ */
+extern DECLSPEC void SDL_SetCursor(SDL_Cursor *cursor);
+
+/*
+ * Returns the currently active cursor.
+ */
+extern DECLSPEC SDL_Cursor * SDL_GetCursor(void);
+
+/*
+ * Deallocates a cursor created with SDL_CreateCursor().
+ */
+extern DECLSPEC void SDL_FreeCursor(SDL_Cursor *cursor);
+
+/*
+ * Toggle whether or not the cursor is shown on the screen.
+ * The cursor start off displayed, but can be turned off.
+ * SDL_ShowCursor() returns 1 if the cursor was being displayed
+ * before the call, or 0 if it was not.  You can query the current
+ * state by passing a 'toggle' value of -1.
+ */
+extern DECLSPEC int SDL_ShowCursor(int toggle);
+
+/* Used as a mask when testing buttons in buttonstate
+   Button 1:	Left mouse button
+   Button 2:	Middle mouse button
+   Button 3:	Right mouse button
+ */
+#define SDL_BUTTON(X)		(SDL_PRESSED<<(X-1))
+#define SDL_BUTTON_LEFT		1
+#define SDL_BUTTON_MIDDLE	2
+#define SDL_BUTTON_RIGHT	3
+#define SDL_BUTTON_LMASK	SDL_BUTTON(SDL_BUTTON_LEFT)
+#define SDL_BUTTON_MMASK	SDL_BUTTON(SDL_BUTTON_MIDDLE)
+#define SDL_BUTTON_RMASK	SDL_BUTTON(SDL_BUTTON_RIGHT)
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_mouse_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_mutex.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,163 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_mutex_h
+#define _SDL_mutex_h
+
+/* Functions to provide thread synchronization primitives
+
+	These are independent of the other SDL routines.
+*/
+
+#include "SDL_main.h"
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Synchronization functions which can time out return this value
+   if they time out.
+*/
+#define SDL_MUTEX_TIMEDOUT	1
+
+/* This is the timeout value which corresponds to never time out */
+#define SDL_MUTEX_MAXWAIT	(~(Uint32)0)
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Mutex functions                                               */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* The SDL mutex structure, defined in SDL_mutex.c */
+struct SDL_mutex;
+typedef struct SDL_mutex SDL_mutex;
+
+/* Create a mutex, initialized unlocked */
+extern DECLSPEC SDL_mutex * SDL_CreateMutex(void);
+
+/* Lock the mutex  (Returns 0, or -1 on error) */
+#define SDL_LockMutex(m)	SDL_mutexP(m)
+extern DECLSPEC int SDL_mutexP(SDL_mutex *mutex);
+
+/* Unlock the mutex  (Returns 0, or -1 on error) */
+#define SDL_UnlockMutex(m)	SDL_mutexV(m)
+extern DECLSPEC int SDL_mutexV(SDL_mutex *mutex);
+
+/* Destroy a mutex */
+extern DECLSPEC void SDL_DestroyMutex(SDL_mutex *mutex);
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Semaphore functions                                           */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* The SDL semaphore structure, defined in SDL_sem.c */
+struct SDL_semaphore;
+typedef struct SDL_semaphore SDL_sem;
+
+/* Create a semaphore, initialized with value, returns NULL on failure. */
+extern DECLSPEC SDL_sem * SDL_CreateSemaphore(Uint32 initial_value);
+
+/* Destroy a semaphore */
+extern DECLSPEC void SDL_DestroySemaphore(SDL_sem *sem);
+
+/* This function suspends the calling thread until the semaphore pointed 
+ * to by sem has a positive count. It then atomically decreases the semaphore
+ * count.
+ */
+extern DECLSPEC int SDL_SemWait(SDL_sem *sem);
+
+/* Non-blocking variant of SDL_SemWait(), returns 0 if the wait succeeds,
+   SDL_MUTEX_TIMEDOUT if the wait would block, and -1 on error.
+*/
+extern DECLSPEC int SDL_SemTryWait(SDL_sem *sem);
+
+/* Variant of SDL_SemWait() with a timeout in milliseconds, returns 0 if
+   the wait succeeds, SDL_MUTEX_TIMEDOUT if the wait does not succeed in
+   the allotted time, and -1 on error.
+   On some platforms this function is implemented by looping with a delay
+   of 1 ms, and so should be avoided if possible.
+*/
+extern DECLSPEC int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 ms);
+
+/* Atomically increases the semaphore's count (not blocking), returns 0,
+   or -1 on error.
+ */
+extern DECLSPEC int SDL_SemPost(SDL_sem *sem);
+
+/* Returns the current count of the semaphore */
+extern DECLSPEC Uint32 SDL_SemValue(SDL_sem *sem);
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* Condition variable functions                                  */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* The SDL condition variable structure, defined in SDL_cond.c */
+struct SDL_cond;
+typedef struct SDL_cond SDL_cond;
+
+/* Create a condition variable */
+extern DECLSPEC SDL_cond * SDL_CreateCond(void);
+
+/* Destroy a condition variable */
+extern DECLSPEC void SDL_DestroyCond(SDL_cond *cond);
+
+/* Restart one of the threads that are waiting on the condition variable,
+   returns 0 or -1 on error.
+ */
+extern DECLSPEC int SDL_CondSignal(SDL_cond *cond);
+
+/* Restart all threads that are waiting on the condition variable,
+   returns 0 or -1 on error.
+ */
+extern DECLSPEC int SDL_CondBroadcast(SDL_cond *cond);
+
+/* Wait on the condition variable, unlocking the provided mutex.
+   The mutex must be locked before entering this function!
+   Returns 0 when it is signaled, or -1 on error.
+ */
+extern DECLSPEC int SDL_CondWait(SDL_cond *cond, SDL_mutex *mut);
+
+/* Waits for at most 'ms' milliseconds, and returns 0 if the condition
+   variable is signaled, SDL_MUTEX_TIMEDOUT if the condition is not
+   signaled in the allotted time, and -1 on error.
+   On some platforms this function is implemented by looping with a delay
+   of 1 ms, and so should be avoided if possible.
+*/
+extern DECLSPEC int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_mutex_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_quit.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,52 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL quit event handling */
+
+#ifndef _SDL_quit_h
+#define _SDL_quit_h
+
+/* 
+  An SDL_QUITEVENT is generated when the user tries to close the application
+  window.  If it is ignored or filtered out, the window will remain open.
+  If it is not ignored or filtered, it is queued normally and the window
+  is allowed to close.  When the window is closed, screen updates will 
+  complete, but have no effect.
+
+  SDL_Init() installs signal handlers for SIGINT (keyboard interrupt)
+  and SIGTERM (system termination request), if handlers do not already
+  exist, that generate SDL_QUITEVENT events as well.  There is no way
+  to determine the cause of an SDL_QUITEVENT, but setting a signal
+  handler in your application will override the default generation of
+  quit events for that signal.
+*/
+
+/* There are no functions directly affecting the quit event */
+#define SDL_QuitRequested() \
+        (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK))
+
+#endif /* _SDL_quit_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_rwops.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,113 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This file provides a general interface for SDL to read and write
+   data sources.  It can easily be extended to files, memory, etc.
+*/
+
+#ifndef _SDL_RWops_h
+#define _SDL_RWops_h
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This is the read/write operation structure -- very basic */
+
+typedef struct SDL_RWops {
+	/* Seek to 'offset' relative to whence, one of stdio's whence values:
+		SEEK_SET, SEEK_CUR, SEEK_END
+	   Returns the final offset in the data source.
+	 */
+	int (*seek)(struct SDL_RWops *context, int offset, int whence);
+
+	/* Read up to 'num' objects each of size 'objsize' from the data
+	   source to the area pointed at by 'ptr'.
+	   Returns the number of objects read, or -1 if the read failed.
+	 */
+	int (*read)(struct SDL_RWops *context, void *ptr, int size, int maxnum);
+
+	/* Write exactly 'num' objects each of size 'objsize' from the area
+	   pointed at by 'ptr' to data source.
+	   Returns 'num', or -1 if the write failed.
+	 */
+	int (*write)(struct SDL_RWops *context, const void *ptr, int size, int num);
+
+	/* Close and free an allocated SDL_FSops structure */
+	int (*close)(struct SDL_RWops *context);
+
+	Uint32 type;
+	union {
+	    struct {
+		int autoclose;
+	 	FILE *fp;
+	    } stdio;
+	    struct {
+		Uint8 *base;
+	 	Uint8 *here;
+		Uint8 *stop;
+	    } mem;
+	    struct {
+		void *data1;
+	    } unknown;
+	} hidden;
+
+} SDL_RWops;
+
+
+/* Functions to create SDL_RWops structures from various data sources */
+
+extern DECLSPEC SDL_RWops * SDL_RWFromFile(const char *file, const char *mode);
+
+extern DECLSPEC SDL_RWops * SDL_RWFromFP(FILE *fp, int autoclose);
+
+extern DECLSPEC SDL_RWops * SDL_RWFromMem(void *mem, int size);
+
+extern DECLSPEC SDL_RWops * SDL_AllocRW(void);
+extern DECLSPEC void SDL_FreeRW(SDL_RWops *area);
+
+/* Macros to easily read and write from an SDL_RWops structure */
+#define SDL_RWseek(ctx, offset, whence)	(ctx)->seek(ctx, offset, whence)
+#define SDL_RWtell(ctx)			(ctx)->seek(ctx, 0, SEEK_CUR)
+#define SDL_RWread(ctx, ptr, size, n)	(ctx)->read(ctx, ptr, size, n)
+#define SDL_RWwrite(ctx, ptr, size, n)	(ctx)->write(ctx, ptr, size, n)
+#define SDL_RWclose(ctx)		(ctx)->close(ctx)
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_RWops_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_syswm.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,150 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Include file for SDL custom system window manager hooks */
+
+#ifndef _SDL_syswm_h
+#define _SDL_syswm_h
+
+#include "SDL_version.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Your application has access to a special type of event 'SDL_SYSWMEVENT',
+   which contains window-manager specific information and arrives whenever
+   an unhandled window event occurs.  This event is ignored by default, but
+   you can enable it with SDL_EventState()
+*/
+#ifdef SDL_PROTOTYPES_ONLY
+struct SDL_SysWMinfo;
+typedef struct SDL_SysWMinfo SDL_SysWMinfo;
+#else
+
+/* This is the structure for custom window manager events */
+#if (defined(unix) || defined(__unix__) || defined(_AIX)) && \
+    (!defined(DISABLE_X11) && !defined(__CYGWIN32__))
+ /* AIX is unix, of course, but the native compiler CSet doesn't define unix */
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
+/* These are the various supported subsystems under UNIX */
+typedef enum {
+	SDL_SYSWM_X11
+} SDL_SYSWM_TYPE;
+
+/* The UNIX custom event structure */
+struct SDL_SysWMmsg {
+	SDL_version version;
+	SDL_SYSWM_TYPE subsystem;
+	union {
+	    XEvent xevent;
+	} event;
+};
+
+/* The UNIX custom window manager information structure.
+   When this structure is returned, it holds information about which
+   low level system it is using, and will be one of SDL_SYSWM_TYPE.
+ */
+typedef struct {
+	SDL_version version;
+	SDL_SYSWM_TYPE subsystem;
+	union {
+	    struct {
+	    	Display *display;	/* The X11 display */
+	    	Window window;		/* The X11 display window */
+		/* These locking functions should be called around
+                   any X11 functions using the display variable.
+                   They lock the event thread, so should not be
+		   called around event functions or from event filters.
+		 */
+		void (*lock_func)(void);
+		void (*unlock_func)(void);
+
+		/* Introduced in SDL 1.0.2 */
+	    	Window fswindow;	/* The X11 fullscreen window */
+	    	Window wmwindow;	/* The X11 managed input window */
+	    } x11;
+	} info;
+} SDL_SysWMinfo;
+
+#elif defined(WIN32)
+#include <windows.h>
+
+/* The windows custom event structure */
+struct SDL_SysWMmsg {
+	SDL_version version;
+	HWND hwnd;			/* The window for the message */
+	UINT msg;			/* The type of message */
+	WPARAM wParam;			/* WORD message parameter */
+	LPARAM lParam;			/* LONG message parameter */
+};
+
+/* The windows custom window manager information structure */
+typedef struct {
+	SDL_version version;
+	HWND window;			/* The Win32 display window */
+} SDL_SysWMinfo;
+
+#else
+
+/* The generic custom event structure */
+struct SDL_SysWMmsg {
+	SDL_version version;
+	int data;
+};
+
+/* The generic custom window manager information structure */
+typedef struct {
+	SDL_version version;
+	int data;
+} SDL_SysWMinfo;
+
+#endif /* OS type */
+
+#endif /* SDL_PROTOTYPES_ONLY */
+
+/* Function prototypes */
+/*
+ * This function gives you custom hooks into the window manager information.
+ * It fills the structure pointed to by 'info' with custom information and
+ * returns 1 if the function is implemented.  If it's not implemented, or
+ * the version member of the 'info' structure is invalid, it returns 0. 
+ */
+extern DECLSPEC int SDL_GetWMInfo(SDL_SysWMinfo *info);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_syswm_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_thread.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,79 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_thread_h
+#define _SDL_thread_h
+
+/* Header for the SDL thread management routines 
+
+	These are independent of the other SDL routines.
+*/
+
+#include "SDL_main.h"
+#include "SDL_types.h"
+
+/* Thread synchronization primitives */
+#include "SDL_mutex.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* The SDL thread structure, defined in SDL_thread.c */
+struct SDL_Thread;
+typedef struct SDL_Thread SDL_Thread;
+
+/* Create a thread */
+extern DECLSPEC SDL_Thread * SDL_CreateThread(int (*fn)(void *), void *data);
+
+/* Get the 32-bit thread identifier for the current thread */
+extern DECLSPEC Uint32 SDL_ThreadID(void);
+
+/* Get the 32-bit thread identifier for the specified thread,
+   equivalent to SDL_ThreadID() if the specified thread is NULL.
+ */
+extern DECLSPEC Uint32 SDL_GetThreadID(SDL_Thread *thread);
+
+/* Wait for a thread to finish.
+   The return code for the thread function is placed in the area
+   pointed to by 'status', if 'status' is not NULL.
+ */
+extern DECLSPEC void SDL_WaitThread(SDL_Thread *thread, int *status);
+
+/* Forcefully kill a thread without worrying about its state */
+extern DECLSPEC void SDL_KillThread(SDL_Thread *thread);
+
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_thread_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_timer.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,118 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_timer_h
+#define _SDL_timer_h
+
+/* Header for the SDL time management routines */
+
+#include "SDL_main.h"
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* This is the OS scheduler timeslice, in milliseconds */
+#define SDL_TIMESLICE		10
+
+/* This is the maximum resolution of the SDL timer on all platforms */
+#define TIMER_RESOLUTION	10	/* Experimentally determined */
+
+/* Get the number of milliseconds since the SDL library initialization.
+ * Note that this value wraps if the program runs for more than ~49 days.
+ */ 
+extern DECLSPEC Uint32 SDL_GetTicks(void);
+
+/* Wait a specified number of milliseconds before returning */
+extern DECLSPEC void SDL_Delay(Uint32 ms);
+
+/* Function prototype for the timer callback function */
+typedef Uint32 (*SDL_TimerCallback)(Uint32 interval);
+
+/* Set a callback to run after the specified number of milliseconds has
+ * elapsed. The callback function is passed the current timer interval
+ * and returns the next timer interval.  If the returned value is the 
+ * same as the one passed in, the periodic alarm continues, otherwise a
+ * new alarm is scheduled.  If the callback returns 0, the periodic alarm
+ * is cancelled.
+ *
+ * To cancel a currently running timer, call SDL_SetTimer(0, NULL);
+ *
+ * The timer callback function may run in a different thread than your
+ * main code, and so shouldn't call any functions from within itself.
+ *
+ * The maximum resolution of this timer is 10 ms, which means that if
+ * you request a 16 ms timer, your callback will run approximately 20 ms
+ * later on an unloaded system.  If you wanted to set a flag signaling
+ * a frame update at 30 frames per second (every 33 ms), you might set a 
+ * timer for 30 ms:
+ *   SDL_SetTimer((33/10)*10, flag_update);
+ *
+ * If you use this function, you need to pass SDL_INIT_TIMER to SDL_Init().
+ *
+ * Under UNIX, you should not use raise or use SIGALRM and this function
+ * in the same program, as it is implemented using setitimer().  You also
+ * should not use this function in multi-threaded applications as signals
+ * to multi-threaded apps have undefined behavior in some implementations.
+ */
+extern DECLSPEC int SDL_SetTimer(Uint32 interval, SDL_TimerCallback callback);
+
+/* New timer API, supports multiple timers
+ * Written by Stephane Peter <megastep@lokigames.com>
+ */
+
+/* Function prototype for the new timer callback function.
+ * The callback function is passed the current timer interval and returns
+ * the next timer interval.  If the returned value is the same as the one
+ * passed in, the periodic alarm continues, otherwise a new alarm is
+ * scheduled.  If the callback returns 0, the periodic alarm is cancelled.
+ */
+typedef Uint32 (*SDL_NewTimerCallback)(Uint32 interval, void *param);
+
+/* Definition of the timer ID type */
+typedef struct _SDL_TimerID *SDL_TimerID;
+
+/* Add a new timer to the pool of timers already running.
+   Returns a timer ID, or NULL when an error occurs.
+ */
+extern DECLSPEC SDL_TimerID SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param);
+
+/* Remove one of the multiple timers knowing its ID.
+ * Returns a boolean value indicating success.
+ */
+extern DECLSPEC SDL_bool SDL_RemoveTimer(SDL_TimerID t);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_timer_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_types.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,87 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General data types used by the SDL library */
+
+#ifndef _SDL_types_h
+#define _SDL_types_h
+
+/* The number of elements in a table */
+#define SDL_TABLESIZE(table)	(sizeof(table)/sizeof(table[0]))
+
+/* Basic data types */
+typedef enum {
+	SDL_FALSE = 0,
+	SDL_TRUE  = 1
+} SDL_bool;
+typedef unsigned char	Uint8;
+typedef signed char	Sint8;
+typedef unsigned short	Uint16;
+typedef signed short	Sint16;
+typedef unsigned int	Uint32;
+typedef signed int	Sint32;
+
+/* Figure out how to support 64-bit datatypes */
+#if !defined(__STRICT_ANSI__)
+#if defined(__GNUC__) || defined(__MWERKS__) /* MJS */
+#define SDL_HAS_64BIT_TYPE	long long
+#elif defined(_MSC_VER) /* VC++ */
+#define SDL_HAS_64BIT_TYPE	__int64
+#endif
+#endif /* !__STRICT_ANSI__ */
+
+/* The 64-bit datatype isn't supported on all platforms */
+#ifdef SDL_HAS_64BIT_TYPE
+typedef unsigned SDL_HAS_64BIT_TYPE Uint64;
+typedef SDL_HAS_64BIT_TYPE Sint64;
+#else
+/* This is really just a hack to prevent the compiler from complaining */
+typedef struct {
+	Uint32 hi;
+	Uint32 lo;
+} Uint64, Sint64;
+#endif
+
+/* Make sure the types really have the right sizes */
+#define SDL_COMPILE_TIME_ASSERT(name, x)               \
+       typedef int SDL_dummy_ ## name[(x) * 2 - 1]
+
+SDL_COMPILE_TIME_ASSERT(uint8, sizeof(Uint8) == 1);
+SDL_COMPILE_TIME_ASSERT(sint8, sizeof(Sint8) == 1);
+SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2);
+SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2);
+SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4);
+SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4);
+SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8);
+SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8);
+
+#undef SDL_COMPILE_TIME_ASSERT
+
+/* General keyboard/mouse state definitions */
+enum { SDL_PRESSED = 0x01, SDL_RELEASED = 0x00 };
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_version.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,90 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This header defines the current SDL version */
+
+#ifndef _SDL_version_h
+#define _SDL_version_h
+
+#include "SDL_types.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
+*/
+#define SDL_MAJOR_VERSION	1
+#define SDL_MINOR_VERSION	2
+#define SDL_PATCHLEVEL		0
+
+typedef struct {
+	Uint8 major;
+	Uint8 minor;
+	Uint8 patch;
+} SDL_version;
+
+/* This macro can be used to fill a version structure with the compile-time
+ * version of the SDL library.
+ */
+#define SDL_VERSION(X)							\
+{									\
+	(X)->major = SDL_MAJOR_VERSION;					\
+	(X)->minor = SDL_MINOR_VERSION;					\
+	(X)->patch = SDL_PATCHLEVEL;					\
+}
+
+/* This macro turns the version numbers into a numeric value:
+   (1,2,3) -> (1203)
+   This assumes that there will never be more than 100 patchlevels
+*/
+#define SDL_VERSIONNUM(X, Y, Z)						\
+	(X)*1000 + (Y)*100 + (Z)
+
+/* This is the version number macro for the current SDL version */
+#define SDL_COMPILEDVERSION \
+	SDL_VERSIONNUM(SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL)
+
+/* This macro will evaluate to true if compiled with SDL at least X.Y.Z */
+#define SDL_VERSION_ATLEAST(X, Y, Z) \
+	(SDL_COMPILEDVERSION >= SDL_VERSIONNUM(X, Y, Z))
+
+/* This function gets the version of the dynamically linked SDL library.
+   it should NOT be used to fill a version structure, instead you should
+   use the SDL_Version() macro.
+ */
+extern DECLSPEC const SDL_version * SDL_Linked_Version(void);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_version_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/SDL_video.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,887 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Header file for access to the SDL raw framebuffer window */
+
+#ifndef _SDL_video_h
+#define _SDL_video_h
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_mutex.h"
+#include "SDL_rwops.h"
+
+#include "begin_code.h"
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Transparency definitions: These define alpha as the opacity of a surface */
+#define SDL_ALPHA_OPAQUE 255
+#define SDL_ALPHA_TRANSPARENT 0
+
+/* Useful data types */
+typedef struct {
+	Sint16 x, y;
+	Uint16 w, h;
+} SDL_Rect;
+
+typedef struct {
+	Uint8 r;
+	Uint8 g;
+	Uint8 b;
+	Uint8 unused;
+} SDL_Color;
+
+typedef struct {
+	int       ncolors;
+	SDL_Color *colors;
+} SDL_Palette;
+
+/* Everything in the pixel format structure is read-only */
+typedef struct SDL_PixelFormat {
+	SDL_Palette *palette;
+	Uint8  BitsPerPixel;
+	Uint8  BytesPerPixel;
+	Uint8  Rloss;
+	Uint8  Gloss;
+	Uint8  Bloss;
+	Uint8  Aloss;
+	Uint8  Rshift;
+	Uint8  Gshift;
+	Uint8  Bshift;
+	Uint8  Ashift;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	Uint32 Amask;
+
+	/* RGB color key information */
+	Uint32 colorkey;
+	/* Alpha value information (per-surface alpha) */
+	Uint8  alpha;
+} SDL_PixelFormat;
+
+/* typedef for private surface blitting functions */
+struct SDL_Surface;
+typedef int (*SDL_blit)(struct SDL_Surface *src, SDL_Rect *srcrect,
+			struct SDL_Surface *dst, SDL_Rect *dstrect);
+
+/* This structure should be treated as read-only, except for 'pixels',
+   which, if not NULL, contains the raw pixel data for the surface.
+*/
+typedef struct SDL_Surface {
+	Uint32 flags;				/* Read-only */
+	SDL_PixelFormat *format;		/* Read-only */
+	int w, h;				/* Read-only */
+	Uint16 pitch;				/* Read-only */
+	void *pixels;				/* Read-write */
+	int offset;				/* Private */
+
+	/* Hardware-specific surface info */
+	struct private_hwdata *hwdata;
+
+	/* clipping information */
+	SDL_Rect clip_rect;			/* Read-only */
+	Uint32 unused1;				/* for binary compatibility */
+
+	/* Allow recursive locks */
+	Uint32 locked;				/* Private */
+
+	/* info for fast blit mapping to other surfaces */
+	struct SDL_BlitMap *map;		/* Private */
+
+	/* format version, bumped at every change to invalidate blit maps */
+	unsigned int format_version;		/* Private */
+
+	/* Reference count -- used when freeing surface */
+	int refcount;				/* Read-mostly */
+} SDL_Surface;
+
+/* These are the currently supported flags for the SDL_surface */
+/* Available for SDL_CreateRGBSurface() or SDL_SetVideoMode() */
+#define SDL_SWSURFACE	0x00000000	/* Surface is in system memory */
+#define SDL_HWSURFACE	0x00000001	/* Surface is in video memory */
+#define SDL_ASYNCBLIT	0x00000004	/* Use asynchronous blits if possible */
+/* Available for SDL_SetVideoMode() */
+#define SDL_ANYFORMAT	0x10000000	/* Allow any video depth/pixel-format */
+#define SDL_HWPALETTE	0x20000000	/* Surface has exclusive palette */
+#define SDL_DOUBLEBUF	0x40000000	/* Set up double-buffered video mode */
+#define SDL_FULLSCREEN	0x80000000	/* Surface is a full screen display */
+#define SDL_OPENGL      0x00000002      /* Create an OpenGL rendering context */
+#define SDL_OPENGLBLIT	0x0000000A	/* Create an OpenGL rendering context and use it for blitting */
+#define SDL_RESIZABLE	0x00000010	/* This video mode may be resized */
+#define SDL_NOFRAME	0x00000020	/* No window caption or edge frame */
+/* Used internally (read-only) */
+#define SDL_HWACCEL	0x00000100	/* Blit uses hardware acceleration */
+#define SDL_SRCCOLORKEY	0x00001000	/* Blit uses a source color key */
+#define SDL_RLEACCELOK	0x00002000	/* Private flag */
+#define SDL_RLEACCEL	0x00004000	/* Surface is RLE encoded */
+#define SDL_SRCALPHA	0x00010000	/* Blit uses source alpha blending */
+#define SDL_PREALLOC	0x01000000	/* Surface uses preallocated memory */
+
+/* Evaluates to true if the surface needs to be locked before access */
+#define SDL_MUSTLOCK(surface)	\
+  (surface->offset ||		\
+  ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0))
+
+
+/* Useful for determining the video hardware capabilities */
+typedef struct {
+	Uint32 hw_available :1;	/* Flag: Can you create hardware surfaces? */
+	Uint32 wm_available :1;	/* Flag: Can you talk to a window manager? */
+	Uint32 UnusedBits1  :6;
+	Uint32 UnusedBits2  :1;
+	Uint32 blit_hw      :1;	/* Flag: Accelerated blits HW --> HW */
+	Uint32 blit_hw_CC   :1;	/* Flag: Accelerated blits with Colorkey */
+	Uint32 blit_hw_A    :1;	/* Flag: Accelerated blits with Alpha */
+	Uint32 blit_sw      :1;	/* Flag: Accelerated blits SW --> HW */
+	Uint32 blit_sw_CC   :1;	/* Flag: Accelerated blits with Colorkey */
+	Uint32 blit_sw_A    :1;	/* Flag: Accelerated blits with Alpha */
+	Uint32 blit_fill    :1;	/* Flag: Accelerated color fill */
+	Uint32 UnusedBits3  :16;
+	Uint32 video_mem;	/* The total amount of video memory (in K) */
+	SDL_PixelFormat *vfmt;	/* Value: The format of the video surface */
+} SDL_VideoInfo;
+
+
+/* The most common video overlay formats.
+   For an explanation of these pixel formats, see:
+	http://www.webartz.com/fourcc/indexyuv.htm
+
+   For information on the relationship between color spaces, see:
+   http://www.neuro.sfc.keio.ac.jp/~aly/polygon/info/color-space-faq.html
+ */
+#define SDL_YV12_OVERLAY  0x32315659	/* Planar mode: Y + V + U  (3 planes) */
+#define SDL_IYUV_OVERLAY  0x56555949	/* Planar mode: Y + U + V  (3 planes) */
+#define SDL_YUY2_OVERLAY  0x32595559	/* Packed mode: Y0+U0+Y1+V0 (1 plane) */
+#define SDL_UYVY_OVERLAY  0x59565955	/* Packed mode: U0+Y0+V0+Y1 (1 plane) */
+#define SDL_YVYU_OVERLAY  0x55595659	/* Packed mode: Y0+V0+Y1+U0 (1 plane) */
+
+/* The YUV hardware video overlay */
+typedef struct SDL_Overlay {
+	Uint32 format;				/* Read-only */
+	int w, h;				/* Read-only */
+	int planes;				/* Read-only */
+	Uint16 *pitches;			/* Read-only */
+	Uint8 **pixels;				/* Read-write */
+
+	/* Hardware-specific surface info */
+	struct private_yuvhwfuncs *hwfuncs;
+	struct private_yuvhwdata *hwdata;
+
+	/* Special flags */
+	Uint32 hw_overlay :1;	/* Flag: This overlay hardware accelerated? */
+	Uint32 UnusedBits :31;
+} SDL_Overlay;
+
+
+/* Public enumeration for setting the OpenGL window attributes. */
+typedef enum {
+    SDL_GL_RED_SIZE,
+    SDL_GL_GREEN_SIZE,
+    SDL_GL_BLUE_SIZE,
+    SDL_GL_ALPHA_SIZE,
+    SDL_GL_BUFFER_SIZE,
+    SDL_GL_DOUBLEBUFFER,
+    SDL_GL_DEPTH_SIZE,
+    SDL_GL_STENCIL_SIZE,
+    SDL_GL_ACCUM_RED_SIZE,
+    SDL_GL_ACCUM_GREEN_SIZE,
+    SDL_GL_ACCUM_BLUE_SIZE,
+    SDL_GL_ACCUM_ALPHA_SIZE
+} SDL_GLattr;
+
+/* flags for SDL_SetPalette() */
+#define SDL_LOGPAL 0x01
+#define SDL_PHYSPAL 0x02
+
+/* Function prototypes */
+
+/* These functions are used internally, and should not be used unless you
+ * have a specific need to specify the video driver you want to use.
+ * You should normally use SDL_Init() or SDL_InitSubSystem().
+ *
+ * SDL_VideoInit() initializes the video subsystem -- sets up a connection
+ * to the window manager, etc, and determines the current video mode and
+ * pixel format, but does not initialize a window or graphics mode.
+ * Note that event handling is activated by this routine.
+ *
+ * If you use both sound and video in your application, you need to call
+ * SDL_Init() before opening the sound device, otherwise under Win32 DirectX,
+ * you won't be able to set full-screen display modes.
+ */
+extern DECLSPEC int SDL_VideoInit(const char *driver_name, Uint32 flags);
+extern DECLSPEC void SDL_VideoQuit(void);
+
+/* This function fills the given character buffer with the name of the
+ * video driver, and returns a pointer to it if the video driver has
+ * been initialized.  It returns NULL if no driver has been initialized.
+ */
+extern DECLSPEC char *SDL_VideoDriverName(char *namebuf, int maxlen);
+
+/*
+ * This function returns a pointer to the current display surface.
+ * If SDL is doing format conversion on the display surface, this
+ * function returns the publicly visible surface, not the real video
+ * surface.
+ */
+extern DECLSPEC SDL_Surface * SDL_GetVideoSurface(void);
+
+/*
+ * This function returns a read-only pointer to information about the
+ * video hardware.  If this is called before SDL_SetVideoMode(), the 'vfmt'
+ * member of the returned structure will contain the pixel format of the
+ * "best" video mode.
+ */
+extern DECLSPEC const SDL_VideoInfo * SDL_GetVideoInfo(void);
+
+/* 
+ * Check to see if a particular video mode is supported.
+ * It returns 0 if the requested mode is not supported under any bit depth,
+ * or returns the bits-per-pixel of the closest available mode with the
+ * given width and height.  If this bits-per-pixel is different from the
+ * one used when setting the video mode, SDL_SetVideoMode() will succeed,
+ * but will emulate the requested bits-per-pixel with a shadow surface.
+ *
+ * The arguments to SDL_VideoModeOK() are the same ones you would pass to
+ * SDL_SetVideoMode()
+ */
+extern DECLSPEC int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags);
+
+/*
+ * Return a pointer to an array of available screen dimensions for the
+ * given format and video flags, sorted largest to smallest.  Returns 
+ * NULL if there are no dimensions available for a particular format, 
+ * or (SDL_Rect **)-1 if any dimension is okay for the given format.
+ *
+ * If 'format' is NULL, the mode list will be for the format given 
+ * by SDL_GetVideoInfo()->vfmt
+ */
+extern DECLSPEC SDL_Rect ** SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
+
+/*
+ * Set up a video mode with the specified width, height and bits-per-pixel.
+ *
+ * If 'bpp' is 0, it is treated as the current display bits per pixel.
+ *
+ * If SDL_ANYFORMAT is set in 'flags', the SDL library will try to set the
+ * requested bits-per-pixel, but will return whatever video pixel format is
+ * available.  The default is to emulate the requested pixel format if it
+ * is not natively available.
+ *
+ * If SDL_HWSURFACE is set in 'flags', the video surface will be placed in
+ * video memory, if possible, and you may have to call SDL_LockSurface()
+ * in order to access the raw framebuffer.  Otherwise, the video surface
+ * will be created in system memory.
+ *
+ * If SDL_ASYNCBLIT is set in 'flags', SDL will try to perform rectangle
+ * updates asynchronously, but you must always lock before accessing pixels.
+ * SDL will wait for updates to complete before returning from the lock.
+ *
+ * If SDL_HWPALETTE is set in 'flags', the SDL library will guarantee
+ * that the colors set by SDL_SetColors() will be the colors you get.
+ * Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
+ * of the colors exactly the way they are requested, and you should look
+ * at the video surface structure to determine the actual palette.
+ * If SDL cannot guarantee that the colors you request can be set, 
+ * i.e. if the colormap is shared, then the video surface may be created
+ * under emulation in system memory, overriding the SDL_HWSURFACE flag.
+ *
+ * If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
+ * a fullscreen video mode.  The default is to create a windowed mode
+ * if the current graphics system has a window manager.
+ * If the SDL library is able to set a fullscreen video mode, this flag 
+ * will be set in the surface that is returned.
+ *
+ * If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
+ * two surfaces in video memory and swap between them when you call 
+ * SDL_Flip().  This is usually slower than the normal single-buffering
+ * scheme, but prevents "tearing" artifacts caused by modifying video 
+ * memory while the monitor is refreshing.  It should only be used by 
+ * applications that redraw the entire screen on every update.
+ *
+ * If SDL_RESIZABLE is set in 'flags', the SDL library will allow the
+ * window manager, if any, to resize the window at runtime.  When this
+ * occurs, SDL will send a SDL_VIDEORESIZE event to you application,
+ * and you must respond to the event by re-calling SDL_SetVideoMode()
+ * with the requested size (or another size that suits the application).
+ *
+ * If SDL_NOFRAME is set in 'flags', the SDL library will create a window
+ * without any title bar or frame decoration.  Fullscreen video modes have
+ * this flag set automatically.
+ *
+ * This function returns the video framebuffer surface, or NULL if it fails.
+ *
+ * If you rely on functionality provided by certain video flags, check the
+ * flags of the returned surface to make sure that functionality is available.
+ * SDL will fall back to reduced functionality if the exact flags you wanted
+ * are not available.
+ */
+extern DECLSPEC SDL_Surface *SDL_SetVideoMode
+			(int width, int height, int bpp, Uint32 flags);
+
+/*
+ * Makes sure the given list of rectangles is updated on the given screen.
+ * If 'x', 'y', 'w' and 'h' are all 0, SDL_UpdateRect will update the entire
+ * screen.
+ * These functions should not be called while 'screen' is locked.
+ */
+extern DECLSPEC void SDL_UpdateRects
+		(SDL_Surface *screen, int numrects, SDL_Rect *rects);
+extern DECLSPEC void SDL_UpdateRect
+		(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h);
+
+/*
+ * On hardware that supports double-buffering, this function sets up a flip
+ * and returns.  The hardware will wait for vertical retrace, and then swap
+ * video buffers before the next video surface blit or lock will return.
+ * On hardware that doesn not support double-buffering, this is equivalent
+ * to calling SDL_UpdateRect(screen, 0, 0, 0, 0);
+ * The SDL_DOUBLEBUF flag must have been passed to SDL_SetVideoMode() when
+ * setting the video mode for this function to perform hardware flipping.
+ * This function returns 0 if successful, or -1 if there was an error.
+ */
+extern DECLSPEC int SDL_Flip(SDL_Surface *screen);
+
+/*
+ * Set the gamma correction for each of the color channels.
+ * The gamma values range (approximately) between 0.1 and 10.0
+ * 
+ * If this function isn't supported directly by the hardware, it will
+ * be emulated using gamma ramps, if available.  If successful, this
+ * function returns 0, otherwise it returns -1.
+ */
+extern DECLSPEC int SDL_SetGamma(float red, float green, float blue);
+
+/*
+ * Set the gamma translation table for the red, green, and blue channels
+ * of the video hardware.  Each table is an array of 256 16-bit quantities,
+ * representing a mapping between the input and output for that channel.
+ * The input is the index into the array, and the output is the 16-bit
+ * gamma value at that index, scaled to the output color precision.
+ * 
+ * You may pass NULL for any of the channels to leave it unchanged.
+ * If the call succeeds, it will return 0.  If the display driver or
+ * hardware does not support gamma translation, or otherwise fails,
+ * this function will return -1.
+ */
+extern DECLSPEC int SDL_SetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue);
+
+/*
+ * Retrieve the current values of the gamma translation tables.
+ * 
+ * You must pass in valid pointers to arrays of 256 16-bit quantities.
+ * Any of the pointers may be NULL to ignore that channel.
+ * If the call succeeds, it will return 0.  If the display driver or
+ * hardware does not support gamma translation, or otherwise fails,
+ * this function will return -1.
+ */
+extern DECLSPEC int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue);
+
+/*
+ * Sets a portion of the colormap for the given 8-bit surface.  If 'surface'
+ * is not a palettized surface, this function does nothing, returning 0.
+ * If all of the colors were set as passed to SDL_SetColors(), it will
+ * return 1.  If not all the color entries were set exactly as given,
+ * it will return 0, and you should look at the surface palette to
+ * determine the actual color palette.
+ *
+ * When 'surface' is the surface associated with the current display, the
+ * display colormap will be updated with the requested colors.  If 
+ * SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
+ * will always return 1, and the palette is guaranteed to be set the way
+ * you desire, even if the window colormap has to be warped or run under
+ * emulation.
+ */
+extern DECLSPEC int SDL_SetColors(SDL_Surface *surface, 
+			SDL_Color *colors, int firstcolor, int ncolors);
+
+/*
+ * Sets a portion of the colormap for a given 8-bit surface.
+ * 'flags' is one or both of:
+ * SDL_LOGPAL  -- set logical palette, which controls how blits are mapped
+ *                to/from the surface,
+ * SDL_PHYSPAL -- set physical palette, which controls how pixels look on
+ *                the screen
+ * Only screens have physical palettes. Separate change of physical/logical
+ * palettes is only possible if the screen has SDL_HWPALETTE set.
+ *
+ * The return value is 1 if all colours could be set as requested, and 0
+ * otherwise.
+ *
+ * SDL_SetColors() is equivalent to calling this function with
+ *     flags = (SDL_LOGPAL|SDL_PHYSPAL).
+ */
+extern DECLSPEC int SDL_SetPalette(SDL_Surface *surface, int flags,
+				   SDL_Color *colors, int firstcolor,
+				   int ncolors);
+
+/*
+ * Maps an RGB triple to an opaque pixel value for a given pixel format
+ */
+extern DECLSPEC Uint32 SDL_MapRGB
+			(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b);
+
+/*
+ * Maps an RGBA quadruple to a pixel value for a given pixel format
+ */
+extern DECLSPEC Uint32 SDL_MapRGBA(SDL_PixelFormat *format,
+				   Uint8 r, Uint8 g, Uint8 b, Uint8 a);
+
+/*
+ * Maps a pixel value into the RGB components for a given pixel format
+ */
+extern DECLSPEC void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt,
+				Uint8 *r, Uint8 *g, Uint8 *b);
+
+/*
+ * Maps a pixel value into the RGBA components for a given pixel format
+ */
+extern DECLSPEC void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
+				 Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a);
+
+/*
+ * Allocate and free an RGB surface (must be called after SDL_SetVideoMode)
+ * If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
+ * If the depth is greater than 8 bits, the pixel format is set using the
+ * flags '[RGB]mask'.
+ * If the function runs out of memory, it will return NULL.
+ *
+ * The 'flags' tell what kind of surface to create.
+ * SDL_SWSURFACE means that the surface should be created in system memory.
+ * SDL_HWSURFACE means that the surface should be created in video memory,
+ * with the same format as the display surface.  This is useful for surfaces
+ * that will not change much, to take advantage of hardware acceleration
+ * when being blitted to the display surface.
+ * SDL_ASYNCBLIT means that SDL will try to perform asynchronous blits with
+ * this surface, but you must always lock it before accessing the pixels.
+ * SDL will wait for current blits to finish before returning from the lock.
+ * SDL_SRCCOLORKEY indicates that the surface will be used for colorkey blits.
+ * If the hardware supports acceleration of colorkey blits between
+ * two surfaces in video memory, SDL will try to place the surface in
+ * video memory. If this isn't possible or if there is no hardware
+ * acceleration available, the surface will be placed in system memory.
+ * SDL_SRCALPHA means that the surface will be used for alpha blits and 
+ * if the hardware supports hardware acceleration of alpha blits between
+ * two surfaces in video memory, to place the surface in video memory
+ * if possible, otherwise it will be placed in system memory.
+ * If the surface is created in video memory, blits will be _much_ faster,
+ * but the surface format must be identical to the video surface format,
+ * and the only way to access the pixels member of the surface is to use
+ * the SDL_LockSurface() and SDL_UnlockSurface() calls.
+ * If the requested surface actually resides in video memory, SDL_HWSURFACE
+ * will be set in the flags member of the returned surface.  If for some
+ * reason the surface could not be placed in video memory, it will not have
+ * the SDL_HWSURFACE flag set, and will be created in system memory instead.
+ */
+#define SDL_AllocSurface    SDL_CreateRGBSurface
+extern DECLSPEC SDL_Surface *SDL_CreateRGBSurface
+			(Uint32 flags, int width, int height, int depth, 
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+extern DECLSPEC SDL_Surface *SDL_CreateRGBSurfaceFrom(void *pixels,
+			int width, int height, int depth, int pitch,
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+extern DECLSPEC void SDL_FreeSurface(SDL_Surface *surface);
+
+/*
+ * SDL_LockSurface() sets up a surface for directly accessing the pixels.
+ * Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
+ * to and read from 'surface->pixels', using the pixel format stored in 
+ * 'surface->format'.  Once you are done accessing the surface, you should 
+ * use SDL_UnlockSurface() to release it.
+ *
+ * Not all surfaces require locking.  If SDL_MUSTLOCK(surface) evaluates
+ * to 0, then you can read and write to the surface at any time, and the
+ * pixel format of the surface will not change.  In particular, if the
+ * SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
+ * will not need to lock the display surface before accessing it.
+ * 
+ * No operating system or library calls should be made between lock/unlock
+ * pairs, as critical system locks may be held during this time.
+ *
+ * SDL_LockSurface() returns 0, or -1 if the surface couldn't be locked.
+ */
+extern DECLSPEC int SDL_LockSurface(SDL_Surface *surface);
+extern DECLSPEC void SDL_UnlockSurface(SDL_Surface *surface);
+
+/*
+ * Load a surface from a seekable SDL data source (memory or file.)
+ * If 'freesrc' is non-zero, the source will be closed after being read.
+ * Returns the new surface, or NULL if there was an error.
+ * The new surface should be freed with SDL_FreeSurface().
+ */
+extern DECLSPEC SDL_Surface * SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
+
+/* Convenience macro -- load a surface from a file */
+#define SDL_LoadBMP(file)	SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
+
+/*
+ * Save a surface to a seekable SDL data source (memory or file.)
+ * If 'freedst' is non-zero, the source will be closed after being written.
+ * Returns 0 if successful or -1 if there was an error.
+ */
+extern DECLSPEC int SDL_SaveBMP_RW
+		(SDL_Surface *surface, SDL_RWops *dst, int freedst);
+
+/* Convenience macro -- save a surface to a file */
+#define SDL_SaveBMP(surface, file) \
+		SDL_SaveBMP_RW(surface, SDL_RWFromFile(file, "wb"), 1)
+
+/*
+ * Sets the color key (transparent pixel) in a blittable surface.
+ * If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL), 
+ * 'key' will be the transparent pixel in the source image of a blit.
+ * SDL_RLEACCEL requests RLE acceleration for the surface if present,
+ * and removes RLE acceleration if absent.
+ * If 'flag' is 0, this function clears any current color key.
+ * This function returns 0, or -1 if there was an error.
+ */
+extern DECLSPEC int SDL_SetColorKey
+			(SDL_Surface *surface, Uint32 flag, Uint32 key);
+
+/*
+ * This function sets the alpha value for the entire surface, as opposed to
+ * using the alpha component of each pixel. This value measures the range
+ * of transparency of the surface, 0 being completely transparent to 255
+ * being completely opaque. An 'alpha' value of 255 causes blits to be
+ * opaque, the source pixels copied to the destination (the default). Note
+ * that per-surface alpha can be combined with colorkey transparency.
+ *
+ * If 'flag' is 0, alpha blending is disabled for the surface.
+ * If 'flag' is SDL_SRCALPHA, alpha blending is enabled for the surface.
+ * OR:ing the flag with SDL_RLEACCEL requests RLE acceleration for the
+ * surface; if SDL_RLEACCEL is not specified, the RLE accel will be removed.
+ */
+extern DECLSPEC int SDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha);
+
+/*
+ * Sets the clipping rectangle for the destination surface in a blit.
+ *
+ * If the clip rectangle is NULL, clipping will be disabled.
+ * If the clip rectangle doesn't intersect the surface, the function will
+ * return SDL_FALSE and blits will be completely clipped.  Otherwise the
+ * function returns SDL_TRUE and blits to the surface will be clipped to
+ * the intersection of the surface area and the clipping rectangle.
+ *
+ * Note that blits are automatically clipped to the edges of the source
+ * and destination surfaces.
+ */
+extern DECLSPEC SDL_bool SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect);
+
+/*
+ * Gets the clipping rectangle for the destination surface in a blit.
+ * 'rect' must be a pointer to a valid rectangle which will be filled
+ * with the correct values.
+ */
+extern DECLSPEC void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
+
+/*
+ * Creates a new surface of the specified format, and then copies and maps 
+ * the given surface to it so the blit of the converted surface will be as 
+ * fast as possible.  If this function fails, it returns NULL.
+ *
+ * The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those 
+ * semantics.  You can also pass SDL_RLEACCEL in the flags parameter and
+ * SDL will try to RLE accelerate colorkey and alpha blits in the resulting
+ * surface.
+ *
+ * This function is used internally by SDL_DisplayFormat().
+ */
+extern DECLSPEC SDL_Surface *SDL_ConvertSurface
+			(SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags);
+
+/*
+ * This performs a fast blit from the source surface to the destination
+ * surface.  It assumes that the source and destination rectangles are
+ * the same size.  If either 'srcrect' or 'dstrect' are NULL, the entire
+ * surface (src or dst) is copied.  The final blit rectangles are saved
+ * in 'srcrect' and 'dstrect' after all clipping is performed.
+ * If the blit is successful, it returns 0, otherwise it returns -1.
+ *
+ * The blit function should not be called on a locked surface.
+ *
+ * The blit semantics for surfaces with and without alpha and colorkey
+ * are defined as follows:
+ *
+ * RGBA->RGB:
+ *     SDL_SRCALPHA set:
+ * 	alpha-blend (using alpha-channel).
+ * 	SDL_SRCCOLORKEY ignored.
+ *     SDL_SRCALPHA not set:
+ * 	copy RGB.
+ * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ * 	RGB values of the source colour key, ignoring alpha in the
+ * 	comparison.
+ * 
+ * RGB->RGBA:
+ *     SDL_SRCALPHA set:
+ * 	alpha-blend (using the source per-surface alpha value);
+ * 	set destination alpha to opaque.
+ *     SDL_SRCALPHA not set:
+ * 	copy RGB, set destination alpha to opaque.
+ *     both:
+ * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ * 	source colour key.
+ * 
+ * RGBA->RGBA:
+ *     SDL_SRCALPHA set:
+ * 	alpha-blend (using the source alpha channel) the RGB values;
+ * 	leave destination alpha untouched. [Note: is this correct?]
+ * 	SDL_SRCCOLORKEY ignored.
+ *     SDL_SRCALPHA not set:
+ * 	copy all of RGBA to the destination.
+ * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ * 	RGB values of the source colour key, ignoring alpha in the
+ * 	comparison.
+ * 
+ * RGB->RGB: 
+ *     SDL_SRCALPHA set:
+ * 	alpha-blend (using the source per-surface alpha value).
+ *     SDL_SRCALPHA not set:
+ * 	copy RGB.
+ *     both:
+ * 	if SDL_SRCCOLORKEY set, only copy the pixels matching the
+ * 	source colour key.
+ *
+ * If either of the surfaces were in video memory, and the blit returns -2,
+ * the video memory was lost, so it should be reloaded with artwork and 
+ * re-blitted:
+	while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
+		while ( SDL_LockSurface(image) < 0 )
+			Sleep(10);
+		-- Write image pixels to image->pixels --
+		SDL_UnlockSurface(image);
+	}
+ * This happens under DirectX 5.0 when the system switches away from your
+ * fullscreen application.  The lock will also fail until you have access
+ * to the video memory again.
+ */
+/* You should call SDL_BlitSurface() unless you know exactly how SDL
+   blitting works internally and how to use the other blit functions.
+*/
+#define SDL_BlitSurface SDL_UpperBlit
+
+/* This is the public blit function, SDL_BlitSurface(), and it performs
+   rectangle validation and clipping before passing it to SDL_LowerBlit()
+*/
+extern DECLSPEC int SDL_UpperBlit
+			(SDL_Surface *src, SDL_Rect *srcrect,
+			 SDL_Surface *dst, SDL_Rect *dstrect);
+/* This is a semi-private blit function and it performs low-level surface
+   blitting only.
+*/
+extern DECLSPEC int SDL_LowerBlit
+			(SDL_Surface *src, SDL_Rect *srcrect,
+			 SDL_Surface *dst, SDL_Rect *dstrect);
+
+/*
+ * This function performs a fast fill of the given rectangle with 'color'
+ * The given rectangle is clipped to the destination surface clip area
+ * and the final fill rectangle is saved in the passed in pointer.
+ * If 'dstrect' is NULL, the whole surface will be filled with 'color'
+ * The color should be a pixel of the format used by the surface, and 
+ * can be generated by the SDL_MapRGB() function.
+ * This function returns 0 on success, or -1 on error.
+ */
+extern DECLSPEC int SDL_FillRect
+		(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
+
+/* 
+ * This function takes a surface and copies it to a new surface of the
+ * pixel format and colors of the video framebuffer, suitable for fast
+ * blitting onto the display surface.  It calls SDL_ConvertSurface()
+ *
+ * If you want to take advantage of hardware colorkey or alpha blit
+ * acceleration, you should set the colorkey and alpha value before
+ * calling this function.
+ *
+ * If the conversion fails or runs out of memory, it returns NULL
+ */
+extern DECLSPEC SDL_Surface * SDL_DisplayFormat(SDL_Surface *surface);
+
+/* 
+ * This function takes a surface and copies it to a new surface of the
+ * pixel format and colors of the video framebuffer (if possible),
+ * suitable for fast alpha blitting onto the display surface.
+ * The new surface will always have an alpha channel.
+ *
+ * If you want to take advantage of hardware colorkey or alpha blit
+ * acceleration, you should set the colorkey and alpha value before
+ * calling this function.
+ *
+ * If the conversion fails or runs out of memory, it returns NULL
+ */
+extern DECLSPEC SDL_Surface * SDL_DisplayFormatAlpha(SDL_Surface *surface);
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* YUV video surface overlay functions                                       */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/* This function creates a video output overlay
+   Calling the returned surface an overlay is something of a misnomer because
+   the contents of the display surface underneath the area where the overlay
+   is shown is undefined - it may be overwritten with the converted YUV data.
+*/
+extern DECLSPEC SDL_Overlay *SDL_CreateYUVOverlay(int width, int height,
+				Uint32 format, SDL_Surface *display);
+
+/* Lock an overlay for direct access, and unlock it when you are done */
+extern DECLSPEC int SDL_LockYUVOverlay(SDL_Overlay *overlay);
+extern DECLSPEC void SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
+
+/* Blit a video overlay to the display surface.
+   The contents of the video surface underneath the blit destination are
+   not defined.  
+   The width and height of the destination rectangle may be different from
+   that of the overlay, but currently only 2x scaling is supported.
+*/
+extern DECLSPEC int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect);
+
+/* Free a video overlay */
+extern DECLSPEC void SDL_FreeYUVOverlay(SDL_Overlay *overlay);
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* OpenGL support functions.                                                 */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Dynamically load a GL driver, if SDL is built with dynamic GL.
+ *
+ * SDL links normally with the OpenGL library on your system by default,
+ * but you can compile it to dynamically load the GL driver at runtime.
+ * If you do this, you need to retrieve all of the GL functions used in
+ * your program from the dynamic library using SDL_GL_GetProcAddress().
+ *
+ * This is disabled in default builds of SDL.
+ */
+extern DECLSPEC int SDL_GL_LoadLibrary(const char *path);
+
+/*
+ * Get the address of a GL function (for extension functions)
+ */
+extern DECLSPEC void *SDL_GL_GetProcAddress(const char* proc);
+
+/*
+ * Set an attribute of the OpenGL subsystem before intialization.
+ */
+extern DECLSPEC int SDL_GL_SetAttribute(SDL_GLattr attr, int value);
+
+/*
+ * Get an attribute of the OpenGL subsystem from the windowing
+ * interface, such as glX. This is of course different from getting
+ * the values from SDL's internal OpenGL subsystem, which only
+ * stores the values you request before initialization.
+ *
+ * Developers should track the values they pass into SDL_GL_SetAttribute
+ * themselves if they want to retrieve these values.
+ */
+extern DECLSPEC int SDL_GL_GetAttribute(SDL_GLattr attr, int* value);
+
+/*
+ * Swap the OpenGL buffers, if double-buffering is supported.
+ */
+extern DECLSPEC void SDL_GL_SwapBuffers(void);
+
+/*
+ * Internal functions that should not be called unless you have read
+ * and understood the source code for these functions.
+ */
+extern DECLSPEC void SDL_GL_UpdateRects(int numrects, SDL_Rect* rects);
+extern DECLSPEC void SDL_GL_Lock(void);
+extern DECLSPEC void SDL_GL_Unlock(void);
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+/* These functions allow interaction with the window manager, if any.        */
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
+
+/*
+ * Sets/Gets the title and icon text of the display window
+ */
+extern DECLSPEC void SDL_WM_SetCaption(const char *title, const char *icon);
+extern DECLSPEC void SDL_WM_GetCaption(char **title, char **icon);
+
+/*
+ * Sets the icon for the display window.
+ * This function must be called before the first call to SDL_SetVideoMode().
+ * It takes an icon surface, and a mask in MSB format.
+ * If 'mask' is NULL, the entire icon surface will be used as the icon.
+ */
+extern DECLSPEC void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask);
+
+/*
+ * This function iconifies the window, and returns 1 if it succeeded.
+ * If the function succeeds, it generates an SDL_APPACTIVE loss event.
+ * This function is a noop and returns 0 in non-windowed environments.
+ */
+extern DECLSPEC int SDL_WM_IconifyWindow(void);
+
+/*
+ * Toggle fullscreen mode without changing the contents of the screen.
+ * If the display surface does not require locking before accessing
+ * the pixel information, then the memory pointers will not change.
+ *
+ * If this function was able to toggle fullscreen mode (change from 
+ * running in a window to fullscreen, or vice-versa), it will return 1.
+ * If it is not implemented, or fails, it returns 0.
+ *
+ * The next call to SDL_SetVideoMode() will set the mode fullscreen
+ * attribute based on the flags parameter - if SDL_FULLSCREEN is not
+ * set, then the display will be windowed by default where supported.
+ *
+ * This is currently only implemented in the X11 video driver.
+ */
+extern DECLSPEC int SDL_WM_ToggleFullScreen(SDL_Surface *surface);
+
+/*
+ * This function allows you to set and query the input grab state of
+ * the application.  It returns the new input grab state.
+ */
+typedef enum {
+	SDL_GRAB_QUERY = -1,
+	SDL_GRAB_OFF = 0,
+	SDL_GRAB_ON = 1,
+	SDL_GRAB_FULLSCREEN	/* Used internally */
+} SDL_GrabMode;
+/*
+ * Grabbing means that the mouse is confined to the application window,
+ * and nearly all keyboard input is passed directly to the application,
+ * and not interpreted by a window manager, if any.
+ */
+extern DECLSPEC SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode);
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+}
+#endif
+#include "close_code.h"
+
+#endif /* _SDL_video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/begin_code.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,86 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+/* This file sets things up for C dynamic library function definitions,
+   static inlined functions, and structures aligned at 4-byte alignment.
+   If you don't like ugly C preprocessor code, don't look at this file. :)
+*/
+
+/* This shouldn't be nested -- included it around code only. */
+#ifdef _begin_code_h
+#error Nested inclusion of begin_code.h
+#endif
+#define _begin_code_h
+
+/* Some compilers use a special export keyword */
+#ifndef DECLSPEC
+# ifdef __BEOS__
+#  if defined(__GNUC__)
+#   define DECLSPEC	__declspec(dllexport)
+#  else
+#   define DECLSPEC	__declspec(export)
+#  endif
+# else
+# ifdef WIN32
+#  define DECLSPEC	__declspec(dllexport)
+# else
+#  define DECLSPEC
+# endif
+# endif
+#endif
+
+/* Force structure packing at 4 byte alignment.
+   This is necessary if the header is included in code which has structure
+   packing set to an alternate value, say for loading structures from disk.
+   The packing is reset to the previous value in close_code.h
+ */
+#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__) || defined(__BORLANDC__)
+#ifdef _MSC_VER
+#pragma warning(disable: 4103)
+#endif
+#ifdef __BORLANDC__
+#pragma nopackwarning
+#endif
+#pragma pack(push,4)
+#endif /* Compiler needs structure packing set */
+
+/* Set up compiler-specific options for inlining functions */
+#ifndef SDL_INLINE_OKAY
+#ifdef __GNUC__
+#define SDL_INLINE_OKAY
+#else
+/* Add any special compiler-specific cases here */
+#if !defined(_MSC_VER) && !defined(__MRC__) && !defined(_SGI_SOURCE)
+#define __inline__ inline
+#define SDL_INLINE_OKAY
+#endif /* Not a funky compiler */
+#endif /* GNU C */
+#endif /* SDL_INLINE_OKAY */
+
+/* If inlining isn't supported, remove "__inline__", turning static
+   inlined functions into static functions (resulting in code bloat
+   in all files which include the offending header files)
+*/
+#ifndef SDL_INLINE_OKAY
+#define __inline__
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/close_code.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+/* This file reverses the effects of begin_code.h and should be included
+   after you finish any function and structure declarations in your headers
+*/
+
+#undef _begin_code_h
+
+/* Reset structure packing at previous byte alignment */
+#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__WATCOMC__)  || defined(__BORLANDC__)
+#ifdef __BORLANDC__
+#pragma nopackwarning
+#endif
+#pragma pack(pop)
+#endif /* Compiler needs structure packing set */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/install-sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+		chmodcmd=""
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ltconfig	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,3123 @@
+#! /bin/sh
+
+# ltconfig - Create a system-specific libtool.
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A lot of this script is taken from autoconf-2.10.
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+echo=echo
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec "$SHELL" "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# Find the correct PATH separator.  Usually this is `:', but
+# DJGPP uses `;' like DOS.
+if test "X${PATH_SEPARATOR+set}" != Xset; then
+  UNAME=${UNAME-`uname 2>/dev/null`}
+  case X$UNAME in
+    *-DOS) PATH_SEPARATOR=';' ;;
+    *)     PATH_SEPARATOR=':' ;;
+  esac
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+if test "X${echo_test_string+set}" != Xset; then
+  # find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string="`eval $cmd`") 2>/dev/null &&
+       echo_test_string="`eval $cmd`" &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null; then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" != 'X\t' ||
+   test "X`($echo "$echo_test_string") 2>/dev/null`" != X"$echo_test_string"; then
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+  for dir in $PATH /usr/ucb; do
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       test "X`($dir/echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       test "X`(print -r "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+	 test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running ltconfig again with it.
+      ORIGINAL_CONFIG_SHELL="${CONFIG_SHELL-/bin/sh}"
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec "$CONFIG_SHELL" "$0" --no-reexec ${1+"$@"}
+    else
+      # Try using printf.
+      echo='printf "%s\n"'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+	 test "X`($echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+	# Cool, printf works
+	:
+      elif test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+	   test "X`("$ORIGINAL_CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+	CONFIG_SHELL="$ORIGINAL_CONFIG_SHELL"
+	export CONFIG_SHELL
+	SHELL="$CONFIG_SHELL"
+	export SHELL
+	echo="$CONFIG_SHELL $0 --fallback-echo"
+      elif test "X`("$CONFIG_SHELL" "$0" --fallback-echo '\t') 2>/dev/null`" = 'X\t' &&
+	   test "X`("$CONFIG_SHELL" "$0" --fallback-echo "$echo_test_string") 2>/dev/null`" = X"$echo_test_string"; then
+	echo="$CONFIG_SHELL $0 --fallback-echo"
+      else
+	# maybe with a smaller string...
+	prev=:
+
+	for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+	  if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null; then
+	    break
+	  fi
+	  prev="$cmd"
+	done
+
+	if test "$prev" != 'sed 50q "$0"'; then
+	  echo_test_string=`eval $prev`
+	  export echo_test_string
+	  exec "${ORIGINAL_CONFIG_SHELL}" "$0" ${1+"$@"}
+	else
+	  # Oops.  We lost completely, so just stick with echo.
+	  echo=echo
+	fi
+      fi
+    fi
+  fi
+fi
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# The name of this program.
+progname=`$echo "X$0" | $Xsed -e 's%^.*/%%'`
+
+# Constants:
+PROGRAM=ltconfig
+PACKAGE=libtool
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
+ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
+ac_link='${CC-cc} -o conftest $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
+rm="rm -f"
+
+help="Try \`$progname --help' for more information."
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+enable_shared=yes
+# All known linkers require a `.a' archive for static linking (except M$VC,
+# which needs '.lib').
+enable_static=yes
+enable_fast_install=yes
+enable_dlopen=unknown
+enable_win32_dll=no
+ltmain=
+silent=
+srcdir=
+ac_config_guess=
+ac_config_sub=
+host=
+nonopt=
+ofile="$default_ofile"
+verify_host=yes
+with_gcc=no
+with_gnu_ld=no
+need_locks=yes
+ac_ext=c
+objext=o
+libext=a
+exeext=
+cache_file=
+
+old_AR="$AR"
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+old_CPPFLAGS="$CPPFLAGS"
+old_LDFLAGS="$LDFLAGS"
+old_LD="$LD"
+old_LN_S="$LN_S"
+old_LIBS="$LIBS"
+old_NM="$NM"
+old_RANLIB="$RANLIB"
+old_DLLTOOL="$DLLTOOL"
+old_OBJDUMP="$OBJDUMP"
+old_AS="$AS"
+
+# Parse the command line options.
+args=
+prev=
+for option
+do
+  case "$option" in
+  -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    eval "$prev=\$option"
+    prev=
+    continue
+  fi
+
+  case "$option" in
+  --help) cat <<EOM
+Usage: $progname [OPTION]... [HOST [LTMAIN]]
+
+Generate a system-specific libtool script.
+
+    --debug                enable verbose shell tracing
+    --disable-shared       do not build shared libraries
+    --disable-static       do not build static libraries
+    --disable-fast-install do not optimize for fast installation
+    --enable-dlopen        enable dlopen support
+    --enable-win32-dll     enable building dlls on win32 hosts
+    --help                 display this help and exit
+    --no-verify            do not verify that HOST is a valid host type
+-o, --output=FILE          specify the output file [default=$default_ofile]
+    --quiet                same as \`--silent'
+    --silent               do not print informational messages
+    --srcdir=DIR           find \`config.guess' in DIR
+    --version              output version information and exit
+    --with-gcc             assume that the GNU C compiler will be used
+    --with-gnu-ld          assume that the C compiler uses the GNU linker
+    --disable-lock         disable file locking
+    --cache-file=FILE      configure cache file
+
+LTMAIN is the \`ltmain.sh' shell script fragment or \`ltmain.c' program
+that provides basic libtool functionality.
+
+HOST is the canonical host system name [default=guessed].
+EOM
+  exit 0
+  ;;
+
+  --debug)
+    echo "$progname: enabling shell trace mode"
+    set -x
+    ;;
+
+  --disable-shared) enable_shared=no ;;
+
+  --disable-static) enable_static=no ;;
+
+  --disable-fast-install) enable_fast_install=no ;;
+
+  --enable-dlopen) enable_dlopen=yes ;;
+
+  --enable-win32-dll) enable_win32_dll=yes ;;
+
+  --quiet | --silent) silent=yes ;;
+
+  --srcdir) prev=srcdir ;;
+  --srcdir=*) srcdir="$optarg" ;;
+
+  --no-verify) verify_host=no ;;
+
+  --output | -o) prev=ofile ;;
+  --output=*) ofile="$optarg" ;;
+
+  --version) echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"; exit 0 ;;
+
+  --with-gcc) with_gcc=yes ;;
+  --with-gnu-ld) with_gnu_ld=yes ;;
+
+  --disable-lock) need_locks=no ;;
+
+  --cache-file=*) cache_file="$optarg" ;;
+
+  -*)
+    echo "$progname: unrecognized option \`$option'" 1>&2
+    echo "$help" 1>&2
+    exit 1
+    ;;
+
+  *)
+    if test -z "$ltmain"; then
+      ltmain="$option"
+    elif test -z "$host"; then
+# This generates an unnecessary warning for sparc-sun-solaris4.1.3_U1
+#      if test -n "`echo $option| sed 's/[-a-z0-9.]//g'`"; then
+#        echo "$progname: warning \`$option' is not a valid host type" 1>&2
+#      fi
+      host="$option"
+    else
+      echo "$progname: too many arguments" 1>&2
+      echo "$help" 1>&2
+      exit 1
+    fi ;;
+  esac
+done
+
+if test -z "$ltmain"; then
+  echo "$progname: you must specify a LTMAIN file" 1>&2
+  echo "$help" 1>&2
+  exit 1
+fi
+
+if test ! -f "$ltmain"; then
+  echo "$progname: \`$ltmain' does not exist" 1>&2
+  echo "$help" 1>&2
+  exit 1
+fi
+
+# Quote any args containing shell metacharacters.
+ltconfig_args=
+for arg
+do
+  case "$arg" in
+  *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ltconfig_args="$ltconfig_args '$arg'" ;;
+  *) ltconfig_args="$ltconfig_args $arg" ;;
+  esac
+done
+
+# A relevant subset of AC_INIT.
+
+# File descriptor usage:
+# 0 standard input
+# 1 file creation
+# 2 errors and warnings
+# 3 some systems may open it to /dev/tty
+# 4 used on the Kubota Titan
+# 5 compiler messages saved in config.log
+# 6 checking for... messages and results
+if test "$silent" = yes; then
+  exec 6>/dev/null
+else
+  exec 6>&1
+fi
+exec 5>>./config.log
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+if test "X${LC_ALL+set}" = Xset; then LC_ALL=C; export LC_ALL; fi
+if test "X${LANG+set}"   = Xset; then LANG=C;   export LANG;   fi
+
+if test -n "$cache_file" && test -r "$cache_file"; then
+  echo "loading cache $cache_file within ltconfig"
+  . $cache_file
+fi
+
+if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
+  # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
+  if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
+    ac_n= ac_c='
+' ac_t='	'
+  else
+    ac_n=-n ac_c= ac_t=
+  fi
+else
+  ac_n= ac_c='\c' ac_t=
+fi
+
+if test -z "$srcdir"; then
+  # Assume the source directory is the same one as the path to LTMAIN.
+  srcdir=`$echo "X$ltmain" | $Xsed -e 's%/[^/]*$%%'`
+  test "$srcdir" = "$ltmain" && srcdir=.
+fi
+
+trap "$rm conftest*; exit 1" 1 2 15
+if test "$verify_host" = yes; then
+  # Check for config.guess and config.sub.
+  ac_aux_dir=
+  for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do
+    if test -f $ac_dir/config.guess; then
+      ac_aux_dir=$ac_dir
+      break
+    fi
+  done
+  if test -z "$ac_aux_dir"; then
+    echo "$progname: cannot find config.guess in $srcdir $srcdir/.. $srcdir/../.." 1>&2
+    echo "$help" 1>&2
+    exit 1
+  fi
+  ac_config_guess=$ac_aux_dir/config.guess
+  ac_config_sub=$ac_aux_dir/config.sub
+
+  # Make sure we can run config.sub.
+  if $SHELL $ac_config_sub sun4 >/dev/null 2>&1; then :
+  else
+    echo "$progname: cannot run $ac_config_sub" 1>&2
+    echo "$help" 1>&2
+    exit 1
+  fi
+
+  echo $ac_n "checking host system type""... $ac_c" 1>&6
+
+  host_alias=$host
+  case "$host_alias" in
+  "")
+    if host_alias=`$SHELL $ac_config_guess`; then :
+    else
+      echo "$progname: cannot guess host type; you must specify one" 1>&2
+      echo "$help" 1>&2
+      exit 1
+    fi ;;
+  esac
+  host=`$SHELL $ac_config_sub $host_alias`
+  echo "$ac_t$host" 1>&6
+
+  # Make sure the host verified.
+  test -z "$host" && exit 1
+
+elif test -z "$host"; then
+  echo "$progname: you must specify a host type if you use \`--no-verify'" 1>&2
+  echo "$help" 1>&2
+  exit 1
+else
+  host_alias=$host
+fi
+
+# Transform linux* to *-*-linux-gnu*, to support old configure scripts.
+case "$host_os" in
+linux-gnu*) ;;
+linux*) host=`echo $host | sed 's/^\(.*-.*-linux\)\(.*\)$/\1-gnu\2/'`
+esac
+
+host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
+host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
+host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
+
+case "$host_os" in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR cru $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+# Set a sane default for `AR'.
+test -z "$AR" && AR=ar
+
+# Set a sane default for `OBJDUMP'.
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+# If RANLIB is not set, then run the test.
+if test "${RANLIB+set}" != "set"; then
+  result=no
+
+  echo $ac_n "checking for ranlib... $ac_c" 1>&6
+  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+  for dir in $PATH; do
+    test -z "$dir" && dir=.
+    if test -f $dir/ranlib || test -f $dir/ranlib$ac_exeext; then
+      RANLIB="ranlib"
+      result="ranlib"
+      break
+    fi
+  done
+  IFS="$save_ifs"
+
+  echo "$ac_t$result" 1>&6
+fi
+
+if test -n "$RANLIB"; then
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+  old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+fi
+
+# Set sane defaults for `DLLTOOL', `OBJDUMP', and `AS', used on cygwin.
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$AS" && AS=as
+
+# Check to see if we are using GCC.
+if test "$with_gcc" != yes || test -z "$CC"; then
+  # If CC is not set, then try to find GCC or a usable CC.
+  if test -z "$CC"; then
+    echo $ac_n "checking for gcc... $ac_c" 1>&6
+    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/gcc || test -f $dir/gcc$ac_exeext; then
+	CC="gcc"
+	break
+      fi
+    done
+    IFS="$save_ifs"
+
+    if test -n "$CC"; then
+      echo "$ac_t$CC" 1>&6
+    else
+      echo "$ac_t"no 1>&6
+    fi
+  fi
+
+  # Not "gcc", so try "cc", rejecting "/usr/ucb/cc".
+  if test -z "$CC"; then
+    echo $ac_n "checking for cc... $ac_c" 1>&6
+    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    cc_rejected=no
+    for dir in $PATH; do
+      test -z "$dir" && dir=.
+      if test -f $dir/cc || test -f $dir/cc$ac_exeext; then
+	if test "$dir/cc" = "/usr/ucb/cc"; then
+	  cc_rejected=yes
+	  continue
+	fi
+	CC="cc"
+	break
+      fi
+    done
+    IFS="$save_ifs"
+    if test $cc_rejected = yes; then
+      # We found a bogon in the path, so make sure we never use it.
+      set dummy $CC
+      shift
+      if test $# -gt 0; then
+	# We chose a different compiler from the bogus one.
+	# However, it has the same name, so the bogon will be chosen
+	# first if we set CC to just the name; use the full file name.
+	shift
+	set dummy "$dir/cc" "$@"
+	shift
+	CC="$@"
+      fi
+    fi
+
+    if test -n "$CC"; then
+      echo "$ac_t$CC" 1>&6
+    else
+      echo "$ac_t"no 1>&6
+    fi
+
+    if test -z "$CC"; then
+      echo "$progname: error: no acceptable cc found in \$PATH" 1>&2
+      exit 1
+    fi
+  fi
+
+  # Now see if the compiler is really GCC.
+  with_gcc=no
+  echo $ac_n "checking whether we are using GNU C... $ac_c" 1>&6
+  echo "$progname:581: checking whether we are using GNU C" >&5
+
+  $rm conftest.c
+  cat > conftest.c <<EOF
+#ifdef __GNUC__
+  yes;
+#endif
+EOF
+  if { ac_try='${CC-cc} -E conftest.c'; { (eval echo $progname:589: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
+    with_gcc=yes
+  fi
+  $rm conftest.c
+  echo "$ac_t$with_gcc" 1>&6
+fi
+
+# Allow CC to be a program name with arguments.
+set dummy $CC
+compiler="$2"
+
+echo $ac_n "checking for object suffix... $ac_c" 1>&6
+$rm conftest*
+echo 'int i = 1;' > conftest.c
+echo "$progname:603: checking for object suffix" >& 5
+if { (eval echo $progname:604: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; }; then
+  # Append any warnings to the config.log.
+  cat conftest.err 1>&5
+
+  for ac_file in conftest.*; do
+    case $ac_file in
+    *.c) ;;
+    *) objext=`echo $ac_file | sed -e s/conftest.//` ;;
+    esac
+  done
+else
+  cat conftest.err 1>&5
+  echo "$progname: failed program was:" >&5
+  cat conftest.c >&5
+fi
+$rm conftest*
+echo "$ac_t$objext" 1>&6
+
+echo $ac_n "checking for executable suffix... $ac_c" 1>&6
+if eval "test \"`echo '$''{'ac_cv_exeext'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_cv_exeext="no"
+  $rm conftest*
+  echo 'main () { return 0; }' > conftest.c
+  echo "$progname:629: checking for executable suffix" >& 5
+  if { (eval echo $progname:630: \"$ac_link\") 1>&5; (eval $ac_link) 2>conftest.err; }; then
+    # Append any warnings to the config.log.
+    cat conftest.err 1>&5
+
+    for ac_file in conftest.*; do
+      case $ac_file in
+      *.c | *.err | *.$objext ) ;;
+      *) ac_cv_exeext=.`echo $ac_file | sed -e s/conftest.//` ;;
+      esac
+    done
+  else
+    cat conftest.err 1>&5
+    echo "$progname: failed program was:" >&5
+    cat conftest.c >&5
+  fi
+  $rm conftest*
+fi
+if test "X$ac_cv_exeext" = Xno; then
+  exeext=""
+else
+  exeext="$ac_cv_exeext"
+fi
+echo "$ac_t$ac_cv_exeext" 1>&6
+
+echo $ac_n "checking for $compiler option to produce PIC... $ac_c" 1>&6
+pic_flag=
+special_shlib_compile_flags=
+wl=
+link_static_flag=
+no_builtin_flag=
+
+if test "$with_gcc" = yes; then
+  wl='-Wl,'
+  link_static_flag='-static'
+
+  case "$host_os" in
+  beos* | irix5* | irix6* | osf3* | osf4* | osf5*)
+    # PIC is the default for these OSes.
+    ;;
+  aix*)
+    # Below there is a dirty hack to force normal static linking with -ldl
+    # The problem is because libdl dynamically linked with both libc and
+    # libC (AIX C++ library), which obviously doesn't included in libraries
+    # list by gcc. This cause undefined symbols with -static flags.
+    # This hack allows C programs to be linked with "-static -ldl", but
+    # we not sure about C++ programs.
+    link_static_flag="$link_static_flag ${wl}-lC"
+    ;;
+  cygwin* | mingw* | os2*)
+    # We can build DLLs from non-PIC.
+    ;;
+  amigaos*)
+    # FIXME: we need at least 68020 code to build shared libraries, but
+    # adding the `-m68020' flag to GCC prevents building anything better,
+    # like `-m68040'.
+    pic_flag='-m68020 -resident32 -malways-restore-a4'
+    ;;
+  sysv4*MP*)
+    if test -d /usr/nec; then
+       pic_flag=-Kconform_pic
+    fi
+    ;;
+  *)
+    pic_flag='-fPIC'
+    ;;
+  esac
+else
+  # PORTME Check for PIC flags for the system compiler.
+  case "$host_os" in
+  aix3* | aix4*)
+    # All AIX code is PIC.
+    link_static_flag='-bnso -bI:/lib/syscalls.exp'
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    # Is there a better link_static_flag that works with the bundled CC?
+    wl='-Wl,'
+    link_static_flag="${wl}-a ${wl}archive"
+    pic_flag='+Z'
+    ;;
+
+  irix5* | irix6*)
+    wl='-Wl,'
+    link_static_flag='-non_shared'
+    # PIC (with -KPIC) is the default.
+    ;;
+
+  cygwin* | mingw* | os2*)
+    # We can build DLLs from non-PIC.
+    ;;
+
+  osf3* | osf4* | osf5*)
+    # All OSF/1 code is PIC.
+    wl='-Wl,'
+    link_static_flag='-non_shared'
+    ;;
+
+  sco3.2v5*)
+    pic_flag='-Kpic'
+    link_static_flag='-dn'
+    special_shlib_compile_flags='-belf'
+    ;;
+
+  solaris*)
+    pic_flag='-KPIC'
+    link_static_flag='-Bstatic'
+    wl='-Wl,'
+    ;;
+
+  sunos4*)
+    pic_flag='-PIC'
+    link_static_flag='-Bstatic'
+    wl='-Qoption ld '
+    ;;
+
+  sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+    pic_flag='-KPIC'
+    link_static_flag='-Bstatic'
+    wl='-Wl,'
+    ;;
+
+  uts4*)
+    pic_flag='-pic'
+    link_static_flag='-Bstatic'
+    ;;
+  sysv4*MP*)
+    if test -d /usr/nec ;then
+      pic_flag='-Kconform_pic'
+      link_static_flag='-Bstatic'
+    fi
+    ;;
+  *)
+    can_build_shared=no
+    ;;
+  esac
+fi
+
+if test -n "$pic_flag"; then
+  echo "$ac_t$pic_flag" 1>&6
+
+  # Check to make sure the pic_flag actually works.
+  echo $ac_n "checking if $compiler PIC flag $pic_flag works... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS $pic_flag -DPIC"
+  echo "$progname:776: checking if $compiler PIC flag $pic_flag works" >&5
+  if { (eval echo $progname:777: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.$objext; then
+    # Append any warnings to the config.log.
+    cat conftest.err 1>&5
+    
+    case "$host_os" in
+    hpux9* | hpux10* | hpux11*)
+      # On HP-UX, both CC and GCC only warn that PIC is supported... then they
+      # create non-PIC objects.  So, if there were any warnings, we assume that
+      # PIC is not supported.
+      if test -s conftest.err; then
+	echo "$ac_t"no 1>&6
+	can_build_shared=no
+	pic_flag=
+      else
+	echo "$ac_t"yes 1>&6
+	pic_flag=" $pic_flag"
+      fi
+      ;;
+    *)
+      echo "$ac_t"yes 1>&6
+      pic_flag=" $pic_flag"
+      ;;
+    esac
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    can_build_shared=no
+    pic_flag=
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+else
+  echo "$ac_t"none 1>&6
+fi
+
+# Check to see if options -o and -c are simultaneously supported by compiler
+echo $ac_n "checking if $compiler supports -c -o file.o... $ac_c" 1>&6
+$rm -r conftest 2>/dev/null
+mkdir conftest
+cd conftest
+$rm conftest*
+echo "int some_variable = 0;" > conftest.c
+mkdir out
+# According to Tom Tromey, Ian Lance Taylor reported there are C compilers
+# that will create temporary files in the current directory regardless of
+# the output directory.  Thus, making CWD read-only will cause this test
+# to fail, enabling locking or at least warning the user not to do parallel
+# builds.
+chmod -w .
+save_CFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -o out/conftest2.o"
+echo "$progname:829: checking if $compiler supports -c -o file.o" >&5
+if { (eval echo $progname:830: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>out/conftest.err; } && test -s out/conftest2.o; then
+
+  # The compiler can only warn and ignore the option if not recognized
+  # So say no if there are warnings
+    if test -s out/conftest.err; then
+      echo "$ac_t"no 1>&6
+      compiler_c_o=no
+    else
+      echo "$ac_t"yes 1>&6
+      compiler_c_o=yes
+    fi
+else
+  # Append any errors to the config.log.
+  cat out/conftest.err 1>&5
+  compiler_c_o=no
+  echo "$ac_t"no 1>&6
+fi
+CFLAGS="$save_CFLAGS"
+chmod u+w .
+$rm conftest* out/*
+rmdir out
+cd ..
+rmdir conftest
+$rm -r conftest 2>/dev/null
+
+if test x"$compiler_c_o" = x"yes"; then
+  # Check to see if we can write to a .lo
+  echo $ac_n "checking if $compiler supports -c -o file.lo... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -c -o conftest.lo"
+  echo "$progname:862: checking if $compiler supports -c -o file.lo" >&5
+if { (eval echo $progname:863: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.lo; then
+
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+      if test -s conftest.err; then
+	echo "$ac_t"no 1>&6
+	compiler_o_lo=no
+      else
+	echo "$ac_t"yes 1>&6
+	compiler_o_lo=yes
+      fi
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    compiler_o_lo=no
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+else
+  compiler_o_lo=no
+fi
+
+# Check to see if we can do hard links to lock some files if needed
+hard_links="nottested"
+if test "$compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  echo $ac_n "checking if we can lock with hard links... $ac_c" 1>&6
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  echo "$ac_t$hard_links" 1>&6
+  $rm conftest*
+  if test "$hard_links" = no; then
+    echo "*** WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+if test "$with_gcc" = yes; then
+  # Check to see if options -fno-rtti -fno-exceptions are supported by compiler
+  echo $ac_n "checking if $compiler supports -fno-rtti -fno-exceptions ... $ac_c" 1>&6
+  $rm conftest*
+  echo "int some_variable = 0;" > conftest.c
+  save_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -fno-rtti -fno-exceptions -c conftest.c"
+  echo "$progname:914: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+  if { (eval echo $progname:915: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>conftest.err; } && test -s conftest.o; then
+
+    # The compiler can only warn and ignore the option if not recognized
+    # So say no if there are warnings
+      if test -s conftest.err; then
+	echo "$ac_t"no 1>&6
+	compiler_rtti_exceptions=no
+      else
+	echo "$ac_t"yes 1>&6
+	compiler_rtti_exceptions=yes
+      fi
+  else
+    # Append any errors to the config.log.
+    cat conftest.err 1>&5
+    compiler_rtti_exceptions=no
+    echo "$ac_t"no 1>&6
+  fi
+  CFLAGS="$save_CFLAGS"
+  $rm conftest*
+
+  if test "$compiler_rtti_exceptions" = "yes"; then
+    no_builtin_flag=' -fno-builtin -fno-rtti -fno-exceptions'
+  else
+    no_builtin_flag=' -fno-builtin'
+  fi
+  
+fi
+
+# Check for any special shared library compilation flags.
+if test -n "$special_shlib_compile_flags"; then
+  echo "$progname: warning: \`$CC' requires \`$special_shlib_compile_flags' to build shared libraries" 1>&2
+  if echo "$old_CC $old_CFLAGS " | egrep -e "[ 	]$special_shlib_compile_flags[ 	]" >/dev/null; then :
+  else
+    echo "$progname: add \`$special_shlib_compile_flags' to the CC or CFLAGS env variable and reconfigure" 1>&2
+    can_build_shared=no
+  fi
+fi
+
+echo $ac_n "checking if $compiler static flag $link_static_flag works... $ac_c" 1>&6
+$rm conftest*
+echo 'main(){return(0);}' > conftest.c
+save_LDFLAGS="$LDFLAGS"
+LDFLAGS="$LDFLAGS $link_static_flag"
+echo "$progname:958: checking if $compiler static flag $link_static_flag works" >&5
+if { (eval echo $progname:959: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+  echo "$ac_t$link_static_flag" 1>&6
+else
+  echo "$ac_t"none 1>&6
+  link_static_flag=
+fi
+LDFLAGS="$save_LDFLAGS"
+$rm conftest*
+
+if test -z "$LN_S"; then
+  # Check to see if we can use ln -s, or we need hard links.
+  echo $ac_n "checking whether ln -s works... $ac_c" 1>&6
+  $rm conftest.dat
+  if ln -s X conftest.dat 2>/dev/null; then
+    $rm conftest.dat
+    LN_S="ln -s"
+  else
+    LN_S=ln
+  fi
+  if test "$LN_S" = "ln -s"; then
+    echo "$ac_t"yes 1>&6
+  else
+    echo "$ac_t"no 1>&6
+  fi
+fi
+
+# Make sure LD is an absolute path.
+if test -z "$LD"; then
+  ac_prog=ld
+  if test "$with_gcc" = yes; then
+    # Check if gcc -print-prog-name=ld gives a path.
+    echo $ac_n "checking for ld used by GCC... $ac_c" 1>&6
+    echo "$progname:991: checking for ld used by GCC" >&5
+    ac_prog=`($CC -print-prog-name=ld) 2>&5`
+    case "$ac_prog" in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+    "")
+      # If it fails, then pretend we are not using GCC.
+      ac_prog=ld
+      ;;
+    *)
+      # If it is relative, then search for the first ld in PATH.
+      with_gnu_ld=unknown
+      ;;
+    esac
+  elif test "$with_gnu_ld" = yes; then
+    echo $ac_n "checking for GNU ld... $ac_c" 1>&6
+    echo "$progname:1015: checking for GNU ld" >&5
+  else
+    echo $ac_n "checking for non-GNU ld""... $ac_c" 1>&6
+    echo "$progname:1018: checking for non-GNU ld" >&5
+  fi
+
+  if test -z "$LD"; then
+    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for ac_dir in $PATH; do
+      test -z "$ac_dir" && ac_dir=.
+      if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+	LD="$ac_dir/$ac_prog"
+	# Check to see if the program is GNU ld.  I'd rather use --version,
+	# but apparently some GNU ld's only accept -v.
+	# Break only if it was the GNU/non-GNU ld that we prefer.
+	if "$LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	  test "$with_gnu_ld" != no && break
+	else
+	  test "$with_gnu_ld" != yes && break
+	fi
+      fi
+    done
+    IFS="$ac_save_ifs"
+  fi
+
+  if test -n "$LD"; then
+    echo "$ac_t$LD" 1>&6
+  else
+    echo "$ac_t"no 1>&6
+  fi
+
+  if test -z "$LD"; then
+    echo "$progname: error: no acceptable ld found in \$PATH" 1>&2
+    exit 1
+  fi
+fi
+
+# Check to see if it really is or is not GNU ld.
+echo $ac_n "checking if the linker ($LD) is GNU ld... $ac_c" 1>&6
+# I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+echo "$ac_t$with_gnu_ld" 1>&6
+
+# See if the linker supports building shared libraries.
+echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c" 1>&6
+
+allow_undefined_flag=
+no_undefined_flag=
+need_lib_prefix=unknown
+need_version=unknown
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+archive_cmds=
+archive_expsym_cmds=
+old_archive_from_new_cmds=
+export_dynamic_flag_spec=
+whole_archive_flag_spec=
+thread_safe_flag_spec=
+hardcode_libdir_flag_spec=
+hardcode_libdir_separator=
+hardcode_direct=no
+hardcode_minus_L=no
+hardcode_shlibpath_var=unsupported
+runpath_var=
+always_export_symbols=no
+export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | sed '\''s/.* //'\'' | sort | uniq > $export_symbols'
+# include_expsyms should be a list of space-separated symbols to be *always*
+# included in the symbol list
+include_expsyms=
+# exclude_expsyms can be an egrep regular expression of symbols to exclude
+# it will be wrapped by ` (' and `)$', so one must not match beginning or
+# end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+# as well as any symbol that contains `d'.
+exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+# Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+# platforms (ab)use it in PIC code, but their linkers get confused if
+# the symbol is explicitly referenced.  Since portable code cannot
+# rely on this symbol name, it's probably fine to never include it in
+# preloaded symbol tables.
+
+case "$host_os" in
+cygwin* | mingw*)
+  # FIXME: the MSVC++ port hasn't been tested in a loooong time
+  # When not using gcc, we currently assume that we are using
+  # Microsoft Visual C++.
+  if test "$with_gcc" != yes; then
+    with_gnu_ld=no
+  fi
+  ;;
+
+esac
+
+ld_shlibs=yes
+if test "$with_gnu_ld" = yes; then
+  # If archive_cmds runs LD, not CC, wlarc should be empty
+  wlarc='${wl}'
+
+  # See if GNU ld supports shared libraries.
+  case "$host_os" in
+  aix3* | aix4*)
+    # On AIX, the GNU linker is very broken
+    ld_shlibs=no
+    cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+    ;;
+
+  amigaos*)
+    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+
+    # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+    # that the semantics of dynamic libraries on AmigaOS, at least up
+    # to version 4, is to share data among multiple programs linked
+    # with the same dynamic library.  Since this doesn't match the
+    # behavior of shared libraries on other platforms, we can use
+    # them.
+    ld_shlibs=no
+    ;;
+
+  beos*)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      #allow_undefined_flag=unsupported
+      # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+      # support --undefined.  This deserves some investigation.  FIXME
+      archive_cmds='$CC -nostart $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+
+  cygwin* | mingw*)
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec='-L$libdir'
+#    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+
+    # Extract the symbol export list from an `--export-all' def file,
+    # then regenerate the def file from the symbol export list, so that
+    # the compiled dll only exports the symbol export list.
+    # Be careful not to strip the DATA tag left by newer dlltools.
+    export_symbols_cmds='test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
+      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
+      $DLLTOOL --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def $objdir/$soname-def  $objdir/$soname-ltdll.$objext $libobjs $convenience~
+      sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]*//" -e "s/ *;.*$//" < $objdir/$soname-def > $export_symbols'
+
+    # If DATA tags from a recent dlltool are present, honour them!
+    archive_expsym_cmds='echo EXPORTS > $objdir/$soname-def~
+      _lt_hint=1;
+      cat $export_symbols | while read symbol; do
+        set dummy \$symbol;
+        case \$# in
+          2) echo "	\$2 @ \$_lt_hint ; " >> $objdir/$soname-def;;
+          *) echo "     \$2 @ \$_lt_hint \$3 ; " >> $objdir/$soname-def;;
+        esac;
+	_lt_hint=`expr 1 + \$_lt_hint`;
+      done~
+      test -f $objdir/$soname-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d < $0 > $objdir/$soname-ltdll.c~
+      test -f $objdir/$soname-ltdll.$objext || (cd $objdir && $CC -c $soname-ltdll.c)~
+      $CC -Wl,--base-file,$objdir/$soname-base -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+      $CC -Wl,--base-file,$objdir/$soname-base $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+      $DLLTOOL --as=$AS --dllname $soname --exclude-symbols _DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def $objdir/$soname-def --base-file $objdir/$soname-base --output-exp $objdir/$soname-exp~
+      $CC $objdir/$soname-exp -Wl,--dll -nostartfiles -Wl,-e,_DllMain@12 -o $lib $objdir/$soname-ltdll.$objext $libobjs $deplibs $linkopts~
+      : strip_is_broken_with_dlls_on_win95B - strip $lib'
+
+      old_archive_from_new_cmds='$DLLTOOL --as=$AS --dllname $soname --def $objdir/$soname-def --output-lib $objdir/$libname.a'
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      archive_cmds='$LD -Bshareable $libobjs $deplibs $linkopts -o $lib'
+      # can we support soname and/or expsyms with a.out? -oliva
+    fi
+    ;;
+
+  solaris* | sysv5*)
+    if $LD -v 2>&1 | egrep 'BFD 2\.8' > /dev/null; then
+      ld_shlibs=no
+      cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+    elif $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;      
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    wlarc=
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    if $LD --help 2>&1 | egrep ': supported targets:.* elf' > /dev/null; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname -o $lib'
+      archive_expsym_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+    else
+      ld_shlibs=no
+    fi
+    ;;
+  esac
+
+  if test "$ld_shlibs" = yes; then
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    case $host_os in
+    cygwin* | mingw*)
+      # dlltool doesn't understand --whole-archive et. al.
+      whole_archive_flag_spec=
+      ;;
+    *)
+      # ancient GNU ld didn't support --whole-archive et. al.
+      if $LD --help 2>&1 | egrep 'no-whole-archive' > /dev/null; then
+        whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+        whole_archive_flag_spec=
+      fi
+      ;;
+    esac
+  fi
+else
+  # PORTME fill in a description of your system's linker (not GNU ld)
+  case "$host_os" in
+  aix3*)
+    allow_undefined_flag=unsupported
+    always_export_symbols=yes
+    archive_expsym_cmds='$LD -o $objdir/$soname $libobjs $deplibs $linkopts -bE:$export_symbols -T512 -H512 -bM:SRE~$AR cru $lib $objdir/$soname'
+    # Note: this linker hardcodes the directories in LIBPATH if there
+    # are no directories specified by -L.
+    hardcode_minus_L=yes
+    if test "$with_gcc" = yes && test -z "$link_static_flag"; then
+      # Neither direct hardcoding nor static linking is supported with a
+      # broken collect2.
+      hardcode_direct=unsupported
+    fi
+    ;;
+
+  aix4*)
+    hardcode_libdir_flag_spec='${wl}-b ${wl}nolibpath ${wl}-b ${wl}libpath:$libdir:/usr/lib:/lib'
+    hardcode_libdir_separator=':'
+    if test "$with_gcc" = yes; then
+      collect2name=`${CC} -print-prog-name=collect2`
+      if test -f "$collect2name" && \
+	 strings "$collect2name" | grep resolve_lib_name >/dev/null
+      then
+	# We have reworked collect2
+	hardcode_direct=yes
+      else
+	# We have old collect2
+	hardcode_direct=unsupported
+	# It fails to find uninstalled libraries when the uninstalled
+	# path is not listed in the libpath.  Setting hardcode_minus_L
+	# to unsupported forces relinking
+	hardcode_minus_L=yes
+	hardcode_libdir_flag_spec='-L$libdir'
+	hardcode_libdir_separator=
+      fi
+      shared_flag='-shared'
+    else
+      shared_flag='${wl}-bM:SRE'
+      hardcode_direct=yes
+    fi
+    allow_undefined_flag=' ${wl}-berok'
+    archive_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bexpall ${wl}-bnoentry${allow_undefined_flag}'
+    archive_expsym_cmds="\$CC $shared_flag"' -o $objdir/$soname $libobjs $deplibs $linkopts ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}'
+    case "$host_os" in aix4.[01]|aix4.[01].*)
+      # According to Greg Wooledge, -bexpall is only supported from AIX 4.2 on
+      always_export_symbols=yes ;;
+    esac
+   ;;
+
+  amigaos*)
+    archive_cmds='$rm $objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $objdir/a2ixlibrary.data~$AR cru $lib $libobjs~$RANLIB $lib~(cd $objdir && a2ixlibrary -32)'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    # see comment about different semantics on the GNU ld section
+    ld_shlibs=no
+    ;;
+
+  cygwin* | mingw*)
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    # hardcode_libdir_flag_spec is actually meaningless, as there is
+    # no search path for DLLs.
+    hardcode_libdir_flag_spec=' '
+#    allow_undefined_flag=unsupported
+    # Tell ltmain to make .lib files, not .a files.
+    libext=lib
+    # FIXME: Setting linknames here is a bad hack.
+    archive_cmds='$CC -o $lib $libobjs $linkopts `echo "$deplibs" | sed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+    # The linker will automatically build a .lib file if we build a DLL.
+    old_archive_from_new_cmds='true'
+    # FIXME: Should let the user specify the lib program.
+    old_archive_cmds='lib /OUT:$oldlib$oldobjs'
+    fix_srcfile_path='`cygpath -w $srcfile`'
+    ;;
+
+  freebsd1*)
+    ld_shlibs=no
+    ;;
+
+  # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+  # support.  Future versions do this automatically, but an explicit c++rt0.o
+  # does not break anything, and helps significantly (at the cost of a little
+  # extra space).
+  freebsd2.2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts /usr/lib/c++rt0.o'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+  freebsd2*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+  freebsd*)
+    archive_cmds='$CC -shared -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  hpux9* | hpux10* | hpux11*)
+    case "$host_os" in
+    hpux9*) archive_cmds='$rm $objdir/$soname~$LD -b +b $install_libdir -o $objdir/$soname $libobjs $deplibs $linkopts~test $objdir/$soname = $lib || mv $objdir/$soname $lib' ;;
+    *) archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linkopts' ;;
+    esac
+    hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+    hardcode_libdir_separator=:
+    hardcode_direct=yes
+    hardcode_minus_L=yes # Not in the search PATH, but as the default
+			 # location of the library.
+    export_dynamic_flag_spec='${wl}-E'
+    ;;
+
+  irix5* | irix6*)
+    if test "$with_gcc" = yes; then
+      archive_cmds='$CC -shared $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      archive_cmds='$LD -shared $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'  # a.out
+    else
+      archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linkopts'      # ELF
+    fi
+    hardcode_libdir_flag_spec='${wl}-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  openbsd*)
+    archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  os2*)
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_minus_L=yes
+    allow_undefined_flag=unsupported
+    archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $objdir/$libname.def~$echo DATA >> $objdir/$libname.def~$echo " SINGLE NONSHARED" >> $objdir/$libname.def~$echo EXPORTS >> $objdir/$libname.def~emxexp $libobjs >> $objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $linkopts $objdir/$libname.def'
+    old_archive_from_new_cmds='emximp -o $objdir/$libname.a $objdir/$libname.def'
+    ;;
+
+  osf3*)
+    if test "$with_gcc" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+
+  osf4* | osf5*)  # As osf3* with the addition of the -msym flag
+    if test "$with_gcc" = yes; then
+      allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+      archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $linkopts ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${objdir}/so_locations -o $lib'
+    else
+      allow_undefined_flag=' -expect_unresolved \*'
+      archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linkopts -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${objdir}/so_locations -o $lib'
+    fi
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    hardcode_libdir_separator=:
+    ;;
+  rhapsody*)
+    archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flags_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_shlibpath_var=no
+    ;;
+                                       
+  sco3.2v5*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_shlibpath_var=no
+    runpath_var=LD_RUN_PATH
+    hardcode_runpath_var=yes
+    ;;
+
+  solaris*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec='-R$libdir'
+    hardcode_shlibpath_var=no
+    case "$host_os" in
+    solaris2.[0-5] | solaris2.[0-5].*) ;;
+    *) # Supported since Solaris 2.6 (maybe 2.5.1?)
+      whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+    esac
+    ;;
+
+  sunos4*)
+    archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_direct=yes
+    hardcode_minus_L=yes
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4)
+    if test "x$host_vendor" = xsequent; then
+      # Use $CC to link under sequent, because it throws in some extra .o 
+      # files that make .init and .fini sections work.
+      archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $linkopts'
+    else
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    fi
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    hardcode_direct=no #Motorola manual says yes, but my tests say they lie 
+    ;;  
+
+  sysv4.3*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_shlibpath_var=no
+    export_dynamic_flag_spec='-Bexport'
+    ;;
+
+  sysv5*)
+    no_undefined_flag=' -z text'
+    # $CC -shared without GNU ld will not create a library from C++
+    # object files and a static libstdc++, better avoid it by now
+    archive_cmds='$LD -G${allow_undefined_flag} -h $rpath/$soname -o $lib $libobjs $deplibs $linkopts'
+    archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+		$LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linkopts~$rm $lib.exp'
+    hardcode_libdir_flag_spec=
+    hardcode_shlibpath_var=no
+    runpath_var='LD_RUN_PATH'
+    ;;
+
+  uts4*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  dgux*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    hardcode_libdir_flag_spec='-L$libdir'
+    hardcode_shlibpath_var=no
+    ;;
+
+  sysv4*MP*)
+    if test -d /usr/nec; then
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+      hardcode_shlibpath_var=no
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ld_shlibs=yes
+    fi
+    ;;
+
+  sysv4.2uw2*)
+    archive_cmds='$LD -G -o $lib $libobjs $deplibs $linkopts'
+    hardcode_direct=yes
+    hardcode_minus_L=no
+    hardcode_shlibpath_var=no
+    hardcode_runpath_var=yes
+    runpath_var=LD_RUN_PATH
+    ;;
+
+  unixware7*)
+    archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linkopts'
+    runpath_var='LD_RUN_PATH'
+    hardcode_shlibpath_var=no
+    ;;
+
+  *)
+    ld_shlibs=no
+    ;;
+  esac
+fi
+echo "$ac_t$ld_shlibs" 1>&6
+test "$ld_shlibs" = no && can_build_shared=no
+
+if test -z "$NM"; then
+  echo $ac_n "checking for BSD-compatible nm... $ac_c" 1>&6
+  case "$NM" in
+  [\\/]* | [A-Za-z]:[\\/]*) ;; # Let the user override the test with a path.
+  *)
+    IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR}"
+    for ac_dir in $PATH /usr/ucb /usr/ccs/bin /bin; do
+      test -z "$ac_dir" && ac_dir=.
+      if test -f $ac_dir/nm || test -f $ac_dir/nm$ac_exeext; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	if ($ac_dir/nm -B /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	  NM="$ac_dir/nm -B"
+	  break
+	elif ($ac_dir/nm -p /dev/null 2>&1 | sed '1q'; exit 0) | egrep /dev/null >/dev/null; then
+	  NM="$ac_dir/nm -p"
+	  break
+	else
+	  NM=${NM="$ac_dir/nm"} # keep the first match, but
+	  continue # so that we can try to find one that supports BSD flags
+	fi
+      fi
+    done
+    IFS="$ac_save_ifs"
+    test -z "$NM" && NM=nm
+    ;;
+  esac
+  echo "$ac_t$NM" 1>&6
+fi
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+echo $ac_n "checking command to parse $NM output... $ac_c" 1>&6
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform the above into a raw symbol and a C symbol.
+symxfrm='\1 \2\3 \3'
+
+# Transform an extracted symbol line into a proper C declaration
+global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern char \1;/p'"
+
+# Define system-specific variables.
+case "$host_os" in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern char \1();/p' -e 's/^. .* \(.*\)$/extern char \1;/p'"
+  ;;
+irix*)
+  symcode='[BCDEGRST]'
+  ;;
+solaris*)
+  symcode='[BDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+if $NM -V 2>&1 | egrep '(GNU|with BFD)' > /dev/null; then
+  symcode='[ABCDGISTW]'
+fi
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Write the raw and C identifiers.
+  global_symbol_pipe="sed -n -e 's/^.*[ 	]\($symcode\)[ 	][ 	]*\($ac_symprfx\)$sympat$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+  $rm conftest*
+  cat > conftest.c <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  echo "$progname:1653: checking if global_symbol_pipe works" >&5
+  if { (eval echo $progname:1654: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; } && test -s conftest.$objext; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { echo "$progname:1657: eval \"$NM conftest.$objext | $global_symbol_pipe > $nlist\"" >&5; eval "$NM conftest.$objext | $global_symbol_pipe > $nlist 2>&5"; } && test -s "$nlist"; then
+
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if egrep ' nm_test_var$' "$nlist" >/dev/null; then
+	if egrep ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<EOF > conftest.c
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+	  # Now generate the symbol file.
+	  eval "$global_symbol_to_cdecl"' < "$nlist" >> conftest.c'
+
+	  cat <<EOF >> conftest.c
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+	  sed 's/^. \(.*\) \(.*\)$/  {"\2", (lt_ptr_t) \&\2},/' < "$nlist" >> conftest.c
+	  cat <<\EOF >> conftest.c
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+	  # Now try linking the two files.
+	  mv conftest.$objext conftstm.$objext
+	  save_LIBS="$LIBS"
+	  save_CFLAGS="$CFLAGS"
+	  LIBS="conftstm.$objext"
+	  CFLAGS="$CFLAGS$no_builtin_flag"
+	  if { (eval echo $progname:1709: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+	    pipe_works=yes
+	  else
+	    echo "$progname: failed program was:" >&5
+	    cat conftest.c >&5
+	  fi
+	  LIBS="$save_LIBS"
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.c >&5
+  fi
+  $rm conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    global_symbol_pipe=
+  fi
+done
+if test "$pipe_works" = yes; then
+  echo "${ac_t}ok" 1>&6
+else
+  echo "${ac_t}failed" 1>&6
+fi
+
+if test -z "$global_symbol_pipe"; then
+  global_symbol_to_cdecl=
+fi
+
+# Check hardcoding attributes.
+echo $ac_n "checking how to hardcode library paths into programs... $ac_c" 1>&6
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var"; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$hardcode_shlibpath_var" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+echo "$ac_t$hardcode_action" 1>&6
+
+
+reload_flag=
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+echo $ac_n "checking for $LD option to reload object files... $ac_c" 1>&6
+# PORTME Some linkers may need a different reload flag.
+reload_flag='-r'
+echo "$ac_t$reload_flag" 1>&6
+test -n "$reload_flag" && reload_flag=" $reload_flag"
+
+# PORTME Fill in your ld.so characteristics
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+file_magic_cmd=
+file_magic_test_file=
+deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [regex]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given egrep regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+echo $ac_n "checking dynamic linker characteristics... $ac_c" 1>&6
+case "$host_os" in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}.so$major'
+  ;;
+
+aix4*)
+  version_type=linux
+  # AIX has no versioning support, so currently we can not hardcode correct
+  # soname into executable. Probably we can add versioning support to
+  # collect2, so additional links can be useful in future.
+  # We preserve .a as extension for shared libraries though AIX4.2
+  # and later linker supports .so
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.a'
+  shlibpath_var=LIBPATH
+  deplibs_check_method=pass_all
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "(cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a)"; (cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a) || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}.so'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  deplibs_check_method=pass_all
+  lt_cv_dlopen="load_add_on"
+  lt_cv_dlopen_libs=
+  lt_cv_dlopen_self=yes
+  ;;
+
+bsdi4*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/shlib/libc.so
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  export_dynamic_flag_spec=-rdynamic
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw*)
+  version_type=windows
+  need_version=no
+  need_lib_prefix=no
+  if test "$with_gcc" = yes; then
+    library_names_spec='`echo ${libname} | sed -e 's/^lib//g'`.dll $libname.a'
+  else
+    library_names_spec='${libname}`echo ${release} | sed -e 's/[.]/-/g'`${versuffix}.dll $libname.lib'
+  fi
+  dynamic_linker='Win32 ld.exe'
+  deplibs_check_method='file_magic file format pe-i386(.*architecture: i386)?'
+  file_magic_cmd='${OBJDUMP} -f'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  if test "$with_gcc" = yes; then
+    # See where the system libraries really are - /usr/lib won't cut it
+    libuser32=`$CC --print-file-name=libuser32.a`
+    win32libs=`expr $libuser32 : '\(.*\)/.*'`
+    sys_lib_search_path_spec="$sys_lib_search_path $win32libs"
+  fi
+  lt_cv_dlopen="LoadLibrary"
+  lt_cv_dlopen_libs=
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+  
+freebsd*)
+  objformat=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout`
+  version_type=freebsd-$objformat
+  case "$version_type" in
+    freebsd-elf*)
+      deplibs_check_method='pass_all'
+    
+      file_magic_cmd=/usr/bin/file
+      file_magic_test_file=`echo /usr/lib/libc.so*`
+      library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      deplibs_check_method=unknown
+      library_names_spec='${libname}${release}.so$versuffix $libname.so$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case "$host_os" in
+  freebsd2* | freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so${major} ${libname}.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  dynamic_linker="$host_os dld.sl"
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  shlibpath_var=SHLIB_PATH
+  shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+  library_names_spec='${libname}${release}.sl$versuffix ${libname}${release}.sl$major $libname.sl'
+  soname_spec='${libname}${release}.sl$major'
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  case "$host_os" in
+  hpux10.20*)
+    # TODO:  Does this work for hpux-11 too?
+  #  deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    deplibs_check_method="unknown"
+    file_magic_cmd=/usr/bin/file
+    file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6*)
+  version_type=irix
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}.so.$major'
+  library_names_spec='${libname}${release}.so.$versuffix ${libname}${release}.so.$major ${libname}${release}.so $libname.so'
+  case "$host_os" in
+  irix5*)
+    libsuff= shlibsuff=
+    # this will be overridden with pass_all, but let us keep it just in case
+    deplibs_check_method="file_magic ELF 32-bit MSB dynamic lib MIPS - version 1"
+    ;;
+  *)
+    case "$LD" in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 ") libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 ") libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 ") libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=`echo /lib${libsuff}/libc.so*`
+  deplibs_check_method='pass_all'
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux-gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  deplibs_check_method=pass_all
+
+  if test -f /lib/ld.so.1; then
+    dynamic_linker='GNU ld.so'
+  else
+    # Only the GNU ld.so supports shared libraries on MkLinux.
+    case "$host_cpu" in
+    powerpc*) dynamic_linker=no ;;
+    *) dynamic_linker='Linux ld.so' ;;
+    esac
+  fi
+  ;;
+
+netbsd*)
+  version_type=sunos
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major ${libname}${release}.so ${libname}.so'
+    soname_spec='${libname}${release}.so$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+openbsd*)
+  version_type=sunos
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+    need_version=no
+  fi
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+os2*)
+  libname_spec='$name'
+  need_lib_prefix=no
+  library_names_spec='$libname.dll $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_version=no
+  soname_spec='${libname}${release}.so'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  # this will be overridden with pass_all, but let us keep it just in case
+  deplibs_check_method='file_magic COFF format alpha shared library'
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/shlib/libc.so
+  deplibs_check_method='pass_all'
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rhapsody*)
+  version_type=sunos
+  library_names_spec='${libname}.so'
+  soname_spec='${libname}.so'
+  shlibpath_var=DYLD_LIBRARY_PATH
+  deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}.so$major'
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  deplibs_check_method="file_magic ELF [0-9][0-9]-bit [LM]SB dynamic lib"
+  file_magic_cmd=/usr/bin/file
+  file_magic_test_file=/lib/libc.so
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}.so$versuffix ${libname}.so$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case "$host_vendor" in
+    sequent)
+      file_magic_cmd='/bin/file'
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+      ;;
+    ncr)
+      deplibs_check_method='pass_all'
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+      file_magic_cmd=/usr/bin/file
+      file_magic_test_file=`echo /usr/lib/libc.so*`
+      ;;
+  esac
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
+  soname_spec='${libname}${release}.so$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname.so.$versuffix $libname.so.$major $libname.so'
+    soname_spec='$libname.so.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+echo "$ac_t$dynamic_linker" 1>&6
+test "$dynamic_linker" = no && can_build_shared=no
+
+# Report the final consequences.
+echo "checking if libtool supports shared libraries... $can_build_shared" 1>&6
+
+# Only try to build win32 dlls if AC_LIBTOOL_WIN32_DLL was used in
+# configure.in, otherwise build static only libraries.
+case "$host_os" in
+cygwin* | mingw* | os2*)
+  if test x$can_build_shared = xyes; then
+    test x$enable_win32_dll = xno && can_build_shared=no
+    echo "checking if package supports dlls... $can_build_shared" 1>&6
+  fi
+;;
+esac
+
+if test -n "$file_magic_test_file" && test -n "$file_magic_cmd"; then
+  case "$deplibs_check_method" in
+  "file_magic "*)
+    file_magic_regex="`expr \"$deplibs_check_method\" : \"file_magic \(.*\)\"`"
+    if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+       egrep "$file_magic_regex" > /dev/null; then
+      :
+    else
+      cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+    fi ;;
+  esac
+fi
+
+echo $ac_n "checking whether to build shared libraries... $ac_c" 1>&6
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case "$host_os" in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4*)
+  test "$enable_shared" = yes && enable_static=no
+  ;;
+esac
+
+echo "$ac_t$enable_shared" 1>&6
+
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+
+echo "checking whether to build static libraries... $enable_static" 1>&6
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+echo $ac_n "checking for objdir... $ac_c" 1>&6
+rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+echo "$ac_t$objdir" 1>&6
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+if eval "test \"`echo '$''{'lt_cv_dlopen'+set}'`\" != set"; then
+  lt_cv_dlopen=no lt_cv_dlopen_libs=
+echo $ac_n "checking for dlopen in -ldl""... $ac_c" 1>&6
+echo "$progname:2248: checking for dlopen in -ldl" >&5
+ac_lib_var=`echo dl'_'dlopen | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldl  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2256 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen();
+
+int main() {
+dlopen()
+; return 0; }
+EOF
+if { (eval echo $progname:2269: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dlopen""... $ac_c" 1>&6
+echo "$progname:2288: checking for dlopen" >&5
+if eval "test \"`echo '$''{'ac_cv_func_dlopen'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2293 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char dlopen(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_dlopen) || defined (__stub___dlopen)
+choke me
+#else
+dlopen();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2318: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_dlopen=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_func_'dlopen`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dlopen"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for dld_link in -ldld""... $ac_c" 1>&6
+echo "$progname:2335: checking for dld_link in -ldld" >&5
+ac_lib_var=`echo dld'_'dld_link | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldld  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2343 "ltconfig"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link();
+
+int main() {
+dld_link()
+; return 0; }
+EOF
+if { (eval echo $progname:2356: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for shl_load""... $ac_c" 1>&6
+echo "$progname:2375: checking for shl_load" >&5
+if eval "test \"`echo '$''{'ac_cv_func_shl_load'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2380 "ltconfig"
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char shl_load(); below.  */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined (__stub_shl_load) || defined (__stub___shl_load)
+choke me
+#else
+shl_load();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo $progname:2405: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_func_shl_load=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_func_shl_load=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'shl_load`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="shl_load"
+else
+  echo "$ac_t""no" 1>&6
+echo $ac_n "checking for shl_load in -ldld""... $ac_c" 1>&6
+echo "$progname:2423: checking for shl_load in -ldld" >&5
+ac_lib_var=`echo dld'_'shl_load | sed 'y%./+-%__p_%'`
+if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  ac_save_LIBS="$LIBS"
+LIBS="-ldld  $LIBS"
+cat > conftest.$ac_ext <<EOF
+#line 2431 "ltconfig"
+#include "confdefs.h"
+/* Override any gcc2 internal prototype to avoid an error.  */
+/* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load();
+
+int main() {
+shl_load()
+; return 0; }
+EOF
+if { (eval echo $progname:2445: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=yes"
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_lib_$ac_lib_var=no"
+fi
+rm -f conftest*
+LIBS="$ac_save_LIBS"
+
+fi
+if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  echo "$ac_t""no" 1>&6
+fi
+
+
+fi
+
+    
+fi
+
+  
+fi
+
+
+fi
+
+fi
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  fi
+
+  case "$lt_cv_dlopen" in
+  dlopen)
+for ac_hdr in dlfcn.h; do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "$progname:2488: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  cat > conftest.$ac_ext <<EOF
+#line 2493 "ltconfig"
+#include <$ac_hdr>
+int fnord = 0;
+EOF
+ac_try="$ac_compile >/dev/null 2>conftest.out"
+{ (eval echo $progname:2498: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=yes"
+else
+  echo "$ac_err" >&5
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -rf conftest*
+  eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+  echo "$ac_t""yes" 1>&6
+else
+  echo "$ac_t""no" 1>&6
+fi
+done
+
+    if test "x$ac_cv_header_dlfcn_h" = xyes; then
+      CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+    fi
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+  echo $ac_n "checking whether a program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2526: checking whether a program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self+set}" = set; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+    lt_cv_dlopen_self=cross
+  else
+    cat > conftest.c <<EOF
+#line 2534 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL	RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+#  define LTDL_GLOBAL	DL_GLOBAL
+# else
+#  define LTDL_GLOBAL	0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+#  define LTDL_LAZY_OR_NOW	RTLD_LAZY
+# else
+#  ifdef DL_LAZY
+#   define LTDL_LAZY_OR_NOW	DL_LAZY
+#  else
+#   ifdef RTLD_NOW
+#    define LTDL_LAZY_OR_NOW	RTLD_NOW
+#   else
+#    ifdef DL_NOW
+#     define LTDL_LAZY_OR_NOW	DL_NOW
+#    else
+#     define LTDL_LAZY_OR_NOW	0
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+	       if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
+
+EOF
+if { (eval echo $progname:2580: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  lt_cv_dlopen_self=yes
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  lt_cv_dlopen_self=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self" 1>&6
+
+  if test "$lt_cv_dlopen_self" = yes; then
+    LDFLAGS="$LDFLAGS $link_static_flag"
+  echo $ac_n "checking whether a statically linked program can dlopen itself""... $ac_c" 1>&6
+echo "$progname:2599: checking whether a statically linked program can dlopen itself" >&5
+if test "${lt_cv_dlopen_self_static+set}" = set; then
+  echo $ac_n "(cached) $ac_c" 1>&6
+else
+  if test "$cross_compiling" = yes; then
+    lt_cv_dlopen_self_static=cross
+  else
+    cat > conftest.c <<EOF
+#line 2607 "ltconfig"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LTDL_GLOBAL	RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+#  define LTDL_GLOBAL	DL_GLOBAL
+# else
+#  define LTDL_GLOBAL	0
+# endif
+#endif
+
+/* We may have to define LTDL_LAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LTDL_LAZY_OR_NOW
+# ifdef RTLD_LAZY
+#  define LTDL_LAZY_OR_NOW	RTLD_LAZY
+# else
+#  ifdef DL_LAZY
+#   define LTDL_LAZY_OR_NOW	DL_LAZY
+#  else
+#   ifdef RTLD_NOW
+#    define LTDL_LAZY_OR_NOW	RTLD_NOW
+#   else
+#    ifdef DL_NOW
+#     define LTDL_LAZY_OR_NOW	DL_NOW
+#    else
+#     define LTDL_LAZY_OR_NOW	0
+#    endif
+#   endif
+#  endif
+# endif
+#endif
+
+fnord() { int i=42;}
+main() { void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
+    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
+    if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); } 
+
+EOF
+if { (eval echo $progname:2653: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+then
+  lt_cv_dlopen_self_static=yes
+else
+  echo "$progname: failed program was:" >&5
+  cat conftest.$ac_ext >&5
+  rm -fr conftest*
+  lt_cv_dlopen_self_static=no
+fi
+rm -fr conftest*
+fi
+
+fi
+
+echo "$ac_t""$lt_cv_dlopen_self_static" 1>&6
+fi
+    ;;
+  esac
+
+  case "$lt_cv_dlopen_self" in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case "$lt_cv_dlopen_self_static" in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+# Copy echo and quote the copy, instead of the original, because it is
+# used later.
+ltecho="$echo"
+if test "X$ltecho" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   ltecho="$CONFIG_SHELL \$0 --fallback-echo"
+fi
+LTSHELL="$SHELL"
+
+LTCONFIG_VERSION="$VERSION"
+
+# Only quote variables if we're using ltmain.sh.
+case "$ltmain" in
+*.sh)
+  # Now quote all the things that may contain metacharacters.
+  for var in ltecho old_CC old_CFLAGS old_CPPFLAGS \
+    old_LD old_LDFLAGS old_LIBS \
+    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS \
+    AR CC LD LN_S NM LTSHELL LTCONFIG_VERSION \
+    reload_flag reload_cmds wl \
+    pic_flag link_static_flag no_builtin_flag export_dynamic_flag_spec \
+    thread_safe_flag_spec whole_archive_flag_spec libname_spec \
+    library_names_spec soname_spec \
+    RANLIB old_archive_cmds old_archive_from_new_cmds old_postinstall_cmds \
+    old_postuninstall_cmds archive_cmds archive_expsym_cmds postinstall_cmds postuninstall_cmds \
+    file_magic_cmd export_symbols_cmds deplibs_check_method allow_undefined_flag no_undefined_flag \
+    finish_cmds finish_eval global_symbol_pipe global_symbol_to_cdecl \
+    hardcode_libdir_flag_spec hardcode_libdir_separator  \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    compiler_c_o compiler_o_lo need_locks exclude_expsyms include_expsyms; do
+
+    case "$var" in
+    reload_cmds | old_archive_cmds | old_archive_from_new_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    export_symbols_cmds | archive_cmds | archive_expsym_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    finish_cmds | sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case "$ltecho" in
+  *'\$0 --fallback-echo"')
+    ltecho=`$echo "X$ltecho" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+  trap "$rm \"$ofile\"; exit 1" 1 2 15
+  echo "creating $ofile"
+  $rm "$ofile"
+  cat <<EOF > "$ofile"
+#! $SHELL
+
+# `$echo "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltconfig or ltmain.sh.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="sed -e s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test "X\${CDPATH+set}" = Xset; then CDPATH=:; export CDPATH; fi
+
+### BEGIN LIBTOOL CONFIG
+EOF
+  cfgfile="$ofile"
+  ;;
+
+*)
+  # Double-quote the variables that need it (for aesthetics).
+  for var in old_CC old_CFLAGS old_CPPFLAGS \
+    old_LD old_LDFLAGS old_LIBS \
+    old_NM old_RANLIB old_LN_S old_DLLTOOL old_OBJDUMP old_AS; do
+    eval "$var=\\\"\$var\\\""
+  done
+
+  # Just create a config file.
+  cfgfile="$ofile.cfg"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  echo "creating $cfgfile"
+  $rm "$cfgfile"
+  cat <<EOF > "$cfgfile"
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Libtool configuration file.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+EOF
+  ;;
+esac
+
+cat <<EOF >> "$cfgfile"
+# Libtool was configured as follows, on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+#
+# CC=$old_CC CFLAGS=$old_CFLAGS CPPFLAGS=$old_CPPFLAGS \\
+# LD=$old_LD LDFLAGS=$old_LDFLAGS LIBS=$old_LIBS \\
+# NM=$old_NM RANLIB=$old_RANLIB LN_S=$old_LN_S \\
+# DLLTOOL=$old_DLLTOOL OBJDUMP=$old_OBJDUMP AS=$old_AS \\
+#   $0$ltconfig_args
+#
+# Compiler and other test output produced by $progname, useful for
+# debugging $progname, is in ./config.log if it exists.
+
+# The version of $progname that generated this script.
+LTCONFIG_VERSION=$LTCONFIG_VERSION
+
+# Shell to use when invoking shell scripts.
+SHELL=$LTSHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+
+# An echo program that does not interpret backslashes.
+echo=$ltecho
+
+# The archiver.
+AR=$AR
+
+# The default C compiler.
+CC=$CC
+
+# The linker used to build libraries.
+LD=$LD
+
+# Whether we need hard or soft links.
+LN_S=$LN_S
+
+# A BSD-compatible nm program.
+NM=$NM
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$reload_flag
+reload_cmds=$reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$wl
+
+# Object file suffix (normally "o").
+objext="$objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$pic_flag
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$compiler_c_o
+
+# Can we write directly to a .lo ?
+compiler_o_lo=$compiler_o_lo
+
+# Must we lock files when doing compilation ?
+need_locks=$need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$link_static_flag
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$RANLIB
+old_archive_cmds=$old_archive_cmds
+old_postinstall_cmds=$old_postinstall_cmds
+old_postuninstall_cmds=$old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$old_archive_from_new_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$archive_cmds
+archive_expsym_cmds=$archive_expsym_cmds
+postinstall_cmds=$postinstall_cmds
+postuninstall_cmds=$postuninstall_cmds
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$global_symbol_to_cdecl
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$hardcode_libdir_flag_spec
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$include_expsyms
+
+EOF
+
+case "$ltmain" in
+*.sh)
+  echo '### END LIBTOOL CONFIG' >> "$ofile"
+  echo >> "$ofile"
+  case "$host_os" in
+  aix3*)
+    cat <<\EOF >> "$ofile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # Append the ltmain.sh script.
+  sed '$q' "$ltmain" >> "$ofile" || (rm -f "$ofile"; exit 1)
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+
+  chmod +x "$ofile"
+  ;;
+
+*)
+  # Compile the libtool program.
+  echo "FIXME: would compile $ltmain"
+  ;;
+esac
+
+test -n "$cache_file" || exit 0
+
+# AC_CACHE_SAVE
+trap '' 1 2 15
+cat > confcache <<\EOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs.  It is not useful on other systems.
+# If it contains results you don't want to keep, you may remove or edit it.
+#
+# By default, configure uses ./config.cache as the cache file,
+# creating it if it does not exist already.  You can give configure
+# the --cache-file=FILE option to use a different cache file; that is
+# what configure does when it calls configure scripts in
+# subdirectories, so they share the cache.
+# Giving --cache-file=/dev/null disables caching, for debugging configure.
+# config.status only pays attention to the cache file if you give it the
+# --recheck option to rerun configure.
+#
+EOF
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, don't put newlines in cache variables' values.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(set) 2>&1 |
+  case `(ac_space=' '; set | grep ac_space) 2>&1` in
+  *ac_space=\ *)
+    # `set' does not quote correctly, so add quotes (double-quote substitution
+    # turns \\\\ into \\, and sed turns \\ into \).
+    sed -n \
+      -e "s/'/'\\\\''/g" \
+      -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
+    ;;
+  *)
+    # `set' quotes correctly as required by POSIX, so do not add quotes.
+    sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
+    ;;
+  esac >> confcache
+if cmp -s $cache_file confcache; then
+  :
+else
+  if test -w $cache_file; then
+    echo "updating cache $cache_file"
+    cat confcache > $cache_file
+  else
+    echo "not updating unwritable cache $cache_file"
+  fi
+fi
+rm -f confcache
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ltmain.sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,4024 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun ltconfig.
+#
+# Copyright (C) 1996-1999 Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell, and then maybe $echo will work.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The name of this program.
+progname=`$echo "$0" | sed 's%^.*/%%'`
+modename="$progname"
+
+# Constants.
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.3.5
+TIMESTAMP=" (1.385.2.206 2000/05/27 11:12:27)"
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+SP2NL='tr \040 \012'
+NL2SP='tr \015\012 \040\040'
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+  save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+if test "$LTCONFIG_VERSION" != "$VERSION"; then
+  echo "$modename: ltconfig version \`$LTCONFIG_VERSION' does not match $PROGRAM version \`$VERSION'" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  echo "$modename: not configured to build any kind of library" 1>&2
+  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit 1
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+# Parse our command line options once, thoroughly.
+while test $# -gt 0
+do
+  arg="$1"
+  shift
+
+  case "$arg" in
+  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    case "$prev" in
+    execute_dlfiles)
+      eval "$prev=\"\$$prev \$arg\""
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
+    prev=
+    prevopt=
+    continue
+  fi
+
+  # Have we seen a non-optional argument yet?
+  case "$arg" in
+  --help)
+    show_help=yes
+    ;;
+
+  --version)
+    echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+    exit 0
+    ;;
+
+  --config)
+    sed -e '1,/^### BEGIN LIBTOOL CONFIG/d' -e '/^### END LIBTOOL CONFIG/,$d' $0
+    exit 0
+    ;;
+
+  --debug)
+    echo "$progname: enabling shell trace mode"
+    set -x
+    ;;
+
+  --dry-run | -n)
+    run=:
+    ;;
+
+  --features)
+    echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      echo "enable shared libraries"
+    else
+      echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      echo "enable static libraries"
+    else
+      echo "disable static libraries"
+    fi
+    exit 0
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --quiet | --silent)
+    show=:
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+fi
+
+if test -z "$show_help"; then
+
+  # Infer the operation mode.
+  if test -z "$mode"; then
+    case "$nonopt" in
+    *cc | *++ | gcc* | *-gcc*)
+      mode=link
+      for arg
+      do
+	case "$arg" in
+	-c)
+	   mode=compile
+	   break
+	   ;;
+	esac
+      done
+      ;;
+    *db | *dbx | *strace | *truss)
+      mode=execute
+      ;;
+    *install*|cp|mv)
+      mode=install
+      ;;
+    *rm)
+      mode=uninstall
+      ;;
+    *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
+      # Just use the default operation mode.
+      if test -z "$mode"; then
+	if test -n "$nonopt"; then
+	  $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+	else
+	  $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+	fi
+      fi
+      ;;
+    esac
+  fi
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+    $echo "$help" 1>&2
+    exit 1
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$modename --help --mode=$mode' for more information."
+
+  # These modes are in order of execution frequency so that they run quickly.
+  case "$mode" in
+  # libtool compile mode
+  compile)
+    modename="$modename: compile"
+    # Get the compilation command and the source file.
+    base_compile=
+    lastarg=
+    srcfile="$nonopt"
+    suppress_output=
+
+    user_target=no
+    for arg
+    do
+      # Accept any command-line options.
+      case "$arg" in
+      -o)
+	if test "$user_target" != "no"; then
+	  $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+	  exit 1
+	fi
+	user_target=next
+	;;
+
+      -static)
+	build_old_libs=yes
+	continue
+	;;
+      esac
+
+      case "$user_target" in
+      next)
+	# The next one is the -o target name
+	user_target=yes
+	continue
+	;;
+      yes)
+	# We got the output file
+	user_target=set
+	libobj="$arg"
+	continue
+	;;
+      esac
+
+      # Accept the current argument as the source file.
+      lastarg="$srcfile"
+      srcfile="$arg"
+
+      # Aesthetically quote the previous argument.
+
+      # Backslashify any backslashes, double quotes, and dollar signs.
+      # These are the only characters that are still specially
+      # interpreted inside of double-quoted scrings.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly in scan
+      # sets, so we specify it separately.
+      case "$lastarg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	lastarg="\"$lastarg\""
+	;;
+      esac
+
+      # Add the previous argument to base_compile.
+      if test -z "$base_compile"; then
+	base_compile="$lastarg"
+      else
+	base_compile="$base_compile $lastarg"
+      fi
+    done
+
+    case "$user_target" in
+    set)
+      ;;
+    no)
+      # Get the name of the library object.
+      libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    *)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSfmso]'
+    case "$libobj" in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.f90) xform=f90 ;;
+    *.for) xform=for ;;
+    esac
+
+    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+    case "$libobj" in
+    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+    *)
+      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+      exit 1
+      ;;
+    esac
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $libobj"
+    else
+      removelist="$libobj"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit 1" 1 2 15
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\..*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit 1" 1 2 15
+    else
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until ln "$0" "$lockfile" 2>/dev/null; do
+	$show "Waiting for $lockfile to be removed"
+	sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+	echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+      echo $srcfile > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      # All platforms use -DPIC, to notify preprocessed assembler code.
+      command="$base_compile $srcfile $pic_flag -DPIC"
+      if test "$build_old_libs" = yes; then
+	lo_libobj="$libobj"
+	dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$dir" = "X$libobj"; then
+	  dir="$objdir"
+	else
+	  dir="$dir/$objdir"
+	fi
+	libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+
+	if test -d "$dir"; then
+	  $show "$rm $libobj"
+	  $run $rm $libobj
+	else
+	  $show "$mkdir $dir"
+	  $run $mkdir $dir
+	  status=$?
+	  if test $status -ne 0 && test ! -d $dir; then
+	    exit $status
+	  fi
+	fi
+      fi
+      if test "$compiler_o_lo" = yes; then
+	output_obj="$libobj"
+	command="$command -o $output_obj"
+      elif test "$compiler_c_o" = yes; then
+	output_obj="$obj"
+	command="$command -o $output_obj"
+      fi
+
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+	test -n "$output_obj" && $run $rm $removelist
+	exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+	echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test x"$output_obj" != x"$libobj"; then
+	$show "$mv $output_obj $libobj"
+	if $run $mv $output_obj $libobj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # If we have no pic_flag, then copy the object into place and finish.
+      if test -z "$pic_flag" && test "$build_old_libs" = yes; then
+	# Rename the .lo from within objdir to obj
+	if test -f $obj; then
+	  $show $rm $obj
+	  $run $rm $obj
+	fi
+
+	$show "$mv $libobj $obj"
+	if $run $mv $libobj $obj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+
+	xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$obj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$obj" | $Xsed -e "s%.*/%%"`
+	libobj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+	# Now arrange that obj and lo_libobj become the same file
+	$show "(cd $xdir && $LN_S $baseobj $libobj)"
+	if $run eval '(cd $xdir && $LN_S $baseobj $libobj)'; then
+	  exit 0
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # Allow error messages only from the first compilation.
+      suppress_output=' >/dev/null 2>&1'
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      command="$base_compile $srcfile"
+      if test "$compiler_c_o" = yes; then
+	command="$command -o $obj"
+	output_obj="$obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+	$run $rm $removelist
+	exit 1
+      fi
+
+      if test "$need_locks" = warn &&
+	 test x"`cat $lockfile 2>/dev/null`" != x"$srcfile"; then
+	echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+	$run $rm $removelist
+	exit 1
+      fi
+
+      # Just move the object if needed
+      if test x"$output_obj" != x"$obj"; then
+	$show "$mv $output_obj $obj"
+	if $run $mv $output_obj $obj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+
+      # Create an invalid libtool object if no PIC, so that we do not
+      # accidentally link it into a program.
+      if test "$build_libtool_libs" != yes; then
+	$show "echo timestamp > $libobj"
+	$run eval "echo timestamp > \$libobj" || exit $?
+      else
+	# Move the .lo from within objdir
+	$show "$mv $libobj $lo_libobj"
+	if $run $mv $libobj $lo_libobj; then :
+	else
+	  error=$?
+	  $run $rm $removelist
+	  exit $error
+	fi
+      fi
+    fi
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $rm "$lockfile"
+    fi
+
+    exit 0
+    ;;
+
+  # libtool link mode
+  link)
+    modename="$modename: link"
+    case "$host" in
+    *-*-cygwin* | *-*-mingw* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invokation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+
+      # This is a source program that is used to create dlls on Windows
+      # Don't remove nor modify the starting and closing comments
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+      # This is a source program that is used to create import libraries
+      # on Windows for dlls which lack them. Don't remove nor modify the
+      # starting and closing comments
+# /* impgen.c starts here */
+# /*   Copyright (C) 1999 Free Software Foundation, Inc.
+# 
+#  This file is part of GNU libtool.
+# 
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU General Public License as published by
+#  the Free Software Foundation; either version 2 of the License, or
+#  (at your option) any later version.
+# 
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+# 
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#  */
+# 
+#  #include <stdio.h>		/* for printf() */
+#  #include <unistd.h>		/* for open(), lseek(), read() */
+#  #include <fcntl.h>		/* for O_RDONLY, O_BINARY */
+#  #include <string.h>		/* for strdup() */
+# 
+#  static unsigned int
+#  pe_get16 (fd, offset)
+#       int fd;
+#       int offset;
+#  {
+#    unsigned char b[2];
+#    lseek (fd, offset, SEEK_SET);
+#    read (fd, b, 2);
+#    return b[0] + (b[1]<<8);
+#  }
+# 
+#  static unsigned int
+#  pe_get32 (fd, offset)
+#      int fd;
+#      int offset;
+#  {
+#    unsigned char b[4];
+#    lseek (fd, offset, SEEK_SET);
+#    read (fd, b, 4);
+#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+#  }
+# 
+#  static unsigned int
+#  pe_as32 (ptr)
+#       void *ptr;
+#  {
+#    unsigned char *b = ptr;
+#    return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24);
+#  }
+# 
+#  int
+#  main (argc, argv)
+#      int argc;
+#      char *argv[];
+#  {
+#      int dll;
+#      unsigned long pe_header_offset, opthdr_ofs, num_entries, i;
+#      unsigned long export_rva, export_size, nsections, secptr, expptr;
+#      unsigned long name_rvas, nexp;
+#      unsigned char *expdata, *erva;
+#      char *filename, *dll_name;
+# 
+#      filename = argv[1];
+# 
+#      dll = open(filename, O_RDONLY|O_BINARY);
+#      if (!dll)
+#  	return 1;
+# 
+#      dll_name = filename;
+#    
+#      for (i=0; filename[i]; i++)
+#  	if (filename[i] == '/' || filename[i] == '\\'  || filename[i] == ':')
+#  	    dll_name = filename + i +1;
+# 
+#      pe_header_offset = pe_get32 (dll, 0x3c);
+#      opthdr_ofs = pe_header_offset + 4 + 20;
+#      num_entries = pe_get32 (dll, opthdr_ofs + 92);
+# 
+#      if (num_entries < 1) /* no exports */
+#  	return 1;
+# 
+#      export_rva = pe_get32 (dll, opthdr_ofs + 96);
+#      export_size = pe_get32 (dll, opthdr_ofs + 100);
+#      nsections = pe_get16 (dll, pe_header_offset + 4 +2);
+#      secptr = (pe_header_offset + 4 + 20 +
+#  	      pe_get16 (dll, pe_header_offset + 4 + 16));
+# 
+#      expptr = 0;
+#      for (i = 0; i < nsections; i++)
+#      {
+#  	char sname[8];
+#  	unsigned long secptr1 = secptr + 40 * i;
+#  	unsigned long vaddr = pe_get32 (dll, secptr1 + 12);
+#  	unsigned long vsize = pe_get32 (dll, secptr1 + 16);
+#  	unsigned long fptr = pe_get32 (dll, secptr1 + 20);
+#  	lseek(dll, secptr1, SEEK_SET);
+#  	read(dll, sname, 8);
+#  	if (vaddr <= export_rva && vaddr+vsize > export_rva)
+#  	{
+#  	    expptr = fptr + (export_rva - vaddr);
+#  	    if (export_rva + export_size > vaddr + vsize)
+#  		export_size = vsize - (export_rva - vaddr);
+#  	    break;
+#  	}
+#      }
+# 
+#      expdata = (unsigned char*)malloc(export_size);
+#      lseek (dll, expptr, SEEK_SET);
+#      read (dll, expdata, export_size);
+#      erva = expdata - export_rva;
+# 
+#      nexp = pe_as32 (expdata+24);
+#      name_rvas = pe_as32 (expdata+32);
+# 
+#      printf ("EXPORTS\n");
+#      for (i = 0; i<nexp; i++)
+#      {
+#  	unsigned long name_rva = pe_as32 (erva+name_rvas+i*4);
+#  	printf ("\t%s @ %ld ;\n", erva+name_rva, 1+ i);
+#      }
+# 
+#      return 0;
+#  }
+# /* impgen.c ends here */
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    linkopts=
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval lib_search_path=\`\$echo \"X \${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      lib_search_path=
+    fi
+    # now prepend the system-specific ones
+    eval lib_search_path=\"$sys_lib_search_path_spec\$lib_search_path\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+    
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    link_against_libtool_libs=
+    ltlibs=
+    module=no
+    objs=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case "$arg" in
+      -all-static | -static)
+	if test "X$arg" = "X-all-static"; then
+	  if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+	    $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+	  fi
+	  if test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	else
+	  if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	    dlopen_self=$dlopen_self_static
+	  fi
+	fi
+	build_libtool_libs=no
+	build_old_libs=yes
+	prefer_static_libs=yes
+	break
+	;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test $# -gt 0; do
+      arg="$1"
+      shift
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+	case "$prev" in
+	output)
+	  compile_command="$compile_command @OUTPUT@"
+	  finalize_command="$finalize_command @OUTPUT@"
+	  ;;
+	esac
+
+	case "$prev" in
+	dlfiles|dlprefiles)
+	  if test "$preload" = no; then
+	    # Add the symbol object into the linking commands.
+	    compile_command="$compile_command @SYMFILE@"
+	    finalize_command="$finalize_command @SYMFILE@"
+	    preload=yes
+	  fi
+	  case "$arg" in
+	  *.la | *.lo) ;;  # We handle these cases below.
+	  force)
+	    if test "$dlself" = no; then
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  self)
+	    if test "$prev" = dlprefiles; then
+	      dlself=yes
+	    elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+	      dlself=yes
+	    else
+	      dlself=needless
+	      export_dynamic=yes
+	    fi
+	    prev=
+	    continue
+	    ;;
+	  *)
+	    if test "$prev" = dlfiles; then
+	      dlfiles="$dlfiles $arg"
+	    else
+	      dlprefiles="$dlprefiles $arg"
+	    fi
+	    prev=
+	    ;;
+	  esac
+	  ;;
+	expsyms)
+	  export_symbols="$arg"
+	  if test ! -f "$arg"; then
+	    $echo "$modename: symbol file \`$arg' does not exist"
+	    exit 1
+	  fi
+	  prev=
+	  continue
+	  ;;
+	expsyms_regex)
+	  export_symbols_regex="$arg"
+	  prev=
+	  continue
+	  ;;
+	release)
+	  release="-$arg"
+	  prev=
+	  continue
+	  ;;
+	rpath | xrpath)
+	  # We need an absolute path.
+	  case "$arg" in
+	  [\\/]* | [A-Za-z]:[\\/]*) ;;
+	  *)
+	    $echo "$modename: only absolute run-paths are allowed" 1>&2
+	    exit 1
+	    ;;
+	  esac
+	  if test "$prev" = rpath; then
+	    case "$rpath " in
+	    *" $arg "*) ;;
+	    *) rpath="$rpath $arg" ;;
+	    esac
+	  else
+	    case "$xrpath " in
+	    *" $arg "*) ;;
+	    *) xrpath="$xrpath $arg" ;;
+	    esac
+	  fi
+	  prev=
+	  continue
+	  ;;
+	*)
+	  eval "$prev=\"\$arg\""
+	  prev=
+	  continue
+	  ;;
+	esac
+      fi
+
+      prevarg="$arg"
+
+      case "$arg" in
+      -all-static)
+	if test -n "$link_static_flag"; then
+	  compile_command="$compile_command $link_static_flag"
+	  finalize_command="$finalize_command $link_static_flag"
+	fi
+	continue
+	;;
+
+      -allow-undefined)
+	# FIXME: remove this flag sometime in the future.
+	$echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+	continue
+	;;
+
+      -avoid-version)
+	avoid_version=yes
+	continue
+	;;
+
+      -dlopen)
+	prev=dlfiles
+	continue
+	;;
+
+      -dlpreopen)
+	prev=dlprefiles
+	continue
+	;;
+
+      -export-dynamic)
+	export_dynamic=yes
+	continue
+	;;
+
+      -export-symbols | -export-symbols-regex)
+	if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	  $echo "$modename: not more than one -exported-symbols argument allowed"
+	  exit 1
+	fi
+	if test "X$arg" = "X-export-symbols"; then
+	  prev=expsyms
+	else
+	  prev=expsyms_regex
+	fi
+	continue
+	;;
+
+      -L*)
+	dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+	# We need an absolute path.
+	case "$dir" in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  absdir=`cd "$dir" && pwd`
+	  if test -z "$absdir"; then
+	    $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+	    $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+	    absdir="$dir"
+	  fi
+	  dir="$absdir"
+	  ;;
+	esac
+	case " $deplibs " in
+	*" $arg "*) ;;
+	*) deplibs="$deplibs $arg";;
+	esac
+	case " $lib_search_path " in
+	*" $dir "*) ;;
+	*) lib_search_path="$lib_search_path $dir";;
+	esac
+	case "$host" in
+	*-*-cygwin* | *-*-mingw* | *-*-os2*)
+	  dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+	  case ":$dllsearchpath:" in
+	  ::) dllsearchpath="$dllsearchdir";;
+	  *":$dllsearchdir:"*) ;;
+	  *) dllsearchpath="$dllsearchpath:$dllsearchdir";;
+	  esac
+	  ;;
+	esac
+	;;
+
+      -l*)
+	if test "$arg" = "-lc"; then
+	  case "$host" in
+	  *-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos* |*-*-freebsd* )
+	    # These systems don't actually have c library (as such)
+	    continue
+	    ;;
+	  esac
+	elif test "$arg" = "-lm"; then
+	  case "$host" in
+	  *-*-cygwin* | *-*-beos*)
+	    # These systems don't actually have math library (as such)
+	    continue
+	    ;;
+	  esac
+	fi
+	deplibs="$deplibs $arg"
+	;;
+
+      -module)
+	module=yes
+	continue
+	;;
+
+      -no-undefined)
+	allow_undefined=no
+	continue
+	;;
+
+      -o) prev=output ;;
+
+      -release)
+	prev=release
+	continue
+	;;
+
+      -rpath)
+	prev=rpath
+	continue
+	;;
+
+      -R)
+	prev=xrpath
+	continue
+	;;
+
+      -R*)
+	dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+	# We need an absolute path.
+	case "$dir" in
+	[\\/]* | [A-Za-z]:[\\/]*) ;;
+	*)
+	  $echo "$modename: only absolute run-paths are allowed" 1>&2
+	  exit 1
+	  ;;
+	esac
+	case "$xrpath " in
+	*" $dir "*) ;;
+	*) xrpath="$xrpath $dir" ;;
+	esac
+	continue
+	;;
+
+      -static)
+	# If we have no pic_flag, then this is the same as -all-static.
+	if test -z "$pic_flag" && test -n "$link_static_flag"; then
+	  compile_command="$compile_command $link_static_flag"
+	  finalize_command="$finalize_command $link_static_flag"
+	fi
+	continue
+	;;
+
+      -thread-safe)
+	thread_safe=yes
+	continue
+	;;
+
+      -version-info)
+	prev=vinfo
+	continue
+	;;
+
+      # Some other compiler flag.
+      -* | +*)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+	case "$arg" in
+	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	  arg="\"$arg\""
+	  ;;
+	esac
+	;;
+
+      *.o | *.obj | *.a | *.lib)
+	# A standard object.
+	objs="$objs $arg"
+	;;
+
+      *.lo)
+	# A library object.
+	if test "$prev" = dlfiles; then
+	  dlfiles="$dlfiles $arg"
+	  if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
+	    prev=
+	    continue
+	  else
+	    # If libtool objects are unsupported, then we need to preload.
+	    prev=dlprefiles
+	  fi
+	fi
+
+	if test "$prev" = dlprefiles; then
+	  # Preload the old-style object.
+	  dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
+	  prev=
+	fi
+	libobjs="$libobjs $arg"
+	;;
+
+      *.la)
+	# A libtool-controlled library.
+
+	dlname=
+	libdir=
+	library_names=
+	old_library=
+
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
+	  exit 1
+	fi
+
+	# If the library was installed with an old release of libtool,
+	# it will not redefine variable installed.
+	installed=yes
+
+	# Read the .la file
+	# If there is no directory component, then add one.
+	case "$arg" in
+	*/* | *\\*) . $arg ;;
+	*) . ./$arg ;;
+	esac
+
+	# Get the name of the library we link against.
+	linklib=
+	for l in $old_library $library_names; do
+	  linklib="$l"
+	done
+
+	if test -z "$linklib"; then
+	  $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
+	  exit 1
+	fi
+
+	# Find the relevant object directory and library name.
+	name=`$echo "X$arg" | $Xsed -e 's%^.*/%%' -e 's/\.la$//' -e 's/^lib//'`
+
+	if test "X$installed" = Xyes; then
+	  dir="$libdir"
+	else
+	  dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+	  if test "X$dir" = "X$arg"; then
+	    dir="$objdir"
+	  else
+	    dir="$dir/$objdir"
+	  fi
+	fi
+
+	if test -n "$dependency_libs"; then
+	  # Extract -R and -L from dependency_libs
+	  temp_deplibs=
+	  for deplib in $dependency_libs; do
+	    case "$deplib" in
+	    -R*) temp_xrpath=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+		 case " $rpath $xrpath " in
+		 *" $temp_xrpath "*) ;;
+		 *) xrpath="$xrpath $temp_xrpath";;
+		 esac;;
+	    -L*) case "$compile_command $temp_deplibs " in
+		 *" $deplib "*) ;;
+		 *) temp_deplibs="$temp_deplibs $deplib";;
+		 esac
+		 temp_dir=`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+		 case " $lib_search_path " in
+		 *" $temp_dir "*) ;;
+		 *) lib_search_path="$lib_search_path $temp_dir";;
+		 esac
+		 ;;
+	    *) temp_deplibs="$temp_deplibs $deplib";;
+	    esac
+	  done
+	  dependency_libs="$temp_deplibs"
+	fi
+
+	if test -z "$libdir"; then
+	  # It is a libtool convenience library, so add in its objects.
+	  convenience="$convenience $dir/$old_library"
+	  old_convenience="$old_convenience $dir/$old_library"
+	  deplibs="$deplibs$dependency_libs"
+	  compile_command="$compile_command $dir/$old_library$dependency_libs"
+	  finalize_command="$finalize_command $dir/$old_library$dependency_libs"
+	  continue
+	fi
+
+	# This library was specified with -dlopen.
+	if test "$prev" = dlfiles; then
+	  dlfiles="$dlfiles $arg"
+	  if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
+	    # If there is no dlname, no dlopen support or we're linking statically,
+	    # we need to preload.
+	    prev=dlprefiles
+	  else
+	    # We should not create a dependency on this library, but we
+	    # may need any libraries it requires.
+	    compile_command="$compile_command$dependency_libs"
+	    finalize_command="$finalize_command$dependency_libs"
+	    prev=
+	    continue
+	  fi
+	fi
+
+	# The library was specified with -dlpreopen.
+	if test "$prev" = dlprefiles; then
+	  # Prefer using a static library (so that no silly _DYNAMIC symbols
+	  # are required to link).
+	  if test -n "$old_library"; then
+	    dlprefiles="$dlprefiles $dir/$old_library"
+	  else
+	    dlprefiles="$dlprefiles $dir/$linklib"
+	  fi
+	  prev=
+	fi
+
+	if test -n "$library_names" &&
+	   { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+	  link_against_libtool_libs="$link_against_libtool_libs $arg"
+	  if test -n "$shlibpath_var"; then
+	    # Make sure the rpath contains only unique directories.
+	    case "$temp_rpath " in
+	    *" $dir "*) ;;
+	    *) temp_rpath="$temp_rpath $dir" ;;
+	    esac
+	  fi
+
+	  # We need an absolute path.
+	  case "$dir" in
+	  [\\/] | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+	  *)
+	    absdir=`cd "$dir" && pwd`
+	    if test -z "$absdir"; then
+	      $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+	      $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+	      absdir="$dir"
+	    fi
+	    ;;
+	  esac
+	  
+	  # This is the magic to use -rpath.
+	  # Skip directories that are in the system default run-time
+	  # search path, unless they have been requested with -R.
+	  case " $sys_lib_dlsearch_path " in
+	  *" $absdir "*) ;;
+	  *)
+	    case "$compile_rpath " in
+	    *" $absdir "*) ;;
+	    *) compile_rpath="$compile_rpath $absdir" 
+	    esac
+	    ;;
+	  esac
+
+	  case " $sys_lib_dlsearch_path " in
+	  *" $libdir "*) ;;
+	  *)
+	    case "$finalize_rpath " in
+	    *" $libdir "*) ;;
+	    *) finalize_rpath="$finalize_rpath $libdir"
+	    esac
+	    ;;
+	  esac
+
+	  lib_linked=yes
+	  case "$hardcode_action" in
+	  immediate | unsupported)
+	    if test "$hardcode_direct" = no; then
+	      compile_command="$compile_command $dir/$linklib"
+	      deplibs="$deplibs $dir/$linklib"
+	      case "$host" in
+	      *-*-cygwin* | *-*-mingw* | *-*-os2*)
+		dllsearchdir=`cd "$dir" && pwd || echo "$dir"`
+		if test -n "$dllsearchpath"; then
+		  dllsearchpath="$dllsearchpath:$dllsearchdir"
+		else
+		  dllsearchpath="$dllsearchdir"
+		fi
+		;;
+	      esac
+	    elif test "$hardcode_minus_L" = no; then
+	      case "$host" in
+	      *-*-sunos*)
+		compile_shlibpath="$compile_shlibpath$dir:"
+		;;
+	      esac
+	      case "$compile_command " in
+	      *" -L$dir "*) ;;
+	      *) compile_command="$compile_command -L$dir";;
+	      esac
+	      compile_command="$compile_command -l$name"
+	      deplibs="$deplibs -L$dir -l$name"
+	    elif test "$hardcode_shlibpath_var" = no; then
+	      case ":$compile_shlibpath:" in
+	      *":$dir:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$dir:";;
+	      esac
+	      compile_command="$compile_command -l$name"
+	      deplibs="$deplibs -l$name"
+	    else
+	      lib_linked=no
+	    fi
+	    ;;
+
+	  relink)
+	    if test "$hardcode_direct" = yes; then
+	      compile_command="$compile_command $absdir/$linklib"
+	      deplibs="$deplibs $absdir/$linklib"
+	    elif test "$hardcode_minus_L" = yes; then
+	      case "$compile_command " in
+	      *" -L$absdir "*) ;;
+	      *) compile_command="$compile_command -L$absdir";;
+	      esac
+	      compile_command="$compile_command -l$name"
+	      deplibs="$deplibs -L$absdir -l$name"
+	    elif test "$hardcode_shlibpath_var" = yes; then
+	      case ":$compile_shlibpath:" in
+	      *":$absdir:"*) ;;
+	      *) compile_shlibpath="$compile_shlibpath$absdir:";;
+	      esac
+	      compile_command="$compile_command -l$name"
+	      deplibs="$deplibs -l$name"
+	    else
+	      lib_linked=no
+	    fi
+	    ;;
+
+	  *)
+	    lib_linked=no
+	    ;;
+	  esac
+
+	  if test "$lib_linked" != yes; then
+	    $echo "$modename: configuration error: unsupported hardcode properties"
+	    exit 1
+	  fi
+
+	  # Finalize command for both is simple: just hardcode it.
+	  if test "$hardcode_direct" = yes; then
+	    finalize_command="$finalize_command $libdir/$linklib"
+	  elif test "$hardcode_minus_L" = yes; then
+	    case "$finalize_command " in
+	    *" -L$libdir "*) ;;
+	    *) finalize_command="$finalize_command -L$libdir";;
+	    esac
+	    finalize_command="$finalize_command -l$name"
+	  elif test "$hardcode_shlibpath_var" = yes; then
+	    case ":$finalize_shlibpath:" in
+	    *":$libdir:"*) ;;
+	    *) finalize_shlibpath="$finalize_shlibpath$libdir:";;
+	    esac
+	    finalize_command="$finalize_command -l$name"
+	  else
+	    # We cannot seem to hardcode it, guess we'll fake it.
+	    case "$finalize_command " in
+	    *" -L$dir "*) ;;
+	    *) finalize_command="$finalize_command -L$libdir";;
+	    esac
+	    finalize_command="$finalize_command -l$name"
+	  fi
+	else
+	  # Transform directly to old archives if we don't build new libraries.
+	  if test -n "$pic_flag" && test -z "$old_library"; then
+	    $echo "$modename: cannot find static library for \`$arg'" 1>&2
+	    exit 1
+	  fi
+
+	  # Here we assume that one of hardcode_direct or hardcode_minus_L
+	  # is not unsupported.  This is valid on all known static and
+	  # shared platforms.
+	  if test "$hardcode_direct" != unsupported; then
+	    test -n "$old_library" && linklib="$old_library"
+	    compile_command="$compile_command $dir/$linklib"
+	    finalize_command="$finalize_command $dir/$linklib"
+	  else
+	    case "$compile_command " in
+	    *" -L$dir "*) ;;
+	    *) compile_command="$compile_command -L$dir";;
+	    esac
+	    compile_command="$compile_command -l$name"
+	    case "$finalize_command " in
+	    *" -L$dir "*) ;;
+	    *) finalize_command="$finalize_command -L$dir";;
+	    esac
+	    finalize_command="$finalize_command -l$name"
+	  fi
+	fi
+
+	# Add in any libraries that this one depends upon.
+	compile_command="$compile_command$dependency_libs"
+	finalize_command="$finalize_command$dependency_libs"
+	continue
+	;;
+
+      # Some other compiler argument.
+      *)
+	# Unknown arguments in both finalize_command and compile_command need
+	# to be aesthetically quoted because they are evaled later.
+	arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+	case "$arg" in
+	*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	  arg="\"$arg\""
+	  ;;
+	esac
+	;;
+      esac
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+	compile_command="$compile_command $arg"
+	finalize_command="$finalize_command $arg"
+      fi
+    done
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      compile_command="$compile_command $arg"
+      finalize_command="$finalize_command $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+    libobjs_save="$libobjs"
+
+    case "$output" in
+    "")
+      $echo "$modename: you must specify an output file" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+      ;;
+
+    *.a | *.lib)
+      if test -n "$link_against_libtool_libs"; then
+	$echo "$modename: error: cannot link libtool libraries into archives" 1>&2
+	exit 1
+      fi
+
+      if test -n "$deplibs"; then
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+	$echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+	$echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+	$echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+      fi
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      ;;
+
+    *.la)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case "$outputname" in
+      lib*)
+	name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+	eval libname=\"$libname_spec\"
+	;;
+      *)
+	if test "$module" = no; then
+	  $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+	if test "$need_lib_prefix" != no; then
+	  # Add the "lib" prefix for modules if required
+	  name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+	  eval libname=\"$libname_spec\"
+	else
+	  libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+	fi
+	;;
+      esac
+
+      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$output_objdir" = "X$output"; then
+	output_objdir="$objdir"
+      else
+	output_objdir="$output_objdir/$objdir"
+      fi
+
+      if test -n "$objs"; then
+	$echo "$modename: cannot build libtool library \`$output' from non-libtool objects:$objs" 2>&1
+	exit 1
+      fi
+
+      # How the heck are we supposed to write a wrapper for a shared library?
+      if test -n "$link_against_libtool_libs"; then
+	 $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
+	 exit 1
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
+      fi
+
+      set dummy $rpath
+      if test $# -gt 2; then
+	$echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+      fi
+      install_libdir="$2"
+
+      oldlibs=
+      if test -z "$rpath"; then
+	if test "$build_libtool_libs" = yes; then
+	  # Building a libtool convenience library.
+	  libext=al
+	  oldlibs="$output_objdir/$libname.$libext $oldlibs"
+	  build_libtool_libs=convenience
+	  build_old_libs=yes
+	fi
+	dependency_libs="$deplibs"
+
+	if test -n "$vinfo"; then
+	  $echo "$modename: warning: \`-version-info' is ignored for convenience libraries" 1>&2
+	fi
+
+	if test -n "$release"; then
+	  $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+	fi
+      else
+
+	# Parse the version information argument.
+	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS=':'
+	set dummy $vinfo 0 0 0
+	IFS="$save_ifs"
+
+	if test -n "$8"; then
+	  $echo "$modename: too many parameters to \`-version-info'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	current="$2"
+	revision="$3"
+	age="$4"
+
+	# Check that each of the things are valid numbers.
+	case "$current" in
+	0 | [1-9] | [1-9][0-9]*) ;;
+	*)
+	  $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	case "$revision" in
+	0 | [1-9] | [1-9][0-9]*) ;;
+	*)
+	  $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	case "$age" in
+	0 | [1-9] | [1-9][0-9]*) ;;
+	*)
+	  $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	if test $age -gt $current; then
+	  $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+	  $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+	  exit 1
+	fi
+
+	# Calculate the version variables.
+	major=
+	versuffix=
+	verstring=
+	case "$version_type" in
+	none) ;;
+
+	irix)
+	  major=`expr $current - $age + 1`
+	  versuffix="$major.$revision"
+	  verstring="sgi$major.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$revision
+	  while test $loop != 0; do
+	    iface=`expr $revision - $loop`
+	    loop=`expr $loop - 1`
+	    verstring="sgi$major.$iface:$verstring"
+	  done
+	  ;;
+
+	linux)
+	  major=.`expr $current - $age`
+	  versuffix="$major.$age.$revision"
+	  ;;
+
+	osf)
+	  major=`expr $current - $age`
+	  versuffix=".$current.$age.$revision"
+	  verstring="$current.$age.$revision"
+
+	  # Add in all the interfaces that we are compatible with.
+	  loop=$age
+	  while test $loop != 0; do
+	    iface=`expr $current - $loop`
+	    loop=`expr $loop - 1`
+	    verstring="$verstring:${iface}.0"
+	  done
+
+	  # Make executables depend on our current version.
+	  verstring="$verstring:${current}.0"
+	  ;;
+
+	sunos)
+	  major=".$current"
+	  versuffix=".$current.$revision"
+	  ;;
+
+	freebsd-aout)
+	  major=".$current"
+	  versuffix=".$current.$revision";
+	  ;;
+
+	freebsd-elf)
+	  major=".$current"
+	  versuffix=".$current";
+	  ;;
+
+	windows)
+	  # Like Linux, but with '-' rather than '.', since we only
+	  # want one extension on Windows 95.
+	  major=`expr $current - $age`
+	  versuffix="-$major-$age-$revision"
+	  ;;
+
+	*)
+	  $echo "$modename: unknown library version type \`$version_type'" 1>&2
+	  echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	# Clear the version info if we defaulted, and they specified a release.
+	if test -z "$vinfo" && test -n "$release"; then
+	  major=
+	  verstring="0.0"
+	  if test "$need_version" = no; then
+	    versuffix=
+	  else
+	    versuffix=".0.0"
+	  fi
+	fi
+
+	# Remove version info from name if versioning should be avoided
+	if test "$avoid_version" = yes && test "$need_version" = no; then
+	  major=
+	  versuffix=
+	  verstring=""
+	fi
+	
+	# Check to see if the archive will have undefined symbols.
+	if test "$allow_undefined" = yes; then
+	  if test "$allow_undefined_flag" = unsupported; then
+	    $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+	    build_libtool_libs=no
+	    build_old_libs=yes
+	  fi
+	else
+	  # Don't allow undefined symbols.
+	  allow_undefined_flag="$no_undefined_flag"
+	fi
+
+	dependency_libs="$deplibs"
+	case "$host" in
+	*-*-cygwin* | *-*-mingw* | *-*-os2* | *-*-beos* | *-*-freebsd* )
+	  # these systems don't actually have a c library (as such)!
+	  ;;
+        *-*-rhapsody*)
+	  # rhapsody is a little odd...
+	  deplibs="$deplibs -framework System"
+	  ;;
+	*)
+	  # Add libc to deplibs on all other systems.
+	  deplibs="$deplibs -lc"
+	  ;;
+	esac
+      fi
+
+      # Create the output directory, or remove our outputs if we need to.
+      if test -d $output_objdir; then
+	$show "${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*"
+	$run ${rm}r $output_objdir/$outputname $output_objdir/$libname.* $output_objdir/${libname}${release}.*
+      else
+	$show "$mkdir $output_objdir"
+	$run $mkdir $output_objdir
+	status=$?
+	if test $status -ne 0 && test ! -d $output_objdir; then
+	  exit $status
+	fi
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+	oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+	# Transform .lo files to .o files.
+	oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      if test "$build_libtool_libs" = yes; then
+	# Transform deplibs into only deplibs that can be linked in shared.
+	name_save=$name
+	libname_save=$libname
+	release_save=$release
+	versuffix_save=$versuffix
+	major_save=$major
+	# I'm not sure if I'm treating the release correctly.  I think
+	# release should show up in the -l (ie -lgmp5) so we don't want to
+	# add it in twice.  Is that correct?
+	release=""
+	versuffix=""
+	major=""
+	newdeplibs=
+	droppeddeps=no
+	case "$deplibs_check_method" in
+	pass_all)
+	  # Don't check for shared/static.  Everything works.
+	  # This might be a little naive.  We might want to check
+	  # whether the library exists or not.  But this is on
+	  # osf3 & osf4 and I'm not really sure... Just
+	  # implementing what was already the behaviour.
+	  newdeplibs=$deplibs
+	  ;;
+	test_compile)
+	  # This code stresses the "libraries are programs" paradigm to its
+	  # limits. Maybe even breaks it.  We compile a program, linking it
+	  # against the deplibs as a proxy for the library.  Then we can check
+	  # whether they linked in statically or dynamically with ldd.
+	  $rm conftest.c
+	  cat > conftest.c <<EOF
+	  int main() { return 0; }
+EOF
+	  $rm conftest
+	  $CC -o conftest conftest.c $deplibs
+	  if test $? -eq 0 ; then
+	    ldd_output=`ldd conftest`
+	    for i in $deplibs; do
+	      name="`expr $i : '-l\(.*\)'`"
+	      # If $name is empty we are operating on a -L argument.
+	      if test "$name" != "" ; then
+		libname=`eval \\$echo \"$libname_spec\"`
+		deplib_matches=`eval \\$echo \"$library_names_spec\"`
+		set dummy $deplib_matches
+		deplib_match=$2
+		if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		  newdeplibs="$newdeplibs $i"
+		else
+		  droppeddeps=yes
+		  echo
+		  echo "*** Warning: This library needs some functionality provided by $i."
+		  echo "*** I have the capability to make that library automatically link in when"
+		  echo "*** you link to this library.  But I can only do this if you have a"
+		  echo "*** shared version of the library, which you do not appear to have."
+		fi
+	      else
+		newdeplibs="$newdeplibs $i"
+	      fi
+	    done
+	  else
+	    # Error occured in the first compile.  Let's try to salvage the situation:
+	    # Compile a seperate program for each library.
+	    for i in $deplibs; do
+	      name="`expr $i : '-l\(.*\)'`"
+	     # If $name is empty we are operating on a -L argument.
+	      if test "$name" != "" ; then
+		$rm conftest
+		$CC -o conftest conftest.c $i
+		# Did it work?
+		if test $? -eq 0 ; then
+		  ldd_output=`ldd conftest`
+		  libname=`eval \\$echo \"$libname_spec\"`
+		  deplib_matches=`eval \\$echo \"$library_names_spec\"`
+		  set dummy $deplib_matches
+		  deplib_match=$2
+		  if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+		    newdeplibs="$newdeplibs $i"
+		  else
+		    droppeddeps=yes
+		    echo
+		    echo "*** Warning: This library needs some functionality provided by $i."
+		    echo "*** I have the capability to make that library automatically link in when"
+		    echo "*** you link to this library.  But I can only do this if you have a"
+		    echo "*** shared version of the library, which you do not appear to have."
+		  fi
+		else
+		  droppeddeps=yes
+		  echo
+		  echo "*** Warning!  Library $i is needed by this library but I was not able to"
+		  echo "***  make it link in!  You will probably need to install it or some"
+		  echo "*** library that it depends on before this library will be fully"
+		  echo "*** functional.  Installing it before continuing would be even better."
+		fi
+	      else
+		newdeplibs="$newdeplibs $i"
+	      fi
+	    done
+	  fi
+	  ;;
+	file_magic*)
+	  set dummy $deplibs_check_method
+	  file_magic_regex="`expr \"$deplibs_check_method\" : \"$2 \(.*\)\"`"
+	  for a_deplib in $deplibs; do
+	    name="`expr $a_deplib : '-l\(.*\)'`"
+	    # If $name is empty we are operating on a -L argument.
+	    if test "$name" != "" ; then
+	      libname=`eval \\$echo \"$libname_spec\"`
+	      for i in $lib_search_path; do
+		    potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+		    for potent_lib in $potential_libs; do
+		      # Follow soft links.
+		      if ls -lLd "$potent_lib" 2>/dev/null \
+			 | grep " -> " >/dev/null; then
+			continue 
+		      fi
+		      # The statement above tries to avoid entering an
+		      # endless loop below, in case of cyclic links.
+		      # We might still enter an endless loop, since a link
+		      # loop can be closed while we follow links,
+		      # but so what?
+		      potlib="$potent_lib"
+		      while test -h "$potlib" 2>/dev/null; do
+			potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+			case "$potliblink" in
+			[\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+			*) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+			esac
+		      done
+		      if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+			 | sed 10q \
+			 | egrep "$file_magic_regex" > /dev/null; then
+			newdeplibs="$newdeplibs $a_deplib"
+			a_deplib=""
+			break 2
+		      fi
+		    done
+	      done
+	      if test -n "$a_deplib" ; then
+		droppeddeps=yes
+		echo
+		echo "*** Warning: This library needs some functionality provided by $a_deplib."
+		echo "*** I have the capability to make that library automatically link in when"
+		echo "*** you link to this library.  But I can only do this if you have a"
+		echo "*** shared version of the library, which you do not appear to have."
+	      fi
+	    else
+	      # Add a -L argument.
+	      newdeplibs="$newdeplibs $a_deplib"
+	    fi
+	  done # Gone through all deplibs.
+	  ;;
+	none | unknown | *)
+	  newdeplibs=""
+	  if $echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+	       -e 's/ -[LR][^ ]*//g' -e 's/[ 	]//g' |
+	     grep . >/dev/null; then
+	    echo
+	    if test "X$deplibs_check_method" = "Xnone"; then
+	      echo "*** Warning: inter-library dependencies are not supported in this platform."
+	    else
+	      echo "*** Warning: inter-library dependencies are not known to be supported."
+	    fi
+	    echo "*** All declared inter-library dependencies are being dropped."
+	    droppeddeps=yes
+	  fi
+	  ;;
+	esac
+	versuffix=$versuffix_save
+	major=$major_save
+	release=$release_save
+	libname=$libname_save
+	name=$name_save
+
+	if test "$droppeddeps" = yes; then
+	  if test "$module" = yes; then
+	    echo
+	    echo "*** Warning: libtool could not satisfy all declared inter-library"
+	    echo "*** dependencies of module $libname.  Therefore, libtool will create"
+	    echo "*** a static module, that should work as long as the dlopening"
+	    echo "*** application is linked with the -dlopen flag."
+	    if test -z "$global_symbol_pipe"; then
+	      echo
+	      echo "*** However, this would only work if libtool was able to extract symbol"
+	      echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+	      echo "*** not find such a program.  So, this module is probably useless."
+	      echo "*** \`nm' from GNU binutils and a full rebuild may help."
+	    fi
+	    if test "$build_old_libs" = no; then
+	      oldlibs="$output_objdir/$libname.$libext"
+	      build_libtool_libs=module
+	      build_old_libs=yes
+	    else
+	      build_libtool_libs=no
+	    fi
+	  else
+	    echo "*** The inter-library dependencies that have been dropped here will be"
+	    echo "*** automatically added whenever a program is linked with this library"
+	    echo "*** or is declared to -dlopen it."
+	  fi
+	fi
+	# Done checking deplibs!
+	deplibs=$newdeplibs
+      fi
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+      
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+	# Get the real and link names of the library.
+	eval library_names=\"$library_names_spec\"
+	set dummy $library_names
+	realname="$2"
+	shift; shift
+
+	if test -n "$soname_spec"; then
+	  eval soname=\"$soname_spec\"
+	else
+	  soname="$realname"
+	fi
+
+	lib="$output_objdir/$realname"
+	for link
+	do
+	  linknames="$linknames $link"
+	done
+
+	# Ensure that we have .o objects for linkers which dislike .lo
+	# (e.g. aix) in case we are running --disable-static
+	for obj in $libobjs; do
+	  xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+	  if test "X$xdir" = "X$obj"; then
+	    xdir="."
+	  else
+	    xdir="$xdir"
+	  fi
+	  baseobj=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+	  oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	  if test ! -f $xdir/$oldobj; then
+	    $show "(cd $xdir && ${LN_S} $baseobj $oldobj)"
+	    $run eval '(cd $xdir && ${LN_S} $baseobj $oldobj)' || exit $?
+	  fi
+	done
+
+	# Use standard objects if they are pic
+	test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+	# Prepare the list of exported symbols
+	if test -z "$export_symbols"; then
+	  if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+	    $show "generating symbol list for \`$libname.la'"
+	    export_symbols="$output_objdir/$libname.exp"
+	    $run $rm $export_symbols
+	    eval cmds=\"$export_symbols_cmds\"
+	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      $show "$cmd"
+	      $run eval "$cmd" || exit $?
+	    done
+	    IFS="$save_ifs"
+	    if test -n "$export_symbols_regex"; then
+	      $show "egrep -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+	      $run eval 'egrep -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+	      $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+	      $run eval '$mv "${export_symbols}T" "$export_symbols"'
+	    fi
+	  fi
+	fi
+
+	if test -n "$export_symbols" && test -n "$include_expsyms"; then
+	  $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+	fi
+
+	if test -n "$convenience"; then
+	  if test -n "$whole_archive_flag_spec"; then
+	    eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+	  else
+	    gentop="$output_objdir/${outputname}x"
+	    $show "${rm}r $gentop"
+	    $run ${rm}r "$gentop"
+	    $show "mkdir $gentop"
+	    $run mkdir "$gentop"
+	    status=$?
+	    if test $status -ne 0 && test ! -d "$gentop"; then
+	      exit $status
+	    fi
+	    generated="$generated $gentop"
+
+	    for xlib in $convenience; do
+	      # Extract the objects.
+	      case "$xlib" in
+	      [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	      *) xabs=`pwd`"/$xlib" ;;
+	      esac
+	      xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	      xdir="$gentop/$xlib"
+
+	      $show "${rm}r $xdir"
+	      $run ${rm}r "$xdir"
+	      $show "mkdir $xdir"
+	      $run mkdir "$xdir"
+	      status=$?
+	      if test $status -ne 0 && test ! -d "$xdir"; then
+		exit $status
+	      fi
+	      $show "(cd $xdir && $AR x $xabs)"
+	      $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	      libobjs="$libobjs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+	    done
+	  fi
+	fi
+
+	if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+	  eval flag=\"$thread_safe_flag_spec\"
+	  linkopts="$linkopts $flag"
+	fi
+
+	# Do each of the archive commands.
+	if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+	  eval cmds=\"$archive_expsym_cmds\"
+	else
+	  eval cmds=\"$archive_cmds\"
+	fi
+	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  $show "$cmd"
+	  $run eval "$cmd" || exit $?
+	done
+	IFS="$save_ifs"
+
+	# Create links to the real library.
+	for linkname in $linknames; do
+	  if test "$realname" != "$linkname"; then
+	    $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+	    $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+	  fi
+	done
+
+	# If -module or -export-dynamic was specified, set the dlname.
+	if test "$module" = yes || test "$export_dynamic" = yes; then
+	  # On all known operating systems, these are identical.
+	  dlname="$soname"
+	fi
+      fi
+      ;;
+
+    *.lo | *.o | *.obj)
+      if test -n "$link_against_libtool_libs"; then
+	$echo "$modename: error: cannot link libtool libraries into objects" 1>&2
+	exit 1
+      fi
+
+      if test -n "$deplibs"; then
+	$echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	$echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+	$echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+	$echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+      fi
+
+      case "$output" in
+      *.lo)
+	if test -n "$objs"; then
+	  $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+	  exit 1
+	fi
+	libobj="$output"
+	obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+	;;
+      *)
+	libobj=
+	obj="$output"
+	;;
+      esac
+
+      # Delete the old objects.
+      $run $rm $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec
+      wl= 
+
+      if test -n "$convenience"; then
+	if test -n "$whole_archive_flag_spec"; then
+	  eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+	else
+	  gentop="$output_objdir/${obj}x"
+	  $show "${rm}r $gentop"
+	  $run ${rm}r "$gentop"
+	  $show "mkdir $gentop"
+	  $run mkdir "$gentop"
+	  status=$?
+	  if test $status -ne 0 && test ! -d "$gentop"; then
+	    exit $status
+	  fi
+	  generated="$generated $gentop"
+
+	  for xlib in $convenience; do
+	    # Extract the objects.
+	    case "$xlib" in
+	    [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	    *) xabs=`pwd`"/$xlib" ;;
+	    esac
+	    xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	    xdir="$gentop/$xlib"
+
+	    $show "${rm}r $xdir"
+	    $run ${rm}r "$xdir"
+	    $show "mkdir $xdir"
+	    $run mkdir "$xdir"
+	    status=$?
+	    if test $status -ne 0 && test ! -d "$xdir"; then
+	      exit $status
+	    fi
+	    $show "(cd $xdir && $AR x $xabs)"
+	    $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	    reload_conv_objs="$reload_objs "`find $xdir -name \*.o -print -o -name \*.lo -print | $NL2SP`
+	  done
+	fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs"
+
+      output="$obj"
+      eval cmds=\"$reload_cmds\"
+      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+	if test -n "$gentop"; then
+	  $show "${rm}r $gentop"
+	  $run ${rm}r $gentop
+	fi
+
+	exit 0
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+	if test -n "$gentop"; then
+	  $show "${rm}r $gentop"
+	  $run ${rm}r $gentop
+	fi
+
+	# Create an invalid libtool object if no PIC, so that we don't
+	# accidentally link it into a program.
+	$show "echo timestamp > $libobj"
+	$run eval "echo timestamp > $libobj" || exit $?
+	exit 0
+      fi
+
+      if test -n "$pic_flag"; then
+	# Only do commands if we really have different PIC objects.
+	reload_objs="$libobjs $reload_conv_objs"
+	output="$libobj"
+	eval cmds=\"$reload_cmds\"
+	IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	for cmd in $cmds; do
+	  IFS="$save_ifs"
+	  $show "$cmd"
+	  $run eval "$cmd" || exit $?
+	done
+	IFS="$save_ifs"
+      else
+	# Just create a symlink.
+	$show $rm $libobj
+	$run $rm $libobj
+	xdir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
+	if test "X$xdir" = "X$libobj"; then
+	  xdir="."
+	else
+	  xdir="$xdir"
+	fi
+	baseobj=`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+	oldobj=`$echo "X$baseobj" | $Xsed -e "$lo2o"`
+	$show "(cd $xdir && $LN_S $oldobj $baseobj)"
+	$run eval '(cd $xdir && $LN_S $oldobj $baseobj)' || exit $?
+      fi
+
+      if test -n "$gentop"; then
+	$show "${rm}r $gentop"
+	$run ${rm}r $gentop
+      fi
+
+      exit 0
+      ;;
+
+    # Anything else should be a program.
+    *)
+      if test -n "$vinfo"; then
+	$echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+      fi
+
+      if test -n "$release"; then
+	$echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+      fi
+
+      if test "$preload" = yes; then
+	if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
+	   test "$dlopen_self_static" = unknown; then
+	  $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+	fi 
+      fi
+    
+      if test -n "$rpath$xrpath"; then
+	# If the user specified any rpath flags, then add them.
+	for libdir in $rpath $xrpath; do
+	  # This is the magic to use -rpath.
+	  case "$compile_rpath " in
+	  *" $libdir "*) ;;
+	  *) compile_rpath="$compile_rpath $libdir" ;;
+	  esac
+	  case "$finalize_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_rpath="$finalize_rpath $libdir" ;;
+	  esac
+	done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) perm_rpath="$perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+	if test -n "$hardcode_libdir_flag_spec"; then
+	  if test -n "$hardcode_libdir_separator"; then
+	    if test -z "$hardcode_libdirs"; then
+	      hardcode_libdirs="$libdir"
+	    else
+	      # Just accumulate the unique libdirs.
+	      case "$hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator" in
+	      *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+		;;
+	      *)
+		hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+		;;
+	      esac
+	    fi
+	  else
+	    eval flag=\"$hardcode_libdir_flag_spec\"
+	    rpath="$rpath $flag"
+	  fi
+	elif test -n "$runpath_var"; then
+	  case "$finalize_perm_rpath " in
+	  *" $libdir "*) ;;
+	  *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+	  esac
+	fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+	 test -n "$hardcode_libdirs"; then
+	libdir="$hardcode_libdirs"
+	eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$output_objdir" = "X$output"; then
+	output_objdir="$objdir"
+      else
+	output_objdir="$output_objdir/$objdir"
+      fi
+
+      # Create the binary in the object directory, then wrap it.
+      if test ! -d $output_objdir; then
+	$show "$mkdir $output_objdir"
+	$run $mkdir $output_objdir
+	status=$?
+	if test $status -ne 0 && test ! -d $output_objdir; then
+	  exit $status
+	fi
+      fi
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+	# Transform all the library objects into standard objects.
+	compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      dlsyms=
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+	if test -n "$NM" && test -n "$global_symbol_pipe"; then
+	  dlsyms="${outputname}S.c"
+	else
+	  $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+	fi
+      fi
+
+      if test -n "$dlsyms"; then
+	case "$dlsyms" in
+	"") ;;
+	*.c)
+	  # Discover the nlist of each of the dlfiles.
+	  nlist="$output_objdir/${outputname}.nm"
+
+	  $show "$rm $nlist ${nlist}S ${nlist}T"
+	  $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+	  # Parse the name list into a source file.
+	  $show "creating $output_objdir/$dlsyms"
+
+	  test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+	  if test "$dlself" = yes; then
+	    $show "generating symbol list for \`$output'"
+
+	    test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+	    # Add our own program objects to the symbol list.
+	    progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+	    for arg in $progfiles; do
+	      $show "extracting global C symbols from \`$arg'"
+	      $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+	    done
+
+	    if test -n "$exclude_expsyms"; then
+	      $run eval 'egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+	      $run eval '$mv "$nlist"T "$nlist"'
+	    fi
+	    
+	    if test -n "$export_symbols_regex"; then
+	      $run eval 'egrep -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+	      $run eval '$mv "$nlist"T "$nlist"'
+	    fi
+
+	    # Prepare the list of exported symbols
+	    if test -z "$export_symbols"; then
+	      export_symbols="$output_objdir/$output.exp"
+	      $run $rm $export_symbols
+	      $run eval "sed -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+	    else
+	      $run eval "sed -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
+	      $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
+	      $run eval 'mv "$nlist"T "$nlist"'
+	    fi
+	  fi
+
+	  for arg in $dlprefiles; do
+	    $show "extracting global C symbols from \`$arg'"
+	    name=`echo "$arg" | sed -e 's%^.*/%%'`
+	    $run eval 'echo ": $name " >> "$nlist"'
+	    $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+	  done
+
+	  if test -z "$run"; then
+	    # Make sure we have at least an empty file.
+	    test -f "$nlist" || : > "$nlist"
+
+	    if test -n "$exclude_expsyms"; then
+	      egrep -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+	      $mv "$nlist"T "$nlist"
+	    fi
+
+	    # Try sorting and uniquifying the output.
+	    if grep -v "^: " < "$nlist" | sort +2 | uniq > "$nlist"S; then
+	      :
+	    else
+	      grep -v "^: " < "$nlist" > "$nlist"S
+	    fi
+
+	    if test -f "$nlist"S; then
+	      eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+	    else
+	      echo '/* NONE */' >> "$output_objdir/$dlsyms"
+	    fi
+
+	    $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+	    sed -n -e 's/^: \([^ ]*\) $/  {\"\1\", (lt_ptr_t) 0},/p' \
+		-e 's/^. \([^ ]*\) \([^ ]*\)$/  {"\2", (lt_ptr_t) \&\2},/p' \
+		  < "$nlist" >> "$output_objdir/$dlsyms"
+
+	    $echo >> "$output_objdir/$dlsyms" "\
+  {0, (lt_ptr_t) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+	  fi
+
+	  pic_flag_for_symtable=
+	  case "$host" in
+	  # compiling the symbol table file with pic_flag works around
+	  # a FreeBSD bug that causes programs to crash when -lm is
+	  # linked before any other PIC object.  But we must not use
+	  # pic_flag when linking with -static.  The problem exists in
+	  # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+	  *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag -DPIC -DFREEBSD_WORKAROUND";;
+	    esac;;
+	  *-*-hpux*)
+	    case "$compile_command " in
+	    *" -static "*) ;;
+	    *) pic_flag_for_symtable=" $pic_flag -DPIC";;
+	    esac
+	  esac
+
+	  # Now compile the dynamic symbol file.
+	  $show "(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+	  $run eval '(cd $output_objdir && $CC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+	  # Clean up the generated files.
+	  $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+	  $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+	  # Transform the symbol file into the correct name.
+	  compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+	  finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+	  ;;
+	*)
+	  $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+	  exit 1
+	  ;;
+	esac
+      else
+	# We keep going just in case the user didn't refer to
+	# lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+	# really was required.
+
+	# Nullify the symbol file.
+	compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+	finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+      fi
+
+      if test -z "$link_against_libtool_libs" || test "$build_libtool_libs" != yes; then
+	# Replace the output file specification.
+	compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+	link_command="$compile_command$compile_rpath"
+
+	# We have no uninstalled library dependencies, so finalize right now.
+	$show "$link_command"
+	$run eval "$link_command"
+	status=$?
+	
+	# Delete the generated files.
+	if test -n "$dlsyms"; then
+	  $show "$rm $output_objdir/${outputname}S.${objext}"
+	  $run $rm "$output_objdir/${outputname}S.${objext}"
+	fi
+
+	exit $status
+      fi
+
+      if test -n "$shlibpath_var"; then
+	# We should set the shlibpath_var
+	rpath=
+	for dir in $temp_rpath; do
+	  case "$dir" in
+	  [\\/]* | [A-Za-z]:[\\/]*)
+	    # Absolute path.
+	    rpath="$rpath$dir:"
+	    ;;
+	  *)
+	    # Relative path: add a thisdir entry.
+	    rpath="$rpath\$thisdir/$dir:"
+	    ;;
+	  esac
+	done
+	temp_rpath="$rpath"
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+	compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+	finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+	if test -n "$perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+	if test -n "$finalize_perm_rpath"; then
+	  # We should set the runpath_var.
+	  rpath=
+	  for dir in $finalize_perm_rpath; do
+	    rpath="$rpath$dir:"
+	  done
+	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+	fi
+      fi
+
+      if test "$hardcode_action" = relink; then
+	# Fast installation is not supported
+	link_command="$compile_var$compile_command$compile_rpath"
+	relink_command="$finalize_var$finalize_command$finalize_rpath"
+	
+	$echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+	$echo "$modename: \`$output' will be relinked during installation" 1>&2
+      else
+	if test "$fast_install" != no; then
+	  link_command="$finalize_var$compile_command$finalize_rpath"
+	  if test "$fast_install" = yes; then
+	    relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+	  else
+	    # fast_install is set to needless
+	    relink_command=
+	  fi
+	else
+	  link_command="$compile_var$compile_command$compile_rpath"
+	  relink_command="$finalize_var$finalize_command$finalize_rpath"
+	fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+      
+      # Delete the old output files.
+      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      $show "$link_command"
+      $run eval "$link_command" || exit $?
+
+      # Now create the wrapper script.
+      $show "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+	relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $0 --fallback-echo"; then
+	case "$0" in
+	[\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $0 --fallback-echo";;
+	*) qecho="$SHELL `pwd`/$0 --fallback-echo";;
+	esac
+	qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+	qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if our run command is non-null.
+      if test -z "$run"; then
+	# win32 will think the script is a binary if it has
+	# a .exe suffix, so we strip it off here.
+	case $output in
+	  *.exe) output=`echo $output|sed 's,.exe$,,'` ;;
+	esac
+	$rm $output
+	trap "$rm $output; exit 1" 1 2 15
+
+	$echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+if test \"\${CDPATH+set}\" = set; then CDPATH=:; export CDPATH; fi
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variable:
+  link_against_libtool_libs='$link_against_libtool_libs'
+else
+  # When we are sourced in execute mode, \$file and \$echo are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    echo=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$echo works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$echo will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+	$echo >> $output "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | sed -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\/]* | [A-Za-z]:[\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | sed -n 's/.*-> //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+	if test "$fast_install" = yes; then
+	  echo >> $output "\
+  program=lt-'$outputname'
+  progdir=\"\$thisdir/$objdir\"
+  
+  if test ! -f \"\$progdir/\$program\" || \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | sed 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $mkdir \"\$progdir\"
+    else
+      $rm \"\$progdir/\$file\"
+    fi"
+
+	  echo >> $output "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if (cd \"\$thisdir\" && eval \$relink_command); then :
+      else
+	$rm \"\$progdir/\$file\"
+	exit 1
+      fi
+    fi
+
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
+  fi"
+	else
+	  echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+	fi
+
+	echo >> $output "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+	# Export our shlibpath_var if we have one.
+	if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+	  $echo >> $output "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+	fi
+
+	# fixup the dll searchpath if we need to.
+	if test -n "$dllsearchpath"; then
+	  $echo >> $output "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+	fi
+
+	$echo >> $output "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+	case $host in
+	  # win32 systems need to use the prog path for dll
+	  # lookup to work
+	*-*-cygwin*)
+	  $echo >> $output "\
+      exec \$progdir/\$program \${1+\"\$@\"}
+"
+	  ;;
+
+	# Backslashes separate directories on plain windows
+	*-*-mingw | *-*-os2*)
+	  $echo >> $output "\
+      exec \$progdir\\\\\$program \${1+\"\$@\"}
+"
+	  ;;
+
+	*)
+	  $echo >> $output "\
+      # Export the path to the program.
+      PATH=\"\$progdir:\$PATH\"
+      export PATH
+
+      exec \$program \${1+\"\$@\"}
+"
+	  ;;
+	esac
+	$echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      exit 1
+    fi
+  else
+    # The program doesn't exist.
+    \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
+    \$echo \"This script is just a wrapper for \$program.\" 1>&2
+    echo \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit 1
+  fi
+fi\
+"
+	chmod +x $output
+      fi
+      exit 0
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+	oldobjs="$libobjs_save"
+	addlibs="$convenience"
+	build_libtool_libs=no
+      else
+	if test "$build_libtool_libs" = module; then
+	  oldobjs="$libobjs_save"
+	  build_libtool_libs=no
+	else
+	  oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
+	fi
+	addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+	gentop="$output_objdir/${outputname}x"
+	$show "${rm}r $gentop"
+	$run ${rm}r "$gentop"
+	$show "mkdir $gentop"
+	$run mkdir "$gentop"
+	status=$?
+	if test $status -ne 0 && test ! -d "$gentop"; then
+	  exit $status
+	fi
+	generated="$generated $gentop"
+	  
+	# Add in members from convenience archives.
+	for xlib in $addlibs; do
+	  # Extract the objects.
+	  case "$xlib" in
+	  [\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
+	  *) xabs=`pwd`"/$xlib" ;;
+	  esac
+	  xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
+	  xdir="$gentop/$xlib"
+
+	  $show "${rm}r $xdir"
+	  $run ${rm}r "$xdir"
+	  $show "mkdir $xdir"
+	  $run mkdir "$xdir"
+	  status=$?
+	  if test $status -ne 0 && test ! -d "$xdir"; then
+	    exit $status
+	  fi
+	  $show "(cd $xdir && $AR x $xabs)"
+	  $run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
+
+	  oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
+	done
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+	eval cmds=\"$old_archive_from_new_cmds\"
+      else
+	# Ensure that we have .o objects in place in case we decided
+	# not to build a shared library, and have fallen back to building
+	# static libs even though --disable-static was passed!
+	for oldobj in $oldobjs; do
+	  if test ! -f $oldobj; then
+	    xdir=`$echo "X$oldobj" | $Xsed -e 's%/[^/]*$%%'`
+	    if test "X$xdir" = "X$oldobj"; then
+	      xdir="."
+	    else
+	      xdir="$xdir"
+	    fi
+	    baseobj=`$echo "X$oldobj" | $Xsed -e 's%^.*/%%'`
+	    obj=`$echo "X$baseobj" | $Xsed -e "$o2lo"`
+	    $show "(cd $xdir && ${LN_S} $obj $baseobj)"
+	    $run eval '(cd $xdir && ${LN_S} $obj $baseobj)' || exit $?
+	  fi
+	done
+
+	eval cmds=\"$old_archive_cmds\"
+      fi
+      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$generated"; then
+      $show "${rm}r$generated"
+      $run ${rm}r$generated
+    fi
+
+    # Now create the libtool archive.
+    case "$output" in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      $show "creating $output"
+
+      if test -n "$xrpath"; then
+	temp_xrpath=
+	for libdir in $xrpath; do
+	  temp_xrpath="$temp_xrpath -R$libdir"
+	done
+	dependency_libs="$temp_xrpath $dependency_libs"
+      fi
+
+      # Only create the output if not a dry run.
+      if test -z "$run"; then
+	for installed in no yes; do
+	  if test "$installed" = yes; then
+	    if test -z "$install_libdir"; then
+	      break
+	    fi
+	    output="$output_objdir/$outputname"i
+	  fi
+	  $rm $output
+	  $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$dlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'\
+"
+	done
+      fi
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+      $run eval "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)" || exit $?
+      ;;
+    esac
+    exit 0
+    ;;
+
+  # libtool install mode
+  install)
+    modename="$modename: install"
+
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh; then
+      # Aesthetically quote it.
+      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+      case "$arg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	arg="\"$arg\""
+	;;
+      esac
+      install_prog="$arg "
+      arg="$1"
+      shift
+    else
+      install_prog=
+      arg="$nonopt"
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+    case "$arg" in
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+      arg="\"$arg\""
+      ;;
+    esac
+    install_prog="$install_prog$arg"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+	files="$files $dest"
+	dest="$arg"
+	continue
+      fi
+
+      case "$arg" in
+      -d) isdir=yes ;;
+      -f) prev="-f" ;;
+      -g) prev="-g" ;;
+      -m) prev="-m" ;;
+      -o) prev="-o" ;;
+      -s)
+	stripme=" -s"
+	continue
+	;;
+      -*) ;;
+
+      *)
+	# If the previous option needed an argument, then skip it.
+	if test -n "$prev"; then
+	  prev=
+	else
+	  dest="$arg"
+	  continue
+	fi
+	;;
+      esac
+
+      # Aesthetically quote the argument.
+      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+      case "$arg" in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \	]*|*]*)
+	arg="\"$arg\""
+	;;
+      esac
+      install_prog="$install_prog $arg"
+    done
+
+    if test -z "$install_prog"; then
+      $echo "$modename: you must specify an install program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+	$echo "$modename: no file or destination specified" 1>&2
+      else
+	$echo "$modename: you must specify a destination" 1>&2
+      fi
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    # Strip any trailing slash from the destination.
+    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$destdir" = "X$dest" && destdir=.
+      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files
+      if test $# -gt 2; then
+	$echo "$modename: \`$dest' is not a directory" 1>&2
+	$echo "$help" 1>&2
+	exit 1
+      fi
+    fi
+    case "$destdir" in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+	case "$file" in
+	*.lo) ;;
+	*)
+	  $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	  ;;
+	esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case "$file" in
+      *.a | *.lib)
+	# Do the static libraries later.
+	staticlibs="$staticlibs $file"
+	;;
+
+      *.la)
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	library_names=
+	old_library=
+	# If there is no directory component, then add one.
+	case "$file" in
+	*/* | *\\*) . $file ;;
+	*) . ./$file ;;
+	esac
+
+	# Add the libdir to current_libdirs if it is the destination.
+	if test "X$destdir" = "X$libdir"; then
+	  case "$current_libdirs " in
+	  *" $libdir "*) ;;
+	  *) current_libdirs="$current_libdirs $libdir" ;;
+	  esac
+	else
+	  # Note the libdir as a future libdir.
+	  case "$future_libdirs " in
+	  *" $libdir "*) ;;
+	  *) future_libdirs="$future_libdirs $libdir" ;;
+	  esac
+	fi
+
+	dir="`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/"
+	test "X$dir" = "X$file/" && dir=
+	dir="$dir$objdir"
+
+	# See the names of the shared library.
+	set dummy $library_names
+	if test -n "$2"; then
+	  realname="$2"
+	  shift
+	  shift
+
+	  # Install the shared library and build the symlinks.
+	  $show "$install_prog $dir/$realname $destdir/$realname"
+	  $run eval "$install_prog $dir/$realname $destdir/$realname" || exit $?
+
+	  if test $# -gt 0; then
+	    # Delete the old symlinks, and create new ones.
+	    for linkname
+	    do
+	      if test "$linkname" != "$realname"; then
+		$show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+		$run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
+	      fi
+	    done
+	  fi
+
+	  # Do each command in the postinstall commands.
+	  lib="$destdir/$realname"
+	  eval cmds=\"$postinstall_cmds\"
+	  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    $show "$cmd"
+	    $run eval "$cmd" || exit $?
+	  done
+	  IFS="$save_ifs"
+	fi
+
+	# Install the pseudo-library for information purposes.
+	name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	instname="$dir/$name"i
+	$show "$install_prog $instname $destdir/$name"
+	$run eval "$install_prog $instname $destdir/$name" || exit $?
+
+	# Maybe install the static library, too.
+	test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+	;;
+
+      *.lo)
+	# Install (i.e. copy) a libtool object.
+
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Deduce the name of the destination old-style object file.
+	case "$destfile" in
+	*.lo)
+	  staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+	  ;;
+	*.o | *.obj)
+	  staticdest="$destfile"
+	  destfile=
+	  ;;
+	*)
+	  $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	  ;;
+	esac
+
+	# Install the libtool object if requested.
+	if test -n "$destfile"; then
+	  $show "$install_prog $file $destfile"
+	  $run eval "$install_prog $file $destfile" || exit $?
+	fi
+
+	# Install the old object if enabled.
+	if test "$build_old_libs" = yes; then
+	  # Deduce the name of the old-style object file.
+	  staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+	  $show "$install_prog $staticobj $staticdest"
+	  $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+	fi
+	exit 0
+	;;
+
+      *)
+	# Figure out destination file name, if it wasn't already specified.
+	if test -n "$destname"; then
+	  destfile="$destdir/$destname"
+	else
+	  destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+	  destfile="$destdir/$destfile"
+	fi
+
+	# Do a test to see if this is really a libtool program.
+	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  link_against_libtool_libs=
+	  relink_command=
+
+	  # If there is no directory component, then add one.
+	  case "$file" in
+	  */* | *\\*) . $file ;;
+	  *) . ./$file ;;
+	  esac
+
+	  # Check the variables that should have been set.
+	  if test -z "$link_against_libtool_libs"; then
+	    $echo "$modename: invalid libtool wrapper script \`$file'" 1>&2
+	    exit 1
+	  fi
+
+	  finalize=yes
+	  for lib in $link_against_libtool_libs; do
+	    # Check to see that each library is installed.
+	    libdir=
+	    if test -f "$lib"; then
+	      # If there is no directory component, then add one.
+	      case "$lib" in
+	      */* | *\\*) . $lib ;;
+	      *) . ./$lib ;;
+	      esac
+	    fi
+	    libfile="$libdir/`$echo "X$lib" | $Xsed -e 's%^.*/%%g'`"
+	    if test -n "$libdir" && test ! -f "$libfile"; then
+	      $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+	      finalize=no
+	    fi
+	  done
+
+	  outputname=
+	  if test "$fast_install" = no && test -n "$relink_command"; then
+	    if test "$finalize" = yes && test -z "$run"; then
+	      tmpdir="/tmp"
+	      test -n "$TMPDIR" && tmpdir="$TMPDIR"
+	      tmpdir="$tmpdir/libtool-$$"
+	      if $mkdir -p "$tmpdir" && chmod 700 "$tmpdir"; then :
+	      else
+		$echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
+		continue
+	      fi
+	      outputname="$tmpdir/$file"
+	      # Replace the output file specification.
+	      relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+	      $show "$relink_command"
+	      if $run eval "$relink_command"; then :
+	      else
+		$echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+		${rm}r "$tmpdir"
+		continue
+	      fi
+	      file="$outputname"
+	    else
+	      $echo "$modename: warning: cannot relink \`$file'" 1>&2
+	    fi
+	  else
+	    # Install the binary that we compiled earlier.
+	    file=`$echo "X$file" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+	  fi
+	fi
+
+	$show "$install_prog$stripme $file $destfile"
+	$run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+	test -n "$outputname" && ${rm}r "$tmpdir"
+	;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      $show "$install_prog $file $oldlib"
+      $run eval "$install_prog \$file \$oldlib" || exit $?
+
+      # Do each command in the postinstall commands.
+      eval cmds=\"$old_postinstall_cmds\"
+      IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+	IFS="$save_ifs"
+	$show "$cmd"
+	$run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$future_libdirs"; then
+      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+    fi
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      test -n "$run" && current_libdirs=" -n$current_libdirs"
+      exec $SHELL $0 --finish$current_libdirs
+      exit 1
+    fi
+
+    exit 0
+    ;;
+
+  # libtool finish mode
+  finish)
+    modename="$modename: finish"
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+	libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+	if test -n "$finish_cmds"; then
+	  # Do each command in the finish commands.
+	  eval cmds=\"$finish_cmds\"
+	  IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	  for cmd in $cmds; do
+	    IFS="$save_ifs"
+	    $show "$cmd"
+	    $run eval "$cmd" || admincmds="$admincmds
+       $cmd"
+	  done
+	  IFS="$save_ifs"
+	fi
+	if test -n "$finish_eval"; then
+	  # Do the single finish_eval.
+	  eval cmds=\"$finish_eval\"
+	  $run eval "$cmds" || admincmds="$admincmds
+       $cmds"
+	fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    test "$show" = : && exit 0
+
+    echo "----------------------------------------------------------------------"
+    echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      echo "   $libdir"
+    done
+    echo
+    echo "If you ever happen to want to link against installed libraries"
+    echo "in a given directory, LIBDIR, you must either use libtool, and"
+    echo "specify the full pathname of the library, or use \`-LLIBDIR'"
+    echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      echo "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      echo "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    echo
+    echo "See any operating system documentation about shared libraries for"
+    echo "more information, such as the ld(1) and ld.so(8) manual pages."
+    echo "----------------------------------------------------------------------"
+    exit 0
+    ;;
+
+  # libtool execute mode
+  execute)
+    modename="$modename: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      $echo "$modename: you must specify a COMMAND" 1>&2
+      $echo "$help"
+      exit 1
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test ! -f "$file"; then
+	$echo "$modename: \`$file' is not a file" 1>&2
+	$echo "$help" 1>&2
+	exit 1
+      fi
+
+      dir=
+      case "$file" in
+      *.la)
+	# Check to see that this really is a libtool archive.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+	else
+	  $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+	  $echo "$help" 1>&2
+	  exit 1
+	fi
+
+	# Read the libtool library.
+	dlname=
+	library_names=
+
+	# If there is no directory component, then add one.
+	case "$file" in
+	*/* | *\\*) . $file ;;
+	*) . ./$file ;;
+	esac
+
+	# Skip this library if it cannot be dlopened.
+	if test -z "$dlname"; then
+	  # Warn if it was a shared library.
+	  test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+	  continue
+	fi
+
+	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+	test "X$dir" = "X$file" && dir=.
+
+	if test -f "$dir/$objdir/$dlname"; then
+	  dir="$dir/$objdir"
+	else
+	  $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+	  exit 1
+	fi
+	;;
+
+      *.lo)
+	# Just add the directory containing the .lo file.
+	dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+	test "X$dir" = "X$file" && dir=.
+	;;
+
+      *)
+	$echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+	continue
+	;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+	eval "$shlibpath_var=\"\$dir\""
+      else
+	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case "$file" in
+      -*) ;;
+      *)
+	# Do a test to see if this is really a libtool program.
+	if (sed -e '4q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  # If there is no directory component, then add one.
+	  case "$file" in
+	  */* | *\\*) . $file ;;
+	  *) . ./$file ;;
+	  esac
+
+	  # Transform arg to wrapped name.
+	  file="$progdir/$program"
+	fi
+	;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+      args="$args \"$file\""
+    done
+
+    if test -z "$run"; then
+      if test -n "$shlibpath_var"; then
+        # Export the shlibpath_var.
+        eval "export $shlibpath_var"
+      fi
+
+      # Restore saved enviroment variables
+      if test "${save_LC_ALL+set}" = set; then
+	LC_ALL="$save_LC_ALL"; export LC_ALL
+      fi
+      if test "${save_LANG+set}" = set; then
+	LANG="$save_LANG"; export LANG
+      fi
+
+      # Now actually exec the command.
+      eval "exec \$cmd$args"
+
+      $echo "$modename: cannot exec \$cmd$args"
+      exit 1
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+        eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+        $echo "export $shlibpath_var"
+      fi
+      $echo "$cmd$args"
+      exit 0
+    fi
+    ;;
+
+  # libtool uninstall mode
+  uninstall)
+    modename="$modename: uninstall"
+    rm="$nonopt"
+    files=
+
+    for arg
+    do
+      case "$arg" in
+      -*) rm="$rm $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    if test -z "$rm"; then
+      $echo "$modename: you must specify an RM program" 1>&2
+      $echo "$help" 1>&2
+      exit 1
+    fi
+
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$dir" = "X$file" && dir=.
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      rmfiles="$file"
+
+      case "$name" in
+      *.la)
+	# Possibly a libtool archive, so verify it.
+	if (sed -e '2q' $file | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+	  . $dir/$name
+
+	  # Delete the libtool libraries and symlinks.
+	  for n in $library_names; do
+	    rmfiles="$rmfiles $dir/$n"
+	  done
+	  test -n "$old_library" && rmfiles="$rmfiles $dir/$old_library"
+
+	  $show "$rm $rmfiles"
+	  $run $rm $rmfiles
+
+	  if test -n "$library_names"; then
+	    # Do each command in the postuninstall commands.
+	    eval cmds=\"$postuninstall_cmds\"
+	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      $show "$cmd"
+	      $run eval "$cmd"
+	    done
+	    IFS="$save_ifs"
+	  fi
+
+	  if test -n "$old_library"; then
+	    # Do each command in the old_postuninstall commands.
+	    eval cmds=\"$old_postuninstall_cmds\"
+	    IFS="${IFS= 	}"; save_ifs="$IFS"; IFS='~'
+	    for cmd in $cmds; do
+	      IFS="$save_ifs"
+	      $show "$cmd"
+	      $run eval "$cmd"
+	    done
+	    IFS="$save_ifs"
+	  fi
+
+	  # FIXME: should reinstall the best remaining shared library.
+	fi
+	;;
+
+      *.lo)
+	if test "$build_old_libs" = yes; then
+	  oldobj=`$echo "X$name" | $Xsed -e "$lo2o"`
+	  rmfiles="$rmfiles $dir/$oldobj"
+	fi
+	$show "$rm $rmfiles"
+	$run $rm $rmfiles
+	;;
+
+      *)
+	$show "$rm $rmfiles"
+	$run $rm $rmfiles
+	;;
+      esac
+    done
+    exit 0
+    ;;
+
+  "")
+    $echo "$modename: you must specify a MODE" 1>&2
+    $echo "$generic_help" 1>&2
+    exit 1
+    ;;
+  esac
+
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$generic_help" 1>&2
+  exit 1
+fi # test -z "$show_help"
+
+# We need to display help for each of the modes.
+case "$mode" in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+    --config          show all configuration variables
+    --debug           enable verbose shell tracing
+-n, --dry-run         display commands without modifying any files
+    --features        display basic configuration information and exit
+    --finish          same as \`--mode=finish'
+    --help            display this help message and exit
+    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
+    --quiet           same as \`--silent'
+    --silent          don't print informational messages
+    --version         print version information
+
+MODE must be one of the following:
+
+      compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
+      finish          complete the installation of libtool libraries
+      install         install libraries or executables
+      link            create a library or an executable
+      uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE."
+  exit 0
+  ;;
+
+compile)
+  $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -static           always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+  ;;
+
+execute)
+  $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+  ;;
+
+finish)
+  $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+  ;;
+
+install)
+  $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+  ;;
+
+link)
+  $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+		    try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+		    try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -static           do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+		    specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+  ;;
+
+uninstall)
+  $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+*)
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$help" 1>&2
+  exit 1
+  ;;
+esac
+
+echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit 0
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/missing	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+case "$1" in
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing - GNU libit 0.0"
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+  aclocal)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acinclude.m4' or \`configure.in'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`configure.in'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acconfig.h' or \`configure.in'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f y.tab.h ]; then
+	echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+    fi
+    touch $file
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequirements for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mkinstalldirs	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id$
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+  	  errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sdl-config.in	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+exec_prefix_set=no
+
+usage="\
+Usage: sdl-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--version] [--libs] [--cflags]"
+
+if test $# -eq 0; then
+      echo "${usage}" 1>&2
+      exit 1
+fi
+
+while test $# -gt 0; do
+  case "$1" in
+  -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  case $1 in
+    --prefix=*)
+      prefix=$optarg
+      if test $exec_prefix_set = no ; then
+        exec_prefix=$optarg
+      fi
+      ;;
+    --prefix)
+      echo $prefix
+      ;;
+    --exec-prefix=*)
+      exec_prefix=$optarg
+      exec_prefix_set=yes
+      ;;
+    --exec-prefix)
+      echo $exec_prefix
+      ;;
+    --version)
+      echo @SDL_VERSION@
+      ;;
+    --cflags)
+      if test @includedir@ != /usr/include ; then
+          # Handle oddities in Win32 path handling (assumes prefix)
+          prefix=`echo ${prefix} | sed 's,^//\([A-Z]\),\1:,'`
+
+          includes=-I@includedir@
+      fi
+      echo $includes -I@includedir@/SDL @SDL_CFLAGS@
+      ;;
+@ENABLE_SHARED_TRUE@    --libs)
+@ENABLE_SHARED_TRUE@      libdirs="-L@libdir@ @SDL_RLD_FLAGS@"
+@ENABLE_SHARED_TRUE@      echo $libdirs @SDL_LIBS@
+@ENABLE_SHARED_TRUE@      ;;
+@ENABLE_STATIC_TRUE@@ENABLE_SHARED_TRUE@    --static-libs)
+@ENABLE_STATIC_TRUE@@ENABLE_SHARED_FALSE@    --libs|--static-libs)
+@ENABLE_STATIC_TRUE@      libdirs="-L@libdir@ @SDL_RLD_FLAGS@"
+@ENABLE_STATIC_TRUE@      echo $libdirs @SDL_LIBS@ @SYSTEM_LIBS@
+@ENABLE_STATIC_TRUE@      ;;
+    *)
+      echo "${usage}" 1>&2
+      exit 1
+      ;;
+  esac
+  shift
+done
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/sdl.m4	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,168 @@
+# Configure paths for SDL
+# Sam Lantinga 9/21/99
+# stolen from Manish Singh
+# stolen back from Frank Belew
+# stolen from Manish Singh
+# Shamelessly stolen from Owen Taylor
+
+dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
+dnl
+AC_DEFUN(AM_PATH_SDL,
+[dnl 
+dnl Get the cflags and libraries from the sdl-config script
+dnl
+AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
+            sdl_prefix="$withval", sdl_prefix="")
+AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
+            sdl_exec_prefix="$withval", sdl_exec_prefix="")
+AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
+		    , enable_sdltest=yes)
+
+  if test x$sdl_exec_prefix != x ; then
+     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
+     if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+     fi
+  fi
+  if test x$sdl_prefix != x ; then
+     sdl_args="$sdl_args --prefix=$sdl_prefix"
+     if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_prefix/bin/sdl-config
+     fi
+  fi
+
+  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
+  min_sdl_version=ifelse([$1], ,0.11.0,$1)
+  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
+  no_sdl=""
+  if test "$SDL_CONFIG" = "no" ; then
+    no_sdl=yes
+  else
+    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
+    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
+
+    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+    if test "x$enable_sdltest" = "xyes" ; then
+      ac_save_CFLAGS="$CFLAGS"
+      ac_save_LIBS="$LIBS"
+      CFLAGS="$CFLAGS $SDL_CFLAGS"
+      LIBS="$LIBS $SDL_LIBS"
+dnl
+dnl Now check if the installed SDL is sufficiently new. (Also sanity
+dnl checks the results of sdl-config to some extent
+dnl
+      rm -f conf.sdltest
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+char*
+my_strdup (char *str)
+{
+  char *new_str;
+  
+  if (str)
+    {
+      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
+      strcpy (new_str, str);
+    }
+  else
+    new_str = NULL;
+  
+  return new_str;
+}
+
+int main (int argc, char *argv[])
+{
+  int major, minor, micro;
+  char *tmp_version;
+
+  /* This hangs on some systems (?)
+  system ("touch conf.sdltest");
+  */
+  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
+
+  /* HP/UX 9 (%@#!) writes to sscanf strings */
+  tmp_version = my_strdup("$min_sdl_version");
+  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+     printf("%s, bad version string\n", "$min_sdl_version");
+     exit(1);
+   }
+
+   if (($sdl_major_version > major) ||
+      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+    {
+      return 0;
+    }
+  else
+    {
+      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+      printf("*** best to upgrade to the required version.\n");
+      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+      printf("*** config.cache before re-running configure\n");
+      return 1;
+    }
+}
+
+],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+  fi
+  if test "x$no_sdl" = x ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$2], , :, [$2])     
+  else
+     AC_MSG_RESULT(no)
+     if test "$SDL_CONFIG" = "no" ; then
+       echo "*** The sdl-config script installed by SDL could not be found"
+       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+       echo "*** your path, or set the SDL_CONFIG environment variable to the"
+       echo "*** full path to sdl-config."
+     else
+       if test -f conf.sdltest ; then
+        :
+       else
+          echo "*** Could not run SDL test program, checking why..."
+          CFLAGS="$CFLAGS $SDL_CFLAGS"
+          LIBS="$LIBS $SDL_LIBS"
+          AC_TRY_LINK([
+#include <stdio.h>
+#include "SDL.h"
+],      [ return 0; ],
+        [ echo "*** The test program compiled, but did not run. This usually means"
+          echo "*** that the run-time linker is not finding SDL or finding the wrong"
+          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+          echo "*** is required on your system"
+	  echo "***"
+          echo "*** If you have an old version installed, it is best to remove it, although"
+          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+        [ echo "*** The test program failed to compile or link. See the file config.log for the"
+          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
+          CFLAGS="$ac_save_CFLAGS"
+          LIBS="$ac_save_LIBS"
+       fi
+     fi
+     SDL_CFLAGS=""
+     SDL_LIBS=""
+     ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(SDL_CFLAGS)
+  AC_SUBST(SDL_LIBS)
+  rm -f conf.sdltest
+])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+
+## Makefile.am for the main SDL library
+
+# These are the subdirectories that are always built
+CORE_SUBDIRS =			\
+	main
+
+# These are the subdirectories which may be built
+EXTRA_SUBDIRS =			\
+	 audio video events joystick cdrom thread timer endian file hermes
+
+# These are the subdirectories which will be built now
+SUBDIRS = $(CORE_SUBDIRS) @SDL_EXTRADIRS@
+
+# These are the subdirectories which will be distributed with "make dist"
+DIST_SUBDIRS = $(CORE_SUBDIRS) $(EXTRA_SUBDIRS)
+
+# The SDL library target
+lib_LTLIBRARIES = libSDL.la
+
+libSDL_la_SOURCES = $(GENERAL_SRCS)
+libSDL_la_LDFLAGS = 		\
+        -release $(LT_RELEASE)	\
+	-version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE)
+libSDL_la_LIBADD =		\
+	main/libarch.la		\
+	@SDL_EXTRALIBS@		\
+	@SYSTEM_LIBS@
+libSDL_la_DEPENDENCIES =	\
+	main/libarch.la		\
+	@SDL_EXTRALIBS@
+
+# The SDL library sources
+GENERAL_SRCS = 		\
+	SDL.c			\
+	SDL_error.c		\
+	SDL_error_c.h		\
+	SDL_fatal.c		\
+	SDL_fatal.h		\
+	SDL_getenv.c
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,233 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Initialization code for SDL */
+
+#include <stdlib.h>		/* For getenv() */
+
+#include "SDL.h"
+#include "SDL_endian.h"
+#include "SDL_fatal.h"
+#ifndef DISABLE_VIDEO
+#include "SDL_leaks.h"
+#endif
+
+/* Initialization/Cleanup routines */
+#ifndef DISABLE_JOYSTICK
+extern int  SDL_JoystickInit(void);
+extern void SDL_JoystickQuit(void);
+#endif
+#ifndef DISABLE_CDROM
+extern int  SDL_CDROMInit(void);
+extern void SDL_CDROMQuit(void);
+#endif
+#ifndef DISABLE_TIMERS
+extern void SDL_StartTicks(void);
+extern int  SDL_TimerInit(void);
+extern void SDL_TimerQuit(void);
+#endif
+
+/* The current SDL version */
+static SDL_version version = 
+	{ SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
+
+/* The initialized subsystems */
+static Uint32 SDL_initialized = 0;
+static Uint32 ticks_started = 0;
+
+#ifdef CHECK_LEAKS
+int surfaces_allocated = 0;
+#endif
+
+int SDL_InitSubSystem(Uint32 flags)
+{
+#ifndef DISABLE_VIDEO
+	/* Initialize the video/event subsystem */
+	if ( (flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO) ) {
+		if ( SDL_VideoInit(getenv("SDL_VIDEODRIVER"),
+		                   (flags&SDL_INIT_EVENTTHREAD)) < 0 ) {
+			return(-1);
+		}
+		SDL_initialized |= SDL_INIT_VIDEO;
+	}
+#else
+	if ( flags & SDL_INIT_VIDEO ) {
+		SDL_SetError("SDL not built with video support");
+		return(-1);
+	}
+#endif
+
+#ifndef DISABLE_AUDIO
+	/* Initialize the audio subsystem */
+	if ( (flags & SDL_INIT_AUDIO) && !(SDL_initialized & SDL_INIT_AUDIO) ) {
+		if ( SDL_AudioInit(getenv("SDL_AUDIODRIVER")) < 0 ) {
+			return(-1);
+		}
+		SDL_initialized |= SDL_INIT_AUDIO;
+	}
+#else
+	if ( flags & SDL_INIT_AUDIO ) {
+		SDL_SetError("SDL not built with audio support");
+		return(-1);
+	}
+#endif
+
+#ifndef DISABLE_TIMERS
+	/* Initialize the timer subsystem */
+	if ( ! ticks_started ) {
+		SDL_StartTicks();
+		ticks_started = 1;
+	}
+	if ( (flags & SDL_INIT_TIMER) && !(SDL_initialized & SDL_INIT_TIMER) ) {
+		if ( SDL_TimerInit() < 0 ) {
+			return(-1);
+		}
+		SDL_initialized |= SDL_INIT_TIMER;
+	}
+#else
+	if ( flags & SDL_INIT_TIMER ) {
+		SDL_SetError("SDL not built with timer support");
+		return(-1);
+	}
+#endif
+
+#ifndef DISABLE_JOYSTICK
+	/* Initialize the joystick subsystem */
+	if ( (flags & SDL_INIT_JOYSTICK) &&
+	     !(SDL_initialized & SDL_INIT_JOYSTICK) ) {
+		if ( SDL_JoystickInit() < 0 ) {
+			return(-1);
+		}
+		SDL_initialized |= SDL_INIT_JOYSTICK;
+	}
+#else
+	if ( flags & SDL_INIT_JOYSTICK ) {
+		SDL_SetError("SDL not built with joystick support");
+		return(-1);
+	}
+#endif
+
+#ifndef DISABLE_CDROM
+	/* Initialize the CD-ROM subsystem */
+	if ( (flags & SDL_INIT_CDROM) && !(SDL_initialized & SDL_INIT_CDROM) ) {
+		if ( SDL_CDROMInit() < 0 ) {
+			return(-1);
+		}
+		SDL_initialized |= SDL_INIT_CDROM;
+	}
+#else
+	if ( flags & SDL_INIT_CDROM ) {
+		SDL_SetError("SDL not built with cdrom support");
+		return(-1);
+	}
+#endif
+	return(0);
+}
+
+int SDL_Init(Uint32 flags)
+{
+	/* Clear the error message */
+	SDL_ClearError();
+
+	/* Initialize the desired subsystems */
+	if ( SDL_InitSubSystem(flags) < 0 ) {
+		return(-1);
+	}
+
+	/* Everything is initialized */
+	if ( !(flags & SDL_INIT_NOPARACHUTE) ) {
+		SDL_InstallParachute();
+	}
+	return(0);
+}
+
+void SDL_QuitSubSystem(Uint32 flags)
+{
+	/* Shut down requested initialized subsystems */
+#ifndef DISABLE_CDROM
+	if ( (flags & SDL_initialized & SDL_INIT_CDROM) ) {
+		SDL_CDROMQuit();
+		SDL_initialized &= ~SDL_INIT_CDROM;
+	}
+#endif
+#ifndef DISABLE_JOYSTICK
+	if ( (flags & SDL_initialized & SDL_INIT_JOYSTICK) ) {
+		SDL_JoystickQuit();
+		SDL_initialized &= ~SDL_INIT_JOYSTICK;
+	}
+#endif
+#ifndef DISABLE_TIMERS
+	if ( (flags & SDL_initialized & SDL_INIT_TIMER) ) {
+		SDL_TimerQuit();
+		SDL_initialized &= ~SDL_INIT_TIMER;
+	}
+#endif
+#ifndef DISABLE_AUDIO
+	if ( (flags & SDL_initialized & SDL_INIT_AUDIO) ) {
+		SDL_AudioQuit();
+		SDL_initialized &= ~SDL_INIT_AUDIO;
+	}
+#endif
+#ifndef DISABLE_VIDEO
+	if ( (flags & SDL_initialized & SDL_INIT_VIDEO) ) {
+		SDL_VideoQuit();
+		SDL_initialized &= ~SDL_INIT_VIDEO;
+	}
+#endif
+}
+
+Uint32 SDL_WasInit(Uint32 flags)
+{
+	if ( ! flags ) {
+		flags = SDL_INIT_EVERYTHING;
+	}
+	return (SDL_initialized&flags);
+}
+
+void SDL_Quit(void)
+{
+	/* Quit all subsystems */
+	SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
+
+#ifdef CHECK_LEAKS
+	/* Print the number of surfaces not freed */
+	if ( surfaces_allocated != 0 ) {
+		fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", 
+							surfaces_allocated);
+	}
+#endif
+
+	/* Uninstall any parachute signal handlers */
+	SDL_UninstallParachute();
+}
+
+/* Return the library version number */
+const SDL_version * SDL_Linked_Version(void)
+{
+	return(&version);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_error.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,340 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Simple error handling in SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+
+#include "SDL_types.h"
+#include "SDL_getenv.h"
+#include "SDL_error.h"
+#include "SDL_error_c.h"
+#ifndef DISABLE_THREADS
+#include "SDL_thread_c.h"
+#endif
+
+#ifdef DISABLE_THREADS
+/* The default (non-thread-safe) global error variable */
+static SDL_error SDL_global_error;
+
+#define SDL_GetErrBuf()	(&SDL_global_error)
+#endif /* DISABLE_THREADS */
+
+#define SDL_ERRBUFIZE	1024
+
+/* Private functions */
+
+static void SDL_LookupString(const Uint8 *key, Uint16 *buf, int buflen)
+{
+	/* FIXME: Add code to lookup key in language string hash-table */
+
+	/* Key not found in language string hash-table */
+	while ( *key && (--buflen > 0) ) {
+		*buf++ = *key++;
+	}
+	*buf = 0;	/* NULL terminate string */
+}
+
+/* Public functions */
+
+void SDL_SetError (const char *fmt, ...)
+{
+	va_list ap;
+	SDL_error *error;
+
+	/* Copy in the key, mark error as valid */
+	error = SDL_GetErrBuf();
+	error->error = 1;
+	strncpy((char *)error->key, fmt, sizeof(error->key));
+	error->key[sizeof(error->key)-1] = '\0';
+
+	va_start(ap, fmt);
+	error->argc = 0;
+	while ( *fmt ) {
+		if ( *fmt++ == '%' ) {
+			switch (*fmt++) {
+			    case 0:  /* Malformed format string.. */
+				--fmt;
+				break;
+#if 0	/* What is a character anyway?  (UNICODE issues) */
+			    case 'c':
+				error->args[error->argc++].value_c =
+						va_arg(ap, unsigned char);
+				break;
+#endif
+			    case 'd':
+				error->args[error->argc++].value_i =
+							va_arg(ap, int);
+				break;
+			    case 'f':
+				error->args[error->argc++].value_f =
+							va_arg(ap, double);
+				break;
+			    case 'p':
+				error->args[error->argc++].value_ptr =
+							va_arg(ap, void *);
+				break;
+			    case 's':
+				{
+				  int index = error->argc;
+				  strncpy((char *)error->args[index].buf,
+					va_arg(ap, char *), ERR_MAX_STRLEN);
+				  error->args[index].buf[ERR_MAX_STRLEN-1] = 0;
+				  error->argc++;
+				}
+				break;
+			    default:
+				break;
+			}
+			if ( error->argc >= ERR_MAX_ARGS ) {
+				break;
+			}
+		}
+	}
+	va_end(ap);
+
+	/* If we are in debug mode, print out an error message */
+#ifdef DEBUG_ERROR
+	fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
+#else
+	if ( getenv("SDL_DEBUG") ) {
+		fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError());
+	}
+#endif
+}
+
+/* Print out an integer value to a UNICODE buffer */
+static int PrintInt(Uint16 *str, unsigned int maxlen, int value)
+{
+	char tmp[128];
+	int len, i;
+
+	sprintf(tmp, "%d", value);
+	len = 0;
+	if ( strlen(tmp) < maxlen ) {
+		for ( i=0; tmp[i]; ++i ) {
+			*str++ = tmp[i];
+			++len;
+		}
+	}
+	return(len);
+}
+/* Print out a double value to a UNICODE buffer */
+static int PrintDouble(Uint16 *str, unsigned int maxlen, double value)
+{
+	char tmp[128];
+	int len, i;
+
+	sprintf(tmp, "%f", value);
+	len = 0;
+	if ( strlen(tmp) < maxlen ) {
+		for ( i=0; tmp[i]; ++i ) {
+			*str++ = tmp[i];
+			++len;
+		}
+	}
+	return(len);
+}
+/* Print out a pointer value to a UNICODE buffer */
+static int PrintPointer(Uint16 *str, unsigned int maxlen, void *value)
+{
+	char tmp[128];
+	int len, i;
+
+	sprintf(tmp, "%p", value);
+	len = 0;
+	if ( strlen(tmp) < maxlen ) {
+		for ( i=0; tmp[i]; ++i ) {
+			*str++ = tmp[i];
+			++len;
+		}
+	}
+	return(len);
+}
+
+/* This function has a bit more overhead than most error functions
+   so that it supports internationalization and thread-safe errors.
+*/
+Uint16 *SDL_GetErrorMsgUNICODE(Uint16 *errstr, unsigned int maxlen)
+{
+	SDL_error *error;
+
+	/* Clear the error string */
+	*errstr = 0; --maxlen;
+
+	/* Get the thread-safe error, and print it out */
+	error = SDL_GetErrBuf();
+	if ( error->error ) {
+		Uint16 translated[ERR_MAX_STRLEN], *fmt, *msg;
+		int len;
+		int argi;
+
+		/* Print out the UNICODE error message */
+		SDL_LookupString(error->key, translated, sizeof(translated));
+		msg = errstr;
+		argi = 0;
+		for ( fmt=translated; *fmt && (maxlen > 0); ) {
+			if ( *fmt == '%' ) {
+				switch (fmt[1]) {
+				    case 'S':	/* Special SKIP operand */
+					argi += (fmt[2] - '0');
+					++fmt;
+					break;
+				    case '%':
+					*msg++ = '%';
+					maxlen -= 1;
+					break;
+#if 0	/* What is a character anyway?  (UNICODE issues) */
+				    case 'c':
+                                        *msg++ = (unsigned char)
+					         error->args[argi++].value_c;
+					maxlen -= 1;
+					break;
+#endif
+				    case 'd':
+					len = PrintInt(msg, maxlen,
+						error->args[argi++].value_i);
+					msg += len;
+					maxlen -= len;
+					break;
+				    case 'f':
+					len = PrintDouble(msg, maxlen,
+						error->args[argi++].value_f);
+					msg += len;
+					maxlen -= len;
+					break;
+				    case 'p':
+					len = PrintPointer(msg, maxlen,
+						error->args[argi++].value_ptr);
+					msg += len;
+					maxlen -= len;
+					break;
+				    case 's': /* UNICODE string */
+					{ Uint16 buf[ERR_MAX_STRLEN], *str;
+					  SDL_LookupString(error->args[argi++].buf, buf, sizeof(buf));
+					  str = buf;
+					  while ( *str && (maxlen > 0) ) {
+						*msg++ = *str++;
+						maxlen -= 1;
+					  }
+					}
+					break;
+				}
+				fmt += 2;
+			} else {
+				*msg++ = *fmt++;
+				maxlen -= 1;
+			}
+		}
+		*msg = 0;	/* NULL terminate the string */
+	}
+	return(errstr);
+}
+
+Uint8 *SDL_GetErrorMsg(Uint8 *errstr, unsigned int maxlen)
+{
+	Uint16 *errstr16;
+	unsigned int i;
+
+	/* Allocate the UNICODE buffer */
+	errstr16 = (Uint16 *)malloc(maxlen * (sizeof *errstr16));
+	if ( ! errstr16 ) {
+		strncpy((char *)errstr, "Out of memory", maxlen);
+		errstr[maxlen-1] = '\0';
+		return(errstr);
+	}
+
+	/* Get the error message */
+	SDL_GetErrorMsgUNICODE(errstr16, maxlen);
+
+	/* Convert from UNICODE to Latin1 encoding */
+	for ( i=0; i<maxlen; ++i ) {
+		errstr[i] = (Uint8)errstr16[i];
+	}
+
+	/* Free UNICODE buffer (if necessary) */
+	free(errstr16);
+
+	return(errstr);
+}
+
+/* Available for backwards compatibility */
+char *SDL_GetError (void)
+{
+	static char errmsg[SDL_ERRBUFIZE];
+
+	return((char *)SDL_GetErrorMsg((unsigned char *)errmsg, SDL_ERRBUFIZE));
+}
+
+void SDL_ClearError(void)
+{
+	SDL_error *error;
+
+	error = SDL_GetErrBuf();
+	error->error = 0;
+}
+
+/* Very common errors go here */
+void SDL_Error(SDL_errorcode code)
+{
+	switch (code) {
+		case SDL_ENOMEM:
+			SDL_SetError("Out of memory");
+			break;
+		case SDL_EFREAD:
+			SDL_SetError("Error reading from datastream");
+			break;
+		case SDL_EFWRITE:
+			SDL_SetError("Error writing to datastream");
+			break;
+		case SDL_EFSEEK:
+			SDL_SetError("Error seeking in datastream");
+			break;
+		default:
+			SDL_SetError("Unknown SDL error");
+			break;
+	}
+}
+
+#ifdef TEST_ERROR
+int main(int argc, char *argv[])
+{
+	char buffer[BUFSIZ+1];
+
+	SDL_SetError("Hi there!");
+	printf("Error 1: %s\n", SDL_GetError());
+	SDL_ClearError();
+	memset(buffer, '1', BUFSIZ);
+	buffer[BUFSIZ] = 0;
+	SDL_SetError("This is the error: %s (%f)", buffer, 1.0);
+	printf("Error 2: %s\n", SDL_GetError());
+	exit(0);
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_error_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,62 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This file defines a structure that carries language-independent
+   error messages
+*/
+
+#ifndef _SDL_error_c_h
+#define _SDL_error_c_h
+
+#define ERR_MAX_STRLEN	128
+#define ERR_MAX_ARGS	5
+
+typedef struct {
+	/* This is a numeric value corresponding to the current error */
+	int error;
+
+	/* This is a key used to index into a language hashtable containing
+	   internationalized versions of the SDL error messages.  If the key
+	   is not in the hashtable, or no hashtable is available, the key is
+	   used directly as an error message format string.
+	*/
+	unsigned char key[ERR_MAX_STRLEN];
+
+	/* These are the arguments for the error functions */
+	int argc;
+	union {
+		void *value_ptr;
+#if 0	/* What is a character anyway?  (UNICODE issues) */
+		unsigned char value_c;
+#endif
+		int value_i;
+		double value_f;
+		unsigned char buf[ERR_MAX_STRLEN];
+	} args[ERR_MAX_ARGS];
+} SDL_error;
+
+#endif /* _SDL_error_c_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_fatal.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,160 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General fatal signal handling code for SDL */
+
+#ifdef NO_SIGNAL_H
+
+/* No signals on this platform, nothing to do.. */
+
+void SDL_InstallParachute(void)
+{
+	return;
+}
+
+void SDL_UninstallParachute(void)
+{
+	return;
+}
+
+#else
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_fatal.h"
+
+/* This installs some signal handlers for the more common fatal signals,
+   so that if the programmer is lazy, the app doesn't die so horribly if
+   the program crashes.
+*/
+
+static void SDL_Parachute(int sig)
+{
+	signal(sig, SIG_DFL);
+	fprintf(stderr, "Fatal signal: ");
+	switch (sig) {
+		case SIGSEGV:
+			fprintf(stderr, "Segmentation Fault");
+			break;
+#ifdef SIGBUS
+#if SIGBUS != SIGSEGV
+		case SIGBUS:
+			fprintf(stderr, "Bus Error");
+			break;
+#endif
+#endif /* SIGBUS */
+#ifdef SIGFPE
+		case SIGFPE:
+			fprintf(stderr, "Floating Point Exception");
+			break;
+#endif /* SIGFPE */
+#ifdef SIGQUIT
+		case SIGQUIT:
+			fprintf(stderr, "Keyboard Quit");
+			break;
+#endif /* SIGQUIT */
+#ifdef SIGPIPE
+		case SIGPIPE:
+			fprintf(stderr, "Broken Pipe");
+			break;
+#endif /* SIGPIPE */
+		default:
+			fprintf(stderr, "# %d", sig);
+			break;
+	}
+	fprintf(stderr, " (SDL Parachute Deployed)\n");
+	SDL_Quit();
+	exit(-sig);
+}
+
+static int SDL_fatal_signals[] = {
+	SIGSEGV,
+#ifdef SIGBUS
+	SIGBUS,
+#endif
+#ifdef SIGFPE
+	SIGFPE,
+#endif
+#ifdef SIGQUIT
+	SIGQUIT,
+#endif
+#ifdef SIGPIPE
+	SIGPIPE,
+#endif
+	0
+};
+
+void SDL_InstallParachute(void)
+{
+	int i;
+	void (*ohandler)(int);
+
+	/* Set a handler for any fatal signal not already handled */
+	for ( i=0; SDL_fatal_signals[i]; ++i ) {
+		ohandler = signal(SDL_fatal_signals[i], SDL_Parachute);
+		if ( ohandler != SIG_DFL ) {
+			signal(SDL_fatal_signals[i], ohandler);
+		}
+	}
+#ifdef SIGALRM
+	/* Set SIGALRM to be ignored -- necessary on Solaris */
+	{
+		struct sigaction action, oaction;
+
+		/* Set SIG_IGN action */
+		memset(&action, 0, (sizeof action));
+		action.sa_handler = SIG_IGN;
+		sigaction(SIGALRM, &action, &oaction);
+
+		/* Reset original action if it was already being handled */
+		if ( oaction.sa_handler != SIG_DFL ) {
+			sigaction(SIGALRM, &oaction, NULL);
+		}
+	}
+#endif
+	return;
+}
+
+void SDL_UninstallParachute(void)
+{
+	int i;
+	void (*ohandler)(int);
+
+	/* Remove a handler for any fatal signal handled */
+	for ( i=0; SDL_fatal_signals[i]; ++i ) {
+		ohandler = signal(SDL_fatal_signals[i], SIG_DFL);
+		if ( ohandler != SDL_Parachute ) {
+			signal(SDL_fatal_signals[i], ohandler);
+		}
+	}
+}
+
+#endif /* NO_SIGNAL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_fatal.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General fatal signal handling code for SDL */
+
+extern void SDL_InstallParachute(void);
+extern void SDL_UninstallParachute(void);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/SDL_getenv.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,171 @@
+
+/* Not all environments have a working getenv()/putenv() */
+
+#ifdef TEST_MAIN
+#define NEED_SDL_GETENV
+#endif
+
+#include "SDL_getenv.h"
+
+#ifdef NEED_SDL_GETENV
+
+#include <stdlib.h>
+#include <string.h>
+
+static char **SDL_env = (char **)0;
+
+/* Put a variable of the form "name=value" into the environment */
+int SDL_putenv(const char *variable)
+{
+	const char *name, *value;
+	int added;
+	int len, i;
+	char **new_env;
+	char *new_variable;
+
+	/* A little error checking */
+	if ( ! variable ) {
+		return(-1);
+	}
+	name = variable;
+	for ( value=variable; *value && (*value != '='); ++value ) {
+		/* Keep looking for '=' */ ;
+	}
+	if ( *value ) {
+		++value;
+	} else {
+		return(-1);
+	}
+
+	/* Allocate memory for the variable */
+	new_variable = (char *)malloc(strlen(variable)+1);
+	if ( ! new_variable ) {
+		return(-1);
+	}
+	strcpy(new_variable, variable);
+
+	/* Actually put it into the environment */
+	added = 0;
+	i = 0;
+	if ( SDL_env ) {
+		/* Check to see if it's already there... */
+		len = (value - name);
+		for ( ; SDL_env[i]; ++i ) {
+			if ( strncmp(SDL_env[i], name, len) == 0 ) {
+				break;
+			}
+		}
+		/* If we found it, just replace the entry */
+		if ( SDL_env[i] ) {
+			free(SDL_env[i]);
+			SDL_env[i] = new_variable;
+			added = 1;
+		}
+	}
+
+	/* Didn't find it in the environment, expand and add */
+	if ( ! added ) {
+		new_env = realloc(SDL_env, (i+2)*sizeof(char *));
+		if ( new_env ) {
+			SDL_env = new_env;
+			SDL_env[i++] = new_variable;
+			SDL_env[i++] = (char *)0;
+			added = 1;
+		} else {
+			free(new_variable);
+		}
+	}
+	return (added ? 0 : -1);
+}
+
+/* Retrieve a variable named "name" from the environment */
+char *SDL_getenv(const char *name)
+{
+	int len, i;
+	char *value;
+
+	value = (char *)0;
+	if ( SDL_env ) {
+		len = strlen(name);
+		for ( i=0; SDL_env[i] && !value; ++i ) {
+			if ( (strncmp(SDL_env[i], name, len) == 0) &&
+			     (SDL_env[i][len] == '=') ) {
+				value = &SDL_env[i][len+1];
+			}
+		}
+	}
+	return value;
+}
+
+#endif /* NEED_GETENV */
+
+#ifdef TEST_MAIN
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+	char *value;
+
+	printf("Checking for non-existent variable... ");
+	fflush(stdout);
+	if ( ! getenv("EXISTS") ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Setting FIRST=VALUE1 in the environment... ");
+	fflush(stdout);
+	if ( putenv("FIRST=VALUE1") == 0 ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Getting FIRST from the environment... ");
+	fflush(stdout);
+	value = getenv("FIRST");
+	if ( value && (strcmp(value, "VALUE1") == 0) ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Setting SECOND=VALUE2 in the environment... ");
+	fflush(stdout);
+	if ( putenv("SECOND=VALUE2") == 0 ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Getting SECOND from the environment... ");
+	fflush(stdout);
+	value = getenv("SECOND");
+	if ( value && (strcmp(value, "VALUE2") == 0) ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Setting FIRST=NOVALUE in the environment... ");
+	fflush(stdout);
+	if ( putenv("FIRST=NOVALUE") == 0 ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Getting FIRST from the environment... ");
+	fflush(stdout);
+	value = getenv("FIRST");
+	if ( value && (strcmp(value, "NOVALUE") == 0) ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	printf("Checking for non-existent variable... ");
+	fflush(stdout);
+	if ( ! getenv("EXISTS") ) {
+		printf("okay\n");
+	} else {
+		printf("failed\n");
+	}
+	return(0);
+}
+#endif /* TEST_MAIN */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,29 @@
+
+## Makefile.am for the SDL audio library
+
+noinst_LTLIBRARIES = libaudio.la
+
+# Define which subdirectories need to be built
+SUBDIRS = @AUDIO_SUBDIRS@
+DIST_SUBDIRS = alsa arts baudio dma dmedia dsp esd macrom nas nto \
+               paudio sun ums windib windx5
+
+DRIVERS = @AUDIO_DRIVERS@
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_audio.c		\
+	SDL_audio_c.h		\
+	SDL_audiocvt.c		\
+	SDL_audiodev.c		\
+	SDL_audiodev_c.h	\
+	SDL_audiomem.c		\
+	SDL_audiomem.h		\
+	SDL_mixer.c		\
+	SDL_sysaudio.h		\
+	SDL_wave.c		\
+	SDL_wave.h
+
+libaudio_la_SOURCES = $(COMMON_SRCS)
+libaudio_la_LIBADD = $(DRIVERS)
+libaudio_la_DEPENDENCIES = $(DRIVERS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,516 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_audio.h"
+#include "SDL_timer.h"
+#include "SDL_error.h"
+#include "SDL_audio_c.h"
+#include "SDL_audiomem.h"
+#include "SDL_sysaudio.h"
+
+/* Available audio drivers */
+static AudioBootStrap *bootstrap[] = {
+#if defined(unix) && \
+   !defined(linux) && !defined(__FreeBSD__) && !defined(__CYGWIN32__) \
+   && !defined(__bsdi__)
+	&AUDIO_bootstrap,
+#endif
+#ifdef OSS_SUPPORT
+	&DSP_bootstrap,
+	&DMA_bootstrap,
+#endif
+#ifdef ALSA_SUPPORT
+	&ALSA_bootstrap,
+#endif
+#ifdef ARTSC_SUPPORT
+	&ARTSC_bootstrap,
+#endif
+#ifdef ESD_SUPPORT
+	&ESD_bootstrap,
+#endif
+#ifdef NAS_SUPPORT
+	&NAS_bootstrap,
+#endif
+#ifdef ENABLE_DIRECTX
+	&DSOUND_bootstrap,
+#endif
+#ifdef ENABLE_WINDIB
+	&WAVEOUT_bootstrap,
+#endif
+#ifdef __BEOS__
+	&BAUDIO_bootstrap,
+#endif
+#if defined(macintosh) || TARGET_API_MAC_CARBON
+	&SNDMGR_bootstrap,
+#endif
+#ifdef _AIX
+	&Paud_bootstrap,
+#endif
+	NULL
+};
+SDL_AudioDevice *current_audio = NULL;
+
+/* Various local functions */
+int SDL_AudioInit(const char *driver_name);
+void SDL_AudioQuit(void);
+
+
+/* The general mixing thread function */
+int SDL_RunAudio(void *audiop)
+{
+	SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
+	Uint8 *stream;
+	int    stream_len;
+	void  *udata;
+	void (*fill)(void *userdata,Uint8 *stream, int len);
+	int    silence;
+
+	/* Perform any thread setup */
+	if ( audio->ThreadInit ) {
+		audio->ThreadInit(audio);
+	}
+	audio->threadid = SDL_ThreadID();
+
+	/* Set up the mixing function */
+	fill  = audio->spec.callback;
+	udata = audio->spec.userdata;
+	if ( audio->convert.needed ) {
+		if ( audio->convert.src_format == AUDIO_U8 ) {
+			silence = 0x80;
+		} else {
+			silence = 0;
+		}
+		stream_len = audio->convert.len;
+	} else {
+		silence = audio->spec.silence;
+		stream_len = audio->spec.size;
+	}
+	stream = audio->fake_stream;
+
+	/* 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 {
+			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 {
+				continue;
+			}
+		} else {
+			stream = audio->GetAudioBuf(audio);
+			if ( stream == NULL ) {
+				stream = audio->fake_stream;
+			}
+		}
+		memset(stream, silence, stream_len);
+
+		if ( ! audio->paused ) {
+			SDL_mutexP(audio->mixer_lock);
+			(*fill)(udata, stream, stream_len);
+			SDL_mutexV(audio->mixer_lock);
+		}
+
+		/* Convert the audio if necessary */
+		if ( audio->convert.needed ) {
+			SDL_ConvertAudio(&audio->convert);
+			stream = audio->GetAudioBuf(audio);
+			if ( stream == NULL ) {
+				stream = audio->fake_stream;
+			}
+			memcpy(stream, audio->convert.buf,
+			               audio->convert.len_cvt);
+		}
+
+		/* Ready current buffer for play and change current buffer */
+		if ( stream != audio->fake_stream ) {
+			audio->PlayAudio(audio);
+		}
+	}
+	/* Wait for the audio to drain.. */
+	if ( audio->WaitDone ) {
+		audio->WaitDone(audio);
+	}
+	return(0);
+}
+
+int SDL_AudioInit(const char *driver_name)
+{
+	SDL_AudioDevice *audio;
+	int i = 0, idx;
+
+	/* Check to make sure we don't overwrite 'current_audio' */
+	if ( current_audio != NULL ) {
+		SDL_AudioQuit();
+	}
+
+	/* Select the proper audio driver */
+	audio = NULL;
+	idx = 0;
+#ifdef unix
+	if ( (driver_name == NULL) && (getenv("ESPEAKER") != NULL) ) {
+		/* Ahem, we know that if ESPEAKER is set, user probably wants
+		   to use ESD, but don't start it if it's not already running.
+		   This probably isn't the place to do this, but... Shh! :)
+		 */
+		for ( i=0; bootstrap[i]; ++i ) {
+			if ( strcmp(bootstrap[i]->name, "esd") == 0 ) {
+				const char *esd_no_spawn;
+
+				/* Don't start ESD if it's not running */
+				esd_no_spawn = getenv("ESD_NO_SPAWN");
+				if ( esd_no_spawn == NULL ) {
+					putenv("ESD_NO_SPAWN=1");
+				}
+				if ( bootstrap[i]->available() ) {
+					audio = bootstrap[i]->create(0);
+					break;
+				}
+#ifdef linux	/* No unsetenv() on most platforms */
+				if ( esd_no_spawn == NULL ) {
+					unsetenv("ESD_NO_SPAWN");
+				}
+#endif
+			}
+		}
+	}
+#endif /* unix */
+	if ( audio == NULL ) {
+		if ( driver_name != NULL ) {
+#if 0	/* This will be replaced with a better driver selection API */
+			if ( strrchr(driver_name, ':') != NULL ) {
+				idx = atoi(strrchr(driver_name, ':')+1);
+			}
+#endif
+			for ( i=0; bootstrap[i]; ++i ) {
+				if (strncmp(bootstrap[i]->name, driver_name,
+				            strlen(bootstrap[i]->name)) == 0) {
+					if ( bootstrap[i]->available() ) {
+						audio=bootstrap[i]->create(idx);
+						break;
+					}
+				}
+			}
+		} else {
+			for ( i=0; bootstrap[i]; ++i ) {
+				if ( bootstrap[i]->available() ) {
+					audio = bootstrap[i]->create(idx);
+					if ( audio != NULL ) {
+						break;
+					}
+				}
+			}
+		}
+		if ( audio == NULL ) {
+			SDL_SetError("No available audio device");
+#if 0 /* Don't fail SDL_Init() if audio isn't available.
+         SDL_OpenAudio() will handle it at that point.  *sigh*
+       */
+			return(-1);
+#endif
+		}
+	}
+	current_audio = audio;
+	if ( current_audio ) {
+		current_audio->name = bootstrap[i]->name;
+	}
+	return(0);
+}
+
+char *SDL_AudioDriverName(char *namebuf, int maxlen)
+{
+	if ( current_audio != NULL ) {
+		strncpy(namebuf, current_audio->name, maxlen-1);
+		namebuf[maxlen-1] = '\0';
+		return(namebuf);
+	}
+	return(NULL);
+}
+
+int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
+{
+	SDL_AudioDevice *audio;
+
+	/* Start up the audio driver, if necessary */
+	if ( ! current_audio ) {
+		if ( (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) ||
+		     (current_audio == NULL) ) {
+			return(-1);
+		}
+	}
+	audio = current_audio;
+
+	/* Verify some parameters */
+	if ( desired->callback == NULL ) {
+		SDL_SetError("SDL_OpenAudio() passed a NULL callback");
+		return(-1);
+	}
+	switch ( desired->channels ) {
+	    case 1:	/* Mono */
+	    case 2:	/* Stereo */
+		break;
+	    default:
+		SDL_SetError("1 (mono) and 2 (stereo) channels supported");
+		return(-1);
+	}
+
+#ifdef macintosh
+	/* FIXME: Need to implement PPC interrupt asm for SDL_LockAudio() */
+#else
+	/* Create a semaphore for locking the sound buffers */
+	audio->mixer_lock = SDL_CreateMutex();
+	if ( audio->mixer_lock == NULL ) {
+		SDL_SetError("Couldn't create mixer lock");
+		SDL_CloseAudio();
+		return(-1);
+	}
+#endif
+
+	/* Calculate the silence and size of the audio specification */
+	SDL_CalculateAudioSpec(desired);
+
+	/* Open the audio subsystem */
+	memcpy(&audio->spec, desired, sizeof(audio->spec));
+	audio->convert.needed = 0;
+	audio->enabled = 1;
+	audio->paused  = 1;
+	audio->opened = audio->OpenAudio(audio, &audio->spec)+1;
+	if ( ! audio->opened ) {
+		SDL_CloseAudio();
+		return(-1);
+	}
+
+	/* If the audio driver changes the buffer size, accept it */
+	if ( audio->spec.samples != desired->samples ) {
+		desired->samples = audio->spec.samples;
+		SDL_CalculateAudioSpec(desired);
+	}
+
+	/* Allocate a fake audio memory buffer */
+	audio->fake_stream = SDL_AllocAudioMem(audio->spec.size);
+	if ( audio->fake_stream == NULL ) {
+		SDL_CloseAudio();
+		SDL_OutOfMemory();
+		return(-1);
+	}
+
+	/* See if we need to do any conversion */
+	if ( memcmp(desired, &audio->spec, sizeof(audio->spec)) == 0 ) {
+		/* Just copy over the desired audio specification */
+		if ( obtained != NULL ) {
+			memcpy(obtained, &audio->spec, sizeof(audio->spec));
+		}
+	} else {
+		/* Copy over the audio specification if possible */
+		if ( obtained != NULL ) {
+			memcpy(obtained, &audio->spec, sizeof(audio->spec));
+		} else {
+			/* Build an audio conversion block */
+			if ( SDL_BuildAudioCVT(&audio->convert,
+				desired->format, desired->channels,
+						desired->freq,
+				audio->spec.format, audio->spec.channels,
+						audio->spec.freq) < 0 ) {
+				SDL_CloseAudio();
+				return(-1);
+			}
+			if ( audio->convert.needed ) {
+				audio->convert.len = desired->size;
+				audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
+				   audio->convert.len*audio->convert.len_mult);
+				if ( audio->convert.buf == NULL ) {
+					SDL_CloseAudio();
+					SDL_OutOfMemory();
+					return(-1);
+				}
+			}
+		}
+	}
+
+	/* Start the audio thread if necessary */
+	switch (audio->opened) {
+		case  1:
+			/* Start the audio thread */
+			audio->thread = SDL_CreateThread(SDL_RunAudio, audio);
+			if ( audio->thread == NULL ) {
+				SDL_CloseAudio();
+				SDL_SetError("Couldn't create audio thread");
+				return(-1);
+			}
+			break;
+
+		default:
+			/* The audio is now playing */
+			break;
+	}
+	return(0);
+}
+
+SDL_audiostatus SDL_GetAudioStatus(void)
+{
+	SDL_AudioDevice *audio = current_audio;
+	SDL_audiostatus status;
+
+	status = SDL_AUDIO_STOPPED;
+	if ( audio && audio->enabled ) {
+		if ( audio->paused ) {
+			status = SDL_AUDIO_PAUSED;
+		} else {
+			status = SDL_AUDIO_PLAYING;
+		}
+	}
+	return(status);
+}
+
+void SDL_PauseAudio (int pause_on)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	if ( audio ) {
+		audio->paused = pause_on;
+	}
+}
+
+void SDL_LockAudio (void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	/* Obtain a lock on the mixing buffers */
+	if ( audio ) {
+		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+			return;
+		}
+		SDL_mutexP(audio->mixer_lock);
+	}
+}
+
+void SDL_UnlockAudio (void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	/* Release lock on the mixing buffers */
+	if ( audio ) {
+		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+			return;
+		}
+		SDL_mutexV(audio->mixer_lock);
+	}
+}
+
+void SDL_CloseAudio (void)
+{
+	SDL_QuitSubSystem(SDL_INIT_AUDIO);
+}
+
+void SDL_AudioQuit(void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	if ( audio ) {
+		audio->enabled = 0;
+		if ( audio->thread != NULL ) {
+			SDL_WaitThread(audio->thread, NULL);
+		}
+		if ( audio->mixer_lock != NULL ) {
+			SDL_DestroyMutex(audio->mixer_lock);
+		}
+		if ( audio->fake_stream != NULL ) {
+			SDL_FreeAudioMem(audio->fake_stream);
+		}
+		if ( audio->convert.needed ) {
+			SDL_FreeAudioMem(audio->convert.buf);
+		}
+		if ( audio->opened ) {
+			audio->CloseAudio(audio);
+			audio->opened = 0;
+		}
+
+		/* Free the driver data */
+		audio->free(audio);
+		current_audio = NULL;
+	}
+}
+
+#define NUM_FORMATS	6
+static int format_idx;
+static int format_idx_sub;
+static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
+ { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
+ { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
+ { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
+};
+
+Uint16 SDL_FirstAudioFormat(Uint16 format)
+{
+	for ( format_idx=0; format_idx < NUM_FORMATS; ++format_idx ) {
+		if ( format_list[format_idx][0] == format ) {
+			break;
+		}
+	}
+	format_idx_sub = 0;
+	return(SDL_NextAudioFormat());
+}
+
+Uint16 SDL_NextAudioFormat(void)
+{
+	if ( (format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS) ) {
+		return(0);
+	}
+	return(format_list[format_idx][format_idx_sub++]);
+}
+
+void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
+{
+	switch (spec->format) {
+		case AUDIO_U8:
+			spec->silence = 0x80;
+			break;
+		default:
+			spec->silence = 0x00;
+			break;
+	}
+	spec->size = (spec->format&0xFF)/8;
+	spec->size *= spec->channels;
+	spec->size *= spec->samples;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audio_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions and variables exported from SDL_audio.c for SDL_sysaudio.c */
+
+/* Functions to get a list of "close" audio formats */
+extern Uint16 SDL_FirstAudioFormat(Uint16 format);
+extern Uint16 SDL_NextAudioFormat(void);
+
+/* Function to calculate the size and silence for a SDL_AudioSpec */
+extern void SDL_CalculateAudioSpec(SDL_AudioSpec *spec);
+
+/* The actual mixing thread function */
+extern int SDL_RunAudio(void *audiop);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audiocvt.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,642 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for audio drivers to perform runtime conversion of audio format */
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_audio.h"
+
+
+/* Effectively mix right and left channels into a single channel */
+void SDL_ConvertMono(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Sint32 sample;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting to mono\n");
+#endif
+	switch (format&0x8018) {
+
+		case AUDIO_U8: {
+			Uint8 *src, *dst;
+
+			src = cvt->buf;
+			dst = cvt->buf;
+			for ( i=cvt->len_cvt/2; i; --i ) {
+				sample = src[0] + src[1];
+				if ( sample > 255 ) {
+					*dst = 255;
+				} else {
+					*dst = sample;
+				}
+				src += 2;
+				dst += 1;
+			}
+		}
+		break;
+
+		case AUDIO_S8: {
+			Sint8 *src, *dst;
+
+			src = (Sint8 *)cvt->buf;
+			dst = (Sint8 *)cvt->buf;
+			for ( i=cvt->len_cvt/2; i; --i ) {
+				sample = src[0] + src[1];
+				if ( sample > 127 ) {
+					*dst = 127;
+				} else
+				if ( sample < -128 ) {
+					*dst = -128;
+				} else {
+					*dst = sample;
+				}
+				src += 2;
+				dst += 1;
+			}
+		}
+		break;
+
+		case AUDIO_U16: {
+			Uint8 *src, *dst;
+
+			src = cvt->buf;
+			dst = cvt->buf;
+			if ( (format & 0x1000) == 0x1000 ) {
+				for ( i=cvt->len_cvt/4; i; --i ) {
+					sample = (Uint16)((src[0]<<8)|src[1])+
+					         (Uint16)((src[2]<<8)|src[3]);
+					if ( sample > 65535 ) {
+						dst[0] = 0xFF;
+						dst[1] = 0xFF;
+					} else {
+						dst[1] = (sample&0xFF);
+						sample >>= 8;
+						dst[0] = (sample&0xFF);
+					}
+					src += 4;
+					dst += 2;
+				}
+			} else {
+				for ( i=cvt->len_cvt/4; i; --i ) {
+					sample = (Uint16)((src[1]<<8)|src[0])+
+					         (Uint16)((src[3]<<8)|src[2]);
+					if ( sample > 65535 ) {
+						dst[0] = 0xFF;
+						dst[1] = 0xFF;
+					} else {
+						dst[0] = (sample&0xFF);
+						sample >>= 8;
+						dst[1] = (sample&0xFF);
+					}
+					src += 4;
+					dst += 2;
+				}
+			}
+		}
+		break;
+
+		case AUDIO_S16: {
+			Uint8 *src, *dst;
+
+			src = cvt->buf;
+			dst = cvt->buf;
+			if ( (format & 0x1000) == 0x1000 ) {
+				for ( i=cvt->len_cvt/4; i; --i ) {
+					sample = (Sint16)((src[0]<<8)|src[1])+
+					         (Sint16)((src[2]<<8)|src[3]);
+					if ( sample > 32767 ) {
+						dst[0] = 0x7F;
+						dst[1] = 0xFF;
+					} else
+					if ( sample < -32768 ) {
+						dst[0] = 0x80;
+						dst[1] = 0x00;
+					} else {
+						dst[1] = (sample&0xFF);
+						sample >>= 8;
+						dst[0] = (sample&0xFF);
+					}
+					src += 4;
+					dst += 2;
+				}
+			} else {
+				for ( i=cvt->len_cvt/4; i; --i ) {
+					sample = (Sint16)((src[1]<<8)|src[0])+
+					         (Sint16)((src[3]<<8)|src[2]);
+					if ( sample > 32767 ) {
+						dst[1] = 0x7F;
+						dst[0] = 0xFF;
+					} else
+					if ( sample < -32768 ) {
+						dst[1] = 0x80;
+						dst[0] = 0x00;
+					} else {
+						dst[0] = (sample&0xFF);
+						sample >>= 8;
+						dst[1] = (sample&0xFF);
+					}
+					src += 4;
+					dst += 2;
+				}
+			}
+		}
+		break;
+	}
+	cvt->len_cvt /= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+
+/* Duplicate a mono channel to both stereo channels */
+void SDL_ConvertStereo(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting to stereo\n");
+#endif
+	if ( (format & 0xFF) == 16 ) {
+		Uint16 *src, *dst;
+
+		src = (Uint16 *)(cvt->buf+cvt->len_cvt);
+		dst = (Uint16 *)(cvt->buf+cvt->len_cvt*2);
+		for ( i=cvt->len_cvt/2; i; --i ) {
+			dst -= 2;
+			src -= 1;
+			dst[0] = src[0];
+			dst[1] = src[0];
+		}
+	} else {
+		Uint8 *src, *dst;
+
+		src = cvt->buf+cvt->len_cvt;
+		dst = cvt->buf+cvt->len_cvt*2;
+		for ( i=cvt->len_cvt; i; --i ) {
+			dst -= 2;
+			src -= 1;
+			dst[0] = src[0];
+			dst[1] = src[0];
+		}
+	}
+	cvt->len_cvt *= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Convert 8-bit to 16-bit - LSB */
+void SDL_Convert16LSB(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *src, *dst;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting to 16-bit LSB\n");
+#endif
+	src = cvt->buf+cvt->len_cvt;
+	dst = cvt->buf+cvt->len_cvt*2;
+	for ( i=cvt->len_cvt; i; --i ) {
+		src -= 1;
+		dst -= 2;
+		dst[1] = *src;
+		dst[0] = 0;
+	}
+	format = ((format & ~0x0008) | AUDIO_U16LSB);
+	cvt->len_cvt *= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+/* Convert 8-bit to 16-bit - MSB */
+void SDL_Convert16MSB(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *src, *dst;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting to 16-bit MSB\n");
+#endif
+	src = cvt->buf+cvt->len_cvt;
+	dst = cvt->buf+cvt->len_cvt*2;
+	for ( i=cvt->len_cvt; i; --i ) {
+		src -= 1;
+		dst -= 2;
+		dst[0] = *src;
+		dst[1] = 0;
+	}
+	format = ((format & ~0x0008) | AUDIO_U16MSB);
+	cvt->len_cvt *= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Convert 16-bit to 8-bit */
+void SDL_Convert8(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *src, *dst;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting to 8-bit\n");
+#endif
+	src = cvt->buf;
+	dst = cvt->buf;
+	if ( (format & 0x1000) != 0x1000 ) { /* Little endian */
+		++src;
+	}
+	for ( i=cvt->len_cvt/2; i; --i ) {
+		*dst = *src;
+		src += 2;
+		dst += 1;
+	}
+	format = ((format & ~0x9010) | AUDIO_U8);
+	cvt->len_cvt /= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Toggle signed/unsigned */
+void SDL_ConvertSign(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *data;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting audio signedness\n");
+#endif
+	data = cvt->buf;
+	if ( (format & 0xFF) == 16 ) {
+		if ( (format & 0x1000) != 0x1000 ) { /* Little endian */
+			++data;
+		}
+		for ( i=cvt->len_cvt/2; i; --i ) {
+			*data ^= 0x80;
+			data += 2;
+		}
+	} else {
+		for ( i=cvt->len_cvt; i; --i ) {
+			*data++ ^= 0x80;
+		}
+	}
+	format = (format ^ 0x8000);
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Toggle endianness */
+void SDL_ConvertEndian(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *data, tmp;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting audio endianness\n");
+#endif
+	data = cvt->buf;
+	for ( i=cvt->len_cvt/2; i; --i ) {
+		tmp = data[0];
+		data[0] = data[1];
+		data[1] = tmp;
+		data += 2;
+	}
+	format = (format ^ 0x1000);
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Convert rate up by multiple of 2 */
+void SDL_RateMUL2(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *src, *dst;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting audio rate * 2\n");
+#endif
+	src = cvt->buf+cvt->len_cvt;
+	dst = cvt->buf+cvt->len_cvt*2;
+	switch (format & 0xFF) {
+		case 8:
+			for ( i=cvt->len_cvt; i; --i ) {
+				src -= 1;
+				dst -= 2;
+				dst[0] = src[0];
+				dst[1] = src[0];
+			}
+			break;
+		case 16:
+			for ( i=cvt->len_cvt/2; i; --i ) {
+				src -= 2;
+				dst -= 4;
+				dst[0] = src[0];
+				dst[1] = src[1];
+				dst[2] = src[0];
+				dst[3] = src[1];
+			}
+			break;
+	}
+	cvt->len_cvt *= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Convert rate down by multiple of 2 */
+void SDL_RateDIV2(SDL_AudioCVT *cvt, Uint16 format)
+{
+	int i;
+	Uint8 *src, *dst;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting audio rate / 2\n");
+#endif
+	src = cvt->buf;
+	dst = cvt->buf;
+	switch (format & 0xFF) {
+		case 8:
+			for ( i=cvt->len_cvt/2; i; --i ) {
+				dst[0] = src[0];
+				src += 2;
+				dst += 1;
+			}
+			break;
+		case 16:
+			for ( i=cvt->len_cvt/4; i; --i ) {
+				dst[0] = src[0];
+				dst[1] = src[1];
+				src += 4;
+				dst += 2;
+			}
+			break;
+	}
+	cvt->len_cvt /= 2;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+/* Very slow rate conversion routine */
+void SDL_RateSLOW(SDL_AudioCVT *cvt, Uint16 format)
+{
+	double ipos;
+	int i, clen;
+
+#ifdef DEBUG_CONVERT
+	fprintf(stderr, "Converting audio rate * %4.4f\n", 1.0/cvt->rate_incr);
+#endif
+	clen = (int)((double)cvt->len_cvt / cvt->rate_incr);
+	if ( cvt->rate_incr > 1.0 ) {
+		switch (format & 0xFF) {
+			case 8: {
+				Uint8 *output;
+
+				output = cvt->buf;
+				ipos = 0.0;
+				for ( i=clen; i; --i ) {
+					*output = cvt->buf[(int)ipos];
+					ipos += cvt->rate_incr;
+					output += 1;
+				}
+			}
+			break;
+
+			case 16: {
+				Uint16 *output;
+
+				clen &= ~1;
+				output = (Uint16 *)cvt->buf;
+				ipos = 0.0;
+				for ( i=clen/2; i; --i ) {
+					*output=((Uint16 *)cvt->buf)[(int)ipos];
+					ipos += cvt->rate_incr;
+					output += 1;
+				}
+			}
+			break;
+		}
+	} else {
+		switch (format & 0xFF) {
+			case 8: {
+				Uint8 *output;
+
+				output = cvt->buf+clen;
+				ipos = (double)cvt->len_cvt;
+				for ( i=clen; i; --i ) {
+					ipos -= cvt->rate_incr;
+					output -= 1;
+					*output = cvt->buf[(int)ipos];
+				}
+			}
+			break;
+
+			case 16: {
+				Uint16 *output;
+
+				clen &= ~1;
+				output = (Uint16 *)(cvt->buf+clen);
+				ipos = (double)cvt->len_cvt/2;
+				for ( i=clen/2; i; --i ) {
+					ipos -= cvt->rate_incr;
+					output -= 1;
+					*output=((Uint16 *)cvt->buf)[(int)ipos];
+				}
+			}
+			break;
+		}
+	}
+	cvt->len_cvt = clen;
+	if ( cvt->filters[++cvt->filter_index] ) {
+		cvt->filters[cvt->filter_index](cvt, format);
+	}
+}
+
+int SDL_ConvertAudio(SDL_AudioCVT *cvt)
+{
+	/* Make sure there's data to convert */
+	if ( cvt->buf == NULL ) {
+		SDL_SetError("No buffer allocated for conversion");
+		return(-1);
+	}
+	/* Return okay if no conversion is necessary */
+	cvt->len_cvt = cvt->len;
+	if ( cvt->filters[0] == NULL ) {
+		return(0);
+	}
+
+	/* Set up the conversion and go! */
+	cvt->filter_index = 0;
+	cvt->filters[0](cvt, cvt->src_format);
+	return(0);
+}
+
+/* Creates a set of audio filters to convert from one format to another. 
+   Returns -1 if the format conversion is not supported, or 1 if the
+   audio filter is set up.
+*/
+  
+int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
+	Uint16 src_format, Uint8 src_channels, int src_rate,
+	Uint16 dst_format, Uint8 dst_channels, int dst_rate)
+{
+	/* Start off with no conversion necessary */
+	cvt->needed = 0;
+	cvt->filter_index = 0;
+	cvt->filters[0] = NULL;
+	cvt->len_mult = 1;
+	cvt->len_ratio = 1.0;
+
+	/* First filter:  Endian conversion from src to dst */
+	if ( (src_format & 0x1000) != (dst_format & 0x1000)
+	     && ((src_format & 0xff) != 8) ) {
+		cvt->filters[cvt->filter_index++] = SDL_ConvertEndian;
+	}
+	
+	/* Second filter: Sign conversion -- signed/unsigned */
+	if ( (src_format & 0x8000) != (dst_format & 0x8000) ) {
+		cvt->filters[cvt->filter_index++] = SDL_ConvertSign;
+	}
+
+	/* Next filter:  Convert 16 bit <--> 8 bit PCM */
+	if ( (src_format & 0xFF) != (dst_format & 0xFF) ) {
+		switch (dst_format&0x10FF) {
+			case AUDIO_U8:
+				cvt->filters[cvt->filter_index++] =
+							 SDL_Convert8;
+				cvt->len_ratio /= 2;
+				break;
+			case AUDIO_U16LSB:
+				cvt->filters[cvt->filter_index++] =
+							SDL_Convert16LSB;
+				cvt->len_mult *= 2;
+				cvt->len_ratio *= 2;
+				break;
+			case AUDIO_U16MSB:
+				cvt->filters[cvt->filter_index++] =
+							SDL_Convert16MSB;
+				cvt->len_mult *= 2;
+				cvt->len_ratio *= 2;
+				break;
+		}
+	}
+
+	/* Last filter:  Mono/Stereo conversion */
+	if ( src_channels != dst_channels ) {
+		while ( (src_channels*2) <= dst_channels ) {
+			cvt->filters[cvt->filter_index++] = 
+						SDL_ConvertStereo;
+			cvt->len_mult *= 2;
+			src_channels *= 2;
+			cvt->len_ratio *= 2;
+		}
+		/* This assumes that 4 channel audio is in the format:
+		     Left {front/back} + Right {front/back}
+		   so converting to L/R stereo works properly.
+		 */
+		while ( ((src_channels%2) == 0) &&
+				((src_channels/2) >= dst_channels) ) {
+			cvt->filters[cvt->filter_index++] =
+						 SDL_ConvertMono;
+			src_channels /= 2;
+			cvt->len_ratio /= 2;
+		}
+		if ( src_channels != dst_channels ) {
+			/* Uh oh.. */;
+		}
+	}
+
+	/* Do rate conversion */
+	cvt->rate_incr = 0.0;
+	if ( (src_rate/100) != (dst_rate/100) ) {
+		Uint32 hi_rate, lo_rate;
+		int len_mult;
+		double len_ratio;
+		void (*rate_cvt)(SDL_AudioCVT *cvt, Uint16 format);
+
+		if ( src_rate > dst_rate ) {
+			hi_rate = src_rate;
+			lo_rate = dst_rate;
+			rate_cvt = SDL_RateDIV2;
+			len_mult = 1;
+			len_ratio = 0.5;
+		} else {
+			hi_rate = dst_rate;
+			lo_rate = src_rate;
+			rate_cvt = SDL_RateMUL2;
+			len_mult = 2;
+			len_ratio = 2.0;
+		}
+		/* If hi_rate = lo_rate*2^x then conversion is easy */
+		while ( ((lo_rate*2)/100) <= (hi_rate/100) ) {
+			cvt->filters[cvt->filter_index++] = rate_cvt;
+			cvt->len_mult *= len_mult;
+			lo_rate *= 2;
+			cvt->len_ratio *= len_ratio;
+		}
+		/* We may need a slow conversion here to finish up */
+		if ( (lo_rate/100) != (hi_rate/100) ) {
+#if 1
+			/* The problem with this is that if the input buffer is
+			   say 1K, and the conversion rate is say 1.1, then the
+			   output buffer is 1.1K, which may not be an acceptable
+			   buffer size for the audio driver (not a power of 2)
+			*/
+			/* For now, punt and hope the rate distortion isn't great.
+			*/
+#else
+			if ( src_rate < dst_rate ) {
+				cvt->rate_incr = (double)lo_rate/hi_rate;
+				cvt->len_mult *= 2;
+				cvt->len_ratio /= cvt->rate_incr;
+			} else {
+				cvt->rate_incr = (double)hi_rate/lo_rate;
+				cvt->len_ratio *= cvt->rate_incr;
+			}
+			cvt->filters[cvt->filter_index++] = SDL_RateSLOW;
+#endif
+		}
+	}
+
+	/* Set up the filter information */
+	if ( cvt->filter_index != 0 ) {
+		cvt->needed = 1;
+		cvt->src_format = src_format;
+		cvt->dst_format = dst_format;
+		cvt->len = 0;
+		cvt->buf = NULL;
+		cvt->filters[cvt->filter_index] = NULL;
+	}
+	return(cvt->needed);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audiodev.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,182 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Get the name of the audio device we use for output */
+
+#if defined(unix) || defined(__unix__)
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+
+#include "SDL_audiodev_c.h"
+
+#ifndef _PATH_DEV_DSP
+#define _PATH_DEV_DSP	"/dev/dsp"
+#endif
+#ifndef _PATH_DEV_DSP24
+#define _PATH_DEV_DSP24	"/dev/sound/dsp"
+#endif
+#ifndef _PATH_DEV_AUDIO
+#define _PATH_DEV_AUDIO	"/dev/audio"
+#endif
+
+
+int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
+{
+	const char *audiodev;
+	int audio_fd;
+	char audiopath[1024];
+
+	/* Figure out what our audio device is */
+	if ( ((audiodev=getenv("SDL_PATH_DSP")) == NULL) &&
+	     ((audiodev=getenv("AUDIODEV")) == NULL) ) {
+		if ( classic ) {
+			audiodev = _PATH_DEV_AUDIO;
+		} else {
+			struct stat sb;
+
+			/* Added support for /dev/sound/\* in Linux 2.4 */
+			if ( (stat("/dev/sound", &sb) == 0) &&
+			     S_ISDIR(sb.st_mode) ) {
+				audiodev = _PATH_DEV_DSP24;
+			} else {
+				audiodev = _PATH_DEV_DSP;
+			}
+		}
+	}
+	audio_fd = open(audiodev, flags, 0);
+
+	/* If the first open fails, look for other devices */
+	if ( (audio_fd < 0) && (strlen(audiodev) < (sizeof(audiopath)-3)) ) {
+		int exists, instance;
+		struct stat sb;
+
+		instance = 1;
+		do { /* Don't use errno ENOENT - it may not be thread-safe */
+			sprintf(audiopath, "%s%d", audiodev, instance++);
+			exists = 0;
+			if ( stat(audiopath, &sb) == 0 ) {
+				exists = 1;
+				audio_fd = open(audiopath, flags, 0); 
+			}
+		} while ( exists && (audio_fd < 0) );
+		audiodev = audiopath;
+	}
+	if ( path != NULL ) {
+		strncpy(path, audiodev, maxlen);
+		path[maxlen-1] = '\0';
+	}
+	return(audio_fd);
+}
+
+#elif defined(_AIX)
+
+/* Get the name of the audio device we use for output */
+
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+
+#include "SDL_audiodev_c.h"
+
+#ifndef _PATH_DEV_DSP
+#define _PATH_DEV_DSP	"/dev/%caud%c/%c"
+#endif
+
+char devsettings[][3] =
+{
+    { 'p', '0', '1' }, { 'p', '0', '2' }, { 'p', '0', '3' }, { 'p', '0', '4' },
+    { 'p', '1', '1' }, { 'p', '1', '2' }, { 'p', '1', '3' }, { 'p', '1', '4' },
+    { 'p', '2', '1' }, { 'p', '2', '2' }, { 'p', '2', '3' }, { 'p', '2', '4' },
+    { 'p', '3', '1' }, { 'p', '3', '2' }, { 'p', '3', '3' }, { 'p', '3', '4' },
+    { 'b', '0', '1' }, { 'b', '0', '2' }, { 'b', '0', '3' }, { 'b', '0', '4' },
+    { 'b', '1', '1' }, { 'b', '1', '2' }, { 'b', '1', '3' }, { 'b', '1', '4' },
+    { 'b', '2', '1' }, { 'b', '2', '2' }, { 'b', '2', '3' }, { 'b', '2', '4' },
+    { 'b', '3', '1' }, { 'b', '3', '2' }, { 'b', '3', '3' }, { 'b', '3', '4' },
+    { '\0', '\0', '\0' }
+};
+
+static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
+{
+	const char *audiodev;
+	int  audio_fd;
+
+	/* Figure out what our audio device is */
+	if ((audiodev=getenv("SDL_PATH_DSP")) == NULL) {
+	    audiodev=getenv("AUDIODEV");
+	}
+	if ( audiodev == NULL ) {
+	    return -1;
+	}
+	audio_fd = open(audiodev, flags, 0);
+	if ( path != NULL ) {
+		strncpy(path, audiodev, maxlen);
+		path[maxlen-1] = '\0';
+	}
+	return audio_fd;
+}
+
+int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
+{
+    struct stat sb;
+    int         audio_fd;
+    char        audiopath[1024];
+    int         cycle;
+
+    audio_fd = OpenUserDefinedDevice(path,maxlen,flags);
+    if ( audio_fd != -1 ) {
+        return audio_fd;
+    }
+
+    cycle    = 0;
+    while( devsettings[cycle][0] != '\0' ) {
+        sprintf( audiopath,
+                 _PATH_DEV_DSP,
+                 devsettings[cycle][0],
+                 devsettings[cycle][1],
+                 devsettings[cycle][2]);
+
+	if ( stat(audiopath, &sb) == 0 ) {
+	    audio_fd = open(audiopath, flags, 0);
+	    if ( audio_fd > 0 ) {
+		if ( path != NULL ) {
+		    strncpy( path, audiopath, maxlen );
+		    path[maxlen-1] = '\0';
+		}
+	        return audio_fd;
+	    }
+	}
+    }
+    return -1;
+}
+
+#endif /* UNIX system */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audiodev_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Open the audio device, storing the pathname in 'path'  */
+extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audiomem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,73 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions to allocate audio buffer memory, shareable across threads
+	(necessary because SDL audio emulates threads with fork()
+ */
+
+#ifdef FORK_HACK
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stddef.h>
+#else
+#include <stdlib.h>
+#endif
+
+#include "SDL_audiomem.h"
+
+/* Allocate memory that will be shared between threads (freed on exit) */
+void *SDL_AllocAudioMem(int size)
+{
+	void *chunk;
+
+#ifdef FORK_HACK
+	int   semid;
+	
+	/* Create and get the address of a shared memory segment */
+	semid = shmget(IPC_PRIVATE, size, (IPC_CREAT|0600));
+	if ( semid < 0 ) {
+		return(NULL);
+	}
+	chunk = shmat(semid, NULL, 0);
+	
+	/* Set the segment for deletion when it is detatched */
+	shmctl(semid, IPC_RMID, NULL);	/* Delets semid if shmat() fails */
+#else
+	chunk = malloc(size);
+#endif
+	return((void *)chunk);
+}
+
+void SDL_FreeAudioMem(void *chunk)
+{
+#ifdef FORK_HACK
+	shmdt(chunk);
+#else
+	free(chunk);
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_audiomem.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,34 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions to allocate audio buffer memory, shareable across threads
+	(necessary because SDL audio emulates threads with fork()
+ */
+
+extern void *SDL_AllocAudioMem(int size);
+extern void SDL_FreeAudioMem(void *mem);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_mixer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,217 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This provides the default mixing callback for the SDL audio routines */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_audio.h"
+#include "SDL_mutex.h"
+#include "SDL_timer.h"
+#include "SDL_sysaudio.h"
+
+
+/* This table is used to add two sound values together and pin
+ * the value to avoid overflow.  (used with permission from ARDI)
+ * Changed to use 0xFE instead of 0xFF for better sound quality.
+ */
+static const Uint8 mix8[] =
+{
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
+  0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
+  0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
+  0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
+  0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
+  0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
+  0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
+  0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
+  0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
+  0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
+  0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
+  0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
+  0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
+  0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
+  0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
+  0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
+  0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
+  0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
+  0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
+  0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
+  0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
+  0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
+  0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
+  0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
+  0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
+};
+
+/* The volume ranges from 0 - 128 */
+#define ADJUST_VOLUME(s, v)	(s = (s*v)/SDL_MIX_MAXVOLUME)
+#define ADJUST_VOLUME_U8(s, v)	(s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
+
+void SDL_MixAudio (Uint8 *dst, Uint8 *src, Uint32 len, int volume)
+{
+	Uint16 format;
+
+	if ( volume == 0 ) {
+		return;
+	}
+	/* Mix the user-level audio format */
+	if ( current_audio ) {
+		if ( current_audio->convert.needed ) {
+			format = current_audio->convert.src_format;
+		} else {
+			format = current_audio->spec.format;
+		}
+	} else {
+  		/* HACK HACK HACK */
+		format = AUDIO_S16;
+	}
+	switch (format) {
+
+		case AUDIO_U8: {
+			Uint8 src_sample;
+
+			while ( len-- ) {
+				src_sample = *src;
+				ADJUST_VOLUME_U8(src_sample, volume);
+				*dst = mix8[*dst+src_sample];
+				++dst;
+				++src;
+			}
+		}
+		break;
+
+		case AUDIO_S8: {
+			Sint8 *dst8, *src8;
+			Sint8 src_sample;
+			int dst_sample;
+			const int max_audioval = ((1<<(8-1))-1);
+			const int min_audioval = -(1<<(8-1));
+
+			src8 = (Sint8 *)src;
+			dst8 = (Sint8 *)dst;
+			while ( len-- ) {
+				src_sample = *src8;
+				ADJUST_VOLUME(src_sample, volume);
+				dst_sample = *dst8 + src_sample;
+				if ( dst_sample > max_audioval ) {
+					*dst8 = max_audioval;
+				} else
+				if ( dst_sample < min_audioval ) {
+					*dst8 = min_audioval;
+				} else {
+					*dst8 = dst_sample;
+				}
+				++dst8;
+				++src8;
+			}
+		}
+		break;
+
+		case AUDIO_S16LSB: {
+			Sint16 src1, src2;
+			int dst_sample;
+			const int max_audioval = ((1<<(16-1))-1);
+			const int min_audioval = -(1<<(16-1));
+
+			len /= 2;
+			while ( len-- ) {
+				src1 = ((src[1])<<8|src[0]);
+				ADJUST_VOLUME(src1, volume);
+				src2 = ((dst[1])<<8|dst[0]);
+				src += 2;
+				dst_sample = src1+src2;
+				if ( dst_sample > max_audioval ) {
+					dst_sample = max_audioval;
+				} else
+				if ( dst_sample < min_audioval ) {
+					dst_sample = min_audioval;
+				}
+				dst[0] = dst_sample&0xFF;
+				dst_sample >>= 8;
+				dst[1] = dst_sample&0xFF;
+				dst += 2;
+			}
+		}
+		break;
+
+		case AUDIO_S16MSB: {
+			Sint16 src1, src2;
+			int dst_sample;
+			const int max_audioval = ((1<<(16-1))-1);
+			const int min_audioval = -(1<<(16-1));
+
+			len /= 2;
+			while ( len-- ) {
+				src1 = ((src[0])<<8|src[1]);
+				ADJUST_VOLUME(src1, volume);
+				src2 = ((dst[0])<<8|dst[1]);
+				src += 2;
+				dst_sample = src1+src2;
+				if ( dst_sample > max_audioval ) {
+					dst_sample = max_audioval;
+				} else
+				if ( dst_sample < min_audioval ) {
+					dst_sample = min_audioval;
+				}
+				dst[1] = dst_sample&0xFF;
+				dst_sample >>= 8;
+				dst[0] = dst_sample&0xFF;
+				dst += 2;
+			}
+		}
+		break;
+
+		default: /* If this happens... FIXME! */
+			SDL_SetError("SDL_MixAudio(): unknown audio format");
+			return;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_sysaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,142 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_sysaudio_h
+#define _SDL_sysaudio_h
+
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+
+/* The SDL audio driver */
+typedef struct SDL_AudioDevice SDL_AudioDevice;
+
+/* Define the SDL audio driver structure */
+#define _THIS	SDL_AudioDevice *_this
+#ifndef _STATUS
+#define _STATUS	SDL_status *status
+#endif
+struct SDL_AudioDevice {
+	/* * * */
+	/* The name of this audio driver */
+	const char *name;
+
+	/* * * */
+	/* The description of this audio driver */
+	const char *desc;
+
+	/* * * */
+	/* Public driver functions */
+	int  (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
+	void (*ThreadInit)(_THIS);	/* Called by audio thread at start */
+	void (*WaitAudio)(_THIS);
+	void (*PlayAudio)(_THIS);
+	Uint8 *(*GetAudioBuf)(_THIS);
+	void (*WaitDone)(_THIS);
+	void (*CloseAudio)(_THIS);
+
+	/* * * */
+	/* Data common to all devices */
+
+	/* The current audio specification (shared with audio thread) */
+	SDL_AudioSpec spec;
+
+	/* An audio conversion block for audio format emulation */
+	SDL_AudioCVT convert;
+
+	/* Current state flags */
+	int enabled;
+	int paused;
+	int opened;
+
+	/* Fake audio buffer for when the audio hardware is busy */
+	Uint8 *fake_stream;
+
+	/* A semaphore for locking the mixing buffers */
+	SDL_mutex *mixer_lock;
+
+	/* A thread to feed the audio device */
+	SDL_Thread *thread;
+	Uint32 threadid;
+
+	/* * * */
+	/* Data private to this driver */
+	struct SDL_PrivateAudioData *hidden;
+
+	/* * * */
+	/* The function used to dispose of this structure */
+	void (*free)(_THIS);
+};
+#undef _THIS
+
+typedef struct AudioBootStrap {
+	const char *name;
+	const char *desc;
+	int (*available)(void);
+	SDL_AudioDevice *(*create)(int devindex);
+} AudioBootStrap;
+
+#if defined(unix) && \
+   !defined(linux) && !defined(__FreeBSD__) && !defined(__CYGWIN32__) \
+   && !defined(__bsdi__)
+extern AudioBootStrap AUDIO_bootstrap;
+#endif
+#ifdef OSS_SUPPORT
+extern AudioBootStrap DSP_bootstrap;
+extern AudioBootStrap DMA_bootstrap;
+#endif
+#ifdef ALSA_SUPPORT
+extern AudioBootStrap ALSA_bootstrap;
+#endif
+#ifdef ARTSC_SUPPORT
+extern AudioBootStrap ARTSC_bootstrap;
+#endif
+#ifdef ESD_SUPPORT
+extern AudioBootStrap ESD_bootstrap;
+#endif
+#ifdef NAS_SUPPORT
+extern AudioBootStrap NAS_bootstrap;
+#endif
+#ifdef ENABLE_DIRECTX
+extern AudioBootStrap DSOUND_bootstrap;
+#endif
+#ifdef ENABLE_WINDIB
+extern AudioBootStrap WAVEOUT_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;
+#endif
+
+/* This is the current audio device */
+extern SDL_AudioDevice *current_audio;
+
+#endif /* _SDL_sysaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_wave.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,591 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef DISABLE_FILE
+
+/* Microsoft WAVE file loading routines */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_audio.h"
+#include "SDL_wave.h"
+#include "SDL_endian.h"
+
+#ifndef NELEMS
+#define NELEMS(array)	((sizeof array)/(sizeof array[0]))
+#endif
+
+static int ReadChunk(SDL_RWops *src, Chunk *chunk);
+
+struct MS_ADPCM_decodestate {
+	Uint8 hPredictor;
+	Uint16 iDelta;
+	Sint16 iSamp1;
+	Sint16 iSamp2;
+};
+static struct MS_ADPCM_decoder {
+	WaveFMT wavefmt;
+	Uint16 wSamplesPerBlock;
+	Uint16 wNumCoef;
+	Sint16 aCoeff[7][2];
+	/* * * */
+	struct MS_ADPCM_decodestate state[2];
+} MS_ADPCM_state;
+
+static int InitMS_ADPCM(WaveFMT *format)
+{
+	Uint8 *rogue_feel;
+	Uint16 extra_info;
+	int i;
+
+	/* Set the rogue pointer to the MS_ADPCM specific data */
+	MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
+	MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
+	MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
+	MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
+	MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
+	MS_ADPCM_state.wavefmt.bitspersample =
+					 SDL_SwapLE16(format->bitspersample);
+	rogue_feel = (Uint8 *)format+sizeof(*format);
+	if ( sizeof(*format) == 16 ) {
+		extra_info = ((rogue_feel[1]<<8)|rogue_feel[0]);
+		rogue_feel += sizeof(Uint16);
+	}
+	MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
+	rogue_feel += sizeof(Uint16);
+	MS_ADPCM_state.wNumCoef = ((rogue_feel[1]<<8)|rogue_feel[0]);
+	rogue_feel += sizeof(Uint16);
+	if ( MS_ADPCM_state.wNumCoef != 7 ) {
+		SDL_SetError("Unknown set of MS_ADPCM coefficients");
+		return(-1);
+	}
+	for ( i=0; i<MS_ADPCM_state.wNumCoef; ++i ) {
+		MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1]<<8)|rogue_feel[0]);
+		rogue_feel += sizeof(Uint16);
+		MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1]<<8)|rogue_feel[0]);
+		rogue_feel += sizeof(Uint16);
+	}
+	return(0);
+}
+
+static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
+					Uint8 nybble, Sint16 *coeff)
+{
+	const Sint32 max_audioval = ((1<<(16-1))-1);
+	const Sint32 min_audioval = -(1<<(16-1));
+	const Sint32 adaptive[] = {
+		230, 230, 230, 230, 307, 409, 512, 614,
+		768, 614, 512, 409, 307, 230, 230, 230
+	};
+	Sint32 new_sample, delta;
+
+	new_sample = ((state->iSamp1 * coeff[0]) +
+		      (state->iSamp2 * coeff[1]))/256;
+	if ( nybble & 0x08 ) {
+		new_sample += state->iDelta * (nybble-0x10);
+	} else {
+		new_sample += state->iDelta * nybble;
+	}
+	if ( new_sample < min_audioval ) {
+		new_sample = min_audioval;
+	} else
+	if ( new_sample > max_audioval ) {
+		new_sample = max_audioval;
+	}
+	delta = ((Sint32)state->iDelta * adaptive[nybble])/256;
+	if ( delta < 16 ) {
+		delta = 16;
+	}
+	state->iDelta = delta;
+	state->iSamp2 = state->iSamp1;
+	state->iSamp1 = new_sample;
+	return(new_sample);
+}
+
+static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
+{
+	struct MS_ADPCM_decodestate *state[2];
+	Uint8 *freeable, *encoded, *decoded;
+	Sint32 encoded_len, samplesleft;
+	Sint8 nybble, stereo;
+	Sint16 *coeff[2];
+	Sint32 new_sample;
+
+	/* Allocate the proper sized output buffer */
+	encoded_len = *audio_len;
+	encoded = *audio_buf;
+	freeable = *audio_buf;
+	*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) * 
+				MS_ADPCM_state.wSamplesPerBlock*
+				MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
+	*audio_buf = (Uint8 *)malloc(*audio_len);
+	if ( *audio_buf == NULL ) {
+		SDL_Error(SDL_ENOMEM);
+		return(-1);
+	}
+	decoded = *audio_buf;
+
+	/* Get ready... Go! */
+	stereo = (MS_ADPCM_state.wavefmt.channels == 2);
+	state[0] = &MS_ADPCM_state.state[0];
+	state[1] = &MS_ADPCM_state.state[stereo];
+	while ( encoded_len >= MS_ADPCM_state.wavefmt.blockalign ) {
+		/* Grab the initial information for this block */
+		state[0]->hPredictor = *encoded++;
+		if ( stereo ) {
+			state[1]->hPredictor = *encoded++;
+		}
+		state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
+		encoded += sizeof(Sint16);
+		if ( stereo ) {
+			state[1]->iDelta = ((encoded[1]<<8)|encoded[0]);
+			encoded += sizeof(Sint16);
+		}
+		state[0]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
+		encoded += sizeof(Sint16);
+		if ( stereo ) {
+			state[1]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
+			encoded += sizeof(Sint16);
+		}
+		state[0]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
+		encoded += sizeof(Sint16);
+		if ( stereo ) {
+			state[1]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
+			encoded += sizeof(Sint16);
+		}
+		coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
+		coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
+
+		/* Store the two initial samples we start with */
+		decoded[0] = state[0]->iSamp2&0xFF;
+		decoded[1] = state[0]->iSamp2>>8;
+		decoded += 2;
+		if ( stereo ) {
+			decoded[0] = state[1]->iSamp2&0xFF;
+			decoded[1] = state[1]->iSamp2>>8;
+			decoded += 2;
+		}
+		decoded[0] = state[0]->iSamp1&0xFF;
+		decoded[1] = state[0]->iSamp1>>8;
+		decoded += 2;
+		if ( stereo ) {
+			decoded[0] = state[1]->iSamp1&0xFF;
+			decoded[1] = state[1]->iSamp1>>8;
+			decoded += 2;
+		}
+
+		/* Decode and store the other samples in this block */
+		samplesleft = (MS_ADPCM_state.wSamplesPerBlock-2)*
+					MS_ADPCM_state.wavefmt.channels;
+		while ( samplesleft > 0 ) {
+			nybble = (*encoded)>>4;
+			new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
+			decoded[0] = new_sample&0xFF;
+			new_sample >>= 8;
+			decoded[1] = new_sample&0xFF;
+			decoded += 2;
+
+			nybble = (*encoded)&0x0F;
+			new_sample = MS_ADPCM_nibble(state[1],nybble,coeff[1]);
+			decoded[0] = new_sample&0xFF;
+			new_sample >>= 8;
+			decoded[1] = new_sample&0xFF;
+			decoded += 2;
+
+			++encoded;
+			samplesleft -= 2;
+		}
+		encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
+	}
+	free(freeable);
+	return(0);
+}
+
+struct IMA_ADPCM_decodestate {
+	Sint32 sample;
+	Sint8 index;
+};
+static struct IMA_ADPCM_decoder {
+	WaveFMT wavefmt;
+	Uint16 wSamplesPerBlock;
+	/* * * */
+	struct IMA_ADPCM_decodestate state[2];
+} IMA_ADPCM_state;
+
+static int InitIMA_ADPCM(WaveFMT *format)
+{
+	Uint8 *rogue_feel;
+	Uint16 extra_info;
+
+	/* Set the rogue pointer to the IMA_ADPCM specific data */
+	IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
+	IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
+	IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
+	IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
+	IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
+	IMA_ADPCM_state.wavefmt.bitspersample =
+					 SDL_SwapLE16(format->bitspersample);
+	rogue_feel = (Uint8 *)format+sizeof(*format);
+	if ( sizeof(*format) == 16 ) {
+		extra_info = ((rogue_feel[1]<<8)|rogue_feel[0]);
+		rogue_feel += sizeof(Uint16);
+	}
+	IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
+	return(0);
+}
+
+static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
+{
+	const Sint32 max_audioval = ((1<<(16-1))-1);
+	const Sint32 min_audioval = -(1<<(16-1));
+	const int index_table[16] = {
+		-1, -1, -1, -1,
+		 2,  4,  6,  8,
+		-1, -1, -1, -1,
+		 2,  4,  6,  8
+	};
+	const Sint32 step_table[89] = {
+		7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
+		34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
+		143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
+		449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
+		1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
+		3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
+		9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
+		22385, 24623, 27086, 29794, 32767
+	};
+	Sint32 delta, step;
+
+	/* Compute difference and new sample value */
+	step = step_table[state->index];
+	delta = step >> 3;
+	if ( nybble & 0x04 ) delta += step;
+	if ( nybble & 0x02 ) delta += (step >> 1);
+	if ( nybble & 0x01 ) delta += (step >> 2);
+	if ( nybble & 0x08 ) delta = -delta;
+	state->sample += delta;
+
+	/* Update index value */
+	state->index += index_table[nybble];
+	if ( state->index > 88 ) {
+		state->index = 88;
+	} else
+	if ( state->index < 0 ) {
+		state->index = 0;
+	}
+
+	/* Clamp output sample */
+	if ( state->sample > max_audioval ) {
+		state->sample = max_audioval;
+	} else
+	if ( state->sample < min_audioval ) {
+		state->sample = min_audioval;
+	}
+	return(state->sample);
+}
+
+/* Fill the decode buffer with a channel block of data (8 samples) */
+static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
+	int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
+{
+	int i;
+	Sint8 nybble;
+	Sint32 new_sample;
+
+	decoded += (channel * 2);
+	for ( i=0; i<4; ++i ) {
+		nybble = (*encoded)&0x0F;
+		new_sample = IMA_ADPCM_nibble(state, nybble);
+		decoded[0] = new_sample&0xFF;
+		new_sample >>= 8;
+		decoded[1] = new_sample&0xFF;
+		decoded += 2 * numchannels;
+
+		nybble = (*encoded)>>4;
+		new_sample = IMA_ADPCM_nibble(state, nybble);
+		decoded[0] = new_sample&0xFF;
+		new_sample >>= 8;
+		decoded[1] = new_sample&0xFF;
+		decoded += 2 * numchannels;
+
+		++encoded;
+	}
+}
+
+static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
+{
+	struct IMA_ADPCM_decodestate *state;
+	Uint8 *freeable, *encoded, *decoded;
+	Sint32 encoded_len, samplesleft;
+	int c, channels;
+
+	/* Check to make sure we have enough variables in the state array */
+	channels = IMA_ADPCM_state.wavefmt.channels;
+	if ( channels > NELEMS(IMA_ADPCM_state.state) ) {
+		SDL_SetError("IMA ADPCM decoder can only handle %d channels",
+						NELEMS(IMA_ADPCM_state.state));
+		return(-1);
+	}
+	state = IMA_ADPCM_state.state;
+
+	/* Allocate the proper sized output buffer */
+	encoded_len = *audio_len;
+	encoded = *audio_buf;
+	freeable = *audio_buf;
+	*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) * 
+				IMA_ADPCM_state.wSamplesPerBlock*
+				IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
+	*audio_buf = (Uint8 *)malloc(*audio_len);
+	if ( *audio_buf == NULL ) {
+		SDL_Error(SDL_ENOMEM);
+		return(-1);
+	}
+	decoded = *audio_buf;
+
+	/* Get ready... Go! */
+	while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
+		/* Grab the initial information for this block */
+		for ( c=0; c<channels; ++c ) {
+			/* Fill the state information for this block */
+			state[c].sample = ((encoded[1]<<8)|encoded[0]);
+			encoded += 2;
+			if ( state[c].sample & 0x8000 ) {
+				state[c].sample -= 0x10000;
+			}
+			state[c].index = *encoded++;
+			/* Reserved byte in buffer header, should be 0 */
+			if ( *encoded++ != 0 ) {
+				/* Uh oh, corrupt data?  Buggy code? */;
+			}
+
+			/* Store the initial sample we start with */
+			decoded[0] = state[c].sample&0xFF;
+			decoded[1] = state[c].sample>>8;
+			decoded += 2;
+		}
+
+		/* Decode and store the other samples in this block */
+		samplesleft = (IMA_ADPCM_state.wSamplesPerBlock-1)*channels;
+		while ( samplesleft > 0 ) {
+			for ( c=0; c<channels; ++c ) {
+				Fill_IMA_ADPCM_block(decoded, encoded,
+						c, channels, &state[c]);
+				encoded += 4;
+				samplesleft -= 8;
+			}
+			decoded += (channels * 8 * 2);
+		}
+		encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
+	}
+	free(freeable);
+	return(0);
+}
+
+SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
+		SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
+{
+	int was_error;
+	Chunk chunk;
+	int lenread;
+	int MS_ADPCM_encoded, IMA_ADPCM_encoded;
+	int samplesize;
+
+	/* WAV magic header */
+	Uint32 RIFFchunk;
+	Uint32 wavelen;
+	Uint32 WAVEmagic;
+
+	/* FMT chunk */
+	WaveFMT *format = NULL;
+
+	/* Make sure we are passed a valid data source */
+	was_error = 0;
+	if ( src == NULL ) {
+		was_error = 1;
+		goto done;
+	}
+		
+	/* Check the magic header */
+	RIFFchunk	= SDL_ReadLE32(src);
+	wavelen		= SDL_ReadLE32(src);
+	WAVEmagic	= SDL_ReadLE32(src);
+	if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
+		SDL_SetError("Unrecognized file type (not WAVE)");
+		was_error = 1;
+		goto done;
+	}
+
+	/* Read the audio data format chunk */
+	chunk.data = NULL;
+	do {
+		if ( chunk.data != NULL ) {
+			free(chunk.data);
+		}
+		lenread = ReadChunk(src, &chunk);
+		if ( lenread < 0 ) {
+			was_error = 1;
+			goto done;
+		}
+	} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
+
+	/* Decode the audio data format */
+	format = (WaveFMT *)chunk.data;
+	if ( chunk.magic != FMT ) {
+		SDL_SetError("Complex WAVE files not supported");
+		was_error = 1;
+		goto done;
+	}
+	MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
+	switch (SDL_SwapLE16(format->encoding)) {
+		case PCM_CODE:
+			/* We can understand this */
+			break;
+		case MS_ADPCM_CODE:
+			/* Try to understand this */
+			if ( InitMS_ADPCM(format) < 0 ) {
+				was_error = 1;
+				goto done;
+			}
+			MS_ADPCM_encoded = 1;
+			break;
+		case IMA_ADPCM_CODE:
+			/* Try to understand this */
+			if ( InitIMA_ADPCM(format) < 0 ) {
+				was_error = 1;
+				goto done;
+			}
+			IMA_ADPCM_encoded = 1;
+			break;
+		default:
+			SDL_SetError("Unknown WAVE data format: 0x%.4x",
+					SDL_SwapLE16(format->encoding));
+			was_error = 1;
+			goto done;
+	}
+	memset(spec, 0, (sizeof *spec));
+	spec->freq = SDL_SwapLE32(format->frequency);
+	switch (SDL_SwapLE16(format->bitspersample)) {
+		case 4:
+			if ( MS_ADPCM_encoded || IMA_ADPCM_encoded ) {
+				spec->format = AUDIO_S16;
+			} else {
+				was_error = 1;
+			}
+			break;
+		case 8:
+			spec->format = AUDIO_U8;
+			break;
+		case 16:
+			spec->format = AUDIO_S16;
+			break;
+		default:
+			was_error = 1;
+			break;
+	}
+	if ( was_error ) {
+		SDL_SetError("Unknown %d-bit PCM data format",
+			SDL_SwapLE16(format->bitspersample));
+		goto done;
+	}
+	spec->channels = (Uint8)SDL_SwapLE16(format->channels);
+	spec->samples = 4096;		/* Good default buffer size */
+
+	/* Read the audio data chunk */
+	*audio_buf = NULL;
+	do {
+		if ( *audio_buf != NULL ) {
+			free(*audio_buf);
+		}
+		lenread = ReadChunk(src, &chunk);
+		if ( lenread < 0 ) {
+			was_error = 1;
+			goto done;
+		}
+		*audio_len = lenread;
+		*audio_buf = chunk.data;
+	} while ( chunk.magic != DATA );
+
+	if ( MS_ADPCM_encoded ) {
+		if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
+			was_error = 1;
+			goto done;
+		}
+	}
+	if ( IMA_ADPCM_encoded ) {
+		if ( IMA_ADPCM_decode(audio_buf, audio_len) < 0 ) {
+			was_error = 1;
+			goto done;
+		}
+	}
+
+	/* Don't return a buffer that isn't a multiple of samplesize */
+	samplesize = ((spec->format & 0xFF)/8)*spec->channels;
+	*audio_len &= ~(samplesize-1);
+
+done:
+	if ( format != NULL ) {
+		free(format);
+	}
+	if ( freesrc && src ) {
+		SDL_RWclose(src);
+	}
+	if ( was_error ) {
+		spec = NULL;
+	}
+	return(spec);
+}
+
+/* Since the WAV memory is allocated in the shared library, it must also
+   be freed here.  (Necessary under Win32, VC++)
+ */
+void SDL_FreeWAV(Uint8 *audio_buf)
+{
+	if ( audio_buf != NULL ) {
+		free(audio_buf);
+	}
+}
+
+static int ReadChunk(SDL_RWops *src, Chunk *chunk)
+{
+	chunk->magic	= SDL_ReadLE32(src);
+	chunk->length	= SDL_ReadLE32(src);
+	chunk->data = (Uint8 *)malloc(chunk->length);
+	if ( chunk->data == NULL ) {
+		SDL_Error(SDL_ENOMEM);
+		return(-1);
+	}
+	if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
+		SDL_Error(SDL_EFREAD);
+		free(chunk->data);
+		return(-1);
+	}
+	return(chunk->length);
+}
+
+#endif /* ENABLE_FILE */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/SDL_wave.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,65 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* WAVE files are little-endian */
+
+/*******************************************/
+/* Define values for Microsoft WAVE format */
+/*******************************************/
+#define RIFF		0x46464952		/* "RIFF" */
+#define WAVE		0x45564157		/* "WAVE" */
+#define FACT		0x74636166		/* "fact" */
+#define LIST		0x5453494c		/* "LIST" */
+#define FMT		0x20746D66		/* "fmt " */
+#define DATA		0x61746164		/* "data" */
+#define PCM_CODE	0x0001
+#define MS_ADPCM_CODE	0x0002
+#define IMA_ADPCM_CODE	0x0011
+#define WAVE_MONO	1
+#define WAVE_STEREO	2
+
+/* Normally, these three chunks come consecutively in a WAVE file */
+typedef struct WaveFMT {
+/* Not saved in the chunk we read:
+	Uint32	FMTchunk;
+	Uint32	fmtlen;
+*/
+	Uint16	encoding;	
+	Uint16	channels;		/* 1 = mono, 2 = stereo */
+	Uint32	frequency;		/* One of 11025, 22050, or 44100 Hz */
+	Uint32	byterate;		/* Average bytes per second */
+	Uint16	blockalign;		/* Bytes per sample block */
+	Uint16	bitspersample;		/* One of 8, 12, 16, or 4 for ADPCM */
+} WaveFMT;
+
+/* The general chunk found in the WAVE file */
+typedef struct Chunk {
+	Uint32 magic;
+	Uint32 length;
+	Uint8 *data;			/* Data includes magic and length */
+} Chunk;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/alsa/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/alsa/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the ALSA PCM audio API
+
+noinst_LTLIBRARIES = libaudio_alsa.la
+libaudio_alsa_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_alsa_audio.c	\
+	SDL_alsa_audio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,521 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_alsa_audio.h"
+
+/* The tag name used by ALSA audio */
+#define DRIVER_NAME         "alsa"
+
+/* default card and device numbers as listed in dev/snd */
+static int card_no = 0;
+static int device_no = 0;
+
+/* default channel communication parameters */
+#define DEFAULT_CPARAMS_RATE 22050
+#define DEFAULT_CPARAMS_VOICES 1
+#define DEFAULT_CPARAMS_FRAG_SIZE 512
+#define DEFAULT_CPARAMS_FRAGS_MIN 1
+#define DEFAULT_CPARAMS_FRAGS_MAX -1
+
+/* Open the audio device for playback, and don't block if busy */
+#define OPEN_FLAGS	(SND_PCM_OPEN_PLAYBACK|SND_PCM_OPEN_NONBLOCK)
+
+/* Audio driver functions */
+static int PCM_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void PCM_WaitAudio(_THIS);
+static void PCM_PlayAudio(_THIS);
+static Uint8 *PCM_GetAudioBuf(_THIS);
+static void PCM_CloseAudio(_THIS);
+
+/* PCM transfer channel parameters initialize function */
+static void init_pcm_cparams(snd_pcm_channel_params_t* cparams)
+{
+	memset(cparams,0,sizeof(snd_pcm_channel_params_t));
+
+	cparams->channel = SND_PCM_CHANNEL_PLAYBACK;
+	cparams->mode = SND_PCM_MODE_BLOCK;
+	cparams->start_mode = SND_PCM_START_DATA; //_FULL
+	cparams->stop_mode  = SND_PCM_STOP_STOP;
+	cparams->format.format = SND_PCM_SFMT_S16_LE;
+	cparams->format.interleave = 1;
+	cparams->format.rate = DEFAULT_CPARAMS_RATE;
+	cparams->format.voices = DEFAULT_CPARAMS_VOICES;
+	cparams->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
+	cparams->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
+	cparams->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
+}
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+/*
+	See if we can open a nonblocking channel.
+	Return value '1' means we can.
+	Return value '0' means we cannot.
+*/
+{
+	int available;
+	int rval;
+	snd_pcm_t *handle;
+	snd_pcm_channel_params_t cparams;
+#ifdef DEBUG_AUDIO
+	snd_pcm_channel_status_t cstatus;
+#endif
+
+	available = 0;
+	handle = NULL;
+
+	init_pcm_cparams(&cparams);
+	
+	rval = snd_pcm_open(&handle, card_no, device_no, OPEN_FLAGS);
+	if (rval >= 0)
+	{
+		rval = snd_pcm_plugin_params(handle, &cparams);
+
+#ifdef DEBUG_AUDIO
+		snd_pcm_plugin_status(handle, &cstatus);
+		printf("status after snd_pcm_plugin_params call = %d\n",cstatus.status);
+#endif
+		if (rval >= 0)
+		{
+			available = 1;
+		}
+		else
+		{
+	        	SDL_SetError("snd_pcm_channel_params failed: %s\n", snd_strerror (rval));
+		}
+
+        if ((rval = snd_pcm_close(handle)) < 0)
+        {
+            SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
+			available = 0;
+        }
+	}
+	else
+	{
+       SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
+	}
+
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_handle = NULL;
+
+	/* Set the function pointers */
+	this->OpenAudio = PCM_OpenAudio;
+	this->WaitAudio = PCM_WaitAudio;
+	this->PlayAudio = PCM_PlayAudio;
+	this->GetAudioBuf = PCM_GetAudioBuf;
+	this->CloseAudio = PCM_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap ALSA_bootstrap = {
+	DRIVER_NAME, "ALSA PCM audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void PCM_WaitAudio(_THIS)
+{
+
+	/* Check to see if the thread-parent process is still alive */
+	{ static int cnt = 0;
+		/* Note that this only works with thread implementations 
+		   that use a different process id for each thread.
+		*/
+		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
+			if ( kill(parent, 0) < 0 ) {
+				this->enabled = 0;
+			}
+		}
+	}
+
+	/* See if we need to use timed audio synchronization */
+	if ( frame_ticks ) 
+	{
+		/* Use timer for general audio synchronization */
+		Sint32 ticks;
+
+		ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+		if ( ticks > 0 ) 
+		{
+			SDL_Delay(ticks);
+		}
+	}
+    else 
+	{
+    	/* Use select() for audio synchronization */
+		fd_set fdset;
+	    struct timeval timeout;
+    	FD_ZERO(&fdset);
+	    FD_SET(audio_fd, &fdset);
+    	timeout.tv_sec = 10;
+	    timeout.tv_usec = 0;
+#ifdef DEBUG_AUDIO
+    	fprintf(stderr, "Waiting for audio to get ready\n");
+#endif
+	    if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) 
+		{
+            const char *message =
+            "Audio timeout - buggy audio driver? (disabled)";
+	        /* In general we should never print to the screen,
+       	       but in this case we have no other way of letting
+               the user know what happened.
+            */
+       	    fprintf(stderr, "SDL: %s\n", message);
+   	        this->enabled = 0;
+            /* Don't try to close - may hang */
+            audio_fd = -1;
+#ifdef DEBUG_AUDIO
+       	    fprintf(stderr, "Done disabling audio\n");
+#endif
+    	    }
+#ifdef DEBUG_AUDIO
+        fprintf(stderr, "Ready!\n");
+#endif
+    }
+}
+
+static snd_pcm_channel_status_t cstatus;
+
+static void PCM_PlayAudio(_THIS)
+{
+    int written, rval;
+
+    /* Write the audio data, checking for EAGAIN (buffer full) and underrun */
+    do {
+		written = snd_pcm_plugin_write(audio_handle, pcm_buf, pcm_len);
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "written = %d pcm_len = %d\n",written,pcm_len);
+#endif
+		if (written != pcm_len)
+		{
+	        if (errno == EAGAIN) 
+			{
+            	SDL_Delay(1);   /* Let a little CPU time go by and try to write again */
+#ifdef DEBUG_AUDIO
+				fprintf(stderr, "errno == EAGAIN\n");
+#endif
+        	}
+			else
+			{
+		        if( (rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0 )
+        		{
+		            SDL_SetError("snd_pcm_plugin_status failed: %s\n", snd_strerror(rval));
+        		    return;
+		        }
+				if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN)
+					||(cstatus.status == SND_PCM_STATUS_READY) )
+				{
+#ifdef DEBUG_AUDIO
+					fprintf(stderr, "buffer underrun\n");
+#endif
+					if ( (rval = snd_pcm_plugin_prepare (audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0 )
+					{
+						SDL_SetError("snd_pcm_plugin_prepare failed: %s\n",snd_strerror(rval) );
+						return;
+					}
+					/* if we reach here, try to write again */
+				}
+			}
+		}
+    } while ( (written < 0) && ((errno == 0) || (errno == EAGAIN)) );
+
+    /* Set the next write frame */
+   if ( frame_ticks ) {
+	    next_frame += frame_ticks;
+	}
+
+    /* If we couldn't write, assume fatal error for now */
+    if ( written < 0 ) {
+        this->enabled = 0;
+    }
+	return;
+}
+
+static Uint8 *PCM_GetAudioBuf(_THIS)
+{
+	return(pcm_buf);
+}
+
+static void PCM_CloseAudio(_THIS)
+{
+	int rval;
+
+	if ( pcm_buf != NULL ) {
+		free(pcm_buf);
+		pcm_buf = NULL;
+	}
+	if ( audio_handle != NULL ) {
+		if ((rval = snd_pcm_plugin_flush(audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0)
+		{
+        	SDL_SetError("snd_pcm_plugin_flush failed: %s\n",snd_strerror(rval));
+			return;
+		}
+		if ((rval = snd_pcm_close(audio_handle)) < 0)
+		{
+			SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
+			return;
+		}
+		audio_handle = NULL;
+	}
+}
+
+static int PCM_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	int rval;
+	snd_pcm_channel_params_t cparams;
+	snd_pcm_channel_setup_t  csetup;
+	int format;
+	Uint16 test_format;
+	int twidth;
+
+	/* initialize channel transfer parameters to default */
+	init_pcm_cparams(&cparams);
+
+	/* Reset the timer synchronization flag */
+	frame_ticks = 0.0;
+
+	/* Open the audio device */
+	
+	rval = snd_pcm_open(&audio_handle, card_no, device_no, OPEN_FLAGS);
+	if ( rval < 0 ) {
+		SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
+		return(-1);
+	}
+
+#ifdef PLUGIN_DISABLE_MMAP /* This is gone in newer versions of ALSA? */
+    /* disable count status parameter */
+    if ((rval = snd_plugin_set_disable(audio_handle, PLUGIN_DISABLE_MMAP))<0)
+    {
+        SDL_SetError("snd_plugin_set_disable failed: %s\n", snd_strerror(rval));
+        return(-1);
+    }
+#endif
+
+	pcm_buf = NULL;
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) 
+	{
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x spec->samples %d\n", test_format,spec->samples);
+#endif
+			/* if match found set format to equivalent ALSA format */
+        switch ( test_format ) {
+			case AUDIO_U8:
+				format = SND_PCM_SFMT_U8;
+				cparams.buf.block.frag_size = spec->samples * spec->channels;
+				break;
+			case AUDIO_S8:
+				format = SND_PCM_SFMT_S8;
+				cparams.buf.block.frag_size = spec->samples * spec->channels;
+				break;
+			case AUDIO_S16LSB:
+				format = SND_PCM_SFMT_S16_LE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				break;
+			case AUDIO_S16MSB:
+				format = SND_PCM_SFMT_S16_BE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				break;
+			case AUDIO_U16LSB:
+				format = SND_PCM_SFMT_U16_LE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				break;
+			case AUDIO_U16MSB:
+				format = SND_PCM_SFMT_U16_BE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				break;
+			default:
+				break;
+		}
+		if ( ! format ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	spec->format = test_format;
+
+	/* Set the audio format */
+	cparams.format.format = format;
+
+	/* Set mono or stereo audio (currently only two channels supported) */
+	cparams.format.voices = spec->channels;
+	
+	#ifdef DEBUG_AUDIO
+	printf("intializing channels %d\n", cparams.format.voices);
+	#endif
+	
+	/* Set rate */
+	cparams.format.rate = spec->freq ;
+
+	/* Setup the transfer parameters according to cparams */
+	rval = snd_pcm_plugin_params(audio_handle, &cparams);
+	if (rval < 0) {
+		SDL_SetError("snd_pcm_channel_params failed: %s\n", snd_strerror (rval));
+		return(-1);
+	}
+
+    /*  Make sure channel is setup right one last time */
+    memset( &csetup, 0, sizeof( csetup ) );
+    csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
+    if ( snd_pcm_plugin_setup( audio_handle, &csetup ) < 0 )
+    {
+        SDL_SetError("Unable to setup playback channel\n" );
+        return(-1);
+    }
+
+#ifdef DEBUG_AUDIO
+    else
+    {
+        fprintf(stderr,"requested format: %d\n",cparams.format.format);
+        fprintf(stderr,"requested frag size: %d\n",cparams.buf.block.frag_size);
+        fprintf(stderr,"requested max frags: %d\n\n",cparams.buf.block.frags_max);
+
+        fprintf(stderr,"real format: %d\n", csetup.format.format );
+        fprintf(stderr,"real frag size : %d\n", csetup.buf.block.frag_size );
+		fprintf(stderr,"real max frags : %d\n", csetup.buf.block.frags_max );
+    }
+#endif // DEBUG_AUDIO
+
+    /*  Allocate memory to the audio buffer and initialize with silence
+        (Note that buffer size must be a multiple of fragment size, so find closest multiple)
+    */
+    
+    twidth = snd_pcm_format_width(format);
+    if (twidth < 0) {
+        printf("snd_pcm_format_width failed\n");
+        twidth = 0;
+    }
+#ifdef DEBUG_AUDIO
+    printf("format is %d bits wide\n",twidth);
+#endif      
+    
+    pcm_len = csetup.buf.block.frag_size * (twidth/8) * csetup.format.voices ;
+    
+#ifdef DEBUG_AUDIO    
+    printf("pcm_len set to %d\n", pcm_len);
+#endif
+    
+    if (pcm_len == 0)
+    {
+        pcm_len = csetup.buf.block.frag_size;
+    }
+    
+    pcm_buf = (Uint8*)malloc(pcm_len);
+    if (pcm_buf == NULL) {
+        SDL_SetError("pcm_buf malloc failed\n");
+        return(-1);
+    }
+    memset(pcm_buf,spec->silence,pcm_len);
+
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"pcm_buf malloced and silenced.\n");
+#endif
+
+    /* get the file descriptor */
+    if( (audio_fd = snd_pcm_file_descriptor(audio_handle, device_no)) < 0)
+    {
+       fprintf(stderr, "snd_pcm_file_descriptor failed with error code: %d\n", audio_fd);
+    }
+
+	/* Trigger audio playback */
+	rval = snd_pcm_plugin_prepare( audio_handle, SND_PCM_CHANNEL_PLAYBACK);
+	if (rval < 0) {
+       SDL_SetError("snd_pcm_plugin_prepare failed: %s\n", snd_strerror (rval));
+       return(-1);
+	}
+	rval =  snd_pcm_playback_go(audio_handle);
+    if (rval < 0) {
+       SDL_SetError("snd_pcm_playback_go failed: %s\n", snd_strerror (rval));
+       return(-1);
+    }
+
+    /* Check to see if we need to use select() workaround */
+    { char *workaround;
+        workaround = getenv("SDL_DSP_NOSELECT");
+        if ( workaround ) {
+            frame_ticks = (float)(spec->samples*1000)/spec->freq;
+            next_frame = SDL_GetTicks()+frame_ticks;
+        }
+    }
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifndef _ALSA_PCM_audio_h
+#define _ALSA_PCM_audio_h
+
+#include "SDL_sysaudio.h"
+#include <sys/asoundlib.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The audio device handle */
+	 snd_pcm_t *audio_handle;
+
+	/* The audio file descriptor */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *pcm_buf;
+	int    pcm_len;
+
+	/* Support for audio timing using a timer, in addition to select() */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_handle	(this->hidden->audio_handle)
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define pcm_buf			(this->hidden->pcm_buf)
+#define pcm_len			(this->hidden->pcm_len)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _ALSA_PCM_audio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/amigaos/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the SDL AmigaOS audio subsystem
+
+noinst_LTLIBRARIES = libaudio_arch.la
+
+ARCH_SRCS = SDL_ahiaudio.c SDL_audio.c SDL_lowaudio.h SDL_sysaudio.h
+
+libaudio_arch_la_SOURCES = $(ARCH_SRCS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/amigaos/SDL_ahiaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,299 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    5635-34 Springhouse Dr.
+    Pleasanton, CA 94588 (USA)
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
+
+#include "SDL_endian.h"
+#include "SDL_audio.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_lowaudio.h"
+
+/* Audio driver functions */
+static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void AHI_WaitAudio(_THIS);
+static void AHI_PlayAudio(_THIS);
+static Uint8 *AHI_GetAudioBuf(_THIS);
+static void AHI_CloseAudio(_THIS);
+
+#ifndef __SASC
+	#define mymalloc(x) AllocVec(x,MEMF_PUBLIC) 
+	#define myfree FreeVec
+#else
+	#define mymalloc malloc
+	#define myfree free
+#endif
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+#ifndef NO_AMIGADEBUG
+	D(bug("AHI available.\n"));
+#endif
+
+	return 1;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+#ifndef NO_AMIGADEBUG
+	D(bug("AHI created...\n"));
+#endif
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = AHI_OpenAudio;
+	this->WaitAudio = AHI_WaitAudio;
+	this->PlayAudio = AHI_PlayAudio;
+	this->GetAudioBuf = AHI_GetAudioBuf;
+	this->CloseAudio = AHI_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap AHI_bootstrap = {
+	"AHI", Audio_Available, Audio_CreateDevice
+};
+
+
+void static AHI_WaitAudio(_THIS)
+{
+	if(!CheckIO((struct IORequest *)audio_req[current_buffer]))
+	{
+		WaitIO((struct IORequest *)audio_req[current_buffer]);
+//		AbortIO((struct IORequest *)audio_req[current_buffer]);
+	}
+}
+
+static void AHI_PlayAudio(_THIS)
+{
+	if(playing>1)
+		WaitIO((struct IORequest *)audio_req[current_buffer]);
+
+	/* Write the audio data out */
+	audio_req[current_buffer] -> ahir_Std. io_Message.mn_Node.ln_Pri = 60;
+	audio_req[current_buffer] -> ahir_Std. io_Data                = mixbuf[current_buffer];
+	audio_req[current_buffer] -> ahir_Std. io_Length              = this->spec.samples*this->hidden->bytespersample;
+	audio_req[current_buffer] -> ahir_Std. io_Offset              = 0;
+	audio_req[current_buffer] -> ahir_Std . io_Command            = CMD_WRITE;
+	audio_req[current_buffer] -> ahir_Frequency                   = this->hidden->freq;
+	audio_req[current_buffer] -> ahir_Volume                      = 0x10000;
+	audio_req[current_buffer] -> ahir_Type                        = this->hidden->type;
+	audio_req[current_buffer] -> ahir_Position                    = 0x8000;
+	audio_req[current_buffer] -> ahir_Link                        = (playing>0 ? audio_req[current_buffer^1] : NULL);
+
+	SendIO((struct IORequest *)audio_req[current_buffer]);
+	current_buffer^=1;
+
+	playing++;
+}
+
+static Uint8 *AHI_GetAudioBuf(_THIS)
+{
+	return(mixbuf[current_buffer]);
+}
+
+static void AHI_CloseAudio(_THIS)
+{
+	D(bug("Closing audio...\n"));
+
+	if ( mixbuf[0] != NULL ) {
+		myfree(mixbuf[0]);
+//		SDL_FreeAudioMem(mixbuf[0]);
+		mixbuf[0] = NULL;
+	}
+
+	if ( mixbuf[1] != NULL ) {
+		myfree(mixbuf[1]);
+//		SDL_FreeAudioMem(mixbuf[1]);
+		mixbuf[1] = NULL;
+	}
+
+	playing=0;
+
+	if(audio_req[0])
+	{
+		if(audio_req[1])
+		{
+			if(!CheckIO((struct IORequest *)audio_req[1]))
+			{
+				AbortIO((struct IORequest *)audio_req[1]);
+				WaitIO((struct IORequest *)audio_req[1]);
+			}
+			myfree(audio_req[1]);
+		}
+
+		if(!CheckIO((struct IORequest *)audio_req[0]))
+		{
+			AbortIO((struct IORequest *)audio_req[0]);
+			WaitIO((struct IORequest *)audio_req[0]);
+		}
+
+		CloseDevice((struct IORequest *)audio_req[0]);
+		DeleteIORequest((struct IORequest *)audio_req[0]);
+		audio_req[0]=audio_req[1]=NULL;
+	}
+
+	if ( audio_port != NULL ) {
+		DeleteMsgPort(audio_port);
+		audio_port = NULL;
+	}
+	D(bug("...done!\n"));
+}
+
+static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{	
+//	int width;
+
+	D(bug("AHI opening...\n"));
+
+	/* Determine the audio parameters from the AudioSpec */
+	switch ( spec->format & 0xFF ) {
+
+		case 8: { /* Signed 8 bit audio data */
+			D(bug("Samples a 8 bit...\n"));
+			spec->format = AUDIO_S8;
+			this->hidden->bytespersample=1;
+			this->hidden->type = AHIST_M8S;
+
+		}
+		break;
+
+		case 16: { /* Signed 16 bit audio data */
+			D(bug("Samples a 16 bit...\n"));
+			spec->format = AUDIO_S16MSB;
+			this->hidden->bytespersample=2;
+			this->hidden->type = AHIST_M16S;
+		}
+		break;
+
+		default: {
+			SDL_SetError("Unsupported audio format");
+			return(-1);
+		}
+	}
+
+	D(bug("Before CalculateAudioSpec\n"));
+	/* Update the fragment size as size in bytes */
+	SDL_CalculateAudioSpec(spec);
+
+	D(bug("Before CreateMsgPort\n"));
+
+	if(!(audio_port=CreateMsgPort()))
+	{
+		SDL_SetError("Unable to create a MsgPort");
+		return -1;
+	}
+
+	D(bug("Before CreateIORequest\n"));
+
+	if(!(audio_req[0]=(struct AHIRequest *)CreateIORequest(audio_port,sizeof(struct AHIRequest))))
+	{
+		SDL_SetError("Unable to create an AHIRequest");
+		DeleteMsgPort(audio_port);
+		return -1;
+	}
+
+	audio_req[0]->ahir_Version = 4;
+
+	if(OpenDevice(AHINAME,0,(struct IORequest *)audio_req[0],NULL))
+	{
+		SDL_SetError("Unable to open AHI device!\n");
+		DeleteIORequest((struct IORequest *)audio_req[0]);
+		DeleteMsgPort(audio_port);
+		return -1;
+	}
+	
+	D(bug("AFTER opendevice\n"));
+
+	/* Set output frequency */
+	this->hidden->freq = spec->freq;
+
+	D(bug("Before buffer allocation\n"));
+
+	/* Allocate mixing buffer */
+	mixbuf[0] = (Uint8 *)mymalloc(spec->size);
+	mixbuf[1] = (Uint8 *)mymalloc(spec->size);
+
+	D(bug("Before audio_req allocation\n"));
+
+	if(!(audio_req[1]=mymalloc(sizeof(struct AHIRequest))))
+	{
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	
+	D(bug("Before audio_req memcpy\n"));
+
+	memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest));
+
+	if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+
+	D(bug("Before mixbuf memset\n"));
+
+	memset(mixbuf[0], spec->silence, spec->size);
+	memset(mixbuf[1], spec->silence, spec->size);
+
+	current_buffer=0;
+	playing=0;
+
+	D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld\n",spec->freq,mixbuf[0],mixbuf[1],spec->size,this->hidden->bytespersample*8));
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/amigaos/SDL_audio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,532 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+#include <stdlib.h>
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_audio.h"
+#include "SDL_timer.h"
+#include "SDL_error.h"
+#include "SDL_audio_c.h"
+#include "SDL_audiomem.h"
+#include "SDL_sysaudio.h"
+
+
+/* Available audio drivers */
+static AudioBootStrap *bootstrap[] = {
+#ifdef unix
+	&AUDIO_bootstrap,
+#endif
+#ifdef linux
+	&DMA_bootstrap,
+#endif
+#ifdef ESD_SUPPORT
+	&ESD_bootstrap,
+#endif
+#ifdef ENABLE_DIRECTX
+	&DSOUND_bootstrap,
+#endif
+#ifdef ENABLE_WINDIB
+	&WAVEOUT_bootstrap,
+#endif
+#ifdef __BEOS__
+	&BAUDIO_bootstrap,
+#endif
+#ifdef macintosh
+	&AUDIO_bootstrap,
+#endif
+#ifdef _AIX
+	&Paud_bootstrap,
+#endif
+#ifdef ENABLE_CYBERGRAPHICS
+	&AHI_bootstrap,
+#endif
+	NULL
+};
+SDL_AudioDevice *current_audio = NULL;
+
+/* Various local functions */
+int SDL_AudioInit(const char *driver_name);
+void SDL_AudioQuit(void);
+
+struct SignalSemaphore AudioSem;
+
+/* The general mixing thread function */
+int RunAudio(void *audiop)
+{
+	SDL_AudioDevice *audio = (SDL_AudioDevice *)audiop;
+	Uint8 *stream;
+	int    stream_len;
+	void  *udata;
+	void (*fill)(void *userdata,Uint8 *stream, int len);
+	int    silence,started=0;
+
+	D(bug("Task audio started audio struct:<%lx>...\n",audiop));
+
+	D(bug("Before Openaudio..."));
+	if(audio->OpenAudio(audio, &audio->spec)==-1)
+	{
+		return(-1);
+	}
+
+	D(bug("OpenAudio...OK\n"));
+
+	/* Perform any thread setup */
+	if ( audio->ThreadInit ) {
+		audio->ThreadInit(audio);
+	}
+	audio->threadid = SDL_ThreadID();
+
+	/* Set up the mixing function */
+	fill  = audio->spec.callback;
+	udata = audio->spec.userdata;
+	if ( audio->convert.needed ) {
+		if ( audio->convert.src_format == AUDIO_U8 ) {
+			silence = 0x80;
+			D(bug("*** Silence 0x80 ***\n"));
+		} else {
+			silence = 0;
+		}
+		stream_len = audio->convert.len;
+	} else {
+		silence = audio->spec.silence;
+		stream_len = audio->spec.size;
+	}
+	stream = audio->fake_stream;
+
+	ObtainSemaphore(&AudioSem);
+	ReleaseSemaphore(&AudioSem);
+
+	D(bug("Enering audio loop...\n"));
+
+	D(if(audio->convert.needed)bug("*** Conversion needed.\n"));
+
+	/* 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
+		{
+			if(started>1)
+			{
+//				D(bug("Waiting audio...\n"));
+				audio->WaitAudio(audio);
+			}
+		}
+
+		ObtainSemaphore(&AudioSem);
+
+		/* Fill the current buffer with sound */
+		if ( audio->convert.needed ) {
+			stream = audio->convert.buf;
+		} else {
+			stream = audio->GetAudioBuf(audio);
+		}
+
+		if(stream!=audio->fake_stream)
+			memset(stream, silence, stream_len);
+
+		if ( ! audio->paused ) {
+			ObtainSemaphore(&audio->mixer_lock);
+			(*fill)(udata, stream, stream_len);
+			ReleaseSemaphore(&audio->mixer_lock);
+		}
+
+		/* Convert the audio if necessary */
+		if ( audio->convert.needed ) {
+			SDL_ConvertAudio(&audio->convert);
+			stream = audio->GetAudioBuf(audio);
+			memcpy(stream, audio->convert.buf,audio->convert.len_cvt);
+		}
+
+		if(stream!=audio->fake_stream)
+		{
+//			D(bug("Playing stream at %lx\n",stream));
+
+			audio->PlayAudio(audio);
+			started++;
+		}
+		ReleaseSemaphore(&AudioSem);
+
+	}
+	D(bug("Out of subtask loop...\n"));
+
+	/* Wait for the audio to drain.. */
+	if ( audio->WaitDone ) {
+		audio->WaitDone(audio);
+	}
+
+	D(bug("WaitAudio...Done\n"));
+
+	audio->CloseAudio(audio);
+
+	D(bug("CloseAudio..Done, subtask exiting...\n"));
+
+	return(0);
+}
+
+int SDL_AudioInit(const char *driver_name)
+{
+	SDL_AudioDevice *audio;
+	int i = 0, idx;
+
+	/* Check to make sure we don't overwrite 'current_audio' */
+	if ( current_audio != NULL ) {
+		SDL_AudioQuit();
+	}
+
+	/* Select the proper audio driver */
+	audio = NULL;
+	idx = 0;
+
+	InitSemaphore(&AudioSem);
+
+	if ( audio == NULL ) {
+		if ( driver_name != NULL ) {
+			if ( strrchr(driver_name, ':') != NULL ) {
+				idx = atoi(strrchr(driver_name, ':')+1);
+			}
+			for ( i=0; bootstrap[i]; ++i ) {
+				if (strncmp(bootstrap[i]->name, driver_name,
+				            strlen(bootstrap[i]->name)) == 0) {
+					if ( bootstrap[i]->available() ) {
+						audio=bootstrap[i]->create(idx);
+						break;
+					}
+				}
+			}
+		} else {
+			for ( i=0; bootstrap[i]; ++i ) {
+				if ( bootstrap[i]->available() ) {
+					audio = bootstrap[i]->create(idx);
+					if ( audio != NULL ) {
+						break;
+					}
+				}
+			}
+		}
+		if ( audio == NULL ) {
+			SDL_SetError("No available audio device");
+#if 0 /* Don't fail SDL_Init() if audio isn't available.
+         SDL_OpenAudio() will handle it at that point.  *sigh*
+       */
+			return(-1);
+#endif
+		}
+	}
+	current_audio = audio;
+	if ( current_audio ) {
+		current_audio->name = bootstrap[i]->name;
+	}
+	return(0);
+}
+
+char *SDL_AudioDriverName(char *namebuf, int maxlen)
+{
+	if ( current_audio != NULL ) {
+		strncpy(namebuf, current_audio->name, maxlen-1);
+		namebuf[maxlen-1] = '\0';
+		return(namebuf);
+	}
+	return(NULL);
+}
+
+int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
+{
+	SDL_AudioDevice *audio;
+
+	/* Start up the audio driver, if necessary */
+	if ( ! current_audio ) {
+		if ( (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) ||
+		     (current_audio == NULL) ) {
+			return(-1);
+		}
+	}
+	audio = current_audio;
+
+	D(bug("Chiamata SDL_OpenAudio...\n"));
+
+	/* Verify some parameters */
+	if ( desired->callback == NULL ) {
+		SDL_SetError("SDL_OpenAudio() passed a NULL callback");
+		return(-1);
+	}
+	switch ( desired->channels ) {
+	    case 1:	/* Mono */
+	    case 2:	/* Stereo */
+		break;
+	    default:
+		SDL_SetError("1 (mono) and 2 (stereo) channels supported");
+		return(-1);
+	}
+
+	/* Create a semaphore for locking the sound buffers */
+	InitSemaphore(&audio->mixer_lock);
+
+	/* Calculate the silence and size of the audio specification */
+	SDL_CalculateAudioSpec(desired);
+
+	/* Open the audio subsystem */
+	memcpy(&audio->spec, desired, sizeof(audio->spec));
+	audio->convert.needed = 0;
+	audio->enabled = 1;
+	audio->paused  = 1;
+
+	ObtainSemaphore(&AudioSem);
+
+	audio->thread = SDL_CreateThread(RunAudio, audio);
+
+	if ( audio->thread == NULL ) {
+		ReleaseSemaphore(&AudioSem);
+		SDL_CloseAudio();
+		SDL_SetError("Couldn't create audio thread");
+		return(-1);
+	}
+
+	/* If the audio driver changes the buffer size, accept it */
+	if ( audio->spec.samples != desired->samples ) {
+		desired->samples = audio->spec.samples;
+		SDL_CalculateAudioSpec(desired);
+	}
+
+	/* Allocate a fake audio memory buffer */
+	audio->fake_stream = SDL_AllocAudioMem(audio->spec.size);
+	if ( audio->fake_stream == NULL ) {
+		ReleaseSemaphore(&AudioSem);
+		SDL_CloseAudio();
+		SDL_OutOfMemory();
+		return(-1);
+	}
+
+	/* See if we need to do any conversion */
+	if ( memcmp(desired, &audio->spec, sizeof(audio->spec)) == 0 ) {
+		/* Just copy over the desired audio specification */
+		if ( obtained != NULL ) {
+			memcpy(obtained, &audio->spec, sizeof(audio->spec));
+		}
+	} else {
+		/* Copy over the audio specification if possible */
+		if ( obtained != NULL ) {
+			memcpy(obtained, &audio->spec, sizeof(audio->spec));
+		} else {
+			/* Build an audio conversion block */
+			D(bug("Need conversion:\n desired: C:%ld F:%ld T:%lx\navailable: C:%ld F:%ld T:%lx\n",
+				desired->channels, desired->freq, desired->format,
+				audio->spec.channels,audio->spec.freq,audio->spec.format));
+
+			Forbid();
+
+// Magari poi lo sostiutisco con un semaforo.
+
+			if ( SDL_BuildAudioCVT(&audio->convert,
+				desired->format, desired->channels,
+						desired->freq,
+				audio->spec.format, audio->spec.channels,
+						audio->spec.freq) < 0 ) {
+				ReleaseSemaphore(&AudioSem);
+				SDL_CloseAudio();
+				return(-1);
+			}
+			if ( audio->convert.needed ) {
+				audio->convert.len = desired->size;
+				audio->convert.buf =(Uint8 *)SDL_AllocAudioMem(
+				   audio->convert.len*audio->convert.len_mult);
+				if ( audio->convert.buf == NULL ) {
+					ReleaseSemaphore(&AudioSem);
+					SDL_CloseAudio();
+					SDL_OutOfMemory();
+					return(-1);
+				}
+			}
+		}
+	}
+
+	ReleaseSemaphore(&AudioSem);
+
+	D(bug("SDL_OpenAudio USCITA...\n"));
+
+	return(0);
+}
+
+SDL_audiostatus SDL_GetAudioStatus(void)
+{
+	SDL_AudioDevice *audio = current_audio;
+	SDL_audiostatus status;
+
+	status = SDL_AUDIO_STOPPED;
+	if ( audio && audio->enabled ) {
+		if ( audio->paused ) {
+			status = SDL_AUDIO_PAUSED;
+		} else {
+			status = SDL_AUDIO_PLAYING;
+		}
+	}
+	return(status);
+}
+
+void SDL_PauseAudio (int pause_on)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	if ( audio ) {
+		audio->paused = pause_on;
+	}
+}
+
+void SDL_LockAudio (void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	/* Obtain a lock on the mixing buffers */
+	if ( audio ) {
+		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+			return;
+		}
+		ObtainSemaphore(&audio->mixer_lock);
+	}
+}
+
+void SDL_UnlockAudio (void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	/* Release lock on the mixing buffers */
+	if ( audio ) {
+		if ( audio->thread && (SDL_ThreadID() == audio->threadid) ) {
+			return;
+		}
+		ReleaseSemaphore(&audio->mixer_lock);
+	}
+}
+
+void SDL_CloseAudio (void)
+{
+	SDL_AudioDevice *audio = current_audio;
+
+	if ( audio ) {
+		if(audio->enabled)
+		{
+			audio->enabled = 0;
+
+			if ( audio->thread != NULL ) {
+				D(bug("Waiting audio thread...\n"));
+				SDL_WaitThread(audio->thread, NULL);
+				D(bug("...audio replied\n"));
+			}
+		}
+
+		if ( audio->fake_stream != NULL ) {
+			SDL_FreeAudioMem(audio->fake_stream);
+			audio->fake_stream=NULL;
+		}
+		if ( audio->convert.needed && current_audio->convert.buf!=NULL) {
+			SDL_FreeAudioMem(audio->convert.buf);
+			current_audio->convert.buf=NULL;
+		}
+	}
+	SDL_QuitSubSystem(SDL_INIT_AUDIO);
+}
+
+void SDL_AudioQuit(void)
+{
+	if ( current_audio ) {
+		if(current_audio->enabled)
+		{
+			D(bug("Closing audio in AudioQuit...\n"));
+			current_audio->enabled = 0;
+
+			if ( current_audio->thread != NULL ) {
+				D(bug("Waiting audio thread...\n"));
+				SDL_WaitThread(current_audio->thread, NULL);
+				D(bug("...audio replied\n"));
+			}
+		}
+		if ( current_audio->fake_stream != NULL ) {
+			SDL_FreeAudioMem(current_audio->fake_stream);
+		}
+		if ( current_audio->convert.needed && 
+				current_audio->convert.buf) {
+			SDL_FreeAudioMem(current_audio->convert.buf);
+		}
+
+		current_audio->free(current_audio);
+		current_audio = NULL;
+	}
+}
+
+#define NUM_FORMATS	6
+static int format_idx;
+static int format_idx_sub;
+static Uint16 format_list[NUM_FORMATS][NUM_FORMATS] = {
+ { AUDIO_U8, AUDIO_S8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
+ { AUDIO_S8, AUDIO_U8, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB },
+ { AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_U16LSB, AUDIO_U16MSB, AUDIO_S16LSB, AUDIO_S16MSB, AUDIO_U8, AUDIO_S8 },
+ { AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_S16MSB, AUDIO_S16LSB, AUDIO_U8, AUDIO_S8 },
+};
+
+Uint16 SDL_FirstAudioFormat(Uint16 format)
+{
+	for ( format_idx=0; format_idx < NUM_FORMATS; ++format_idx ) {
+		if ( format_list[format_idx][0] == format ) {
+			break;
+		}
+	}
+	format_idx_sub = 0;
+	return(SDL_NextAudioFormat());
+}
+
+Uint16 SDL_NextAudioFormat(void)
+{
+	if ( (format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS) ) {
+		return(0);
+	}
+	return(format_list[format_idx][format_idx_sub++]);
+}
+
+void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
+{
+	switch (spec->format) {
+		case AUDIO_U8:
+			spec->silence = 0x80;
+			break;
+		default:
+			spec->silence = 0x00;
+			break;
+	}
+	spec->size = (spec->format&0xFF)/8;
+	spec->size *= spec->channels;
+	spec->size *= spec->samples;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/amigaos/SDL_lowaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,58 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+// #include <libraries/ahi_sub.h>
+
+#include "SDL_sysaudio.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* Hidden "this" pointer for the audio functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The handle for the audio device */
+	struct AHIRequest *audio_req[2];
+	struct MsgPort *audio_port;
+	Sint32 freq,type,bytespersample;
+	Uint8 *mixbuf[2];           /* The app mixing buffer */
+	int current_buffer;
+	Uint32 playing;
+};
+
+/* Old variable names */
+#define audio_port		(this->hidden->audio_port)
+#define audio_req		(this->hidden->audio_req)
+#define mixbuf			(this->hidden->mixbuf)
+#define current_buffer		(this->hidden->current_buffer)
+#define playing			(this->hidden->playing)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/amigaos/SDL_sysaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,142 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_sysaudio_h
+#define _SDL_sysaudio_h
+
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+
+#include <exec/exec.h>
+#include <dos/dos.h>
+#ifdef __SASC
+#include <proto/exec.h>
+#else
+#include <inline/exec.h>
+#endif
+
+#include <devices/ahi.h>
+#include "mydebug.h"
+
+/* The SDL audio driver */
+typedef struct SDL_AudioDevice SDL_AudioDevice;
+
+/* Define the SDL audio driver structure */
+#define _THIS	SDL_AudioDevice *_this
+#ifndef _STATUS
+#define _STATUS	SDL_status *status
+#endif
+struct SDL_AudioDevice {
+	/* * * */
+	/* The name of this audio driver */
+	const char *name;
+
+	/* * * */
+	/* Public driver functions */
+	int  (*OpenAudio)(_THIS, SDL_AudioSpec *spec);
+	void (*ThreadInit)(_THIS);	/* Called by audio thread at start */
+	void (*WaitAudio)(_THIS);
+	void (*PlayAudio)(_THIS);
+	Uint8 *(*GetAudioBuf)(_THIS);
+	void (*WaitDone)(_THIS);
+	void (*CloseAudio)(_THIS);
+
+	/* * * */
+	/* Data common to all devices */
+
+	/* The current audio specification (shared with audio thread) */
+	SDL_AudioSpec spec;
+
+	/* An audio conversion block for audio format emulation */
+	SDL_AudioCVT convert;
+
+	/* Current state flags */
+	int enabled;
+	int paused;
+
+	/* Fake audio buffer for when the audio hardware is busy */
+	Uint8 *fake_stream;
+
+	/* A semaphore for locking the mixing buffers */
+	struct SignalSemaphore mixer_lock;
+
+	/* A thread to feed the audio device */
+	SDL_Thread *thread;
+	Uint32 threadid;
+
+	/* * * */
+	/* Data private to this driver */
+	struct SDL_PrivateAudioData *hidden;
+
+	/* * * */
+	/* The function used to dispose of this structure */
+	void (*free)(_THIS);
+};
+#undef _THIS
+
+typedef struct AudioBootStrap {
+	const char *name;
+	int (*available)(void);
+	SDL_AudioDevice *(*create)(int devindex);
+} AudioBootStrap;
+
+#ifdef ESD_SUPPORT
+extern AudioBootStrap ESD_bootstrap;
+#endif
+#ifdef linux
+extern AudioBootStrap DMA_bootstrap;
+#endif
+#ifdef unix
+extern AudioBootStrap AUDIO_bootstrap;
+#endif
+#ifdef ENABLE_WINDIB
+extern AudioBootStrap WAVEOUT_bootstrap;
+#endif
+#ifdef ENABLE_DIRECTX
+extern AudioBootStrap DSOUND_bootstrap;
+#endif
+#ifdef __BEOS__
+extern AudioBootStrap BAUDIO_bootstrap;
+#endif
+#ifdef macintosh
+extern AudioBootStrap AUDIO_bootstrap;
+#endif
+#ifdef _AIX
+extern AudioBootStrap Paud_bootstrap;
+#endif
+#ifdef ENABLE_CYBERGRAPHICS
+extern AudioBootStrap AHI_bootstrap;
+#endif
+
+/* This is the current audio device */
+extern SDL_AudioDevice *current_audio;
+
+#ifndef __SASC
+extern struct ExecBase *SysBase;
+#endif
+
+#endif /* _SDL_sysaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/arts/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/arts/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the Analog Realtime Synthesizer sound driver
+
+noinst_LTLIBRARIES = libaudio_arts.la
+libaudio_arts_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_artsaudio.c	\
+	SDL_artsaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/arts/SDL_artsaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,247 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_artsaudio.h"
+
+/* The tag name used by artsc audio */
+#define ARTSC_DRIVER_NAME         "artsc"
+
+/* Audio driver functions */
+static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void ARTSC_WaitAudio(_THIS);
+static void ARTSC_PlayAudio(_THIS);
+static Uint8 *ARTSC_GetAudioBuf(_THIS);
+static void ARTSC_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	if(arts_init())
+		return 0;
+	else
+		return 1;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	stream = 0;
+
+	/* Set the function pointers */
+	this->OpenAudio = ARTSC_OpenAudio;
+	this->WaitAudio = ARTSC_WaitAudio;
+	this->PlayAudio = ARTSC_PlayAudio;
+	this->GetAudioBuf = ARTSC_GetAudioBuf;
+	this->CloseAudio = ARTSC_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap ARTSC_bootstrap = {
+	ARTSC_DRIVER_NAME, "Analog Realtime Synthesizer",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void ARTSC_WaitAudio(_THIS)
+{
+	Sint32 ticks;
+
+	/* Check to see if the thread-parent process is still alive */
+	{ static int cnt = 0;
+		/* Note that this only works with thread implementations 
+		   that use a different process id for each thread.
+		*/
+		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
+			if ( kill(parent, 0) < 0 ) {
+				this->enabled = 0;
+			}
+		}
+	}
+
+	/* Use timer for general audio synchronization */
+	ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+	if ( ticks > 0 ) {
+		SDL_Delay(ticks);
+	}
+}
+
+static void ARTSC_PlayAudio(_THIS)
+{
+	int written;
+
+	/* Write the audio data */
+	written = arts_write(stream, mixbuf, mixlen);
+	
+	/* If timer synchronization is enabled, set the next write frame */
+	if ( frame_ticks ) {
+		next_frame += frame_ticks;
+	}
+
+	/* If we couldn't write, assume fatal error for now */
+	if ( written < 0 ) {
+		this->enabled = 0;
+	}
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Wrote %d bytes of audio data\n", written);
+#endif
+}
+
+static Uint8 *ARTSC_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+static void ARTSC_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( stream ) {
+		arts_close_stream(stream);
+		stream = 0;
+	}
+}
+
+static int ARTSC_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	int bits, frag_spec;
+	Uint16 test_format, format;
+
+	/* Reset the timer synchronization flag */
+	frame_ticks = 0.0;
+
+	mixbuf = NULL;
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	bits = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) {
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
+#endif
+		switch ( test_format ) {
+			case AUDIO_U8:
+				bits = 8;
+				format = 1;
+				break;
+			case AUDIO_S16LSB:
+				bits = 16;
+				format = 1;
+				break;
+			default:
+				format = 0;
+				break;
+		}
+		if ( ! format ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	spec->format = test_format;
+
+	stream = arts_play_stream(spec->freq, bits, spec->channels, "SDL");
+
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Determine the power of two of the fragment size */
+	for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
+	if ( (0x01<<frag_spec) != spec->size ) {
+		SDL_SetError("Fragment size must be a power of two");
+		return(-1);
+	}
+	frag_spec |= 0x00020000;	/* two fragments, for low latency */
+
+#ifdef ARTS_P_PACKET_SETTINGS
+	arts_stream_set(stream, ARTS_P_PACKET_SETTINGS, frag_spec);
+#else
+	arts_stream_set(stream, ARTS_P_PACKET_SIZE, frag_spec&0xffff);
+	arts_stream_set(stream, ARTS_P_PACKET_COUNT, frag_spec>>16);
+#endif
+	spec->size = arts_stream_get(stream, ARTS_P_PACKET_SIZE);
+
+	/* Allocate mixing buffer */
+	mixlen = spec->size;
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
+	if ( mixbuf == NULL ) {
+		return(-1);
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/arts/SDL_artsaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,63 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_artscaudio_h
+#define _SDL_artscaudio_h
+
+#include <artsc.h>
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The stream descriptor for the audio device */
+	arts_stream_t stream;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+	/* Support for audio timing using a timer, in addition to select() */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define stream			(this->hidden->stream)
+#define parent			(this->hidden->parent)
+#define mixbuf			(this->hidden->mixbuf)
+#define mixlen			(this->hidden->mixlen)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _SDL_artscaudio_h */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/baudio/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/baudio/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the BeOS BSoundPlayer sound driver
+
+noinst_LTLIBRARIES = libaudio_baudio.la
+libaudio_baudio_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_beaudio.cc	\
+	SDL_beaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/baudio/SDL_beaudio.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,211 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to the audio stream on BeOS */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <SoundPlayer.h>
+
+#include "SDL_BeApp.h"
+
+extern "C" {
+
+#include "SDL_audio.h"
+#include "SDL_audio_c.h"
+#include "SDL_sysaudio.h"
+#include "SDL_systhread_c.h"
+#include "SDL_beaudio.h"
+
+
+/* Audio driver functions */
+static int BE_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void BE_WaitAudio(_THIS);
+static void BE_PlayAudio(_THIS);
+static Uint8 *BE_GetAudioBuf(_THIS);
+static void BE_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	return(1);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->OpenAudio = BE_OpenAudio;
+	device->WaitAudio = BE_WaitAudio;
+	device->PlayAudio = BE_PlayAudio;
+	device->GetAudioBuf = BE_GetAudioBuf;
+	device->CloseAudio = BE_CloseAudio;
+
+	device->free = Audio_DeleteDevice;
+
+	return device;
+}
+
+AudioBootStrap BAUDIO_bootstrap = {
+	"baudio", "BeOS BSoundPlayer",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* The BeOS callback for handling the audio buffer */
+static void FillSound(void *device, void *stream, size_t len, 
+					const media_raw_audio_format &format)
+{
+	SDL_AudioDevice *audio = (SDL_AudioDevice *)device;
+
+	/* Silence the buffer, since it's ours */
+	memset(stream, audio->spec.silence, len);
+
+	/* Only do soemthing if audio is enabled */
+	if ( ! audio->enabled )
+		return;
+
+	if ( ! audio->paused ) {
+		if ( audio->convert.needed ) {
+			SDL_mutexP(audio->mixer_lock);
+			(*audio->spec.callback)(audio->spec.userdata,
+				(Uint8 *)audio->convert.buf,audio->convert.len);
+			SDL_mutexV(audio->mixer_lock);
+			SDL_ConvertAudio(&audio->convert);
+			memcpy(stream,audio->convert.buf,audio->convert.len_cvt);
+		} else {
+			SDL_mutexP(audio->mixer_lock);
+			(*audio->spec.callback)(audio->spec.userdata,
+						(Uint8 *)stream, len);
+			SDL_mutexV(audio->mixer_lock);
+		}
+	}
+	return;
+}
+
+/* Dummy functions -- we don't use thread-based audio */
+void BE_WaitAudio(_THIS)
+{
+	return;
+}
+void BE_PlayAudio(_THIS)
+{
+	return;
+}
+Uint8 *BE_GetAudioBuf(_THIS)
+{
+	return(NULL);
+}
+
+void BE_CloseAudio(_THIS)
+{
+	if ( audio_obj ) {
+		audio_obj->Stop();
+		delete audio_obj;
+		audio_obj = NULL;
+	}
+
+	/* Quit the Be Application, if there's nothing left to do */
+	SDL_QuitBeApp();
+}
+
+int BE_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	media_raw_audio_format format;
+
+	/* Initialize the Be Application, if it's not already started */
+	if ( SDL_InitBeApp() < 0 ) {
+		return(-1);
+	}
+
+	/* Parse the audio format and fill the Be raw audio format */
+	format.frame_rate = (float)spec->freq;
+	format.channel_count = spec->channels;
+	switch (spec->format&~0x1000) {
+		case AUDIO_S8:
+			/* Signed 8-bit audio unsupported, convert to U8 */
+			spec->format = AUDIO_U8;
+		case AUDIO_U8:
+			format.format = media_raw_audio_format::B_AUDIO_UCHAR;
+			format.byte_order = 0;
+			break;
+		case AUDIO_U16:
+			/* Unsigned 16-bit audio unsupported, convert to S16 */
+			spec->format ^= 0x8000;
+		case AUDIO_S16:
+			format.format = media_raw_audio_format::B_AUDIO_SHORT;
+			if ( spec->format & 0x1000 ) {
+				format.byte_order = 1; /* Big endian */
+			} else {
+				format.byte_order = 2; /* Little endian */
+			}
+			break;
+	}
+	format.buffer_size = spec->samples;
+	
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Subscribe to the audio stream (creates a new thread) */
+	{ sigset_t omask;
+		SDL_MaskSignals(&omask);
+		audio_obj = new BSoundPlayer(&format, "SDL Audio", FillSound,
+		                                                 NULL, _this);
+		SDL_UnmaskSignals(&omask);
+	}
+	audio_obj->Start();
+	audio_obj->SetHasData(true);
+
+	/* We're running! */
+	return(1);
+}
+
+};	/* Extern C */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/baudio/SDL_beaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,43 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *_this
+
+struct SDL_PrivateAudioData {
+	BSoundPlayer *audio_obj;
+};
+
+/* Old variable names */
+#define audio_obj	(_this->hidden->audio_obj)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dma/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dma/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the OSS /dev/dsp DMA sound driver
+
+noinst_LTLIBRARIES = libaudio_dma.la
+libaudio_dma_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_dmaaudio.c	\
+	SDL_dmaaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dma/SDL_dmaaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,466 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#ifdef linux
+#include <linux/soundcard.h>
+#endif
+#ifdef __bsdi__
+#include <sys/soundcard.h>
+#endif
+#ifdef __FreeBSD__
+#include <machine/soundcard.h>
+#endif
+#ifdef __USLC__
+#include <sys/soundcard.h>
+#endif
+
+#ifndef MAP_FAILED
+#define MAP_FAILED	((Uint8 *)-1)
+#endif
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_dmaaudio.h"
+
+/* The tag name used by DMA audio */
+#define DMA_DRIVER_NAME         "dma"
+
+/* Open the audio device for playback, and don't block if busy */
+#define OPEN_FLAGS	(O_RDWR|O_NONBLOCK)
+
+/* Audio driver functions */
+static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void DMA_WaitAudio(_THIS);
+static void DMA_PlayAudio(_THIS);
+static Uint8 *DMA_GetAudioBuf(_THIS);
+static void DMA_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	int available;
+	int fd;
+
+	available = 0;
+
+	fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
+	if ( fd >= 0 ) {
+		int caps;
+		struct audio_buf_info info;
+
+		if ( (ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) &&
+	             (caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) &&
+		     (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0) ) {
+			available = 1;
+		}
+		close(fd);
+	}
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_fd = -1;
+
+	/* Set the function pointers */
+	this->OpenAudio = DMA_OpenAudio;
+	this->WaitAudio = DMA_WaitAudio;
+	this->PlayAudio = DMA_PlayAudio;
+	this->GetAudioBuf = DMA_GetAudioBuf;
+	this->CloseAudio = DMA_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap DMA_bootstrap = {
+	DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void DMA_WaitAudio(_THIS)
+{
+	fd_set fdset;
+
+	/* Check to see if the thread-parent process is still alive */
+	{ static int cnt = 0;
+		/* Note that this only works with thread implementations 
+		   that use a different process id for each thread.
+		*/
+		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
+			if ( kill(parent, 0) < 0 ) {
+				this->enabled = 0;
+			}
+		}
+	}
+
+	/* See if we need to use timed audio synchronization */
+	if ( frame_ticks ) {
+		/* Use timer for general audio synchronization */
+		Sint32 ticks;
+
+		ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+		if ( ticks > 0 ) {
+			SDL_Delay(ticks);
+		}
+	} else {
+		/* Use select() for audio synchronization */
+		struct timeval timeout;
+		FD_ZERO(&fdset);
+		FD_SET(audio_fd, &fdset);
+		timeout.tv_sec = 10;
+		timeout.tv_usec = 0;
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Waiting for audio to get ready\n");
+#endif
+		if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) {
+			const char *message =
+#ifdef AUDIO_OSPACE_HACK
+			"Audio timeout - buggy audio driver? (trying ospace)";
+#else
+			"Audio timeout - buggy audio driver? (disabled)";
+#endif
+			/* In general we should never print to the screen,
+			   but in this case we have no other way of letting
+			   the user know what happened.
+			*/
+			fprintf(stderr, "SDL: %s\n", message);
+#ifdef AUDIO_OSPACE_HACK
+			/* We may be able to use GET_OSPACE trick */
+			frame_ticks = (float)(this->spec->samples*1000) /
+			                      this->spec->freq;
+			next_frame = SDL_GetTicks()+frame_ticks;
+#else
+			this->enabled = 0;
+			/* Don't try to close - may hang */
+			audio_fd = -1;
+#ifdef DEBUG_AUDIO
+			fprintf(stderr, "Done disabling audio\n");
+#endif
+#endif /* AUDIO_OSPACE_HACK */
+		}
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Ready!\n");
+#endif
+	}
+}
+
+static void DMA_PlayAudio(_THIS)
+{
+	/* If timer synchronization is enabled, set the next write frame */
+	if ( frame_ticks ) {
+		next_frame += frame_ticks;
+	}
+	return;
+}
+
+static Uint8 *DMA_GetAudioBuf(_THIS)
+{
+	count_info info;
+	int playing;
+	int filling;
+
+	/* Get number of blocks, looping if we're not using select() */
+	do {
+		if ( ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &info) < 0 ) {
+			/* Uh oh... */
+			this->enabled = 0;
+			return(NULL);
+		}
+	} while ( frame_ticks && (info.blocks < 1) );
+#ifdef DEBUG_AUDIO
+	if ( info.blocks > 1 ) {
+		printf("Warning: audio underflow (%d frags)\n", info.blocks-1);
+	}
+#endif
+	playing = info.ptr / this->spec.size;
+	filling = (playing + 1)%num_buffers;
+	return (dma_buf + (filling * this->spec.size));
+}
+
+static void DMA_CloseAudio(_THIS)
+{
+	if ( dma_buf != NULL ) {
+		munmap(dma_buf, dma_len);
+		dma_buf = NULL;
+	}
+	if ( audio_fd >= 0 ) {
+		close(audio_fd);
+		audio_fd = -1;
+	}
+}
+
+static int DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo,
+							SDL_AudioSpec *spec)
+{
+	int frag_spec;
+	int value;
+
+	/* Close and then reopen the audio device */
+	close(audio_fd);
+	audio_fd = open(audiodev, O_RDWR, 0);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+		return(-1);
+	}
+	ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Determine the power of two of the fragment size */
+	for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
+	if ( (0x01<<frag_spec) != spec->size ) {
+		SDL_SetError("Fragment size must be a power of two");
+		return(-1);
+	}
+
+	/* Set the audio buffering parameters */
+	if ( ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0 ) {
+		SDL_SetError("Couldn't set audio fragment spec");
+		return(-1);
+	}
+
+	/* Set the audio format */
+	value = format;
+	if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
+						(value != format) ) {
+		SDL_SetError("Couldn't set audio format");
+		return(-1);
+	}
+
+	/* Set mono or stereo audio */
+	value = (spec->channels > 1);
+	if ( (ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) ||
+						(value != stereo) ) {
+		SDL_SetError("Couldn't set audio channels");
+		return(-1);
+	}
+
+	/* Set the DSP frequency */
+	value = spec->freq;
+	if ( ioctl(audio_fd, SOUND_PCM_WRITE_RATE, &value) < 0 ) {
+		SDL_SetError("Couldn't set audio frequency");
+		return(-1);
+	}
+	spec->freq = value;
+
+	/* We successfully re-opened the audio */
+	return(0);
+}
+
+static int DMA_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	char audiodev[1024];
+	int format;
+	int stereo;
+	int value;
+	Uint16 test_format;
+	struct audio_buf_info info;
+
+	/* Reset the timer synchronization flag */
+	frame_ticks = 0.0;
+
+	/* Open the audio device */
+	audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+		return(-1);
+	}
+	dma_buf = NULL;
+	ioctl(audio_fd, SNDCTL_DSP_RESET, 0);
+
+	/* Get a list of supported hardware formats */
+	if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) {
+		SDL_SetError("Couldn't get audio format list");
+		return(-1);
+	}
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) {
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
+#endif
+		switch ( test_format ) {
+			case AUDIO_U8:
+				if ( value & AFMT_U8 ) {
+					format = AFMT_U8;
+				}
+				break;
+			case AUDIO_S8:
+				if ( value & AFMT_S8 ) {
+					format = AFMT_S8;
+				}
+				break;
+			case AUDIO_S16LSB:
+				if ( value & AFMT_S16_LE ) {
+					format = AFMT_S16_LE;
+				}
+				break;
+			case AUDIO_S16MSB:
+				if ( value & AFMT_S16_BE ) {
+					format = AFMT_S16_BE;
+				}
+				break;
+			case AUDIO_U16LSB:
+				if ( value & AFMT_U16_LE ) {
+					format = AFMT_U16_LE;
+				}
+				break;
+			case AUDIO_U16MSB:
+				if ( value & AFMT_U16_BE ) {
+					format = AFMT_U16_BE;
+				}
+				break;
+			default:
+				break;
+		}
+		if ( ! format ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	spec->format = test_format;
+
+	/* Set the audio format */
+	value = format;
+	if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
+						(value != format) ) {
+		SDL_SetError("Couldn't set audio format");
+		return(-1);
+	}
+
+	/* Set mono or stereo audio (currently only two channels supported) */
+	stereo = (spec->channels > 1);
+	ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo);
+	if ( stereo ) {
+		spec->channels = 2;
+	} else {
+		spec->channels = 1;
+	}
+
+	/* Because some drivers don't allow setting the buffer size
+	   after setting the format, we must re-open the audio device
+	   once we know what format and channels are supported
+	 */
+	if ( DMA_ReopenAudio(this, audiodev, format, stereo, spec) < 0 ) {
+		/* Error is set by DMA_ReopenAudio() */
+		return(-1);
+	}
+
+	/* Memory map the audio buffer */
+	if ( ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0 ) {
+		SDL_SetError("Couldn't get OSPACE parameters");
+		return(-1);
+	}
+	spec->size = info.fragsize;
+	spec->samples = spec->size / ((spec->format & 0xFF) / 8);
+	spec->samples /= spec->channels;
+	num_buffers = info.fragstotal;
+	dma_len = num_buffers*spec->size;
+	dma_buf = (Uint8 *)mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED,
+							audio_fd, 0);
+	if ( dma_buf == MAP_FAILED ) {
+		SDL_SetError("DMA memory map failed");
+		dma_buf = NULL;
+		return(-1);
+	}
+	memset(dma_buf, spec->silence, dma_len);
+
+	/* Check to see if we need to use select() workaround */
+	{ char *workaround;
+		workaround = getenv("SDL_DSP_NOSELECT");
+		if ( workaround ) {
+			frame_ticks = (float)(spec->samples*1000)/spec->freq;
+			next_frame = SDL_GetTicks()+frame_ticks;
+		}
+	}
+
+	/* Trigger audio playback */
+	value = 0;
+	ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value);
+	value = PCM_ENABLE_OUTPUT;
+	if ( ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0 ) {
+		SDL_SetError("Couldn't trigger audio output");
+		return(-1);
+	}
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dma/SDL_dmaaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,63 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dspaudio_h
+#define _SDL_dspaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The file descriptor for the audio device */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *dma_buf;
+	int    dma_len;
+	int num_buffers;
+
+	/* Support for audio timing using a timer, in addition to select() */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define dma_buf			(this->hidden->dma_buf)
+#define dma_len			(this->hidden->dma_len)
+#define num_buffers		(this->hidden->num_buffers)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _SDL_dspaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dmedia/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dmedia/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the IRIX DMedia sound driver
+
+noinst_LTLIBRARIES = libaudio_dmedia.la
+libaudio_dmedia_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_irixaudio.c	\
+	SDL_irixaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dmedia/SDL_irixaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,201 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    5635-34 Springhouse Dr.
+    Pleasanton, CA 94588 (USA)
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */
+
+#include <stdlib.h>
+
+#include "SDL_endian.h"
+#include "SDL_timer.h"
+#include "SDL_audio.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_irixaudio.h"
+
+
+/* Audio driver functions */
+static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void AL_WaitAudio(_THIS);
+static void AL_PlayAudio(_THIS);
+static Uint8 *AL_GetAudioBuf(_THIS);
+static void AL_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	return 1;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = AL_OpenAudio;
+	this->WaitAudio = AL_WaitAudio;
+	this->PlayAudio = AL_PlayAudio;
+	this->GetAudioBuf = AL_GetAudioBuf;
+	this->CloseAudio = AL_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap AUDIO_bootstrap = {
+	"AL", "IRIX DMedia audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+
+void static AL_WaitAudio(_THIS)
+{
+	Sint32 timeleft;
+
+	timeleft = this->spec.samples - alGetFillable(audio_port);
+	if ( timeleft > 0 ) {
+		timeleft /= (this->spec.freq/1000);
+		SDL_Delay((Uint32)timeleft);
+	}
+}
+
+static void AL_PlayAudio(_THIS)
+{
+	/* Write the audio data out */
+	if ( alWriteFrames(audio_port, mixbuf, this->spec.samples) < 0 ) {
+		/* Assume fatal error, for now */
+		this->enabled = 0;
+	}
+}
+
+static Uint8 *AL_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+static void AL_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( audio_port != NULL ) {
+		ALcloseport(audio_port);
+		audio_port = NULL;
+	}
+}
+
+static int AL_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	ALconfig audio_config;
+	ALpv audio_param;
+	int width;
+
+	/* Determine the audio parameters from the AudioSpec */
+	switch ( spec->format & 0xFF ) {
+
+		case 8: { /* Signed 8 bit audio data */
+			spec->format = AUDIO_S8;
+			width = AL_SAMPLE_8;
+		}
+		break;
+
+		case 16: { /* Signed 16 bit audio data */
+			spec->format = AUDIO_S16MSB;
+			width = AL_SAMPLE_16;
+		}
+		break;
+
+		default: {
+			SDL_SetError("Unsupported audio format");
+			return(-1);
+		}
+	}
+
+	/* Update the fragment size as size in bytes */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Set output frequency */
+	audio_param.param = AL_RATE;
+	audio_param.value.i = spec->freq;
+	if( alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0 ) {
+		SDL_SetError("alSetParams failed");
+		return(-1);
+	}
+
+	/* Open the audio port with the requested frequency */
+	audio_port = NULL;
+	audio_config = alNewConfig();
+	if ( audio_config &&
+	     (alSetSampFmt(audio_config, AL_SAMPFMT_TWOSCOMP) >= 0) &&
+	     (alSetWidth(audio_config, width) >= 0) &&
+	     (alSetQueueSize(audio_config, spec->samples*2) >= 0) &&
+	     (alSetChannels(audio_config, spec->channels) >= 0) ) {
+		audio_port = ALopenport("SDL audio", "w", audio_config);
+	}
+	alFreeConfig(audio_config);
+	if( audio_port == NULL ) {
+		SDL_SetError("Unable to open audio port");
+		return(-1);
+	}
+
+	/* Allocate mixing buffer */
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(spec->size);
+	if ( mixbuf == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dmedia/SDL_irixaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+#include <dmedia/audio.h>
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the audio functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The handle for the audio device */
+	ALport audio_port;
+
+	Uint8 *mixbuf;           /* The app mixing buffer */
+};
+
+/* Old variable names */
+#define audio_port		(this->hidden->audio_port)
+#define mixbuf			(this->hidden->mixbuf)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dsp/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dsp/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the OSS /dev/dsp standard sound driver
+
+noinst_LTLIBRARIES = libaudio_dsp.la
+libaudio_dsp_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_dspaudio.c	\
+	SDL_dspaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dsp/SDL_dspaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,450 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#ifdef linux
+#include <linux/soundcard.h>
+#endif
+#ifdef __bsdi__
+#include <sys/soundcard.h>
+#endif
+#ifdef __FreeBSD__
+#include <machine/soundcard.h>
+#endif
+#ifdef __USLC__
+#include <sys/soundcard.h>
+#endif
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_dspaudio.h"
+
+/* The tag name used by DSP audio */
+#define DSP_DRIVER_NAME         "dsp"
+
+/* Open the audio device for playback, and don't block if busy */
+/*#define USE_BLOCKING_WRITES*/
+#ifdef USE_BLOCKING_WRITES
+#define OPEN_FLAGS	O_WRONLY
+#else
+#define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
+#endif
+
+/* Audio driver functions */
+static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void DSP_WaitAudio(_THIS);
+static void DSP_PlayAudio(_THIS);
+static Uint8 *DSP_GetAudioBuf(_THIS);
+static void DSP_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	int fd;
+	int available;
+
+	available = 0;
+	fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
+	if ( fd >= 0 ) {
+		available = 1;
+		close(fd);
+	}
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_fd = -1;
+
+	/* Set the function pointers */
+	this->OpenAudio = DSP_OpenAudio;
+	this->WaitAudio = DSP_WaitAudio;
+	this->PlayAudio = DSP_PlayAudio;
+	this->GetAudioBuf = DSP_GetAudioBuf;
+	this->CloseAudio = DSP_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap DSP_bootstrap = {
+	DSP_DRIVER_NAME, "OSS /dev/dsp standard audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void DSP_WaitAudio(_THIS)
+{
+#ifndef USE_BLOCKING_WRITES /* Not necessary because of blocking writes */
+	fd_set fdset;
+
+	/* Check to see if the thread-parent process is still alive */
+	{ static int cnt = 0;
+		/* Note that this only works with thread implementations 
+		   that use a different process id for each thread.
+		*/
+		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
+			if ( kill(parent, 0) < 0 ) {
+				this->enabled = 0;
+			}
+		}
+	}
+
+	/* See if we need to use timed audio synchronization */
+	if ( frame_ticks ) {
+		/* Use timer for general audio synchronization */
+		Sint32 ticks;
+
+		ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+		if ( ticks > 0 ) {
+			SDL_Delay(ticks);
+		}
+	} else {
+		/* Use select() for audio synchronization */
+		struct timeval timeout;
+		FD_ZERO(&fdset);
+		FD_SET(audio_fd, &fdset);
+		timeout.tv_sec = 10;
+		timeout.tv_usec = 0;
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Waiting for audio to get ready\n");
+#endif
+		if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) {
+			const char *message =
+			"Audio timeout - buggy audio driver? (disabled)";
+			/* In general we should never print to the screen,
+			   but in this case we have no other way of letting
+			   the user know what happened.
+			*/
+			fprintf(stderr, "SDL: %s\n", message);
+			this->enabled = 0;
+			/* Don't try to close - may hang */
+			audio_fd = -1;
+#ifdef DEBUG_AUDIO
+			fprintf(stderr, "Done disabling audio\n");
+#endif
+		}
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Ready!\n");
+#endif
+	}
+#endif /* !USE_BLOCKING_WRITES */
+}
+
+static void DSP_PlayAudio(_THIS)
+{
+	int written;
+
+	/* Write the audio data, checking for EAGAIN on broken audio drivers */
+	do {
+		written = write(audio_fd, mixbuf, mixlen);
+		if ( (written < 0) && ((errno == 0) || (errno == EAGAIN)) ) {
+			SDL_Delay(1);	/* Let a little CPU time go by */
+		}
+	} while ( (written < 0) && 
+	          ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)) );
+
+	/* If timer synchronization is enabled, set the next write frame */
+	if ( frame_ticks ) {
+		next_frame += frame_ticks;
+	}
+
+	/* If we couldn't write, assume fatal error for now */
+	if ( written < 0 ) {
+		this->enabled = 0;
+	}
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Wrote %d bytes of audio data\n", written);
+#endif
+}
+
+static Uint8 *DSP_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+static void DSP_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( audio_fd >= 0 ) {
+		close(audio_fd);
+		audio_fd = -1;
+	}
+}
+
+static int DSP_ReopenAudio(_THIS, const char *audiodev, int format,
+						SDL_AudioSpec *spec)
+{
+	int frag_spec;
+	int value;
+
+	/* Close and then reopen the audio device */
+	close(audio_fd);
+	audio_fd = open(audiodev, O_WRONLY, 0);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+		return(-1);
+	}
+
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Determine the power of two of the fragment size */
+	for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
+	if ( (0x01<<frag_spec) != spec->size ) {
+		SDL_SetError("Fragment size must be a power of two");
+		return(-1);
+	}
+	frag_spec |= 0x00020000;	/* two fragments, for low latency */
+
+	/* Set the audio buffering parameters */
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Requesting %d fragments of size %d\n",
+		(frag_spec >> 16), 1<<(frag_spec&0xFFFF));
+#endif
+	if ( ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0 ) {
+		fprintf(stderr, "Warning: Couldn't set audio fragment size\n");
+	}
+#ifdef DEBUG_AUDIO
+	{ audio_buf_info info;
+	  ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info);
+	  fprintf(stderr, "fragments = %d\n", info.fragments);
+	  fprintf(stderr, "fragstotal = %d\n", info.fragstotal);
+	  fprintf(stderr, "fragsize = %d\n", info.fragsize);
+	  fprintf(stderr, "bytes = %d\n", info.bytes);
+	}
+#endif
+
+	/* Set the audio format */
+	value = format;
+	if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
+						(value != format) ) {
+		SDL_SetError("Couldn't set audio format");
+		return(-1);
+	}
+
+	/* Set the number of channels of output */
+	value = spec->channels;
+#ifdef SNDCTL_DSP_CHANNELS
+	if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0 ) {
+#endif
+		value = (spec->channels > 1);
+		ioctl(audio_fd, SNDCTL_DSP_STEREO, &value);
+		value = (value ? 2 : 1);
+#ifdef SNDCTL_DSP_CHANNELS
+	}
+#endif
+	if ( value != spec->channels ) {
+		SDL_SetError("Couldn't set audio channels");
+		return(-1);
+	}
+
+	/* Set the DSP frequency */
+	value = spec->freq;
+	if ( ioctl(audio_fd, SOUND_PCM_WRITE_RATE, &value) < 0 ) {
+		SDL_SetError("Couldn't set audio frequency");
+		return(-1);
+	}
+	spec->freq = value;
+
+	/* We successfully re-opened the audio */
+	return(0);
+}
+
+static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	char audiodev[1024];
+	int format;
+	int value;
+	Uint16 test_format;
+
+	/* Reset the timer synchronization flag */
+	frame_ticks = 0.0;
+
+	/* Open the audio device */
+	audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+		return(-1);
+	}
+	mixbuf = NULL;
+
+	/* Get a list of supported hardware formats */
+	if ( ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0 ) {
+		SDL_SetError("Couldn't get audio format list");
+		return(-1);
+	}
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) {
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
+#endif
+		switch ( test_format ) {
+			case AUDIO_U8:
+				if ( value & AFMT_U8 ) {
+					format = AFMT_U8;
+				}
+				break;
+			case AUDIO_S8:
+				if ( value & AFMT_S8 ) {
+					format = AFMT_S8;
+				}
+				break;
+			case AUDIO_S16LSB:
+				if ( value & AFMT_S16_LE ) {
+					format = AFMT_S16_LE;
+				}
+				break;
+			case AUDIO_S16MSB:
+				if ( value & AFMT_S16_BE ) {
+					format = AFMT_S16_BE;
+				}
+				break;
+			case AUDIO_U16LSB:
+				if ( value & AFMT_U16_LE ) {
+					format = AFMT_U16_LE;
+				}
+				break;
+			case AUDIO_U16MSB:
+				if ( value & AFMT_U16_BE ) {
+					format = AFMT_U16_BE;
+				}
+				break;
+			default:
+				break;
+		}
+		if ( ! format ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	spec->format = test_format;
+
+	/* Set the audio format */
+	value = format;
+	if ( (ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) ||
+						(value != format) ) {
+		SDL_SetError("Couldn't set audio format");
+		return(-1);
+	}
+
+	/* Set the number of channels of output */
+	value = spec->channels;
+#ifdef SNDCTL_DSP_CHANNELS
+	if ( ioctl(audio_fd, SNDCTL_DSP_CHANNELS, &value) < 0 ) {
+#endif
+		value = (spec->channels > 1);
+		ioctl(audio_fd, SNDCTL_DSP_STEREO, &value);
+		value = (value ? 2 : 1);
+#ifdef SNDCTL_DSP_CHANNELS
+	}
+#endif
+	spec->channels = value;
+
+	/* Because some drivers don't allow setting the buffer size
+	   after setting the format, we must re-open the audio device
+	   once we know what format and channels are supported
+	 */
+	if ( DSP_ReopenAudio(this, audiodev, format, spec) < 0 ) {
+		/* Error is set by DSP_ReopenAudio() */
+		return(-1);
+	}
+
+	/* Allocate mixing buffer */
+	mixlen = spec->size;
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
+	if ( mixbuf == NULL ) {
+		return(-1);
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+#ifndef USE_BLOCKING_WRITES
+	/* Check to see if we need to use select() workaround */
+	{ char *workaround;
+		workaround = getenv("SDL_DSP_NOSELECT");
+		if ( workaround ) {
+			frame_ticks = (float)(spec->samples*1000)/spec->freq;
+			next_frame = SDL_GetTicks()+frame_ticks;
+		}
+	}
+#endif /* !USE_BLOCKING_WRITES */
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/dsp/SDL_dspaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dspaudio_h
+#define _SDL_dspaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The file descriptor for the audio device */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+	/* Support for audio timing using a timer, in addition to select() */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define mixbuf			(this->hidden->mixbuf)
+#define mixlen			(this->hidden->mixlen)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _SDL_dspaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/esd/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/esd/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the Enlightened Sound Daemon sound driver
+
+noinst_LTLIBRARIES = libaudio_esd.la
+libaudio_esd_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_esdaudio.c	\
+	SDL_esdaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/esd/SDL_esdaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,260 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to an ESD network stream mixing buffer */
+
+#ifdef ESD_SUPPORT
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include <esd.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_esdaudio.h"
+
+/* The tag name used by ESD audio */
+#define ESD_DRIVER_NAME		"esd"
+
+/* Audio driver functions */
+static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void ESD_WaitAudio(_THIS);
+static void ESD_PlayAudio(_THIS);
+static Uint8 *ESD_GetAudioBuf(_THIS);
+static void ESD_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	int connection;
+	int available;
+
+	available = 0;
+	connection = esd_open_sound(NULL);
+	if ( connection >= 0 ) {
+		available = 1;
+		esd_close(connection);
+	}
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_fd = -1;
+
+	/* Set the function pointers */
+	this->OpenAudio = ESD_OpenAudio;
+	this->WaitAudio = ESD_WaitAudio;
+	this->PlayAudio = ESD_PlayAudio;
+	this->GetAudioBuf = ESD_GetAudioBuf;
+	this->CloseAudio = ESD_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap ESD_bootstrap = {
+	ESD_DRIVER_NAME, "Enlightened Sound Daemon",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void ESD_WaitAudio(_THIS)
+{
+	Sint32 ticks;
+
+	/* Check to see if the thread-parent process is still alive */
+	{ static int cnt = 0;
+		/* Note that this only works with thread implementations 
+		   that use a different process id for each thread.
+		*/
+		if (parent && (((++cnt)%10) == 0)) { /* Check every 10 loops */
+			if ( kill(parent, 0) < 0 ) {
+				this->enabled = 0;
+			}
+		}
+	}
+
+	/* Use timer for general audio synchronization */
+	ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+	if ( ticks > 0 ) {
+		SDL_Delay(ticks);
+	}
+}
+
+static void ESD_PlayAudio(_THIS)
+{
+	int written;
+
+	/* Write the audio data, checking for EAGAIN on broken audio drivers */
+	do {
+		written = write(audio_fd, mixbuf, mixlen);
+		if ( (written < 0) && ((errno == 0) || (errno == EAGAIN)) ) {
+			SDL_Delay(1);	/* Let a little CPU time go by */
+		}
+	} while ( (written < 0) && 
+	          ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)) );
+
+	/* Set the next write frame */
+	next_frame += frame_ticks;
+
+	/* If we couldn't write, assume fatal error for now */
+	if ( written < 0 ) {
+		this->enabled = 0;
+	}
+}
+
+static Uint8 *ESD_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+static void ESD_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( audio_fd >= 0 ) {
+		close(audio_fd);
+		audio_fd = -1;
+	}
+}
+
+/* Try to get the name of the program */
+static char *get_progname(void)
+{
+	char *progname = NULL;
+#ifdef linux
+	FILE *fp;
+	static char temp[BUFSIZ];
+
+	sprintf(temp, "/proc/%d/cmdline", getpid());
+	fp = fopen(temp, "r");
+	if ( fp != NULL ) {
+		if ( fgets(temp, sizeof(temp)-1, fp) ) {
+			progname = strrchr(temp, '/');
+			if ( progname == NULL ) {
+				progname = temp;
+			} else {
+				progname = progname+1;
+			}
+		}
+		fclose(fp);
+	}
+#endif
+	return(progname);
+}
+
+static int ESD_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	esd_format_t format;
+
+	/* Convert audio spec to the ESD audio format */
+	format = (ESD_STREAM | ESD_PLAY);
+	switch ( spec->format & 0xFF ) {
+		case 8:
+			format |= ESD_BITS8;
+			break;
+		case 16:
+			format |= ESD_BITS16;
+			break;
+		default:
+			SDL_SetError("Unsupported ESD audio format");
+			return(-1);
+	}
+	if ( spec->channels == 1 ) {
+		format |= ESD_MONO;
+	} else {
+		format |= ESD_STEREO;
+	}
+#if 0
+	spec->samples = ESD_BUF_SIZE;	/* Darn, no way to change this yet */
+#endif
+
+	/* Open a connection to the ESD audio server */
+	audio_fd = esd_play_stream(format, spec->freq, NULL, get_progname());
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open ESD connection");
+		return(-1);
+	}
+
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+	frame_ticks = (float)(spec->samples*1000)/spec->freq;
+	next_frame = SDL_GetTicks()+frame_ticks;
+
+	/* Allocate mixing buffer */
+	mixlen = spec->size;
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
+	if ( mixbuf == NULL ) {
+		return(-1);
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
+
+#endif /* ESD_SUPPORT */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/esd/SDL_esdaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_esdaudio_h
+#define _SDL_esdaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The file descriptor for the audio device */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+	/* Support for audio timing using a timer */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define mixbuf			(this->hidden->mixbuf)
+#define mixlen			(this->hidden->mixlen)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _SDL_esdaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/macrom/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/macrom/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the MacOS SoundManager audio driver
+
+noinst_LTLIBRARIES = libaudio_macrom.la
+libaudio_macrom_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_romaudio.c	\
+	SDL_romaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/macrom/SDL_romaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,439 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#if TARGET_API_MAC_CARBON
+#  include <Carbon.h>
+#else
+#  include <Sound.h> /* SoundManager interface */
+#  include <Gestalt.h>
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "SDL_endian.h"
+#include "SDL_audio.h"
+#include "SDL_audio_c.h"
+#include "SDL_audiomem.h"
+#include "SDL_sysaudio.h"
+#include "SDL_romaudio.h"
+
+/* Audio driver functions */
+
+static void Mac_CloseAudio(_THIS);
+static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec);
+
+/* Audio driver bootstrap functions */
+
+
+static int Audio_Available(void)
+{
+    return(1);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+    free(device->hidden);
+    free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+    SDL_AudioDevice *this;
+
+    /* Initialize all variables that we clean on shutdown */
+    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+    if ( this ) {
+        memset(this, 0, (sizeof *this));
+        this->hidden = (struct SDL_PrivateAudioData *)
+                malloc((sizeof *this->hidden));
+    }
+    if ( (this == NULL) || (this->hidden == NULL) ) {
+        SDL_OutOfMemory();
+        if ( this ) {
+            free(this);
+        }
+        return(0);
+    }
+    memset(this->hidden, 0, (sizeof *this->hidden));
+
+    /* Set the function pointers */
+    this->OpenAudio   = Mac_OpenAudio;
+    this->CloseAudio  = Mac_CloseAudio;
+    this->free        = Audio_DeleteDevice;
+
+    return this;
+}
+
+AudioBootStrap SNDMGR_bootstrap = {
+	"sndmgr", "MacOS SoundManager 3.0",
+	Audio_Available, Audio_CreateDevice
+};
+
+#if TARGET_API_MAC_CARBON
+
+static UInt8  *buffer[2];
+static volatile UInt32 running = 0;
+static CmpSoundHeader header;
+
+static void callBackProc (SndChannel *chan, SndCommand *cmd_passed ) {
+   
+   UInt32 fill_me, play_me;
+   SndCommand cmd; 
+   SDL_AudioDevice *audio = (SDL_AudioDevice *)chan->userInfo;
+ 
+   fill_me = cmd_passed->param2;  /* buffer that has just finished playing,
+so fill it */      
+   play_me = ! fill_me;           /* filled buffer to play _now_ */
+
+   if ( ! audio->enabled ) {
+      return;
+   }
+   
+   header.samplePtr = (Ptr)buffer[play_me];
+   
+   cmd.cmd = bufferCmd;
+   cmd.param1 = 0; 
+   cmd.param2 = (long)&header;
+   
+    SndDoCommand (chan, &cmd, 0);
+   
+   memset (buffer[fill_me], 0, audio->spec.size);
+   
+   if ( ! audio->paused ) {
+        if ( audio->convert.needed ) {
+            audio->spec.callback(audio->spec.userdata,
+                (Uint8 *)audio->convert.buf,audio->convert.len);
+               SDL_ConvertAudio(&audio->convert);
+#if 0
+            if ( audio->convert.len_cvt != audio->spec.size ) {
+                /* Uh oh... probably crashes here; */
+            }
+#endif
+            memcpy(buffer[fill_me], audio->convert.buf,
+                            audio->convert.len_cvt);
+        } else {
+            audio->spec.callback(audio->spec.userdata,
+                (Uint8 *)buffer[fill_me], audio->spec.size);
+        }
+    }
+    
+    if ( running ) {
+         
+      cmd.cmd = callBackCmd;
+      cmd.param1 = 0;
+      cmd.param2 = play_me;
+   
+      SndDoCommand (chan, &cmd, 0);
+   }
+}
+
+static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec) {
+
+   SndCallBackUPP callback;
+   int sample_bits;
+   int i;
+   long initOptions;
+   
+   /* Very few conversions are required, but... */
+    switch (spec->format) {
+        case AUDIO_S8:
+        spec->format = AUDIO_U8;
+        break;
+        case AUDIO_U16LSB:
+        spec->format = AUDIO_S16LSB;
+        break;
+        case AUDIO_U16MSB:
+        spec->format = AUDIO_S16MSB;
+        break;
+    }
+    SDL_CalculateAudioSpec(spec);
+    
+    /* initialize bufferCmd header */
+    memset (&header, 0, sizeof(header));
+    callback = NewSndCallBackUPP (callBackProc);
+    sample_bits = spec->size / spec->samples / spec->channels * 8;
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr,
+	"Audio format 0x%x, channels = %d, sample_bits = %d, frequency = %d\n",
+	spec->format, spec->channels, sample_bits, spec->freq);
+#endif /* DEBUG_AUDIO */
+    
+    header.numChannels = spec->channels;
+    header.sampleSize  = sample_bits;
+    header.sampleRate  = spec->freq << 16;
+    header.numFrames   = spec->samples;
+    header.encode      = cmpSH;
+    
+    /* Note that we install the 16bitLittleEndian Converter if needed. */
+    if ( spec->format == 0x8010 ) {
+        header.compressionID = fixedCompression;
+        header.format = k16BitLittleEndianFormat;
+    }
+    
+    /* allocate 2 buffers */
+    for (i=0; i<2; i++) {
+       buffer[i] = (UInt8*)malloc (sizeof(UInt8) * spec->size);
+      if (buffer[i] == NULL) {
+         SDL_OutOfMemory();
+         return (-1);
+      }
+     memset (buffer[i], 0, spec->size);
+   }
+   
+   /* Create the sound manager channel */
+    channel = (SndChannelPtr)malloc(sizeof(*channel));
+    if ( channel == NULL ) {
+        SDL_OutOfMemory();
+        return(-1);
+    }
+    if ( spec->channels >= 2 ) {
+        initOptions = initStereo;
+    } else {
+        initOptions = initMono;
+    }
+    channel->userInfo = (long)this;
+    channel->qLength = 128;
+    if ( SndNewChannel(&channel, sampledSynth, initOptions, callback) !=
+noErr ) {
+        SDL_SetError("Unable to create audio channel");
+        free(channel);
+        channel = NULL;
+        return(-1);
+    }
+   
+   /* start playback */
+   {
+      SndCommand cmd;
+      cmd.cmd = callBackCmd;
+      cmd.param2 = 0;
+      running = 1;
+      SndDoCommand (channel, &cmd, 0);
+   }
+   
+   return 1;
+}
+
+static void Mac_CloseAudio(_THIS) {
+   
+   int i;
+   
+   running = 0;
+   
+   if (channel) {
+      SndDisposeChannel (channel, true);
+      channel = NULL;
+   }
+   
+    for ( i=0; i<2; ++i ) {
+        if ( buffer[i] ) {
+            free(buffer[i]);
+            buffer[i] = NULL;
+        }
+    }
+}
+
+#else /* !TARGET_API_MAC_CARBON */
+
+/* This function is called by Sound Manager when it has exhausted one of
+   the buffers, so we'll zero it to silence and fill it with audio if
+   we're not paused.
+*/
+static pascal
+void sndDoubleBackProc (SndChannelPtr chan, SndDoubleBufferPtr newbuf)
+{
+    SDL_AudioDevice *audio = (SDL_AudioDevice *)newbuf->dbUserInfo[0];
+
+    /* If audio is quitting, don't do anything */
+    if ( ! audio->enabled ) {
+        return;
+    }
+    memset (newbuf->dbSoundData, 0, audio->spec.size);
+    newbuf->dbNumFrames = audio->spec.samples;
+    if ( ! audio->paused ) {
+        if ( audio->convert.needed ) {
+            audio->spec.callback(audio->spec.userdata,
+                (Uint8 *)audio->convert.buf,audio->convert.len);
+            SDL_ConvertAudio(&audio->convert);
+#if 0
+            if ( audio->convert.len_cvt != audio->spec.size ) {
+                /* Uh oh... probably crashes here */;
+            }
+#endif
+            memcpy(newbuf->dbSoundData, audio->convert.buf,
+                            audio->convert.len_cvt);
+        } else {
+            audio->spec.callback(audio->spec.userdata,
+                (Uint8 *)newbuf->dbSoundData, audio->spec.size);
+        }
+    }
+    newbuf->dbFlags    |= dbBufferReady;
+}
+
+static int DoubleBufferAudio_Available(void)
+{
+    int available;
+    NumVersion sndversion;
+    long response;
+
+    available = 0;
+    sndversion = SndSoundManagerVersion();
+    if ( sndversion.majorRev >= 3 ) {
+        if ( Gestalt(gestaltSoundAttr, &response) == noErr ) {
+            if ( (response & (1 << gestaltSndPlayDoubleBuffer)) ) {
+                available = 1;
+            }
+        }
+    } else {
+        if ( Gestalt(gestaltSoundAttr, &response) == noErr ) {
+            if ( (response & (1 << gestaltHasASC)) ) {
+                available = 1;
+            }
+        }
+    }
+    return(available);
+}
+
+static void Mac_CloseAudio(_THIS)
+{
+    int i;
+
+    if ( channel != NULL ) {
+#if 0
+        SCStatus status;
+
+        /* Wait for audio to complete */
+        do {
+            SndChannelStatus(channel, sizeof(status), &status);
+        } while ( status.scChannelBusy );
+#endif
+        /* Clean up the audio channel */
+        SndDisposeChannel(channel, true);
+        channel = NULL;
+    }
+    for ( i=0; i<2; ++i ) {
+        if ( audio_buf[i] ) {
+            free(audio_buf[i]);
+            audio_buf[i] = NULL;
+        }
+    }
+}
+
+static int Mac_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+    SndDoubleBufferHeader2 audio_dbh;
+    int i;
+    long initOptions;
+    int sample_bits;
+    SndDoubleBackUPP doubleBackProc;
+
+    /* Check to make sure double-buffered audio is available */
+    if ( ! DoubleBufferAudio_Available() ) {
+        SDL_SetError("Sound manager doesn't support double-buffering");
+        return(-1);
+    }
+
+    /* Very few conversions are required, but... */
+    switch (spec->format) {
+        case AUDIO_S8:
+        spec->format = AUDIO_U8;
+        break;
+        case AUDIO_U16LSB:
+        spec->format = AUDIO_S16LSB;
+        break;
+        case AUDIO_U16MSB:
+        spec->format = AUDIO_S16MSB;
+        break;
+    }
+    SDL_CalculateAudioSpec(spec);
+
+    /* initialize the double-back header */
+    memset(&audio_dbh, 0, sizeof(audio_dbh));
+    doubleBackProc = NewSndDoubleBackProc (sndDoubleBackProc);
+    sample_bits = spec->size / spec->samples / spec->channels * 8;
+    
+    audio_dbh.dbhNumChannels = spec->channels;
+    audio_dbh.dbhSampleSize    = sample_bits;
+    audio_dbh.dbhCompressionID = 0;
+    audio_dbh.dbhPacketSize    = 0;
+    audio_dbh.dbhSampleRate    = spec->freq << 16;
+    audio_dbh.dbhDoubleBack    = doubleBackProc;
+    audio_dbh.dbhFormat    = 0;
+
+    /* Note that we install the 16bitLittleEndian Converter if needed. */
+    if ( spec->format == 0x8010 ) {
+        audio_dbh.dbhCompressionID = fixedCompression;
+        audio_dbh.dbhFormat = k16BitLittleEndianFormat;
+    }
+
+    /* allocate the 2 double-back buffers */
+    for ( i=0; i<2; ++i ) {
+        audio_buf[i] = calloc(1, sizeof(SndDoubleBuffer)+spec->size);
+        if ( audio_buf[i] == NULL ) {
+            SDL_OutOfMemory();
+            return(-1);
+        }
+        audio_buf[i]->dbNumFrames = spec->samples;
+        audio_buf[i]->dbFlags = dbBufferReady;
+        audio_buf[i]->dbUserInfo[0] = (long)this;
+        audio_dbh.dbhBufferPtr[i] = audio_buf[i];
+    }
+
+    /* Create the sound manager channel */
+    channel = (SndChannelPtr)malloc(sizeof(*channel));
+    if ( channel == NULL ) {
+        SDL_OutOfMemory();
+        return(-1);
+    }
+    if ( spec->channels >= 2 ) {
+        initOptions = initStereo;
+    } else {
+        initOptions = initMono;
+    }
+    channel->userInfo = 0;
+    channel->qLength = 128;
+    if ( SndNewChannel(&channel, sampledSynth, initOptions, 0L) != noErr ) {
+        SDL_SetError("Unable to create audio channel");
+        free(channel);
+        channel = NULL;
+        return(-1);
+    }
+ 
+    /* Start playback */
+    if ( SndPlayDoubleBuffer(channel, (SndDoubleBufferHeaderPtr)&audio_dbh)
+                                != noErr ) {
+        SDL_SetError("Unable to play double buffered audio");
+        return(-1);
+    }
+    
+    return 1;
+}
+
+#endif /* TARGET_API_MAC_CARBON */
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/macrom/SDL_romaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_romaudio_h
+#define _SDL_romaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* Sound manager audio channel */
+	SndChannelPtr channel;
+    #if ! TARGET_API_MAC_CARBON
+	/* Double buffering variables */
+	SndDoubleBufferPtr audio_buf[2];
+    #endif
+};
+
+/* Old variable names */
+#define channel		(this->hidden->channel)
+#define audio_buf	(this->hidden->audio_buf)
+
+#endif /* _SDL_romaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nas/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nas/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the Network Audio System sound driver
+
+noinst_LTLIBRARIES = libaudio_nas.la
+libaudio_nas_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_nasaudio.c	\
+	SDL_nasaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nas/SDL_nasaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,308 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+
+    This driver was written by:
+    Erik Inge Bolsø
+    knan@mo.himolde.no
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_nasaudio.h"
+
+/* The tag name used by artsc audio */
+#define NAS_DRIVER_NAME         "nas"
+
+static struct SDL_PrivateAudioData *this2 = NULL;
+
+/* Audio driver functions */
+static int NAS_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void NAS_WaitAudio(_THIS);
+static void NAS_PlayAudio(_THIS);
+static Uint8 *NAS_GetAudioBuf(_THIS);
+static void NAS_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	AuServer *aud = AuOpenServer("", 0, NULL, 0, NULL, NULL);
+	if (!aud) return 0;
+
+	AuCloseServer(aud);
+	return 1;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = NAS_OpenAudio;
+	this->WaitAudio = NAS_WaitAudio;
+	this->PlayAudio = NAS_PlayAudio;
+	this->GetAudioBuf = NAS_GetAudioBuf;
+	this->CloseAudio = NAS_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap NAS_bootstrap = {
+	NAS_DRIVER_NAME, "Network Audio System",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void NAS_WaitAudio(_THIS)
+{
+	while ( this->hidden->buf_free < this->hidden->mixlen ) {
+		AuEvent ev;
+		AuNextEvent(this->hidden->aud, AuTrue, &ev);
+		AuDispatchEvent(this->hidden->aud, &ev);
+	}
+}
+
+static void NAS_PlayAudio(_THIS)
+{
+	while (this->hidden->mixlen > this->hidden->buf_free) { /* We think the buffer is full? Yikes! Ask the server for events,
+				    in the hope that some of them is LowWater events telling us more
+				    of the buffer is free now than what we think. */
+		AuEvent ev;
+		AuNextEvent(this->hidden->aud, AuTrue, &ev);
+		AuDispatchEvent(this->hidden->aud, &ev);
+	}
+	this->hidden->buf_free -= this->hidden->mixlen;
+
+	/* Write the audio data */
+	AuWriteElement(this->hidden->aud, this->hidden->flow, 0, this->hidden->mixlen, this->hidden->mixbuf, AuFalse, NULL);
+
+	this->hidden->written += this->hidden->mixlen;
+	
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Wrote %d bytes of audio data\n", this->hidden->mixlen);
+#endif
+}
+
+static Uint8 *NAS_GetAudioBuf(_THIS)
+{
+	return(this->hidden->mixbuf);
+}
+
+static void NAS_CloseAudio(_THIS)
+{
+	if ( this->hidden->mixbuf != NULL ) {
+		SDL_FreeAudioMem(this->hidden->mixbuf);
+		this->hidden->mixbuf = NULL;
+	}
+	if ( this->hidden->aud ) {
+		AuCloseServer(this->hidden->aud);
+		this->hidden->aud = 0;
+	}
+}
+
+static unsigned char sdlformat_to_auformat(unsigned int fmt)
+{
+  switch (fmt)
+    {
+    case AUDIO_U8:
+      return AuFormatLinearUnsigned8;
+    case AUDIO_S8:
+      return AuFormatLinearSigned8;
+    case AUDIO_U16LSB:
+      return AuFormatLinearUnsigned16LSB;
+    case AUDIO_U16MSB:
+      return AuFormatLinearUnsigned16MSB;
+    case AUDIO_S16LSB:
+      return AuFormatLinearSigned16LSB;
+    case AUDIO_S16MSB:
+      return AuFormatLinearSigned16MSB;
+    }
+  return AuNone;
+}
+
+static AuBool
+event_handler(AuServer* aud, AuEvent* ev, AuEventHandlerRec* hnd)
+{
+	switch (ev->type) {
+	case AuEventTypeElementNotify: {
+		AuElementNotifyEvent* event = (AuElementNotifyEvent *)ev;
+
+		switch (event->kind) {
+		case AuElementNotifyKindLowWater:
+			if (this2->buf_free >= 0) {
+				this2->really += event->num_bytes;
+				gettimeofday(&this2->last_tv, 0);
+				this2->buf_free += event->num_bytes;
+			} else {
+				this2->buf_free = event->num_bytes;
+			}
+			break;
+		case AuElementNotifyKindState:
+			switch (event->cur_state) {
+			case AuStatePause:
+				if (event->reason != AuReasonUser) {
+					if (this2->buf_free >= 0) {
+						this2->really += event->num_bytes;
+						gettimeofday(&this2->last_tv, 0);
+						this2->buf_free += event->num_bytes;
+					} else {
+						this2->buf_free = event->num_bytes;
+					}
+				}
+				break;
+			}
+		}
+	}
+	}
+	return AuTrue;
+}
+
+static AuDeviceID
+find_device(_THIS, int nch)
+{
+	int i;
+	for (i = 0; i < AuServerNumDevices(this->hidden->aud); i++) {
+		if ((AuDeviceKind(AuServerDevice(this->hidden->aud, i)) ==
+				AuComponentKindPhysicalOutput) &&
+			AuDeviceNumTracks(AuServerDevice(this->hidden->aud, i)) == nch) {
+			return AuDeviceIdentifier(AuServerDevice(this->hidden->aud, i));
+		}
+	}
+	return AuNone;
+}
+
+static int NAS_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	AuElement elms[3];
+	int buffer_size;
+	Uint16 test_format, format;
+
+	this->hidden->mixbuf = NULL;
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) {
+		format = sdlformat_to_auformat(test_format);
+
+		if (format == AuNone) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	spec->format = test_format;
+
+	this->hidden->aud = AuOpenServer("", 0, NULL, 0, NULL, NULL);
+	if (this->hidden->aud == 0)
+	{
+		SDL_SetError("Couldn't open connection to NAS server");
+		return (-1);
+	}
+	
+	this->hidden->dev = find_device(this, spec->channels);
+	if ((this->hidden->dev == AuNone) || (!(this->hidden->flow = AuCreateFlow(this->hidden->aud, NULL)))) {
+		AuCloseServer(this->hidden->aud);
+		this->hidden->aud = 0;
+		SDL_SetError("Couldn't find a fitting playback device on NAS server");
+		return (-1);
+	}
+	
+	buffer_size = spec->freq;
+	if (buffer_size < 4096)
+		buffer_size = 4096; 
+
+	if (buffer_size > 32768)
+		buffer_size = 32768; /* So that the buffer won't get unmanageably big. */
+
+	/* Calculate the final parameters for this audio specification */
+	SDL_CalculateAudioSpec(spec);
+
+	this2 = this->hidden;
+
+	AuMakeElementImportClient(elms, spec->freq, format, spec->channels, AuTrue,
+				buffer_size, buffer_size / 4, 0, NULL);
+	AuMakeElementExportDevice(elms+1, 0, this->hidden->dev, spec->freq,
+				AuUnlimitedSamples, 0, NULL);
+	AuSetElements(this->hidden->aud, this->hidden->flow, AuTrue, 2, elms, NULL);
+	AuRegisterEventHandler(this->hidden->aud, AuEventHandlerIDMask, 0, this->hidden->flow,
+				event_handler, (AuPointer) NULL);
+
+	AuStartFlow(this->hidden->aud, this->hidden->flow, NULL);
+
+	/* Allocate mixing buffer */
+	this->hidden->mixlen = spec->size;
+	this->hidden->mixbuf = (Uint8 *)SDL_AllocAudioMem(this->hidden->mixlen);
+	if ( this->hidden->mixbuf == NULL ) {
+		return(-1);
+	}
+	memset(this->hidden->mixbuf, spec->silence, spec->size);
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	this->hidden->parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nas/SDL_nasaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+
+    This driver was written by:
+    Erik Inge Bolsø
+    knan@mo.himolde.no
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_nasaudio_h
+#define _SDL_nasaudio_h
+
+#include <audio/audiolib.h>
+#include <sys/time.h>
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	AuServer*  aud;
+	AuFlowID   flow;
+	AuDeviceID dev;
+	
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+	int written;
+	int really;
+	int bps;
+	struct timeval last_tv;
+	int buf_free;
+};
+#endif /* _SDL_nasaudio_h */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nto/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nto/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the QNX Neutrino PCM audio API
+
+noinst_LTLIBRARIES = libaudio_nto.la
+libaudio_nto_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_nto_audio.c	\
+	SDL_nto_audio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nto/SDL_nto_audio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,554 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sched.h>
+#include <sys/asoundlib.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_nto_audio.h"
+
+/* The tag name used by NTO audio */
+#define DRIVER_NAME         "nto"
+
+/* default card and device numbers as listed in dev/snd */
+static int card_no = 0;
+static int device_no = 0;
+
+/* default channel communication parameters */
+#define DEFAULT_CPARAMS_RATE 22050
+#define DEFAULT_CPARAMS_VOICES 1
+#define DEFAULT_CPARAMS_FRAG_SIZE 4096  //was 512
+#define DEFAULT_CPARAMS_FRAGS_MIN 1
+#define DEFAULT_CPARAMS_FRAGS_MAX -1
+
+/* Open the audio device for playback, and don't block if busy */
+#define OPEN_FLAGS	SND_PCM_OPEN_PLAYBACK
+
+/* Audio driver functions */
+static int NTO_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void NTO_WaitAudio(_THIS);
+static void NTO_PlayAudio(_THIS);
+static Uint8 *NTO_GetAudioBuf(_THIS);
+static void NTO_CloseAudio(_THIS);
+
+static snd_pcm_channel_status_t cstatus;
+static	snd_pcm_channel_params_t cparams;
+static	snd_pcm_channel_setup_t  csetup;
+
+/* PCM transfer channel parameters initialize function */
+static void init_pcm_cparams(snd_pcm_channel_params_t* cparams)
+{
+	memset(cparams,0,sizeof(snd_pcm_channel_params_t));
+
+	cparams->channel = SND_PCM_CHANNEL_PLAYBACK;
+	cparams->mode = SND_PCM_MODE_BLOCK;
+	cparams->start_mode = SND_PCM_START_DATA; //_FULL
+	cparams->stop_mode  = SND_PCM_STOP_STOP;
+	cparams->format.format = SND_PCM_SFMT_S16_LE;
+	cparams->format.interleave = 1;
+	cparams->format.rate = DEFAULT_CPARAMS_RATE;
+	cparams->format.voices = DEFAULT_CPARAMS_VOICES;
+	cparams->buf.block.frag_size = DEFAULT_CPARAMS_FRAG_SIZE;
+	cparams->buf.block.frags_min = DEFAULT_CPARAMS_FRAGS_MIN;
+	cparams->buf.block.frags_max = DEFAULT_CPARAMS_FRAGS_MAX;
+}
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+/*
+	See if we can open a nonblocking channel.
+	Return value '1' means we can.
+	Return value '0' means we cannot.
+*/
+{
+	int available;
+	int rval;
+	snd_pcm_t *handle;
+
+	available = 0;
+	handle = NULL;
+	
+	//JB modified to take advantage of software mixer
+	rval = snd_pcm_open_preferred(&handle, &card_no, &device_no, OPEN_FLAGS);
+
+	if (rval >= 0)
+	{
+			available = 1;
+
+        if ((rval = snd_pcm_close(handle)) < 0)
+        {
+            SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
+			available = 0;
+        }
+	}
+	else
+	{
+	
+       SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
+	}
+	
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"AudioAvailable rtns %d\n", available);
+#endif
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"Audio_DeleteDevice\n");
+#endif
+
+	
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"Audio_CreateDevice\n");
+#endif
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_handle = NULL;
+
+	/* Set the function pointers */
+	this->OpenAudio = NTO_OpenAudio;
+	this->WaitAudio = NTO_WaitAudio;
+	this->PlayAudio = NTO_PlayAudio;
+	this->GetAudioBuf = NTO_GetAudioBuf;
+	this->CloseAudio = NTO_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+/* Don't change the name from "ALSA_bootstrap" - that's how it's called */
+AudioBootStrap ALSA_bootstrap = {
+	DRIVER_NAME, "Neutrino PCM audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void NTO_WaitAudio(_THIS)
+{
+	int rval;
+	int totalbytes,roomavail;
+	/*we consider a full sound buffer to be of size pcm_len bytes */
+	
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"NTO_WaitAudio\n");
+#endif
+
+	while(1)
+	{
+	memset(&cstatus, 0, sizeof(cstatus));
+	 if( (rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0 )
+    {
+		 SDL_SetError("snd_pcm_plugin_status failed: %s\n", snd_strerror(rval));
+   	    return;
+	}	
+	
+	totalbytes = csetup.buf.block.frag_size *csetup.buf.block.frags;
+	roomavail = totalbytes - cstatus.count;
+
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"NTO_WaitAudio roomavail %d pcm_len %d\n",roomavail,pcm_len);
+#endif
+	
+	if ((roomavail >= pcm_len) || (roomavail < 0))
+		return;
+		
+		SDL_Delay(10);	
+	}	
+      
+}
+
+
+
+static void NTO_PlayAudio(_THIS)
+{
+    int written, rval;
+    int towrite;
+
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "NTO_PlayAudio\n");
+#endif
+
+	if( !this->enabled)
+	   return;
+
+	towrite = pcm_len;
+	
+
+    /* Write the audio data, checking for EAGAIN (buffer full) and underrun */
+    do {
+		written = snd_pcm_plugin_write(audio_handle, pcm_buf, towrite);
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "NTO_PlayAudio: written = %d towrite = %d\n",written,towrite);
+#endif
+		if (written != towrite)
+		{
+	        if ((errno == EAGAIN) || (errno == EWOULDBLOCK))
+			{
+            	SDL_Delay(1);   /* Let a little CPU time go by and try to write again */
+#ifdef DEBUG_AUDIO
+				fprintf(stderr, "errno == EAGAIN written %d\n", written);
+				towrite -= written; //we wrote some data
+#endif
+				continue;
+        	}		
+			else if((errno == EINVAL) || (errno == EIO))
+			{
+#ifdef DEBUG_AUDIO
+					if(errno == EIO)
+						fprintf(stderr,"snd_pcm_plugin_write failed EIO: %s\n", snd_strerror(written));	
+					if(errno == EINVAL)
+						fprintf(stderr,"snd_pcm_plugin_write failed EINVAL: %s\n", snd_strerror(written));	
+								
+#endif			
+			
+				  memset(&cstatus, 0, sizeof(cstatus));			
+		         if( (rval = snd_pcm_plugin_status(audio_handle, &cstatus)) < 0 )
+        		 {
+#ifdef DEBUG_AUDIO
+					fprintf(stderr, "snd_pcm_plugin_status failed %s\n",snd_strerror(rval));
+#endif
+		            SDL_SetError("snd_pcm_plugin_status failed: %s\n", snd_strerror(rval));
+        		   return;
+		        }	
+		        
+				if ( (cstatus.status == SND_PCM_STATUS_UNDERRUN) ||
+					(cstatus.status == SND_PCM_STATUS_READY) )
+				{
+#ifdef DEBUG_AUDIO
+					fprintf(stderr, "buffer underrun\n");
+#endif
+					if ( (rval = snd_pcm_plugin_prepare (audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0 )
+					{
+#ifdef DEBUG_AUDIO
+						fprintf(stderr, "NTO_PlayAudio: prepare failed %s\n",snd_strerror(rval));
+#endif
+						SDL_SetError("snd_pcm_plugin_prepare failed: %s\n",snd_strerror(rval) );
+						return;
+					}
+					
+				}		        		
+ 				continue;
+			}
+			else
+			{
+#ifdef DEBUG_AUDIO
+						fprintf(stderr, "NTO_PlayAudio: snd_pcm_plugin_write failed unknown errno %d %s\n",errno, snd_strerror(rval));
+#endif
+				return;
+			
+			}
+			
+		}
+		else
+		{
+			towrite -= written; //we wrote all remaining data
+		}
+    } while ( (towrite > 0)  && (this->enabled) );
+
+    /* If we couldn't write, assume fatal error for now */
+    if ( towrite != 0 ) {
+        this->enabled = 0;
+    }
+	return;
+}
+
+static Uint8 *NTO_GetAudioBuf(_THIS)
+{
+ #ifdef DEBUG_AUDIO
+		fprintf(stderr, "NTO_GetAudioBuf: pcm_buf %X\n",(Uint8 *)pcm_buf);
+#endif
+	return(pcm_buf);
+}
+
+static void NTO_CloseAudio(_THIS)
+{
+	int rval;
+	
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "NTO_CloseAudio\n");
+#endif
+
+	 this->enabled = 0;
+
+	if ( audio_handle != NULL ) {
+		if ((rval = snd_pcm_plugin_flush(audio_handle,SND_PCM_CHANNEL_PLAYBACK)) < 0)
+		{
+        	SDL_SetError("snd_pcm_plugin_flush failed: %s\n",snd_strerror(rval));
+			return;
+		}
+		if ((rval = snd_pcm_close(audio_handle)) < 0)
+		{
+			SDL_SetError("snd_pcm_close failed: %s\n",snd_strerror(rval));
+			return;
+		}
+		audio_handle = NULL;
+	}
+}
+
+static int NTO_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	int rval;
+	int format;
+	Uint16 test_format;
+	int twidth;
+	int found;
+
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "NTO_OpenAudio\n");
+#endif
+	
+	audio_handle = NULL;
+	 this->enabled = 0;
+
+	if ( pcm_buf != NULL ) {
+		free((Uint8 *)pcm_buf); 
+		pcm_buf = NULL;
+	}
+	 
+	/* initialize channel transfer parameters to default */
+	init_pcm_cparams(&cparams);
+
+	/* Open the audio device */
+	
+	rval = snd_pcm_open_preferred(&audio_handle, &card_no, &device_no, OPEN_FLAGS);
+	if ( rval < 0 ) {
+		SDL_SetError("snd_pcm_open failed: %s\n", snd_strerror(rval));
+		return(-1);
+	}
+
+    /* set to nonblocking mode */
+    if ((rval = snd_pcm_nonblock_mode(audio_handle, 1))<0) //I assume 1 means on
+    {
+        SDL_SetError("snd_pcm_nonblock_mode failed: %s\n", snd_strerror(rval));
+        return(-1);
+    }
+
+    /* enable count status parameter */
+    if ((rval = snd_plugin_set_disable(audio_handle, PLUGIN_DISABLE_MMAP))<0)
+    {
+        SDL_SetError("snd_plugin_set_disable failed: %s\n", snd_strerror(rval));
+        return(-1);
+    }
+
+
+	/* Try for a closest match on audio format */
+	format = 0;
+ 	found = 0; // can't use format as SND_PCM_SFMT_U8 = 0 in nto
+	for ( test_format = SDL_FirstAudioFormat(spec->format);	!found ; ) 
+
+	{
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x spec->samples %d\n", test_format,spec->samples);
+#endif
+			/* if match found set format to equivalent ALSA format */
+        switch ( test_format ) {
+			case AUDIO_U8:
+				format = SND_PCM_SFMT_U8;
+				cparams.buf.block.frag_size = spec->samples * spec->channels;
+				found = 1;
+				break;
+			case AUDIO_S8:
+				format = SND_PCM_SFMT_S8;
+				cparams.buf.block.frag_size = spec->samples * spec->channels;
+				found = 1;
+				break;
+			case AUDIO_S16LSB:
+				format = SND_PCM_SFMT_S16_LE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				found = 1;
+				break;
+			case AUDIO_S16MSB:
+				format = SND_PCM_SFMT_S16_BE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				found = 1;
+				break;
+			case AUDIO_U16LSB:
+				format = SND_PCM_SFMT_U16_LE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				found = 1;
+				break;
+			case AUDIO_U16MSB:
+				format = SND_PCM_SFMT_U16_BE;
+				cparams.buf.block.frag_size = spec->samples*2 * spec->channels;
+				found = 1;
+				break;
+			default:
+				break;
+		}
+		if ( ! found ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	
+	/* assumes test_format not 0 on success */
+	if ( test_format == 0 ) {
+		SDL_SetError("Couldn't find any hardware audio formats");
+		return(-1);
+	}
+	
+	spec->format = test_format;
+
+	/* Set the audio format */
+	cparams.format.format = format;
+
+	/* Set mono or stereo audio (currently only two channels supported) */
+	cparams.format.voices = spec->channels;
+	
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"intializing channels %d\n", cparams.format.voices);
+#endif
+
+	
+	/* Set rate */
+	cparams.format.rate = spec->freq ;
+
+	/* Setup the transfer parameters according to cparams */
+	rval = snd_pcm_plugin_params(audio_handle, &cparams);
+	if (rval < 0) {
+		SDL_SetError("snd_pcm_channel_params failed: %s\n", snd_strerror (rval));
+		return(-1);
+	}
+
+    /*  Make sure channel is setup right one last time */
+    memset( &csetup, 0, sizeof( csetup ) );
+    csetup.channel = SND_PCM_CHANNEL_PLAYBACK;
+    if ( snd_pcm_plugin_setup( audio_handle, &csetup ) < 0 )
+    {
+        SDL_SetError("Unable to setup playback channel\n" );
+        return(-1);
+    }
+    else
+    {
+#ifdef DEBUG_AUDIO
+        fprintf(stderr,"requested format: %d\n",cparams.format.format);
+        fprintf(stderr,"requested frag size: %d\n",cparams.buf.block.frag_size);
+        fprintf(stderr,"requested max frags: %d\n\n",cparams.buf.block.frags_max);
+
+        fprintf(stderr,"real format: %d\n", csetup.format.format );
+        fprintf(stderr,"real frag size : %d\n", csetup.buf.block.frag_size );
+		fprintf(stderr,"real max frags : %d\n", csetup.buf.block.frags_max );
+#endif // DEBUG_AUDIO
+    }
+
+
+    /*  Allocate memory to the audio buffer and initialize with silence
+        (Note that buffer size must be a multiple of fragment size, so find closest multiple)
+    */
+    
+    twidth = snd_pcm_format_width(format);
+    if (twidth < 0) {
+        printf("snd_pcm_format_width failed\n");
+        twidth = 0;
+    }
+    
+#ifdef DEBUG_AUDIO
+    fprintf(stderr,"format is %d bits wide\n",twidth);
+#endif      
+    
+    pcm_len = spec->size ;
+    
+  
+#ifdef DEBUG_AUDIO    
+    fprintf(stderr,"pcm_len set to %d\n", pcm_len);
+#endif
+    
+    if (pcm_len == 0)
+    {
+        pcm_len = csetup.buf.block.frag_size;
+    }
+    
+    pcm_buf = (Uint8*)malloc(pcm_len);
+    if (pcm_buf == NULL) {
+        SDL_SetError("pcm_buf malloc failed\n");
+        return(-1);
+    }
+    memset(pcm_buf,spec->silence,pcm_len);
+
+#ifdef DEBUG_AUDIO
+	fprintf(stderr,"pcm_buf malloced and silenced.\n");
+#endif
+
+    /* get the file descriptor */
+    if( (audio_fd = snd_pcm_file_descriptor(audio_handle, SND_PCM_CHANNEL_PLAYBACK)) < 0)
+    {
+       fprintf(stderr, "snd_pcm_file_descriptor failed with error code: %d\n", audio_fd);
+    }
+
+	/* Trigger audio playback */
+	rval = snd_pcm_plugin_prepare( audio_handle, SND_PCM_CHANNEL_PLAYBACK);
+	if (rval < 0) {
+       SDL_SetError("snd_pcm_plugin_prepare failed: %s\n", snd_strerror (rval));
+       return(-1);
+	}
+	
+	 this->enabled = 1;
+	 
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/nto/SDL_nto_audio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,55 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifndef _NTO_PCM_audio_h
+#define _NTO_PCM_audio_h
+
+#include "SDL_sysaudio.h"
+#include <sys/asoundlib.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The audio device handle */
+	 snd_pcm_t *audio_handle;
+
+	/* The audio file descriptor */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *pcm_buf;
+	int    pcm_len;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_handle	(this->hidden->audio_handle)
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define pcm_buf			(this->hidden->pcm_buf)
+#define pcm_len			(this->hidden->pcm_len)
+
+#endif /* _NTO_PCM_audio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/paudio/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/paudio/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the AIX PAudio sound driver
+
+noinst_LTLIBRARIES = libaudio_paudio.la
+libaudio_paudio_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_paudio.c	\
+	SDL_paudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/paudio/SDL_paudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,519 @@
+/*
+    AIX support for the SDL - Simple DirectMedia Layer
+    Copyright (C) 2000  Carsten Griwodz
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Carsten Griwodz
+    griff@kom.tu-darmstadt.de
+
+    based on linux/SDL_dspaudio.c by Sam Lantinga
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audiomem.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_paudio.h"
+
+#define DEBUG_AUDIO 1
+
+/* A conflict within AIX 4.3.3 <sys/> headers and probably others as well.
+ * I guess nobody ever uses audio... Shame over AIX header files.  */
+#include <sys/machine.h>
+#undef BIG_ENDIAN
+#include <sys/audio.h>
+
+/* The tag name used by paud audio */
+#define Paud_DRIVER_NAME         "paud"
+
+/* Open the audio device for playback, and don't block if busy */
+/* #define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK) */
+#define OPEN_FLAGS	O_WRONLY
+
+/* Audio driver functions */
+static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void Paud_WaitAudio(_THIS);
+static void Paud_PlayAudio(_THIS);
+static Uint8 *Paud_GetAudioBuf(_THIS);
+static void Paud_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	int fd;
+	int available;
+
+	available = 0;
+	fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 0);
+	if ( fd >= 0 ) {
+		available = 1;
+		close(fd);
+	}
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_fd = -1;
+
+	/* Set the function pointers */
+	this->OpenAudio = Paud_OpenAudio;
+	this->WaitAudio = Paud_WaitAudio;
+	this->PlayAudio = Paud_PlayAudio;
+	this->GetAudioBuf = Paud_GetAudioBuf;
+	this->CloseAudio = Paud_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap Paud_bootstrap = {
+	Paud_DRIVER_NAME, "AIX Paudio",
+	Audio_Available, Audio_CreateDevice
+};
+
+/* This function waits until it is possible to write a full sound buffer */
+static void Paud_WaitAudio(_THIS)
+{
+    fd_set fdset;
+
+    /* See if we need to use timed audio synchronization */
+    if ( frame_ticks ) {
+        /* Use timer for general audio synchronization */
+        Sint32 ticks;
+
+        ticks = ((Sint32)(next_frame - SDL_GetTicks()))-FUDGE_TICKS;
+        if ( ticks > 0 ) {
+	    SDL_Delay(ticks);
+        }
+    } else {
+        audio_buffer  paud_bufinfo;
+
+        /* Use select() for audio synchronization */
+        struct timeval timeout;
+        FD_ZERO(&fdset);
+        FD_SET(audio_fd, &fdset);
+
+        if ( ioctl(audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0 ) {
+#ifdef DEBUG_AUDIO
+            fprintf(stderr, "Couldn't get audio buffer information\n");
+#endif
+            timeout.tv_sec  = 10;
+            timeout.tv_usec = 0;
+        } else {
+	    long ms_in_buf = paud_bufinfo.write_buf_time;
+            timeout.tv_sec  = ms_in_buf/1000;
+	    ms_in_buf       = ms_in_buf - timeout.tv_sec*1000;
+            timeout.tv_usec = ms_in_buf*1000;
+#ifdef DEBUG_AUDIO
+            fprintf( stderr,
+		     "Waiting for write_buf_time=%ld,%ld\n",
+		     timeout.tv_sec,
+		     timeout.tv_usec );
+#endif
+	}
+
+#ifdef DEBUG_AUDIO
+        fprintf(stderr, "Waiting for audio to get ready\n");
+#endif
+        if ( select(audio_fd+1, NULL, &fdset, NULL, &timeout) <= 0 ) {
+            const char *message = "Audio timeout - buggy audio driver? (disabled)";
+            /*
+	     * In general we should never print to the screen,
+             * but in this case we have no other way of letting
+             * the user know what happened.
+             */
+            fprintf(stderr, "SDL: %s - %s\n", strerror(errno), message);
+            this->enabled = 0;
+            /* Don't try to close - may hang */
+            audio_fd = -1;
+#ifdef DEBUG_AUDIO
+            fprintf(stderr, "Done disabling audio\n");
+#endif
+        }
+#ifdef DEBUG_AUDIO
+        fprintf(stderr, "Ready!\n");
+#endif
+    }
+}
+
+static void Paud_PlayAudio(_THIS)
+{
+	int written;
+
+	/* Write the audio data, checking for EAGAIN on broken audio drivers */
+	do {
+		written = write(audio_fd, mixbuf, mixlen);
+		if ( (written < 0) && ((errno == 0) || (errno == EAGAIN)) ) {
+			SDL_Delay(1);	/* Let a little CPU time go by */
+		}
+	} while ( (written < 0) && 
+	          ((errno == 0) || (errno == EAGAIN) || (errno == EINTR)) );
+
+	/* If timer synchronization is enabled, set the next write frame */
+	if ( frame_ticks ) {
+		next_frame += frame_ticks;
+	}
+
+	/* If we couldn't write, assume fatal error for now */
+	if ( written < 0 ) {
+		this->enabled = 0;
+	}
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Wrote %d bytes of audio data\n", written);
+#endif
+}
+
+static Uint8 *Paud_GetAudioBuf(_THIS)
+{
+	return mixbuf;
+}
+
+static void Paud_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( audio_fd >= 0 ) {
+		close(audio_fd);
+		audio_fd = -1;
+	}
+}
+
+static int Paud_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	char          audiodev[1024];
+	int           format;
+	int           bytes_per_sample;
+	Uint16        test_format;
+	audio_init    paud_init;
+	audio_buffer  paud_bufinfo;
+	audio_status  paud_status;
+	audio_control paud_control;
+	audio_change  paud_change;
+
+	/* Reset the timer synchronization flag */
+	frame_ticks = 0.0;
+
+	/* Open the audio device */
+	audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 0);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+		return -1;
+	}
+
+	/*
+	 * We can't set the buffer size - just ask the device for the maximum
+	 * that we can have.
+	 */
+	if ( ioctl(audio_fd, AUDIO_BUFFER, &paud_bufinfo) < 0 ) {
+		SDL_SetError("Couldn't get audio buffer information");
+		return -1;
+	}
+
+	mixbuf = NULL;
+
+	if ( spec->channels > 1 )
+	    spec->channels = 2;
+	else
+	    spec->channels = 1;
+
+	/*
+	 * Fields in the audio_init structure:
+	 *
+	 * Ignored by us:
+	 *
+	 * paud.loadpath[LOAD_PATH]; * DSP code to load, MWave chip only?
+	 * paud.slot_number;         * slot number of the adapter
+	 * paud.device_id;           * adapter identification number
+	 *
+	 * Input:
+	 *
+	 * paud.srate;           * the sampling rate in Hz
+	 * paud.bits_per_sample; * 8, 16, 32, ...
+	 * paud.bsize;           * block size for this rate
+	 * paud.mode;            * ADPCM, PCM, MU_LAW, A_LAW, SOURCE_MIX
+	 * paud.channels;        * 1=mono, 2=stereo
+	 * paud.flags;           * FIXED - fixed length data
+	 *                       * LEFT_ALIGNED, RIGHT_ALIGNED (var len only)
+	 *                       * TWOS_COMPLEMENT - 2's complement data
+	 *                       * SIGNED - signed? comment seems wrong in sys/audio.h
+	 *                       * BIG_ENDIAN
+	 * paud.operation;       * PLAY, RECORD
+	 *
+	 * Output:
+	 *
+	 * paud.flags;           * PITCH            - pitch is supported
+	 *                       * INPUT            - input is supported
+	 *                       * OUTPUT           - output is supported
+	 *                       * MONITOR          - monitor is supported
+	 *                       * VOLUME           - volume is supported
+	 *                       * VOLUME_DELAY     - volume delay is supported
+	 *                       * BALANCE          - balance is supported
+	 *                       * BALANCE_DELAY    - balance delay is supported
+	 *                       * TREBLE           - treble control is supported
+	 *                       * BASS             - bass control is supported
+	 *                       * BESTFIT_PROVIDED - best fit returned
+	 *                       * LOAD_CODE        - DSP load needed
+	 * paud.rc;              * NO_PLAY         - DSP code can't do play requests
+	 *                       * NO_RECORD       - DSP code can't do record requests
+	 *                       * INVALID_REQUEST - request was invalid
+	 *                       * CONFLICT        - conflict with open's flags
+	 *                       * OVERLOADED      - out of DSP MIPS or memory
+	 * paud.position_resolution; * smallest increment for position
+	 */
+
+        paud_init.srate = spec->freq;
+	paud_init.mode = PCM;
+	paud_init.operation = PLAY;
+	paud_init.channels = spec->channels;
+
+	/* Try for a closest match on audio format */
+	format = 0;
+	for ( test_format = SDL_FirstAudioFormat(spec->format);
+						! format && test_format; ) {
+#ifdef DEBUG_AUDIO
+		fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
+#endif
+		switch ( test_format ) {
+			case AUDIO_U8:
+			    bytes_per_sample = 1;
+			    paud_init.bits_per_sample = 8;
+			    paud_init.flags = TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			case AUDIO_S8:
+			    bytes_per_sample = 1;
+			    paud_init.bits_per_sample = 8;
+			    paud_init.flags = SIGNED |
+					      TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			case AUDIO_S16LSB:
+			    bytes_per_sample = 2;
+			    paud_init.bits_per_sample = 16;
+			    paud_init.flags = SIGNED |
+					      TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			case AUDIO_S16MSB:
+			    bytes_per_sample = 2;
+			    paud_init.bits_per_sample = 16;
+			    paud_init.flags = BIG_ENDIAN |
+					      SIGNED |
+					      TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			case AUDIO_U16LSB:
+			    bytes_per_sample = 2;
+			    paud_init.bits_per_sample = 16;
+			    paud_init.flags = TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			case AUDIO_U16MSB:
+			    bytes_per_sample = 2;
+			    paud_init.bits_per_sample = 16;
+			    paud_init.flags = BIG_ENDIAN |
+					      TWOS_COMPLEMENT | FIXED;
+			    format = 1;
+			    break;
+			default:
+				break;
+		}
+		if ( ! format ) {
+			test_format = SDL_NextAudioFormat();
+		}
+	}
+	if ( format == 0 ) {
+#ifdef DEBUG_AUDIO
+            fprintf(stderr, "Couldn't find any hardware audio formats\n");
+#endif
+	    SDL_SetError("Couldn't find any hardware audio formats");
+	    return -1;
+	}
+	spec->format = test_format;
+
+	/*
+	 * We know the buffer size and the max number of subsequent writes
+	 * that can be pending. If more than one can pend, allow the application
+	 * to do something like double buffering between our write buffer and
+	 * the device's own buffer that we are filling with write() anyway.
+	 *
+	 * We calculate spec->samples like this because SDL_CalculateAudioSpec()
+	 * will give put paud_bufinfo.write_buf_cap (or paud_bufinfo.write_buf_cap/2)
+	 * into spec->size in return.
+	 */
+	if ( paud_bufinfo.request_buf_cap == 1 )
+	{
+	    spec->samples = paud_bufinfo.write_buf_cap
+			  / bytes_per_sample
+			  / spec->channels;
+	}
+	else
+	{
+	    spec->samples = paud_bufinfo.write_buf_cap
+			  / bytes_per_sample
+			  / spec->channels
+			  / 2;
+	}
+        paud_init.bsize = bytes_per_sample * spec->channels;
+
+	SDL_CalculateAudioSpec(spec);
+
+	/*
+	 * The AIX paud device init can't modify the values of the audio_init
+	 * structure that we pass to it. So we don't need any recalculation
+	 * of this stuff and no reinit call as in linux dsp and dma code.
+	 *
+	 * /dev/paud supports all of the encoding formats, so we don't need
+	 * to do anything like reopening the device, either.
+	 */
+	if ( ioctl(audio_fd, AUDIO_INIT, &paud_init) < 0 ) {
+	    switch ( paud_init.rc )
+	    {
+	    case 1 :
+		SDL_SetError("Couldn't set audio format: DSP can't do play requests");
+		return -1;
+		break;
+	    case 2 :
+		SDL_SetError("Couldn't set audio format: DSP can't do record requests");
+		return -1;
+		break;
+	    case 4 :
+		SDL_SetError("Couldn't set audio format: request was invalid");
+		return -1;
+		break;
+	    case 5 :
+		SDL_SetError("Couldn't set audio format: conflict with open's flags");
+		return -1;
+		break;
+	    case 6 :
+		SDL_SetError("Couldn't set audio format: out of DSP MIPS or memory");
+		return -1;
+		break;
+	    default :
+		SDL_SetError("Couldn't set audio format: not documented in sys/audio.h");
+		return -1;
+		break;
+	    }
+	}
+
+	/* Allocate mixing buffer */
+	mixlen = spec->size;
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(mixlen);
+	if ( mixbuf == NULL ) {
+		return -1;
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+	/*
+	 * Set some paramters: full volume, first speaker that we can find.
+	 * Ignore the other settings for now.
+	 */
+	paud_change.input = AUDIO_IGNORE;         /* the new input source */
+        paud_change.output = OUTPUT_1;            /* EXTERNAL_SPEAKER,INTERNAL_SPEAKER,OUTPUT_1 */
+        paud_change.monitor = AUDIO_IGNORE;       /* the new monitor state */
+        paud_change.volume = 0x7fffffff;          /* volume level [0-0x7fffffff] */
+        paud_change.volume_delay = AUDIO_IGNORE;  /* the new volume delay */
+        paud_change.balance = 0x3fffffff;         /* the new balance */
+        paud_change.balance_delay = AUDIO_IGNORE; /* the new balance delay */
+        paud_change.treble = AUDIO_IGNORE;        /* the new treble state */
+        paud_change.bass = AUDIO_IGNORE;          /* the new bass state */
+        paud_change.pitch = AUDIO_IGNORE;         /* the new pitch state */
+
+	paud_control.ioctl_request = AUDIO_CHANGE;
+	paud_control.request_info = (char*)&paud_change;
+	if ( ioctl(audio_fd, AUDIO_CONTROL, &paud_control) < 0 ) {
+#ifdef DEBUG_AUDIO
+            fprintf(stderr, "Can't change audio display settings\n" );
+#endif
+	}
+
+	/*
+	 * Tell the device to expect data. Actual start will wait for
+	 * the first write() call.
+	 */
+	paud_control.ioctl_request = AUDIO_START;
+	paud_control.position = 0;
+	if ( ioctl(audio_fd, AUDIO_CONTROL, &paud_control) < 0 ) {
+#ifdef DEBUG_AUDIO
+            fprintf(stderr, "Can't start audio play\n" );
+#endif
+	    SDL_SetError("Can't start audio play");
+	    return -1;
+	}
+
+        /* Check to see if we need to use select() workaround */
+        { char *workaround;
+                workaround = getenv("SDL_DSP_NOSELECT");
+                if ( workaround ) {
+                        frame_ticks = (float)(spec->samples*1000)/spec->freq;
+                        next_frame = SDL_GetTicks()+frame_ticks;
+                }
+        }
+
+	/* Get the parent process id (we're the parent of the audio thread) */
+	parent = getpid();
+
+	/* We're ready to rock and roll. :-) */
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/paudio/SDL_paudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,61 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_paudaudio_h
+#define _SDL_paudaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The file descriptor for the audio device */
+	int audio_fd;
+
+	/* The parent process id, to detect when application quits */
+	pid_t parent;
+
+	/* Raw mixing buffer */
+	Uint8 *mixbuf;
+	int    mixlen;
+
+	/* Support for audio timing using a timer, in addition to select() */
+	float frame_ticks;
+	float next_frame;
+};
+#define FUDGE_TICKS	10	/* The scheduler overhead ticks per frame */
+
+/* Old variable names */
+#define audio_fd		(this->hidden->audio_fd)
+#define parent			(this->hidden->parent)
+#define mixbuf			(this->hidden->mixbuf)
+#define mixlen			(this->hidden->mixlen)
+#define frame_ticks		(this->hidden->frame_ticks)
+#define next_frame		(this->hidden->next_frame)
+
+#endif /* _SDL_paudaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/sun/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/sun/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the UNIX /dev/audio sound driver
+
+noinst_LTLIBRARIES = libaudio_sun.la
+libaudio_sun_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_sunaudio.c	\
+	SDL_sunaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/sun/SDL_sunaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,439 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <string.h>
+#ifdef __NetBSD__
+#include <sys/ioctl.h>
+#include <sys/audioio.h>
+#endif
+#ifdef __SVR4
+#include <sys/audioio.h>
+#else
+#include <sys/time.h>
+#include <sys/types.h>
+#endif
+#include <unistd.h>
+
+#include "SDL_endian.h"
+#include "SDL_audio.h"
+#include "SDL_audiomem.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_sunaudio.h"
+#include "SDL_audio_c.h"
+#include "SDL_timer.h"
+
+/* Open the audio device for playback, and don't block if busy */
+#define OPEN_FLAGS	(O_WRONLY|O_NONBLOCK)
+
+/* Audio driver functions */
+static int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void DSP_WaitAudio(_THIS);
+static void DSP_PlayAudio(_THIS);
+static Uint8 *DSP_GetAudioBuf(_THIS);
+static void DSP_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	int fd;
+	int available;
+
+	available = 0;
+	fd = SDL_OpenAudioPath(NULL, 0, OPEN_FLAGS, 1);
+	if ( fd >= 0 ) {
+		available = 1;
+		close(fd);
+	}
+	return(available);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	audio_fd = -1;
+
+	/* Set the function pointers */
+	this->OpenAudio = DSP_OpenAudio;
+	this->WaitAudio = DSP_WaitAudio;
+	this->PlayAudio = DSP_PlayAudio;
+	this->GetAudioBuf = DSP_GetAudioBuf;
+	this->CloseAudio = DSP_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap AUDIO_bootstrap = {
+	"audio", "UNIX /dev/audio interface",
+	Audio_Available, Audio_CreateDevice
+};
+
+#ifdef DEBUG_AUDIO
+void CheckUnderflow(_THIS)
+{
+#ifdef AUDIO_GETINFO
+	audio_info_t info;
+	int left;
+
+	ioctl(audio_fd, AUDIO_GETINFO, &info);
+	left = (written - info.play.samples);
+	if ( written && (left == 0) ) {
+		fprintf(stderr, "audio underflow!\n");
+	}
+#endif
+}
+#endif
+
+void DSP_WaitAudio(_THIS)
+{
+#ifdef AUDIO_GETINFO
+#define SLEEP_FUDGE	10		/* 10 ms scheduling fudge factor */
+	audio_info_t info;
+	Sint32 left;
+
+	ioctl(audio_fd, AUDIO_GETINFO, &info);
+	left = (written - info.play.samples);
+	if ( left > fragsize ) {
+		Sint32 sleepy;
+
+		sleepy = ((left - fragsize)/frequency);
+		sleepy -= SLEEP_FUDGE;
+		if ( sleepy > 0 ) {
+			SDL_Delay(sleepy);
+		}
+	}
+#else
+	fd_set fdset;
+
+	FD_ZERO(&fdset);
+	FD_SET(audio_fd, &fdset);
+	select(audio_fd+1, NULL, &fdset, NULL, NULL);
+#endif
+}
+
+void DSP_PlayAudio(_THIS)
+{
+	static Uint8 snd2au(int sample);
+	/* Write the audio data */
+	if ( ulaw_only ) {
+		/* Assuming that this->spec.freq >= 8000 Hz */
+		int accum, incr, pos;
+		Uint8 *aubuf;
+
+		accum = 0;
+		incr  = this->spec.freq/8;
+		aubuf = ulaw_buf;
+		switch (audio_fmt & 0xFF) {
+			case 8: {
+				Uint8 *sndbuf;
+
+				sndbuf = mixbuf;
+				for ( pos=0; pos < fragsize; ++pos ) {
+					*aubuf = snd2au((0x80-*sndbuf)*64);
+					accum += incr;
+					while ( accum > 0 ) {
+						accum -= 1000;
+						sndbuf += 1;
+					}
+					aubuf += 1;
+				}
+			}
+			break;
+			case 16: {
+				Sint16 *sndbuf;
+
+				sndbuf = (Sint16 *)mixbuf;
+				for ( pos=0; pos < fragsize; ++pos ) {
+					*aubuf = snd2au(*sndbuf/4);
+					accum += incr;
+					while ( accum > 0 ) {
+						accum -= 1000;
+						sndbuf += 1;
+					}
+					aubuf += 1;
+				}
+			}
+			break;
+		}
+#ifdef DEBUG_AUDIO
+		CheckUnderflow(this);
+#endif
+		if ( write(audio_fd, ulaw_buf, fragsize) < 0 ) {
+			/* Assume fatal error, for now */
+			this->enabled = 0;
+		}
+		written += fragsize;
+	} else {
+#ifdef DEBUG_AUDIO
+		CheckUnderflow(this);
+#endif
+		if ( write(audio_fd, mixbuf, this->spec.size) < 0 ) {
+			/* Assume fatal error, for now */
+			this->enabled = 0;
+		}
+		written += fragsize;
+	}
+}
+
+Uint8 *DSP_GetAudioBuf(_THIS)
+{
+	return(mixbuf);
+}
+
+void DSP_CloseAudio(_THIS)
+{
+	if ( mixbuf != NULL ) {
+		SDL_FreeAudioMem(mixbuf);
+		mixbuf = NULL;
+	}
+	if ( ulaw_buf != NULL ) {
+		free(ulaw_buf);
+		ulaw_buf = NULL;
+	}
+	close(audio_fd);
+}
+
+int DSP_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	char audiodev[1024];
+#ifdef AUDIO_SETINFO
+	int enc;
+#endif
+	int desired_freq = spec->freq;
+
+	/* Initialize our freeable variables, in case we fail*/
+	audio_fd = -1;
+	mixbuf = NULL;
+	ulaw_buf = NULL;
+
+	/* Determine the audio parameters from the AudioSpec */
+	switch ( spec->format & 0xFF ) {
+
+		case 8: { /* Unsigned 8 bit audio data */
+			spec->format = AUDIO_U8;
+#ifdef AUDIO_SETINFO
+			enc = AUDIO_ENCODING_LINEAR8;
+#endif
+		}
+		break;
+
+		case 16: { /* Signed 16 bit audio data */
+		        spec->format = AUDIO_S16SYS;
+#ifdef AUDIO_SETINFO
+			enc = AUDIO_ENCODING_LINEAR;
+#endif
+		}
+		break;
+
+		default: {
+			SDL_SetError("Unsupported audio format");
+			return(-1);
+		}
+	}
+	audio_fmt = spec->format;
+
+	/* Open the audio device */
+	audio_fd = SDL_OpenAudioPath(audiodev, sizeof(audiodev), OPEN_FLAGS, 1);
+	if ( audio_fd < 0 ) {
+		SDL_SetError("Couldn't open %s: %s", audiodev,
+			     strerror(errno));
+		return(-1);
+	}
+
+	ulaw_only = 0;		/* modern Suns do support linear audio */
+#ifdef AUDIO_SETINFO
+	for(;;) {
+	    audio_info_t info;
+	    AUDIO_INITINFO(&info); /* init all fields to "no change" */
+
+	    /* Try to set the requested settings */
+	    info.play.sample_rate = spec->freq;
+	    info.play.channels = spec->channels;
+	    info.play.precision = (enc == AUDIO_ENCODING_ULAW)
+		                  ? 8 : spec->format & 0xff;
+	    info.play.encoding = enc;
+	    if( ioctl(audio_fd, AUDIO_SETINFO, &info) == 0 ) {
+
+		/* Check to be sure we got what we wanted */
+		if(ioctl(audio_fd, AUDIO_GETINFO, &info) < 0) {
+		    SDL_SetError("Error getting audio parameters: %s",
+				 strerror(errno));
+		    return -1;
+		}
+		if(info.play.encoding == enc
+		   && info.play.precision == (spec->format & 0xff)
+		   && info.play.channels == spec->channels) {
+		    /* Yow! All seems to be well! */
+		    spec->freq = info.play.sample_rate;
+		    break;
+		}
+	    }
+
+	    switch(enc) {
+	    case AUDIO_ENCODING_LINEAR8:
+		/* unsigned 8bit apparently not supported here */
+		enc = AUDIO_ENCODING_LINEAR;
+		spec->format = AUDIO_S16SYS;
+		break;	/* try again */
+
+	    case AUDIO_ENCODING_LINEAR:
+		/* linear 16bit didn't work either, resort to µ-law */
+		enc = AUDIO_ENCODING_ULAW;
+		spec->channels = 1;
+		spec->freq = 8000;
+		spec->format = AUDIO_U8;
+		ulaw_only = 1;
+		break;
+
+	    default:
+		/* oh well... */
+		SDL_SetError("Error setting audio parameters: %s",
+			     strerror(errno));
+		return -1;
+	    }
+	}
+#endif /* AUDIO_SETINFO */
+	written = 0;
+
+	/* We can actually convert on-the-fly to U-Law */
+	if ( ulaw_only ) {
+	        spec->freq = desired_freq;
+		fragsize = (spec->samples*1000)/(spec->freq/8);
+		frequency = 8;
+		ulaw_buf = (Uint8 *)malloc(fragsize);
+		if ( ulaw_buf == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		spec->channels = 1;
+	} else {
+		fragsize = spec->samples;
+		frequency = spec->freq/1000;
+	}
+#ifdef DEBUG_AUDIO
+	fprintf(stderr, "Audio device %s U-Law only\n", 
+				ulaw_only ? "is" : "is not");
+	fprintf(stderr, "format=0x%x chan=%d freq=%d\n",
+		spec->format, spec->channels, spec->freq);
+#endif
+
+	/* Update the fragment size as size in bytes */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Allocate mixing buffer */
+	mixbuf = (Uint8 *)SDL_AllocAudioMem(spec->size);
+	if ( mixbuf == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	memset(mixbuf, spec->silence, spec->size);
+
+	/* We're ready to rock and roll. :-) */
+	return(0);
+}
+
+/************************************************************************/
+/* This function (snd2au()) copyrighted:                                */
+/************************************************************************/
+/*      Copyright 1989 by Rich Gopstein and Harris Corporation          */
+/*                                                                      */
+/*      Permission to use, copy, modify, and distribute this software   */
+/*      and its documentation for any purpose and without fee is        */
+/*      hereby granted, provided that the above copyright notice        */
+/*      appears in all copies and that both that copyright notice and   */
+/*      this permission notice appear in supporting documentation, and  */
+/*      that the name of Rich Gopstein and Harris Corporation not be    */
+/*      used in advertising or publicity pertaining to distribution     */
+/*      of the software without specific, written prior permission.     */
+/*      Rich Gopstein and Harris Corporation make no representations    */
+/*      about the suitability of this software for any purpose.  It     */
+/*      provided "as is" without express or implied warranty.           */
+/************************************************************************/
+
+static Uint8 snd2au(int sample)
+{
+
+	int mask;
+
+	if (sample < 0) {
+		sample = -sample;
+		mask = 0x7f;
+	} else {
+		mask = 0xff;
+	}
+
+	if (sample < 32) {
+		sample = 0xF0 | (15 - sample / 2);
+	} else if (sample < 96) {
+		sample = 0xE0 | (15 - (sample - 32) / 4);
+	} else if (sample < 224) {
+		sample = 0xD0 | (15 - (sample - 96) / 8);
+	} else if (sample < 480) {
+		sample = 0xC0 | (15 - (sample - 224) / 16);
+	} else if (sample < 992) {
+		sample = 0xB0 | (15 - (sample - 480) / 32);
+	} else if (sample < 2016) {
+		sample = 0xA0 | (15 - (sample - 992) / 64);
+	} else if (sample < 4064) {
+		sample = 0x90 | (15 - (sample - 2016) / 128);
+	} else if (sample < 8160) {
+		sample = 0x80 | (15 - (sample - 4064) /  256);
+	} else {
+		sample = 0x80;
+	}
+	return (mask & sample);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/sun/SDL_sunaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,59 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData {
+	/* The file descriptor for the audio device */
+	int audio_fd;
+
+	Uint16 audio_fmt;        /* The app audio format */
+	Uint8 *mixbuf;           /* The app mixing buffer */
+	int ulaw_only;           /* Flag -- does hardware only output U-law? */
+	Uint8 *ulaw_buf;         /* The U-law mixing buffer */
+	Sint32 written;          /* The number of samples written */
+	int fragsize;            /* The audio fragment size in samples */
+	int frequency;           /* The audio frequency in KHz */
+};
+
+/* Old variable names */
+#define audio_fd		(this->hidden->audio_fd)
+#define audio_fmt		(this->hidden->audio_fmt)
+#define mixbuf			(this->hidden->mixbuf)
+#define ulaw_only		(this->hidden->ulaw_only)
+#define ulaw_buf		(this->hidden->ulaw_buf)
+#define written			(this->hidden->written)
+#define fragsize		(this->hidden->fragsize)
+#define frequency		(this->hidden->frequency)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/ums/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/ums/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the AIX UMS sound driver
+
+noinst_LTLIBRARIES = libaudio_ums.la
+libaudio_ums_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_umsaudio.c	\
+	SDL_umsaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/ums/SDL_umsaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,555 @@
+/*
+    AIX support for the SDL - Simple DirectMedia Layer
+    Copyright (C) 2000  Carsten Griwodz
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Carsten Griwodz
+    griff@kom.tu-darmstadt.de
+
+    based on linux/SDL_dspaudio.c by Sam Lantinga
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+
+#include "SDL_audio.h"
+#include "SDL_error.h"
+#include "SDL_audio_c.h"
+#include "SDL_audiodev_c.h"
+#include "SDL_umsaudio.h"
+
+/* The tag name used by UMS audio */
+#define UMS_DRIVER_NAME         "ums"
+
+#define DEBUG_AUDIO 1
+
+/* Audio driver functions */
+static int UMS_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void UMS_PlayAudio(_THIS);
+static Uint8 *UMS_GetAudioBuf(_THIS);
+static void UMS_CloseAudio(_THIS);
+
+static UMSAudioDevice_ReturnCode UADOpen(_THIS,  string device, string mode, long flags);
+static UMSAudioDevice_ReturnCode UADClose(_THIS);
+static UMSAudioDevice_ReturnCode UADGetBitsPerSample(_THIS, long* bits);
+static UMSAudioDevice_ReturnCode UADSetBitsPerSample(_THIS, long bits);
+static UMSAudioDevice_ReturnCode UADSetSampleRate(_THIS, long rate, long* set_rate);
+static UMSAudioDevice_ReturnCode UADSetByteOrder(_THIS, string byte_order);
+static UMSAudioDevice_ReturnCode UADSetAudioFormatType(_THIS, string fmt);
+static UMSAudioDevice_ReturnCode UADSetNumberFormat(_THIS, string fmt);
+static UMSAudioDevice_ReturnCode UADInitialize(_THIS);
+static UMSAudioDevice_ReturnCode UADStart(_THIS);
+static UMSAudioDevice_ReturnCode UADStop(_THIS);
+static UMSAudioDevice_ReturnCode UADSetTimeFormat(_THIS,  UMSAudioTypes_TimeFormat fmt );
+static UMSAudioDevice_ReturnCode UADWriteBuffSize(_THIS,  long* buff_size );
+static UMSAudioDevice_ReturnCode UADWriteBuffRemain(_THIS,  long* buff_size );
+static UMSAudioDevice_ReturnCode UADWriteBuffUsed(_THIS,  long* buff_size );
+static UMSAudioDevice_ReturnCode UADSetDMABufferSize(_THIS,  long bytes, long* bytes_ret );
+static UMSAudioDevice_ReturnCode UADSetVolume(_THIS,  long volume );
+static UMSAudioDevice_ReturnCode UADSetBalance(_THIS,  long balance );
+static UMSAudioDevice_ReturnCode UADSetChannels(_THIS,  long channels );
+static UMSAudioDevice_ReturnCode UADPlayRemainingData(_THIS,  boolean block );
+static UMSAudioDevice_ReturnCode UADEnableOutput(_THIS,  string output, long* left_gain, long* right_gain);
+static UMSAudioDevice_ReturnCode UADWrite(_THIS,  UMSAudioTypes_Buffer* buff, long samples, long* samples_written);
+
+/* Audio driver bootstrap functions */
+static int Audio_Available(void)
+{
+    return 1;
+}
+
+static void Audio_DeleteDevice(_THIS)
+{
+    if(this->hidden->playbuf._buffer) free(this->hidden->playbuf._buffer);
+    if(this->hidden->fillbuf._buffer) free(this->hidden->fillbuf._buffer);
+    _somFree( this->hidden->umsdev );
+    free(this->hidden);
+    free(this);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+    SDL_AudioDevice *this;
+
+    /*
+     * Allocate and initialize management storage and private management
+     * storage for this SDL-using library.
+     */
+    this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+    if ( this ) {
+        memset(this, 0, (sizeof *this));
+        this->hidden = (struct SDL_PrivateAudioData *)malloc((sizeof *this->hidden));
+    }
+    if ( (this == NULL) || (this->hidden == NULL) ) {
+        SDL_OutOfMemory();
+        if ( this ) {
+            free(this);
+        }
+        return(0);
+    }
+    memset(this->hidden, 0, (sizeof *this->hidden));
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "Creating UMS Audio device\n");
+#endif
+
+    /*
+     * Calls for UMS env initialization and audio object construction.
+     */
+    this->hidden->ev     = somGetGlobalEnvironment();
+    this->hidden->umsdev = UMSAudioDeviceNew();
+
+    /*
+     * Set the function pointers.
+     */
+    this->OpenAudio   = UMS_OpenAudio;
+    this->WaitAudio   = NULL;           /* we do blocking output */
+    this->PlayAudio   = UMS_PlayAudio;
+    this->GetAudioBuf = UMS_GetAudioBuf;
+    this->CloseAudio  = UMS_CloseAudio;
+    this->free        = Audio_DeleteDevice;
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "done\n");
+#endif
+    return this;
+}
+
+AudioBootStrap UMS_bootstrap = {
+	UMS_DRIVER_NAME, "AUX UMS audio",
+	Audio_Available, Audio_CreateDevice
+};
+
+static Uint8 *UMS_GetAudioBuf(_THIS)
+{
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "enter UMS_GetAudioBuf\n");
+#endif
+    return this->hidden->fillbuf._buffer;
+/*
+    long                      bufSize;
+    UMSAudioDevice_ReturnCode rc;
+
+    rc = UADSetTimeFormat(this, UMSAudioTypes_Bytes );
+    rc = UADWriteBuffSize(this,  bufSize );
+*/
+}
+
+static void UMS_CloseAudio(_THIS)
+{
+    UMSAudioDevice_ReturnCode rc;
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "enter UMS_CloseAudio\n");
+#endif
+    rc = UADPlayRemainingData(this, TRUE);
+    rc = UADStop(this);
+    rc = UADClose(this);
+}
+
+static void UMS_PlayAudio(_THIS)
+{
+    UMSAudioDevice_ReturnCode rc;
+    long                      samplesToWrite;
+    long                      samplesWritten;
+    UMSAudioTypes_Buffer      swpbuf;
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "enter UMS_PlayAudio\n");
+#endif
+    samplesToWrite = this->hidden->playbuf._length/this->hidden->bytesPerSample;
+    do
+    {
+        rc = UADWrite(this,  &this->hidden->playbuf,
+		       samplesToWrite,
+	               &samplesWritten );
+	samplesToWrite -= samplesWritten;
+
+	/* rc values: UMSAudioDevice_Success
+	 *            UMSAudioDevice_Failure
+	 *            UMSAudioDevice_Preempted
+	 *            UMSAudioDevice_Interrupted
+	 *            UMSAudioDevice_DeviceError
+	 */
+	if ( rc == UMSAudioDevice_DeviceError ) {
+#ifdef DEBUG_AUDIO
+	    fprintf(stderr, "Returning from PlayAudio with devices error\n");
+#endif
+	    return;
+	}
+    }
+    while(samplesToWrite>0);
+
+    SDL_LockAudio();
+    memcpy( &swpbuf,                &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer) );
+    memcpy( &this->hidden->playbuf, &this->hidden->fillbuf, sizeof(UMSAudioTypes_Buffer) );
+    memcpy( &this->hidden->fillbuf, &swpbuf,                sizeof(UMSAudioTypes_Buffer) );
+    SDL_UnlockAudio();
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "Wrote audio data and swapped buffer\n");
+#endif
+}
+
+#if 0
+// 	/* Set the DSP frequency */
+// 	value = spec->freq;
+// 	if ( ioctl(this->hidden->audio_fd, SOUND_PCM_WRITE_RATE, &value) < 0 ) {
+// 		SDL_SetError("Couldn't set audio frequency");
+// 		return(-1);
+// 	}
+// 	spec->freq = value;
+#endif
+
+static int UMS_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+    char*  audiodev = "/dev/paud0";
+    long   lgain;
+    long   rgain;
+    long   outRate;
+    long   outBufSize;
+    long   bitsPerSample;
+    long   samplesPerSec;
+    long   success;
+    Uint16 test_format;
+    int    frag_spec;
+    UMSAudioDevice_ReturnCode rc;
+
+#ifdef DEBUG_AUDIO
+    fprintf(stderr, "enter UMS_OpenAudio\n");
+#endif
+    rc = UADOpen(this, audiodev,"PLAY", UMSAudioDevice_BlockingIO);
+    if ( rc != UMSAudioDevice_Success ) {
+	SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno));
+	return -1;
+    }
+ 
+    rc = UADSetAudioFormatType(this, "PCM"); 
+
+    success = 0;
+    test_format = SDL_FirstAudioFormat(spec->format);
+    do
+    {
+#ifdef DEBUG_AUDIO
+        fprintf(stderr, "Trying format 0x%4.4x\n", test_format);
+#endif
+        switch ( test_format )
+        {
+        case AUDIO_U8:
+/* from the mac code: better ? */
+/* sample_bits = spec->size / spec->samples / spec->channels * 8; */
+	    success       = 1;
+            bitsPerSample = 8;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "MSB");       /* irrelevant */
+            rc = UADSetNumberFormat(this, "UNSIGNED");
+            break;
+        case AUDIO_S8:
+	    success       = 1;
+            bitsPerSample = 8;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "MSB");       /* irrelevant */
+            rc = UADSetNumberFormat(this, "SIGNED");
+            break;
+        case AUDIO_S16LSB:
+	    success       = 1;
+            bitsPerSample = 16;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "LSB");
+            rc = UADSetNumberFormat(this, "SIGNED");
+            break;
+        case AUDIO_S16MSB:
+	    success       = 1;
+            bitsPerSample = 16;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "MSB");
+            rc = UADSetNumberFormat(this, "SIGNED");
+            break;
+        case AUDIO_U16LSB:
+	    success       = 1;
+            bitsPerSample = 16;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "LSB");
+            rc = UADSetNumberFormat(this, "UNSIGNED");
+            break;
+        case AUDIO_U16MSB:
+	    success       = 1;
+            bitsPerSample = 16;
+            rc = UADSetSampleRate(this,  spec->freq << 16, &outRate );
+            rc = UADSetByteOrder(this, "MSB");
+            rc = UADSetNumberFormat(this, "UNSIGNED");
+            break;
+        default:
+            break;
+        }
+        if ( ! success ) {
+            test_format = SDL_NextAudioFormat();
+        }
+    }
+    while ( ! success && test_format );
+
+    if ( success == 0 ) {
+        SDL_SetError("Couldn't find any hardware audio formats");
+        return -1;
+    }
+
+    spec->format = test_format;
+
+    for ( frag_spec = 0; (0x01<<frag_spec) < spec->size; ++frag_spec );
+    if ( (0x01<<frag_spec) != spec->size ) {
+        SDL_SetError("Fragment size must be a power of two");
+        return -1;
+    }
+    if ( frag_spec > 2048 ) frag_spec = 2048;
+
+    this->hidden->bytesPerSample   = (bitsPerSample / 8) * spec->channels;
+    samplesPerSec                  = this->hidden->bytesPerSample * outRate;
+
+    this->hidden->playbuf._length  = 0;
+    this->hidden->playbuf._maximum = spec->size;
+    this->hidden->playbuf._buffer  = (unsigned char*)malloc(spec->size);
+    this->hidden->fillbuf._length  = 0;
+    this->hidden->fillbuf._maximum = spec->size;
+    this->hidden->fillbuf._buffer  = (unsigned char*)malloc(spec->size);
+
+    rc = UADSetBitsPerSample(this,  bitsPerSample );
+    rc = UADSetDMABufferSize(this,  frag_spec, &outBufSize );
+    rc = UADSetChannels(this, spec->channels);      /* functions reduces to mono or stereo */
+
+    lgain = 100; /*maximum left input gain*/
+    rgain = 100; /*maimum right input gain*/
+    rc = UADEnableOutput(this, "LINE_OUT",&lgain,&rgain);
+    rc = UADInitialize(this);
+    rc = UADStart(this);
+    rc = UADSetVolume(this, 100);
+    rc = UADSetBalance(this, 0);
+
+    /* We're ready to rock and roll. :-) */
+    return 0;
+}
+
+
+static UMSAudioDevice_ReturnCode UADGetBitsPerSample(_THIS, long* bits)
+{
+    return UMSAudioDevice_get_bits_per_sample( this->hidden->umsdev,
+					       this->hidden->ev,
+					       bits );
+}
+
+static UMSAudioDevice_ReturnCode UADSetBitsPerSample(_THIS, long bits)
+{
+    return UMSAudioDevice_set_bits_per_sample( this->hidden->umsdev,
+					       this->hidden->ev,
+					       bits );
+}
+
+static UMSAudioDevice_ReturnCode UADSetSampleRate(_THIS, long rate, long* set_rate)
+{
+    /* from the mac code: sample rate = spec->freq << 16; */
+    return UMSAudioDevice_set_sample_rate( this->hidden->umsdev,
+					   this->hidden->ev,
+					   rate,
+					   set_rate );
+}
+
+static UMSAudioDevice_ReturnCode UADSetByteOrder(_THIS, string byte_order)
+{
+    return UMSAudioDevice_set_byte_order( this->hidden->umsdev,
+					  this->hidden->ev,
+					  byte_order );
+}
+
+static UMSAudioDevice_ReturnCode UADSetAudioFormatType(_THIS, string fmt)
+{
+    /* possible PCM, A_LAW or MU_LAW */
+    return UMSAudioDevice_set_audio_format_type( this->hidden->umsdev,
+						 this->hidden->ev,
+						 fmt );
+}
+
+static UMSAudioDevice_ReturnCode UADSetNumberFormat(_THIS, string fmt)
+{
+    /* possible SIGNED, UNSIGNED, or TWOS_COMPLEMENT */
+    return UMSAudioDevice_set_number_format( this->hidden->umsdev,
+					     this->hidden->ev,
+					     fmt );
+}
+
+static UMSAudioDevice_ReturnCode UADInitialize(_THIS)
+{
+    return UMSAudioDevice_initialize( this->hidden->umsdev,
+				      this->hidden->ev );
+}
+
+static UMSAudioDevice_ReturnCode UADStart(_THIS)
+{
+    return UMSAudioDevice_start( this->hidden->umsdev,
+				 this->hidden->ev );
+}
+
+static UMSAudioDevice_ReturnCode UADSetTimeFormat(_THIS,  UMSAudioTypes_TimeFormat fmt )
+{
+    /*
+     * Switches the time format to the new format, immediately.
+     * possible UMSAudioTypes_Msecs, UMSAudioTypes_Bytes or UMSAudioTypes_Samples
+     */
+    return UMSAudioDevice_set_time_format( this->hidden->umsdev,
+					   this->hidden->ev,
+					   fmt );
+}
+
+static UMSAudioDevice_ReturnCode UADWriteBuffSize(_THIS,  long* buff_size )
+{
+    /*
+     * returns write buffer size in the current time format
+     */
+    return UMSAudioDevice_write_buff_size( this->hidden->umsdev,
+                                           this->hidden->ev,
+					   buff_size );
+}
+
+static UMSAudioDevice_ReturnCode UADWriteBuffRemain(_THIS,  long* buff_size )
+{
+    /*
+     * returns amount of available space in the write buffer
+     * in the current time format
+     */
+    return UMSAudioDevice_write_buff_remain( this->hidden->umsdev,
+                                             this->hidden->ev,
+					     buff_size );
+}
+
+static UMSAudioDevice_ReturnCode UADWriteBuffUsed(_THIS,  long* buff_size )
+{
+    /*
+     * returns amount of filled space in the write buffer
+     * in the current time format
+     */
+    return UMSAudioDevice_write_buff_used( this->hidden->umsdev,
+                                           this->hidden->ev,
+					   buff_size );
+}
+
+static UMSAudioDevice_ReturnCode UADSetDMABufferSize(_THIS,  long bytes, long* bytes_ret )
+{
+    /*
+     * Request a new DMA buffer size, maximum requested size 2048.
+     * Takes effect with next initialize() call.
+     * Devices may or may not support DMA.
+     */
+    return UMSAudioDevice_set_DMA_buffer_size( this->hidden->umsdev,
+					       this->hidden->ev,
+					       bytes,
+					       bytes_ret );
+}
+
+static UMSAudioDevice_ReturnCode UADSetVolume(_THIS,  long volume )
+{
+    /*
+     * Set the volume.
+     * Takes effect immediately.
+     */
+    return UMSAudioDevice_set_volume( this->hidden->umsdev,
+				      this->hidden->ev,
+				      volume );
+}
+
+static UMSAudioDevice_ReturnCode UADSetBalance(_THIS,  long balance )
+{
+    /*
+     * Set the balance.
+     * Takes effect immediately.
+     */
+    return UMSAudioDevice_set_balance( this->hidden->umsdev,
+				       this->hidden->ev,
+				       balance );
+}
+
+static UMSAudioDevice_ReturnCode UADSetChannels(_THIS,  long channels )
+{
+    /*
+     * Set mono or stereo.
+     * Takes effect with next initialize() call.
+     */
+    if ( channels != 1 ) channels = 2;
+    return UMSAudioDevice_set_number_of_channels( this->hidden->umsdev,
+				                  this->hidden->ev,
+				                  channels );
+}
+
+static UMSAudioDevice_ReturnCode UADOpen(_THIS,  string device, string mode, long flags)
+{
+    return UMSAudioDevice_open( this->hidden->umsdev,
+				this->hidden->ev,
+				device,
+				mode,
+				flags );
+}
+
+static UMSAudioDevice_ReturnCode UADWrite(_THIS,  UMSAudioTypes_Buffer* buff,
+                                           long samples,
+					   long* samples_written)
+{
+    return UMSAudioDevice_write( this->hidden->umsdev,
+				 this->hidden->ev,
+				 buff,
+				 samples,
+				 samples_written );
+}
+
+static UMSAudioDevice_ReturnCode UADPlayRemainingData(_THIS,  boolean block )
+{
+    return UMSAudioDevice_play_remaining_data( this->hidden->umsdev,
+					       this->hidden->ev,
+					       block);
+}
+
+static UMSAudioDevice_ReturnCode UADStop(_THIS)
+{
+    return UMSAudioDevice_stop( this->hidden->umsdev,
+				this->hidden->ev );
+}
+
+static UMSAudioDevice_ReturnCode UADClose(_THIS)
+{
+    return UMSAudioDevice_close( this->hidden->umsdev,
+				 this->hidden->ev );
+}
+
+static UMSAudioDevice_ReturnCode UADEnableOutput(_THIS,  string output, long* left_gain, long* right_gain)
+{
+    return UMSAudioDevice_enable_output( this->hidden->umsdev,
+					 this->hidden->ev,
+					 output,
+					 left_gain,
+					 right_gain );
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/ums/SDL_umsaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,54 @@
+/*
+    AIX support for the SDL - Simple DirectMedia Layer
+    Copyright (C) 2000  Carsten Griwodz
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Carsten Griwodz
+    griff@kom.tu-darmstadt.de
+
+    based on linux/SDL_dspaudio.h by Sam Lantinga
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_UMSaudio_h
+#define _SDL_UMSaudio_h
+
+#include "SDL_sysaudio.h"
+
+#include <UMS/UMSAudioDevice.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+struct SDL_PrivateAudioData
+{
+    /* Pointer to the (open) UMS audio device */
+    Environment*   ev;
+    UMSAudioDevice umsdev;
+
+    /* Raw mixing buffer */
+    UMSAudioTypes_Buffer playbuf;
+    UMSAudioTypes_Buffer fillbuf;
+
+    long bytesPerSample;
+};
+
+#endif /* _SDL_UMSaudio_h */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windib/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windib/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the Win32 WaveOut audio driver
+
+noinst_LTLIBRARIES = libaudio_windib.la
+libaudio_windib_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_dibaudio.c	\
+	SDL_dibaudio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windib/SDL_dibaudio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,298 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+#include <mmsystem.h>
+
+#include "SDL_audio.h"
+#include "SDL_mutex.h"
+#include "SDL_timer.h"
+#include "SDL_audio_c.h"
+#include "SDL_dibaudio.h"
+
+
+/* Audio driver functions */
+static int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void DIB_ThreadInit(_THIS);
+static void DIB_WaitAudio(_THIS);
+static Uint8 *DIB_GetAudioBuf(_THIS);
+static void DIB_PlayAudio(_THIS);
+static void DIB_WaitDone(_THIS);
+static void DIB_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	return(1);
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = DIB_OpenAudio;
+	this->ThreadInit = DIB_ThreadInit;
+	this->WaitAudio = DIB_WaitAudio;
+	this->PlayAudio = DIB_PlayAudio;
+	this->GetAudioBuf = DIB_GetAudioBuf;
+	this->WaitDone = DIB_WaitDone;
+	this->CloseAudio = DIB_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap WAVEOUT_bootstrap = {
+	"waveout", "Win95/98/NT/2000 WaveOut",
+	Audio_Available, Audio_CreateDevice
+};
+
+
+/* The Win32 callback for filling the WAVE device */
+static void CALLBACK FillSound(HWAVEOUT hwo, UINT uMsg, DWORD dwInstance,
+						DWORD dwParam1, DWORD dwParam2)
+{
+	SDL_AudioDevice *this = (SDL_AudioDevice *)dwInstance;
+
+	/* Only service "buffer done playing" messages */
+	if ( uMsg != WOM_DONE )
+		return;
+
+	/* Signal that we are done playing a buffer */
+	ReleaseSemaphore(audio_sem, 1, NULL);
+}
+
+static void SetMMerror(char *function, MMRESULT code)
+{
+	int len;
+	char errbuf[MAXERRORLENGTH];
+
+	sprintf(errbuf, "%s: ", function);
+	len = strlen(errbuf);
+	waveOutGetErrorText(code, errbuf+len, MAXERRORLENGTH-len);
+	SDL_SetError("%s", errbuf);
+}
+
+/* Set high priority for the audio thread */
+static void DIB_ThreadInit(_THIS)
+{
+	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+}
+
+void DIB_WaitAudio(_THIS)
+{
+	/* Wait for an audio chunk to finish */
+	WaitForSingleObject(audio_sem, INFINITE);
+}
+
+Uint8 *DIB_GetAudioBuf(_THIS)
+{
+        Uint8 *retval;
+
+	retval = (Uint8 *)(wavebuf[next_buffer].lpData);
+	return retval;
+}
+
+void DIB_PlayAudio(_THIS)
+{
+	/* Queue it up */
+	waveOutWrite(sound, &wavebuf[next_buffer], sizeof(wavebuf[0]));
+	next_buffer = (next_buffer+1)%NUM_BUFFERS;
+}
+
+void DIB_WaitDone(_THIS)
+{
+	int i, left;
+
+	do {
+		left = NUM_BUFFERS;
+		for ( i=0; i<NUM_BUFFERS; ++i ) {
+			if ( wavebuf[i].dwFlags & WHDR_DONE ) {
+				--left;
+			}
+		}
+		if ( left > 0 ) {
+			SDL_Delay(100);
+		}
+	} while ( left > 0 );
+}
+
+void DIB_CloseAudio(_THIS)
+{
+	int i;
+
+	/* Close up audio */
+	if ( audio_sem ) {
+		CloseHandle(audio_sem);
+	}
+	if ( sound ) {
+		waveOutClose(sound);
+	}
+
+	/* Clean up mixing buffers */
+	for ( i=0; i<NUM_BUFFERS; ++i ) {
+		if ( wavebuf[i].dwUser != 0xFFFF ) {
+			waveOutUnprepareHeader(sound, &wavebuf[i],
+						sizeof(wavebuf[i]));
+			wavebuf[i].dwUser = 0xFFFF;
+		}
+	}
+	/* Free raw mixing buffer */
+	if ( mixbuf != NULL ) {
+		free(mixbuf);
+		mixbuf = NULL;
+	}
+}
+
+int DIB_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	MMRESULT result;
+	int i;
+	WAVEFORMATEX waveformat;
+
+	/* Initialize the wavebuf structures for closing */
+	sound = NULL;
+	audio_sem = NULL;
+	for ( i = 0; i < NUM_BUFFERS; ++i )
+		wavebuf[i].dwUser = 0xFFFF;
+	mixbuf = NULL;
+
+	/* Set basic WAVE format parameters */
+	memset(&waveformat, 0, sizeof(waveformat));
+	waveformat.wFormatTag = WAVE_FORMAT_PCM;
+
+	/* Determine the audio parameters from the AudioSpec */
+	switch ( spec->format & 0xFF ) {
+		case 8:
+			/* Unsigned 8 bit audio data */
+			spec->format = AUDIO_U8;
+			waveformat.wBitsPerSample = 8;
+			break;
+		case 16:
+			/* Signed 16 bit audio data */
+			spec->format = AUDIO_S16;
+			waveformat.wBitsPerSample = 16;
+			break;
+		default:
+			SDL_SetError("Unsupported audio format");
+			return(-1);
+	}
+	waveformat.nChannels = spec->channels;
+	waveformat.nSamplesPerSec = spec->freq;
+	waveformat.nBlockAlign =
+		waveformat.nChannels * (waveformat.wBitsPerSample/8);
+	waveformat.nAvgBytesPerSec = 
+		waveformat.nSamplesPerSec * waveformat.nBlockAlign;
+
+	/* Check the buffer size -- minimum of 1/4 second (word aligned) */
+	if ( spec->samples < (spec->freq/4) )
+		spec->samples = ((spec->freq/4)+3)&~3;
+
+	/* Update the fragment size as size in bytes */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Open the audio device */
+	result = waveOutOpen(&sound, WAVE_MAPPER, &waveformat,
+			(DWORD)FillSound, (DWORD)this, CALLBACK_FUNCTION);
+	if ( result != MMSYSERR_NOERROR ) {
+		SetMMerror("waveOutOpen()", result);
+		return(-1);
+	}
+
+#ifdef SOUND_DEBUG
+	/* Check the sound device we retrieved */
+	{
+		WAVEOUTCAPS caps;
+
+		result = waveOutGetDevCaps((UINT)sound, &caps, sizeof(caps));
+		if ( result != MMSYSERR_NOERROR ) {
+			SetMMerror("waveOutGetDevCaps()", result);
+			return(-1);
+		}
+		printf("Audio device: %s\n", caps.szPname);
+	}
+#endif
+
+	/* Create the audio buffer semaphore */
+	audio_sem = CreateSemaphore(NULL, NUM_BUFFERS-1, NUM_BUFFERS, NULL);
+	if ( audio_sem == NULL ) {
+		SDL_SetError("Couldn't create semaphore");
+		return(-1);
+	}
+
+	/* Create the sound buffers */
+	mixbuf = (Uint8 *)malloc(NUM_BUFFERS*spec->size);
+	if ( mixbuf == NULL ) {
+		SDL_SetError("Out of memory");
+		return(-1);
+	}
+	for ( i = 0; i < NUM_BUFFERS; ++i ) {
+		memset(&wavebuf[i], 0, sizeof(wavebuf[i]));
+		wavebuf[i].lpData = (LPSTR) &mixbuf[i*spec->size];
+		wavebuf[i].dwBufferLength = spec->size;
+		wavebuf[i].dwFlags = WHDR_DONE;
+		result = waveOutPrepareHeader(sound, &wavebuf[i],
+							sizeof(wavebuf[i]));
+		if ( result != MMSYSERR_NOERROR ) {
+			SetMMerror("waveOutPrepareHeader()", result);
+			return(-1);
+		}
+	}
+
+	/* Ready to go! */
+	next_buffer = 0;
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windib/SDL_dibaudio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,53 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+#define NUM_BUFFERS 2			/* -- Don't lower this! */
+
+struct SDL_PrivateAudioData {
+	HWAVEOUT sound;
+	HANDLE audio_sem;
+	Uint8 *mixbuf;		/* The raw allocated mixing buffer */
+	WAVEHDR wavebuf[NUM_BUFFERS];	/* Wave audio fragments */
+	int next_buffer;
+};
+
+/* Old variable names */
+#define sound			(this->hidden->sound)
+#define audio_sem 		(this->hidden->audio_sem)
+#define mixbuf			(this->hidden->mixbuf)
+#define wavebuf			(this->hidden->wavebuf)
+#define next_buffer		(this->hidden->next_buffer)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windx5/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windx5/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+
+## Makefile.am for SDL using the Win32 DirectX audio driver
+
+noinst_LTLIBRARIES = libaudio_windx5.la
+libaudio_windx5_la_SOURCES = $(SRCS)
+
+# The SDL audio driver sources
+SRCS =	SDL_dx5audio.c	\
+	SDL_dx5audio.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windx5/SDL_dx5audio.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,677 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Allow access to a raw mixing buffer */
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_audio.h"
+#include "SDL_audio_c.h"
+#include "SDL_dx5audio.h"
+
+/* Define this if you want to use DirectX 6 DirectSoundNotify interface */
+//#define USE_POSITION_NOTIFY
+
+/* DirectX function pointers for audio */
+HRESULT (WINAPI *DSoundCreate)(LPGUID, LPDIRECTSOUND *, LPUNKNOWN);
+
+/* Audio driver functions */
+static int DX5_OpenAudio(_THIS, SDL_AudioSpec *spec);
+static void DX5_ThreadInit(_THIS);
+static void DX5_WaitAudio_BusyWait(_THIS);
+#ifdef USE_POSITION_NOTIFY
+static void DX6_WaitAudio_EventWait(_THIS);
+#endif
+static void DX5_PlayAudio(_THIS);
+static Uint8 *DX5_GetAudioBuf(_THIS);
+static void DX5_WaitDone(_THIS);
+static void DX5_CloseAudio(_THIS);
+
+/* Audio driver bootstrap functions */
+
+static int Audio_Available(void)
+{
+	HINSTANCE DSoundDLL;
+	int dsound_ok;
+
+	/* Version check DSOUND.DLL (Is DirectX okay?) */
+	dsound_ok = 0;
+	DSoundDLL = LoadLibrary("DSOUND.DLL");
+	if ( DSoundDLL != NULL ) {
+		/* We just use basic DirectSound, we're okay */
+		/* Yay! */
+		/* Unfortunately, the sound drivers on NT have
+		   higher latencies than the audio buffers used
+		   by many SDL applications, so there are gaps
+		   in the audio - it sounds terrible.  Punt for now.
+		 */
+		OSVERSIONINFO ver;
+		ver.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
+		GetVersionEx(&ver);
+		switch (ver.dwPlatformId) {
+			case VER_PLATFORM_WIN32_NT:
+				if ( ver.dwMajorVersion > 4 ) {
+					/* Win2K */
+					dsound_ok = 1;
+				} else {
+					/* WinNT */
+					dsound_ok = 0;
+				}
+				break;
+			default:
+				/* Win95 or Win98 */
+				dsound_ok = 1;
+				break;
+		}
+		/* Now check for DirectX 5 or better - otherwise
+		 * we will fail later in DX5_OpenAudio without a chance
+		 * to fall back to the DIB driver. */
+		if (dsound_ok) {
+			/* DirectSoundCaptureCreate was added in DX5 */
+			if (!GetProcAddress(DSoundDLL, "DirectSoundCaptureCreate"))
+				dsound_ok = 0;
+
+		}
+		/* Clean up.. */
+		FreeLibrary(DSoundDLL);
+	}
+	return(dsound_ok);
+}
+
+/* Functions for loading the DirectX functions dynamically */
+static HINSTANCE DSoundDLL = NULL;
+
+static void DX5_Unload(void)
+{
+	if ( DSoundDLL != NULL ) {
+		FreeLibrary(DSoundDLL);
+		DSoundCreate = NULL;
+		DSoundDLL = NULL;
+	}
+}
+static int DX5_Load(void)
+{
+	int status;
+
+	DX5_Unload();
+	DSoundDLL = LoadLibrary("DSOUND.DLL");
+	if ( DSoundDLL != NULL ) {
+		DSoundCreate = (void *)GetProcAddress(DSoundDLL,
+					"DirectSoundCreate");
+	}
+	if ( DSoundDLL && DSoundCreate ) {
+		status = 0;
+	} else {
+		DX5_Unload();
+		status = -1;
+	}
+	return status;
+}
+
+static void Audio_DeleteDevice(SDL_AudioDevice *device)
+{
+	DX5_Unload();
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_AudioDevice *Audio_CreateDevice(int devindex)
+{
+	SDL_AudioDevice *this;
+
+	/* Load DirectX */
+	if ( DX5_Load() < 0 ) {
+		return(NULL);
+	}
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateAudioData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+
+	/* Set the function pointers */
+	this->OpenAudio = DX5_OpenAudio;
+	this->ThreadInit = DX5_ThreadInit;
+	this->WaitAudio = DX5_WaitAudio_BusyWait;
+	this->PlayAudio = DX5_PlayAudio;
+	this->GetAudioBuf = DX5_GetAudioBuf;
+	this->WaitDone = DX5_WaitDone;
+	this->CloseAudio = DX5_CloseAudio;
+
+	this->free = Audio_DeleteDevice;
+
+	return this;
+}
+
+AudioBootStrap DSOUND_bootstrap = {
+	"dsound", "Win95/98/2000 DirectSound",
+	Audio_Available, Audio_CreateDevice
+};
+
+static void SetDSerror(const char *function, int code)
+{
+	static const char *error;
+	static char  errbuf[BUFSIZ];
+
+	errbuf[0] = 0;
+	switch (code) {
+		case E_NOINTERFACE:
+			error = 
+		"Unsupported interface\n-- Is DirectX 5.0 or later installed?";
+			break;
+		case DSERR_ALLOCATED:
+			error = "Audio device in use";
+			break;
+		case DSERR_BADFORMAT:
+			error = "Unsupported audio format";
+			break;
+		case DSERR_BUFFERLOST:
+			error = "Mixing buffer was lost";
+			break;
+		case DSERR_CONTROLUNAVAIL:
+			error = "Control requested is not available";
+			break;
+		case DSERR_INVALIDCALL:
+			error = "Invalid call for the current state";
+			break;
+		case DSERR_INVALIDPARAM:
+			error = "Invalid parameter";
+			break;
+		case DSERR_NODRIVER:
+			error = "No audio device found";
+			break;
+		case DSERR_OUTOFMEMORY:
+			error = "Out of memory";
+			break;
+		case DSERR_PRIOLEVELNEEDED:
+			error = "Caller doesn't have priority";
+			break;
+		case DSERR_UNSUPPORTED:
+			error = "Function not supported";
+			break;
+		default:
+			sprintf(errbuf, "%s: Unknown DirectSound error: 0x%x",
+								function, code);
+			break;
+	}
+	if ( ! errbuf[0] ) {
+		sprintf(errbuf, "%s: %s", function, error);
+	}
+	SDL_SetError("%s", errbuf);
+	return;
+}
+
+/* DirectSound needs to be associated with a window */
+static HWND mainwin = NULL;
+/* */
+void DX5_SoundFocus(HWND hwnd)
+{
+	mainwin = hwnd;
+}
+
+static void DX5_ThreadInit(_THIS)
+{
+	SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);
+}
+
+static void DX5_WaitAudio_BusyWait(_THIS)
+{
+	DWORD status;
+	DWORD cursor, junk;
+	HRESULT result;
+
+	/* Semi-busy wait, since we have no way of getting play notification
+	   on a primary mixing buffer located in hardware (DirectX 5.0)
+	*/
+	result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk);
+	if ( result != DS_OK ) {
+		if ( result == DSERR_BUFFERLOST ) {
+			IDirectSoundBuffer_Restore(mixbuf);
+		}
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound GetCurrentPosition", result);
+#endif
+		return;
+	}
+	cursor /= mixlen;
+
+	while ( cursor == playing ) {
+		/* FIXME: find out how much time is left and sleep that long */
+		SDL_Delay(10);
+
+		/* Try to restore a lost sound buffer */
+		IDirectSoundBuffer_GetStatus(mixbuf, &status);
+		if ( (status&DSBSTATUS_BUFFERLOST) ) {
+			IDirectSoundBuffer_Restore(mixbuf);
+			IDirectSoundBuffer_GetStatus(mixbuf, &status);
+			if ( (status&DSBSTATUS_BUFFERLOST) ) {
+				break;
+			}
+		}
+		if ( ! (status&DSBSTATUS_PLAYING) ) {
+			result = IDirectSoundBuffer_Play(mixbuf, 0, 0, DSBPLAY_LOOPING);
+			if ( result == DS_OK ) {
+				continue;
+			}
+#ifdef DEBUG_SOUND
+			SetDSerror("DirectSound Play", result);
+#endif
+			return;
+		}
+
+		/* Find out where we are playing */
+		result = IDirectSoundBuffer_GetCurrentPosition(mixbuf,
+								&cursor, &junk);
+		if ( result != DS_OK ) {
+			SetDSerror("DirectSound GetCurrentPosition", result);
+			return;
+		}
+		cursor /= mixlen;
+	}
+}
+
+#ifdef USE_POSITION_NOTIFY
+static void DX6_WaitAudio_EventWait(_THIS)
+{
+	DWORD status;
+	HRESULT result;
+
+	/* Try to restore a lost sound buffer */
+	IDirectSoundBuffer_GetStatus(mixbuf, &status);
+	if ( (status&DSBSTATUS_BUFFERLOST) ) {
+		IDirectSoundBuffer_Restore(mixbuf);
+		IDirectSoundBuffer_GetStatus(mixbuf, &status);
+		if ( (status&DSBSTATUS_BUFFERLOST) ) {
+			return;
+		}
+	}
+	if ( ! (status&DSBSTATUS_PLAYING) ) {
+		result = IDirectSoundBuffer_Play(mixbuf, 0, 0, DSBPLAY_LOOPING);
+		if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+			SetDSerror("DirectSound Play", result);
+#endif
+			return;
+		}
+	}
+	WaitForSingleObject(audio_event, INFINITE);
+}
+#endif /* USE_POSITION_NOTIFY */
+
+static void DX5_PlayAudio(_THIS)
+{
+	/* Unlock the buffer, allowing it to play */
+	if ( locked_buf ) {
+		IDirectSoundBuffer_Unlock(mixbuf, locked_buf, mixlen, NULL, 0);
+	}
+
+}
+
+static Uint8 *DX5_GetAudioBuf(_THIS)
+{
+	DWORD   cursor, junk;
+	HRESULT result;
+	DWORD   rawlen;
+
+	/* Figure out which blocks to fill next */
+	locked_buf = NULL;
+	result = IDirectSoundBuffer_GetCurrentPosition(mixbuf, &cursor, &junk);
+	if ( result == DSERR_BUFFERLOST ) {
+		IDirectSoundBuffer_Restore(mixbuf);
+		result = IDirectSoundBuffer_GetCurrentPosition(mixbuf,
+								&cursor, &junk);
+	}
+	if ( result != DS_OK ) {
+		SetDSerror("DirectSound GetCurrentPosition", result);
+		return(NULL);
+	}
+	cursor /= mixlen;
+	playing = cursor;
+	cursor = (cursor+1)%NUM_BUFFERS;
+	cursor *= mixlen;
+
+	/* Lock the audio buffer */
+	result = IDirectSoundBuffer_Lock(mixbuf, cursor, mixlen,
+				(LPVOID *)&locked_buf, &rawlen, NULL, &junk, 0);
+	if ( result == DSERR_BUFFERLOST ) {
+		IDirectSoundBuffer_Restore(mixbuf);
+		result = IDirectSoundBuffer_Lock(mixbuf, cursor, mixlen,
+				(LPVOID *)&locked_buf, &rawlen, NULL, &junk, 0);
+	}
+	if ( result != DS_OK ) {
+		SetDSerror("DirectSound Lock", result);
+		return(NULL);
+	}
+	return(locked_buf);
+}
+
+static void DX5_WaitDone(_THIS)
+{
+	Uint8 *stream;
+
+	/* Wait for the playing chunk to finish */
+	stream = this->GetAudioBuf(this);
+	if ( stream != NULL ) {
+		memset(stream, silence, mixlen);
+		this->PlayAudio(this);
+	}
+	this->WaitAudio(this);
+
+	/* Stop the looping sound buffer */
+	IDirectSoundBuffer_Stop(mixbuf);
+}
+
+static void DX5_CloseAudio(_THIS)
+{
+	if ( sound != NULL ) {
+		if ( mixbuf != NULL ) {
+			/* Clean up the audio buffer */
+			IDirectSoundBuffer_Release(mixbuf);
+			mixbuf = NULL;
+		}
+		if ( audio_event != NULL ) {
+			CloseHandle(audio_event);
+			audio_event = NULL;
+		}
+		IDirectSound_Release(sound);
+		sound = NULL;
+	}
+}
+
+/* This function tries to create a primary audio buffer, and returns the
+   number of audio chunks available in the created buffer.
+*/
+static int CreatePrimary(LPDIRECTSOUND sndObj, HWND focus, 
+	LPDIRECTSOUNDBUFFER *sndbuf, WAVEFORMATEX *wavefmt, Uint32 chunksize)
+{
+	HRESULT result;
+	DSBUFFERDESC format;
+	DSBCAPS caps;
+	int numchunks;
+
+	/* Try to set primary mixing privileges */
+	result = IDirectSound_SetCooperativeLevel(sndObj, focus,
+							DSSCL_WRITEPRIMARY);
+	if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound SetCooperativeLevel", result);
+#endif
+		return(-1);
+	}
+
+	/* Try to create the primary buffer */
+	memset(&format, 0, sizeof(format));
+	format.dwSize = sizeof(format);
+	format.dwFlags=(DSBCAPS_PRIMARYBUFFER|DSBCAPS_GETCURRENTPOSITION2);
+#ifdef USE_POSITION_NOTIFY
+	format.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY;
+#endif
+	result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
+	if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound CreateSoundBuffer", result);
+#endif
+		return(-1);
+	}
+
+	/* Check the size of the fragment buffer */
+	memset(&caps, 0, sizeof(caps));
+	caps.dwSize = sizeof(caps);
+	result = IDirectSoundBuffer_GetCaps(*sndbuf, &caps);
+	if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound GetCaps", result);
+#endif
+		IDirectSoundBuffer_Release(*sndbuf);
+		return(-1);
+	}
+	if ( (chunksize > caps.dwBufferBytes) ||
+				((caps.dwBufferBytes%chunksize) != 0) ) {
+		/* The primary buffer size is not a multiple of 'chunksize'
+		   -- this hopefully doesn't happen when 'chunksize' is a 
+		      power of 2.
+		*/
+		IDirectSoundBuffer_Release(*sndbuf);
+		SDL_SetError(
+"Primary buffer size is: %d, cannot break it into chunks of %d bytes\n",
+					caps.dwBufferBytes, chunksize);
+		return(-1);
+	}
+	numchunks = (caps.dwBufferBytes/chunksize);
+
+	/* Set the primary audio format */
+	result = IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt);
+	if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound SetFormat", result);
+#endif
+		IDirectSoundBuffer_Release(*sndbuf);
+		return(-1);
+	}
+	return(numchunks);
+}
+
+/* This function tries to create a secondary audio buffer, and returns the
+   number of audio chunks available in the created buffer.
+*/
+static int CreateSecondary(LPDIRECTSOUND sndObj, HWND focus,
+	LPDIRECTSOUNDBUFFER *sndbuf, WAVEFORMATEX *wavefmt, Uint32 chunksize)
+{
+	HRESULT result;
+	DSBUFFERDESC format;
+	const int numchunks = 2;
+
+	/* Try to set primary mixing privileges */
+	if ( focus ) {
+		result = IDirectSound_SetCooperativeLevel(sndObj,
+					focus, DSSCL_PRIORITY);
+	} else {
+		result = IDirectSound_SetCooperativeLevel(sndObj,
+					GetDesktopWindow(), DSSCL_NORMAL);
+	}
+	if ( result != DS_OK ) {
+#ifdef DEBUG_SOUND
+		SetDSerror("DirectSound SetCooperativeLevel", result);
+#endif
+		return(-1);
+	}
+
+	/* Try to create the secondary buffer */
+	memset(&format, 0, sizeof(format));
+	format.dwSize = sizeof(format);
+	format.dwFlags = DSBCAPS_GETCURRENTPOSITION2;
+#ifdef USE_POSITION_NOTIFY
+	format.dwFlags |= DSBCAPS_CTRLPOSITIONNOTIFY;
+#endif
+	if ( ! focus ) {
+		format.dwFlags |= DSBCAPS_GLOBALFOCUS;
+	}
+	format.dwBufferBytes = numchunks*chunksize;
+	if ( (format.dwBufferBytes < DSBSIZE_MIN) ||
+	     (format.dwBufferBytes > DSBSIZE_MAX) ) {
+		SDL_SetError("Sound buffer size must be between %d and %d",
+				DSBSIZE_MIN/numchunks, DSBSIZE_MAX/numchunks);
+		return(-1);
+	}
+	format.dwReserved = 0;
+	format.lpwfxFormat = wavefmt;
+	result = IDirectSound_CreateSoundBuffer(sndObj, &format, sndbuf, NULL);
+	if ( result != DS_OK ) {
+		SetDSerror("DirectSound CreateSoundBuffer", result);
+		return(-1);
+	}
+	IDirectSoundBuffer_SetFormat(*sndbuf, wavefmt);
+
+	/* We're ready to go */
+	return(numchunks);
+}
+
+/* This function tries to set position notify events on the mixing buffer */
+#ifdef USE_POSITION_NOTIFY
+static int CreateAudioEvent(_THIS)
+{
+	LPDIRECTSOUNDNOTIFY notify;
+	DSBPOSITIONNOTIFY *notify_positions;
+	int i, retval;
+	HRESULT result;
+
+	/* Default to fail on exit */
+	retval = -1;
+	notify = NULL;
+
+	/* Query for the interface */
+	result = IDirectSoundBuffer_QueryInterface(mixbuf,
+			&IID_IDirectSoundNotify, (void *)&notify);
+	if ( result != DS_OK ) {
+		goto done;
+	}
+
+	/* Allocate the notify structures */
+	notify_positions = (DSBPOSITIONNOTIFY *)malloc(NUM_BUFFERS*
+					sizeof(*notify_positions));
+	if ( notify_positions == NULL ) {
+		goto done;
+	}
+
+	/* Create the notify event */
+	audio_event = CreateEvent(NULL, FALSE, FALSE, NULL);
+	if ( audio_event == NULL ) {
+		goto done;
+	}
+
+	/* Set up the notify structures */
+	for ( i=0; i<NUM_BUFFERS; ++i ) {
+		notify_positions[i].dwOffset = i*mixlen;
+		notify_positions[i].hEventNotify = audio_event;
+	}
+	result = IDirectSoundNotify_SetNotificationPositions(notify,
+					NUM_BUFFERS, notify_positions);
+	if ( result == DS_OK ) {
+		retval = 0;
+	}
+done:
+	if ( notify != NULL ) {
+		IDirectSoundNotify_Release(notify);
+	}
+	return(retval);
+}
+#endif /* USE_POSITION_NOTIFY */
+
+static int DX5_OpenAudio(_THIS, SDL_AudioSpec *spec)
+{
+	HRESULT      result;
+	WAVEFORMATEX waveformat;
+
+	/* Set basic WAVE format parameters */
+	memset(&waveformat, 0, sizeof(waveformat));
+	waveformat.wFormatTag = WAVE_FORMAT_PCM;
+
+	/* Determine the audio parameters from the AudioSpec */
+	switch ( spec->format & 0xFF ) {
+		case 8:
+			/* Unsigned 8 bit audio data */
+			spec->format = AUDIO_U8;
+			silence = 0x80;
+			waveformat.wBitsPerSample = 8;
+			break;
+		case 16:
+			/* Signed 16 bit audio data */
+			spec->format = AUDIO_S16;
+			silence = 0x00;
+			waveformat.wBitsPerSample = 16;
+			break;
+		default:
+			SDL_SetError("Unsupported audio format");
+			return(-1);
+	}
+	waveformat.nChannels = spec->channels;
+	waveformat.nSamplesPerSec = spec->freq;
+	waveformat.nBlockAlign =
+		waveformat.nChannels * (waveformat.wBitsPerSample/8);
+	waveformat.nAvgBytesPerSec = 
+		waveformat.nSamplesPerSec * waveformat.nBlockAlign;
+
+	/* Update the fragment size as size in bytes */
+	SDL_CalculateAudioSpec(spec);
+
+	/* Open the audio device */
+	result = DSoundCreate(NULL, &sound, NULL);
+	if ( result != DS_OK ) {
+		SetDSerror("DirectSoundCreate", result);
+		return(-1);
+	}
+
+	/* Create the audio buffer to which we write */
+	NUM_BUFFERS = -1;
+	if ( mainwin ) {
+		NUM_BUFFERS = CreatePrimary(sound, mainwin, &mixbuf,
+						&waveformat, spec->size);
+	}
+	if ( NUM_BUFFERS < 0 ) {
+		NUM_BUFFERS = CreateSecondary(sound, mainwin, &mixbuf,
+						&waveformat, spec->size);
+		if ( NUM_BUFFERS < 0 ) {
+			return(-1);
+		}
+#ifdef DEBUG_SOUND
+		fprintf(stderr, "Using secondary audio buffer\n");
+#endif
+	}
+#ifdef DEBUG_SOUND
+	else
+		fprintf(stderr, "Using primary audio buffer\n");
+#endif
+
+	/* The buffer will auto-start playing in DX5_WaitAudio() */
+	playing = 0;
+	mixlen = spec->size;
+
+#ifdef USE_POSITION_NOTIFY
+	/* See if we can use DirectX 6 event notification */
+	if ( CreateAudioEvent(this) == 0 ) {
+		this->WaitAudio = DX6_WaitAudio_EventWait;
+	} else {
+		this->WaitAudio = DX5_WaitAudio_BusyWait;
+	}
+#endif
+	return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/audio/windx5/SDL_dx5audio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,59 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowaudio_h
+#define _SDL_lowaudio_h
+
+#include "directx.h"
+
+#include "SDL_sysaudio.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_AudioDevice *this
+
+/* The DirectSound objects */
+struct SDL_PrivateAudioData {
+	LPDIRECTSOUND sound;
+	LPDIRECTSOUNDBUFFER mixbuf;
+	int NUM_BUFFERS;
+	int mixlen, silence;
+	DWORD playing;
+	Uint8 *locked_buf;
+	HANDLE audio_event;
+};
+
+/* Old variable names */
+#define sound			(this->hidden->sound)
+#define mixbuf			(this->hidden->mixbuf)
+#define NUM_BUFFERS		(this->hidden->NUM_BUFFERS)
+#define mixlen			(this->hidden->mixlen)
+#define silence			(this->hidden->silence)
+#define playing			(this->hidden->playing)
+#define locked_buf		(this->hidden->locked_buf)
+#define audio_event		(this->hidden->audio_event)
+
+#endif /* _SDL_lowaudio_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,7 @@
+Makefile.in
+SDL_syscdrom.c
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+
+## Makefile.am for the SDL cdrom library
+
+noinst_LTLIBRARIES = libcdrom.la
+
+ARCH_SUBDIRS = dummy beos freebsd linux macos openbsd qnx win32
+
+# Include the architecture-independent sources
+COMMON_SRCS = SDL_cdrom.c SDL_syscdrom.h
+
+# Include the architecture-specific sources
+ARCH_SRCS = SDL_syscdrom.c
+
+libcdrom_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
+
+## Let automake know that it shouldn't distribute linked sources
+BUILT_SOURCES = $(ARCH_SRCS)
+
+## Let automake know that it should remove these for distribution
+DISTCLEANFILES = $(ARCH_SRCS)
+
+# The architecture specific directories need to be copied into place
+# when building a distribution.
+dist-hook:
+	(cd $(distdir) && rm -f $(BUILT_SOURCES))
+	cp -rp $(ARCH_SUBDIRS) $(distdir)
+	(cd $(distdir) && rm -rf `find . -name CVS`)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/SDL_cdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,350 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the CD-audio control API for Simple DirectMedia Layer */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+#if !defined(macintosh)
+#define CLIP_FRAMES	10	/* Some CD-ROMs won't go all the way */
+#endif
+
+static int SDL_cdinitted = 0;
+static SDL_CD *default_cdrom;
+
+/* The system level CD-ROM control functions */
+struct CDcaps SDL_CDcaps = {
+	NULL,					/* Name */
+	NULL,					/* Open */
+	NULL,					/* GetTOC */
+	NULL,					/* Status */
+	NULL,					/* Play */
+	NULL,					/* Pause */
+	NULL,					/* Resume */
+	NULL,					/* Stop */
+	NULL,					/* Eject */
+	NULL,					/* Close */
+};
+int SDL_numcds;
+
+int SDL_CDROMInit(void)
+{
+	int retval;
+
+	SDL_numcds = 0;
+	retval = SDL_SYS_CDInit();
+	if ( retval == 0 ) {
+		SDL_cdinitted = 1;
+	}
+	default_cdrom = NULL;
+	return(retval);
+}
+
+/* Check to see if the CD-ROM subsystem has been initialized */
+static int CheckInit(int check_cdrom, SDL_CD **cdrom)
+{
+	int okay;
+
+	okay = SDL_cdinitted;
+	if ( check_cdrom && (*cdrom == NULL) ) {
+		*cdrom = default_cdrom;
+		if ( *cdrom == NULL ) {
+			SDL_SetError("CD-ROM not opened");
+			okay = 0;
+		}
+	}
+	if ( ! SDL_cdinitted ) {
+		SDL_SetError("CD-ROM subsystem not initialized");
+	}
+	return(okay);
+}
+
+int SDL_CDNumDrives(void)
+{
+	if ( ! CheckInit(0, NULL) ) {
+		return(-1);
+	}
+	return(SDL_numcds);
+}
+
+const char *SDL_CDName(int drive)
+{
+	if ( ! CheckInit(0, NULL) ) {
+		return(NULL);
+	}
+	if ( drive >= SDL_numcds ) {
+		SDL_SetError("Invalid CD-ROM drive index");
+		return(NULL);
+	}
+	if ( SDL_CDcaps.Name ) {
+		return(SDL_CDcaps.Name(drive));
+	} else {
+		return("");
+	}
+}
+
+SDL_CD *SDL_CDOpen(int drive)
+{
+	struct SDL_CD *cdrom;
+
+	if ( ! CheckInit(0, NULL) ) {
+		return(NULL);
+	}
+	if ( drive >= SDL_numcds ) {
+		SDL_SetError("Invalid CD-ROM drive index");
+		return(NULL);
+	}
+	cdrom = (SDL_CD *)malloc(sizeof(*cdrom));
+	if ( cdrom == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(cdrom, 0, sizeof(*cdrom));
+	cdrom->id = SDL_CDcaps.Open(drive);
+	if ( cdrom->id < 0 ) {
+		free(cdrom);
+		return(NULL);
+	}
+	default_cdrom = cdrom;
+	return(cdrom);
+}
+
+CDstatus SDL_CDStatus(SDL_CD *cdrom)
+{
+	CDstatus status;
+	int i;
+	Uint32 position;
+
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	/* Get the current status of the drive */
+	cdrom->numtracks = 0;
+	cdrom->cur_track = 0;
+	cdrom->cur_frame = 0;
+	status = SDL_CDcaps.Status(cdrom, &i);
+	position = (Uint32)i;
+	cdrom->status = status;
+
+	/* Get the table of contents, if there's a CD available */
+	if ( CD_INDRIVE(status) ) {
+		if ( SDL_CDcaps.GetTOC(cdrom) < 0 ) {
+			status = CD_ERROR;
+		}
+		/* If the drive is playing, get current play position */
+		if ( (status == CD_PLAYING) || (status == CD_PAUSED) ) {
+			for ( i=1; cdrom->track[i].offset <= position; ++i ) {
+				/* Keep looking */;
+			}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Current position: %d, track = %d (offset is %d)\n",
+				position, i-1, cdrom->track[i-1].offset);
+#endif
+			cdrom->cur_track = i-1;
+			position -= cdrom->track[cdrom->cur_track].offset;
+			cdrom->cur_frame = position;
+		}
+	}
+	return(status);
+}
+
+int SDL_CDPlayTracks(SDL_CD *cdrom,
+			int strack, int sframe, int ntracks, int nframes)
+{
+	int etrack, eframe;
+	int start, length;
+
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	/* Determine the starting and ending tracks */
+	if ( (strack < 0) || (strack >= cdrom->numtracks) ) {
+		SDL_SetError("Invalid starting track");
+		return(CD_ERROR);
+	}
+	if ( ! ntracks && ! nframes ) {
+		etrack = cdrom->numtracks;
+		eframe = 0;
+	} else {
+		etrack = strack+ntracks;
+		if ( etrack == strack ) {
+			eframe = sframe + nframes;
+		} else {
+			eframe = nframes;
+		}
+	}
+	if ( etrack > cdrom->numtracks ) {
+		SDL_SetError("Invalid play length");
+		return(CD_ERROR);
+	}
+
+	/* Skip data tracks and verify frame offsets */
+	while ( (strack <= etrack) &&
+			(cdrom->track[strack].type == SDL_DATA_TRACK) ) {
+		++strack;
+	}
+	if ( sframe >= (int)cdrom->track[strack].length ) {
+		SDL_SetError("Invalid starting frame for track %d", strack);
+		return(CD_ERROR);
+	}
+	while ( (etrack > strack) &&
+			(cdrom->track[etrack-1].type == SDL_DATA_TRACK) ) {
+		--etrack;
+	}
+	if ( eframe > (int)cdrom->track[etrack].length ) {
+		SDL_SetError("Invalid ending frame for track %d", etrack);
+		return(CD_ERROR);
+	}
+
+	/* Determine start frame and play length */
+	start = (cdrom->track[strack].offset+sframe);
+	length = (cdrom->track[etrack].offset+eframe)-start;
+#ifdef CLIP_FRAMES
+	/* I've never seen this necessary, but xmcd does it.. */
+	length -= CLIP_FRAMES;	/* CLIP_FRAMES == 10 */
+#endif
+	if ( length < 0 ) {
+		return(0);
+	}
+
+	/* Play! */
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Playing %d frames at offset %d\n", length, start);
+#endif
+	return(SDL_CDcaps.Play(cdrom, start, length));
+}
+
+int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length)
+{
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	return(SDL_CDcaps.Play(cdrom, sframe, length));
+}
+
+int SDL_CDPause(SDL_CD *cdrom)
+{
+	CDstatus status;
+	int retval;
+
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	status = SDL_CDcaps.Status(cdrom, NULL);
+	switch (status) {
+		case CD_PLAYING:
+			retval = SDL_CDcaps.Pause(cdrom);
+			break;
+		default:
+			retval = 0;
+			break;
+	}
+	return(retval);
+}
+
+int SDL_CDResume(SDL_CD *cdrom)
+{
+	CDstatus status;
+	int retval;
+
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	status = SDL_CDcaps.Status(cdrom, NULL);
+	switch (status) {
+		case CD_PAUSED:
+			retval = SDL_CDcaps.Resume(cdrom);
+		default:
+			retval = 0;
+			break;
+	}
+	return(retval);
+}
+
+int SDL_CDStop(SDL_CD *cdrom)
+{
+	CDstatus status;
+	int retval;
+
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+
+	status = SDL_CDcaps.Status(cdrom, NULL);
+	switch (status) {
+		case CD_PLAYING:
+		case CD_PAUSED:
+			retval = SDL_CDcaps.Stop(cdrom);
+		default:
+			retval = 0;
+			break;
+	}
+	return(retval);
+}
+
+int SDL_CDEject(SDL_CD *cdrom)
+{
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return(CD_ERROR);
+	}
+	return(SDL_CDcaps.Eject(cdrom));
+}
+
+void SDL_CDClose(SDL_CD *cdrom)
+{
+	/* Check if the CD-ROM subsystem has been initialized */
+	if ( ! CheckInit(1, &cdrom) ) {
+		return;
+	}
+	SDL_CDcaps.Close(cdrom);
+	free(cdrom);
+	default_cdrom = NULL;
+}
+
+void SDL_CDROMQuit(void)
+{
+	SDL_SYS_CDQuit();
+	SDL_cdinitted = 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/SDL_syscdrom.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,80 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the system specific header for the SDL CD-ROM API */
+
+/* Structure of CD audio control functions */
+extern struct CDcaps {
+	/* Get the name of the specified drive */
+	const char *(*Name)(int drive);
+
+	/* Open the specified drive, returning a drive id, or -1 on error */
+	int (*Open)(int drive);
+
+	/* Get table-of-contents (number of tracks + track info) for disk.
+	   The TOC information should be stored in the cdrom structure.
+	   This function should return 0 on success, or -1 on error.
+	 */
+	int (*GetTOC)(SDL_CD *cdrom);
+
+	/* Return the current status and play position, in frames, of the
+	   drive.  'position' may be NULL, and if so, should be ignored.
+	 */
+	CDstatus (*Status)(SDL_CD *cdrom, int *position);
+
+	/* Play from frame 'start' to 'start+len' */
+	int (*Play)(SDL_CD *cdrom, int start, int len); 
+
+	/* Pause play */
+	int (*Pause)(SDL_CD *cdrom);
+
+	/* Resume play */
+	int (*Resume)(SDL_CD *cdrom);
+
+	/* Stop play */
+	int (*Stop)(SDL_CD *cdrom);
+
+	/* Eject the current disk */
+	int (*Eject)(SDL_CD *cdrom);
+
+	/* Close the specified drive */
+	void (*Close)(SDL_CD *cdrom);
+} SDL_CDcaps;
+
+/* The number of available CD-ROM drives on the system */
+extern int SDL_numcds;
+
+/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.
+ * This function should set SDL_numcds to the number of available CD
+ * drives.  Drive 0 should be the system default CD-ROM.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+*/
+extern int  SDL_SYS_CDInit(void);
+
+/* Function to perform any system-specific CD-ROM related cleanup */
+extern void SDL_SYS_CDQuit(void);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/aix/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,663 @@
+/*
+    AIX audio module for SDL (Simple DirectMedia Layer)
+    Copyright (C) 2000 Carsten Griwodz
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Carsten Griwodz
+    griff@kom.tu-darmstadt.de
+
+    based on linux/SDL_syscdrom.c by Sam Lantinga
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#define DEBUG_CDROM 1
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+
+#include <sys/ioctl.h>
+#include <sys/devinfo.h>
+#include <sys/mntctl.h>
+#include <sys/statfs.h>
+#include <sys/vmount.h>
+#include <fstab.h>
+#include <sys/scdisk.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static dev_t SDL_cdmode[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int         SDL_SYS_CDOpen(int drive);
+static int         SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus    SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int         SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int         SDL_SYS_CDPause(SDL_CD *cdrom);
+static int         SDL_SYS_CDResume(SDL_CD *cdrom);
+static int         SDL_SYS_CDStop(SDL_CD *cdrom);
+static int         SDL_SYS_CDEject(SDL_CD *cdrom);
+static void        SDL_SYS_CDClose(SDL_CD *cdrom);
+static int         SDL_SYS_CDioctl(int id, int command, void *arg);
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive, struct stat *stbuf)
+{
+    int is_cd;
+    int cdfd;
+    int ret;
+    struct devinfo info;
+
+    /* If it doesn't exist, return -1 */
+    if ( stat(drive, stbuf) < 0 ) {
+        return -1;
+    }
+
+    /* If it does exist, verify that it's an available CD-ROM */
+    is_cd = 0;
+    if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
+        cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
+        if ( cdfd >= 0 ) {
+            ret = SDL_SYS_CDioctl( cdfd, IOCINFO, &info );
+	    if ( ret < 0 ) {
+		/* Some kind of error */
+		is_cd = 0;
+	    } else {
+		if ( info.devtype == DD_CDROM ) {
+		    is_cd = 1;
+		} else {
+		    is_cd = 0;
+		}
+	    }
+            close(cdfd);
+	}
+#ifdef DEBUG_CDROM
+	else
+	{
+            fprintf(stderr, "Could not open drive %s (%s)\n", drive, strerror(errno));
+	}
+#endif
+    }
+    return is_cd;
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive, struct stat *stbuf)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Check to make sure it's not already in our list.
+	 	   This can happen when we see a drive via symbolic link.
+		 */
+		for ( i=0; i<SDL_numcds; ++i ) {
+			if ( stbuf->st_rdev == SDL_cdmode[i] ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
+#endif
+				return;
+			}
+		}
+
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		SDL_cdmode[i] = stbuf->st_rdev;
+		++SDL_numcds;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+static void CheckMounts()
+{
+    char*          buffer;
+    int            bufsz;
+    struct vmount* ptr;
+    int            ret;
+
+    buffer = (char*)malloc(10);
+    bufsz  = 10;
+    if ( buffer==NULL )
+    {
+        fprintf(stderr, "Could not allocate 10 bytes in aix/SDL_syscdrom.c:CheckMounts\n" );
+	exit ( -10 );
+    }
+
+    do
+    {
+	/* mntctrl() returns an array of all mounted filesystems */
+        ret = mntctl ( MCTL_QUERY, bufsz, buffer );
+        if ( ret == 0 )
+        {
+				   /* Buffer was too small, realloc.    */
+            bufsz = *(int*)buffer; /* Required size is in first word.   */
+				   /* (whatever a word is in AIX 4.3.3) */
+				   /* int seems to be OK in 32bit mode. */
+            free(buffer);
+            buffer = (char*)malloc(bufsz);
+            if ( buffer==NULL )
+            {
+                fprintf(stderr,
+			"Could not allocate %d bytes in aix/SDL_syscdrom.c:CheckMounts\n",
+			bufsz );
+	        exit ( -10 );
+            }
+        }
+	else if ( ret < 0 )
+	{
+#ifdef DEBUG_CDROM
+            fprintf(stderr, "Error reading vmount structures\n");
+#endif
+	    return;
+	}
+    }
+    while ( ret == 0 );
+
+#ifdef DEBUG_CDROM
+    fprintf ( stderr, "Read %d vmount structures\n",ret );
+#endif
+    ptr = (struct vmount*)buffer;
+    do
+    {
+            switch(ptr->vmt_gfstype)
+            {
+            case MNT_CDROM :
+                {
+		    struct stat stbuf;
+		    char*       text;
+
+		    text = (char*)ptr + ptr->vmt_data[VMT_OBJECT].vmt_off;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking mount path: %s mounted on %s\n",
+	text, (char*)ptr + ptr->vmt_data[VMT_STUB].vmt_off );
+#endif
+		    if ( CheckDrive( text, &stbuf) > 0)
+		    {
+		        AddDrive( text, &stbuf);
+		    }
+                }
+                break;
+            default :
+                break;
+            }
+            ptr = (struct vmount*)((char*)ptr + ptr->vmt_length);
+            ret--;
+    }
+    while ( ret > 0 );
+
+    free ( buffer );
+}
+
+static int CheckNonmounts()
+{
+#ifdef _THREAD_SAFE
+    AFILE_t      fsFile = NULL;
+    int          passNo = 0;
+    int          ret;
+    struct fstab entry;
+    struct stat  stbuf;
+
+    ret = setfsent_r( &fsFile, &passNo );
+    if ( ret != 0 ) return -1;
+    do
+    {
+        ret = getfsent_r ( &entry, &fsFile, &passNo );
+        if ( ret == 0 ) {
+            char* l = strrchr(entry.fs_spec,'/');
+            if ( l != NULL ) {
+                if ( !strncmp("cd",++l,2) ) {
+#ifdef DEBUG_CDROM
+                    fprintf(stderr,
+			    "Found unmounted CD ROM drive with device name %s\n",
+			    entry.fs_spec);
+#endif
+		    if ( CheckDrive( entry.fs_spec, &stbuf) > 0)
+		    {
+		        AddDrive( entry.fs_spec, &stbuf);
+		    }
+                }
+            }
+        }
+    }
+    while ( ret == 0 );
+    ret = endfsent_r ( &fsFile );
+    if ( ret != 0 ) return -1;
+    return 0;
+#else
+    struct fstab* entry;
+    struct stat  stbuf;
+
+    setfsent();
+    do
+    {
+        entry = getfsent();
+        if ( entry != NULL ) {
+            char* l = strrchr(entry->fs_spec,'/');
+            if ( l != NULL ) {
+                if ( !strncmp("cd",++l,2) ) {
+#ifdef DEBUG_CDROM
+                    fprintf(stderr,"Found unmounted CD ROM drive with device name %s", entry->fs_spec);
+#endif
+		    if ( CheckDrive( entry->fs_spec, &stbuf) > 0)
+		    {
+		        AddDrive( entry->fs_spec, &stbuf);
+		    }
+                }
+            }
+        }
+    }
+    while ( entry != NULL );
+    endfsent();
+#endif
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	char *SDLcdrom;
+	struct stat stbuf;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom);
+#endif
+				if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
+					AddDrive(SDLcdrom, &stbuf);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+	CheckMounts();
+	CheckNonmounts();
+
+	return 0;
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int id, int command, void *arg)
+{
+    int retval;
+
+    retval = ioctl(id, command, arg);
+    if ( retval < 0 ) {
+        SDL_SetError("ioctl() error: %s", strerror(errno));
+    }
+    return retval;
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+    int   fd;
+    char* lastsl;
+    char* cdromname;
+
+    /*
+     * We found /dev/cd? drives and that is in our list. But we can
+     * open only the /dev/rcd? versions of those devices for Audio CD.
+     */
+    cdromname = (char*)malloc( strlen(SDL_cdlist[drive]+2) );
+    strcpy(cdromname,SDL_cdlist[drive]);
+    lastsl = strrchr(cdromname,'/');
+    if (lastsl) {
+	*lastsl = 0;
+	strcat(cdromname,"/r");
+	lastsl = strrchr(SDL_cdlist[drive],'/');
+	if (lastsl) {
+	    lastsl++;
+	    strcat(cdromname,lastsl);
+	}
+    }
+
+#ifdef DEBUG_CDROM
+    fprintf(stderr, "Should open drive %s, opening %s\n", SDL_cdlist[drive], cdromname);
+#endif
+
+    /*
+     * Use exclusive access. Don't use SC_DIAGNOSTICS as xmcd does because they
+     * require root priviledges, and we don't want that. SC_SINGLE provides
+     * exclusive access with less trouble.
+     */
+    fd = openx(cdromname, O_RDONLY, NULL, SC_SINGLE);
+    if ( fd < 0 )
+    {
+#ifdef DEBUG_CDROM
+            fprintf(stderr, "Could not open drive %s (%s)\n", cdromname, strerror(errno));
+#endif
+    }
+    else
+    {
+	struct mode_form_op cdMode;
+	int                 ret;
+#ifdef DEBUG_CDROM
+	cdMode.action = CD_GET_MODE;
+	ret = SDL_SYS_CDioctl(fd, DK_CD_MODE, &cdMode);
+	if ( ret < 0 ) {
+            fprintf(stderr,
+	            "Could not get drive mode for %s (%s)\n",
+		    cdromname, strerror(errno));
+	} else {
+	    switch(cdMode.cd_mode_form) {
+		case CD_MODE1 :
+                    fprintf(stderr,
+	                "Drive mode for %s is %s\n",
+		        cdromname, "CD-ROM Data Mode 1");
+		    break;
+		case CD_MODE2_FORM1 :
+                    fprintf(stderr,
+	                "Drive mode for %s is %s\n",
+		        cdromname, "CD-ROM XA Data Mode 2 Form 1");
+		    break;
+		case CD_MODE2_FORM2 :
+                    fprintf(stderr,
+	                "Drive mode for %s is %s\n",
+		        cdromname, "CD-ROM XA Data Mode 2 Form 2");
+		    break;
+		case CD_DA :
+                    fprintf(stderr,
+	                "Drive mode for %s is %s\n",
+		        cdromname, "CD-DA");
+		    break;
+		default :
+                    fprintf(stderr,
+	                "Drive mode for %s is %s\n",
+		        cdromname, "unknown");
+		    break;
+	    }
+	}
+#endif
+
+	cdMode.action       = CD_CHG_MODE;
+	cdMode.cd_mode_form = CD_DA;
+	ret = SDL_SYS_CDioctl(fd, DK_CD_MODE, &cdMode);
+	if ( ret < 0 ) {
+#ifdef DEBUG_CDROM
+            fprintf(stderr,
+	            "Could not set drive mode for %s (%s)\n",
+		    cdromname, strerror(errno));
+#endif
+            SDL_SetError("ioctl() error: Could not set CD drive mode, %s",
+	                 strerror(errno));
+	} else {
+#ifdef DEBUG_CDROM
+            fprintf(stderr,
+	            "Drive mode for %s set to CD_DA\n",
+		    cdromname);
+#endif
+	}
+    }
+    free(cdromname);
+    return fd;
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+    struct cd_audio_cmd cmd;
+    struct cd_audio_cmd entry;
+    int                 i;
+    int                 okay;
+
+    cmd.audio_cmds = CD_TRK_INFO_AUDIO;
+    cmd.msf_flag   = FALSE;
+    if ( SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd) < 0 ) {
+	return -1;
+    }
+
+    okay = 0;
+    cdrom->numtracks = cmd.indexing.track_index.last_track
+		     - cmd.indexing.track_index.first_track+1;
+    if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+        cdrom->numtracks = SDL_MAX_TRACKS;
+    }
+
+    /* Read all the track TOC entries */
+    for ( i=0; i<=cdrom->numtracks; ++i ) {
+        if ( i == cdrom->numtracks ) {
+            cdrom->track[i].id = 0xAA;;
+        } else {
+            cdrom->track[i].id = cmd.indexing.track_index.first_track+i;
+        }
+        entry.audio_cmds         = CD_GET_TRK_MSF;
+	entry.indexing.track_msf.track = cdrom->track[i].id;
+	if ( SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &entry) < 0 ) {
+            break;
+        } else {
+            cdrom->track[i].type = 0;    /* don't know how to detect 0x04 data track */
+            cdrom->track[i].offset = MSF_TO_FRAMES(
+                entry.indexing.track_msf.mins,
+                entry.indexing.track_msf.secs,
+                entry.indexing.track_msf.frames);
+            cdrom->track[i].length = 0;
+            if ( i > 0 ) {
+                cdrom->track[i-1].length = cdrom->track[i].offset
+		                         - cdrom->track[i-1].offset;
+            }
+        }
+    }
+    if ( i == (cdrom->numtracks+1) ) {
+        okay = 1;
+    }
+    return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+    CDstatus            status;
+    struct cd_audio_cmd cmd;
+    cmd.audio_cmds = CD_INFO_AUDIO;
+
+    if ( SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd) < 0 ) {
+#ifdef DEBUG_CDROM
+    fprintf(stderr, "ioctl failed in SDL_SYS_CDStatus (%s)\n", SDL_GetError());
+#endif
+        status = CD_ERROR;
+    } else {
+        switch (cmd.status) {
+            case CD_NO_AUDIO:
+            case CD_COMPLETED:
+                status = CD_STOPPED;
+                break;
+            case CD_PLAY_AUDIO:
+                status = CD_PLAYING;
+                break;
+            case CD_PAUSE_AUDIO:
+                status = CD_PAUSED;
+                break;
+            case CD_NOT_VALID:
+#ifdef DEBUG_CDROM
+    fprintf(stderr, "cdStatus failed with CD_NOT_VALID\n");
+#endif
+                status = CD_ERROR;
+                break;
+            case CD_STATUS_ERROR:
+#ifdef DEBUG_CDROM
+    fprintf(stderr, "cdStatus failed with CD_STATUS_ERROR\n");
+#endif
+                status = CD_ERROR;
+                break;
+            default:
+#ifdef DEBUG_CDROM
+    fprintf(stderr, "cdStatus failed with unknown error\n");
+#endif
+                status = CD_ERROR;
+                break;
+        }
+    }
+    if ( position ) {
+        if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+            *position = MSF_TO_FRAMES( cmd.indexing.info_audio.current_mins,
+                                       cmd.indexing.info_audio.current_secs,
+                                       cmd.indexing.info_audio.current_frames);
+        } else {
+            *position = 0;
+        }
+    }
+    return status;
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+    struct cd_audio_cmd cmd;
+
+    /*
+     * My CD Rom is muted by default. I think I read that this is new with
+     * AIX 4.3. SDL does not change the volume, so I need a kludge. Maybe
+     * its better to do this elsewhere?
+     */
+    cmd.audio_cmds = CD_PLAY_AUDIO | CD_SET_VOLUME;
+    cmd.msf_flag   = TRUE;
+    FRAMES_TO_MSF(start,
+                  &cmd.indexing.msf.first_mins,
+                  &cmd.indexing.msf.first_secs,
+                  &cmd.indexing.msf.first_frames);
+    FRAMES_TO_MSF(start+length,
+                  &cmd.indexing.msf.last_mins,
+                  &cmd.indexing.msf.last_secs,
+                  &cmd.indexing.msf.last_frames);
+    cmd.volume_type     = CD_VOLUME_ALL;
+    cmd.all_channel_vol = 255;   /* This is a uchar. What is a good value? No docu! */
+    cmd.out_port_0_sel  = CD_AUDIO_CHNL_0;
+    cmd.out_port_1_sel  = CD_AUDIO_CHNL_1;
+    cmd.out_port_2_sel  = CD_AUDIO_CHNL_2;
+    cmd.out_port_3_sel  = CD_AUDIO_CHNL_3;
+
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
+	cmd.indexing.msf.first_mins,
+	cmd.indexing.msf.first_secs,
+	cmd.indexing.msf.first_frames,
+	cmd.indexing.msf.last_mins,
+	cmd.indexing.msf.last_secs,
+	cmd.indexing.msf.last_frames);
+#endif
+	return(SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+    struct cd_audio_cmd cmd;
+    cmd.audio_cmds = CD_PAUSE_AUDIO;
+    return(SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+    struct cd_audio_cmd cmd;
+    cmd.audio_cmds = CD_RESUME_AUDIO;
+    return(SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+    struct cd_audio_cmd cmd;
+    cmd.audio_cmds = CD_STOP_AUDIO;
+    return(SDL_SYS_CDioctl(cdrom->id, DKAUDIO, &cmd));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+    return(SDL_SYS_CDioctl(cdrom->id, DKEJECT, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+    close(cdrom->id);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/beos/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,398 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control on BeOS
+   (not completely implemented yet)
+ */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <scsi.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+/* Constants to help us get at the SCSI table-of-contents info */
+#define CD_NUMTRACKS(toc)	toc.toc_data[3]
+#define CD_TRACK(toc, track)	(&toc.toc_data[6+(track)*8])
+#define CD_TRACK_N(toc, track)	CD_TRACK(toc, track)[0]
+#define CD_TRACK_M(toc, track)	CD_TRACK(toc, track)[3]
+#define CD_TRACK_S(toc, track)	CD_TRACK(toc, track)[4]
+#define CD_TRACK_F(toc, track)	CD_TRACK(toc, track)[5]
+
+/* Constants to help us get at the SCSI position info */
+#define POS_TRACK(pos)	pos.position[6]
+#define POS_ABS_M(pos)	pos.position[9]
+#define POS_ABS_S(pos)	pos.position[10]
+#define POS_ABS_F(pos)	pos.position[11]
+#define POS_REL_M(pos)	pos.position[13]
+#define POS_REL_S(pos)	pos.position[14]
+#define POS_REL_F(pos)	pos.position[15]
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive)
+{
+	struct stat stbuf;
+	int is_cd, cdfd;
+	device_geometry info;
+
+	/* If it doesn't exist, return -1 */
+	if ( stat(drive, &stbuf) < 0 ) {
+		return(-1);
+	}
+
+	/* If it does exist, verify that it's an available CD-ROM */
+	is_cd = 0;
+	cdfd = open(drive, 0);
+	if ( cdfd >= 0 ) {
+		if ( ioctl(cdfd, B_GET_GEOMETRY, &info) == B_NO_ERROR ) {
+			if ( info.device_type == B_CD ) {
+				is_cd = 1;
+			}
+		}
+		close(cdfd);
+	} else {
+		/* This can happen when the drive is open .. (?) */;
+		is_cd = 1;
+	}
+	return(is_cd);
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		++SDL_numcds;
+#ifdef CDROM_DEBUG
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+# if 0 /* Save this for later, when I can test it */
+/* SCSI bus scanning magic */
+static int CheckSCSI(int path, int id, int lun)
+{
+	int is_cd;
+	int fd;
+	scsiprobe_inquiry inquiry;
+
+	is_cd = 0;
+	fd = open("/dev/scsiprobe", 0);
+	if ( fd >= 0 ) {
+		inquiry.path = path;
+		inquiry.id = id;
+		inquiry.lun = lun;
+		inquiry.len = sizeof(inquiry);
+		if ( ioctl(fd, B_SCSIPROBE_INQUIRY, &inquiry) == B_NO_ERROR ) {
+			if ( (inquiry.data[0]&0x1F) == B_SCSI_CD ) {
+				is_cd = 1;
+			}
+		}
+		close(fd);
+	}
+	return(is_cd);
+}
+#endif
+		
+/* IDE bus scanning magic */
+enum {
+	IDE_GET_DEVICES_INFO = B_DEVICE_OP_CODES_END + 50,
+};
+struct ide_ctrl_info {
+	bool	ide_0_present;
+	bool	ide_0_master_present;
+	bool	ide_0_slave_present;
+	int	ide_0_master_type;
+	int	ide_0_slave_type;
+	bool	ide_1_present;
+	bool	ide_1_master_present;
+	bool	ide_1_slave_present;
+	int	ide_1_master_type;
+	int	ide_1_slave_type;
+};
+
+int  SDL_SYS_CDInit(void)
+{
+	char *SDLcdrom;
+	int raw_fd;
+	struct ide_ctrl_info info;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+				if ( CheckDrive(SDLcdrom) > 0 ) {
+					AddDrive(SDLcdrom);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+	/* Scan the system for CD-ROM drives */
+	raw_fd = open("/dev/disk/ide/rescan", 0);
+	if ( raw_fd >= 0 ) {
+		if (ioctl(raw_fd, IDE_GET_DEVICES_INFO, &info) == B_NO_ERROR) {
+			if ( info.ide_0_master_type == B_CD ) {
+				AddDrive("/dev/disk/ide/0/master/raw");
+			}
+			if ( info.ide_0_slave_type == B_CD ) {
+				AddDrive("/dev/disk/ide/0/slave/raw");
+			}
+			if ( info.ide_1_master_type == B_CD ) {
+				AddDrive("/dev/disk/ide/1/master/raw");
+			}
+			if ( info.ide_1_slave_type == B_CD ) {
+				AddDrive("/dev/disk/ide/1/slave/raw");
+			}
+		}
+		close(raw_fd);
+	}
+	return(0);
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int index, int command, void *arg)
+{
+	int okay;
+	int fd;
+
+	okay = 0;
+	fd = open(SDL_cdlist[index], 0);
+	if ( fd >= 0 ) {
+		if ( ioctl(fd, command, arg) == B_NO_ERROR ) {
+			okay = 1;
+		}
+		close(fd);
+	}
+	return(okay ? 0 : -1);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+} 
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(drive);
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	int i;
+	scsi_toc toc;
+
+	if ( SDL_SYS_CDioctl(cdrom->id, B_SCSI_GET_TOC, &toc) == 0 ) {
+		cdrom->numtracks = CD_NUMTRACKS(toc);
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		for ( i=0; i<=cdrom->numtracks; ++i ) {
+			cdrom->track[i].id = CD_TRACK_N(toc, i);
+			/* FIXME:  How do we tell on BeOS? */
+			cdrom->track[i].type = SDL_AUDIO_TRACK;
+			cdrom->track[i].offset = MSF_TO_FRAMES(
+							CD_TRACK_M(toc, i),
+							CD_TRACK_S(toc, i),
+							CD_TRACK_F(toc, i));
+			cdrom->track[i].length = 0;
+			if ( i > 0 ) {
+				cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+			}
+		}
+		return(0);
+	} else {
+		return(-1);
+	}
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	int fd;
+	int cur_frame;
+	scsi_position pos;
+
+	fd = open(SDL_cdlist[cdrom->id], 0);
+	cur_frame = 0;
+	if ( fd >= 0 ) {
+		if ( ioctl(fd, B_SCSI_GET_POSITION, &pos) == B_NO_ERROR ) {
+			cur_frame = MSF_TO_FRAMES(
+				POS_ABS_M(pos), POS_ABS_S(pos), POS_ABS_F(pos));
+		}
+		if ( ! pos.position[1] || (pos.position[1] >= 0x13) ||
+			((pos.position[1] == 0x12) && (!pos.position[6])) ) {
+			status = CD_STOPPED;
+		} else
+		if ( pos.position[1] == 0x11 ) {
+			status = CD_PLAYING;
+		} else {
+			status = CD_PAUSED;
+		}
+		close(fd);
+	} else {
+		status = CD_TRAYEMPTY;
+	}
+	if ( position ) {
+		*position = cur_frame;
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	int okay;
+	int fd;
+	scsi_play_position pos;
+
+	okay = 0;
+	fd = open(SDL_cdlist[cdrom->id], 0);
+	if ( fd >= 0 ) {
+		FRAMES_TO_MSF(start, &pos.start_m, &pos.start_s, &pos.start_f);
+		FRAMES_TO_MSF(start+length, &pos.end_m, &pos.end_s, &pos.end_f);
+		if ( ioctl(fd, B_SCSI_PLAY_POSITION, &pos) == B_NO_ERROR ) {
+			okay = 1;
+		}
+		close(fd);
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_PAUSE_AUDIO, 0));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_RESUME_AUDIO, 0));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_STOP_AUDIO, 0));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, B_SCSI_EJECT, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	free(cdrom);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/dummy/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Stub functions for system-level CD-ROM audio control */
+
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+int  SDL_SYS_CDInit(void)
+{
+	return(0);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	return;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/freebsd/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,411 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/cdio.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static dev_t SDL_cdmode[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+/* Some ioctl() errno values which occur when the tray is empty */
+#define ERRNO_TRAYEMPTY(errno)	\
+	((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive, struct stat *stbuf)
+{
+	int is_cd, cdfd;
+	struct ioc_read_subchannel info;
+
+	/* If it doesn't exist, return -1 */
+	if ( stat(drive, stbuf) < 0 ) {
+		return(-1);
+	}
+
+	/* If it does exist, verify that it's an available CD-ROM */
+	is_cd = 0;
+	if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
+		cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
+		if ( cdfd >= 0 ) {
+			info.address_format = CD_MSF_FORMAT;
+			info.data_format = CD_CURRENT_POSITION;
+			info.data_len = 0;
+			info.data = NULL;
+			/* Under Linux, EIO occurs when a disk is not present.
+			   This isn't 100% reliable, so we use the USE_MNTENT
+			   code above instead.
+			 */
+			if ( (ioctl(cdfd, CDIOCREADSUBCHANNEL, &info) == 0) ||
+						ERRNO_TRAYEMPTY(errno) ) {
+				is_cd = 1;
+			}
+			close(cdfd);
+		}
+	}
+	return(is_cd);
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive, struct stat *stbuf)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Check to make sure it's not already in our list.
+	 	   This can happen when we see a drive via symbolic link.
+		 */
+		for ( i=0; i<SDL_numcds; ++i ) {
+			if ( stbuf->st_rdev == SDL_cdmode[i] ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
+#endif
+				return;
+			}
+		}
+
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		SDL_cdmode[i] = stbuf->st_rdev;
+		++SDL_numcds;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	/* checklist: /dev/cdrom,/dev/cd?c /dev/acd?c
+			/dev/matcd?c /dev/mcd?c /dev/scd?c */
+	static char *checklist[] = {
+	"cdrom", "?0 cd?", "?0 acd?", "?0 matcd?", "?0 mcd?", "?0 scd?",NULL
+	};
+	char *SDLcdrom;
+	int i, j, exists;
+	char drive[32];
+	struct stat stbuf;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+				if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
+					AddDrive(SDLcdrom, &stbuf);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+	/* Scan the system for CD-ROM drives */
+	for ( i=0; checklist[i]; ++i ) {
+		if ( checklist[i][0] == '?' ) {
+			char *insert;
+			exists = 1;
+			for ( j=checklist[i][1]; exists; ++j ) {
+				sprintf(drive, "/dev/%sc", &checklist[i][3]);
+				insert = strchr(drive, '?');
+				if ( insert != NULL ) {
+					*insert = j;
+				}
+				switch (CheckDrive(drive, &stbuf)) {
+					/* Drive exists and is a CD-ROM */
+					case 1:
+						AddDrive(drive, &stbuf);
+						break;
+					/* Drive exists, but isn't a CD-ROM */
+					case 0:
+						break;
+					/* Drive doesn't exist */
+					case -1:
+						exists = 0;
+						break;
+				}
+			}
+		} else {
+			sprintf(drive, "/dev/%s", checklist[i]);
+			if ( CheckDrive(drive, &stbuf) > 0 ) {
+				AddDrive(drive, &stbuf);
+			}
+		}
+	}
+	return(0);
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int id, int command, void *arg)
+{
+	int retval;
+
+	retval = ioctl(id, command, arg);
+	if ( retval < 0 ) {
+		SDL_SetError("ioctl() error: %s", strerror(errno));
+	}
+	return(retval);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(open(SDL_cdlist[drive], (O_RDONLY|O_EXCL|O_NONBLOCK), 0));
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	struct ioc_toc_header toc;
+	int i, okay;
+	struct ioc_read_toc_entry entry;
+	struct cd_toc_entry data;
+
+	okay = 0;
+	if ( SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0 ) {
+		cdrom->numtracks = toc.ending_track-toc.starting_track+1;
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		/* Read all the track TOC entries */
+		for ( i=0; i<=cdrom->numtracks; ++i ) {
+			if ( i == cdrom->numtracks ) {
+				cdrom->track[i].id = 0xAA; /* CDROM_LEADOUT */
+			} else {
+				cdrom->track[i].id = toc.starting_track+i;
+			}
+			entry.starting_track = cdrom->track[i].id;
+			entry.address_format = CD_MSF_FORMAT;
+			entry.data_len = sizeof(data);
+			entry.data = &data;
+			if ( SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCENTRYS,
+								&entry) < 0 ) {
+				break;
+			} else {
+				cdrom->track[i].type = data.control;
+				cdrom->track[i].offset = MSF_TO_FRAMES(
+						data.addr.msf.minute,
+						data.addr.msf.second,
+						data.addr.msf.frame);
+				cdrom->track[i].length = 0;
+				if ( i > 0 ) {
+					cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+				}
+			}
+		}
+		if ( i == (cdrom->numtracks+1) ) {
+			okay = 1;
+		}
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	struct ioc_toc_header toc;
+	struct ioc_read_subchannel info;
+	struct cd_sub_channel_info data;
+
+	info.address_format = CD_MSF_FORMAT;
+	info.data_format = CD_CURRENT_POSITION;
+	info.track = 0;
+	info.data_len = sizeof(data);
+	info.data = &data;
+	if ( ioctl(cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0 ) {
+		if ( ERRNO_TRAYEMPTY(errno) ) {
+			status = CD_TRAYEMPTY;
+		} else {
+			status = CD_ERROR;
+		}
+	} else {
+		switch (data.header.audio_status) {
+			case CD_AS_AUDIO_INVALID:
+			case CD_AS_NO_STATUS:
+				/* Try to determine if there's a CD available */
+				if (ioctl(cdrom->id,CDIOREADTOCHEADER,&toc)==0)
+					status = CD_STOPPED;
+				else
+					status = CD_TRAYEMPTY;
+				break;
+			case CD_AS_PLAY_COMPLETED:
+				status = CD_STOPPED;
+				break;
+			case CD_AS_PLAY_IN_PROGRESS:
+				status = CD_PLAYING;
+				break;
+			case CD_AS_PLAY_PAUSED:
+				status = CD_PAUSED;
+				break;
+			default:
+				status = CD_ERROR;
+				break;
+		}
+	}
+	if ( position ) {
+		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+			*position = MSF_TO_FRAMES(
+					data.what.position.absaddr.msf.minute,
+					data.what.position.absaddr.msf.second,
+					data.what.position.absaddr.msf.frame);
+		} else {
+			*position = 0;
+		}
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	struct ioc_play_msf playtime;
+
+	FRAMES_TO_MSF(start,
+		&playtime.start_m, &playtime.start_s, &playtime.start_f);
+	FRAMES_TO_MSF(start+length,
+		&playtime.end_m, &playtime.end_s, &playtime.end_f);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
+	playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
+	playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
+#endif
+	ioctl(cdrom->id, CDIOCSTART, 0);
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCPLAYMSF, &playtime));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCPAUSE, 0));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCRESUME, 0));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCSTOP, 0));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCEJECT, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	close(cdrom->id);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/linux/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,528 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#ifdef __linux__
+#include <linux/cdrom.h>
+#endif
+#ifdef __SVR4
+#include <sys/cdio.h>
+#endif
+
+/* Define this to use the alternative getmntent() code */
+#ifndef __SVR4
+#define USE_MNTENT
+#endif
+
+#ifdef USE_MNTENT
+#if defined(__USLC__)
+#include <sys/mntent.h>
+#else
+#include <mntent.h>
+#endif
+
+#ifndef _PATH_MNTTAB
+#ifdef MNTTAB
+#define _PATH_MNTTAB	MNTTAB
+#else
+#define _PATH_MNTTAB	"/etc/fstab"
+#endif
+#endif /* !_PATH_MNTTAB */
+
+#ifndef _PATH_MOUNTED
+#define _PATH_MOUNTED	"/etc/mtab"
+#endif /* !_PATH_MOUNTED */
+
+#ifndef MNTTYPE_CDROM
+#define MNTTYPE_CDROM	"iso9660"
+#endif
+#ifndef MNTTYPE_SUPER
+#define MNTTYPE_SUPER	"supermount"
+#endif
+#endif /* USE_MNTENT */
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static dev_t SDL_cdmode[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+/* Some ioctl() errno values which occur when the tray is empty */
+#define ERRNO_TRAYEMPTY(errno)	\
+	((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive, char *mnttype, struct stat *stbuf)
+{
+	int is_cd, cdfd;
+	struct cdrom_subchnl info;
+
+	/* If it doesn't exist, return -1 */
+	if ( stat(drive, stbuf) < 0 ) {
+		return(-1);
+	}
+
+	/* If it does exist, verify that it's an available CD-ROM */
+	is_cd = 0;
+	if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
+		cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
+		if ( cdfd >= 0 ) {
+			info.cdsc_format = CDROM_MSF;
+			/* Under Linux, EIO occurs when a disk is not present.
+			 */
+			if ( (ioctl(cdfd, CDROMSUBCHNL, &info) == 0) ||
+						ERRNO_TRAYEMPTY(errno) ) {
+				is_cd = 1;
+			}
+			close(cdfd);
+		}
+#ifdef USE_MNTENT
+		/* Even if we can't read it, it might be mounted */
+		else if ( mnttype && (strcmp(mnttype, MNTTYPE_CDROM) == 0) ) {
+			is_cd = 1;
+		}
+#endif
+	}
+	return(is_cd);
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive, struct stat *stbuf)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Check to make sure it's not already in our list.
+	 	   This can happen when we see a drive via symbolic link.
+		 */
+		for ( i=0; i<SDL_numcds; ++i ) {
+			if ( stbuf->st_rdev == SDL_cdmode[i] ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
+#endif
+				return;
+			}
+		}
+
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		SDL_cdmode[i] = stbuf->st_rdev;
+		++SDL_numcds;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+#ifdef USE_MNTENT
+static void CheckMounts(const char *mtab)
+{
+	FILE *mntfp;
+	struct mntent *mntent;
+	struct stat stbuf;
+
+	mntfp = setmntent(mtab, "r");
+	if ( mntfp != NULL ) {
+		char *tmp, mnt_type[32], mnt_dev[1024];
+
+		while ( (mntent=getmntent(mntfp)) != NULL ) {
+			/* Warning, possible buffer overflow.. */
+			strcpy(mnt_type, mntent->mnt_type);
+			strcpy(mnt_dev, mntent->mnt_fsname);
+
+			/* Handle "supermount" filesystem mounts */
+			if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
+				tmp = strstr(mntent->mnt_opts, "fs=");
+				if ( tmp ) {
+					strcpy(mnt_type, tmp+strlen("fs="));
+					tmp = strchr(mnt_type, ',');
+					if ( tmp ) {
+						*tmp = '\0';
+					}
+				}
+				tmp = strstr(mntent->mnt_opts, "dev=");
+				if ( tmp ) {
+					strcpy(mnt_dev, tmp+strlen("dev="));
+					tmp = strchr(mnt_dev, ',');
+					if ( tmp ) {
+						*tmp = '\0';
+					}
+				}
+			}
+			if ( strcmp(mnt_type, MNTTYPE_CDROM) == 0 ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking mount path from %s: %s mounted on %s of %s\n",
+	mtab, mnt_dev, mntent->mnt_dir, mnt_type);
+#endif
+				if (CheckDrive(mnt_dev, mnt_type, &stbuf) > 0) {
+					AddDrive(mnt_dev, &stbuf);
+				}
+			}
+		}
+		endmntent(mntfp);
+	}
+}
+#endif /* USE_MNTENT */
+
+int  SDL_SYS_CDInit(void)
+{
+	/* checklist: /dev/cdrom, /dev/hd?, /dev/scd? /dev/sr? */
+	static char *checklist[] = {
+		"cdrom", "?a hd?", "?0 scd?", "?0 sr?", NULL
+	};
+	char *SDLcdrom;
+	int i, j, exists;
+	char drive[32];
+	struct stat stbuf;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom);
+#endif
+				if ( CheckDrive(SDLcdrom, NULL, &stbuf) > 0 ) {
+					AddDrive(SDLcdrom, &stbuf);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+#ifdef USE_MNTENT
+	/* Check /dev/cdrom first :-) */
+	if (CheckDrive("/dev/cdrom", NULL, &stbuf) > 0) {
+		AddDrive("/dev/cdrom", &stbuf);
+	}
+
+	/* Now check the currently mounted CD drives */
+	CheckMounts(_PATH_MOUNTED);
+
+	/* Finally check possible mountable drives in /etc/fstab */
+	CheckMounts(_PATH_MNTTAB);
+
+	/* If we found our drives, there's nothing left to do */
+	if ( SDL_numcds > 0 ) {
+		return(0);
+	}
+#endif /* USE_MNTENT */
+
+	/* Scan the system for CD-ROM drives.
+	   Not always 100% reliable, so use the USE_MNTENT code above first.
+	 */
+	for ( i=0; checklist[i]; ++i ) {
+		if ( checklist[i][0] == '?' ) {
+			char *insert;
+			exists = 1;
+			for ( j=checklist[i][1]; exists; ++j ) {
+				sprintf(drive, "/dev/%s", &checklist[i][3]);
+				insert = strchr(drive, '?');
+				if ( insert != NULL ) {
+					*insert = j;
+				}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
+#endif
+				switch (CheckDrive(drive, NULL, &stbuf)) {
+					/* Drive exists and is a CD-ROM */
+					case 1:
+						AddDrive(drive, &stbuf);
+						break;
+					/* Drive exists, but isn't a CD-ROM */
+					case 0:
+						break;
+					/* Drive doesn't exist */
+					case -1:
+						exists = 0;
+						break;
+				}
+			}
+		} else {
+			sprintf(drive, "/dev/%s", checklist[i]);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
+#endif
+			if ( CheckDrive(drive, NULL, &stbuf) > 0 ) {
+				AddDrive(drive, &stbuf);
+			}
+		}
+	}
+	return(0);
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int id, int command, void *arg)
+{
+	int retval;
+
+	retval = ioctl(id, command, arg);
+	if ( retval < 0 ) {
+		SDL_SetError("ioctl() error: %s", strerror(errno));
+	}
+	return(retval);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(open(SDL_cdlist[drive], (O_RDONLY|O_EXCL|O_NONBLOCK), 0));
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	struct cdrom_tochdr toc;
+	int i, okay;
+	struct cdrom_tocentry entry;
+
+	okay = 0;
+	if ( SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCHDR, &toc) == 0 ) {
+		cdrom->numtracks = toc.cdth_trk1-toc.cdth_trk0+1;
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		/* Read all the track TOC entries */
+		for ( i=0; i<=cdrom->numtracks; ++i ) {
+			if ( i == cdrom->numtracks ) {
+				cdrom->track[i].id = CDROM_LEADOUT;
+			} else {
+				cdrom->track[i].id = toc.cdth_trk0+i;
+			}
+			entry.cdte_track = cdrom->track[i].id;
+			entry.cdte_format = CDROM_MSF;
+			if ( SDL_SYS_CDioctl(cdrom->id, CDROMREADTOCENTRY,
+								&entry) < 0 ) {
+				break;
+			} else {
+				if ( entry.cdte_ctrl & CDROM_DATA_TRACK ) {
+					cdrom->track[i].type = SDL_DATA_TRACK;
+				} else {
+					cdrom->track[i].type = SDL_AUDIO_TRACK;
+				}
+				cdrom->track[i].offset = MSF_TO_FRAMES(
+						entry.cdte_addr.msf.minute,
+						entry.cdte_addr.msf.second,
+						entry.cdte_addr.msf.frame);
+				cdrom->track[i].length = 0;
+				if ( i > 0 ) {
+					cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+				}
+			}
+		}
+		if ( i == (cdrom->numtracks+1) ) {
+			okay = 1;
+		}
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	struct cdrom_tochdr toc;
+	struct cdrom_subchnl info;
+
+	info.cdsc_format = CDROM_MSF;
+	if ( ioctl(cdrom->id, CDROMSUBCHNL, &info) < 0 ) {
+		if ( ERRNO_TRAYEMPTY(errno) ) {
+			status = CD_TRAYEMPTY;
+		} else {
+			status = CD_ERROR;
+		}
+	} else {
+		switch (info.cdsc_audiostatus) {
+			case CDROM_AUDIO_INVALID:
+			case CDROM_AUDIO_NO_STATUS:
+				/* Try to determine if there's a CD available */
+				if (ioctl(cdrom->id, CDROMREADTOCHDR, &toc)==0)
+					status = CD_STOPPED;
+				else
+					status = CD_TRAYEMPTY;
+				break;
+			case CDROM_AUDIO_COMPLETED:
+				status = CD_STOPPED;
+				break;
+			case CDROM_AUDIO_PLAY:
+				status = CD_PLAYING;
+				break;
+			case CDROM_AUDIO_PAUSED:
+				/* Workaround buggy CD-ROM drive */
+				if ( info.cdsc_trk == CDROM_LEADOUT ) {
+					status = CD_STOPPED;
+				} else {
+					status = CD_PAUSED;
+				}
+				break;
+			default:
+				status = CD_ERROR;
+				break;
+		}
+	}
+	if ( position ) {
+		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+			*position = MSF_TO_FRAMES(
+					info.cdsc_absaddr.msf.minute,
+					info.cdsc_absaddr.msf.second,
+					info.cdsc_absaddr.msf.frame);
+		} else {
+			*position = 0;
+		}
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	struct cdrom_msf playtime;
+
+	FRAMES_TO_MSF(start,
+	   &playtime.cdmsf_min0, &playtime.cdmsf_sec0, &playtime.cdmsf_frame0);
+	FRAMES_TO_MSF(start+length,
+	   &playtime.cdmsf_min1, &playtime.cdmsf_sec1, &playtime.cdmsf_frame1);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
+	playtime.cdmsf_min0, playtime.cdmsf_sec0, playtime.cdmsf_frame0,
+	playtime.cdmsf_min1, playtime.cdmsf_sec1, playtime.cdmsf_frame1);
+#endif
+	return(SDL_SYS_CDioctl(cdrom->id, CDROMPLAYMSF, &playtime));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDROMPAUSE, 0));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDROMRESUME, 0));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDROMSTOP, 0));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDROMEJECT, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	close(cdrom->id);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/macos/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,526 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* MacOS functions for system-level CD-ROM audio control */
+
+#include <Devices.h>
+#include <Files.h>
+#include <LowMem.h> /* Use entry table macros, not functions in InterfaceLib  */
+
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+#include "SDL_syscdrom_c.h"
+
+/* Added by Matt Slot */
+#if !defined(LMGetUnitTableEntryCount)
+  #define LMGetUnitTableEntryCount()   *(short *)0x01D2
+#endif
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	26	
+
+/* A list of available CD-ROM drives */
+static long SDL_cdversion = 0;
+static struct {
+	short		dRefNum;
+	short		driveNum;
+	long		frames;
+	char		name[256];
+	Boolean		hasAudio;
+	} SDL_cdlist[MAX_DRIVES];
+static StringPtr gDriverName = "\p.AppleCD";
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+static short SDL_SYS_ShortToBCD(short value)
+{
+	return((value % 10) + (value / 10) * 0x10); /* Convert value to BCD */
+}
+
+static short SDL_SYS_BCDToShort(short value)
+{
+	return((value % 0x10) + (value / 0x10) * 10); /* Convert value from BCD */
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	SInt16			dRefNum = 0;
+	SInt16			first, last;
+
+	SDL_numcds = 0;
+
+	/* Check that the software is available */
+	if (Gestalt(kGestaltAudioCDSelector, &SDL_cdversion) || 
+			!SDL_cdversion) return(0);
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Walk the list, count each AudioCD driver, and save the refnums */
+	first = -1;
+	last = 0 - LMGetUnitTableEntryCount();
+	for(dRefNum = first; dRefNum >= last; dRefNum--) {
+		Str255		driverName;
+		StringPtr	namePtr;
+		DCtlHandle	deviceEntry;
+
+		deviceEntry = GetDCtlEntry(dRefNum);
+		if (! deviceEntry) continue;
+		
+		/* Is this an .AppleCD ? */
+		namePtr = (*deviceEntry)->dCtlFlags & (1L << dRAMBased) ?
+				((StringPtr) ((DCtlPtr) deviceEntry)->dCtlDriver + 18) :
+				((StringPtr) (*deviceEntry)->dCtlDriver + 18);
+		BlockMoveData(namePtr, driverName, namePtr[0]+1);
+		if (driverName[0] > gDriverName[0]) driverName[0] = gDriverName[0];
+		if (! EqualString(driverName, gDriverName, false, false)) continue;
+
+		/* Record the basic info for each drive */
+		SDL_cdlist[SDL_numcds].dRefNum = dRefNum;
+		BlockMoveData(namePtr + 1, SDL_cdlist[SDL_numcds].name, namePtr[0]);
+		SDL_cdlist[SDL_numcds].name[namePtr[0]] = 0;
+		SDL_cdlist[SDL_numcds].hasAudio = false;
+		SDL_numcds++;
+	}
+	return(0);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive].name);
+}
+
+static int get_drivenum(int drive)
+{
+	QHdr *driveQ = GetDrvQHdr();
+	DrvQEl *driveElem;
+
+	/* Update the drive number */
+	SDL_cdlist[drive].driveNum = 0;
+	if ( driveQ->qTail ) {
+		driveQ->qTail->qLink = 0;
+	}
+	for ( driveElem=(DrvQEl *)driveQ->qHead; driveElem;
+	      driveElem = (DrvQEl *)driveElem->qLink ) {
+		if ( driveElem->dQRefNum == SDL_cdlist[drive].dRefNum ) {
+			SDL_cdlist[drive].driveNum = driveElem->dQDrive;
+			break;
+		}
+	}
+	return(SDL_cdlist[drive].driveNum);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(drive);
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	CDCntrlParam		cdpb;
+	CDTrackData			tracks[SDL_MAX_TRACKS];
+	long				i, leadout;
+
+	/* Get the number of tracks on the CD by examining the TOC */
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kReadTOC;
+	cdpb.csParam.words[0] = kGetTrackRange;
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+
+	cdrom->numtracks = 
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) - 
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1;
+	if ( cdrom->numtracks > SDL_MAX_TRACKS )
+		cdrom->numtracks = SDL_MAX_TRACKS;
+	cdrom->status = CD_STOPPED;
+	cdrom->cur_track = 0; /* Apparently these are set elsewhere */
+	cdrom->cur_frame = 0; /* Apparently these are set elsewhere */
+
+
+	/* Get the lead out area of the CD by examining the TOC */
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kReadTOC;
+	cdpb.csParam.words[0] = kGetLeadOutArea;
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+
+	leadout = MSF_TO_FRAMES(
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]),
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]),
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[2]));
+
+	/* Get an array of track locations by examining the TOC */
+	memset(tracks, 0, sizeof(tracks));
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kReadTOC;
+	cdpb.csParam.words[0] = kGetTrackEntries;	/* Type of Query */
+	* ((long *) (cdpb.csParam.words+1)) = (long) tracks;				
+	cdpb.csParam.words[3] = cdrom->numtracks * sizeof(tracks[0]);		
+	* ((char *) (cdpb.csParam.words+4)) = 1;	/* First track */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+
+	/* Read all the track TOC entries */
+	SDL_cdlist[cdrom->id].hasAudio = false;
+	for ( i=0; i<cdrom->numtracks; ++i ) 
+		{
+		cdrom->track[i].id = i+1;
+		if (tracks[i].entry.control & kDataTrackMask)
+			cdrom->track[i].type = SDL_DATA_TRACK;
+		else
+			{
+			cdrom->track[i].type = SDL_AUDIO_TRACK;
+			SDL_cdlist[SDL_numcds].hasAudio = true;
+			}
+		
+		cdrom->track[i].offset = MSF_TO_FRAMES(
+				SDL_SYS_BCDToShort(tracks[i].entry.min),
+				SDL_SYS_BCDToShort(tracks[i].entry.min),
+				SDL_SYS_BCDToShort(tracks[i].entry.frame));
+		cdrom->track[i].length = MSF_TO_FRAMES(
+				SDL_SYS_BCDToShort(tracks[i+1].entry.min),
+				SDL_SYS_BCDToShort(tracks[i+1].entry.min),
+				SDL_SYS_BCDToShort(tracks[i+1].entry.frame)) -
+				cdrom->track[i].offset;
+		}
+	
+	/* Apparently SDL wants a fake last entry */
+	cdrom->track[i].offset = leadout;
+	cdrom->track[i].length = 0;
+
+	return(0);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDCntrlParam cdpb;
+	CDstatus status = CD_ERROR;
+	Boolean spinning = false;
+
+	if (position) *position = 0;
+
+	/* Get the number of tracks on the CD by examining the TOC */
+	if ( ! get_drivenum(cdrom->id) ) {
+		return(CD_TRAYEMPTY);
+	}
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kReadTOC;
+	cdpb.csParam.words[0] = kGetTrackRange;
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(CD_ERROR);
+	}
+
+	cdrom->numtracks = 
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[1]) - 
+			SDL_SYS_BCDToShort(cdpb.csParam.bytes[0]) + 1;
+	if ( cdrom->numtracks > SDL_MAX_TRACKS )
+		cdrom->numtracks = SDL_MAX_TRACKS;
+	cdrom->cur_track = 0; /* Apparently these are set elsewhere */
+	cdrom->cur_frame = 0; /* Apparently these are set elsewhere */
+
+
+	if (1 || SDL_cdlist[cdrom->id].hasAudio) {
+		/* Get the current playback status */
+		memset(&cdpb, 0, sizeof(cdpb));
+		cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+		cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+		cdpb.csCode = kAudioStatus;
+		if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+			SDL_SetError("PBControlSync() failed");
+			return(-1);
+		}
+	
+		switch(cdpb.csParam.cd.status) {
+			case kStatusPlaying:
+				status = CD_PLAYING;
+				spinning = true;
+				break;
+			case kStatusPaused:
+				status = CD_PAUSED;
+				spinning = true;
+				break;
+			case kStatusMuted:
+				status = CD_PLAYING; /* What should I do here? */
+				spinning = true;
+				break;
+			case kStatusDone:
+				status = CD_STOPPED;
+				spinning = true;
+				break;
+			case kStatusStopped:
+				status = CD_STOPPED;
+				spinning = false;
+				break;
+			case kStatusError:
+			default:
+				status = CD_ERROR;
+				spinning = false;
+				break;
+			}
+
+		if (spinning && position) *position = MSF_TO_FRAMES(
+				SDL_SYS_BCDToShort(cdpb.csParam.cd.minute),
+				SDL_SYS_BCDToShort(cdpb.csParam.cd.second),
+				SDL_SYS_BCDToShort(cdpb.csParam.cd.frame));
+		}
+	else
+		status = CD_ERROR; /* What should I do here? */
+
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	CDCntrlParam cdpb;
+
+	/* Pause the current audio playback to avoid audible artifacts */
+	if ( SDL_SYS_CDPause(cdrom) < 0 ) {
+		return(-1);
+	}
+
+	/* Specify the AudioCD playback mode */
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kSetPlayMode;
+	cdpb.csParam.bytes[0] = false;			/* Repeat? */
+	cdpb.csParam.bytes[1] = kPlayModeSequential;	/* Play mode */
+	/* ¥¥¥ÊTreat as soft error, NEC Drive doesnt support this call ¥¥¥ */
+	PBControlSync((ParmBlkPtr) &cdpb);
+
+#if 1
+	/* Specify the end of audio playback */
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioStop;
+	cdpb.csParam.words[0] = kBlockPosition;		/* Position Mode */
+	*(long *) (cdpb.csParam.words + 1) = start+length-1; /* Search Address */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+
+	/* Specify the start of audio playback, and start it */
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioPlay;
+	cdpb.csParam.words[0] = kBlockPosition;			/* Position Mode */
+	*(long *) (cdpb.csParam.words + 1) = start+1;	/* Search Address */
+	cdpb.csParam.words[3] = false;					/* Stop address? */
+	cdpb.csParam.words[4] = kStereoPlayMode;		/* Audio Play Mode */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+#else
+	/* Specify the end of audio playback */
+	FRAMES_TO_MSF(start+length, &m, &s, &f);
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioStop;
+	cdpb.csParam.words[0] = kTrackPosition;			/* Position Mode */
+	cdpb.csParam.words[1] = 0;						/* Search Address (hiword)*/
+	cdpb.csParam.words[2] = 						/* Search Address (loword)*/
+			SDL_SYS_ShortToBCD(cdrom->numtracks);	
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+
+	/* Specify the start of audio playback, and start it */
+	FRAMES_TO_MSF(start, &m, &s, &f);
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioPlay;
+	cdpb.csParam.words[0] = kTrackPosition;			/* Position Mode */
+	cdpb.csParam.words[1] = 0;						/* Search Address (hiword)*/
+	cdpb.csParam.words[2] = SDL_SYS_ShortToBCD(1);	/* Search Address (loword)*/
+	cdpb.csParam.words[3] = false;					/* Stop address? */
+	cdpb.csParam.words[4] = kStereoPlayMode;		/* Audio Play Mode */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+#endif
+
+	return(0);
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	CDCntrlParam cdpb;
+
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioPause;
+	cdpb.csParam.words[0] = 0;	/* Pause/Continue Flag (hiword) */
+	cdpb.csParam.words[1] = 1;	/* Pause/Continue Flag (loword) */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+	return(0);
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	CDCntrlParam cdpb;
+
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioPause;
+	cdpb.csParam.words[0] = 0;	/* Pause/Continue Flag (hiword) */
+	cdpb.csParam.words[1] = 0;	/* Pause/Continue Flag (loword) */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+	return(0);
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	CDCntrlParam cdpb;
+
+	memset(&cdpb, 0, sizeof(cdpb));
+	cdpb.ioVRefNum = SDL_cdlist[cdrom->id].driveNum;
+	cdpb.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+	cdpb.csCode = kAudioStop;
+	cdpb.csParam.words[0] = 0;		/* Position Mode */
+	cdpb.csParam.words[1] = 0;		/* Search Address (hiword) */
+	cdpb.csParam.words[2] = 0;		/* Search Address (loword) */
+	if ( PBControlSync((ParmBlkPtr)&cdpb) != noErr ) {
+		SDL_SetError("PBControlSync() failed");
+		return(-1);
+	}
+	return(0);
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	Boolean	disk = false;
+	QHdr *driveQ = GetDrvQHdr();
+	DrvQEl *driveElem;
+	HParamBlockRec hpb;
+	ParamBlockRec cpb;
+
+	for ( driveElem = (DrvQEl *) driveQ->qHead; driveElem; driveElem = 
+			  (driveElem) ? ((DrvQEl *) driveElem->qLink) : 
+			  ((DrvQEl *) driveQ->qHead) ) {
+		if ( driveQ->qTail ) {
+			driveQ->qTail->qLink = 0;
+		}
+		if ( driveElem->dQRefNum != SDL_cdlist[cdrom->id].dRefNum ) {
+			continue;
+		}
+	
+		/* Does drive contain mounted volume? If not, skip */
+		memset(&hpb, 0, sizeof(hpb));
+		hpb.volumeParam.ioVRefNum = driveElem->dQDrive;
+		if ( PBHGetVInfoSync(&hpb) != noErr ) {
+			continue;
+		}
+		if ( (UnmountVol(0, driveElem->dQDrive) == noErr) && 
+		     (Eject(0, driveElem->dQDrive) == noErr) ) {
+			driveElem = 0; /* Clear pointer to reset our loop */
+			disk = true;
+		}
+	}
+
+	/* If no disk is present, just eject the tray */
+	if (! disk) {
+		memset(&cpb, 0, sizeof(cpb));
+		cpb.cntrlParam.ioVRefNum = 0; /* No Drive */
+		cpb.cntrlParam.ioCRefNum = SDL_cdlist[cdrom->id].dRefNum;
+		cpb.cntrlParam.csCode = kEjectTheDisc;
+		if ( PBControlSync((ParmBlkPtr)&cpb) != noErr ) {
+			SDL_SetError("PBControlSync() failed");
+			return(-1);
+		}
+	}
+	return(0);
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	return;
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	while(SDL_numcds--) 
+		memset(SDL_cdlist + SDL_numcds, 0, sizeof(SDL_cdlist[0]));
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/macos/SDL_syscdrom_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,139 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+/* This is the MacOS specific header for the SDL CD-ROM API
+   Contributed by Matt Slot
+ */
+
+/* AppleCD Control calls */
+#define kVerifyTheDisc   	  5		/* Returns noErr if there is disc inserted */
+#define kEjectTheDisc   	  7		/* Eject disc from drive */
+#define kUserEject    		 80		/* Enable/disable the CD-ROM eject button */
+#define kReadTOC    		100		/* Extract various TOC information from the disc */
+#define kReadQ   			101		/* Extract Q subcode info for the current track */
+#define kAudioTrackSearch   103		/* Start playback from the indicated position */
+#define kAudioPlay    		104		/* Start playback from the indicated position */
+#define kAudioPause    		105		/* Pause/continue the playback */
+#define kAudioStop    		106		/* Stop playback at the indicated position */
+#define kAudioStatus    	107		/* Return audio play status */
+#define kAudioControl    	109		/* Set the output volume for the audio channels */
+#define kReadAudioVolume   	112		/* Get the output volume for the audio channels */
+#define kSetTrackList   	122		/* Set the track program for the audio CD to play */
+#define kGetTrackList   	123		/* Get the track program the audio CD is playing */
+#define kGetTrackIndex   	124		/* Get the track index the audio CD is playing */
+#define kSetPlayMode   		125		/* Set the audio tracks play mode */
+#define kGetPlayMode   		126		/* Get the audio tracks play mode */
+
+/* AppleCD Status calls */
+#define kGetDriveType   	 96		/* Get the type of the physical CD-ROM drive */
+#define kWhoIsThere    		 97		/* Get a bitmap of SCSI IDs the driver controls */
+#define kGetBlockSize    	 98		/* Get current block size of the CD-ROM drive */
+	
+/* AppleCD other constants */
+#define kBlockPosition    	  0		/* Position at the specified logical block number */
+#define kAbsMSFPosition    	  1		/* Position at the specified Min/Sec/Frame (in BCD) */
+#define kTrackPosition    	  2		/* Position at the specified track number (in BCD) */
+#define kIndexPosition    	  3		/* Position at the nth track in program (in BCD) */
+
+#define kMutedPlayMode   	  0		/* Play the audio track with no output */
+#define kStereoPlayMode   	  9		/* Play the audio track in normal stereo */
+
+#define kControlFieldMask  	0x0D	/* Bits 3,2,0 in the nibble */
+#define kDataTrackMask   	0x04	/* Indicates Data Track */
+
+#define kGetTrackRange    	  1		/* Query TOC for track numbers */
+#define kGetLeadOutArea    	  2		/* Query TOC for "Lead Out" end of audio data */
+#define kGetTrackEntries   	  3		/* Query TOC for track starts and data types */
+
+#define kStatusPlaying		  0		/* Audio Play operation in progress */
+#define kStatusPaused		  1		/* CD-ROM device in Hold Track ("Pause") state */
+#define kStatusMuted		  2		/* MUTING-ON operation in progress */
+#define kStatusDone			  3		/* Audio Play completed */
+#define kStatusError		  4		/* Error occurred during audio play operation */
+#define kStatusStopped		  5		/* Audio play operation not requested */
+
+#define kPlayModeSequential	  0		/*  Play tracks in order */
+#define kPlayModeShuffled	  1		/* Play tracks randomly */
+#define kPlayModeProgrammed   2		/* Use custom playlist */
+
+/* AppleCD Gestalt selectors */
+#define kGestaltAudioCDSelector    'aucd'
+#define kDriverVersion52   		0x00000520
+#define kDriverVersion51   		0x00000510
+#define kDriverVersion50   		0x00000500
+
+/* Drive type constants */
+#define kDriveAppleCD_SC   				  1
+#define kDriveAppleCD_SCPlus_or_150   	  2
+#define kDriveAppleCD_300_or_300Plus   	  3
+
+/* Misc constants */
+#define kFirstSCSIDevice   	 -33
+#define kLastSCSIDevice    	 -40
+
+#if PRAGMA_STRUCT_ALIGN
+	#pragma options align=mac68k
+#endif
+
+/* AppleCD driver parameter block */
+typedef struct CDCntrlParam {
+	QElemPtr				qLink;
+	short					qType;
+	short					ioTrap;
+	Ptr						ioCmdAddr;
+	IOCompletionUPP			ioCompletion;
+	OSErr					ioResult;
+	StringPtr				ioNamePtr;
+	short					ioVRefNum;
+	short					ioCRefNum;
+	short					csCode;
+	
+	union {
+		long				longs[6];
+		short				words[11];
+		unsigned char		bytes[22];
+		struct {
+			unsigned char	status;
+			unsigned char	play;
+			unsigned char	control;
+			unsigned char	minute;
+			unsigned char	second;
+			unsigned char	frame;
+			} cd;
+		} csParam;
+
+	} CDCntrlParam, *CDCntrlParamPtr;
+
+typedef union CDTrackData {
+	long				value;			/* Treat as a longword value */
+	struct {
+		unsigned char	reserved : 4;	/* Unused by AppleCD driver  */
+		unsigned char	control : 4;	/* Track flags (data track?) */
+		unsigned char	min;			/* Start of track (BCD)      */
+		unsigned char	sec;			/* Start of track (BCD)      */
+		unsigned char	frame;			/* Start of track (BCD)      */
+		} entry;						/* Broken into fields        */
+	} CDTrackData, *CDTrackPtr;
+	
+#if PRAGMA_STRUCT_ALIGN
+	#pragma options align=reset
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/openbsd/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,410 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/cdio.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static dev_t SDL_cdmode[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+/* Some ioctl() errno values which occur when the tray is empty */
+#define ERRNO_TRAYEMPTY(errno)	\
+	((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive, struct stat *stbuf)
+{
+	int is_cd, cdfd;
+	struct ioc_read_subchannel info;
+
+	/* If it doesn't exist, return -1 */
+	if ( stat(drive, stbuf) < 0 ) {
+		return(-1);
+	}
+
+	/* If it does exist, verify that it's an available CD-ROM */
+	is_cd = 0;
+	if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
+		cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
+		if ( cdfd >= 0 ) {
+			info.address_format = CD_MSF_FORMAT;
+			info.data_format = CD_CURRENT_POSITION;
+			info.data_len = 0;
+			info.data = NULL;
+			/* Under Linux, EIO occurs when a disk is not present.
+			   This isn't 100% reliable, so we use the USE_MNTENT
+			   code above instead.
+			 */
+			if ( (ioctl(cdfd, CDIOCREADSUBCHANNEL, &info) == 0) ||
+						ERRNO_TRAYEMPTY(errno) ) {
+				is_cd = 1;
+			}
+			close(cdfd);
+		}
+	}
+	return(is_cd);
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive, struct stat *stbuf)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Check to make sure it's not already in our list.
+	 	   This can happen when we see a drive via symbolic link.
+		 */
+		for ( i=0; i<SDL_numcds; ++i ) {
+			if ( stbuf->st_rdev == SDL_cdmode[i] ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
+#endif
+				return;
+			}
+		}
+
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		SDL_cdmode[i] = stbuf->st_rdev;
+		++SDL_numcds;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	static char *checklist[] = {
+		"?0 cd?c", "?0 acd?c", "cdrom", NULL
+	};
+	char *SDLcdrom;
+	int i, j, exists;
+	char drive[32];
+	struct stat stbuf;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+				if ( CheckDrive(SDLcdrom, &stbuf) > 0 ) {
+					AddDrive(SDLcdrom, &stbuf);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+	/* Scan the system for CD-ROM drives */
+	for ( i=0; checklist[i]; ++i ) {
+		if ( checklist[i][0] == '?' ) {
+			char *insert;
+			exists = 1;
+			for ( j=checklist[i][1]; exists; ++j ) {
+				sprintf(drive, "/dev/%s", &checklist[i][3]);
+				insert = strchr(drive, '?');
+				if ( insert != NULL ) {
+					*insert = j;
+				}
+				switch (CheckDrive(drive, &stbuf)) {
+					/* Drive exists and is a CD-ROM */
+					case 1:
+						AddDrive(drive, &stbuf);
+						break;
+					/* Drive exists, but isn't a CD-ROM */
+					case 0:
+						break;
+					/* Drive doesn't exist */
+					case -1:
+						exists = 0;
+						break;
+				}
+			}
+		} else {
+			sprintf(drive, "/dev/%s", checklist[i]);
+			if ( CheckDrive(drive, &stbuf) > 0 ) {
+				AddDrive(drive, &stbuf);
+			}
+		}
+	}
+	return(0);
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int id, int command, void *arg)
+{
+	int retval;
+
+	retval = ioctl(id, command, arg);
+	if ( retval < 0 ) {
+		SDL_SetError("ioctl() error: %s", strerror(errno));
+	}
+	return(retval);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(open(SDL_cdlist[drive], (O_RDONLY|O_EXCL|O_NONBLOCK), 0));
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	struct ioc_toc_header toc;
+	int i, okay;
+	struct ioc_read_toc_entry entry;
+	struct cd_toc_entry data;
+
+	okay = 0;
+	if ( SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCHEADER, &toc) == 0 ) {
+		cdrom->numtracks = toc.ending_track-toc.starting_track+1;
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		/* Read all the track TOC entries */
+		for ( i=0; i<=cdrom->numtracks; ++i ) {
+			if ( i == cdrom->numtracks ) {
+				cdrom->track[i].id = 0xAA; /* CDROM_LEADOUT */
+			} else {
+				cdrom->track[i].id = toc.starting_track+i;
+			}
+			entry.starting_track = cdrom->track[i].id;
+			entry.address_format = CD_MSF_FORMAT;
+			entry.data_len = sizeof(data);
+			entry.data = &data;
+			if ( SDL_SYS_CDioctl(cdrom->id, CDIOREADTOCENTRYS,
+								&entry) < 0 ) {
+				break;
+			} else {
+				cdrom->track[i].type = data.control;
+				cdrom->track[i].offset = MSF_TO_FRAMES(
+						data.addr.msf.minute,
+						data.addr.msf.second,
+						data.addr.msf.frame);
+				cdrom->track[i].length = 0;
+				if ( i > 0 ) {
+					cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+				}
+			}
+		}
+		if ( i == (cdrom->numtracks+1) ) {
+			okay = 1;
+		}
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	struct ioc_toc_header toc;
+	struct ioc_read_subchannel info;
+	struct cd_sub_channel_info data;
+
+	info.address_format = CD_MSF_FORMAT;
+	info.data_format = CD_CURRENT_POSITION;
+	info.track = 0;
+	info.data_len = sizeof(data);
+	info.data = &data;
+	if ( ioctl(cdrom->id, CDIOCREADSUBCHANNEL, &info) < 0 ) {
+		if ( ERRNO_TRAYEMPTY(errno) ) {
+			status = CD_TRAYEMPTY;
+		} else {
+			status = CD_ERROR;
+		}
+	} else {
+		switch (data.header.audio_status) {
+			case CD_AS_AUDIO_INVALID:
+			case CD_AS_NO_STATUS:
+				/* Try to determine if there's a CD available */
+				if (ioctl(cdrom->id,CDIOREADTOCHEADER,&toc)==0)
+					status = CD_STOPPED;
+				else
+					status = CD_TRAYEMPTY;
+				break;
+			case CD_AS_PLAY_COMPLETED:
+				status = CD_STOPPED;
+				break;
+			case CD_AS_PLAY_IN_PROGRESS:
+				status = CD_PLAYING;
+				break;
+			case CD_AS_PLAY_PAUSED:
+				status = CD_PAUSED;
+				break;
+			default:
+				status = CD_ERROR;
+				break;
+		}
+	}
+	if ( position ) {
+		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+			*position = MSF_TO_FRAMES(
+					data.what.position.absaddr.msf.minute,
+					data.what.position.absaddr.msf.second,
+					data.what.position.absaddr.msf.frame);
+		} else {
+			*position = 0;
+		}
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	struct ioc_play_msf playtime;
+
+	FRAMES_TO_MSF(start,
+		&playtime.start_m, &playtime.start_s, &playtime.start_f);
+	FRAMES_TO_MSF(start+length,
+		&playtime.end_m, &playtime.end_s, &playtime.end_f);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
+	playtime.start_m, playtime.start_s, playtime.start_f,
+	playtime.end_m, playtime.end_s, playtime.end_f);
+#endif
+	ioctl(cdrom->id, CDIOCSTART, 0);
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCPLAYMSF, &playtime));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCPAUSE, 0));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCRESUME, 0));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCSTOP, 0));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, CDIOCEJECT, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	close(cdrom->id);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/qnx/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,404 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#include <sys/types.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <string.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/cdrom.h>
+#include <sys/dcmd_cam.h>
+
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+
+/* The maximum number of CD-ROM drives we'll detect */
+#define MAX_DRIVES	16	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static dev_t SDL_cdmode[MAX_DRIVES];
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+/* Some ioctl() errno values which occur when the tray is empty */
+#define ERRNO_TRAYEMPTY(errno)	\
+	((errno == EIO) || (errno == ENOENT) || (errno == EINVAL))
+
+/* Check a drive to see if it is a CD-ROM */
+static int CheckDrive(char *drive, char *mnttype, struct stat *stbuf)
+{
+	int is_cd, cdfd;
+	cdrom_subch_data_t info;
+
+	/* If it doesn't exist, return -1 */
+	if ( stat(drive, stbuf) < 0 ) {
+		return(-1);
+	}
+
+	/* If it does exist, verify that it's an available CD-ROM */
+	is_cd = 0;
+	if ( S_ISCHR(stbuf->st_mode) || S_ISBLK(stbuf->st_mode) ) {
+		cdfd = open(drive, (O_RDONLY|O_EXCL|O_NONBLOCK), 0);
+		if ( cdfd >= 0 ) {
+			info.subch_command.data_format = CDROM_MSF;
+			/* Under Linux, EIO occurs when a disk is not present.
+			 */
+			if ((devctl(cdfd,DCMD_CAM_CDROMSUBCHNL,&info,sizeof(info),0) == 0) ||
+						ERRNO_TRAYEMPTY(errno) )
+			{
+				is_cd = 1;
+			}
+			close(cdfd);
+		}
+	}
+	return(is_cd);
+}
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive, struct stat *stbuf)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Check to make sure it's not already in our list.
+	 	   This can happen when we see a drive via symbolic link.
+		 */
+		for ( i=0; i<SDL_numcds; ++i ) {
+			if ( stbuf->st_rdev == SDL_cdmode[i] ) {
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Duplicate drive detected: %s == %s\n", drive, SDL_cdlist[i]);
+#endif
+				return;
+			}
+		}
+
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		SDL_cdmode[i] = stbuf->st_rdev;
+		++SDL_numcds;
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	/* checklist: /dev/cdrom, /dev/hd?, /dev/scd? /dev/sr? */
+	static char *checklist[] = {
+		"cdrom", "?0 cd?", "?1 cd?", "?a hd?", "?0 scd?", "?0 sr?", NULL
+	};
+	char *SDLcdrom;
+	int i, j, exists;
+	char drive[32];
+	struct stat stbuf;
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Look in the environment for our CD-ROM drive list */
+	SDLcdrom = getenv("SDL_CDROM");	/* ':' separated list of devices */
+	if ( SDLcdrom != NULL ) {
+		char *cdpath, *delim;
+		cdpath = malloc(strlen(SDLcdrom)+1);
+		if ( cdpath != NULL ) {
+			strcpy(cdpath, SDLcdrom);
+			SDLcdrom = cdpath;
+			do {
+				delim = strchr(SDLcdrom, ':');
+				if ( delim ) {
+					*delim++ = '\0';
+				}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking CD-ROM drive from SDL_CDROM: %s\n", SDLcdrom);
+#endif
+				if ( CheckDrive(SDLcdrom, NULL, &stbuf) > 0 ) {
+					AddDrive(SDLcdrom, &stbuf);
+				}
+				if ( delim ) {
+					SDLcdrom = delim;
+				} else {
+					SDLcdrom = NULL;
+				}
+			} while ( SDLcdrom );
+			free(cdpath);
+		}
+
+		/* If we found our drives, there's nothing left to do */
+		if ( SDL_numcds > 0 ) {
+			return(0);
+		}
+	}
+
+	/* Scan the system for CD-ROM drives */
+	for ( i=0; checklist[i]; ++i ) {
+		if ( checklist[i][0] == '?' ) {
+			char *insert;
+			exists = 1;
+			for ( j=checklist[i][1]; exists; ++j ) {
+				sprintf(drive, "/dev/%s", &checklist[i][3]);
+				insert = strchr(drive, '?');
+				if ( insert != NULL ) {
+					*insert = j;
+				}
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
+#endif
+				switch (CheckDrive(drive, NULL, &stbuf)) {
+					/* Drive exists and is a CD-ROM */
+					case 1:
+						AddDrive(drive, &stbuf);
+						break;
+					/* Drive exists, but isn't a CD-ROM */
+					case 0:
+						break;
+					/* Drive doesn't exist */
+					case -1:
+						exists = 0;
+						break;
+				}
+			}
+		} else {
+			sprintf(drive, "/dev/%s", checklist[i]);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Checking possible CD-ROM drive: %s\n", drive);
+#endif
+			if ( CheckDrive(drive, NULL, &stbuf) > 0 ) {
+				AddDrive(drive, &stbuf);
+			}
+		}
+	}
+	return(0);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	return(open(SDL_cdlist[drive], (O_RDONLY|O_EXCL|O_NONBLOCK), 0));
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	cdrom_read_toc_t toc;
+	int i, okay;
+
+	okay = 0;
+	if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), 0) == 0) {
+		cdrom->numtracks = toc.last_track - toc.first_track + 1;
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		/* Read all the track TOC entries */
+		for ( i=0; i<=cdrom->numtracks; ++i ) {
+			if ( i == cdrom->numtracks ) {
+				cdrom->track[i].id = CDROM_LEADOUT;
+			} else {
+#if 0 /* Sam 11/6/00 - an obsolete field? */
+				cdrom->track[i].id = toc.cdth_trk0+i;
+#else
+				cdrom->track[i].id = toc.first_track+i;
+#endif
+			}
+			cdrom->track[i].type = toc.toc_entry[i].control_adr;
+			cdrom->track[i].offset = MSF_TO_FRAMES(
+						toc.toc_entry[i].addr.msf.minute,
+						toc.toc_entry[i].addr.msf.second,
+						toc.toc_entry[i].addr.msf.frame);			
+			cdrom->track[i].length = 0;
+			if ( i > 0 ) {
+				cdrom->track[i-1].length =
+					cdrom->track[i].offset-
+					cdrom->track[i-1].offset;
+			}
+		}
+		if ( i == (cdrom->numtracks+1) ) {
+			okay = 1;
+		}
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	cdrom_read_toc_t toc;
+	subch_current_position_t info;
+
+#if 0 /* Sam 11/6/00 - an obsolete field? */
+	info.subch_command.data_format = CDROM_SUBCH_CURRENT_POSITION;
+	info.subch_command.track_number = 0;
+#else
+	info.data_format = CDROM_SUBCH_CURRENT_POSITION;
+	info.track_number = 0;
+#endif
+	if (devctl(cdrom->id, DCMD_CAM_CDROMSUBCHNL, &info, sizeof(info), 0) != 0) {
+		if ( ERRNO_TRAYEMPTY(errno) ) {
+			status = CD_TRAYEMPTY;
+		} else {
+			status = CD_ERROR;
+		}
+	} else {
+		switch (info.header.audio_status) {
+			case CDROM_AUDIO_INVALID:
+			case CDROM_AUDIO_NO_STATUS:
+				/* Try to determine if there's a CD available */
+				if (devctl(cdrom->id, DCMD_CAM_CDROMREADTOC, &toc, sizeof(toc), 0)==0)
+					status = CD_STOPPED;
+				else
+					status = CD_TRAYEMPTY;
+				break;
+			case CDROM_AUDIO_COMPLETED:
+				status = CD_STOPPED;
+				break;
+			case CDROM_AUDIO_PLAY:
+				status = CD_PLAYING;
+				break;
+			case CDROM_AUDIO_PAUSED:
+				/* Workaround buggy CD-ROM drive */
+				if ( info.data_format == CDROM_LEADOUT ) {
+					status = CD_STOPPED;
+				} else {
+					status = CD_PAUSED;
+				}
+				break;
+			default:
+				status = CD_ERROR;
+				break;
+		}
+	}
+	if ( position ) {
+		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+			*position = MSF_TO_FRAMES(
+					info.addr.msf.minute,
+					info.addr.msf.second,
+					info.addr.msf.frame);
+		} else {
+			*position = 0;
+		}
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	cdrom_playmsf_t playtime;
+
+	FRAMES_TO_MSF(start,
+	   &playtime.start_minute, &playtime.start_second, &playtime.start_frame);
+	FRAMES_TO_MSF(start+length,
+	   &playtime.end_minute, &playtime.end_second, &playtime.end_frame);
+#ifdef DEBUG_CDROM
+  fprintf(stderr, "Trying to play from %d:%d:%d to %d:%d:%d\n",
+	playtime.start_minute, playtime.start_second, playtime.start_frame,
+	playtime.end_minute, playtime.end_second, playtime.end_frame);
+#endif
+	return(devctl(cdrom->id, DCMD_CAM_CDROMPLAYMSF, &playtime, sizeof(playtime), 0));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+	return(devctl(cdrom->id, DCMD_CAM_CDROMPAUSE, NULL, 0, 0));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+	return(devctl(cdrom->id, DCMD_CAM_CDROMRESUME, NULL, 0, 0));
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(devctl(cdrom->id, DCMD_CAM_CDROMSTOP, NULL, 0, 0));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(devctl(cdrom->id, DCMD_CAM_EJECT_MEDIA, NULL, 0, 0));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	close(cdrom->id);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cdrom/win32/SDL_syscdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,377 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for system-level CD-ROM audio control */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <windows.h>
+#include <mmsystem.h>
+
+#include "SDL_error.h"
+#include "SDL_cdrom.h"
+#include "SDL_syscdrom.h"
+
+/* This really broken?? */
+#define BROKEN_MCI_PAUSE	/* Pausing actually stops play -- Doh! */
+
+/* The maximum number of CD-ROM drives we'll detect (Don't change!) */
+#define MAX_DRIVES	26	
+
+/* A list of available CD-ROM drives */
+static char *SDL_cdlist[MAX_DRIVES];
+static MCIDEVICEID SDL_mciID[MAX_DRIVES];
+#ifdef BROKEN_MCI_PAUSE
+static int SDL_paused[MAX_DRIVES];
+#endif
+
+/* The system-dependent CD control functions */
+static const char *SDL_SYS_CDName(int drive);
+static int SDL_SYS_CDOpen(int drive);
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom);
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position);
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length);
+static int SDL_SYS_CDPause(SDL_CD *cdrom);
+static int SDL_SYS_CDResume(SDL_CD *cdrom);
+static int SDL_SYS_CDStop(SDL_CD *cdrom);
+static int SDL_SYS_CDEject(SDL_CD *cdrom);
+static void SDL_SYS_CDClose(SDL_CD *cdrom);
+
+
+/* Add a CD-ROM drive to our list of valid drives */
+static void AddDrive(char *drive)
+{
+	int i;
+
+	if ( SDL_numcds < MAX_DRIVES ) {
+		/* Add this drive to our list */
+		i = SDL_numcds;
+		SDL_cdlist[i] = (char *)malloc(strlen(drive)+1);
+		if ( SDL_cdlist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return;
+		}
+		strcpy(SDL_cdlist[i], drive);
+		++SDL_numcds;
+#ifdef CDROM_DEBUG
+  fprintf(stderr, "Added CD-ROM drive: %s\n", drive);
+#endif
+	}
+}
+
+int  SDL_SYS_CDInit(void)
+{
+	/* checklist: Drive 'A' - 'Z' */
+	int i;
+	char drive[4];
+
+	/* Fill in our driver capabilities */
+	SDL_CDcaps.Name = SDL_SYS_CDName;
+	SDL_CDcaps.Open = SDL_SYS_CDOpen;
+	SDL_CDcaps.GetTOC = SDL_SYS_CDGetTOC;
+	SDL_CDcaps.Status = SDL_SYS_CDStatus;
+	SDL_CDcaps.Play = SDL_SYS_CDPlay;
+	SDL_CDcaps.Pause = SDL_SYS_CDPause;
+	SDL_CDcaps.Resume = SDL_SYS_CDResume;
+	SDL_CDcaps.Stop = SDL_SYS_CDStop;
+	SDL_CDcaps.Eject = SDL_SYS_CDEject;
+	SDL_CDcaps.Close = SDL_SYS_CDClose;
+
+	/* Scan the system for CD-ROM drives */
+	for ( i='A'; i<='Z'; ++i ) {
+		sprintf(drive, "%c:\\", i);
+		if ( GetDriveType(drive) == DRIVE_CDROM ) {
+			AddDrive(drive);
+		}
+	}
+	memset(SDL_mciID, 0, sizeof(SDL_mciID));
+	return(0);
+}
+
+/* General ioctl() CD-ROM command function */
+static int SDL_SYS_CDioctl(int id, UINT msg, DWORD flags, void *arg)
+{
+	MCIERROR mci_error;
+
+	mci_error = mciSendCommand(SDL_mciID[id], msg, flags, (DWORD)arg);
+	if ( mci_error ) {
+		char error[256];
+
+		mciGetErrorString(mci_error, error, 256);
+		SDL_SetError("mciSendCommand() error: %s", error);
+	}
+	return(!mci_error ? 0 : -1);
+}
+
+static const char *SDL_SYS_CDName(int drive)
+{
+	return(SDL_cdlist[drive]);
+}
+
+static int SDL_SYS_CDOpen(int drive)
+{
+	MCI_OPEN_PARMS mci_open;
+	MCI_SET_PARMS mci_set;
+	char device[3];
+	DWORD flags;
+
+	/* Open the requested device */
+	mci_open.lpstrDeviceType = (LPCSTR) MCI_DEVTYPE_CD_AUDIO;
+	device[0] = *SDL_cdlist[drive];
+	device[1] = ':';
+	device[2] = '\0';
+	mci_open.lpstrElementName = device;
+	flags =
+	  (MCI_OPEN_TYPE|MCI_OPEN_SHAREABLE|MCI_OPEN_TYPE_ID|MCI_OPEN_ELEMENT);
+	if ( SDL_SYS_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0 ) {
+		flags &= ~MCI_OPEN_SHAREABLE;
+		if ( SDL_SYS_CDioctl(0, MCI_OPEN, flags, &mci_open) < 0 ) {
+			return(-1);
+		}
+	}
+	SDL_mciID[drive] = mci_open.wDeviceID;
+
+	/* Set the minute-second-frame time format */
+	mci_set.dwTimeFormat = MCI_FORMAT_MSF;
+	SDL_SYS_CDioctl(drive, MCI_SET, MCI_SET_TIME_FORMAT, &mci_set);
+
+#ifdef BROKEN_MCI_PAUSE
+	SDL_paused[drive] = 0;
+#endif
+	return(drive);
+}
+
+static int SDL_SYS_CDGetTOC(SDL_CD *cdrom)
+{
+	MCI_STATUS_PARMS mci_status;
+	int i, okay;
+	DWORD flags;
+
+	okay = 0;
+	mci_status.dwItem = MCI_STATUS_NUMBER_OF_TRACKS;
+	flags = MCI_STATUS_ITEM | MCI_WAIT;
+	if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) == 0 ) {
+		cdrom->numtracks = mci_status.dwReturn;
+		if ( cdrom->numtracks > SDL_MAX_TRACKS ) {
+			cdrom->numtracks = SDL_MAX_TRACKS;
+		}
+		/* Read all the track TOC entries */
+		flags = MCI_STATUS_ITEM | MCI_TRACK | MCI_WAIT;
+		for ( i=0; i<cdrom->numtracks; ++i ) {
+			cdrom->track[i].id = i+1;
+			mci_status.dwTrack = cdrom->track[i].id;
+#ifdef MCI_CDA_STATUS_TYPE_TRACK
+			mci_status.dwItem = MCI_CDA_STATUS_TYPE_TRACK;
+			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
+							&mci_status) < 0 ) {
+				break;
+			}
+			if ( mci_status.dwReturn == MCI_CDA_TRACK_AUDIO ) {
+				cdrom->track[i].type = SDL_AUDIO_TRACK;
+			} else {
+				cdrom->track[i].type = SDL_DATA_TRACK;
+			}
+#else
+			cdrom->track[i].type = SDL_AUDIO_TRACK;
+#endif
+			mci_status.dwItem = MCI_STATUS_POSITION;
+			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
+							&mci_status) < 0 ) {
+				break;
+			}
+			cdrom->track[i].offset = MSF_TO_FRAMES(
+					MCI_MSF_MINUTE(mci_status.dwReturn),
+					MCI_MSF_SECOND(mci_status.dwReturn),
+					MCI_MSF_FRAME(mci_status.dwReturn));
+			cdrom->track[i].length = 0;
+			if ( i > 0 ) {
+				cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+			}
+		}
+		if ( i == cdrom->numtracks ) {
+			flags &= ~MCI_TRACK;
+			mci_status.dwItem = MCI_STATUS_LENGTH;
+			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
+							&mci_status) == 0 ) {
+				cdrom->track[i].offset = MSF_TO_FRAMES(
+					MCI_MSF_MINUTE(mci_status.dwReturn),
+					MCI_MSF_SECOND(mci_status.dwReturn),
+					MCI_MSF_FRAME(mci_status.dwReturn));
+				cdrom->track[i].length = 0;
+				cdrom->track[i-1].length =
+						cdrom->track[i].offset-
+						cdrom->track[i-1].offset;
+				okay = 1;
+			}
+		}
+	}
+	return(okay ? 0 : -1);
+}
+
+/* Get CD-ROM status */
+static CDstatus SDL_SYS_CDStatus(SDL_CD *cdrom, int *position)
+{
+	CDstatus status;
+	MCI_STATUS_PARMS mci_status;
+	DWORD flags;
+
+	flags = MCI_STATUS_ITEM | MCI_WAIT;
+	mci_status.dwItem = MCI_STATUS_MODE;
+	if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) < 0 ) {
+		status = CD_ERROR;
+	} else {
+		switch (mci_status.dwReturn) {
+			case MCI_MODE_NOT_READY:
+			case MCI_MODE_OPEN:
+				status = CD_TRAYEMPTY;
+				break;
+			case MCI_MODE_STOP:
+#ifdef BROKEN_MCI_PAUSE
+				if ( SDL_paused[cdrom->id] ) {
+					status = CD_PAUSED;
+				} else {
+					status = CD_STOPPED;
+				}
+#else
+				status = CD_STOPPED;
+#endif /* BROKEN_MCI_PAUSE */
+				break;
+			case MCI_MODE_PLAY:
+				status = CD_PLAYING;
+				break;
+			case MCI_MODE_PAUSE:
+				status = CD_PAUSED;
+				break;
+			default:
+				status = CD_ERROR;
+				break;
+		}
+	}
+	if ( position ) {
+		if ( status == CD_PLAYING || (status == CD_PAUSED) ) {
+			mci_status.dwItem = MCI_STATUS_POSITION;
+			if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags,
+							&mci_status) == 0 ) {
+				*position = MSF_TO_FRAMES(
+					MCI_MSF_MINUTE(mci_status.dwReturn),
+					MCI_MSF_SECOND(mci_status.dwReturn),
+					MCI_MSF_FRAME(mci_status.dwReturn));
+			} else {
+				*position = 0;
+			}
+		} else {
+			*position = 0;
+		}
+	}
+	return(status);
+}
+
+/* Start play */
+static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length)
+{
+	MCI_PLAY_PARMS mci_play;
+	int m, s, f;
+	DWORD flags;
+
+	flags = MCI_FROM | MCI_TO | MCI_NOTIFY;
+	mci_play.dwCallback = 0;
+	FRAMES_TO_MSF(start, &m, &s, &f);
+	mci_play.dwFrom = MCI_MAKE_MSF(m, s, f);
+	FRAMES_TO_MSF(start+length, &m, &s, &f);
+	mci_play.dwTo = MCI_MAKE_MSF(m, s, f);
+	return(SDL_SYS_CDioctl(cdrom->id, MCI_PLAY, flags, &mci_play));
+}
+
+/* Pause play */
+static int SDL_SYS_CDPause(SDL_CD *cdrom)
+{
+#ifdef BROKEN_MCI_PAUSE
+	SDL_paused[cdrom->id] = 1;
+#endif
+	return(SDL_SYS_CDioctl(cdrom->id, MCI_PAUSE, MCI_WAIT, NULL));
+}
+
+/* Resume play */
+static int SDL_SYS_CDResume(SDL_CD *cdrom)
+{
+#ifdef BROKEN_MCI_PAUSE
+	MCI_STATUS_PARMS mci_status;
+	int okay;
+	int flags;
+
+	okay = 0;
+	/* Play from the current play position to end of CD */
+	flags = MCI_STATUS_ITEM | MCI_WAIT;
+	mci_status.dwItem = MCI_STATUS_POSITION;
+	if ( SDL_SYS_CDioctl(cdrom->id, MCI_STATUS, flags, &mci_status) == 0 ) {
+		MCI_PLAY_PARMS mci_play;
+
+		flags = MCI_FROM | MCI_NOTIFY;
+		mci_play.dwCallback = 0;
+		mci_play.dwFrom = mci_status.dwReturn;
+		if (SDL_SYS_CDioctl(cdrom->id,MCI_PLAY,flags,&mci_play) == 0) {
+			okay = 1;
+			SDL_paused[cdrom->id] = 0;
+		}
+	}
+	return(okay ? 0 : -1);
+#else
+	return(SDL_SYS_CDioctl(cdrom->id, MCI_RESUME, MCI_WAIT, NULL));
+#endif /* BROKEN_MCI_PAUSE */
+}
+
+/* Stop play */
+static int SDL_SYS_CDStop(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, MCI_STOP, MCI_WAIT, NULL));
+}
+
+/* Eject the CD-ROM */
+static int SDL_SYS_CDEject(SDL_CD *cdrom)
+{
+	return(SDL_SYS_CDioctl(cdrom->id, MCI_SET, MCI_SET_DOOR_OPEN, NULL));
+}
+
+/* Close the CD-ROM handle */
+static void SDL_SYS_CDClose(SDL_CD *cdrom)
+{
+	SDL_SYS_CDioctl(cdrom->id, MCI_CLOSE, MCI_WAIT, NULL);
+}
+
+void SDL_SYS_CDQuit(void)
+{
+	int i;
+
+	if ( SDL_numcds > 0 ) {
+		for ( i=0; i<SDL_numcds; ++i ) {
+			free(SDL_cdlist[i]);
+		}
+		SDL_numcds = 0;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/endian/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/endian/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,11 @@
+
+## Makefile.am for the SDL endian library
+
+noinst_LTLIBRARIES = libendian.la
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_endian.c
+
+libendian_la_SOURCES = $(COMMON_SRCS)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/endian/SDL_endian.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,104 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions for dynamically reading and writing endian-specific values */
+
+#include "SDL_endian.h"
+
+Uint16 SDL_ReadLE16 (SDL_RWops *src)
+{
+	Uint16 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE16(value));
+}
+Uint16 SDL_ReadBE16 (SDL_RWops *src)
+{
+	Uint16 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE16(value));
+}
+Uint32 SDL_ReadLE32 (SDL_RWops *src)
+{
+	Uint32 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE32(value));
+}
+Uint32 SDL_ReadBE32 (SDL_RWops *src)
+{
+	Uint32 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE32(value));
+}
+Uint64 SDL_ReadLE64 (SDL_RWops *src)
+{
+	Uint64 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapLE64(value));
+}
+Uint64 SDL_ReadBE64 (SDL_RWops *src)
+{
+	Uint64 value;
+
+	SDL_RWread(src, &value, (sizeof value), 1);
+	return(SDL_SwapBE64(value));
+}
+
+int SDL_WriteLE16 (SDL_RWops *dst, Uint16 value)
+{
+	value = SDL_SwapLE16(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE16 (SDL_RWops *dst, Uint16 value)
+{
+	value = SDL_SwapBE16(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteLE32 (SDL_RWops *dst, Uint32 value)
+{
+	value = SDL_SwapLE32(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE32 (SDL_RWops *dst, Uint32 value)
+{
+	value = SDL_SwapBE32(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteLE64 (SDL_RWops *dst, Uint64 value)
+{
+	value = SDL_SwapLE64(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
+int SDL_WriteBE64 (SDL_RWops *dst, Uint64 value)
+{
+	value = SDL_SwapBE64(value);
+	return(SDL_RWwrite(dst, &value, (sizeof value), 1));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+
+## Makefile.am for the SDL event handling library
+
+noinst_LTLIBRARIES = libevents.la
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_events.c		\
+	SDL_events_c.h		\
+	SDL_expose.c		\
+	SDL_sysevents.h		\
+	SDL_quit.c		\
+	SDL_active.c		\
+	SDL_keyboard.c		\
+	SDL_mouse.c		\
+	SDL_resize.c
+
+libevents_la_SOURCES = $(COMMON_SRCS)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_active.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,95 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Application focus/iconification handling code for SDL */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+
+
+/* These are static for our active event handling code */
+static Uint8 SDL_appstate = 0;
+
+/* Public functions */
+int SDL_AppActiveInit(void)
+{
+	/* Start completely active */
+	SDL_appstate = (SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS);
+
+	/* That's it! */
+	return(0);
+}
+
+Uint8 SDL_GetAppState(void)
+{
+	return(SDL_appstate);
+}
+
+/* This is global for SDL_eventloop.c */
+int SDL_PrivateAppActive(Uint8 gain, Uint8 state)
+{
+	int posted;
+	Uint8 new_state;
+
+	/* Modify the current state with the given mask */
+	if ( gain ) {
+		new_state = (SDL_appstate | state);
+	} else {
+		new_state = (SDL_appstate & ~state);
+	}
+
+	/* Drop events that don't change state */
+	if ( new_state == SDL_appstate ) {
+		return(0);
+	}
+
+	/* Update internal active state */
+	SDL_appstate = new_state;
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_ACTIVEEVENT] == SDL_ENABLE ) {
+		SDL_Event event;
+		memset(&event, 0, sizeof(event));
+		event.type = SDL_ACTIVEEVENT;
+		event.active.gain = gain;
+		event.active.state = state;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+
+	/* If we lost keyboard focus, post key-up events */
+	if ( (state & SDL_APPINPUTFOCUS) && !gain ) {
+		SDL_ResetKeyboard();
+	}
+	return(posted);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_events.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,475 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General event handling code for SDL */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+#include "SDL_mutex.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_timer_c.h"
+#ifndef DISABLE_JOYSTICK
+#include "SDL_joystick_c.h"
+#endif
+#ifndef ENABLE_X11
+#define DISABLE_X11
+#endif
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+
+/* Public data -- the event filter */
+SDL_EventFilter SDL_EventOK = NULL;
+Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
+static Uint32 SDL_eventstate = 0;
+
+/* Private data -- event queue */
+#define MAXEVENTS	128
+static struct {
+	SDL_mutex *lock;
+	int active;
+	int head;
+	int tail;
+	SDL_Event event[MAXEVENTS];
+	int wmmsg_next;
+	struct SDL_SysWMmsg wmmsg[MAXEVENTS];
+} SDL_EventQ;
+
+/* Private data -- event locking structure */
+static struct {
+	SDL_mutex *lock;
+	int safe;
+} SDL_EventLock;
+
+/* Thread functions */
+static SDL_Thread *SDL_EventThread = NULL;	/* Thread handle */
+static Uint32 event_thread;			/* The event thread id */
+
+void SDL_Lock_EventThread(void)
+{
+	if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
+		/* Grab lock and spin until we're sure event thread stopped */
+		SDL_mutexP(SDL_EventLock.lock);
+		while ( ! SDL_EventLock.safe ) {
+			SDL_Delay(1);
+		}
+	}
+}
+void SDL_Unlock_EventThread(void)
+{
+	if ( SDL_EventThread && (SDL_ThreadID() != event_thread) ) {
+		SDL_mutexV(SDL_EventLock.lock);
+	}
+}
+
+static int SDL_GobbleEvents(void *unused)
+{
+	SDL_SetTimerThreaded(2);
+	event_thread = SDL_ThreadID();
+	while ( SDL_EventQ.active ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+
+		/* Get events from the video subsystem */
+		if ( video ) {
+			video->PumpEvents(this);
+		}
+
+		/* Queue pending key-repeat events */
+		SDL_CheckKeyRepeat();
+
+#ifndef DISABLE_JOYSTICK
+		/* Check for joystick state change */
+		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
+			SDL_JoystickUpdate();
+		}
+#endif
+
+		/* Give up the CPU for the rest of our timeslice */
+		SDL_EventLock.safe = 1;
+		if( SDL_timer_running ) {
+			SDL_ThreadedTimerCheck();
+		}
+		SDL_Delay(1);
+
+		/* Check for event locking.
+		   On the P of the lock mutex, if the lock is held, this thread
+		   will wait until the lock is released before continuing.  The
+		   safe flag will be set, meaning that the other thread can go
+		   about it's business.  The safe flag is reset before the V,
+		   so as soon as the mutex is free, other threads can see that
+		   it's not safe to interfere with the event thread.
+		 */
+		SDL_mutexP(SDL_EventLock.lock);
+		SDL_EventLock.safe = 0;
+		SDL_mutexV(SDL_EventLock.lock);
+	}
+	SDL_SetTimerThreaded(0);
+	event_thread = 0;
+	return(0);
+}
+
+static int SDL_StartEventThread(Uint32 flags)
+{
+	/* Reset everything to zero */
+	SDL_EventThread = NULL;
+	memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
+
+	/* Create the lock and set ourselves active */
+#ifndef DISABLE_THREADS
+	SDL_EventQ.lock = SDL_CreateMutex();
+	if ( SDL_EventQ.lock == NULL ) {
+#ifdef macintosh /* On MacOS 7/8, you can't multithread, so no lock needed */
+		;
+#else
+		return(-1);
+#endif
+	}
+#endif /* !DISABLE_THREADS */
+	SDL_EventQ.active = 1;
+
+	if ( (flags&SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
+		SDL_EventLock.lock = SDL_CreateMutex();
+		if ( SDL_EventLock.lock == NULL ) {
+			return(-1);
+		}
+		SDL_EventLock.safe = 0;
+
+		SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
+		if ( SDL_EventThread == NULL ) {
+			return(-1);
+		}
+	} else {
+		event_thread = 0;
+	}
+	return(0);
+}
+
+static void SDL_StopEventThread(void)
+{
+	SDL_EventQ.active = 0;
+	if ( SDL_EventThread ) {
+		SDL_WaitThread(SDL_EventThread, NULL);
+		SDL_EventThread = NULL;
+		SDL_DestroyMutex(SDL_EventLock.lock);
+	}
+	SDL_DestroyMutex(SDL_EventQ.lock);
+}
+
+Uint32 SDL_EventThreadID(void)
+{
+	return(event_thread);
+}
+
+/* Public functions */
+
+void SDL_StopEventLoop(void)
+{
+	/* Halt the event thread, if running */
+	SDL_StopEventThread();
+
+	/* Clean out EventQ */
+	SDL_EventQ.head = 0;
+	SDL_EventQ.tail = 0;
+	SDL_EventQ.wmmsg_next = 0;
+}
+
+/* This function (and associated calls) may be called more than once */
+int SDL_StartEventLoop(Uint32 flags)
+{
+	int retcode;
+
+	/* Clean out the event queue */
+	SDL_EventThread = NULL;
+	SDL_EventQ.lock = NULL;
+	SDL_StopEventLoop();
+
+	/* No filter to start with, process most event types */
+	SDL_EventOK = NULL;
+	memset(SDL_ProcessEvents,SDL_ENABLE,sizeof(SDL_ProcessEvents));
+	SDL_eventstate = ~0;
+	/* It's not save to call SDL_EventState() yet */
+	SDL_eventstate &= ~(0x00000001 << SDL_SYSWMEVENT);
+	SDL_ProcessEvents[SDL_SYSWMEVENT] = SDL_IGNORE;
+
+	/* Initialize event handlers */
+	retcode = 0;
+	retcode += SDL_AppActiveInit();
+	retcode += SDL_KeyboardInit();
+	retcode += SDL_MouseInit();
+	retcode += SDL_QuitInit();
+	if ( retcode < 0 ) {
+		/* We don't expect them to fail, but... */
+		return(-1);
+	}
+
+	/* Create the lock and event thread */
+	if ( SDL_StartEventThread(flags) < 0 ) {
+		SDL_StopEventLoop();
+		return(-1);
+	}
+	return(0);
+}
+
+
+/* Add an event to the event queue -- called with the queue locked */
+static int SDL_AddEvent(SDL_Event *event)
+{
+	int tail, added;
+
+	tail = (SDL_EventQ.tail+1)%MAXEVENTS;
+	if ( tail == SDL_EventQ.head ) {
+		/* Overflow, drop event */
+		added = 0;
+	} else {
+		SDL_EventQ.event[SDL_EventQ.tail] = *event;
+		if (event->type == SDL_SYSWMEVENT) {
+			/* Note that it's possible to lose an event */
+			int next = SDL_EventQ.wmmsg_next;
+			SDL_EventQ.wmmsg[next] = *event->syswm.msg;
+		        SDL_EventQ.event[SDL_EventQ.tail].syswm.msg =
+						&SDL_EventQ.wmmsg[next];
+			SDL_EventQ.wmmsg_next = (next+1)%MAXEVENTS;
+		}
+		SDL_EventQ.tail = tail;
+		added = 1;
+	}
+	return(added);
+}
+
+/* Cut an event, and return the next valid spot, or the tail */
+/*                           -- called with the queue locked */
+static int SDL_CutEvent(int spot)
+{
+	if ( spot == SDL_EventQ.head ) {
+		SDL_EventQ.head = (SDL_EventQ.head+1)%MAXEVENTS;
+		return(SDL_EventQ.head);
+	} else
+	if ( (spot+1)%MAXEVENTS == SDL_EventQ.tail ) {
+		SDL_EventQ.tail = spot;
+		return(SDL_EventQ.tail);
+	} else
+	/* We cut the middle -- shift everything over */
+	{
+		int here, next;
+
+		/* This can probably be optimized with memcpy() -- careful! */
+		if ( --SDL_EventQ.tail < 0 ) {
+			SDL_EventQ.tail = MAXEVENTS-1;
+		}
+		for ( here=spot; here != SDL_EventQ.tail; here = next ) {
+			next = (here+1)%MAXEVENTS;
+			SDL_EventQ.event[here] = SDL_EventQ.event[next];
+		}
+		return(spot);
+	}
+	/* NOTREACHED */
+}
+
+/* Lock the event queue, take a peep at it, and unlock it */
+int SDL_PeepEvents(SDL_Event *events, int numevents, SDL_eventaction action,
+								Uint32 mask)
+{
+	int i, used;
+
+	/* Don't look after we've quit */
+	if ( ! SDL_EventQ.active ) {
+		return(0);
+	}
+	/* Lock the event queue */
+	used = 0;
+	if ( SDL_mutexP(SDL_EventQ.lock) == 0 ) {
+		if ( action == SDL_ADDEVENT ) {
+			for ( i=0; i<numevents; ++i ) {
+				used += SDL_AddEvent(&events[i]);
+			}
+		} else {
+			SDL_Event tmpevent;
+			int spot;
+
+			/* If 'events' is NULL, just see if they exist */
+			if ( events == NULL ) {
+				action = SDL_PEEKEVENT;
+				numevents = 1;
+				events = &tmpevent;
+			}
+			spot = SDL_EventQ.head;
+			while ((used < numevents)&&(spot != SDL_EventQ.tail)) {
+				if ( mask & SDL_EVENTMASK(SDL_EventQ.event[spot].type) ) {
+					events[used++] = SDL_EventQ.event[spot];
+					if ( action == SDL_GETEVENT ) {
+						spot = SDL_CutEvent(spot);
+					} else {
+						spot = (spot+1)%MAXEVENTS;
+					}
+				} else {
+					spot = (spot+1)%MAXEVENTS;
+				}
+			}
+		}
+		SDL_mutexV(SDL_EventQ.lock);
+	} else {
+		SDL_SetError("Couldn't lock event queue");
+		used = -1;
+	}
+	return(used);
+}
+
+/* Run the system dependent event loops */
+void SDL_PumpEvents(void)
+{
+	if ( !SDL_EventThread ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+
+		/* Get events from the video subsystem */
+		if ( video ) {
+			video->PumpEvents(this);
+		}
+
+		/* Queue pending key-repeat events */
+		SDL_CheckKeyRepeat();
+
+#ifndef DISABLE_JOYSTICK
+		/* Check for joystick state change */
+		if ( SDL_numjoysticks && (SDL_eventstate & SDL_JOYEVENTMASK) ) {
+			SDL_JoystickUpdate();
+		}
+#endif
+	}
+}
+
+/* Public functions */
+
+int SDL_PollEvent (SDL_Event *event)
+{
+	SDL_PumpEvents();
+
+	return(SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS));
+}
+
+int SDL_WaitEvent (SDL_Event *event)
+{
+	while ( 1 ) {
+		SDL_PumpEvents();
+		switch(SDL_PeepEvents(event, 1, SDL_GETEVENT, SDL_ALLEVENTS)) {
+		    case -1: return -1; 
+		    case 1: return 1;
+		    case 0: SDL_Delay(10);
+		}
+	}
+}
+
+int SDL_PushEvent(SDL_Event *event)
+{
+	return(SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0));
+}
+
+void SDL_SetEventFilter (SDL_EventFilter filter)
+{
+	SDL_Event bitbucket;
+
+	/* Set filter and discard pending events */
+	SDL_EventOK = filter;
+	while ( SDL_PollEvent(&bitbucket) > 0 )
+		;
+}
+
+SDL_EventFilter SDL_GetEventFilter(void)
+{
+	return(SDL_EventOK);
+}
+
+Uint8 SDL_EventState (Uint8 type, int state)
+{
+	SDL_Event bitbucket;
+	Uint8 current_state;
+
+	/* If SDL_ALLEVENTS was specified... */
+	if ( type == 0xFF ) {
+		current_state = SDL_IGNORE;
+		for ( type=0; type<SDL_NUMEVENTS; ++type ) {
+			if ( SDL_ProcessEvents[type] != SDL_IGNORE ) {
+				current_state = SDL_ENABLE;
+			}
+			SDL_ProcessEvents[type] = state;
+			if ( state == SDL_ENABLE ) {
+				SDL_eventstate |= (0x00000001 << (type));
+			} else {
+				SDL_eventstate &= ~(0x00000001 << (type));
+			}
+		}
+		while ( SDL_PollEvent(&bitbucket) > 0 )
+			;
+		return(current_state);
+	}
+
+	/* Just set the state for one event type */
+	current_state = SDL_ProcessEvents[type];
+	switch (state) {
+		case SDL_IGNORE:
+		case SDL_ENABLE:
+			/* Set state and discard pending events */
+			SDL_ProcessEvents[type] = state;
+			if ( state == SDL_ENABLE ) {
+				SDL_eventstate |= (0x00000001 << (type));
+			} else {
+				SDL_eventstate &= ~(0x00000001 << (type));
+			}
+			while ( SDL_PollEvent(&bitbucket) > 0 )
+				;
+			break;
+		default:
+			/* Querying state? */
+			break;
+	}
+	return(current_state);
+}
+
+/* This is a generic event handler.
+ */
+int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message)
+{
+	int posted;
+
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+		SDL_Event event;
+		memset(&event, 0, sizeof(event));
+		event.type = SDL_SYSWMEVENT;
+		event.syswm.msg = message;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	/* Update internal event state */
+	return(posted);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_events_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,78 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful functions and variables from SDL_events.c */
+#include "SDL_events.h"
+
+/* Start and stop the event processing loop */
+extern int SDL_StartEventLoop(Uint32 flags);
+extern void SDL_StopEventLoop(void);
+extern void SDL_QuitInterrupt(void);
+
+extern void SDL_Lock_EventThread();
+extern void SDL_Unlock_EventThread();
+extern Uint32 SDL_EventThreadID(void);
+
+/* Event handler init routines */
+extern int  SDL_AppActiveInit(void);
+extern int  SDL_KeyboardInit(void);
+extern int  SDL_MouseInit(void);
+extern int  SDL_QuitInit(void);
+
+/* The event filter function */
+extern SDL_EventFilter SDL_EventOK;
+
+/* The array of event processing states */
+extern Uint8 SDL_ProcessEvents[SDL_NUMEVENTS];
+
+/* Internal event queueing functions
+   (from SDL_active.c, SDL_mouse.c, SDL_keyboard.c, SDL_quit.c, SDL_events.c)
+ */
+extern int SDL_PrivateAppActive(Uint8 gain, Uint8 state);
+extern int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative,
+						Sint16 x, Sint16 y);
+extern int SDL_PrivateMouseButton(Uint8 state, Uint8 button,Sint16 x,Sint16 y);
+extern int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *key);
+extern int SDL_PrivateResize(int w, int h);
+extern int SDL_PrivateExpose(void);
+extern int SDL_PrivateQuit(void);
+extern int SDL_PrivateSysWMEvent(SDL_SysWMmsg *message);
+
+/* Used by the activity event handler to remove mouse focus */
+extern void SDL_MouseFocus(int focus);
+
+/* Used by the activity event handler to remove keyboard focus */
+extern void SDL_ResetKeyboard(void);
+
+/* Used by the event loop to queue pending keyboard repeat events */
+extern void SDL_CheckKeyRepeat(void);
+
+/* Used by the OS keyboard code to detect whether or not to do UNICODE */
+#ifndef DEFAULT_UNICODE_TRANSLATION
+#define DEFAULT_UNICODE_TRANSLATION 0	/* Default off because of overhead */
+#endif
+extern int SDL_TranslateUNICODE;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_expose.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,55 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Refresh event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+
+
+/* This is global for SDL_eventloop.c */
+int SDL_PrivateExpose(void)
+{
+	int posted;
+	SDL_Event events[32];
+
+	/* Pull out all old refresh events */
+	SDL_PeepEvents(events, sizeof(events)/sizeof(events[0]),
+	                    SDL_GETEVENT, SDL_VIDEOEXPOSEMASK);
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_VIDEOEXPOSE] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.type = SDL_VIDEOEXPOSE;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_keyboard.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,572 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General keyboard handling code for SDL */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_timer.h"
+#include "SDL_events_c.h"
+#include "SDL_sysevents.h"
+
+
+/* Global keystate information */
+static Uint8  SDL_KeyState[SDLK_LAST];
+static SDLMod SDL_ModState;
+int SDL_TranslateUNICODE = 0;
+
+static char *keynames[SDLK_LAST];	/* Array of keycode names */
+
+/*
+ * jk 991215 - added
+ */
+#define MINIMUM_REPEAT_INTERVAL	30	/* Minimum repeat interval (30 ms) */
+struct {
+	int firsttime;    /* if we check against the delay or repeat value */
+	int delay;        /* the delay before we start repeating */
+	int interval;     /* the delay between key repeat events */
+	Uint32 timestamp; /* the time the first keydown event occurred */
+
+	SDL_Event evt;    /* the event we are supposed to repeat */
+} SDL_KeyRepeat;
+
+/* Public functions */
+int SDL_KeyboardInit(void)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	Uint16 i;
+
+	/* Set default mode of UNICODE translation */
+	SDL_EnableUNICODE(DEFAULT_UNICODE_TRANSLATION);
+
+	/* Initialize the tables */
+	SDL_ModState = KMOD_NONE;
+	for ( i=0; i<SDL_TABLESIZE(keynames); ++i )
+		keynames[i] = NULL;
+	for ( i=0; i<SDL_TABLESIZE(SDL_KeyState); ++i )
+		SDL_KeyState[i] = SDL_RELEASED;
+	video->InitOSKeymap(this);
+
+	SDL_EnableKeyRepeat(0, 0);
+
+	/* Fill in the blanks in keynames */
+	keynames[SDLK_BACKSPACE] = "backspace";
+	keynames[SDLK_TAB] = "tab";
+	keynames[SDLK_CLEAR] = "clear";
+	keynames[SDLK_RETURN] = "return";
+	keynames[SDLK_PAUSE] = "pause";
+	keynames[SDLK_ESCAPE] = "escape";
+	keynames[SDLK_SPACE] = "space";
+	keynames[SDLK_EXCLAIM]  = "!";
+	keynames[SDLK_QUOTEDBL]  = "\"";
+	keynames[SDLK_HASH]  = "#";
+	keynames[SDLK_DOLLAR]  = "$";
+	keynames[SDLK_AMPERSAND]  = "&";
+	keynames[SDLK_QUOTE] = "'";
+	keynames[SDLK_LEFTPAREN] = "(";
+	keynames[SDLK_RIGHTPAREN] = ")";
+	keynames[SDLK_ASTERISK] = "*";
+	keynames[SDLK_PLUS] = "+";
+	keynames[SDLK_COMMA] = ",";
+	keynames[SDLK_MINUS] = "-";
+	keynames[SDLK_PERIOD] = ".";
+	keynames[SDLK_SLASH] = "/";
+	keynames[SDLK_0] = "0";
+	keynames[SDLK_1] = "1";
+	keynames[SDLK_2] = "2";
+	keynames[SDLK_3] = "3";
+	keynames[SDLK_4] = "4";
+	keynames[SDLK_5] = "5";
+	keynames[SDLK_6] = "6";
+	keynames[SDLK_7] = "7";
+	keynames[SDLK_8] = "8";
+	keynames[SDLK_9] = "9";
+	keynames[SDLK_COLON] = ":";
+	keynames[SDLK_SEMICOLON] = ";";
+	keynames[SDLK_LESS] = "<";
+	keynames[SDLK_EQUALS] = "=";
+	keynames[SDLK_GREATER] = ">";
+	keynames[SDLK_QUESTION] = "?";
+	keynames[SDLK_AT] = "@";
+	keynames[SDLK_LEFTBRACKET] = "[";
+	keynames[SDLK_BACKSLASH] = "\\";
+	keynames[SDLK_RIGHTBRACKET] = "]";
+	keynames[SDLK_CARET] = "^";
+	keynames[SDLK_UNDERSCORE] = "_";
+	keynames[SDLK_BACKQUOTE] = "`";
+	keynames[SDLK_a] = "a";
+	keynames[SDLK_b] = "b";
+	keynames[SDLK_c] = "c";
+	keynames[SDLK_d] = "d";
+	keynames[SDLK_e] = "e";
+	keynames[SDLK_f] = "f";
+	keynames[SDLK_g] = "g";
+	keynames[SDLK_h] = "h";
+	keynames[SDLK_i] = "i";
+	keynames[SDLK_j] = "j";
+	keynames[SDLK_k] = "k";
+	keynames[SDLK_l] = "l";
+	keynames[SDLK_m] = "m";
+	keynames[SDLK_n] = "n";
+	keynames[SDLK_o] = "o";
+	keynames[SDLK_p] = "p";
+	keynames[SDLK_q] = "q";
+	keynames[SDLK_r] = "r";
+	keynames[SDLK_s] = "s";
+	keynames[SDLK_t] = "t";
+	keynames[SDLK_u] = "u";
+	keynames[SDLK_v] = "v";
+	keynames[SDLK_w] = "w";
+	keynames[SDLK_x] = "x";
+	keynames[SDLK_y] = "y";
+	keynames[SDLK_z] = "z";
+	keynames[SDLK_DELETE] = "delete";
+
+	keynames[SDLK_WORLD_0] = "world 0";
+	keynames[SDLK_WORLD_1] = "world 1";
+	keynames[SDLK_WORLD_2] = "world 2";
+	keynames[SDLK_WORLD_3] = "world 3";
+	keynames[SDLK_WORLD_4] = "world 4";
+	keynames[SDLK_WORLD_5] = "world 5";
+	keynames[SDLK_WORLD_6] = "world 6";
+	keynames[SDLK_WORLD_7] = "world 7";
+	keynames[SDLK_WORLD_8] = "world 8";
+	keynames[SDLK_WORLD_9] = "world 9";
+	keynames[SDLK_WORLD_10] = "world 10";
+	keynames[SDLK_WORLD_11] = "world 11";
+	keynames[SDLK_WORLD_12] = "world 12";
+	keynames[SDLK_WORLD_13] = "world 13";
+	keynames[SDLK_WORLD_14] = "world 14";
+	keynames[SDLK_WORLD_15] = "world 15";
+	keynames[SDLK_WORLD_16] = "world 16";
+	keynames[SDLK_WORLD_17] = "world 17";
+	keynames[SDLK_WORLD_18] = "world 18";
+	keynames[SDLK_WORLD_19] = "world 19";
+	keynames[SDLK_WORLD_20] = "world 20";
+	keynames[SDLK_WORLD_21] = "world 21";
+	keynames[SDLK_WORLD_22] = "world 22";
+	keynames[SDLK_WORLD_23] = "world 23";
+	keynames[SDLK_WORLD_24] = "world 24";
+	keynames[SDLK_WORLD_25] = "world 25";
+	keynames[SDLK_WORLD_26] = "world 26";
+	keynames[SDLK_WORLD_27] = "world 27";
+	keynames[SDLK_WORLD_28] = "world 28";
+	keynames[SDLK_WORLD_29] = "world 29";
+	keynames[SDLK_WORLD_30] = "world 30";
+	keynames[SDLK_WORLD_31] = "world 31";
+	keynames[SDLK_WORLD_32] = "world 32";
+	keynames[SDLK_WORLD_33] = "world 33";
+	keynames[SDLK_WORLD_34] = "world 34";
+	keynames[SDLK_WORLD_35] = "world 35";
+	keynames[SDLK_WORLD_36] = "world 36";
+	keynames[SDLK_WORLD_37] = "world 37";
+	keynames[SDLK_WORLD_38] = "world 38";
+	keynames[SDLK_WORLD_39] = "world 39";
+	keynames[SDLK_WORLD_40] = "world 40";
+	keynames[SDLK_WORLD_41] = "world 41";
+	keynames[SDLK_WORLD_42] = "world 42";
+	keynames[SDLK_WORLD_43] = "world 43";
+	keynames[SDLK_WORLD_44] = "world 44";
+	keynames[SDLK_WORLD_45] = "world 45";
+	keynames[SDLK_WORLD_46] = "world 46";
+	keynames[SDLK_WORLD_47] = "world 47";
+	keynames[SDLK_WORLD_48] = "world 48";
+	keynames[SDLK_WORLD_49] = "world 49";
+	keynames[SDLK_WORLD_50] = "world 50";
+	keynames[SDLK_WORLD_51] = "world 51";
+	keynames[SDLK_WORLD_52] = "world 52";
+	keynames[SDLK_WORLD_53] = "world 53";
+	keynames[SDLK_WORLD_54] = "world 54";
+	keynames[SDLK_WORLD_55] = "world 55";
+	keynames[SDLK_WORLD_56] = "world 56";
+	keynames[SDLK_WORLD_57] = "world 57";
+	keynames[SDLK_WORLD_58] = "world 58";
+	keynames[SDLK_WORLD_59] = "world 59";
+	keynames[SDLK_WORLD_60] = "world 60";
+	keynames[SDLK_WORLD_61] = "world 61";
+	keynames[SDLK_WORLD_62] = "world 62";
+	keynames[SDLK_WORLD_63] = "world 63";
+	keynames[SDLK_WORLD_64] = "world 64";
+	keynames[SDLK_WORLD_65] = "world 65";
+	keynames[SDLK_WORLD_66] = "world 66";
+	keynames[SDLK_WORLD_67] = "world 67";
+	keynames[SDLK_WORLD_68] = "world 68";
+	keynames[SDLK_WORLD_69] = "world 69";
+	keynames[SDLK_WORLD_70] = "world 70";
+	keynames[SDLK_WORLD_71] = "world 71";
+	keynames[SDLK_WORLD_72] = "world 72";
+	keynames[SDLK_WORLD_73] = "world 73";
+	keynames[SDLK_WORLD_74] = "world 74";
+	keynames[SDLK_WORLD_75] = "world 75";
+	keynames[SDLK_WORLD_76] = "world 76";
+	keynames[SDLK_WORLD_77] = "world 77";
+	keynames[SDLK_WORLD_78] = "world 78";
+	keynames[SDLK_WORLD_79] = "world 79";
+	keynames[SDLK_WORLD_80] = "world 80";
+	keynames[SDLK_WORLD_81] = "world 81";
+	keynames[SDLK_WORLD_82] = "world 82";
+	keynames[SDLK_WORLD_83] = "world 83";
+	keynames[SDLK_WORLD_84] = "world 84";
+	keynames[SDLK_WORLD_85] = "world 85";
+	keynames[SDLK_WORLD_86] = "world 86";
+	keynames[SDLK_WORLD_87] = "world 87";
+	keynames[SDLK_WORLD_88] = "world 88";
+	keynames[SDLK_WORLD_89] = "world 89";
+	keynames[SDLK_WORLD_90] = "world 90";
+	keynames[SDLK_WORLD_91] = "world 91";
+	keynames[SDLK_WORLD_92] = "world 92";
+	keynames[SDLK_WORLD_93] = "world 93";
+	keynames[SDLK_WORLD_94] = "world 94";
+	keynames[SDLK_WORLD_95] = "world 95";
+
+	keynames[SDLK_KP0] = "[0]";
+	keynames[SDLK_KP1] = "[1]";
+	keynames[SDLK_KP2] = "[2]";
+	keynames[SDLK_KP3] = "[3]";
+	keynames[SDLK_KP4] = "[4]";
+	keynames[SDLK_KP5] = "[5]";
+	keynames[SDLK_KP6] = "[6]";
+	keynames[SDLK_KP7] = "[7]";
+	keynames[SDLK_KP8] = "[8]";
+	keynames[SDLK_KP9] = "[9]";
+	keynames[SDLK_KP_PERIOD] = "[.]";
+	keynames[SDLK_KP_DIVIDE] = "[/]";
+	keynames[SDLK_KP_MULTIPLY] = "[*]";
+	keynames[SDLK_KP_MINUS] = "[-]";
+	keynames[SDLK_KP_PLUS] = "[+]";
+	keynames[SDLK_KP_ENTER] = "enter";
+	keynames[SDLK_KP_EQUALS] = "equals";
+
+	keynames[SDLK_UP] = "up";
+	keynames[SDLK_DOWN] = "down";
+	keynames[SDLK_RIGHT] = "right";
+	keynames[SDLK_LEFT] = "left";
+	keynames[SDLK_DOWN] = "down";
+	keynames[SDLK_INSERT] = "insert";
+	keynames[SDLK_HOME] = "home";
+	keynames[SDLK_END] = "end";
+	keynames[SDLK_PAGEUP] = "page up";
+	keynames[SDLK_PAGEDOWN] = "page down";
+
+	keynames[SDLK_F1] = "f1";
+	keynames[SDLK_F2] = "f2";
+	keynames[SDLK_F3] = "f3";
+	keynames[SDLK_F4] = "f4";
+	keynames[SDLK_F5] = "f5";
+	keynames[SDLK_F6] = "f6";
+	keynames[SDLK_F7] = "f7";
+	keynames[SDLK_F8] = "f8";
+	keynames[SDLK_F9] = "f9";
+	keynames[SDLK_F10] = "f10";
+	keynames[SDLK_F11] = "f11";
+	keynames[SDLK_F12] = "f12";
+	keynames[SDLK_F13] = "f13";
+	keynames[SDLK_F14] = "f14";
+	keynames[SDLK_F15] = "f15";
+
+	keynames[SDLK_NUMLOCK] = "numlock";
+	keynames[SDLK_CAPSLOCK] = "caps lock";
+	keynames[SDLK_SCROLLOCK] = "scroll lock";
+	keynames[SDLK_RSHIFT] = "right shift";
+	keynames[SDLK_LSHIFT] = "left shift";
+	keynames[SDLK_RCTRL] = "right ctrl";
+	keynames[SDLK_LCTRL] = "left ctrl";
+	keynames[SDLK_RALT] = "right alt";
+	keynames[SDLK_LALT] = "left alt";
+	keynames[SDLK_RMETA] = "right meta";
+	keynames[SDLK_LMETA] = "left meta";
+	keynames[SDLK_LSUPER] = "left super";	/* "Windows" keys */
+	keynames[SDLK_RSUPER] = "right super";	
+	keynames[SDLK_MODE] = "alt gr";
+	keynames[SDLK_COMPOSE] = "compose";
+
+	keynames[SDLK_HELP] = "help";
+	keynames[SDLK_PRINT] = "print screen";
+	keynames[SDLK_SYSREQ] = "sys req";
+	keynames[SDLK_BREAK] = "break";
+	keynames[SDLK_MENU] = "menu";
+	keynames[SDLK_POWER] = "power";
+	keynames[SDLK_EURO] = "euro";
+
+	/* Done.  Whew. */
+	return(0);
+}
+
+/* We lost the keyboard, so post key up messages for all pressed keys */
+void SDL_ResetKeyboard(void)
+{
+	SDL_keysym keysym;
+	SDLKey key;
+
+	memset(&keysym, 0, (sizeof keysym));
+	for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
+		if ( SDL_KeyState[key] == SDL_PRESSED ) {
+			keysym.sym = key;
+			SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
+		}
+	}
+}
+
+int SDL_EnableUNICODE(int enable)
+{
+	int old_mode;
+
+	old_mode = SDL_TranslateUNICODE;
+	if ( enable >= 0 ) {
+		SDL_TranslateUNICODE = enable;
+	}
+	return(old_mode);
+}
+
+Uint8 * SDL_GetKeyState (int *numkeys)
+{
+	if ( numkeys != (int *)0 )
+		*numkeys = SDLK_LAST;
+	return(SDL_KeyState);
+}
+SDLMod SDL_GetModState (void)
+{
+	return(SDL_ModState);
+}
+void SDL_SetModState (SDLMod modstate)
+{
+	SDL_ModState = modstate;
+}
+
+char *SDL_GetKeyName(SDLKey key)
+{
+	char *keyname;
+
+	keyname = NULL;
+	if ( key < SDLK_LAST ) {
+		keyname = keynames[key];
+	}
+	if ( keyname == NULL ) {
+		keyname = "unknown key";
+	}
+	return(keyname);
+}
+
+/* These are global for SDL_eventloop.c */
+int SDL_PrivateKeyboard(Uint8 state, SDL_keysym *keysym)
+{
+	SDL_Event event;
+	int posted, repeatable;
+	Uint16 modstate;
+
+	memset(&event, 0, sizeof(event));
+
+#if 0
+printf("The '%s' key has been %s\n", SDL_GetKeyName(keysym->sym), 
+				state == SDL_PRESSED ? "pressed" : "released");
+#endif
+	/* Set up the keysym */
+	modstate = (Uint16)SDL_ModState;
+
+	repeatable = 0;
+
+	if ( state == SDL_PRESSED ) {
+		keysym->mod = (SDLMod)modstate;
+		switch (keysym->sym) {
+			case SDLK_NUMLOCK:
+				modstate ^= KMOD_NUM;
+				if ( ! (modstate&KMOD_NUM) )
+					state = SDL_RELEASED;
+				keysym->mod = (SDLMod)modstate;
+				break;
+			case SDLK_CAPSLOCK:
+				modstate ^= KMOD_CAPS;
+				if ( ! (modstate&KMOD_CAPS) )
+					state = SDL_RELEASED;
+				keysym->mod = (SDLMod)modstate;
+				break;
+			case SDLK_LCTRL:
+				modstate |= KMOD_LCTRL;
+				break;
+			case SDLK_RCTRL:
+				modstate |= KMOD_RCTRL;
+				break;
+			case SDLK_LSHIFT:
+				modstate |= KMOD_LSHIFT;
+				break;
+			case SDLK_RSHIFT:
+				modstate |= KMOD_RSHIFT;
+				break;
+			case SDLK_LALT:
+				modstate |= KMOD_LALT;
+				break;
+			case SDLK_RALT:
+				modstate |= KMOD_RALT;
+				break;
+			case SDLK_LMETA:
+				modstate |= KMOD_LMETA;
+				break;
+			case SDLK_RMETA:
+				modstate |= KMOD_RMETA;
+				break;
+			case SDLK_MODE:
+				modstate |= KMOD_MODE;
+				break;
+			default:
+				repeatable = 1;
+				break;
+		}
+	} else {
+		switch (keysym->sym) {
+			case SDLK_NUMLOCK:
+			case SDLK_CAPSLOCK:
+				/* Only send keydown events */
+				return(0);
+			case SDLK_LCTRL:
+				modstate &= ~KMOD_LCTRL;
+				break;
+			case SDLK_RCTRL:
+				modstate &= ~KMOD_RCTRL;
+				break;
+			case SDLK_LSHIFT:
+				modstate &= ~KMOD_LSHIFT;
+				break;
+			case SDLK_RSHIFT:
+				modstate &= ~KMOD_RSHIFT;
+				break;
+			case SDLK_LALT:
+				modstate &= ~KMOD_LALT;
+				break;
+			case SDLK_RALT:
+				modstate &= ~KMOD_RALT;
+				break;
+			case SDLK_LMETA:
+				modstate &= ~KMOD_LMETA;
+				break;
+			case SDLK_RMETA:
+				modstate &= ~KMOD_RMETA;
+				break;
+			case SDLK_MODE:
+				modstate &= ~KMOD_MODE;
+				break;
+			default:
+				break;
+		}
+		keysym->mod = (SDLMod)modstate;
+	}
+
+	/* Figure out what type of event this is */
+	switch (state) {
+		case SDL_PRESSED:
+			event.type = SDL_KEYDOWN;
+			break;
+		case SDL_RELEASED:
+			event.type = SDL_KEYUP;
+			/*
+			 * jk 991215 - Added
+			 */
+			if ( SDL_KeyRepeat.timestamp ) {
+				SDL_KeyRepeat.timestamp = 0;
+			}
+			break;
+		default:
+			/* Invalid state -- bail */
+			return(0);
+	}
+
+	/* Drop events that don't change state */
+	if ( SDL_KeyState[keysym->sym] == state ) {
+		return(0);
+	}
+
+	/* Update internal keyboard state */
+	SDL_ModState = (SDLMod)modstate;
+	SDL_KeyState[keysym->sym] = state;
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) {
+		event.key.state = state;
+		event.key.keysym = *keysym;
+		if ( (SDL_EventOK == NULL) || SDL_EventOK(&event) ) {
+			posted = 1;
+			/*
+			 * jk 991215 - Added
+			 */
+			if (repeatable && (SDL_KeyRepeat.delay != 0)) {
+				SDL_KeyRepeat.evt = event;
+				SDL_KeyRepeat.firsttime = 1;
+				SDL_KeyRepeat.timestamp=SDL_GetTicks();
+			}
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
+
+/*
+ * jk 991215 - Added
+ */
+void SDL_CheckKeyRepeat(void)
+{
+	if ( SDL_KeyRepeat.timestamp ) {
+		Uint32 now, interval;
+
+		now = SDL_GetTicks();
+		interval = (now - SDL_KeyRepeat.timestamp);
+		if ( SDL_KeyRepeat.firsttime ) {
+			if ( interval > (Uint32)SDL_KeyRepeat.delay ) {
+				SDL_KeyRepeat.timestamp = now;
+				SDL_KeyRepeat.firsttime = 0;
+			}
+		} else {
+			if ( interval > (Uint32)SDL_KeyRepeat.interval ) {
+				SDL_KeyRepeat.timestamp = now;
+				SDL_PushEvent(&SDL_KeyRepeat.evt);
+			}
+		}
+	}
+}
+
+int SDL_EnableKeyRepeat(int delay, int interval)
+{
+	if ( delay < 0 ) {
+		SDL_SetError("keyboard repeat delay less than zero");
+		return(-1);
+	}
+	SDL_KeyRepeat.firsttime = 0;
+	SDL_KeyRepeat.delay = delay;
+	if ( interval < MINIMUM_REPEAT_INTERVAL ) {
+		SDL_KeyRepeat.interval = MINIMUM_REPEAT_INTERVAL;
+	} else {
+		SDL_KeyRepeat.interval = interval;
+	}
+	SDL_KeyRepeat.timestamp = 0;
+	return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_mouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,247 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General mouse handling code for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_sysvideo.h"
+
+
+/* These are static for our mouse handling code */
+static Sint16 SDL_MouseX = 0;
+static Sint16 SDL_MouseY = 0;
+static Sint16 SDL_DeltaX = 0;
+static Sint16 SDL_DeltaY = 0;
+static Uint8  SDL_ButtonState = 0;
+
+
+/* Public functions */
+int SDL_MouseInit(void)
+{
+	/* The mouse is at (0,0) */
+	SDL_MouseX = 0;
+	SDL_MouseY = 0;
+	SDL_DeltaX = 0;
+	SDL_DeltaY = 0;
+	SDL_ButtonState = 0;
+
+	/* That's it! */
+	return(0);
+}
+
+Uint8 SDL_GetMouseState (int *x, int *y)
+{
+	if ( x )
+		*x = SDL_MouseX;
+	if ( y )
+		*y = SDL_MouseY;
+	return(SDL_ButtonState);
+}
+
+Uint8 SDL_GetRelativeMouseState (int *x, int *y)
+{
+	if ( x )
+		*x = SDL_DeltaX;
+	if ( y )
+		*y = SDL_DeltaY;
+	SDL_DeltaX = 0;
+	SDL_DeltaY = 0;
+	return(SDL_ButtonState);
+}
+
+static void ClipOffset(Sint16 *x, Sint16 *y)
+{
+	/* This clips absolute mouse coordinates when the apparent
+	   display surface is smaller than the real display surface.
+	 */
+	if ( SDL_VideoSurface->offset ) {
+		*y -= SDL_VideoSurface->offset/SDL_VideoSurface->pitch;
+		*x -= (SDL_VideoSurface->offset%SDL_VideoSurface->pitch)/
+				SDL_VideoSurface->format->BytesPerPixel;
+	}
+}
+
+/* These are global for SDL_eventloop.c */
+int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 y)
+{
+	int posted;
+	Uint16 X, Y;
+	Sint16 Xrel;
+	Sint16 Yrel;
+
+	/* Don't handle mouse motion if there's no cursor surface */
+	if ( SDL_VideoSurface == NULL ) {
+		return(0);
+	}
+
+	/* Default buttonstate is the current one */
+	if ( ! buttonstate ) {
+		buttonstate = SDL_ButtonState;
+	}
+
+	Xrel = x;
+	Yrel = y;
+	if ( relative ) {
+		/* Push the cursor around */
+		x = (SDL_MouseX+x);
+		y = (SDL_MouseY+y);
+	} else {
+		/* Do we need to clip {x,y} ? */
+		ClipOffset(&x, &y);
+	}
+
+	/* Mouse coordinates range from 0 - width-1 and 0 - height-1 */
+	if ( x < 0 )
+		X = 0;
+	else
+	if ( x >= SDL_VideoSurface->w )
+		X = SDL_VideoSurface->w-1;
+	else
+		X = (Uint16)x;
+
+	if ( y < 0 )
+		Y = 0;
+	else
+	if ( y >= SDL_VideoSurface->h )
+		Y = SDL_VideoSurface->h-1;
+	else
+		Y = (Uint16)y;
+
+	/* If not relative mode, generate relative motion from clamped X/Y.
+	   This prevents lots of extraneous large delta relative motion when
+	   the screen is windowed mode and the mouse is outside the window.
+	*/
+	if ( ! relative ) {
+		Xrel = X-SDL_MouseX;
+		Yrel = Y-SDL_MouseY;
+	}
+
+	/* Update internal mouse state */
+	SDL_ButtonState = buttonstate;
+	SDL_MouseX = X;
+	SDL_MouseY = Y;
+	SDL_DeltaX += Xrel;
+	SDL_DeltaY += Yrel;
+	SDL_MoveCursor(SDL_MouseX, SDL_MouseY);
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE ) {
+		SDL_Event event;
+		memset(&event, 0, sizeof(event));
+		event.type = SDL_MOUSEMOTION;
+		event.motion.state = buttonstate;
+		event.motion.x = X;
+		event.motion.y = Y;
+		event.motion.xrel = Xrel;
+		event.motion.yrel = Yrel;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
+
+int SDL_PrivateMouseButton(Uint8 state, Uint8 button, Sint16 x, Sint16 y)
+{
+	SDL_Event event;
+	int posted;
+	int move_mouse;
+	Uint8 buttonstate;
+
+	memset(&event, 0, sizeof(event));
+
+	/* Check parameters */
+	if ( x || y ) {
+		ClipOffset(&x, &y);
+		move_mouse = 1;
+		/* Mouse coordinates range from 0 - width-1 and 0 - height-1 */
+		if ( x < 0 )
+			x = 0;
+		else
+		if ( x >= SDL_VideoSurface->w )
+			x = SDL_VideoSurface->w-1;
+
+		if ( y < 0 )
+			y = 0;
+		else
+		if ( y >= SDL_VideoSurface->h )
+			y = SDL_VideoSurface->h-1;
+	} else {
+		move_mouse = 0;
+	}
+	if ( ! x )
+		x = SDL_MouseX;
+	if ( ! y )
+		y = SDL_MouseY;
+
+	/* Figure out which event to perform */
+	buttonstate = SDL_ButtonState;
+	switch ( state ) {
+		case SDL_PRESSED:
+			event.type = SDL_MOUSEBUTTONDOWN;
+			buttonstate |= SDL_BUTTON(button);
+			break;
+		case SDL_RELEASED:
+			event.type = SDL_MOUSEBUTTONUP;
+			buttonstate &= ~SDL_BUTTON(button);
+			break;
+		default:
+			/* Invalid state -- bail */
+			return(0);
+	}
+
+	/* Update internal mouse state */
+	SDL_ButtonState = buttonstate;
+	if ( move_mouse ) {
+		SDL_MouseX = x;
+		SDL_MouseY = y;
+		SDL_MoveCursor(SDL_MouseX, SDL_MouseY);
+	}
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) {
+		event.button.state = state;
+		event.button.button = button;
+		event.button.x = x;
+		event.button.y = y;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_quit.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,84 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General quit handling code for SDL */
+
+#include <stdio.h>
+#ifndef NO_SIGNAL_H
+#include <signal.h>
+#endif
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+
+
+#ifndef NO_SIGNAL_H
+static void SDL_HandleSIG(int sig)
+{
+	/* Reset the signal handler */
+	signal(sig, SDL_HandleSIG);
+
+	/* Signal a quit interrupt */
+	SDL_PrivateQuit();
+}
+#endif /* NO_SIGNAL_H */
+
+/* Public functions */
+int SDL_QuitInit(void)
+{
+#ifndef NO_SIGNAL_H
+	void (*ohandler)(int);
+
+	/* Both SIGINT and SIGTERM are translated into quit interrupts */
+	ohandler = signal(SIGINT,  SDL_HandleSIG);
+	if ( ohandler != SIG_DFL )
+		signal(SIGINT, ohandler);
+	ohandler = signal(SIGTERM, SDL_HandleSIG);
+	if ( ohandler != SIG_DFL )
+		signal(SIGTERM, ohandler);
+#endif /* NO_SIGNAL_H */
+
+	/* That's it! */
+	return(0);
+}
+
+/* This function returns 1 if it's okay to close the application window */
+int SDL_PrivateQuit(void)
+{
+	int posted;
+
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_QUIT] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.type = SDL_QUIT;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_resize.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,76 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Resize event handling code for SDL */
+
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_sysvideo.h"
+
+
+/* Keep the last resize event so we don't post duplicates */
+static struct {
+	int w;
+	int h;
+} last_resize;
+
+/* This is global for SDL_eventloop.c */
+int SDL_PrivateResize(int w, int h)
+{
+	int posted;
+	SDL_Event events[32];
+
+	/* See if this event would change the video surface */
+	if ( !w || !h ||
+	     ((last_resize.w == w) && (last_resize.h == h)) ) {
+		return(0);
+	}
+        last_resize.w = w;
+        last_resize.h = h;
+	if ( ! SDL_VideoSurface ||
+	     ((w == SDL_VideoSurface->w) && (h == SDL_VideoSurface->h)) ) {
+		return(0);
+	}
+
+	/* Pull out all old resize events */
+	SDL_PeepEvents(events, sizeof(events)/sizeof(events[0]),
+	                    SDL_GETEVENT, SDL_VIDEORESIZEMASK);
+
+	/* Post the event, if desired */
+	posted = 0;
+	if ( SDL_ProcessEvents[SDL_VIDEORESIZE] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.type = SDL_VIDEORESIZE;
+		event.resize.w = w;
+		event.resize.h = h;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+	return(posted);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/events/SDL_sysevents.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_sysvideo.h"
+
+/* Useful functions and variables from SDL_sysevents.c */
+
+#ifdef __BEOS__		/* The Be event loop runs in a separate thread */
+#define MUST_THREAD_EVENTS
+#endif
+
+#ifdef WIN32		/* Win32 doesn't allow a separate event thread */
+#define CANT_THREAD_EVENTS
+#endif
+
+#ifdef macintosh	/* MacOS 7/8 don't support preemptive multi-tasking */
+#define CANT_THREAD_EVENTS
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/file/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/file/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,11 @@
+
+## Makefile.am for the SDL file library
+
+noinst_LTLIBRARIES = libfile.la
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_rwops.c
+
+libfile_la_SOURCES = $(COMMON_SRCS)
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/file/SDL_rwops.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,274 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This file provides a general interface for SDL to read and write
+   data sources.  It can easily be extended to files, memory, etc.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_rwops.h"
+
+/* Functions to read/write stdio file pointers */
+
+static int stdio_seek(SDL_RWops *context, int offset, int whence)
+{
+	if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
+		return(ftell(context->hidden.stdio.fp));
+	} else {
+		SDL_Error(SDL_EFSEEK);
+		return(-1);
+	}
+}
+static int stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
+{
+	size_t nread;
+
+	nread = fread(ptr, size, maxnum, context->hidden.stdio.fp); 
+	if ( nread == 0 && ferror(context->hidden.stdio.fp) ) {
+		SDL_Error(SDL_EFREAD);
+	}
+	return(nread);
+}
+static int stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
+{
+	size_t nwrote;
+
+	nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
+	if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) {
+		SDL_Error(SDL_EFWRITE);
+	}
+	return(nwrote);
+}
+static int stdio_close(SDL_RWops *context)
+{
+	if ( context ) {
+		if ( context->hidden.stdio.autoclose ) {
+			/* WARNING:  Check the return value here! */
+			fclose(context->hidden.stdio.fp);
+		}
+		free(context);
+	}
+	return(0);
+}
+
+/* Functions to read/write memory pointers */
+
+static int mem_seek(SDL_RWops *context, int offset, int whence)
+{
+	Uint8 *newpos;
+
+	switch (whence) {
+		case SEEK_SET:
+			newpos = context->hidden.mem.base+offset;
+			break;
+		case SEEK_CUR:
+			newpos = context->hidden.mem.here+offset;
+			break;
+		case SEEK_END:
+			newpos = context->hidden.mem.stop+offset;
+			break;
+		default:
+			SDL_SetError("Unknown value for 'whence'");
+			return(-1);
+	}
+	if ( newpos < context->hidden.mem.base ) {
+		newpos = context->hidden.mem.base;
+	}
+	if ( newpos > context->hidden.mem.stop ) {
+		newpos = context->hidden.mem.stop;
+	}
+	context->hidden.mem.here = newpos;
+	return(context->hidden.mem.here-context->hidden.mem.base);
+}
+static int mem_read(SDL_RWops *context, void *ptr, int size, int maxnum)
+{
+	int num;
+
+	num = maxnum;
+	if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
+		num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
+	}
+	memcpy(ptr, context->hidden.mem.here, num*size);
+	context->hidden.mem.here += num*size;
+	return(num);
+}
+static int mem_write(SDL_RWops *context, const void *ptr, int size, int num)
+{
+	if ( (context->hidden.mem.here + (num*size)) > context->hidden.mem.stop ) {
+		num = (context->hidden.mem.stop-context->hidden.mem.here)/size;
+	}
+	memcpy(context->hidden.mem.here, ptr, num*size);
+	context->hidden.mem.here += num*size;
+	return(num);
+}
+static int mem_close(SDL_RWops *context)
+{
+	if ( context ) {
+		free(context);
+	}
+	return(0);
+}
+
+/* Functions to create SDL_RWops structures from various data sources */
+#ifdef WIN32
+/* Aggh.  You can't (apparently) open a file in an application and
+   read from it in a DLL.
+*/
+static int in_sdl = 0;
+#endif
+
+#ifdef macintosh
+/*
+ * translate unix-style slash-separated filename to mac-style colon-separated
+ * name; return malloced string
+ */
+static char *unix_to_mac(const char *file)
+{
+	int flen = strlen(file);
+	char *path = malloc(flen + 2);
+	const char *src = file;
+	char *dst = path;
+	if(*src == '/') {
+		/* really depends on filesystem layout, hope for the best */
+		src++;
+	} else {
+		/* Check if this is a MacOS path to begin with */
+		if(*src != ':')
+			*dst++ = ':';   /* relative paths begin with ':' */
+	}
+	while(src < file + flen) {
+		const char *end = strchr(src, '/');
+		int len;
+		if(!end)
+			end = file + flen; /* last component */
+		len = end - src;
+		if(len == 0 || (len == 1 && src[0] == '.')) {
+			/* remove repeated slashes and . */
+		} else {
+			if(len == 2 && src[0] == '.' && src[1] == '.') {
+				/* replace .. with the empty string */
+			} else {
+				memcpy(dst, src, len);
+				dst += len;
+			}
+			if(end < file + flen)
+				*dst++ = ':';
+		}
+		src = end + 1;
+	}
+	*dst++ = '\0';
+	return path;
+}
+#endif /* macintosh */
+
+SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
+{
+	FILE *fp;
+	SDL_RWops *rwops;
+
+	rwops = NULL;
+
+#ifdef macintosh
+	{
+		char *mpath = unix_to_mac(file);
+		fp = fopen(mpath, mode);
+		free(mpath);
+	}
+#else
+	fp = fopen(file, mode);
+#endif
+	if ( fp == NULL ) {
+		SDL_SetError("Couldn't open %s", file);
+	} else {
+#ifdef WIN32
+		in_sdl = 1;
+		rwops = SDL_RWFromFP(fp, 1);
+		in_sdl = 0;
+#else
+		rwops = SDL_RWFromFP(fp, 1);
+#endif
+	}
+	return(rwops);
+}
+
+SDL_RWops *SDL_RWFromFP(FILE *fp, int autoclose)
+{
+	SDL_RWops *rwops;
+
+#ifdef WIN32
+	if ( ! in_sdl ) {
+		SDL_SetError("You can't pass a FILE pointer to a DLL (??)");
+		/*return(NULL);*/
+	}
+#endif
+	rwops = SDL_AllocRW();
+	if ( rwops != NULL ) {
+		rwops->seek = stdio_seek;
+		rwops->read = stdio_read;
+		rwops->write = stdio_write;
+		rwops->close = stdio_close;
+		rwops->hidden.stdio.fp = fp;
+		rwops->hidden.stdio.autoclose = autoclose;
+	}
+	return(rwops);
+}
+
+SDL_RWops *SDL_RWFromMem(void *mem, int size)
+{
+	SDL_RWops *rwops;
+
+	rwops = SDL_AllocRW();
+	if ( rwops != NULL ) {
+		rwops->seek = mem_seek;
+		rwops->read = mem_read;
+		rwops->write = mem_write;
+		rwops->close = mem_close;
+		rwops->hidden.mem.base = (Uint8 *)mem;
+		rwops->hidden.mem.here = rwops->hidden.mem.base;
+		rwops->hidden.mem.stop = rwops->hidden.mem.base+size;
+	}
+	return(rwops);
+}
+
+SDL_RWops *SDL_AllocRW(void)
+{
+	SDL_RWops *area;
+
+	area = (SDL_RWops *)malloc(sizeof *area);
+	if ( area == NULL ) {
+		SDL_OutOfMemory();
+	}
+	return(area);
+}
+
+void SDL_FreeRW(SDL_RWops *area)
+{
+	free(area);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/COPYING.LIB	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,438 @@
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1991 Free Software Foundation, Inc.
+    		    59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the library GPL.  It is
+ numbered 2 because it goes with version 2 of the ordinary GPL.]
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Library General Public License, applies to some
+specially designated Free Software Foundation software, and to any
+other libraries whose authors decide to use it.  You can use it for
+your libraries, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if
+you distribute copies of the library, or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link a program with the library, you must provide
+complete object files to the recipients so that they can relink them
+with the library, after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  Our method of protecting your rights has two steps: (1) copyright
+the library, and (2) offer you this license which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  Also, for each distributor's protection, we want to make certain
+that everyone understands that there is no warranty for this free
+library.  If the library is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original
+version, so that any problems introduced by others will not reflect on
+the original authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that companies distributing free
+software will individually obtain patent licenses, thus in effect
+transforming the program into proprietary software.  To prevent this,
+we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+  Most GNU software, including some libraries, is covered by the ordinary
+GNU General Public License, which was designed for utility programs.  This
+license, the GNU Library General Public License, applies to certain
+designated libraries.  This license is quite different from the ordinary
+one; be sure to read it in full, and don't assume that anything in it is
+the same as in the ordinary license.
+
+  The reason we have a separate public license for some libraries is that
+they blur the distinction we usually make between modifying or adding to a
+program and simply using it.  Linking a program with a library, without
+changing the library, is in some sense simply using the library, and is
+analogous to running a utility program or application program.  However, in
+a textual and legal sense, the linked executable is a combined work, a
+derivative of the original library, and the ordinary General Public License
+treats it as such.
+
+  Because of this blurred distinction, using the ordinary General
+Public License for libraries did not effectively promote software
+sharing, because most developers did not use the libraries.  We
+concluded that weaker conditions might promote sharing better.
+
+  However, unrestricted linking of non-free programs would deprive the
+users of those programs of all benefit from the free status of the
+libraries themselves.  This Library General Public License is intended to
+permit developers of non-free programs to use free libraries, while
+preserving your freedom as a user of such programs to change the free
+libraries that are incorporated in them.  (We have not seen how to achieve
+this as regards changes in header files, but we have achieved it as regards
+changes in the actual functions of the Library.)  The hope is that this
+will lead to faster development of free libraries.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, while the latter only
+works together with the library.
+
+  Note that it is possible for a library to be covered by the ordinary
+General Public License rather than by this special one.
+
+		  GNU LIBRARY GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library which
+contains a notice placed by the copyright holder or other authorized
+party saying it may be distributed under the terms of this Library
+General Public License (also called "this License").  Each licensee is
+addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+  
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also compile or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    c) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    d) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the source code distributed need not include anything that is normally
+distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Library General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+			    NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/HeadMMX.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,101 @@
+/*
+   Header definitions for the MMX routines for the HERMES library
+   Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk)
+   This source code is licensed under the GNU LGPL
+  
+   Please refer to the file COPYING.LIB contained in the distribution for
+   licensing conditions
+*/
+
+#ifndef __HERMES_HEAD_MMX__
+#define __HERMES_HEAD_MMX__
+
+
+/* If you cannot stand ifdefs, then please do not look into this file, it's
+   going to end your life :) */
+
+#ifdef X86_ASSEMBLER
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void STACKCALL ConvertMMX(HermesConverterInterface *);
+
+void STACKCALL ClearMMX_32(HermesClearInterface *);
+void STACKCALL ClearMMX_24(HermesClearInterface *);
+void STACKCALL ClearMMX_16(HermesClearInterface *);
+void STACKCALL ClearMMX_8(HermesClearInterface *);
+
+void ConvertMMXpII32_24RGB888();
+void ConvertMMXpII32_16RGB565();
+void ConvertMMXpII32_16BGR565();
+void ConvertMMXpII32_16RGB555();
+void ConvertMMXpII32_16BGR565();
+void ConvertMMXpII32_16BGR555();
+
+void ConvertMMXp32_16RGB555();
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+/* Fix the underscore business with ELF compilers */
+
+#if defined(__ELF__) && defined(__GNUC__)
+  #ifdef __cplusplus 
+  extern "C" {   
+  #endif
+
+  void ConvertMMX(HermesConverterInterface *) __attribute__ ((alias ("_ConvertMMX")));
+#if 0
+  void ClearMMX_32(HermesClearInterface *) __attribute__ ((alias ("_ClearMMX_32")));
+  void ClearMMX_24(HermesClearInterface *)  __attribute__ ((alias ("_ClearMMX_24")));
+  void ClearMMX_16(HermesClearInterface *)  __attribute__ ((alias ("_ClearMMX_16")));
+  void ClearMMX_8(HermesClearInterface *)  __attribute__ ((alias ("_ClearMMX_8")));
+
+  void ConvertMMXp32_16RGB555() __attribute__ ((alias ("_ConvertMMXp32_16RGB555")));
+#endif
+
+  void ConvertMMXpII32_24RGB888() __attribute__ ((alias ("_ConvertMMXpII32_24RGB888")));
+  void ConvertMMXpII32_16RGB565() __attribute__ ((alias ("_ConvertMMXpII32_16RGB565")));
+  void ConvertMMXpII32_16BGR565() __attribute__ ((alias ("_ConvertMMXpII32_16BGR565")));
+  void ConvertMMXpII32_16RGB555() __attribute__ ((alias ("_ConvertMMXpII32_16RGB555")));
+  void ConvertMMXpII32_16BGR555() __attribute__ ((alias ("_ConvertMMXpII32_16BGR555")));
+
+  #ifdef __cplusplus
+  }
+  #endif
+
+#endif /* ELF and GNUC */
+
+
+
+
+/* Make it work with Watcom */
+#ifdef __WATCOMC__
+#pragma warning 601 9
+
+#pragma aux ConvertMMX "_*" modify [EAX EBX ECX EDX ESI EDI]
+
+#pragma aux ClearMMX_32 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearMMX_24 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearMMX_16 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearMMX_8 "_*" modify [EAX EBX ECX EDX ESI EDI]
+
+#pragma aux ConvertMMXpII32_24RGB888 "_*"
+#pragma aux ConvertMMXpII32_16RGB565 "_*"
+#pragma aux ConvertMMXpII32_16BGR565 "_*"
+#pragma aux ConvertMMXpII32_16RGB555 "_*"
+#pragma aux ConvertMMXpII32_16BGR555 "_*"
+#pragma aux ConvertMMXp32_16RGB555 "_*"
+
+#endif /* WATCOM */
+
+#endif /* X86_ASSEMBLER */
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/HeadX86.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,195 @@
+/*
+   Header definitions for the x86 routines for the HERMES library
+   Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at)
+   This source code is licensed under the GNU LGPL
+  
+   Please refer to the file COPYING.LIB contained in the distribution for
+   licensing conditions
+*/
+
+#ifndef __HERMES_HEAD_X86__
+#define __HERMES_HEAD_X86__
+
+
+#ifdef X86_ASSEMBLER
+
+/* If you can't stand IFDEFS, then close your eyes now, please :) */
+
+/* Ok, we start with normal function definitions */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+void STACKCALL ConvertX86(HermesConverterInterface *);
+void STACKCALL ClearX86_32(HermesClearInterface *);
+void STACKCALL ClearX86_24(HermesClearInterface *);
+void STACKCALL ClearX86_16(HermesClearInterface *);
+void STACKCALL ClearX86_8(HermesClearInterface *);
+
+int STACKCALL Hermes_X86_CPU();
+
+void ConvertX86p32_32BGR888();
+void ConvertX86p32_32RGBA888();
+void ConvertX86p32_32BGRA888();
+void ConvertX86p32_24RGB888();
+void ConvertX86p32_24BGR888();
+void ConvertX86p32_16RGB565();
+void ConvertX86p32_16BGR565();
+void ConvertX86p32_16RGB555();
+void ConvertX86p32_16BGR555();
+void ConvertX86p32_8RGB332();
+
+void ConvertX86p16_32RGB888();
+void ConvertX86p16_32BGR888();
+void ConvertX86p16_32RGBA888();
+void ConvertX86p16_32BGRA888();
+void ConvertX86p16_24RGB888();
+void ConvertX86p16_24BGR888();
+void ConvertX86p16_16BGR565();
+void ConvertX86p16_16RGB555();
+void ConvertX86p16_16BGR555();
+void ConvertX86p16_8RGB332();
+
+void CopyX86p_4byte();
+void CopyX86p_3byte();
+void CopyX86p_2byte();
+void CopyX86p_1byte();
+
+void ConvertX86pI8_32();
+void ConvertX86pI8_24();
+void ConvertX86pI8_16();
+
+extern int32 ConvertX86p16_32RGB888_LUT_X86[512];
+extern int32 ConvertX86p16_32BGR888_LUT_X86[512];
+extern int32 ConvertX86p16_32RGBA888_LUT_X86[512];
+extern int32 ConvertX86p16_32BGRA888_LUT_X86[512];
+  
+#ifdef __cplusplus
+}
+#endif
+
+
+
+
+/* Now fix up the ELF underscore problem */
+
+#if defined(__ELF__) && defined(__GNUC__)
+  #ifdef __cplusplus
+  extern "C" {
+  #endif
+
+  int Hermes_X86_CPU() __attribute__ ((alias ("_Hermes_X86_CPU")));
+
+  void ConvertX86(HermesConverterInterface *) __attribute__ ((alias ("_ConvertX86")));
+
+#if 0
+  void ClearX86_32(HermesClearInterface *) __attribute__ ((alias ("_ClearX86_32")));
+  void ClearX86_24(HermesClearInterface *)  __attribute__ ((alias ("_ClearX86_24")));
+  void ClearX86_16(HermesClearInterface *)  __attribute__ ((alias ("_ClearX86_16")));
+  void ClearX86_8(HermesClearInterface *)  __attribute__ ((alias ("_ClearX86_8")));
+#endif
+
+  void ConvertX86p32_32BGR888() __attribute__ ((alias ("_ConvertX86p32_32BGR888")));
+  void ConvertX86p32_32RGBA888() __attribute__ ((alias ("_ConvertX86p32_32RGBA888")));
+  void ConvertX86p32_32BGRA888() __attribute__ ((alias ("_ConvertX86p32_32BGRA888")));
+  void ConvertX86p32_24RGB888() __attribute__ ((alias ("_ConvertX86p32_24RGB888")));
+  void ConvertX86p32_24BGR888() __attribute__ ((alias ("_ConvertX86p32_24BGR888")));
+  void ConvertX86p32_16RGB565() __attribute__ ((alias ("_ConvertX86p32_16RGB565")));
+  void ConvertX86p32_16BGR565() __attribute__ ((alias ("_ConvertX86p32_16BGR565")));
+  void ConvertX86p32_16RGB555() __attribute__ ((alias ("_ConvertX86p32_16RGB555")));
+  void ConvertX86p32_16BGR555() __attribute__ ((alias ("_ConvertX86p32_16BGR555")));
+  void ConvertX86p32_8RGB332() __attribute__ ((alias ("_ConvertX86p32_8RGB332")));
+
+#if 0
+  void ConvertX86p16_32RGB888() __attribute__ ((alias ("_ConvertX86p16_32RGB888")));
+  void ConvertX86p16_32BGR888() __attribute__ ((alias ("_ConvertX86p16_32BGR888")));
+  void ConvertX86p16_32RGBA888() __attribute__ ((alias ("_ConvertX86p16_32RGBA888")));
+  void ConvertX86p16_32BGRA888() __attribute__ ((alias ("_ConvertX86p16_32BGRA888")));
+  void ConvertX86p16_24RGB888() __attribute__ ((alias ("_ConvertX86p16_24RGB888")));
+  void ConvertX86p16_24BGR888() __attribute__ ((alias ("_ConvertX86p16_24BGR888")));
+#endif
+  void ConvertX86p16_16BGR565() __attribute__ ((alias ("_ConvertX86p16_16BGR565")));
+  void ConvertX86p16_16RGB555() __attribute__ ((alias ("_ConvertX86p16_16RGB555")));
+  void ConvertX86p16_16BGR555() __attribute__ ((alias ("_ConvertX86p16_16BGR555")));
+  void ConvertX86p16_8RGB332() __attribute__ ((alias ("_ConvertX86p16_8RGB332")));
+
+#if 0
+  void CopyX86p_4byte() __attribute__ ((alias ("_CopyX86p_4byte")));
+  void CopyX86p_3byte() __attribute__ ((alias ("_CopyX86p_3byte")));
+  void CopyX86p_2byte() __attribute__ ((alias ("_CopyX86p_2byte")));
+  void CopyX86p_1byte() __attribute__ ((alias ("_CopyX86p_1byte")));
+
+  void ConvertX86pI8_32() __attribute__ ((alias ("_ConvertX86pI8_32")));
+  void ConvertX86pI8_24() __attribute__ ((alias ("_ConvertX86pI8_24")));
+  void ConvertX86pI8_16() __attribute__ ((alias ("_ConvertX86pI8_16")));
+
+  extern int32 ConvertX86p16_32RGB888_LUT_X86[512] __attribute__ ((alias ("_ConvertX86p16_32RGB888_LUT_X86")));
+  extern int32 ConvertX86p16_32BGR888_LUT_X86[512] __attribute__ ((alias ("_ConvertX86p16_32BGR888_LUT_X86")));
+  extern int32 ConvertX86p16_32RGBA888_LUT_X86[512] __attribute__ ((alias ("_ConvertX86p16_32RGBA888_LUT_X86")));
+  extern int32 ConvertX86p16_32BGRA888_LUT_X86[512] __attribute__ ((alias ("_ConvertX86p16_32BGRA888_LUT_X86")));
+#endif
+
+  #ifdef __cplusplus
+  }
+  #endif
+
+#endif /* ELF & GNU */
+
+
+
+/* Make it run with WATCOM C */
+#ifdef __WATCOMC__
+#pragma warning 601 9
+
+#pragma aux Hermes_X86_CPU "_*"
+
+#pragma aux ConvertX86 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearX86_32 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearX86_24 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearX86_16 "_*" modify [EAX EBX ECX EDX ESI EDI]
+#pragma aux ClearX86_8 "_*" modify [EAX EBX ECX EDX ESI EDI]
+
+#pragma aux ConvertX86p32_32BGR888 "_*"
+#pragma aux ConvertX86p32_32RGBA888 "_*"
+#pragma aux ConvertX86p32_32BGRA888 "_*"
+#pragma aux ConvertX86p32_24RGB888 "_*"
+#pragma aux ConvertX86p32_24BGR888 "_*"
+#pragma aux ConvertX86p32_16RGB565 "_*"
+#pragma aux ConvertX86p32_16BGR565 "_*"
+#pragma aux ConvertX86p32_16RGB555 "_*"
+#pragma aux ConvertX86p32_16BGR555 "_*"
+#pragma aux ConvertX86p32_8RGB332 "_*"
+
+#pragma aux ConvertX86p16_32RGB888 "_*"
+#pragma aux ConvertX86p16_32BGR888 "_*"
+#pragma aux ConvertX86p16_32RGBA888 "_*"
+#pragma aux ConvertX86p16_32BGRA888 "_*"
+#pragma aux ConvertX86p16_24RGB888 "_*"
+#pragma aux ConvertX86p16_24BGR888 "_*"
+#pragma aux ConvertX86p16_16BGR565 "_*"
+#pragma aux ConvertX86p16_16RGB555 "_*"
+#pragma aux ConvertX86p16_16BGR555 "_*"
+#pragma aux ConvertX86p16_8RGB332 "_*"
+
+#pragma aux CopyX86p_4byte "_*"
+#pragma aux CopyX86p_3byte "_*"
+#pragma aux CopyX86p_2byte "_*"
+#pragma aux CopyX86p_1byte "_*"
+
+#pragma aux ConvertX86pI8_32 "_*"
+#pragma aux ConvertX86pI8_24 "_*"
+#pragma aux ConvertX86pI8_16 "_*"
+
+#pragma aux ConvertX86p16_32RGB888_LUT_X86 "_*"
+#pragma aux ConvertX86p16_32BGR888_LUT_X86 "_*"
+#pragma aux ConvertX86p16_32RGBA888_LUT_X86 "_*"
+#pragma aux ConvertX86p16_32BGRA888_LUT_X86 "_*"
+
+#endif /* __WATCOMC__ */
+
+
+#endif /* X86_ASSEMBLER */
+
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+###########################################################################
+#
+# Some consistent rules for building asm files:
+
+STRIP_FPIC = sh $(top_srcdir)/strip_fPIC.sh
+
+SUFFIXES = .asm
+
+.asm.lo:
+	$(LIBTOOL) --mode=compile $(STRIP_FPIC) $(NASM) @NASMFLAGS@ $<
+
+###########################################################################
+
+# The hermes library target
+noinst_LTLIBRARIES = libhermes.la
+
+libhermes_la_SOURCES = $(PORTABLE_SRCS)
+
+# The hermes library sources
+PORTABLE_SRCS = 		\
+	mmx_main.asm		\
+	mmxp2_32.asm		\
+	x86_main.asm		\
+	x86p_16.asm		\
+	x86p_32.asm		\
+	\
+	HeadMMX.h		\
+	HeadX86.h
+
+EXTRA_DIST =			\
+	COPYING.LIB		\
+	README
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/README	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+HERMES 1.2.4 (c)1998 Christian Nentwich (brn) (c.nentwich@cs.ucl.ac.uk)
+and quite a few assembler routines (c) Glenn Fielder (gaffer@gaffer.org)
+
+This library and all the files enclosed in this package are free software
+under the terms of the GNU Library General Public License (LGPL). Please
+refer to the included file COPYING.LIB for the exact terms.
+----------------------------------------------------------------------------
+
+This is a stripped down version of HERMES, including only the x86 assembler
+converters, for use with Simple DirectMedia Layer.
+
+The full HERMES library is available at:  http://hermes.terminal.at/
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/mmx_main.asm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,74 @@
+;
+; mmx format converter main loops for HERMES
+; Some routines Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk)
+; This source code is licensed under the GNU LGPL
+; 
+; Please refer to the file COPYING.LIB contained in the distribution for
+; licensing conditions		
+;
+
+BITS 32
+
+GLOBAL _ConvertMMX
+GLOBAL _mmxreturn
+
+
+SECTION .text
+		
+;; _ConvertMMX:	 
+;; [ESP+8] ConverterInfo*
+;; --------------------------------------------------------------------------
+;; ConverterInfo (ebp+..)
+;;   0:	void *s_pixels
+;;   4:	int s_width
+;;   8:	int s_height
+;;  12:	int s_add
+;;  16:	void *d_pixels
+;;  20:	int d_width
+;;  24:	int d_height
+;;  28:	int d_add
+;;  32:	void (*converter_function)() 
+;;  36: int32 *lookup
+	
+_ConvertMMX:
+	push ebp
+	mov ebp,esp
+
+; Save the registers used by the blitters, necessary for optimized code
+	pusha
+
+	mov eax,[ebp+8]
+
+        cmp dword [eax+4],BYTE 0
+	je endconvert
+	
+	mov ebp,eax
+	
+	mov esi,[ebp+0]
+	mov edi,[ebp+16]
+	
+y_loop:	
+	mov ecx,[ebp+4]
+
+	jmp [ebp+32]
+
+_mmxreturn:	
+	add esi,[ebp+12]
+	add edi,[ebp+28]
+	
+	dec dword  [ebp+8]
+	jnz y_loop
+
+	
+; Restore the registers used by the blitters, necessary for optimized code
+	popa
+
+	pop ebp
+
+endconvert:
+	emms
+	
+	ret		
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/mmxp2_32.asm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,386 @@
+;
+; pII-optimised MMX format converters for HERMES
+; Copyright (c) 1998 Christian Nentwich (c.nentwich@cs.ucl.ac.uk)
+;   and (c) 1999 Jonathan Matthew (jmatthew@uq.net.au)
+; This source code is licensed under the GNU LGPL
+; 
+; Please refer to the file COPYING.LIB contained in the distribution for
+; licensing conditions		
+;
+; COPYRIGHT NOTICE
+; 
+; This file partly contains code that is (c) Intel Corporation, specifically
+; the mode detection routine, and the converter to 15 bit (8 pixel
+; conversion routine from the mmx programming tutorial pages).
+;
+;
+; These routines aren't exactly pII optimised - it's just that as they
+; are, they're terrible on p5 MMXs, but less so on pIIs.  Someone needs to
+; optimise them for p5 MMXs..
+
+BITS 32
+
+	
+GLOBAL _ConvertMMXpII32_24RGB888
+GLOBAL _ConvertMMXpII32_16RGB565
+GLOBAL _ConvertMMXpII32_16BGR565
+GLOBAL _ConvertMMXpII32_16RGB555
+GLOBAL _ConvertMMXpII32_16BGR555
+
+EXTERN _mmxreturn
+ 
+SECTION .data
+	
+ALIGN 8
+
+;; Constants for conversion routines
+
+mmx32_rgb888_mask dd 00ffffffh,00ffffffh
+
+mmx32_rgb565_b dd 000000f8h, 000000f8h
+mmx32_rgb565_g dd 0000fc00h, 0000fc00h
+mmx32_rgb565_r dd 00f80000h, 00f80000h
+
+mmx32_rgb555_rb dd 00f800f8h,00f800f8h
+mmx32_rgb555_g dd 0000f800h,0000f800h
+mmx32_rgb555_mul dd 20000008h,20000008h
+mmx32_bgr555_mul dd 00082000h,00082000h
+
+
+			
+SECTION .text
+
+_ConvertMMXpII32_24RGB888:
+
+        ; set up mm6 as the mask, mm7 as zero
+        movq mm6, qword [mmx32_rgb888_mask]
+        pxor mm7, mm7
+
+        mov edx, ecx                    ; save ecx
+        and ecx, 0fffffffch             ; clear lower two bits
+        jnz .L1
+        jmp .L2
+
+.L1:
+
+        movq mm0, [esi]                 ; A R G B a r g b
+        pand mm0, mm6                   ; 0 R G B 0 r g b
+        movq mm1, [esi+8]               ; A R G B a r g b
+        pand mm1, mm6                   ; 0 R G B 0 r g b
+
+        movq mm2, mm0                   ; 0 R G B 0 r g b
+        punpckhdq mm2, mm7              ; 0 0 0 0 0 R G B
+        punpckldq mm0, mm7              ; 0 0 0 0 0 r g b
+        psllq mm2, 24                   ; 0 0 R G B 0 0 0
+        por mm0, mm2                    ; 0 0 R G B r g b
+
+        movq mm3, mm1                   ; 0 R G B 0 r g b
+        psllq mm3, 48                   ; g b 0 0 0 0 0 0
+        por mm0, mm3                    ; g b R G B r g b
+
+        movq mm4, mm1                   ; 0 R G B 0 r g b
+        punpckhdq mm4, mm7              ; 0 0 0 0 0 R G B
+        punpckldq mm1, mm7              ; 0 0 0 0 0 r g b
+        psrlq mm1, 16                   ; 0 0 0 R G B 0 r
+        psllq mm4, 8                    ; 0 0 0 0 R G B 0
+        por mm1, mm4                    ; 0 0 0 0 R G B r
+
+        movq [edi], mm0
+        add esi, BYTE 16
+        movd [edi+8], mm1
+        add edi, BYTE 12
+        sub ecx, BYTE 4
+        jnz .L1
+
+.L2:
+        mov ecx, edx
+        and ecx, BYTE 3
+        jz .L4
+.L3:
+        mov al, [esi]
+        mov bl, [esi+1]
+        mov dl, [esi+2]
+        mov [edi], al
+        mov [edi+1], bl
+        mov [edi+2], dl
+        add esi, BYTE 4
+        add edi, BYTE 3
+        dec ecx
+        jnz .L3
+.L4:
+        jmp _mmxreturn
+
+
+
+_ConvertMMXpII32_16RGB565:
+
+        ; set up masks
+        movq mm5, [mmx32_rgb565_b]
+        movq mm6, [mmx32_rgb565_g]
+        movq mm7, [mmx32_rgb565_r]
+
+        mov edx, ecx
+        shr ecx, 2
+        jnz .L1
+        jmp .L2         ; not necessary at the moment, but doesn't hurt (much)
+
+.L1:
+        movq mm0, [esi]         ; argb
+        movq mm1, mm0           ; argb
+        pand mm0, mm6           ; 00g0
+        movq mm3, mm1           ; argb
+        pand mm1, mm5           ; 000b
+        pand mm3, mm7           ; 0r00
+        pslld mm1, 2            ; 0 0 000000bb bbb00000
+        por mm0, mm1            ; 0 0 ggggggbb bbb00000
+        psrld mm0, 5            ; 0 0 00000ggg gggbbbbb
+
+        movq mm4, [esi+8]       ; argb
+        movq mm2, mm4           ; argb
+        pand mm4, mm6           ; 00g0
+        movq mm1, mm2           ; argb
+        pand mm2, mm5           ; 000b
+        pand mm1, mm7           ; 0r00
+        pslld mm2, 2            ; 0 0 000000bb bbb00000
+        por mm4, mm2            ; 0 0 ggggggbb bbb00000
+        psrld mm4, 5            ; 0 0 00000ggg gggbbbbb
+
+        packuswb mm3, mm1       ; R 0 r 0
+        packssdw mm0, mm4       ; as above.. ish
+        por mm0, mm3            ; done.
+        movq [edi], mm0
+
+        add esi, 16
+        add edi, 8
+        dec ecx
+        jnz .L1
+
+.L2:
+        mov ecx, edx
+        and ecx, BYTE 3
+        jz .L4
+.L3:
+        mov al, [esi]
+        mov bh, [esi+1]
+        mov ah, [esi+2]
+        shr al, 3
+        and eax, 0F81Fh            ; BYTE?
+        shr ebx, 5
+        and ebx, 07E0h             ; BYTE?
+        add eax, ebx
+        mov [edi], al
+        mov [edi+1], ah
+        add esi, BYTE 4
+        add edi, BYTE 2
+        dec ecx
+        jnz .L3
+
+.L4:
+	jmp _mmxreturn
+
+	
+_ConvertMMXpII32_16BGR565:
+
+        movq mm5, [mmx32_rgb565_r]
+        movq mm6, [mmx32_rgb565_g]
+        movq mm7, [mmx32_rgb565_b]
+
+        mov edx, ecx
+        shr ecx, 2
+        jnz .L1
+        jmp .L2
+
+.L1:
+        movq mm0, [esi]                 ; a r g b
+        movq mm1, mm0                   ; a r g b
+        pand mm0, mm6                   ; 0 0 g 0
+        movq mm3, mm1                   ; a r g b
+        pand mm1, mm5                   ; 0 r 0 0
+        pand mm3, mm7                   ; 0 0 0 b
+
+        psllq mm3, 16                   ; 0 b 0 0
+        psrld mm1, 14                   ; 0 0 000000rr rrr00000
+        por mm0, mm1                    ; 0 0 ggggggrr rrr00000
+        psrld mm0, 5                    ; 0 0 00000ggg gggrrrrr
+
+        movq mm4, [esi+8]               ; a r g b
+        movq mm2, mm4                   ; a r g b
+        pand mm4, mm6                   ; 0 0 g 0
+        movq mm1, mm2                   ; a r g b
+        pand mm2, mm5                   ; 0 r 0 0
+        pand mm1, mm7                   ; 0 0 0 b
+
+        psllq mm1, 16                   ; 0 b 0 0
+        psrld mm2, 14                   ; 0 0 000000rr rrr00000
+        por mm4, mm2                    ; 0 0 ggggggrr rrr00000
+        psrld mm4, 5                    ; 0 0 00000ggg gggrrrrr
+
+        packuswb mm3, mm1               ; BBBBB000 00000000 bbbbb000 00000000
+        packssdw mm0, mm4               ; 00000GGG GGGRRRRR 00000GGG GGGRRRRR
+        por mm0, mm3                    ; BBBBBGGG GGGRRRRR bbbbbggg gggrrrrr
+        movq [edi], mm0
+
+        add esi, BYTE 16
+        add edi, BYTE 8
+        dec ecx
+        jnz .L1
+
+.L2:
+        and edx, BYTE 3
+        jz .L4
+.L3:
+        mov al, [esi+2]
+        mov bh, [esi+1]
+        mov ah, [esi]
+        shr al, 3
+        and eax, 0F81Fh                    ; BYTE ?
+        shr ebx, 5
+        and ebx, 07E0h                     ; BYTE ?
+        add eax, ebx
+        mov [edi], al
+        mov [edi+1], ah
+        add esi, BYTE 4
+        add edi, BYTE 2
+        dec edx
+        jnz .L3
+
+.L4:
+        jmp _mmxreturn
+
+_ConvertMMXpII32_16BGR555:
+
+        ; the 16BGR555 converter is identical to the RGB555 one,
+        ; except it uses a different multiplier for the pmaddwd
+        ; instruction.  cool huh.
+
+        movq mm7, qword [mmx32_bgr555_mul]
+        jmp _convert_bgr555_cheat
+
+; This is the same as the Intel version.. they obviously went to
+; much more trouble to expand/coil the loop than I did, so theirs
+; would almost certainly be faster, even if only a little.
+; I did rename 'mmx32_rgb555_add' to 'mmx32_rgb555_mul', which is
+; (I think) a more accurate name..
+_ConvertMMXpII32_16RGB555:
+
+        movq mm7,qword [mmx32_rgb555_mul]
+_convert_bgr555_cheat:
+        movq mm6,qword [mmx32_rgb555_g]
+        
+	mov edx,ecx		           ; Save ecx 
+
+        and ecx,BYTE 0fffffff8h            ; clear lower three bits
+	jnz .L_OK
+        jmp .L2 
+
+.L_OK:
+	
+	movq mm2,[esi+8]
+
+	movq mm0,[esi]
+	movq mm3,mm2
+
+	pand mm3,qword [mmx32_rgb555_rb]
+	movq mm1,mm0
+
+	pand mm1,qword [mmx32_rgb555_rb]
+	pmaddwd mm3,mm7
+
+	pmaddwd mm1,mm7
+	pand mm2,mm6
+
+.L1:
+	movq mm4,[esi+24]
+	pand mm0,mm6
+
+	movq mm5,[esi+16]
+	por mm3,mm2
+
+	psrld mm3,6
+	por mm1,mm0
+
+	movq mm0,mm4
+	psrld mm1,6
+
+	pand mm0,qword [mmx32_rgb555_rb]
+	packssdw mm1,mm3
+
+	movq mm3,mm5
+	pmaddwd mm0,mm7
+
+	pand mm3,qword [mmx32_rgb555_rb]
+	pand mm4,mm6
+
+	movq [edi],mm1			
+	pmaddwd mm3,mm7
+
+        add esi,BYTE 32
+	por mm4,mm0
+
+	pand mm5,mm6
+	psrld mm4,6
+
+	movq mm2,[esi+8]
+	por mm5,mm3
+
+	movq mm0,[esi]
+	psrld mm5,6
+
+	movq mm3,mm2
+	movq mm1,mm0
+
+	pand mm3,qword [mmx32_rgb555_rb]
+	packssdw mm5,mm4
+
+	pand mm1,qword [mmx32_rgb555_rb]
+	pand mm2,mm6
+
+	movq [edi+8],mm5
+	pmaddwd mm3,mm7
+
+	pmaddwd mm1,mm7
+        add edi,BYTE 16
+	
+        sub ecx,BYTE 8
+	jz .L2
+        jmp .L1
+
+
+.L2:	
+	mov ecx,edx
+	
+        and ecx,BYTE 7
+	jz .L4
+	
+.L3:	
+	mov ebx,[esi]
+        add esi,BYTE 4
+	
+        mov eax,ebx
+        mov edx,ebx
+
+        shr eax,3
+        shr edx,6
+
+        and eax,BYTE 0000000000011111b
+        and edx,     0000001111100000b
+
+        shr ebx,9
+
+        or eax,edx
+
+        and ebx,     0111110000000000b
+
+        or eax,ebx
+
+        mov [edi],ax
+        add edi,BYTE 2
+
+	dec ecx
+	jnz .L3	
+
+.L4:		
+	jmp _mmxreturn
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/x86_main.asm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,125 @@
+;
+; x86 format converters for HERMES
+; Some routines Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at)
+; This source code is licensed under the GNU LGPL
+; 
+; Please refer to the file COPYING.LIB contained in the distribution for
+; licensing conditions		
+;
+; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission
+; 
+
+BITS 32
+
+GLOBAL _ConvertX86
+GLOBAL _x86return
+	
+GLOBAL _Hermes_X86_CPU
+
+
+SECTION .data
+	
+cpu_flags dd 0
+	
+		
+SECTION .text
+		
+;; _ConvertX86:	 
+;; [ESP+8] ConverterInfo*
+;; --------------------------------------------------------------------------
+;; ConverterInfo (ebp+..)
+;;   0:	void *s_pixels
+;;   4:	int s_width
+;;   8:	int s_height
+;;  12:	int s_add
+;;  16:	void *d_pixels
+;;  20:	int d_width
+;;  24:	int d_height
+;;  28:	int d_add
+;;  32:	void (*converter_function)() 
+;;  36: int32 *lookup
+	
+_ConvertX86:
+	push ebp
+	mov ebp,esp
+
+; Save the registers used by the blitters, necessary for optimized code
+	pusha
+
+	mov eax,[ebp+8]
+
+        cmp dword [eax+4],BYTE 0
+	je endconvert
+	
+	mov ebp,eax
+	
+	mov esi,[ebp+0]
+	mov edi,[ebp+16]
+	
+y_loop:	
+	mov ecx,[ebp+4]
+
+	jmp [ebp+32]
+
+_x86return:	
+	add esi,[ebp+12]
+	add edi,[ebp+28]
+	
+	dec dword  [ebp+8]
+	jnz y_loop
+
+; Restore the registers used by the blitters, necessary for optimized code
+	popa
+	
+	pop ebp
+
+endconvert:	
+	ret		
+
+
+
+;; Hermes_X86_CPU returns the CPUID flags in eax
+	
+_Hermes_X86_CPU:
+	pushfd
+	pop eax
+	
+	mov ecx,eax
+	
+	xor eax,040000h
+	push eax
+	
+	popfd
+	pushfd
+
+	pop eax
+	xor eax,ecx
+	jz .L1			; Processor is 386
+
+	push ecx
+	popfd
+
+	mov eax,ecx
+	xor eax,200000h
+
+	push eax
+	popfd
+	pushfd
+
+	pop eax
+	xor eax,ecx
+	je .L1
+	
+	pusha
+	
+	mov eax,1
+	cpuid
+
+	mov [cpu_flags],edx
+
+	popa
+
+	mov eax,[cpu_flags]
+
+.L1:	
+	ret
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/x86p_16.asm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,496 @@
+;
+; x86 format converters for HERMES
+; Copyright (c) 1998 Glenn Fielder (gaffer@gaffer.org)
+; This source code is licensed under the GNU LGPL
+; 
+; Please refer to the file COPYING.LIB contained in the distribution for
+; licensing conditions		
+; 
+; Routines adjusted for Hermes by Christian Nentwich (brn@eleet.mcb.at)
+; Used with permission.
+; 
+
+	
+BITS 32
+
+GLOBAL _ConvertX86p16_32RGB888
+GLOBAL _ConvertX86p16_32BGR888
+GLOBAL _ConvertX86p16_32RGBA888
+GLOBAL _ConvertX86p16_32BGRA888
+GLOBAL _ConvertX86p16_24RGB888
+GLOBAL _ConvertX86p16_24BGR888
+GLOBAL _ConvertX86p16_16BGR565
+GLOBAL _ConvertX86p16_16RGB555
+GLOBAL _ConvertX86p16_16BGR555
+GLOBAL _ConvertX86p16_8RGB332
+
+EXTERN _ConvertX86
+EXTERN _x86return
+
+
+SECTION .text
+
+
+
+_ConvertX86p16_16BGR565:
+
+    ; check short
+    cmp ecx,BYTE 16
+    ja .L3
+
+
+.L1 ; short loop
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    and ebx,11111100000b
+    shl edx,11
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; head
+    mov eax,edi
+    and eax,BYTE 11b
+    jz .L4
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    and ebx,11111100000b
+    shl edx,11
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+
+.L4 ; save count
+    push ecx
+
+    ; unroll twice
+    shr ecx,1
+    
+    ; point arrays to end
+    lea esi,[esi+ecx*4]
+    lea edi,[edi+ecx*4]
+
+    ; negative counter 
+    neg ecx
+    jmp SHORT .L6
+                              
+.L5     mov [edi+ecx*4-4],eax
+.L6     mov eax,[esi+ecx*4]
+
+        mov ebx,[esi+ecx*4]
+        and eax,07E007E0h         
+
+        mov edx,[esi+ecx*4]
+        and ebx,0F800F800h
+
+        shr ebx,11
+        and edx,001F001Fh
+
+        shl edx,11
+        add eax,ebx
+
+        add eax,edx                 
+        inc ecx
+
+        jnz .L5                 
+         
+    mov [edi+ecx*4-4],eax
+
+    ; tail
+    pop ecx
+    and ecx,BYTE 1
+    jz .L7
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    and ebx,11111100000b
+    shl edx,11
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+
+.L7
+    jmp _x86return
+
+
+
+
+
+
+_ConvertX86p16_16RGB555:
+
+    ; check short
+    cmp ecx,BYTE 32
+    ja .L3
+
+
+.L1 ; short loop
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    shr ebx,1
+    and ebx,     0111111111100000b
+    and eax,BYTE 0000000000011111b
+    add eax,ebx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; head
+    mov eax,edi
+    and eax,BYTE 11b
+    jz .L4
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    shr ebx,1
+    and ebx,     0111111111100000b
+    and eax,BYTE 0000000000011111b
+    add eax,ebx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+
+.L4 ; save ebp
+    push ebp
+
+    ; save count
+    push ecx
+
+    ; unroll four times
+    shr ecx,2
+    
+    ; point arrays to end
+    lea esi,[esi+ecx*8]
+    lea edi,[edi+ecx*8]
+
+    ; negative counter 
+    xor ebp,ebp
+    sub ebp,ecx
+
+.L5     mov eax,[esi+ebp*8]        ; agi?
+        mov ecx,[esi+ebp*8+4]
+       
+        mov ebx,eax
+        mov edx,ecx
+
+        and eax,0FFC0FFC0h
+        and ecx,0FFC0FFC0h
+
+        shr eax,1
+        and ebx,001F001Fh
+
+        shr ecx,1
+        and edx,001F001Fh
+
+        add eax,ebx
+        add ecx,edx
+
+        mov [edi+ebp*8],eax
+        mov [edi+ebp*8+4],ecx
+
+        inc ebp
+        jnz .L5                 
+
+    ; tail
+    pop ecx
+.L6 and ecx,BYTE 11b
+    jz .L7
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    shr ebx,1
+    and ebx,     0111111111100000b
+    and eax,BYTE 0000000000011111b
+    add eax,ebx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+    jmp SHORT .L6
+
+.L7 pop ebp
+    jmp _x86return
+
+
+
+
+
+
+_ConvertX86p16_16BGR555:
+
+    ; check short
+    cmp ecx,BYTE 16
+    ja .L3
+
+	
+.L1 ; short loop
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    shr ebx,1
+    and ebx,1111100000b
+    shl edx,10
+    and edx,0111110000000000b
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; head
+    mov eax,edi
+    and eax,BYTE 11b
+    jz .L4
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    shr ebx,1
+    and ebx,1111100000b
+    shl edx,10
+    and edx,0111110000000000b
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+    dec ecx
+
+.L4 ; save count
+    push ecx
+
+    ; unroll twice
+    shr ecx,1
+    
+    ; point arrays to end
+    lea esi,[esi+ecx*4]
+    lea edi,[edi+ecx*4]
+
+    ; negative counter 
+    neg ecx
+    jmp SHORT .L6
+                              
+.L5     mov [edi+ecx*4-4],eax
+.L6     mov eax,[esi+ecx*4]
+
+        shr eax,1
+        mov ebx,[esi+ecx*4]
+        
+        and eax,03E003E0h         
+        mov edx,[esi+ecx*4]
+
+        and ebx,0F800F800h
+
+        shr ebx,11
+        and edx,001F001Fh
+
+        shl edx,10
+        add eax,ebx
+
+        add eax,edx                 
+        inc ecx
+
+        jnz .L5                 
+         
+    mov [edi+ecx*4-4],eax
+
+    ; tail
+    pop ecx
+    and ecx,BYTE 1
+    jz .L7
+    mov al,[esi]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    shr eax,11
+    and eax,BYTE 11111b
+    shr ebx,1
+    and ebx,1111100000b
+    shl edx,10
+    and edx,0111110000000000b
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    mov [edi+1],ah
+    add esi,BYTE 2
+    add edi,BYTE 2
+
+.L7
+    jmp _x86return
+
+
+
+
+
+
+_ConvertX86p16_8RGB332:
+
+    ; check short
+    cmp ecx,BYTE 16
+    ja .L3
+
+
+.L1 ; short loop
+    mov al,[esi+0]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    and eax,BYTE 11000b         ; blue
+    shr eax,3
+    and ebx,11100000000b        ; green
+    shr ebx,6
+    and edx,1110000000000000b   ; red
+    shr edx,8
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    add esi,BYTE 2
+    inc edi
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 mov eax,edi
+    and eax,BYTE 11b
+    jz .L4
+    mov al,[esi+0]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    and eax,BYTE 11000b         ; blue
+    shr eax,3
+    and ebx,11100000000b        ; green
+    shr ebx,6
+    and edx,1110000000000000b   ; red
+    shr edx,8
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    add esi,BYTE 2
+    inc edi
+    dec ecx
+    jmp SHORT .L3
+
+.L4 ; save ebp
+    push ebp
+
+    ; save count
+    push ecx
+
+    ; unroll 4 times
+    shr ecx,2
+
+    ; prestep
+    mov dl,[esi+0]
+    mov bl,[esi+1]
+    mov dh,[esi+2]
+        
+.L5     shl edx,16
+        mov bh,[esi+3]
+        
+        shl ebx,16
+        mov dl,[esi+4]
+
+        mov dh,[esi+6]
+        mov bl,[esi+5]
+
+        and edx,00011000000110000001100000011000b
+        mov bh,[esi+7]
+
+        ror edx,16+3
+        mov eax,ebx                                     ; setup eax for reds
+
+        and ebx,00000111000001110000011100000111b
+        and eax,11100000111000001110000011100000b       ; reds
+
+        ror ebx,16-2
+        add esi,BYTE 8
+
+        ror eax,16
+        add edi,BYTE 4
+
+        add eax,ebx
+        mov bl,[esi+1]                                  ; greens
+
+        add eax,edx
+        mov dl,[esi+0]                                  ; blues
+
+        mov [edi-4],eax
+        mov dh,[esi+2]
+
+        dec ecx
+        jnz .L5                 
+    
+    ; check tail
+    pop ecx
+    and ecx,BYTE 11b
+    jz .L7
+
+.L6 ; tail
+    mov al,[esi+0]
+    mov ah,[esi+1]
+    mov ebx,eax
+    mov edx,eax
+    and eax,BYTE 11000b         ; blue
+    shr eax,3
+    and ebx,11100000000b        ; green
+    shr ebx,6
+    and edx,1110000000000000b   ; red
+    shr edx,8
+    add eax,ebx
+    add eax,edx
+    mov [edi],al
+    add esi,BYTE 2
+    inc edi
+    dec ecx
+    jnz .L6
+
+.L7 pop ebp
+    jmp _x86return
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/hermes/x86p_32.asm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1043 @@
+;
+; x86 format converters for HERMES
+; Some routines Copyright (c) 1998 Christian Nentwich (brn@eleet.mcb.at)
+; This source code is licensed under the GNU LGPL
+; 
+; Please refer to the file COPYING.LIB contained in the distribution for
+; licensing conditions		
+;
+; Most routines are (c) Glenn Fiedler (ptc@gaffer.org), used with permission
+; 
+
+	
+BITS 32
+
+GLOBAL _ConvertX86p32_32BGR888
+GLOBAL _ConvertX86p32_32RGBA888
+GLOBAL _ConvertX86p32_32BGRA888
+GLOBAL _ConvertX86p32_24RGB888	
+GLOBAL _ConvertX86p32_24BGR888
+GLOBAL _ConvertX86p32_16RGB565
+GLOBAL _ConvertX86p32_16BGR565
+GLOBAL _ConvertX86p32_16RGB555
+GLOBAL _ConvertX86p32_16BGR555
+GLOBAL _ConvertX86p32_8RGB332
+
+EXTERN _x86return
+		
+SECTION .text
+
+
+;; _Convert_*
+;; Paramters:	
+;;   ESI = source 
+;;   EDI = dest
+;;   ECX = amount (NOT 0!!! (the _ConvertX86 routine checks for that though))
+;; Destroys:
+;;   EAX, EBX, EDX
+
+
+_ConvertX86p32_32BGR888:
+
+    ; check short
+    cmp ecx,BYTE 32
+    ja .L3
+
+.L1 ; short loop
+    mov edx,[esi]
+    bswap edx
+    ror edx,8
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; save ebp
+    push ebp
+
+    ; unroll four times
+    mov ebp,ecx
+    shr ebp,2
+    
+    ; save count
+    push ecx
+
+.L4     mov eax,[esi]
+        mov ebx,[esi+4]
+
+        bswap eax
+
+        bswap ebx
+
+        ror eax,8
+        mov ecx,[esi+8]
+
+        ror ebx,8
+        mov edx,[esi+12]
+
+        bswap ecx
+
+        bswap edx
+
+        ror ecx,8
+        mov [edi+0],eax
+
+        ror edx,8
+        mov [edi+4],ebx
+
+        mov [edi+8],ecx
+        mov [edi+12],edx
+
+        add esi,BYTE 16
+        add edi,BYTE 16
+
+        dec ebp
+        jnz .L4                 
+
+    ; check tail
+    pop ecx
+    and ecx,BYTE 11b
+    jz .L6
+
+.L5 ; tail loop
+    mov edx,[esi]
+    bswap edx
+    ror edx,8
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L5
+
+.L6 pop ebp
+    jmp _x86return
+	
+
+	
+		
+_ConvertX86p32_32RGBA888:
+	
+    ; check short
+    cmp ecx,BYTE 32
+    ja .L3
+
+.L1 ; short loop
+    mov edx,[esi]
+    rol edx,8
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; save ebp
+    push ebp
+
+    ; unroll four times
+    mov ebp,ecx
+    shr ebp,2
+    
+    ; save count
+    push ecx
+
+.L4     mov eax,[esi]
+        mov ebx,[esi+4]
+
+        rol eax,8
+        mov ecx,[esi+8]
+
+        rol ebx,8
+        mov edx,[esi+12]
+
+        rol ecx,8
+        mov [edi+0],eax
+
+        rol edx,8
+        mov [edi+4],ebx
+
+        mov [edi+8],ecx
+        mov [edi+12],edx
+
+        add esi,BYTE 16
+        add edi,BYTE 16
+
+        dec ebp
+        jnz .L4                 
+
+    ; check tail
+    pop ecx
+    and ecx,BYTE 11b
+    jz .L6
+
+.L5 ; tail loop
+    mov edx,[esi]
+    rol edx,8
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L5
+
+.L6 pop ebp
+    jmp _x86return
+
+	
+
+
+_ConvertX86p32_32BGRA888:
+
+    ; check short
+    cmp ecx,BYTE 32
+    ja .L3
+
+.L1 ; short loop
+    mov edx,[esi]
+    bswap edx
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L1
+.L2
+    jmp _x86return
+
+.L3 ; save ebp
+    push ebp
+
+    ; unroll four times
+    mov ebp,ecx
+    shr ebp,2
+    
+    ; save count
+    push ecx
+
+.L4     mov eax,[esi]
+        mov ebx,[esi+4]
+
+        mov ecx,[esi+8]
+        mov edx,[esi+12]
+
+        bswap eax
+
+        bswap ebx
+
+        bswap ecx
+
+        bswap edx
+
+        mov [edi+0],eax
+        mov [edi+4],ebx
+
+        mov [edi+8],ecx
+        mov [edi+12],edx
+
+        add esi,BYTE 16
+        add edi,BYTE 16
+
+        dec ebp
+        jnz .L4                 
+
+    ; check tail
+    pop ecx
+    and ecx,BYTE 11b
+    jz .L6
+
+.L5 ; tail loop
+    mov edx,[esi]
+    bswap edx
+    mov [edi],edx
+    add esi,BYTE 4
+    add edi,BYTE 4
+    dec ecx
+    jnz .L5
+
+.L6 pop ebp
+    jmp _x86return
+
+
+	
+	
+;; 32 bit RGB 888 to 24 BIT RGB 888
+
+_ConvertX86p32_24RGB888:
+
+	; check short
+	cmp ecx,BYTE 32
+	ja .L3
+
+.L1	; short loop
+	mov al,[esi]
+	mov bl,[esi+1]
+	mov dl,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jnz .L1
+.L2 
+	jmp _x86return
+
+.L3	;	 head
+	mov edx,edi
+	and edx,BYTE 11b
+	jz .L4
+	mov al,[esi]
+	mov bl,[esi+1]
+	mov dl,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jmp SHORT .L3
+
+.L4 ; unroll 4 times
+	push ebp
+	mov ebp,ecx
+	shr ebp,2
+
+    ; save count
+	push ecx
+
+.L5     mov eax,[esi]                   ; first dword            eax = [A][R][G][B]
+        mov ebx,[esi+4]                 ; second dword           ebx = [a][r][g][b]
+
+        shl eax,8                       ;                        eax = [R][G][B][.]
+        mov ecx,[esi+12]                ; third dword            ecx = [a][r][g][b]
+
+        shl ebx,8                       ;                        ebx = [r][g][b][.]
+        mov al,[esi+4]                  ;                        eax = [R][G][B][b]
+
+        ror eax,8                       ;                        eax = [b][R][G][B] (done)
+        mov bh,[esi+8+1]                ;                        ebx = [r][g][G][.]
+
+        mov [edi],eax
+        add edi,BYTE 3*4
+
+        shl ecx,8                       ;                        ecx = [r][g][b][.]
+        mov bl,[esi+8+0]                ;                        ebx = [r][g][G][B]
+
+        rol ebx,16                      ;                        ebx = [G][B][r][g] (done)
+        mov cl,[esi+8+2]                ;                        ecx = [r][g][b][R] (done)
+
+        mov [edi+4-3*4],ebx
+        add esi,BYTE 4*4
+        
+        mov [edi+8-3*4],ecx
+        dec ebp
+
+        jnz .L5
+
+    ; check tail
+	pop ecx
+	and ecx,BYTE 11b
+	jz .L7
+
+.L6 ; tail loop
+	mov al,[esi]
+	mov bl,[esi+1]
+	mov dl,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jnz .L6
+
+.L7	pop ebp
+	jmp _x86return
+
+
+
+
+;; 32 bit RGB 888 to 24 bit BGR 888
+
+_ConvertX86p32_24BGR888:
+
+	; check short
+	cmp ecx,BYTE 32
+	ja .L3
+
+	
+.L1	; short loop
+	mov dl,[esi]
+	mov bl,[esi+1]
+	mov al,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jnz .L1
+.L2
+	jmp _x86return
+
+.L3 ; head
+	mov edx,edi
+	and edx,BYTE 11b
+	jz .L4
+	mov dl,[esi]
+	mov bl,[esi+1]
+	mov al,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jmp SHORT .L3
+
+.L4	; unroll 4 times
+	push ebp
+	mov ebp,ecx
+	shr ebp,2
+
+	; save count
+	push ecx
+
+.L5     
+	mov eax,[esi]                   ; first dword            eax = [A][R][G][B]
+        mov ebx,[esi+4]                 ; second dword           ebx = [a][r][g][b]
+        
+        bswap eax                       ;                        eax = [B][G][R][A]
+
+        bswap ebx                       ;                        ebx = [b][g][r][a]
+
+        mov al,[esi+4+2]                ;                        eax = [B][G][R][r] 
+        mov bh,[esi+4+4+1]              ;                        ebx = [b][g][G][a]
+
+        ror eax,8                       ;                        eax = [r][B][G][R] (done)
+        mov bl,[esi+4+4+2]              ;                        ebx = [b][g][G][R]
+
+        ror ebx,16                      ;                        ebx = [G][R][b][g] (done)
+        mov [edi],eax
+    
+        mov [edi+4],ebx
+        mov ecx,[esi+12]                ; third dword            ecx = [a][r][g][b]
+        
+        bswap ecx                       ;                        ecx = [b][g][r][a]
+        
+        mov cl,[esi+8]                  ;                        ecx = [b][g][r][B] (done)
+        add esi,BYTE 4*4
+
+        mov [edi+8],ecx
+        add edi,BYTE 3*4
+
+        dec ebp
+        jnz .L5
+
+	; check tail
+	pop ecx
+	and ecx,BYTE 11b
+	jz .L7
+
+.L6	; tail loop
+	mov dl,[esi]
+	mov bl,[esi+1]
+	mov al,[esi+2]
+	mov [edi],al
+	mov [edi+1],bl
+	mov [edi+2],dl
+	add esi,BYTE 4
+	add edi,BYTE 3
+	dec ecx
+	jnz .L6
+
+.L7 
+	pop ebp
+	jmp _x86return
+ 
+
+	
+		
+;; 32 bit RGB 888 to 16 BIT RGB 565 
+
+_ConvertX86p32_16RGB565:
+	; check short
+	cmp ecx,BYTE 16
+	ja .L3
+
+.L1 ; short loop
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+        and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+	jnz .L1
+
+.L2:				; End of short loop
+	jmp _x86return
+
+	
+.L3	; head
+	mov ebx,edi
+	and ebx,BYTE 11b
+	jz .L4
+	
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+	and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+
+.L4:	 
+    ; save count
+	push ecx
+
+    ; unroll twice
+	shr ecx,1
+    
+    ; point arrays to end
+	lea esi,[esi+ecx*8]
+	lea edi,[edi+ecx*4]
+
+    ; negative counter 
+	neg ecx
+	jmp SHORT .L6
+
+.L5:	    
+	mov [edi+ecx*4-4],eax
+.L6:	
+	mov eax,[esi+ecx*8]
+
+        shr ah,2
+        mov ebx,[esi+ecx*8+4]
+
+        shr eax,3
+        mov edx,[esi+ecx*8+4]
+
+        shr bh,2
+        mov dl,[esi+ecx*8+2]
+
+        shl ebx,13
+        and eax,000007FFh
+        
+        shl edx,8
+        and ebx,07FF0000h
+
+        and edx,0F800F800h
+        add eax,ebx
+
+        add eax,edx
+        inc ecx
+
+        jnz .L5                 
+
+	mov [edi+ecx*4-4],eax
+
+    ; tail
+	pop ecx
+	test cl,1
+	jz .L7
+	
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+	and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+
+.L7:	
+	jmp _x86return
+
+
+
+	
+;; 32 bit RGB 888 to 16 BIT BGR 565 
+
+_ConvertX86p32_16BGR565:
+	
+	; check short
+	cmp ecx,BYTE 16
+	ja .L3
+
+.L1	; short loop
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+	jnz .L1
+.L2
+	jmp _x86return
+
+.L3	; head
+	mov ebx,edi
+	and ebx,BYTE 11b
+	jz .L4   
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+
+.L4	; save count
+	push ecx
+
+	; unroll twice
+	shr ecx,1
+    
+	; point arrays to end
+	lea esi,[esi+ecx*8]
+	lea edi,[edi+ecx*4]
+
+	; negative count
+	neg ecx
+	jmp SHORT .L6
+
+.L5     
+	mov [edi+ecx*4-4],eax            
+.L6     
+	mov edx,[esi+ecx*8+4]
+
+        mov bh,[esi+ecx*8+4]                       
+        mov ah,[esi+ecx*8]                       
+
+        shr bh,3
+        mov al,[esi+ecx*8+1]             
+
+        shr ah,3
+        mov bl,[esi+ecx*8+5]           
+
+        shl eax,3
+        mov dl,[esi+ecx*8+2]
+
+        shl ebx,19
+        and eax,0000FFE0h              
+                
+        shr edx,3
+        and ebx,0FFE00000h             
+        
+        and edx,001F001Fh               
+        add eax,ebx
+
+        add eax,edx
+        inc ecx
+
+        jnz .L5                 
+
+	mov [edi+ecx*4-4],eax            
+
+	; tail
+	pop ecx
+	and ecx,BYTE 1
+	jz .L7
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111100b
+	shl eax,3
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+
+.L7 
+	jmp _x86return
+
+
+	
+	
+;; 32 BIT RGB TO 16 BIT RGB 555
+
+_ConvertX86p32_16RGB555:
+
+	; check short
+	cmp ecx,BYTE 16
+	ja .L3
+
+.L1	; short loop
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+	jnz .L1
+.L2
+	jmp _x86return
+
+.L3	; head
+	mov ebx,edi
+        and ebx,BYTE 11b
+	jz .L4   
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+
+.L4	; save count
+	push ecx
+
+	; unroll twice
+	shr ecx,1
+    
+	; point arrays to end
+	lea esi,[esi+ecx*8]
+	lea edi,[edi+ecx*4]
+
+	; negative counter 
+	neg ecx
+	jmp SHORT .L6
+
+.L5     
+	mov [edi+ecx*4-4],eax
+.L6     
+	mov eax,[esi+ecx*8]
+
+        shr ah,3
+        mov ebx,[esi+ecx*8+4]
+
+        shr eax,3
+        mov edx,[esi+ecx*8+4]
+
+        shr bh,3
+        mov dl,[esi+ecx*8+2]
+
+        shl ebx,13
+        and eax,000007FFh
+        
+        shl edx,7
+        and ebx,07FF0000h
+
+        and edx,07C007C00h
+        add eax,ebx
+
+        add eax,edx
+        inc ecx
+
+        jnz .L5                 
+
+	mov [edi+ecx*4-4],eax
+
+	; tail
+	pop ecx
+	and ecx,BYTE 1
+	jz .L7
+	mov bl,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov ah,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+
+.L7
+	jmp _x86return
+
+
+
+
+;; 32 BIT RGB TO 16 BIT BGR 555
+	
+_ConvertX86p32_16BGR555:
+	
+	; check short
+	cmp ecx,BYTE 16
+	ja .L3
+
+
+.L1	; short loop
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+	jnz .L1
+.L2 
+	jmp _x86return
+
+.L3	; head
+	mov ebx,edi
+        and ebx,BYTE 11b
+	jz .L4   
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+	dec ecx
+
+.L4	; save count
+	push ecx
+
+	; unroll twice
+	shr ecx,1
+    
+	; point arrays to end
+	lea esi,[esi+ecx*8]
+	lea edi,[edi+ecx*4]
+
+	; negative counter 
+	neg ecx
+	jmp SHORT .L6
+
+.L5     
+	mov [edi+ecx*4-4],eax            
+.L6     
+	mov edx,[esi+ecx*8+4]
+
+        mov bh,[esi+ecx*8+4]                       
+        mov ah,[esi+ecx*8]                       
+
+        shr bh,3
+        mov al,[esi+ecx*8+1]             
+
+        shr ah,3
+        mov bl,[esi+ecx*8+5]           
+
+        shl eax,2
+        mov dl,[esi+ecx*8+2]
+
+        shl ebx,18
+        and eax,00007FE0h              
+                
+        shr edx,3
+        and ebx,07FE00000h             
+        
+        and edx,001F001Fh               
+        add eax,ebx
+
+        add eax,edx
+        inc ecx
+
+        jnz .L5                 
+
+	mov [edi+ecx*4-4],eax            
+
+	; tail
+	pop ecx
+	and ecx,BYTE 1
+	jz .L7
+	mov ah,[esi+0]    ; blue
+	mov al,[esi+1]    ; green
+	mov bl,[esi+2]    ; red
+	shr ah,3
+	and al,11111000b
+	shl eax,2
+	shr bl,3
+	add al,bl
+	mov [edi+0],al
+	mov [edi+1],ah
+	add esi,BYTE 4
+	add edi,BYTE 2
+
+.L7
+	jmp _x86return
+
+
+
+
+	
+;; FROM 32 BIT RGB to 8 BIT RGB (rrrgggbbb)
+;; This routine writes FOUR pixels at once (dword) and then, if they exist
+;; the trailing three pixels
+_ConvertX86p32_8RGB332:
+
+	
+.L_ALIGNED
+	push ecx
+
+	shr ecx,2		; We will draw 4 pixels at once
+	jnz .L1
+	
+	jmp .L2			; short jump out of range :(
+	
+.L1:
+	mov eax,[esi]		; first pair of pixels
+	mov edx,[esi+4]
+
+	shr dl,6
+	mov ebx,eax
+
+	shr al,6
+	and ah,0e0h
+
+	shr ebx,16
+	and dh,0e0h
+	
+	shr ah,3
+	and bl,0e0h
+
+	shr dh,3
+	
+	or al,bl
+	
+	mov ebx,edx	
+	or al,ah
+	
+	shr ebx,16
+	or dl,dh
+
+	and bl,0e0h
+	
+	or dl,bl
+
+	mov ah,dl
+
+	
+		
+	mov ebx,[esi+8]		; second pair of pixels
+
+	mov edx,ebx
+	and bh,0e0h
+
+	shr bl,6
+	and edx,0e00000h
+
+	shr edx,16
+
+	shr bh,3
+
+	ror eax,16
+	or bl,dl
+
+	mov edx,[esi+12]
+	or bl,bh
+	
+	mov al,bl
+
+	mov ebx,edx
+	and dh,0e0h
+
+	shr dl,6
+	and ebx,0e00000h
+	
+	shr dh,3
+	mov ah,dl
+
+	shr ebx,16
+	or ah,dh
+
+	or ah,bl
+
+	rol eax,16
+	add esi,BYTE 16
+			
+	mov [edi],eax	
+	add edi,BYTE 4
+	
+	dec ecx
+	jz .L2			; L1 out of range for short jump :(
+	
+	jmp .L1
+.L2:
+	
+	pop ecx
+	and ecx,BYTE 3		; mask out number of pixels to draw
+	
+	jz .L4			; Nothing to do anymore
+
+.L3:
+	mov eax,[esi]		; single pixel conversion for trailing pixels
+
+        mov ebx,eax
+
+        shr al,6
+        and ah,0e0h
+
+        shr ebx,16
+
+        shr ah,3
+        and bl,0e0h
+
+        or al,ah
+        or al,bl
+
+        mov [edi],al
+
+        inc edi
+        add esi,BYTE 4
+
+	dec ecx
+	jnz .L3
+	
+.L4:	
+	jmp _x86return
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+
+## Makefile.am for the SDL joystick library
+
+noinst_LTLIBRARIES = libjoystick.la
+
+# Define which subdirectories need to be built
+SUBDIRS = @JOYSTICK_SUBDIRS@
+DIST_SUBDIRS = dummy beos linux macos win32
+
+DRIVERS = @JOYSTICK_DRIVERS@
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_joystick.c		\
+	SDL_joystick_c.h	\
+	SDL_sysjoystick.h
+
+libjoystick_la_SOURCES = $(COMMON_SRCS)
+libjoystick_la_LIBADD = $(DRIVERS)
+libjoystick_la_DEPENDENCIES = $(DRIVERS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/SDL_joystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,582 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the joystick API for Simple DirectMedia Layer */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_events.h"
+#ifndef DISABLE_EVENTS
+#include "SDL_events_c.h"
+#endif
+#include "SDL_joystick_c.h"
+#include "SDL_sysjoystick.h"
+
+/* This is used for Quake III Arena */
+#ifdef DISABLE_EVENTS
+#define SDL_Lock_EventThread()
+#define SDL_Unlock_EventThread()
+#endif
+
+Uint8 SDL_numjoysticks = 0;
+SDL_Joystick **SDL_joysticks = NULL;
+static SDL_Joystick *default_joystick = NULL;
+
+int SDL_JoystickInit(void)
+{
+	int arraylen;
+	int status;
+
+	SDL_numjoysticks = 0;
+	status = SDL_SYS_JoystickInit();
+	if ( status >= 0 ) {
+		arraylen = (status+1)*sizeof(*SDL_joysticks);
+		SDL_joysticks = (SDL_Joystick **)malloc(arraylen);
+		if ( SDL_joysticks == NULL ) {
+			SDL_numjoysticks = 0;
+		} else {
+			memset(SDL_joysticks, 0, arraylen);
+		}
+		SDL_numjoysticks = status;
+		status = 0;
+	}
+	default_joystick = NULL;
+	return(status);
+}
+
+/*
+ * Count the number of joysticks attached to the system
+ */
+int SDL_NumJoysticks(void)
+{
+	return SDL_numjoysticks;
+}
+
+/*
+ * Get the implementation dependent name of a joystick
+ */
+const char *SDL_JoystickName(int device_index)
+{
+	if ( (device_index < 0) || (device_index >= SDL_numjoysticks) ) {
+		SDL_SetError("There are %d joysticks available",
+		             SDL_numjoysticks);
+		return(NULL);
+	}
+	return(SDL_SYS_JoystickName(device_index));
+}
+
+/*
+ * Open a joystick for use - the index passed as an argument refers to
+ * the N'th joystick on the system.  This index is the value which will
+ * identify this joystick in future joystick events.
+ *
+ * This function returns a joystick identifier, or NULL if an error occurred.
+ */
+SDL_Joystick *SDL_JoystickOpen(int device_index)
+{
+	int i;
+	SDL_Joystick *joystick;
+
+	if ( (device_index < 0) || (device_index >= SDL_numjoysticks) ) {
+		SDL_SetError("There are %d joysticks available",
+		             SDL_numjoysticks);
+		return(NULL);
+	}
+
+	/* If the joystick is already open, return it */
+	for ( i=0; SDL_joysticks[i]; ++i ) {
+		if ( device_index == SDL_joysticks[i]->index ) {
+			joystick = SDL_joysticks[i];
+			++joystick->ref_count;
+			return(joystick);
+		}
+	}
+
+	/* Create and initialize the joystick */
+	joystick = (SDL_Joystick *)malloc((sizeof *joystick));
+	if ( joystick != NULL ) {
+		memset(joystick, 0, (sizeof *joystick));
+		joystick->index = device_index;
+		if ( SDL_SYS_JoystickOpen(joystick) < 0 ) {
+			free(joystick);
+			joystick = NULL;
+		} else {
+			if ( joystick->naxes > 0 ) {
+				joystick->axes = (Sint16 *)malloc
+					(joystick->naxes*sizeof(Sint16));
+			}
+			if ( joystick->nhats > 0 ) {
+				joystick->hats = (Uint8 *)malloc
+					(joystick->nhats*sizeof(Uint8));
+			}
+			if ( joystick->nballs > 0 ) {
+				joystick->balls = (struct balldelta *)malloc
+				  (joystick->nballs*sizeof(*joystick->balls));
+			}
+			if ( joystick->nbuttons > 0 ) {
+				joystick->buttons = (Uint8 *)malloc
+					(joystick->nbuttons*sizeof(Uint8));
+			}
+			if ( ((joystick->naxes > 0) && !joystick->axes)
+			  || ((joystick->nhats > 0) && !joystick->hats)
+			  || ((joystick->nballs > 0) && !joystick->balls)
+			  || ((joystick->nbuttons > 0) && !joystick->buttons)) {
+				SDL_OutOfMemory();
+				SDL_JoystickClose(joystick);
+				joystick = NULL;
+			}
+			if ( joystick->axes ) {
+				memset(joystick->axes, 0,
+					joystick->naxes*sizeof(Sint16));
+			}
+			if ( joystick->hats ) {
+				memset(joystick->hats, 0,
+					joystick->nhats*sizeof(Uint8));
+			}
+			if ( joystick->balls ) {
+				memset(joystick->balls, 0,
+				  joystick->nballs*sizeof(*joystick->balls));
+			}
+			if ( joystick->buttons ) {
+				memset(joystick->buttons, 0,
+					joystick->nbuttons*sizeof(Uint8));
+			}
+		}
+	}
+	if ( joystick ) {
+		/* Add joystick to list */
+		++joystick->ref_count;
+		SDL_Lock_EventThread();
+		for ( i=0; SDL_joysticks[i]; ++i )
+			/* Skip to next joystick */;
+		SDL_joysticks[i] = joystick;
+		SDL_Unlock_EventThread();
+	}
+	return(joystick);
+}
+
+/*
+ * Returns 1 if the joystick has been opened, or 0 if it has not.
+ */
+int SDL_JoystickOpened(int device_index)
+{
+	int i, opened;
+
+	opened = 0;
+	for ( i=0; SDL_joysticks[i]; ++i ) {
+		if ( SDL_joysticks[i]->index == (Uint8)device_index ) {
+			opened = 1;
+			break;
+		}
+	}
+	return(opened);
+}
+
+static int ValidJoystick(SDL_Joystick **joystick)
+{
+	int valid;
+
+	if ( *joystick == NULL ) {
+		*joystick = default_joystick;
+	}
+	if ( *joystick == NULL ) {
+		SDL_SetError("Joystick hasn't been opened yet");
+		valid = 0;
+	} else {
+		valid = 1;
+	}
+	return valid;
+}
+
+/*
+ * Get the device index of an opened joystick.
+ */
+int SDL_JoystickIndex(SDL_Joystick *joystick)
+{
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+	return(joystick->index);
+}
+
+/*
+ * Get the number of multi-dimensional axis controls on a joystick
+ */
+int SDL_JoystickNumAxes(SDL_Joystick *joystick)
+{
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+	return(joystick->naxes);
+}
+
+/*
+ * Get the number of hats on a joystick
+ */
+int SDL_JoystickNumHats(SDL_Joystick *joystick)
+{
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+	return(joystick->nhats);
+}
+
+/*
+ * Get the number of trackballs on a joystick
+ */
+int SDL_JoystickNumBalls(SDL_Joystick *joystick)
+{
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+	return(joystick->nballs);
+}
+
+/*
+ * Get the number of buttons on a joystick
+ */
+int SDL_JoystickNumButtons(SDL_Joystick *joystick)
+{
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+	return(joystick->nbuttons);
+}
+
+/*
+ * Get the current state of an axis control on a joystick
+ */
+Sint16 SDL_JoystickGetAxis(SDL_Joystick *joystick, int axis)
+{
+	Sint16 state;
+
+	if ( ! ValidJoystick(&joystick) ) {
+		return(0);
+	}
+	if ( axis < joystick->naxes ) {
+		state = joystick->axes[axis];
+	} else {
+		SDL_SetError("Joystick only has %d axes", joystick->naxes);
+		state = 0;
+	}
+	return(state);
+}
+
+/*
+ * Get the current state of a hat on a joystick
+ */
+Uint8 SDL_JoystickGetHat(SDL_Joystick *joystick, int hat)
+{
+	Uint8 state;
+
+	if ( ! ValidJoystick(&joystick) ) {
+		return(0);
+	}
+	if ( hat < joystick->nhats ) {
+		state = joystick->hats[hat];
+	} else {
+		SDL_SetError("Joystick only has %d hats", joystick->nhats);
+		state = 0;
+	}
+	return(state);
+}
+
+/*
+ * Get the ball axis change since the last poll
+ */
+int SDL_JoystickGetBall(SDL_Joystick *joystick, int ball, int *dx, int *dy)
+{
+	int retval;
+
+	if ( ! ValidJoystick(&joystick) ) {
+		return(-1);
+	}
+
+	retval = 0;
+	if ( ball < joystick->nballs ) {
+		if ( dx ) {
+			*dx = joystick->balls[ball].dx;
+		}
+		if ( dy ) {
+			*dy = joystick->balls[ball].dy;
+		}
+		joystick->balls[ball].dx = 0;
+		joystick->balls[ball].dy = 0;
+	} else {
+		SDL_SetError("Joystick only has %d balls", joystick->nballs);
+		retval = -1;
+	}
+	return(retval);
+}
+
+/*
+ * Get the current state of a button on a joystick
+ */
+Uint8 SDL_JoystickGetButton(SDL_Joystick *joystick, int button)
+{
+	Uint8 state;
+
+	if ( ! ValidJoystick(&joystick) ) {
+		return(0);
+	}
+	if ( button < joystick->nbuttons ) {
+		state = joystick->buttons[button];
+	} else {
+		SDL_SetError("Joystick only has %d buttons",joystick->nbuttons);
+		state = 0;
+	}
+	return(state);
+}
+
+/*
+ * Close a joystick previously opened with SDL_JoystickOpen()
+ */
+void SDL_JoystickClose(SDL_Joystick *joystick)
+{
+	int i;
+
+	if ( ! ValidJoystick(&joystick) ) {
+		return;
+	}
+
+	/* First decrement ref count */
+	if ( --joystick->ref_count > 0 ) {
+		return;
+	}
+
+	/* Lock the event queue - prevent joystick polling */
+	SDL_Lock_EventThread();
+
+	if ( joystick == default_joystick ) {
+		default_joystick = NULL;
+	}
+	SDL_SYS_JoystickClose(joystick);
+
+	/* Remove joystick from list */
+	for ( i=0; SDL_joysticks[i]; ++i ) {
+		if ( joystick == SDL_joysticks[i] ) {
+			memcpy(&SDL_joysticks[i], &SDL_joysticks[i+1],
+			       (SDL_numjoysticks-i)*sizeof(joystick));
+			break;
+		}
+	}
+
+	/* Let the event thread keep running */
+	SDL_Unlock_EventThread();
+
+	/* Free the data associated with this joystick */
+	if ( joystick->axes ) {
+		free(joystick->axes);
+	}
+	if ( joystick->hats ) {
+		free(joystick->hats);
+	}
+	if ( joystick->balls ) {
+		free(joystick->balls);
+	}
+	if ( joystick->buttons ) {
+		free(joystick->buttons);
+	}
+	free(joystick);
+}
+
+void SDL_JoystickQuit(void)
+{
+	/* Stop the event polling */
+	SDL_Lock_EventThread();
+	SDL_numjoysticks = 0;
+	SDL_Unlock_EventThread();
+
+	/* Quit the joystick setup */
+	SDL_SYS_JoystickQuit();
+	if ( SDL_joysticks ) {
+		free(SDL_joysticks);
+		SDL_joysticks = NULL;
+	}
+}
+
+
+/* These are global for SDL_sysjoystick.c and SDL_events.c */
+
+int SDL_PrivateJoystickAxis(SDL_Joystick *joystick, Uint8 axis, Sint16 value)
+{
+	int posted;
+
+	/* Update internal joystick state */
+	joystick->axes[axis] = value;
+
+	/* Post the event, if desired */
+	posted = 0;
+#ifndef DISABLE_EVENTS
+	if ( SDL_ProcessEvents[SDL_JOYAXISMOTION] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.type = SDL_JOYAXISMOTION;
+		event.jaxis.which = joystick->index;
+		event.jaxis.axis = axis;
+		event.jaxis.value = value;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+#endif /* !DISABLE_EVENTS */
+	return(posted);
+}
+
+int SDL_PrivateJoystickHat(SDL_Joystick *joystick, Uint8 hat, Uint8 value)
+{
+	int posted;
+
+	/* Update internal joystick state */
+	joystick->hats[hat] = value;
+
+	/* Post the event, if desired */
+	posted = 0;
+#ifndef DISABLE_EVENTS
+	if ( SDL_ProcessEvents[SDL_JOYHATMOTION] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.jhat.type = SDL_JOYHATMOTION;
+		event.jhat.which = joystick->index;
+		event.jhat.hat = hat;
+		event.jhat.value = value;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+#endif /* !DISABLE_EVENTS */
+	return(posted);
+}
+
+int SDL_PrivateJoystickBall(SDL_Joystick *joystick, Uint8 ball,
+					Sint16 xrel, Sint16 yrel)
+{
+	int posted;
+
+	/* Update internal mouse state */
+	joystick->balls[ball].dx += xrel;
+	joystick->balls[ball].dy += yrel;
+
+	/* Post the event, if desired */
+	posted = 0;
+#ifndef DISABLE_EVENTS
+	if ( SDL_ProcessEvents[SDL_JOYBALLMOTION] == SDL_ENABLE ) {
+		SDL_Event event;
+		event.jball.type = SDL_JOYBALLMOTION;
+		event.jball.which = joystick->index;
+		event.jball.ball = ball;
+		event.jball.xrel = xrel;
+		event.jball.yrel = yrel;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+#endif /* !DISABLE_EVENTS */
+	return(posted);
+}
+
+int SDL_PrivateJoystickButton(SDL_Joystick *joystick, Uint8 button, Uint8 state)
+{
+	int posted;
+#ifndef DISABLE_EVENTS
+	SDL_Event event;
+
+	switch ( state ) {
+		case SDL_PRESSED:
+			event.type = SDL_JOYBUTTONDOWN;
+			break;
+		case SDL_RELEASED:
+			event.type = SDL_JOYBUTTONUP;
+			break;
+		default:
+			/* Invalid state -- bail */
+			return(0);
+	}
+#endif /* !DISABLE_EVENTS */
+
+	/* Update internal joystick state */
+	joystick->buttons[button] = state;
+
+	/* Post the event, if desired */
+	posted = 0;
+#ifndef DISABLE_EVENTS
+	if ( SDL_ProcessEvents[event.type] == SDL_ENABLE ) {
+		event.jbutton.which = joystick->index;
+		event.jbutton.button = button;
+		event.jbutton.state = state;
+		if ( (SDL_EventOK == NULL) || (*SDL_EventOK)(&event) ) {
+			posted = 1;
+			SDL_PushEvent(&event);
+		}
+	}
+#endif /* !DISABLE_EVENTS */
+	return(posted);
+}
+
+void SDL_JoystickUpdate(void)
+{
+	int i;
+
+	for ( i=0; SDL_joysticks[i]; ++i ) {
+		SDL_SYS_JoystickUpdate(SDL_joysticks[i]);
+	}
+}
+
+int SDL_JoystickEventState(int state)
+{
+#ifdef DISABLE_EVENTS
+	return SDL_IGNORE;
+#else
+	const Uint8 event_list[] = {
+		SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
+		SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP,
+	};
+	int i;
+
+	switch (state) {
+		case SDL_QUERY:
+			state = SDL_IGNORE;
+			for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) {
+				state = SDL_EventState(event_list[i],SDL_QUERY);
+				if ( state == SDL_ENABLE ) {
+					break;
+				}
+			}
+			break;
+		default:
+			for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) {
+				SDL_EventState(event_list[i], state);
+			}
+			break;
+	}
+	return(state);
+#endif /* DISABLE_EVENTS */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/SDL_joystick_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful functions and variables from SDL_joystick.c */
+#include "SDL_joystick.h"
+
+/* The number of available joysticks on the system */
+extern Uint8 SDL_numjoysticks;
+
+/* Internal event queueing functions */
+extern int SDL_PrivateJoystickAxis(SDL_Joystick *joystick,
+                                   Uint8 axis, Sint16 value);
+extern int SDL_PrivateJoystickBall(SDL_Joystick *joystick,
+                                   Uint8 ball, Sint16 xrel, Sint16 yrel);
+extern int SDL_PrivateJoystickHat(SDL_Joystick *joystick,
+                                 Uint8 hat, Uint8 value);
+extern int SDL_PrivateJoystickButton(SDL_Joystick *joystick,
+                                     Uint8 button, Uint8 state);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/SDL_sysjoystick.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,86 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the system specific header for the SDL joystick API */
+
+#include "SDL_joystick.h"
+
+/* The SDL joystick structure */
+struct _SDL_Joystick {
+	Uint8 index;		/* Device index */
+	const char *name;	/* Joystick name - system dependent */
+
+	int naxes;		/* Number of axis controls on the joystick */
+	Sint16 *axes;		/* Current axis states */
+
+	int nhats;		/* Number of hats on the joystick */
+	Uint8 *hats;		/* Current hat states */
+	
+	int nballs;		/* Number of trackballs on the joystick */
+	struct balldelta {
+		int dx;
+		int dy;
+	} *balls;		/* Current ball motion deltas */
+	
+	int nbuttons;		/* Number of buttons on the joystick */
+	Uint8 *buttons;		/* Current button states */
+	
+	struct joystick_hwdata *hwdata;	/* Driver dependent information */
+
+	int ref_count;		/* Reference count for multiple opens */
+};
+
+/* Function to scan the system for joysticks.
+ * Joystick 0 should be the system default joystick.
+ * This function should return the number of available joysticks, or -1
+ * on an unrecoverable fatal error.
+ */
+extern int SDL_SYS_JoystickInit(void);
+
+/* Function to get the device-dependent name of a joystick */
+extern const char *SDL_SYS_JoystickName(int index);
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+extern int SDL_SYS_JoystickOpen(SDL_Joystick *joystick);
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+extern void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick);
+
+/* Function to close a joystick after use */
+extern void SDL_SYS_JoystickClose(SDL_Joystick *joystick);
+
+/* Function to perform any system-specific joystick related cleanup */
+extern void SDL_SYS_JoystickQuit(void);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/beos/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/beos/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the BeOS joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_beos.la
+libjoystick_beos_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS =  SDL_bejoystick.cc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/beos/SDL_bejoystick.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,242 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the system specific header for the SDL joystick API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <be/support/String.h>
+#include <be/device/Joystick.h>
+
+extern "C" {
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+
+/* The maximum number of joysticks we'll detect */
+#define MAX_JOYSTICKS	16	
+
+/* A list of available joysticks */
+static char *SDL_joyport[MAX_JOYSTICKS];
+static char *SDL_joyname[MAX_JOYSTICKS];
+
+/* The private structure used to keep track of a joystick */
+struct joystick_hwdata {
+	BJoystick *stick;
+	uint8 *new_hats;
+	int16 *new_axes;
+};
+
+/* Function to scan the system for joysticks.
+ * This function should set SDL_numjoysticks to the number of available
+ * joysticks.  Joystick 0 should be the system default joystick.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int SDL_SYS_JoystickInit(void)
+{
+	BJoystick joystick;
+	int numjoysticks;
+	int i;
+	int32 nports;
+	char name[B_OS_NAME_LENGTH];
+	
+	/* Search for attached joysticks */
+	nports = joystick.CountDevices();
+	numjoysticks = 0;
+	memset(SDL_joyport, 0, (sizeof SDL_joyport));
+	memset(SDL_joyname, 0, (sizeof SDL_joyname));
+	for ( i=0; (SDL_numjoysticks < MAX_JOYSTICKS) && (i < nports); ++i ) {
+		if ( joystick.GetDeviceName(i, name) == B_OK ) {
+			if ( joystick.Open(name) != B_ERROR ) {
+				BString stick_name;
+				joystick.GetControllerName(&stick_name);
+				SDL_joyport[numjoysticks] = strdup(name);
+				SDL_joyname[numjoysticks] =
+					           strdup(stick_name.String());
+				numjoysticks++;
+				joystick.Close();
+			}
+		}
+	}
+	return(numjoysticks);
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *SDL_SYS_JoystickName(int index)
+{
+	return SDL_joyname[index];
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+{
+	BJoystick *stick;
+
+	/* Create the joystick data structure */
+	joystick->hwdata = (struct joystick_hwdata *)
+	                   malloc(sizeof(*joystick->hwdata));
+	if ( joystick->hwdata == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+	stick = new BJoystick;
+	joystick->hwdata->stick = stick;
+
+	/* Open the requested joystick for use */
+	if ( stick->Open(SDL_joyport[joystick->index]) == B_ERROR ) {
+		SDL_SetError("Unable to open joystick");
+		SDL_SYS_JoystickClose(joystick);
+		return(-1);
+	}
+
+	/* Set the joystick to calibrated mode */
+	stick->EnableCalibration();
+
+	/* Get the number of buttons, hats, and axes on the joystick */
+	joystick->nbuttons = stick->CountButtons();
+	joystick->naxes = stick->CountAxes();
+	joystick->nhats = stick->CountHats();
+
+	joystick->hwdata->new_axes = (int16 *)
+	                  malloc(joystick->naxes*sizeof(int16));
+	joystick->hwdata->new_hats = (uint8 *)
+	                  malloc(joystick->nhats*sizeof(uint8));
+	if ( ! joystick->hwdata->new_hats || ! joystick->hwdata->new_axes ) {
+		SDL_OutOfMemory();
+		SDL_SYS_JoystickClose(joystick);
+		return(-1);
+	}
+
+	/* We're done! */
+	return(0);
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+{
+	static const Uint8 hat_map[9] = {
+             SDL_HAT_CENTERED,
+             SDL_HAT_UP,
+             SDL_HAT_RIGHTUP,
+             SDL_HAT_RIGHT,
+             SDL_HAT_RIGHTDOWN,
+             SDL_HAT_DOWN,
+             SDL_HAT_LEFTDOWN,
+             SDL_HAT_LEFT,
+             SDL_HAT_LEFTUP
+	};
+	const int JITTER = (32768/10);	/* 10% jitter threshold (ok?) */
+
+	BJoystick *stick;
+	int i, change;
+	int16 *axes;
+	uint8 *hats;
+	uint32 buttons;
+
+	/* Set up data pointers */
+	stick = joystick->hwdata->stick;
+	axes = joystick->hwdata->new_axes;
+	hats = joystick->hwdata->new_hats;
+
+	/* Get the new joystick state */
+	stick->Update();
+	stick->GetAxisValues(axes);
+	stick->GetHatValues(hats);
+	buttons = stick->ButtonValues();
+
+	/* Generate axis motion events */
+	for ( i=0; i<joystick->naxes; ++i ) {
+		change = ((int32)axes[i] - joystick->axes[i]);
+		if ( (change > JITTER) || (change < -JITTER) ) {
+			SDL_PrivateJoystickAxis(joystick, i, axes[i]);
+		}
+	}
+
+	/* Generate hat change events */
+	for ( i=0; i<joystick->nhats; ++i ) {
+		if ( hats[i] != joystick->hats[i] ) {
+			SDL_PrivateJoystickHat(joystick, i, hat_map[hats[i]]);
+		}
+	}
+
+	/* Generate button events */
+	for ( i=0; i<joystick->nbuttons; ++i ) {
+		if ( (buttons&0x01) != joystick->buttons[i] ) {
+			SDL_PrivateJoystickButton(joystick, i, (buttons&0x01));
+		}
+		buttons >>= 1;
+	}
+}
+
+/* Function to close a joystick after use */
+void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+{
+	if ( joystick->hwdata ) {
+		joystick->hwdata->stick->Close();
+		delete joystick->hwdata->stick;
+		if ( joystick->hwdata->new_hats ) {
+			free(joystick->hwdata->new_hats);
+		}
+		if ( joystick->hwdata->new_axes ) {
+			free(joystick->hwdata->new_axes);
+		}
+		free(joystick->hwdata);
+		joystick->hwdata = NULL;
+	}
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void SDL_SYS_JoystickQuit(void)
+{
+	int i;
+
+	for ( i=0; SDL_joyport[i]; ++i ) {
+		free(SDL_joyport[i]);
+	}
+	SDL_joyport[0] = NULL;
+
+	for ( i=0; SDL_joyname[i]; ++i ) {
+		free(SDL_joyname[i]);
+	}
+	SDL_joyname[0] = NULL;
+}
+
+}; // extern "C"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/dummy/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/dummy/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the dummy joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_dummy.la
+libjoystick_dummy_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS =  SDL_sysjoystick.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/dummy/SDL_sysjoystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,87 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the system specific header for the SDL joystick API */
+
+#include <stdio.h>		/* For the definition of NULL */
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+/* Function to scan the system for joysticks.
+ * This function should set SDL_numjoysticks to the number of available
+ * joysticks.  Joystick 0 should be the system default joystick.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int SDL_SYS_JoystickInit(void)
+{
+	SDL_numjoysticks = 0;
+	return(0);
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *SDL_SYS_JoystickName(int index)
+{
+	SDL_SetError("Logic error: No joysticks available");
+	return(NULL);
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+{
+	SDL_SetError("Logic error: No joysticks available");
+	return(-1);
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+{
+	return;
+}
+
+/* Function to close a joystick after use */
+void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+{
+	return;
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void SDL_SYS_JoystickQuit(void)
+{
+	return;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/linux/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/linux/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the Linux joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_linux.la
+libjoystick_linux_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS =  SDL_sysjoystick.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/linux/SDL_sysjoystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,742 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the system specific header for the SDL joystick API */
+
+#include <stdio.h>		/* For the definition of NULL */
+#include <stdlib.h>		/* For getenv() prototype */
+#include <string.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <limits.h>		/* For the definition of PATH_MAX */
+
+#include <linux/joystick.h>
+#ifdef USE_INPUT_EVENTS
+#include <linux/input.h>
+#endif
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+/* Define this if you want to map axes to hats and trackballs */
+#define FANCY_HATS_AND_BALLS
+
+#ifdef FANCY_HATS_AND_BALLS
+/* Special joystick configurations:
+	'JoystickName' Naxes Nhats Nballs
+ */
+static const char *special_joysticks[] = {
+	"'MadCatz Panther XL' 3 2 1", /* We don't handle a rudder (axis 8) */
+	"'SideWinder Precision Pro' 4 1 0",
+	"'SideWinder 3D Pro' 4 1 0",
+	"'Microsoft SideWinder 3D Pro' 4 1 0",
+	"'Microsoft SideWinder Dual Strike USB version 1.0' 2 1 0",
+	"'WingMan Interceptor' 3 3 0",
+	/* WingMan Extreme Analog - not recognized by default
+	"'Analog 3-axis 4-button joystick' 2 1",
+	*/
+	"'WingMan Extreme Digital 3D' 4 1 0",
+	NULL
+};
+#else
+#undef USE_INPUT_EVENTS
+#endif
+
+/* The maximum number of joysticks we'll detect */
+#define MAX_JOYSTICKS	32
+
+/* A list of available joysticks */
+static char *SDL_joylist[MAX_JOYSTICKS];
+
+/* The private structure used to keep track of a joystick */
+struct joystick_hwdata {
+	int fd;
+	/* The current linux joystick driver maps hats to two axes */
+	int analog_hat;		/* Well, except for analog hats */
+	struct hwdata_hat {
+		int axis[2];
+	} *hats;
+	/* The current linux joystick driver maps balls to two axes */
+	struct hwdata_ball {
+		int axis[2];
+	} *balls;
+
+	/* Support for the Linux 2.4 unified input interface */
+	SDL_bool is_hid;
+#ifdef USE_INPUT_EVENTS
+	Uint8 key_map[KEY_MAX-BTN_MISC];
+	Uint8 abs_map[ABS_MAX];
+	struct axis_correct {
+		int used;
+		int coef[3];
+	} abs_correct[ABS_MAX];
+#endif
+};
+
+static char *mystrdup(const char *string)
+{
+	char *newstring;
+
+	newstring = (char *)malloc(strlen(string)+1);
+	if ( newstring ) {
+		strcpy(newstring, string);
+	}
+	return(newstring);
+}
+
+#ifdef USE_INPUT_EVENTS
+#define test_bit(nr, addr) \
+	(((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
+
+static int EV_IsJoystick(int fd)
+{
+	unsigned long evbit[40];
+	unsigned long keybit[40];
+	unsigned long absbit[40];
+
+	if ( (ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
+	     (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
+	     (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0) ) {
+		return(0);
+	}
+	if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
+	      test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) &&
+	     (test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_A, keybit) || test_bit(BTN_1, keybit)))) return 0;
+	return(1);
+}
+
+#endif /* USE_INPUT_EVENTS */
+
+/* Function to scan the system for joysticks */
+int SDL_SYS_JoystickInit(void)
+{
+	/* The base path of the joystick devices */
+	const char *joydev_pattern[2] = {
+		"/dev/js%d",
+#ifdef USE_INPUT_EVENTS
+		"/dev/input/event%d"
+#else
+		"/dev/input/js%d"
+#endif
+	};
+	int numjoysticks;
+	int i, j, done;
+	int fd;
+	char path[PATH_MAX];
+	dev_t dev_nums[MAX_JOYSTICKS];  /* major/minor device numbers */
+	struct stat sb;
+	int n, duplicate;
+
+	numjoysticks = 0;
+
+	/* First see if the user specified a joystick to use */
+	if ( getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
+		strncpy(path, getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
+		path[sizeof(path)-1] = '\0';
+		if ( stat(path, &sb) == 0 ) {
+			fd = open(path, O_RDONLY, 0);
+			if ( fd >= 0 ) {
+				/* Assume the user knows what they're doing. */
+				SDL_joylist[numjoysticks] = mystrdup(path);
+				if ( SDL_joylist[numjoysticks] ) {
+					dev_nums[numjoysticks] = sb.st_rdev;
+					++numjoysticks;
+				}
+				close(fd);
+			}
+		}
+	}
+	for ( i=0; i<SDL_TABLESIZE(joydev_pattern); ++i ) {
+		done = 0;
+		for ( j=0; (j < MAX_JOYSTICKS) && !done; ++j ) {
+			sprintf(path, joydev_pattern[i], j);
+
+			/* rcg06302000 replaced access(F_OK) call with stat().
+			 * stat() will fail if the file doesn't exist, so it's
+			 * equivalent behaviour.
+			 */
+			if ( stat(path, &sb) == 0 ) {
+				/* Check to make sure it's not already in list.
+				 * This happens when we see a stick via symlink.
+				 */
+				duplicate = 0;
+				for (n=0; (n<numjoysticks) && !duplicate; ++n) {
+					if ( sb.st_rdev == dev_nums[n] ) {
+						duplicate = 1;
+					}
+				}
+				if (duplicate) {
+					continue;
+				}
+
+				fd = open(path, O_RDONLY, 0);
+				if ( fd < 0 ) {
+					continue;
+				}
+#ifdef USE_INPUT_EVENTS
+#ifdef DEBUG_INPUT_EVENTS
+				printf("Checking %s\n", path);
+#endif
+				if ( (i > 0) && ! EV_IsJoystick(fd) ) {
+					close(fd);
+					continue;
+				}
+#endif
+				close(fd);
+
+				/* We're fine, add this joystick */
+				SDL_joylist[numjoysticks] = mystrdup(path);
+				if ( SDL_joylist[numjoysticks] ) {
+					dev_nums[numjoysticks] = sb.st_rdev;
+					++numjoysticks;
+				}
+			} else {
+				done = 1;
+			}
+		}
+	}
+	return(numjoysticks);
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *SDL_SYS_JoystickName(int index)
+{
+	int fd;
+	static char namebuf[128];
+	char *name;
+
+	name = NULL;
+	fd = open(SDL_joylist[index], O_RDONLY, 0);
+	if ( fd >= 0 ) {
+		if ( 
+#ifdef USE_INPUT_EVENTS
+		     (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) &&
+#endif
+		     (ioctl(fd, JSIOCGNAME(sizeof(namebuf)), namebuf) <= 0) ) {
+			name = SDL_joylist[index];
+		} else {
+			name = namebuf;
+		}
+		close(fd);
+	}
+	return name;
+}
+
+#ifdef FANCY_HATS_AND_BALLS
+
+static int allocate_hatdata(SDL_Joystick *joystick)
+{
+	int i;
+
+	joystick->hwdata->hats = (struct hwdata_hat *)malloc(
+		joystick->nhats * sizeof(struct hwdata_hat));
+	if ( joystick->hwdata->hats == NULL ) {
+		return(-1);
+	}
+	for ( i=0; i<joystick->nhats; ++i ) {
+		joystick->hwdata->hats[i].axis[0] = 1;
+		joystick->hwdata->hats[i].axis[1] = 1;
+	}
+	return(0);
+}
+
+static int allocate_balldata(SDL_Joystick *joystick)
+{
+	int i;
+
+	joystick->hwdata->balls = (struct hwdata_ball *)malloc(
+		joystick->nballs * sizeof(struct hwdata_ball));
+	if ( joystick->hwdata->balls == NULL ) {
+		return(-1);
+	}
+	for ( i=0; i<joystick->nballs; ++i ) {
+		joystick->hwdata->balls[i].axis[0] = 0;
+		joystick->hwdata->balls[i].axis[1] = 0;
+	}
+	return(0);
+}
+
+static SDL_bool ConfigJoystick(SDL_Joystick *joystick,
+			const char *name, const char *config)
+{
+	char cfg_name[128];
+	SDL_bool handled;
+
+	if ( config == NULL ) {
+		return(SDL_FALSE);
+	}
+	strcpy(cfg_name, "");
+	if ( *config == '\'' ) {
+		sscanf(config, "'%[^']s'", cfg_name);
+		config += strlen(cfg_name)+2;
+	} else {
+		sscanf(config, "%s", cfg_name);
+		config += strlen(cfg_name);
+	}
+	handled = SDL_FALSE;
+	if ( strcmp(cfg_name, name) == 0 ) {
+		/* Get the number of axes, hats and balls for this joystick */
+		int joystick_axes = joystick->naxes;
+		sscanf(config, "%d %d %d", 
+			&joystick->naxes, &joystick->nhats, &joystick->nballs);
+
+		/* Allocate the extra data for mapping them */
+		if ( joystick->nhats > 0 ) {
+			/* HACK: Analog hats map to only one axis */
+			if (joystick_axes == (joystick->naxes+joystick->nhats)){
+				joystick->hwdata->analog_hat = 1;
+			} else {
+				if ( allocate_hatdata(joystick) < 0 ) {
+					joystick->nhats = 0;
+				}
+				joystick->hwdata->analog_hat = 0;
+			}
+		}
+		if ( joystick->nballs > 0 ) {
+			if ( allocate_balldata(joystick) < 0 ) {
+				joystick->nballs = 0;
+			}
+		}
+		handled = SDL_TRUE;
+	}
+	return(handled);
+}
+
+#ifdef USE_INPUT_EVENTS
+
+static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
+{
+	int i;
+	unsigned long keybit[40];
+	unsigned long absbit[40];
+	unsigned long relbit[40];
+
+	/* See if this device uses the new unified event API */
+	if ( (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
+	     (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
+	     (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0) ) {
+		joystick->hwdata->is_hid = SDL_TRUE;
+
+		/* Get the number of buttons, axes, and other thingamajigs */
+		for ( i=BTN_JOYSTICK; i < KEY_MAX; ++i ) {
+			if ( test_bit(i, keybit) ) {
+#ifdef DEBUG_INPUT_EVENTS
+				printf("Joystick has button: 0x%x\n", i);
+#endif
+				joystick->hwdata->key_map[i-BTN_MISC] =
+						joystick->nbuttons;
+				++joystick->nbuttons;
+			}
+		}
+		for ( i=BTN_MISC; i < BTN_JOYSTICK; ++i ) {
+			if ( test_bit(i, keybit) ) {
+#ifdef DEBUG_INPUT_EVENTS
+				printf("Joystick has button: 0x%x\n", i);
+#endif
+				joystick->hwdata->key_map[i-BTN_MISC] =
+						joystick->nbuttons;
+				++joystick->nbuttons;
+			}
+		}
+		for ( i=0; i<ABS_MAX; ++i ) {
+			/* Skip hats */
+			if ( i == ABS_HAT0X ) {
+				i = ABS_HAT3Y;
+				continue;
+			}
+			if ( test_bit(i, absbit) ) {
+				int values[5];
+
+				ioctl(fd, EVIOCGABS(i), values);
+#ifdef DEBUG_INPUT_EVENTS
+				printf("Joystick has absolute axis: %x\n", i);
+				printf("Values = { %d, %d, %d, %d, %d }\n",
+					values[0], values[1],
+					values[2], values[3], values[4]);
+#endif /* DEBUG_INPUT_EVENTS */
+				joystick->hwdata->abs_map[i] = joystick->naxes;
+				if ( values[1] == values[2] ) {
+				    joystick->hwdata->abs_correct[i].used = 0;
+				} else {
+				    joystick->hwdata->abs_correct[i].used = 1;
+				    joystick->hwdata->abs_correct[i].coef[0] =
+					(values[2] + values[1]) / 2 - values[4];
+				    joystick->hwdata->abs_correct[i].coef[1] =
+					(values[2] + values[1]) / 2 + values[4];
+				    joystick->hwdata->abs_correct[i].coef[2] =
+					(1 << 29) / ((values[2] - values[1]) / 2 - 2 * values[4]);
+				}
+				++joystick->naxes;
+			}
+		}
+		for ( i=ABS_HAT0X; i <= ABS_HAT3Y; i += 2 ) {
+			if ( test_bit(i, absbit) || test_bit(i+1, absbit) ) {
+#ifdef DEBUG_INPUT_EVENTS
+				printf("Joystick has hat %d\n",(i-ABS_HAT0X)/2);
+#endif
+				++joystick->nhats;
+			}
+		}
+		if ( test_bit(REL_X, relbit) || test_bit(REL_Y, relbit) ) {
+			++joystick->nballs;
+		}
+
+		/* Allocate data to keep track of these thingamajigs */
+		if ( joystick->nhats > 0 ) {
+			if ( allocate_hatdata(joystick) < 0 ) {
+				joystick->nhats = 0;
+			}
+		}
+		if ( joystick->nballs > 0 ) {
+			if ( allocate_balldata(joystick) < 0 ) {
+				joystick->nballs = 0;
+			}
+		}
+	}
+	return(joystick->hwdata->is_hid);
+}
+
+#endif /* USE_INPUT_EVENTS */
+
+#endif /* FANCY_HATS_AND_BALLS */
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+{
+#ifdef FANCY_HATS_AND_BALLS
+	const char *name;
+	int i;
+#endif
+	int fd;
+	unsigned char n;
+
+	/* Open the joystick and set the joystick file descriptor */
+	fd = open(SDL_joylist[joystick->index], O_RDONLY, 0);
+	if ( fd < 0 ) {
+		SDL_SetError("Unable to open %s\n",
+		             SDL_joylist[joystick->index]);
+		return(-1);
+	}
+	joystick->hwdata = (struct joystick_hwdata *)
+	                   malloc(sizeof(*joystick->hwdata));
+	if ( joystick->hwdata == NULL ) {
+		SDL_OutOfMemory();
+		close(fd);
+		return(-1);
+	}
+	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+	joystick->hwdata->fd = fd;
+
+	/* Set the joystick to non-blocking read mode */
+	fcntl(fd, F_SETFL, O_NONBLOCK);
+
+	/* Get the number of buttons and axes on the joystick */
+#ifdef USE_INPUT_EVENTS
+	if ( ! EV_ConfigJoystick(joystick, fd) )
+#endif
+	{
+		if ( ioctl(fd, JSIOCGAXES, &n) < 0 ) {
+			joystick->naxes = 2;
+		} else {
+			joystick->naxes = n;
+		}
+		if ( ioctl(fd, JSIOCGBUTTONS, &n) < 0 ) {
+			joystick->nbuttons = 2;
+		} else {
+			joystick->nbuttons = n;
+		}
+#ifdef FANCY_HATS_AND_BALLS
+		/* Check for special joystick support */
+		name = SDL_SYS_JoystickName(joystick->index);
+		for ( i=0; special_joysticks[i]; ++i ) {
+			if (ConfigJoystick(joystick,name,special_joysticks[i])){
+				break;
+			}
+		}
+		if ( special_joysticks[i] == NULL ) {
+			ConfigJoystick(joystick, name,
+					getenv("SDL_LINUX_JOYSTICK"));
+		}
+#endif /* FANCY_HATS_AND_BALLS */
+	}
+	return(0);
+}
+
+static __inline__
+void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
+{
+	struct hwdata_hat *the_hat;
+	const Uint8 position_map[3][3] = {
+		{ SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP },
+		{ SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT },
+		{ SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN }
+	};
+
+	the_hat = &stick->hwdata->hats[hat];
+	if ( value < 0 ) {
+		value = 0;
+	} else
+	if ( value == 0 ) {
+		value = 1;
+	} else
+	if ( value > 0 ) {
+		value = 2;
+	}
+	if ( value != the_hat->axis[axis] ) {
+		the_hat->axis[axis] = value;
+		SDL_PrivateJoystickHat(stick, hat,
+			position_map[the_hat->axis[1]][the_hat->axis[0]]);
+	}
+}
+
+/* This was necessary for the Wingman Extreme Analog joystick */
+static __inline__
+void HandleAnalogHat(SDL_Joystick *stick, Uint8 hat, int value)
+{
+	const Uint8 position_map[] = {
+		SDL_HAT_UP,
+		SDL_HAT_RIGHT,
+		SDL_HAT_DOWN,
+		SDL_HAT_LEFT,
+		SDL_HAT_CENTERED
+	};
+	SDL_PrivateJoystickHat(stick, hat, position_map[(value/16000)+2]);
+}
+
+static __inline__
+void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value)
+{
+	stick->hwdata->balls[ball].axis[axis] += value;
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+static __inline__ void JS_HandleEvents(SDL_Joystick *joystick)
+{
+	struct js_event events[32];
+	int i, len;
+	Uint8 other_axis;
+
+	while ((len=read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
+		len /= sizeof(events[0]);
+		for ( i=0; i<len; ++i ) {
+			switch (events[i].type & ~JS_EVENT_INIT) {
+			    case JS_EVENT_AXIS:
+				if ( events[i].number < joystick->naxes ) {
+					SDL_PrivateJoystickAxis(joystick,
+				           events[i].number, events[i].value);
+					break;
+				}
+				events[i].number -= joystick->naxes;
+				if ( joystick->hwdata->analog_hat ) {
+					other_axis = events[i].number;
+					if ( other_axis < joystick->nhats ) {
+						HandleAnalogHat(joystick, other_axis,
+							events[i].value);
+						break;
+					}
+				} else {
+					other_axis = (events[i].number / 2);
+					if ( other_axis < joystick->nhats ) {
+						HandleHat(joystick, other_axis,
+							events[i].number%2,
+							events[i].value);
+						break;
+					}
+				}
+				events[i].number -= joystick->nhats*2;
+				other_axis = (events[i].number / 2);
+				if ( other_axis < joystick->nballs ) {
+					HandleBall(joystick, other_axis,
+						events[i].number%2,
+						events[i].value);
+					break;
+				}
+				break;
+			    case JS_EVENT_BUTTON:
+				SDL_PrivateJoystickButton(joystick,
+				           events[i].number, events[i].value);
+				break;
+			    default:
+				/* ?? */
+				break;
+			}
+		}
+	}
+}
+#ifdef USE_INPUT_EVENTS
+static __inline__ int EV_AxisCorrect(SDL_Joystick *joystick, int which, int value)
+{
+	struct axis_correct *correct;
+
+	correct = &joystick->hwdata->abs_correct[which];
+	if ( correct->used ) {
+		if ( value > correct->coef[0] ) {
+			if ( value < correct->coef[1] ) {
+				return 0;
+			}
+			value -= correct->coef[1];
+		} else {
+			value -= correct->coef[0];
+		}
+		value *= correct->coef[2];
+		value >>= 14;
+	}
+	/* Clamp and return */
+	if ( value < -32767 ) {
+		value = -32767;
+	} else
+	if ( value > 32767 ) {
+		value = 32767;
+	}
+	return value;
+}
+
+static __inline__ void EV_HandleEvents(SDL_Joystick *joystick)
+{
+	struct input_event events[32];
+	int i, len;
+	int code;
+
+	while ((len=read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
+		len /= sizeof(events[0]);
+		for ( i=0; i<len; ++i ) {
+			code = events[i].code;
+			switch (events[i].type) {
+			    case EV_KEY:
+				if ( code >= BTN_MISC ) {
+					code -= BTN_MISC;
+					SDL_PrivateJoystickButton(joystick,
+				           joystick->hwdata->key_map[code],
+					   events[i].value);
+				}
+				break;
+			    case EV_ABS:
+				switch (code) {
+				    case ABS_HAT0X:
+				    case ABS_HAT0Y:
+				    case ABS_HAT1X:
+				    case ABS_HAT1Y:
+				    case ABS_HAT2X:
+				    case ABS_HAT2Y:
+				    case ABS_HAT3X:
+				    case ABS_HAT3Y:
+					code -= ABS_HAT0X;
+					HandleHat(joystick, code/2, code%2,
+							events[i].value);
+					break;
+				    default:
+					events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
+					SDL_PrivateJoystickAxis(joystick,
+				           joystick->hwdata->abs_map[code],
+					   events[i].value);
+					break;
+				}
+				break;
+			    case EV_REL:
+				switch (code) {
+				    case REL_X:
+				    case REL_Y:
+					code -= REL_X;
+					HandleBall(joystick, code/2, code%2,
+							events[i].value);
+					break;
+				    default:
+					break;
+				}
+				break;
+			    default:
+				break;
+			}
+		}
+	}
+}
+#endif /* USE_INPUT_EVENTS */
+
+void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+{
+	int i;
+	
+#ifdef USE_INPUT_EVENTS
+	if ( joystick->hwdata->is_hid )
+		EV_HandleEvents(joystick);
+	else
+#endif
+		JS_HandleEvents(joystick);
+
+	/* Deliver ball motion updates */
+	for ( i=0; i<joystick->nballs; ++i ) {
+		int xrel, yrel;
+
+		xrel = joystick->hwdata->balls[i].axis[0];
+		yrel = joystick->hwdata->balls[i].axis[1];
+		if ( xrel || yrel ) {
+			joystick->hwdata->balls[i].axis[0] = 0;
+			joystick->hwdata->balls[i].axis[1] = 0;
+			SDL_PrivateJoystickBall(joystick, (Uint8)i, xrel, yrel);
+		}
+	}
+}
+
+/* Function to close a joystick after use */
+void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+{
+	if ( joystick->hwdata ) {
+		close(joystick->hwdata->fd);
+		if ( joystick->hwdata->hats ) {
+			free(joystick->hwdata->hats);
+		}
+		if ( joystick->hwdata->balls ) {
+			free(joystick->hwdata->balls);
+		}
+		free(joystick->hwdata);
+		joystick->hwdata = NULL;
+	}
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void SDL_SYS_JoystickQuit(void)
+{
+	int i;
+
+	for ( i=0; SDL_joylist[i]; ++i ) {
+		free(SDL_joylist[i]);
+	}
+	SDL_joylist[0] = NULL;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/macos/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/macos/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the MacOS joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_macos.la
+libjoystick_macos_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS =  SDL_sysjoystick.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/macos/SDL_sysjoystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,322 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/*  SDL stuff  --  "SDL_sysjoystick.c"
+    MacOS joystick functions by Frederick Reitberger
+
+    The code that follows is meant for SDL.  Use at your own risk.
+*/
+
+#include <string.h>
+
+#include <InputSprocket.h>
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+
+/*  The max number of joysticks we will detect  */
+#define     MAX_JOYSTICKS       16 
+/*  Limit ourselves to 32 elements per device  */
+#define     kMaxReferences      32 
+
+#define		ISpSymmetricAxisToFloat(axis)	((((float) axis) - kISpAxisMiddle) / (kISpAxisMaximum-kISpAxisMiddle))
+#define		ISpAsymmetricAxisToFloat(axis)	(((float) axis) / (kISpAxisMaximum))
+
+
+static  ISpDeviceReference  SYS_Joysticks[MAX_JOYSTICKS];
+static  ISpElementListReference SYS_Elements[MAX_JOYSTICKS];
+static  ISpDeviceDefinition     SYS_DevDef[MAX_JOYSTICKS];
+
+struct joystick_hwdata 
+{
+    char name[64];
+/*    Uint8   id;*/
+    ISpElementReference refs[kMaxReferences];
+    /*  gonna need some sort of mapping info  */
+}; 
+
+
+/* Function to scan the system for joysticks.
+ * Joystick 0 should be the system default joystick.
+ * This function should return the number of available joysticks, or -1
+ * on an unrecoverable fatal error.
+ */
+int SDL_SYS_JoystickInit(void)
+{
+    static ISpDeviceClass classes[4] = {
+        kISpDeviceClass_Joystick,
+        kISpDeviceClass_Gamepad,
+        kISpDeviceClass_Wheel,
+        0
+    };
+    OSErr   err;
+    int     i;
+    UInt32  count, numJoysticks;
+
+    if ( (Ptr)0 == (Ptr)ISpStartup ) {
+        SDL_SetError("InputSprocket not installed");
+        return -1;  //  InputSprocket not installed
+    }
+
+    if( (Ptr)0 == (Ptr)ISpGetVersion ) {
+        SDL_SetError("InputSprocket not version 1.1 or newer");
+        return -1;  //  old version of ISp (not at least 1.1)
+    }
+
+    ISpStartup();
+
+    /* Get all the joysticks */
+    numJoysticks = 0;
+    for ( i=0; classes[i]; ++i ) {
+        count = 0;
+        err = ISpDevices_ExtractByClass(
+            classes[i],
+            MAX_JOYSTICKS-numJoysticks,
+            &count,
+            &SYS_Joysticks[numJoysticks]);
+        numJoysticks += count;
+    }
+
+    for(i = 0; i < numJoysticks; i++)
+    {
+        ISpDevice_GetDefinition(
+            SYS_Joysticks[i], sizeof(ISpDeviceDefinition),
+            &SYS_DevDef[i]);
+        
+        err = ISpElementList_New(
+            0, NULL,
+            &SYS_Elements[i], 0);
+        
+        if (err) {
+            SDL_OutOfMemory();
+            return -1;
+        }
+
+        ISpDevice_GetElementList(
+            SYS_Joysticks[i],
+            &SYS_Elements[i]);
+    }
+
+    ISpDevices_Deactivate(numJoysticks, SYS_Joysticks);
+
+    return numJoysticks;
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *SDL_SYS_JoystickName(int index)
+{
+    static char name[64];
+    int len;
+
+    /*  convert pascal string to c-string  */
+    len = SYS_DevDef[index].deviceName[0];
+    if ( len >= sizeof(name) ) {
+        len = (sizeof(name) - 1);
+    }
+    memcpy(name, &SYS_DevDef[index].deviceName[1], len);
+    name[len] = '\0';
+
+    return name;
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+{
+    int     index;
+    UInt32  count, gotCount, count2;
+    long    numAxis, numButtons, numHats, numBalls;
+
+    count = kMaxReferences;
+    count2 = 0;
+    numAxis = numButtons = numHats = numBalls = 0;
+
+    index = joystick->index;
+
+    /* allocate memory for system specific hardware data */
+    joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
+    if (joystick->hwdata == NULL)
+    {
+		SDL_OutOfMemory();
+		return(-1);
+    }
+    memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+    strcpy(joystick->hwdata->name, SDL_SYS_JoystickName(index));
+    joystick->name = joystick->hwdata->name;
+
+    ISpElementList_ExtractByKind(
+        SYS_Elements[index],
+        kISpElementKind_Axis,
+        count,
+        &gotCount,
+        joystick->hwdata->refs);
+
+    numAxis = gotCount;
+    count -= gotCount;
+    count2 += gotCount;
+
+    ISpElementList_ExtractByKind(
+        SYS_Elements[index],
+        kISpElementKind_DPad,
+        count,
+        &gotCount,
+        &(joystick->hwdata->refs[count2]));
+
+    numHats = gotCount;
+    count -= gotCount;
+    count2 += gotCount;
+
+    ISpElementList_ExtractByKind(
+        SYS_Elements[index],
+        kISpElementKind_Button,
+        count,
+        &gotCount,
+        &(joystick->hwdata->refs[count2]));
+
+    numButtons = gotCount;
+    count -= gotCount;
+    count2 += gotCount;
+
+    joystick->naxes = numAxis;
+    joystick->nhats = numHats;
+    joystick->nballs = numBalls;
+    joystick->nbuttons = numButtons;
+
+    ISpDevices_Activate(
+        1,
+        &SYS_Joysticks[index]);
+
+    return 0;
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+{
+    int     i, j;
+    ISpAxisData     a;
+    ISpDPadData     b;
+    //ISpDeltaData    c;
+    ISpButtonData   d;
+
+    for(i = 0, j = 0; i < joystick->naxes; i++, j++)
+    {
+        Sint16 value;
+
+        ISpElement_GetSimpleState(
+            joystick->hwdata->refs[j],
+            &a);
+        value = (ISpSymmetricAxisToFloat(a)* 32767.0);
+        if ( value != joystick->axes[i] ) {
+            SDL_PrivateJoystickAxis(joystick, i, value);
+        }
+    }
+
+    for(i = 0; i < joystick->nhats; i++, j++)
+    {
+        Uint8 pos;
+
+        ISpElement_GetSimpleState(
+            joystick->hwdata->refs[j],
+            &b);
+        switch(b) {
+            case kISpPadIdle:
+                pos = SDL_HAT_CENTERED;
+                break;
+            case kISpPadLeft:
+                pos = SDL_HAT_LEFT;
+                break;
+            case kISpPadUpLeft:
+                pos = SDL_HAT_LEFTUP;
+                break;
+            case kISpPadUp:
+                pos = SDL_HAT_UP;
+                break;
+            case kISpPadUpRight:
+                pos = SDL_HAT_RIGHTUP;
+                break;
+            case kISpPadRight:
+                pos = SDL_HAT_RIGHT;
+                break;
+            case kISpPadDownRight:
+                pos = SDL_HAT_RIGHTDOWN;
+                break;
+            case kISpPadDown:
+                pos = SDL_HAT_DOWN;
+                break;
+            case kISpPadDownLeft:
+                pos = SDL_HAT_LEFTDOWN;
+                break;
+        }
+        if ( pos != joystick->hats[i] ) {
+            SDL_PrivateJoystickHat(joystick, i, pos);
+        }
+    }
+
+    for(i = 0; i < joystick->nballs; i++, j++)
+    {
+        /*  ignore balls right now  */
+    }
+
+    for(i = 0; i < joystick->nbuttons; i++, j++)
+    {
+        ISpElement_GetSimpleState(
+            joystick->hwdata->refs[j],
+            &d);
+        if ( d != joystick->buttons[i] ) {
+            SDL_PrivateJoystickButton(joystick, i, d);
+        }
+    }
+}
+
+/* Function to close a joystick after use */
+void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+{
+    int index;
+
+    index = joystick->index;
+
+    ISpDevices_Deactivate(
+        1,
+        &SYS_Joysticks[index]);
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void SDL_SYS_JoystickQuit(void)
+{
+    ISpShutdown();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/win32/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/win32/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+## Makefile.am for the Windows MultiMedia joystick driver for SDL
+
+noinst_LTLIBRARIES = libjoystick_winmm.la
+libjoystick_winmm_la_SOURCES = $(SRCS)
+
+# The SDL joystick driver sources
+SRCS =  SDL_mmjoystick.c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/joystick/win32/SDL_mmjoystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,328 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
+
+#include <stdlib.h>
+#include <stdio.h>		/* For the definition of NULL */
+
+#include "SDL_error.h"
+#include "SDL_joystick.h"
+#include "SDL_sysjoystick.h"
+#include "SDL_joystick_c.h"
+
+#include <windows.h>
+#include <mmsystem.h>
+
+#define MAX_JOYSTICKS	2	/* only 2 are supported in the multimedia API */
+#define MAX_AXES	6	/* each joystick can have up to 6 axes */
+#define MAX_BUTTONS	32	/* and 32 buttons                      */
+#define AXIS_MIN	-32768  /* minimum value for axis coordinate */
+#define AXIS_MAX	32767   /* maximum value for axis coordinate */
+#define JOY_AXIS_THRESHOLD	(((AXIS_MAX)-(AXIS_MIN))/100) /* 1% motion */
+#define JOY_BUTTON_FLAG(n)	(1<<n)
+
+
+/* array to hold joystick ID values */
+static UINT	SYS_JoystickID[MAX_JOYSTICKS];
+static JOYCAPS	SYS_Joystick[MAX_JOYSTICKS];
+
+/* The private structure used to keep track of a joystick */
+struct joystick_hwdata
+{
+	/* joystick ID */
+	UINT	id;
+
+	/* values used to translate device-specific coordinates into
+	   SDL-standard ranges */
+	struct _transaxis {
+		int offset;
+		float scale;
+	} transaxis[6];
+};
+
+/* Convert a win32 Multimedia API return code to a text message */
+static void SetMMerror(char *function, int code);
+
+
+/* Function to scan the system for joysticks.
+ * This function should set SDL_numjoysticks to the number of available
+ * joysticks.  Joystick 0 should be the system default joystick.
+ * It should return 0, or -1 on an unrecoverable fatal error.
+ */
+int SDL_SYS_JoystickInit(void)
+{
+	int	i;
+	int maxdevs;
+	int numdevs;
+	JOYINFOEX joyinfo;
+	JOYCAPS	joycaps;
+	MMRESULT result;
+
+	numdevs = 0;
+	maxdevs = joyGetNumDevs();
+	if ( maxdevs > MAX_JOYSTICKS ) {
+		maxdevs = MAX_JOYSTICKS;
+	}
+
+	SYS_JoystickID[0] = JOYSTICKID1;
+	SYS_JoystickID[1] = JOYSTICKID2;
+
+	for ( i = 0; (i < maxdevs); ++i ) {
+		result = joyGetPosEx(SYS_JoystickID[i], &joyinfo);
+		if ( result == JOYERR_NOERROR ) {
+			result = joyGetDevCaps(SYS_JoystickID[i], &joycaps, sizeof(joycaps));
+			if ( result == JOYERR_NOERROR ) {
+				SYS_JoystickID[numdevs] = SYS_JoystickID[i];
+				SYS_Joystick[numdevs] = joycaps;
+				numdevs++;
+			}
+		}
+	}
+	return(numdevs);
+}
+
+/* Function to get the device-dependent name of a joystick */
+const char *SDL_SYS_JoystickName(int index)
+{
+	/***-> test for invalid index ? */
+	return(SYS_Joystick[index].szPname);
+}
+
+/* Function to open a joystick for use.
+   The joystick to open is specified by the index field of the joystick.
+   This should fill the nbuttons and naxes fields of the joystick structure.
+   It returns 0, or -1 if there is an error.
+ */
+int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
+{
+	int index, i;
+	int caps_flags[MAX_AXES-2] =
+		{ JOYCAPS_HASZ, JOYCAPS_HASR, JOYCAPS_HASU, JOYCAPS_HASV };
+	int axis_min[MAX_AXES], axis_max[MAX_AXES];
+
+
+	/* shortcut */
+	index = joystick->index;
+	axis_min[0] = SYS_Joystick[index].wXmin;
+	axis_max[0] = SYS_Joystick[index].wXmax;
+	axis_min[1] = SYS_Joystick[index].wYmin;
+	axis_max[1] = SYS_Joystick[index].wYmax;
+	axis_min[2] = SYS_Joystick[index].wZmin;
+	axis_max[2] = SYS_Joystick[index].wZmax;
+	axis_min[3] = SYS_Joystick[index].wRmin;
+	axis_max[3] = SYS_Joystick[index].wRmax;
+	axis_min[4] = SYS_Joystick[index].wUmin;
+	axis_max[4] = SYS_Joystick[index].wUmax;
+	axis_min[5] = SYS_Joystick[index].wVmin;
+	axis_max[5] = SYS_Joystick[index].wVmax;
+
+	/* allocate memory for system specific hardware data */
+	joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
+	if (joystick->hwdata == NULL)
+	{
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
+
+	/* set hardware data */
+	joystick->hwdata->id = SYS_JoystickID[index];
+	for ( i = 0; i < MAX_AXES; ++i ) {
+		if ( (i<2) || (SYS_Joystick[index].wCaps & caps_flags[i-2]) ) {
+			joystick->hwdata->transaxis[i].offset =
+				AXIS_MIN - axis_min[i];
+			joystick->hwdata->transaxis[i].scale =
+				(float)(AXIS_MAX - AXIS_MIN) / (axis_max[i] - axis_min[i]);
+		} else {
+			joystick->hwdata->transaxis[i].offset = 0;
+			joystick->hwdata->transaxis[i].scale = 1.0; /* Just in case */
+		}
+	}
+
+	/* fill nbuttons, naxes, and nhats fields */
+	joystick->nbuttons = SYS_Joystick[index].wNumButtons;
+	joystick->naxes = SYS_Joystick[index].wNumAxes;
+	if ( SYS_Joystick[index].wCaps & JOYCAPS_HASPOV ) {
+		joystick->nhats = 1;
+	} else {
+		joystick->nhats = 0;
+	}
+	return(0);
+}
+
+static Uint8 TranslatePOV(DWORD value)
+{
+	Uint8 pos;
+
+	pos = SDL_HAT_CENTERED;
+	if ( value != JOY_POVCENTERED ) {
+		if ( (value > JOY_POVLEFT) || (value < JOY_POVRIGHT) ) {
+			pos |= SDL_HAT_UP;
+		}
+		if ( (value > JOY_POVFORWARD) && (value < JOY_POVBACKWARD) ) {
+			pos |= SDL_HAT_RIGHT;
+		}
+		if ( (value > JOY_POVRIGHT) && (value < JOY_POVLEFT) ) {
+			pos |= SDL_HAT_DOWN;
+		}
+		if ( value > JOY_POVBACKWARD ) {
+			pos |= SDL_HAT_LEFT;
+		}
+	}
+	return(pos);
+}
+
+/* Function to update the state of a joystick - called as a device poll.
+ * This function shouldn't update the joystick structure directly,
+ * but instead should call SDL_PrivateJoystick*() to deliver events
+ * and update joystick device state.
+ */
+void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
+{
+	MMRESULT result;
+	int i;
+	DWORD flags[MAX_AXES] = { JOY_RETURNX, JOY_RETURNY, JOY_RETURNZ, 
+				  JOY_RETURNR, JOY_RETURNU, JOY_RETURNV };
+	DWORD pos[MAX_AXES];
+	struct _transaxis *transaxis;
+	int value, change;
+	JOYINFOEX joyinfo;
+
+	joyinfo.dwSize = sizeof(joyinfo);
+	joyinfo.dwFlags = JOY_RETURNALL|JOY_RETURNPOVCTS;
+	if ( ! joystick->hats ) {
+		joyinfo.dwFlags &= ~(JOY_RETURNPOV|JOY_RETURNPOVCTS);
+	}
+	result = joyGetPosEx(joystick->hwdata->id, &joyinfo);
+	if ( result != JOYERR_NOERROR ) {
+		SetMMerror("joyGetPosEx", result);
+		return;
+	}
+
+	/* joystick motion events */
+	pos[0] = joyinfo.dwXpos;
+	pos[1] = joyinfo.dwYpos;
+	pos[2] = joyinfo.dwZpos;
+	pos[3] = joyinfo.dwRpos;
+	pos[4] = joyinfo.dwUpos;
+	pos[5] = joyinfo.dwVpos;
+
+	transaxis = joystick->hwdata->transaxis;
+	for (i = 0; i < joystick->naxes; i++) {
+		if (joyinfo.dwFlags & flags[i]) {
+			value = (int)((float)(pos[i] + transaxis[i].offset) * transaxis[i].scale);
+			change = (value - joystick->axes[i]);
+			if ( (change < -JOY_AXIS_THRESHOLD) || (change > JOY_AXIS_THRESHOLD) ) {
+				SDL_PrivateJoystickAxis(joystick, (Uint8)i, (Sint16)value);
+			}
+		}
+	}
+
+	/* joystick button events */
+	if ( joyinfo.dwFlags & JOY_RETURNBUTTONS ) {
+		for ( i = 0; i < joystick->nbuttons; ++i ) {
+			if ( joyinfo.dwButtons & JOY_BUTTON_FLAG(i) ) {
+				if ( ! joystick->buttons[i] ) {
+					SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_PRESSED);
+				}
+			} else {
+				if ( joystick->buttons[i] ) {
+					SDL_PrivateJoystickButton(joystick, (Uint8)i, SDL_RELEASED);
+				}
+			}
+		}
+	}
+
+	/* joystick hat events */
+	if ( joyinfo.dwFlags & JOY_RETURNPOV ) {
+		Uint8 pos;
+
+		pos = TranslatePOV(joyinfo.dwPOV);
+		if ( pos != joystick->hats[0] ) {
+			SDL_PrivateJoystickHat(joystick, 0, pos);
+		}
+	}
+}
+
+/* Function to close a joystick after use */
+void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
+{
+	if (joystick->hwdata != NULL) {
+		/* free system specific hardware data */
+		free(joystick->hwdata);
+	}
+}
+
+/* Function to perform any system-specific joystick related cleanup */
+void SDL_SYS_JoystickQuit(void)
+{
+	return;
+}
+
+
+/* implementation functions */
+void SetMMerror(char *function, int code)
+{
+	static char *error;
+	static char  errbuf[BUFSIZ];
+
+	errbuf[0] = 0;
+	switch (code) 
+	{
+		case MMSYSERR_NODRIVER:
+			error = "Joystick driver not present";
+		break;
+
+		case MMSYSERR_INVALPARAM:
+		case JOYERR_PARMS:
+			error = "Invalid parameter(s)";
+		break;
+		
+		case MMSYSERR_BADDEVICEID:
+			error = "Bad device ID";
+		break;
+
+		case JOYERR_UNPLUGGED:
+			error = "Joystick not attached";
+		break;
+
+		case JOYERR_NOCANDO:
+			error = "Can't capture joystick input";
+		break;
+
+		default:
+			sprintf(errbuf, "%s: Unknown Multimedia system error: 0x%x",
+								function, code);
+		break;
+	}
+
+	if ( ! errbuf[0] ) {
+		sprintf(errbuf, "%s: %s", function, error);
+	}
+	SDL_SetError("%s", errbuf);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,7 @@
+Makefile.in
+SDL_main.c
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+
+## Makefile.am for the main() function in the SDL library
+#
+# This is necessary because some platforms have special program
+# entry points, which require special application initialization.
+
+ARCH_SUBDIRS = beos linux macos win32
+
+# Build a separate library containing the main() entry point.
+lib_LIBRARIES = libSDLmain.a
+
+MAINLIB_ARCH_SRCS = SDL_main.c
+
+libSDLmain_a_SOURCES = $(MAINLIB_ARCH_SRCS)
+
+# Build an internal library of any special app setup functions
+noinst_LTLIBRARIES = libarch.la
+
+if TARGET_BEOS
+ARCH_SRCS = SDL_BeApp.cc SDL_BeApp.h
+else
+ARCH_SRCS = 
+endif
+
+# Include the architecture-independent sources
+COMMON_SRCS = dummy.c
+
+libarch_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
+
+## Let automake know that it shouldn't distribute linked sources
+BUILT_SOURCES = $(MAINLIB_ARCH_SRCS) $(ARCH_SRCS)
+
+## Let automake know that it should remove these for distribution
+DISTCLEANFILES = $(MAINLIB_ARCH_SRCS) $(ARCH_SRCS)
+
+# The architecture specific directories need to be copied into place
+# when building a distribution.
+dist-hook:
+	(cd $(distdir) && rm -f $(BUILT_SOURCES))
+	cp -rp $(ARCH_SUBDIRS) $(distdir)
+	(cd $(distdir) && rm -rf `find . -name CVS`)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/beos/SDL_BeApp.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,121 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the BeApp specific portions of the application */
+
+#include <AppKit.h>
+#include <storage/Path.h>
+#include <storage/Entry.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "SDL_BeApp.h"
+#include "SDL_thread.h"
+#include "SDL_timer.h"
+#include "SDL_error.h"
+
+/* Flag to tell whether or not the Be application is active or not */
+int SDL_BeAppActive = 0;
+static SDL_Thread *SDL_AppThread = NULL;
+
+static int StartBeApp(void *unused)
+{
+	BApplication *App;
+
+	App = new BApplication("application/x-SDL-executable");
+
+	App->Run();
+	delete App;
+	return(0);
+}
+
+/* Initialize the Be Application, if it's not already started */
+int SDL_InitBeApp(void)
+{
+	/* Create the BApplication that handles appserver interaction */
+	if ( SDL_BeAppActive <= 0 ) {
+		SDL_AppThread = SDL_CreateThread(StartBeApp, NULL);
+		if ( SDL_AppThread == NULL ) {
+			SDL_SetError("Couldn't create BApplication thread");
+			return(-1);
+		}
+		
+		/* Check if we started from Terminal or Tracker... */
+		/* Based on code posted to BeDevTalk by Marco Nelissen */
+		char *cmd = getenv("_"); 
+		if(!(cmd == NULL || strlen(cmd) < 7) && 
+			(!strcmp(cmd + strlen(cmd) - 7 , "Tracker"))) { 
+	
+			/* Change working to directory to that of executable */
+			app_info info;
+			if (B_OK == be_app->GetAppInfo(&info)) {
+				entry_ref ref = info.ref;
+				BEntry entry;
+				if (B_OK == entry.SetTo(&ref)) {
+					BPath path;
+					if (B_OK == path.SetTo(&entry)) {
+						if (B_OK == path.GetParent(&path)) {
+							chdir(path.Path());
+						}
+					}
+				}
+			}	
+		} /* else started from Terminal */
+		
+		do {
+			SDL_Delay(10);
+		} while ( (be_app == NULL) || be_app->IsLaunching() );
+
+		/* Mark the application active */
+		SDL_BeAppActive = 0;
+	}
+
+	/* Increment the application reference count */
+	++SDL_BeAppActive;
+
+	/* The app is running, and we're ready to go */
+	return(0);
+}
+
+/* Quit the Be Application, if there's nothing left to do */
+void SDL_QuitBeApp(void)
+{
+	/* Decrement the application reference count */
+	--SDL_BeAppActive;
+
+	/* If the reference count reached zero, clean up the app */
+	if ( SDL_BeAppActive == 0 ) {
+		if ( SDL_AppThread != NULL ) {
+			if ( be_app != NULL ) { /* Not tested */
+				be_app->PostMessage(B_QUIT_REQUESTED);
+			}
+			SDL_WaitThread(SDL_AppThread, NULL);
+			SDL_AppThread = NULL;
+		}
+		/* be_app should now be NULL since be_app has quit */
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/beos/SDL_BeApp.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the BeApp specific portions of the application */
+
+/* Initialize the Be Application, if it's not already started */
+extern int SDL_InitBeApp(void);
+
+/* Quit the Be Application, if there's nothing left to do */
+extern void SDL_QuitBeApp(void);
+
+/* Flag to tell whether the app is active or not */
+extern int SDL_BeAppActive;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/beos/exports/Makefile	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+
+EXPORTS = SDL.exp
+HEADERS = \
+	../../../../include/SDL.h \
+	../../../../include/SDL_active.h \
+	../../../../include/SDL_audio.h \
+	../../../../include/SDL_byteorder.h \
+	../../../../include/SDL_cdrom.h \
+	../../../../include/SDL_endian.h \
+	../../../../include/SDL_error.h \
+	../../../../include/SDL_events.h \
+	../../../../include/SDL_joystick.h \
+	../../../../include/SDL_keyboard.h \
+	../../../../include/SDL_keysym.h \
+	../../../../include/SDL_main.h \
+	../../../../include/SDL_mouse.h \
+	../../../../include/SDL_mutex.h \
+	../../../../include/SDL_quit.h \
+	../../../../include/SDL_rwops.h \
+	../../../../include/SDL_syswm.h \
+	../../../../include/SDL_thread.h \
+	../../../../include/SDL_timer.h \
+	../../../../include/SDL_types.h \
+	../../../../include/SDL_version.h \
+	../../../../include/SDL_video.h
+
+all: $(EXPORTS)
+
+$(EXPORTS): $(HEADERS)
+	perl genexp.pl $(HEADERS) >$@ || rm $@
+
+clean:
+	rm -f $(EXPORTS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/beos/exports/SDL.exp	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,176 @@
+_SDL_Init
+_SDL_InitSubSystem
+_SDL_QuitSubSystem
+_SDL_WasInit
+_SDL_Quit
+_SDL_GetAppState
+_SDL_AudioInit
+_SDL_AudioQuit
+_SDL_AudioDriverName
+_SDL_OpenAudio
+_SDL_GetAudioStatus
+_SDL_PauseAudio
+_SDL_LoadWAV_RW
+_SDL_FreeWAV
+_SDL_BuildAudioCVT
+_SDL_ConvertAudio
+_SDL_MixAudio
+_SDL_LockAudio
+_SDL_UnlockAudio
+_SDL_CloseAudio
+_SDL_CDNumDrives
+_SDL_CDName
+_SDL_CDOpen
+_SDL_CDStatus
+_SDL_CDPlayTracks
+_SDL_CDPlay
+_SDL_CDPause
+_SDL_CDResume
+_SDL_CDStop
+_SDL_CDEject
+_SDL_CDClose
+_SDL_ReadLE16
+_SDL_ReadBE16
+_SDL_ReadLE32
+_SDL_ReadBE32
+_SDL_ReadLE64
+_SDL_ReadBE64
+_SDL_WriteLE16
+_SDL_WriteBE16
+_SDL_WriteLE32
+_SDL_WriteBE32
+_SDL_WriteLE64
+_SDL_WriteBE64
+_SDL_SetError
+_SDL_GetError
+_SDL_ClearError
+_SDL_PumpEvents
+_SDL_PeepEvents
+_SDL_PollEvent
+_SDL_WaitEvent
+_SDL_PushEvent
+_SDL_SetEventFilter
+_SDL_GetEventFilter
+_SDL_EventState
+_SDL_NumJoysticks
+_SDL_JoystickName
+_SDL_JoystickOpen
+_SDL_JoystickOpened
+_SDL_JoystickIndex
+_SDL_JoystickNumAxes
+_SDL_JoystickNumBalls
+_SDL_JoystickNumHats
+_SDL_JoystickNumButtons
+_SDL_JoystickUpdate
+_SDL_JoystickEventState
+_SDL_JoystickGetAxis
+_SDL_JoystickGetHat
+_SDL_JoystickGetBall
+_SDL_JoystickGetButton
+_SDL_JoystickClose
+_SDL_EnableUNICODE
+_SDL_EnableKeyRepeat
+_SDL_GetKeyState
+_SDL_GetModState
+_SDL_SetModState
+_SDL_GetKeyName
+_SDL_RegisterApp
+_SDL_InitQuickDraw
+_SDL_GetMouseState
+_SDL_GetRelativeMouseState
+_SDL_WarpMouse
+_SDL_CreateCursor
+_SDL_SetCursor
+_SDL_GetCursor
+_SDL_FreeCursor
+_SDL_ShowCursor
+_SDL_CreateMutex
+_SDL_mutexP
+_SDL_mutexV
+_SDL_DestroyMutex
+_SDL_CreateSemaphore
+_SDL_DestroySemaphore
+_SDL_SemWait
+_SDL_SemTryWait
+_SDL_SemWaitTimeout
+_SDL_SemPost
+_SDL_SemValue
+_SDL_CreateCond
+_SDL_DestroyCond
+_SDL_CondSignal
+_SDL_CondBroadcast
+_SDL_CondWait
+_SDL_CondWaitTimeout
+_SDL_RWFromFile
+_SDL_RWFromFP
+_SDL_RWFromMem
+_SDL_AllocRW
+_SDL_FreeRW
+_SDL_GetWMInfo
+_SDL_CreateThread
+_SDL_ThreadID
+_SDL_GetThreadID
+_SDL_WaitThread
+_SDL_KillThread
+_SDL_GetTicks
+_SDL_Delay
+_SDL_SetTimer
+_SDL_AddTimer
+_SDL_RemoveTimer
+_SDL_Linked_Version
+_SDL_VideoInit
+_SDL_VideoQuit
+_SDL_VideoDriverName
+_SDL_GetVideoSurface
+_SDL_GetVideoInfo
+_SDL_VideoModeOK
+_SDL_ListModes
+_SDL_SetVideoMode
+_SDL_UpdateRects
+_SDL_UpdateRect
+_SDL_Flip
+_SDL_SetGamma
+_SDL_SetGammaRamp
+_SDL_GetGammaRamp
+_SDL_SetColors
+_SDL_SetPalette
+_SDL_MapRGB
+_SDL_MapRGBA
+_SDL_GetRGB
+_SDL_GetRGBA
+_SDL_CreateRGBSurface
+_SDL_CreateRGBSurfaceFrom
+_SDL_FreeSurface
+_SDL_LockSurface
+_SDL_UnlockSurface
+_SDL_LoadBMP_RW
+_SDL_SaveBMP_RW
+_SDL_SetColorKey
+_SDL_SetAlpha
+_SDL_SetClipRect
+_SDL_GetClipRect
+_SDL_ConvertSurface
+_SDL_UpperBlit
+_SDL_LowerBlit
+_SDL_FillRect
+_SDL_DisplayFormat
+_SDL_DisplayFormatAlpha
+_SDL_CreateYUVOverlay
+_SDL_LockYUVOverlay
+_SDL_UnlockYUVOverlay
+_SDL_DisplayYUVOverlay
+_SDL_FreeYUVOverlay
+_SDL_GL_LoadLibrary
+_SDL_GL_GetProcAddress
+_SDL_GL_SetAttribute
+_SDL_GL_GetAttribute
+_SDL_GL_SwapBuffers
+_SDL_GL_UpdateRects
+_SDL_GL_Lock
+_SDL_GL_Unlock
+_SDL_WM_SetCaption
+_SDL_WM_GetCaption
+_SDL_WM_SetIcon
+_SDL_WM_IconifyWindow
+_SDL_WM_ToggleFullScreen
+_SDL_WM_GrabInput
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/beos/exports/genexp.pl	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+#
+# Program to take a set of header files and generate MWCC export definitions
+
+while ( ($file = shift(@ARGV)) ) {
+	if ( ! defined(open(FILE, $file)) ) {
+		warn "Couldn't open $file: $!\n";
+		next;
+	}
+	$file =~ s,.*/,,;
+	while (<FILE>) {
+		if ( /DECLSPEC.*\s\**([^\s\(]+)\(/ ) {
+			print "_$1\n";
+		} elsif ( /DECLSPEC.*\s\**([^\s\(]+)$/ ) {
+			print "_$1\n";
+		}
+	}
+	close(FILE);
+}
+# Special exports not public in the header files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/dummy.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,4 @@
+
+/* This is needed for automake, so that it can build an empty archive */
+
+int pointless_symbol_so_the_archive_doesnt_look_empty;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/linux/SDL_main.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+
+/* Include the SDL main definition header */
+#include "SDL_main.h"
+#ifdef main
+#undef main
+#endif
+
+extern int SDL_run(int argc, char **argv);
+
+int main(int argc, char *argv[])
+{
+	return(SDL_run(argc, argv));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/SDL.r	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,58 @@
+data 'DLOG' (1000) {
+	$"0072 0040 00EA 01B3 0001 0100 0000 0000 0000 03E8 0C43 6F6D 6D61 6E64 204C 696E"                    /* .r.@.ê.³...........è.Command Lin */
+	$"6500 280A"                                                                                          /* e.(Â */
+};
+
+data 'DLOG' (1001) {
+	$"0072 0040 00DB 01AC 0001 0100 0000 0000 0000 03E9 0C45 7272 6F72 2057 696E 646F"                    /* .r.@.Û.¬...........é.Error Windo */
+	$"7700 280A"                                                                                          /* w.(Â */
+};
+
+data 'DLOG' (1002) {
+	$"00B8 00BE 0147 01D8 0005 0100 0000 0000 0000 03EA 1643 6F6E 6669 726D 2044 6973"                    /* .¸.¾.G.Ø...........ê.Confirm Dis */
+	$"706C 6179 2043 6861 6E67 6510 280A"                                                                 /* play Change.(Â */
+};
+
+data 'DITL' (1000) {
+	$"0005 0000 0000 0052 0113 0066 0158 0402 4F4B 0000 0000 0052 00C2 0066 0107 0406"                    /* .......R...f.X..OK.....R.Â.f.... */
+	$"4361 6E63 656C 0000 0000 000F 0084 001F 0155 1000 0000 0000 0054 0019 0066 007D"                    /* Cancel.......„...U.......T...f.} */
+	$"050E 4F75 7470 7574 2074 6F20 6669 6C65 0000 0000 000F 0018 001F 007F 080D 436F"                    /* ..Output to file..............Co */
+	$"6D6D 616E 6420 4C69 6E65 3A00 0000 0000 0030 0018 0040 0158 0702 0080"                              /* mmand Line:......0...@.X...€ */
+};
+
+data 'DITL' (1001) {
+	$"0001 0000 0000 0046 0120 005A 015A 0402 4F4B 0000 0000 0010 000A 0038 0160 0800"                    /* .......F. .Z.Z..OK.......Â.8.`.. */
+};
+
+data 'DITL' (1002) {
+	$"0002 0000 0000 006F 001E 0083 0058 0406 4361 6E63 656C 0000 0000 006E 00C0 0082"                    /* .......o...ƒ.X..Cancel.....n.À.‚ */
+	$"00FA 0402 4F4B 0000 0000 000E 000F 005F 010C 88B3 5468 6520 7365 7474 696E 6720"                    /* .ú..OK........._..ˆ³The setting  */
+	$"666F 7220 796F 7572 206D 6F6E 6974 6F72 2068 6173 2062 6565 6E20 6368 616E 6765"                    /* for your monitor has been change */
+	$"642C 2061 6E64 2069 7420 6D61 7920 6E6F 7420 6265 2064 6973 706C 6179 6564 2063"                    /* d, and it may not be displayed c */
+	$"6F72 7265 6374 6C79 2E20 546F 2063 6F6E 6669 726D 2074 6865 2064 6973 706C 6179"                    /* orrectly. To confirm the display */
+	$"2069 7320 636F 7272 6563 742C 2063 6C69 636B 204F 4B2E 2054 6F20 7265 7475 726E"                    /*  is correct, click OK. To return */
+	$"2074 6F20 7468 6520 6F72 6967 696E 616C 2073 6574 7469 6E67 2C20 636C 6963 6B20"                    /*  to the original setting, click  */
+	$"4361 6E63 656C 2E00"                                                                                /* Cancel.. */
+};
+
+data 'MENU' (128, preload) {
+	$"0080 0000 0000 0000 0000 FFFF FFFB 0114 0C41 626F 7574 2053 444C 2E2E 2E00 0000"                    /* .€........ÿÿÿû...About SDL...... */
+	$"0001 2D00 0000 0000"                                                                                /* ..-..... */
+};
+
+data 'MENU' (129) {
+	$"0081 0000 0000 0000 0000 FFFF FFFF 0C56 6964 656F 2044 7269 7665 7219 4472 6177"                    /* .........ÿÿÿÿ.Video Driver.Draw */
+	$"5370 726F 636B 6574 2028 4675 6C6C 7363 7265 656E 2900 0000 001E 546F 6F6C 426F"                    /* Sprocket (Fullscreen).....ToolBo */
+	$"7820 2028 4675 6C6C 7363 7265 656E 2F57 696E 646F 7765 6429 0000 0000 00"                           /* x  (Fullscreen/Windowed)..... */
+};
+
+data 'CNTL' (128) {
+	$"0000 0000 0010 0140 0000 0100 0064 0081 03F0 0000 0000 0D56 6964 656F 2044 7269"                    /* .......@.....d..ð.....Video Dri */
+	$"7665 723A"                                                                                          /* ver: */
+};
+
+data 'TMPL' (128, "CLne") {
+	$"0C43 6F6D 6D61 6E64 204C 696E 6550 5354 520C 5669 6465 6F20 4472 6976 6572 5053"                    /* .Command LinePSTR.Video DriverPS */
+	$"5452 0C53 6176 6520 546F 2046 696C 6542 4F4F 4C"                                                    /* TR.Save To FileBOOL */
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/SDL_main.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,562 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This file takes care of command line argument parsing, and stdio redirection
+   in the MacOS environment.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>	
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <Dialogs.h>
+#include <Fonts.h>
+#include <Events.h>
+#include <Resources.h>
+#include <Folders.h>
+#endif
+
+/* Include the SDL main definition header */
+#include "SDL.h"
+#include "SDL_main.h"
+#ifdef main
+#undef main
+#endif
+
+/* The standard output files */
+#define STDOUT_FILE	"stdout.txt"
+#define STDERR_FILE	"stderr.txt"
+
+#if !defined(__MWERKS__) && !TARGET_API_MAC_CARBON
+	/* In MPW, the qd global has been removed from the libraries */
+	QDGlobals qd;
+#endif
+
+/* Structure for keeping prefs in 1 variable */
+typedef struct {
+    Str255  command_line;
+    Str255  video_driver_name;
+    Boolean output_to_file;
+}  PrefsRecord;
+
+/* See if the command key is held down at startup */
+static Boolean CommandKeyIsDown(void)
+{
+	KeyMap  theKeyMap;
+
+	GetKeys(theKeyMap);
+
+	if (((unsigned char *) theKeyMap)[6] & 0x80) {
+		return(true);
+	}
+	return(false);
+}
+
+/* Parse a command line buffer into arguments */
+static int ParseCommandLine(char *cmdline, char **argv)
+{
+	char *bufp;
+	int argc;
+
+	argc = 0;
+	for ( bufp = cmdline; *bufp; ) {
+		/* Skip leading whitespace */
+		while ( isspace(*bufp) ) {
+			++bufp;
+		}
+		/* Skip over argument */
+		if ( *bufp == '"' ) {
+			++bufp;
+			if ( *bufp ) {
+				if ( argv ) {
+					argv[argc] = bufp;
+				}
+				++argc;
+			}
+			/* Skip over word */
+			while ( *bufp && (*bufp != '"') ) {
+				++bufp;
+			}
+		} else {
+			if ( *bufp ) {
+				if ( argv ) {
+					argv[argc] = bufp;
+				}
+				++argc;
+			}
+			/* Skip over word */
+			while ( *bufp && ! isspace(*bufp) ) {
+				++bufp;
+			}
+		}
+		if ( *bufp ) {
+			if ( argv ) {
+				*bufp = '\0';
+			}
+			++bufp;
+		}
+	}
+	if ( argv ) {
+		argv[argc] = NULL;
+	}
+	return(argc);
+}
+
+/* Remove the output files if there was no output written */
+static void cleanup_output(void)
+{
+	FILE *file;
+	int empty;
+
+	/* Flush the output in case anything is queued */
+	fclose(stdout);
+	fclose(stderr);
+
+	/* See if the files have any output in them */
+	file = fopen(STDOUT_FILE, "rb");
+	if ( file ) {
+		empty = (fgetc(file) == EOF) ? 1 : 0;
+		fclose(file);
+		if ( empty ) {
+			remove(STDOUT_FILE);
+		}
+	}
+	file = fopen(STDERR_FILE, "rb");
+	if ( file ) {
+		empty = (fgetc(file) == EOF) ? 1 : 0;
+		fclose(file);
+		if ( empty ) {
+			remove(STDERR_FILE);
+		}
+	}
+}
+
+static int getCurrentAppName (StrFileName name) {
+	
+    ProcessSerialNumber process;
+    ProcessInfoRec      process_info;
+    FSSpec              process_fsp;
+    
+    process.highLongOfPSN = 0;
+    process.lowLongOfPSN  = kCurrentProcess;
+    process_info.processInfoLength = sizeof (process_info);
+    process_info.processName    = NULL;
+    process_info.processAppSpec = &process_fsp;
+    
+    if ( noErr != GetProcessInformation (&process, &process_info) )
+       return 0;
+    
+    memcpy (name, process_fsp.name, process_fsp.name[0] + 1);
+    return 1;
+}
+
+static int getPrefsFile (FSSpec *prefs_fsp, int create) {
+
+    /* The prefs file name is the application name, possibly truncated, */
+    /* plus " Preferences */
+    
+    #define  SUFFIX   " Preferences"
+    #define  MAX_NAME 19             /* 31 - strlen (SUFFIX) */
+    
+    short  volume_ref_number;
+    long   directory_id;
+    StrFileName  prefs_name;
+    StrFileName  app_name;
+    
+    /* Get Preferences folder - works with Multiple Users */
+    if ( noErr != FindFolder ( kOnSystemDisk, kPreferencesFolderType, kDontCreateFolder,
+                               &volume_ref_number, &directory_id) )
+        exit (-1);
+    
+    if ( ! getCurrentAppName (app_name) )
+        exit (-1);
+    
+    /* Truncate if name is too long */
+    if (app_name[0] > MAX_NAME )
+        app_name[0] = MAX_NAME;
+        
+    memcpy (prefs_name + 1, app_name + 1, app_name[0]);    
+    memcpy (prefs_name + app_name[0] + 1, SUFFIX, strlen (SUFFIX));
+    prefs_name[0] = app_name[0] + strlen (SUFFIX);
+   
+    /* Make the file spec for prefs file */
+    if ( noErr != FSMakeFSSpec (volume_ref_number, directory_id, prefs_name, prefs_fsp) )
+        if ( !create )
+            return 0;
+        else {
+            /* Create the prefs file */
+            memcpy (prefs_fsp->name, prefs_name, prefs_name[0] + 1);
+            prefs_fsp->parID   = directory_id;
+            prefs_fsp->vRefNum = volume_ref_number;
+                
+            FSpCreateResFile (prefs_fsp, '????', 'pref', 0);
+            
+            if ( noErr != ResError () )
+                return 0;
+        }
+      
+    return 1;
+}
+
+static int readPrefsResource (PrefsRecord *prefs) {
+    
+    Handle prefs_handle;
+    
+    prefs_handle = Get1Resource( 'CLne', 128 );
+
+	if (prefs_handle != NULL) {
+		int offset = 0;
+		int j      = 0;
+		
+		HLock(prefs_handle);
+		
+		/* Get command line string */	
+		memcpy (prefs->command_line, *prefs_handle, (*prefs_handle)[0]+1);
+
+		/* Get video driver name */
+		offset += (*prefs_handle)[0] + 1;	
+		memcpy (prefs->video_driver_name, *prefs_handle + offset, (*prefs_handle)[offset] + 1);		
+		
+		/* Get save-to-file option (1 or 0) */
+		offset += (*prefs_handle)[offset] + 1;
+		prefs->output_to_file = (*prefs_handle)[offset];
+		
+		ReleaseResource( prefs_handle );
+    
+        return ResError() == noErr;
+    }
+
+    return 0;
+}
+
+static int writePrefsResource (PrefsRecord *prefs, short resource_file) {
+
+    Handle prefs_handle;
+    
+    UseResFile (resource_file);
+    
+    prefs_handle = Get1Resource ( 'CLne', 128 );
+    if (prefs_handle != NULL)
+        RemoveResource (prefs_handle);
+    
+    prefs_handle = NewHandle ( prefs->command_line[0] + prefs->video_driver_name[0] + 4 );
+    if (prefs_handle != NULL) {
+    
+        int offset;
+        
+        HLock (prefs_handle);
+        
+        /* Command line text */
+        offset = 0;
+        memcpy (*prefs_handle, prefs->command_line, prefs->command_line[0] + 1);
+        
+        /* Video driver name */
+        offset += prefs->command_line[0] + 1;
+        memcpy (*prefs_handle + offset, prefs->video_driver_name, prefs->video_driver_name[0] + 1);
+        
+        /* Output-to-file option */
+        offset += prefs->video_driver_name[0] + 1;
+        *( *((char**)prefs_handle) + offset)     = (char)prefs->output_to_file;
+        *( *((char**)prefs_handle) + offset + 1) = 0;
+              
+        AddResource   (prefs_handle, 'CLne', 128, "\pCommand Line");
+        WriteResource (prefs_handle);
+        UpdateResFile (resource_file);
+        DisposeHandle (prefs_handle);
+        
+        return ResError() == noErr;
+    }
+    
+    return 0;
+}
+
+static int readPreferences (PrefsRecord *prefs) {
+
+    int    no_error = 1;
+    FSSpec prefs_fsp;
+
+    /* Check for prefs file first */
+    if ( getPrefsFile (&prefs_fsp, 0) ) {
+    
+        short  prefs_resource;
+        
+        prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdPerm);
+        if ( prefs_resource == -1 ) /* this shouldn't happen, but... */
+            return 0;
+    
+        UseResFile   (prefs_resource);
+        no_error = readPrefsResource (prefs);     
+        CloseResFile (prefs_resource);
+    }
+    
+    /* Fall back to application's resource fork (reading only, so this is safe) */
+    else {
+    
+          no_error = readPrefsResource (prefs);
+     }
+
+    return no_error;
+}
+
+static int writePreferences (PrefsRecord *prefs) {
+    
+    int    no_error = 1;
+    FSSpec prefs_fsp;
+    
+    /* Get prefs file, create if it doesn't exist */
+    if ( getPrefsFile (&prefs_fsp, 1) ) {
+    
+        short  prefs_resource;
+        
+        prefs_resource = FSpOpenResFile (&prefs_fsp, fsRdWrPerm);
+        if (prefs_resource == -1)
+            return 0;
+        no_error = writePrefsResource (prefs, prefs_resource);
+        CloseResFile (prefs_resource);
+    }
+    
+    return no_error;
+}
+
+/* This is where execution begins */
+int main(int argc, char *argv[])
+{
+
+#pragma unused(argc, argv)
+	
+#define DEFAULT_ARGS "\p"                /* pascal string for default args */
+#define DEFAULT_VIDEO_DRIVER "\ptoolbox" /* pascal string for default video driver name */	
+#define DEFAULT_OUTPUT_TO_FILE 1         /* 1 == output to file, 0 == no output */
+
+#define VIDEO_ID_DRAWSPROCKET 1          /* these correspond to popup menu choices */
+#define VIDEO_ID_TOOLBOX      2
+
+    PrefsRecord prefs = { DEFAULT_ARGS, DEFAULT_VIDEO_DRIVER, DEFAULT_OUTPUT_TO_FILE }; 
+	
+	int     nargs;
+	char   **args;
+	char   *commandLine;
+	
+	StrFileName  appNameText;
+	int     videodriver     = VIDEO_ID_TOOLBOX;
+    int     settingsChanged = 0;
+    
+    long	i;
+
+	/* Kyle's SDL command-line dialog code ... */
+#if !TARGET_API_MAC_CARBON
+	InitGraf    (&qd.thePort);
+	InitFonts   ();
+	InitWindows ();
+	InitMenus   ();
+	InitDialogs (nil);
+#endif
+	InitCursor ();
+	FlushEvents(everyEvent,0);
+#if !TARGET_API_MAC_CARBON
+	MaxApplZone ();
+#endif
+	MoreMasters ();
+	MoreMasters ();
+#if 0
+	/* Intialize SDL, and put up a dialog if we fail */
+	if ( SDL_Init (0) < 0 ) {
+
+#define kErr_OK		1
+#define kErr_Text	2
+
+        DialogPtr errorDialog;
+        short	  dummyType;
+    	Rect	  dummyRect;
+	    Handle    dummyHandle;
+	    short     itemHit;
+	
+		errorDialog = GetNewDialog (1001, nil, (WindowPtr)-1);
+		DrawDialog (errorDialog);
+		
+		GetDialogItem (errorDialog, kErr_Text, &dummyType, &dummyHandle, &dummyRect);
+		SetDialogItemText (dummyHandle, "\pError Initializing SDL");
+		
+		SetPort (errorDialog);
+		do {
+			ModalDialog (nil, &itemHit);
+		} while (itemHit != kErr_OK);
+		
+		DisposeDialog (errorDialog);
+		exit (-1);
+	}
+	atexit(cleanup_output);
+	atexit(SDL_Quit);
+#endif
+
+/* Set up SDL's QuickDraw environment  */
+#if !TARGET_API_MAC_CARBON
+	SDL_InitQuickDraw(&qd);
+#endif
+
+	 if ( readPreferences (&prefs) ) {
+		
+        if (memcmp (prefs.video_driver_name+1, "DSp", 3) == 0)
+            videodriver = 1;
+        else if (memcmp (prefs.video_driver_name+1, "toolbox", 7) == 0)
+            videodriver = 2;
+	 }
+	 	
+	if ( CommandKeyIsDown() ) {
+
+#define kCL_OK		1
+#define kCL_Cancel	2
+#define kCL_Text	3
+#define kCL_File	4
+#define kCL_Video   6
+       
+        DialogPtr commandDialog;
+        short	  dummyType;
+        Rect	  dummyRect;
+        Handle    dummyHandle;
+        short     itemHit;
+
+        /* Assume that they will change settings, rather than do exhaustive check */
+        settingsChanged = 1;
+        
+        /* Create dialog and display it */
+        commandDialog = GetNewDialog (1000, nil, (DialogPtr)-1);
+        SetPort (commandDialog);
+            
+        /* Setup controls */
+        GetDialogItem   (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
+        SetControlValue ((ControlHandle)dummyHandle, prefs.output_to_file );
+
+        GetDialogItem     (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect);
+        SetDialogItemText (dummyHandle, prefs.command_line);
+
+        GetDialogItem   (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect);
+        SetControlValue ((ControlRef)dummyHandle, videodriver);
+
+        SetDialogDefaultItem (commandDialog, kCL_OK);
+        SetDialogCancelItem  (commandDialog, kCL_Cancel);
+
+        do {
+        		
+        	ModalDialog(nil, &itemHit); /* wait for user response */
+            
+            /* Toggle command-line output checkbox */	
+        	if ( itemHit == kCL_File ) {
+        		GetDialogItem(commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
+        		SetControlValue((ControlHandle)dummyHandle, !GetControlValue((ControlHandle)dummyHandle) );
+        	}
+
+        } while (itemHit != kCL_OK && itemHit != kCL_Cancel);
+
+        /* Get control values, even if they did not change */
+        GetDialogItem     (commandDialog, kCL_Text, &dummyType, &dummyHandle, &dummyRect); /* MJS */
+        GetDialogItemText (dummyHandle, prefs.command_line);
+
+        GetDialogItem (commandDialog, kCL_File, &dummyType, &dummyHandle, &dummyRect); /* MJS */
+        prefs.output_to_file = GetControlValue ((ControlHandle)dummyHandle);
+
+        GetDialogItem (commandDialog, kCL_Video, &dummyType, &dummyHandle, &dummyRect);
+        videodriver = GetControlValue ((ControlRef)dummyHandle);
+
+        DisposeDialog (commandDialog);
+
+        if (itemHit == kCL_Cancel ) {
+        	exit (0);
+        }
+	}
+    
+    /* Set pseudo-environment variables for video driver, update prefs */
+	switch ( videodriver ) {
+	   case VIDEO_ID_DRAWSPROCKET: 
+	      putenv ("SDL_VIDEODRIVER=DSp");
+	      memcpy (prefs.video_driver_name, "\pDSp", 4);
+	      break;
+	   case VIDEO_ID_TOOLBOX:
+	      putenv ("SDL_VIDEODRIVER=toolbox");
+	      memcpy (prefs.video_driver_name, "\ptoolbox", 8);
+	      break;
+	}
+
+    /* Redirect standard I/O to files */
+	if ( prefs.output_to_file ) {
+		freopen (STDOUT_FILE, "w", stdout);
+		freopen (STDERR_FILE, "w", stderr);
+	} else {
+		fclose (stdout);
+		fclose (stderr);
+	}
+   
+    if (settingsChanged) {
+        /* Save the prefs, even if they might not have changed (but probably did) */
+        if ( ! writePreferences (&prefs) )
+            fprintf (stderr, "WARNING: Could not save preferences!\n");
+    }
+   
+    getCurrentAppName (appNameText); /* check for error here ? */
+
+    commandLine = (char*) malloc (appNameText[0] + prefs.command_line[0] + 2);
+    if ( commandLine == NULL ) {
+       exit(-1);
+    }
+
+    /* Rather than rewrite ParseCommandLine method, let's replace  */
+    /* any spaces in application name with underscores,            */
+    /* so that the app name is only 1 argument                     */   
+    for (i = 1; i < 1+appNameText[0]; i++)
+        if ( appNameText[i] == ' ' ) appNameText[i] = '_';
+
+    /* Copy app name & full command text to command-line C-string */      
+    memcpy (commandLine, appNameText + 1, appNameText[0]);
+    commandLine[appNameText[0]] = ' ';
+    memcpy (commandLine + appNameText[0] + 1, prefs.command_line + 1, prefs.command_line[0]);
+    commandLine[ appNameText[0] + 1 + prefs.command_line[0] ] = '\0';
+
+    /* Parse C-string into argv and argc */
+    nargs = ParseCommandLine (commandLine, NULL);
+    args = (char **)malloc((nargs+1)*(sizeof *args));
+    if ( args == NULL ) {
+		exit(-1);
+	}
+	ParseCommandLine (commandLine, args);
+        
+	/* Run the main application code */
+	SDL_main(nargs, args);
+	free (args);
+	free (commandLine);
+   
+   	/* Remove useless stdout.txt and stderr.txt */
+   	cleanup_output ();
+   	
+	/* Exit cleanly, calling atexit() functions */
+	exit (0);    
+
+	/* Never reached, but keeps the compiler quiet */
+	return (0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/SIZE.r	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,24 @@
+
+#include "Processes.r"
+
+resource 'SIZE' (-1) {
+	reserved,
+	acceptSuspendResumeEvents,
+	reserved,
+	canBackground,
+	doesActivateOnFGSwitch,
+	backgroundAndForeground,
+	getFrontClicks,
+	ignoreAppDiedEvents,
+	is32BitCompatible,
+	isHighLevelEventAware,
+	onlyLocalHLEvents,
+	notStationeryAware,
+	useTextEditServices,
+	reserved,
+	reserved,
+	reserved,
+	5242880,		// 5 megs minimum
+	5242880			// 5 megs maximum
+};
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/exports/Makefile	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+
+EXPORTS = SDL.x
+HEADERS = \
+	../../../../include/SDL.h \
+	../../../../include/SDL_active.h \
+	../../../../include/SDL_audio.h \
+	../../../../include/SDL_byteorder.h \
+	../../../../include/SDL_cdrom.h \
+	../../../../include/SDL_copying.h \
+	../../../../include/SDL_endian.h \
+	../../../../include/SDL_error.h \
+	../../../../include/SDL_events.h \
+	../../../../include/SDL_getenv.h \
+	../../../../include/SDL_joystick.h \
+	../../../../include/SDL_keyboard.h \
+	../../../../include/SDL_keysym.h \
+	../../../../include/SDL_mouse.h \
+	../../../../include/SDL_mutex.h \
+	../../../../include/SDL_quit.h \
+	../../../../include/SDL_rwops.h \
+	../../../../include/SDL_syswm.h \
+	../../../../include/SDL_thread.h \
+	../../../../include/SDL_timer.h \
+	../../../../include/SDL_types.h \
+	../../../../include/SDL_version.h \
+	../../../../include/SDL_video.h
+
+
+all: $(EXPORTS)
+
+$(EXPORTS): $(HEADERS)
+	perl gendef.pl $(HEADERS) >$@ || rm $@
+
+clean:
+	rm -f $(EXPORTS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/exports/SDL.x	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,177 @@
+	SDL_Init
+	SDL_InitSubSystem
+	SDL_QuitSubSystem
+	SDL_WasInit
+	SDL_Quit
+	SDL_GetAppState
+	SDL_AudioInit
+	SDL_AudioQuit
+	SDL_AudioDriverName
+	SDL_OpenAudio
+	SDL_GetAudioStatus
+	SDL_PauseAudio
+	SDL_LoadWAV_RW
+	SDL_FreeWAV
+	SDL_BuildAudioCVT
+	SDL_ConvertAudio
+	SDL_MixAudio
+	SDL_LockAudio
+	SDL_UnlockAudio
+	SDL_CloseAudio
+	SDL_CDNumDrives
+	SDL_CDName
+	SDL_CDOpen
+	SDL_CDStatus
+	SDL_CDPlayTracks
+	SDL_CDPlay
+	SDL_CDPause
+	SDL_CDResume
+	SDL_CDStop
+	SDL_CDEject
+	SDL_CDClose
+	SDL_ReadLE16
+	SDL_ReadBE16
+	SDL_ReadLE32
+	SDL_ReadBE32
+	SDL_ReadLE64
+	SDL_ReadBE64
+	SDL_WriteLE16
+	SDL_WriteBE16
+	SDL_WriteLE32
+	SDL_WriteBE32
+	SDL_WriteLE64
+	SDL_WriteBE64
+	SDL_SetError
+	SDL_GetError
+	SDL_ClearError
+	SDL_PumpEvents
+	SDL_PeepEvents
+	SDL_PollEvent
+	SDL_WaitEvent
+	SDL_PushEvent
+	SDL_SetEventFilter
+	SDL_GetEventFilter
+	SDL_EventState
+	SDL_putenv
+	SDL_getenv
+	SDL_NumJoysticks
+	SDL_JoystickName
+	SDL_JoystickOpen
+	SDL_JoystickOpened
+	SDL_JoystickIndex
+	SDL_JoystickNumAxes
+	SDL_JoystickNumBalls
+	SDL_JoystickNumHats
+	SDL_JoystickNumButtons
+	SDL_JoystickUpdate
+	SDL_JoystickEventState
+	SDL_JoystickGetAxis
+	SDL_JoystickGetHat
+	SDL_JoystickGetBall
+	SDL_JoystickGetButton
+	SDL_JoystickClose
+	SDL_EnableUNICODE
+	SDL_EnableKeyRepeat
+	SDL_GetKeyState
+	SDL_GetModState
+	SDL_SetModState
+	SDL_GetKeyName
+	SDL_GetMouseState
+	SDL_GetRelativeMouseState
+	SDL_WarpMouse
+	SDL_CreateCursor
+	SDL_SetCursor
+	SDL_GetCursor
+	SDL_FreeCursor
+	SDL_ShowCursor
+	SDL_CreateMutex
+	SDL_mutexP
+	SDL_mutexV
+	SDL_DestroyMutex
+	SDL_CreateSemaphore
+	SDL_DestroySemaphore
+	SDL_SemWait
+	SDL_SemTryWait
+	SDL_SemWaitTimeout
+	SDL_SemPost
+	SDL_SemValue
+	SDL_CreateCond
+	SDL_DestroyCond
+	SDL_CondSignal
+	SDL_CondBroadcast
+	SDL_CondWait
+	SDL_CondWaitTimeout
+	SDL_RWFromFile
+	SDL_RWFromFP
+	SDL_RWFromMem
+	SDL_AllocRW
+	SDL_FreeRW
+	SDL_GetWMInfo
+	SDL_CreateThread
+	SDL_ThreadID
+	SDL_GetThreadID
+	SDL_WaitThread
+	SDL_KillThread
+	SDL_GetTicks
+	SDL_Delay
+	SDL_SetTimer
+	SDL_AddTimer
+	SDL_RemoveTimer
+	SDL_Linked_Version
+	SDL_VideoInit
+	SDL_VideoQuit
+	SDL_VideoDriverName
+	SDL_GetVideoSurface
+	SDL_GetVideoInfo
+	SDL_VideoModeOK
+	SDL_ListModes
+	SDL_SetVideoMode
+	SDL_UpdateRects
+	SDL_UpdateRect
+	SDL_Flip
+	SDL_SetGamma
+	SDL_SetGammaRamp
+	SDL_GetGammaRamp
+	SDL_SetColors
+	SDL_SetPalette
+	SDL_MapRGB
+	SDL_MapRGBA
+	SDL_GetRGB
+	SDL_GetRGBA
+	SDL_CreateRGBSurface
+	SDL_CreateRGBSurfaceFrom
+	SDL_FreeSurface
+	SDL_LockSurface
+	SDL_UnlockSurface
+	SDL_LoadBMP_RW
+	SDL_SaveBMP_RW
+	SDL_SetColorKey
+	SDL_SetAlpha
+	SDL_SetClipRect
+	SDL_GetClipRect
+	SDL_ConvertSurface
+	SDL_UpperBlit
+	SDL_LowerBlit
+	SDL_FillRect
+	SDL_DisplayFormat
+	SDL_DisplayFormatAlpha
+	SDL_CreateYUVOverlay
+	SDL_LockYUVOverlay
+	SDL_UnlockYUVOverlay
+	SDL_DisplayYUVOverlay
+	SDL_FreeYUVOverlay
+	SDL_GL_LoadLibrary
+	SDL_GL_GetProcAddress
+	SDL_GL_SetAttribute
+	SDL_GL_GetAttribute
+	SDL_GL_SwapBuffers
+	SDL_GL_UpdateRects
+	SDL_GL_Lock
+	SDL_GL_Unlock
+	SDL_WM_SetCaption
+	SDL_WM_GetCaption
+	SDL_WM_SetIcon
+	SDL_WM_IconifyWindow
+	SDL_WM_ToggleFullScreen
+	SDL_WM_GrabInput
+	SDL_InitQuickDraw
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/macos/exports/gendef.pl	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+#
+# Program to take a set of header files and generate DLL export definitions
+
+while ( ($file = shift(@ARGV)) ) {
+	if ( ! defined(open(FILE, $file)) ) {
+		warn "Couldn't open $file: $!\n";
+		next;
+	}
+	$printed_header = 0;
+	$file =~ s,.*/,,;
+	while (<FILE>) {
+		if ( /DECLSPEC.*\s\**([^\s\(]+)\(/ ) {
+			print "\t$1\n";
+		} elsif ( /DECLSPEC.*\s\**([^\s\(]+)$/ ) {
+			print "\t$1\n";
+		}
+	}
+	close(FILE);
+}
+# Special exports not in the header files
+print "\tSDL_InitQuickDraw\n";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/win32/SDL_main.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,242 @@
+/*
+    SDL_main.c, placed in the public domain by Sam Lantinga  4/13/98
+
+    The WinMain function -- calls your program's main() function 
+*/
+
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+#include <stdlib.h>
+
+#include <windows.h>
+#include <malloc.h>		/* For _alloca() */
+
+/* Include the SDL main definition header */
+#include "SDL.h"
+#include "SDL_main.h"
+#ifdef main
+#undef main
+#endif
+
+/* The standard output files */
+#define STDOUT_FILE	"stdout.txt"
+#define STDERR_FILE	"stderr.txt"
+
+/* Parse a command line buffer into arguments */
+static int ParseCommandLine(char *cmdline, char **argv)
+{
+	char *bufp;
+	int argc;
+
+	argc = 0;
+	for ( bufp = cmdline; *bufp; ) {
+		/* Skip leading whitespace */
+		while ( isspace(*bufp) ) {
+			++bufp;
+		}
+		/* Skip over argument */
+		if ( *bufp == '"' ) {
+			++bufp;
+			if ( *bufp ) {
+				if ( argv ) {
+					argv[argc] = bufp;
+				}
+				++argc;
+			}
+			/* Skip over word */
+			while ( *bufp && (*bufp != '"') ) {
+				++bufp;
+			}
+		} else {
+			if ( *bufp ) {
+				if ( argv ) {
+					argv[argc] = bufp;
+				}
+				++argc;
+			}
+			/* Skip over word */
+			while ( *bufp && ! isspace(*bufp) ) {
+				++bufp;
+			}
+		}
+		if ( *bufp ) {
+			if ( argv ) {
+				*bufp = '\0';
+			}
+			++bufp;
+		}
+	}
+	if ( argv ) {
+		argv[argc] = NULL;
+	}
+	return(argc);
+}
+
+/* Show an error message */
+static void ShowError(const char *title, const char *message)
+{
+/* If USE_MESSAGEBOX is defined, you need to link with user32.lib */
+#ifdef USE_MESSAGEBOX
+	MessageBox(NULL, message, title, MB_ICONEXCLAMATION|MB_OK);
+#else
+	fprintf(stderr, "%s: %s\n", title, message);
+#endif
+}
+
+/* Pop up an out of memory message, returns to Windows */
+static BOOL OutOfMemory(void)
+{
+	ShowError("Fatal Error", "Out of memory - aborting");
+	return FALSE;
+}
+
+/* Remove the output files if there was no output written */
+static void cleanup_output(void)
+{
+	FILE *file;
+	int empty;
+
+	/* Flush the output in case anything is queued */
+	fclose(stdout);
+	fclose(stderr);
+
+	/* See if the files have any output in them */
+	file = fopen(STDOUT_FILE, "rb");
+	if ( file ) {
+		empty = (fgetc(file) == EOF) ? 1 : 0;
+		fclose(file);
+		if ( empty ) {
+			remove(STDOUT_FILE);
+		}
+	}
+	file = fopen(STDERR_FILE, "rb");
+	if ( file ) {
+		empty = (fgetc(file) == EOF) ? 1 : 0;
+		fclose(file);
+		if ( empty ) {
+			remove(STDERR_FILE);
+		}
+	}
+}
+
+#ifdef _MSC_VER /* The VC++ compiler needs main defined */
+#define console_main main
+#endif
+
+/* This is where execution begins [console apps] */
+int console_main(int argc, char *argv[])
+{
+	int n;
+	char *bufp, *appname;
+
+	/* Get the class name from argv[0] */
+	appname = argv[0];
+	if ( (bufp=strrchr(argv[0], '\\')) != NULL ) {
+		appname = bufp+1;
+	} else
+	if ( (bufp=strrchr(argv[0], '/')) != NULL ) {
+		appname = bufp+1;
+	}
+
+	if ( (bufp=strrchr(appname, '.')) == NULL )
+		n = strlen(appname);
+	else
+		n = (bufp-appname);
+
+	bufp = (char *)alloca(n+1);
+	if ( bufp == NULL ) {
+		return OutOfMemory();
+	}
+	strncpy(bufp, appname, n);
+	bufp[n] = '\0';
+	appname = bufp;
+
+	/* Load SDL dynamic link library */
+	if ( SDL_Init(SDL_INIT_NOPARACHUTE) < 0 ) {
+		ShowError("WinMain() error", SDL_GetError());
+		return(FALSE);
+	}
+	atexit(cleanup_output);
+	atexit(SDL_Quit);
+
+	/* Create and register our class, then run main code */
+	if ( SDL_RegisterApp(appname, CS_BYTEALIGNCLIENT, 
+	                     GetModuleHandle(NULL)) < 0 ) {
+		ShowError("WinMain() error", SDL_GetError());
+		exit(1);
+	}
+	SDL_main(argc, argv);
+
+	/* Exit cleanly, calling atexit() functions */
+	exit(0);
+}
+
+/* This is where execution begins [windowed apps] */
+int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR szCmdLine, int sw)
+{
+	HINSTANCE handle;
+	char **argv;
+	int argc;
+	char *cmdline;
+	char *bufp;
+#ifndef NO_STDIO_REDIRECT
+	FILE *newfp;
+#endif
+
+	/* Start up DDHELP.EXE before opening any files, so DDHELP doesn't
+	   keep them open.  This is a hack.. hopefully it will be fixed 
+	   someday.  DDHELP.EXE starts up the first time DDRAW.DLL is loaded.
+	 */
+	handle = LoadLibrary("DDRAW.DLL");
+	if ( handle != NULL ) {
+		FreeLibrary(handle);
+	}
+
+#ifndef NO_STDIO_REDIRECT
+	/* Redirect standard input and standard output */
+	newfp = freopen(STDOUT_FILE, "w", stdout);
+	if ( newfp == NULL ) {	/* This happens on NT */
+#if !defined(stdout)
+		stdout = fopen(STDOUT_FILE, "w");
+#else
+		newfp = fopen(STDOUT_FILE, "w");
+		if ( newfp ) {
+			*stdout = *newfp;
+		}
+#endif
+	}
+	newfp = freopen(STDERR_FILE, "w", stderr);
+	if ( newfp == NULL ) {	/* This happens on NT */
+#if !defined(stderr)
+		stderr = fopen(STDERR_FILE, "w");
+#else
+		newfp = fopen(STDERR_FILE, "w");
+		if ( newfp ) {
+			*stderr = *newfp;
+		}
+#endif
+	}
+	setvbuf(stdout, NULL, _IOLBF, BUFSIZ);	/* Line buffered */
+	setbuf(stderr, NULL);			/* No buffering */
+#endif /* !NO_STDIO_REDIRECT */
+
+	/* Grab the command line (use alloca() on Windows) */
+	bufp = GetCommandLine();
+	cmdline = (char *)alloca(strlen(bufp)+1);
+	if ( cmdline == NULL ) {
+		return OutOfMemory();
+	}
+	strcpy(cmdline, bufp);
+
+	/* Parse it into argv and argc */
+	argc = ParseCommandLine(cmdline, NULL);
+	argv = (char **)alloca((argc+1)*(sizeof *argv));
+	if ( argv == NULL ) {
+		return OutOfMemory();
+	}
+	ParseCommandLine(cmdline, argv);
+
+	/* Run the main program (after a little SDL initialization) */
+	return(console_main(argc, argv));
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/win32/exports/Makefile	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+
+EXPORTS = SDL.def
+HEADERS = \
+	../../../../include/SDL.h \
+	../../../../include/SDL_active.h \
+	../../../../include/SDL_audio.h \
+	../../../../include/SDL_byteorder.h \
+	../../../../include/SDL_cdrom.h \
+	../../../../include/SDL_copying.h \
+	../../../../include/SDL_endian.h \
+	../../../../include/SDL_error.h \
+	../../../../include/SDL_events.h \
+	../../../../include/SDL_joystick.h \
+	../../../../include/SDL_keyboard.h \
+	../../../../include/SDL_keysym.h \
+	../../../../include/SDL_main.h \
+	../../../../include/SDL_mouse.h \
+	../../../../include/SDL_mutex.h \
+	../../../../include/SDL_quit.h \
+	../../../../include/SDL_rwops.h \
+	../../../../include/SDL_syswm.h \
+	../../../../include/SDL_thread.h \
+	../../../../include/SDL_timer.h \
+	../../../../include/SDL_types.h \
+	../../../../include/SDL_version.h \
+	../../../../include/SDL_video.h
+
+
+all: $(EXPORTS)
+
+$(EXPORTS): $(HEADERS)
+	perl gendef.pl $(HEADERS) >$@ || rm $@
+
+clean:
+	rm -f $(EXPORTS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/win32/exports/SDL.def	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,177 @@
+	SDL_Init
+	SDL_InitSubSystem
+	SDL_QuitSubSystem
+	SDL_WasInit
+	SDL_Quit
+	SDL_GetAppState
+	SDL_AudioInit
+	SDL_AudioQuit
+	SDL_AudioDriverName
+	SDL_OpenAudio
+	SDL_GetAudioStatus
+	SDL_PauseAudio
+	SDL_LoadWAV_RW
+	SDL_FreeWAV
+	SDL_BuildAudioCVT
+	SDL_ConvertAudio
+	SDL_MixAudio
+	SDL_LockAudio
+	SDL_UnlockAudio
+	SDL_CloseAudio
+	SDL_CDNumDrives
+	SDL_CDName
+	SDL_CDOpen
+	SDL_CDStatus
+	SDL_CDPlayTracks
+	SDL_CDPlay
+	SDL_CDPause
+	SDL_CDResume
+	SDL_CDStop
+	SDL_CDEject
+	SDL_CDClose
+	SDL_ReadLE16
+	SDL_ReadBE16
+	SDL_ReadLE32
+	SDL_ReadBE32
+	SDL_ReadLE64
+	SDL_ReadBE64
+	SDL_WriteLE16
+	SDL_WriteBE16
+	SDL_WriteLE32
+	SDL_WriteBE32
+	SDL_WriteLE64
+	SDL_WriteBE64
+	SDL_SetError
+	SDL_GetError
+	SDL_ClearError
+	SDL_PumpEvents
+	SDL_PeepEvents
+	SDL_PollEvent
+	SDL_WaitEvent
+	SDL_PushEvent
+	SDL_SetEventFilter
+	SDL_GetEventFilter
+	SDL_EventState
+	SDL_NumJoysticks
+	SDL_JoystickName
+	SDL_JoystickOpen
+	SDL_JoystickOpened
+	SDL_JoystickIndex
+	SDL_JoystickNumAxes
+	SDL_JoystickNumBalls
+	SDL_JoystickNumHats
+	SDL_JoystickNumButtons
+	SDL_JoystickUpdate
+	SDL_JoystickEventState
+	SDL_JoystickGetAxis
+	SDL_JoystickGetHat
+	SDL_JoystickGetBall
+	SDL_JoystickGetButton
+	SDL_JoystickClose
+	SDL_EnableUNICODE
+	SDL_EnableKeyRepeat
+	SDL_GetKeyState
+	SDL_GetModState
+	SDL_SetModState
+	SDL_GetKeyName
+	SDL_RegisterApp
+	SDL_InitQuickDraw
+	SDL_GetMouseState
+	SDL_GetRelativeMouseState
+	SDL_WarpMouse
+	SDL_CreateCursor
+	SDL_SetCursor
+	SDL_GetCursor
+	SDL_FreeCursor
+	SDL_ShowCursor
+	SDL_CreateMutex
+	SDL_mutexP
+	SDL_mutexV
+	SDL_DestroyMutex
+	SDL_CreateSemaphore
+	SDL_DestroySemaphore
+	SDL_SemWait
+	SDL_SemTryWait
+	SDL_SemWaitTimeout
+	SDL_SemPost
+	SDL_SemValue
+	SDL_CreateCond
+	SDL_DestroyCond
+	SDL_CondSignal
+	SDL_CondBroadcast
+	SDL_CondWait
+	SDL_CondWaitTimeout
+	SDL_RWFromFile
+	SDL_RWFromFP
+	SDL_RWFromMem
+	SDL_AllocRW
+	SDL_FreeRW
+	SDL_GetWMInfo
+	SDL_CreateThread
+	SDL_ThreadID
+	SDL_GetThreadID
+	SDL_WaitThread
+	SDL_KillThread
+	SDL_GetTicks
+	SDL_Delay
+	SDL_SetTimer
+	SDL_AddTimer
+	SDL_RemoveTimer
+	SDL_Linked_Version
+	SDL_VideoInit
+	SDL_VideoQuit
+	SDL_VideoDriverName
+	SDL_GetVideoSurface
+	SDL_GetVideoInfo
+	SDL_VideoModeOK
+	SDL_ListModes
+	SDL_SetVideoMode
+	SDL_UpdateRects
+	SDL_UpdateRect
+	SDL_Flip
+	SDL_SetGamma
+	SDL_SetGammaRamp
+	SDL_GetGammaRamp
+	SDL_SetColors
+	SDL_SetPalette
+	SDL_MapRGB
+	SDL_MapRGBA
+	SDL_GetRGB
+	SDL_GetRGBA
+	SDL_CreateRGBSurface
+	SDL_CreateRGBSurfaceFrom
+	SDL_FreeSurface
+	SDL_LockSurface
+	SDL_UnlockSurface
+	SDL_LoadBMP_RW
+	SDL_SaveBMP_RW
+	SDL_SetColorKey
+	SDL_SetAlpha
+	SDL_SetClipRect
+	SDL_GetClipRect
+	SDL_ConvertSurface
+	SDL_UpperBlit
+	SDL_LowerBlit
+	SDL_FillRect
+	SDL_DisplayFormat
+	SDL_DisplayFormatAlpha
+	SDL_CreateYUVOverlay
+	SDL_LockYUVOverlay
+	SDL_UnlockYUVOverlay
+	SDL_DisplayYUVOverlay
+	SDL_FreeYUVOverlay
+	SDL_GL_LoadLibrary
+	SDL_GL_GetProcAddress
+	SDL_GL_SetAttribute
+	SDL_GL_GetAttribute
+	SDL_GL_SwapBuffers
+	SDL_GL_UpdateRects
+	SDL_GL_Lock
+	SDL_GL_Unlock
+	SDL_WM_SetCaption
+	SDL_WM_GetCaption
+	SDL_WM_SetIcon
+	SDL_WM_IconifyWindow
+	SDL_WM_ToggleFullScreen
+	SDL_WM_GrabInput
+	SDL_RegisterApp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/win32/exports/gendef.pl	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,22 @@
+#!/usr/bin/perl
+#
+# Program to take a set of header files and generate DLL export definitions
+
+while ( ($file = shift(@ARGV)) ) {
+	if ( ! defined(open(FILE, $file)) ) {
+		warn "Couldn't open $file: $!\n";
+		next;
+	}
+	$printed_header = 0;
+	$file =~ s,.*/,,;
+	while (<FILE>) {
+		if ( /DECLSPEC.*\s\**([^\s\(]+)\(/ ) {
+			print "\t$1\n";
+		} elsif ( /DECLSPEC.*\s\**([^\s\(]+)$/ ) {
+			print "\t$1\n";
+		}
+	}
+	close(FILE);
+}
+# Special exports not in the header files
+print "\tSDL_RegisterApp\n";
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+Makefile.in
+SDL_mutex.c
+SDL_systhread.c
+SDL_systhread_c.h
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,43 @@
+
+## Makefile.am for the SDL thread library
+
+noinst_LTLIBRARIES = libthread.la
+
+ARCH_SUBDIRS = generic amigaos beos irix linux win32
+
+# Older versions of Linux require an asm clone() implementation
+if USE_CLONE
+THREAD_ASM_SRC = clone.S
+else
+THREAD_ASM_SRC =
+endif
+
+COMMON_SRCS =			\
+	SDL_systhread.h		\
+	SDL_thread.c		\
+	SDL_thread_c.h
+ARCH_SRCS = 			\
+	SDL_systhread.c		\
+	SDL_systhread_c.h	\
+	SDL_sysmutex.c		\
+	SDL_sysmutex_c.h	\
+	SDL_syssem.c		\
+	SDL_syssem_c.h		\
+	SDL_syscond.c		\
+	SDL_syscond_c.h		\
+	$(THREAD_ASM_SRC)
+
+libthread_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
+
+## Let automake know that it shouldn't distribute linked sources
+BUILT_SOURCES = $(ARCH_SRCS)
+
+## Let automake know that it should remove these for distribution
+DISTCLEANFILES = $(ARCH_SRCS)
+
+# The architecture specific directories need to be copied into place
+# when building a distribution.
+dist-hook:
+	(cd $(distdir) && rm -f $(BUILT_SOURCES))
+	cp -rp $(ARCH_SUBDIRS) $(distdir)
+	(cd $(distdir) && rm -rf `find . -name CVS`)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/SDL_systhread.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* These are functions that need to be implemented by a port of SDL */
+
+#include "SDL_thread_c.h"
+
+/* This function creates a thread, passing args to SDL_RunThread(),
+   saves a system-dependent thread id in thread->id, and returns 0
+   on success.
+*/
+extern int SDL_SYS_CreateThread(SDL_Thread *thread, void *args);
+
+/* This function does any necessary setup in the child thread */
+extern void SDL_SYS_SetupThread(void);
+
+/* This function waits for the thread to finish and frees any data
+   allocated by SDL_SYS_CreateThread()
+ */
+extern void SDL_SYS_WaitThread(SDL_Thread *thread);
+
+/* This function kills the thread and returns */
+extern void SDL_SYS_KillThread(SDL_Thread *thread);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/SDL_thread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,300 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* System independent thread management routines for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+#include "SDL_thread_c.h"
+#include "SDL_systhread.h"
+
+#define ARRAY_CHUNKSIZE	32
+/* The array of threads currently active in the application
+   (except the main thread)
+   The manipulation of an array here is safer than using a linked list.
+*/
+static int SDL_maxthreads = 0;
+static int SDL_numthreads = 0;
+static SDL_Thread **SDL_Threads = NULL;
+static SDL_mutex *thread_lock = NULL;
+int _creating_thread_lock = 0;
+
+int SDL_ThreadsInit(void)
+{
+	int retval;
+
+	retval = 0;
+	/* Set the thread lock creation flag so that we can reuse an
+	   existing lock on the system - since this mutex never gets
+	   destroyed (see SDL_ThreadsQuit()), we want to reuse it.
+	*/
+	_creating_thread_lock = 1;
+	thread_lock = SDL_CreateMutex();
+	_creating_thread_lock = 0;
+	if ( thread_lock == NULL ) {
+		retval = -1;
+	}
+	return(retval);
+}
+
+/* This should never be called...
+   If this is called by SDL_Quit(), we don't know whether or not we should
+   clean up threads here.  If any threads are still running after this call,
+   they will no longer have access to any per-thread data.
+ */
+void SDL_ThreadsQuit()
+{
+	SDL_mutex *mutex;
+
+	mutex = thread_lock;
+	thread_lock = NULL;
+	if ( mutex != NULL ) {
+		SDL_DestroyMutex(mutex);
+	}
+}
+
+/* Routines for manipulating the thread list */
+static void SDL_AddThread(SDL_Thread *thread)
+{
+	SDL_Thread **threads;
+
+	/* WARNING:
+	   If the very first threads are created simultaneously, then
+	   there could be a race condition causing memory corruption.
+	   In practice, this isn't a problem because by definition there
+	   is only one thread running the first time this is called.
+	*/
+	if ( thread_lock == NULL ) {
+		if ( SDL_ThreadsInit() < 0 ) {
+			return;
+		}
+	}
+	SDL_mutexP(thread_lock);
+
+	/* Expand the list of threads, if necessary */
+#ifdef DEBUG_THREADS
+	printf("Adding thread (%d already - %d max)\n",
+			SDL_numthreads, SDL_maxthreads);
+#endif
+	if ( SDL_numthreads == SDL_maxthreads ) {
+		threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
+		                              (sizeof *threads));
+		if ( threads == NULL ) {
+			SDL_OutOfMemory();
+			goto done;
+		}
+		memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
+		SDL_maxthreads += ARRAY_CHUNKSIZE;
+		if ( SDL_Threads ) {
+			free(SDL_Threads);
+		}
+		SDL_Threads = threads;
+	}
+	SDL_Threads[SDL_numthreads++] = thread;
+done:
+	SDL_mutexV(thread_lock);
+}
+
+static void SDL_DelThread(SDL_Thread *thread)
+{
+	int i;
+
+	if ( thread_lock ) {
+		SDL_mutexP(thread_lock);
+		for ( i=0; i<SDL_numthreads; ++i ) {
+			if ( thread == SDL_Threads[i] ) {
+				break;
+			}
+		}
+		if ( i < SDL_numthreads ) {
+			--SDL_numthreads;
+			while ( i < SDL_numthreads ) {
+				SDL_Threads[i] = SDL_Threads[i+1];
+				++i;
+			}
+#ifdef DEBUG_THREADS
+			printf("Deleting thread (%d left - %d max)\n",
+					SDL_numthreads, SDL_maxthreads);
+#endif
+		}
+		SDL_mutexV(thread_lock);
+	}
+}
+
+/* The default (non-thread-safe) global error variable */
+static SDL_error SDL_global_error;
+
+/* Routine to get the thread-specific error variable */
+SDL_error *SDL_GetErrBuf(void)
+{
+	SDL_error *errbuf;
+
+	errbuf = &SDL_global_error;
+	if ( SDL_Threads ) {
+		int i;
+		Uint32 this_thread;
+
+		this_thread = SDL_ThreadID();
+		SDL_mutexP(thread_lock);
+		for ( i=0; i<SDL_numthreads; ++i ) {
+			if ( this_thread == SDL_Threads[i]->threadid ) {
+				errbuf = &SDL_Threads[i]->errbuf;
+				break;
+			}
+		}
+		SDL_mutexV(thread_lock);
+	}
+	return(errbuf);
+}
+
+
+/* Arguments and callback to setup and run the user thread function */
+typedef struct {
+	int (*func)(void *);
+	void *data;
+	SDL_Thread *info;
+	SDL_sem *wait;
+} thread_args;
+
+void SDL_RunThread(void *data)
+{
+	thread_args *args;
+	int (*userfunc)(void *);
+	void *userdata;
+	int *statusloc;
+
+	/* Perform any system-dependent setup
+	   - this function cannot fail, and cannot use SDL_SetError()
+	 */
+	SDL_SYS_SetupThread();
+
+	/* Get the thread id */
+	args = (thread_args *)data;
+	args->info->threadid = SDL_ThreadID();
+
+	/* Figure out what function to run */
+	userfunc = args->func;
+	userdata = args->data;
+	statusloc = &args->info->status;
+
+	/* Wake up the parent thread */
+	SDL_SemPost(args->wait);
+
+	/* Run the function */
+	*statusloc = userfunc(userdata);
+}
+
+SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
+{
+	SDL_Thread *thread;
+	thread_args *args;
+	int ret;
+
+	/* Allocate memory for the thread info structure */
+	thread = (SDL_Thread *)malloc(sizeof(*thread));
+	if ( thread == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(thread, 0, (sizeof *thread));
+	thread->status = -1;
+
+	/* Set up the arguments for the thread */
+	args = (thread_args *)malloc(sizeof(*args));
+	if ( args == NULL ) {
+		SDL_OutOfMemory();
+		free(thread);
+		return(NULL);
+	}
+	args->func = fn;
+	args->data = data;
+	args->info = thread;
+	args->wait = SDL_CreateSemaphore(0);
+	if ( args->wait == NULL ) {
+		free(thread);
+		free(args);
+		return(NULL);
+	}
+
+	/* Add the thread to the list of available threads */
+	SDL_AddThread(thread);
+
+	/* Create the thread and go! */
+	ret = SDL_SYS_CreateThread(thread, args);
+	if ( ret >= 0 ) {
+		/* Wait for the thread function to use arguments */
+		SDL_SemWait(args->wait);
+	} else {
+		/* Oops, failed.  Gotta free everything */
+		SDL_DelThread(thread);
+		free(thread);
+		thread = NULL;
+	}
+	SDL_DestroySemaphore(args->wait);
+	free(args);
+
+	/* Everything is running now */
+	return(thread);
+}
+
+void SDL_WaitThread(SDL_Thread *thread, int *status)
+{
+	if ( thread ) {
+		SDL_SYS_WaitThread(thread);
+		if ( status ) {
+			*status = thread->status;
+		}
+		SDL_DelThread(thread);
+		free(thread);
+	}
+}
+
+Uint32 SDL_GetThreadID(SDL_Thread *thread)
+{
+	Uint32 id;
+
+	if ( thread ) {
+		id = thread->threadid;
+	} else {
+		id = SDL_ThreadID();
+	}
+	return(id);
+}
+
+void SDL_KillThread(SDL_Thread *thread)
+{
+	if ( thread ) {
+		SDL_SYS_KillThread(thread);
+		SDL_WaitThread(thread, NULL);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/SDL_thread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_thread_c_h
+#define _SDL_thread_c_h
+
+#include "SDL_error_c.h"
+#include "SDL_systhread_c.h"
+
+/* This is the system-independent thread info structure */
+struct SDL_Thread {
+	Uint32 threadid;
+	SYS_ThreadHandle handle;
+	int status;
+	SDL_error errbuf;
+	void *data;
+};
+
+/* This is the function called to run a thread */
+extern void SDL_RunThread(void *data);
+
+/* Routine to get the thread-specific error variable */
+extern SDL_error *SDL_GetErrBuf(void);
+
+#endif /* _SDL_thread_c_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/amigaos/SDL_syssem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,166 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* An native implementation of semaphores on AmigaOS */
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread_c.h"
+
+
+struct SDL_semaphore
+{
+	struct SignalSemaphore Sem;
+};
+
+#undef D(x)
+
+#define D(x)
+
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_sem *sem;
+
+	sem = (SDL_sem *)malloc(sizeof(*sem));
+	if ( ! sem ) {
+		SDL_OutOfMemory();
+		return(0);
+	}
+	memset(sem, 0, sizeof(*sem));
+
+	D(bug("Creating semaphore %lx...\n",sem));
+
+	InitSemaphore(&sem->Sem);
+#if 1 // Allow multiple obtainings of the semaphore
+        while ( initial_value-- ) {
+		ReleaseSemaphore(&sem->Sem);
+	}
+#endif
+	return(sem);
+}
+
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	D(bug("Destroying semaphore %lx...\n",sem));
+
+	if ( sem ) {
+// Condizioni per liberare i task in attesa?
+		free(sem);
+	}
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	D(bug("TryWait semaphore...%lx\n",sem));
+
+	retval = SDL_MUTEX_TIMEDOUT;
+	if ( AttemptSemaphore(&sem->Sem) ) {
+		retval = 0;
+	}
+	return retval;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	D(bug("WaitTimeout (%ld) semaphore...%lx\n",timeout,sem));
+
+#if 1 // We need to keep trying the semaphore until the timeout expires
+	retval = SDL_MUTEX_TIMEDOUT;
+	then = SDL_GetTicks();
+	do {
+		if ( AttemptSemaphore(&sem->Sem) ) {
+			retval = 0;
+		}
+		now = SDL_GetTicks();
+	} while ( (retval == SDL_MUTEX_TIMEDOUT) && ((now-then) < timeout) );
+#else
+	if(!(retval=AttemptSemaphore(&sem->Sem)))
+	{
+		SDL_Delay(timeout);
+		retval=AttemptSemaphore(&sem->Sem);
+	}
+
+	if(retval==TRUE)
+	{
+//		ReleaseSemaphore(&sem->Sem);
+		retval=1;
+	}
+#endif
+	return retval;
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+#if 1 // This should be an infinite wait - FIXME, what is the return value?
+	ObtainSemaphore(&sem->Sem);
+        return 0;
+#else
+	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+#endif
+}
+
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	Uint32 value;
+	
+	value = 0;
+	if ( sem ) {
+		value = sem->Sem.ss_NestCount;
+	}
+	return value;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+	D(bug("SemPost semaphore...%lx\n",sem));
+
+	ReleaseSemaphore(&sem->Sem);
+	return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/amigaos/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,107 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* AmigaOS thread management routines for SDL */
+
+#include "SDL_error.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+#include "SDL_thread_c.h"
+#include "SDL_systhread.h"
+
+typedef struct {
+	int (*func)(void *);
+	void *data;
+	SDL_Thread *info;
+	struct Task *wait;
+} thread_args;
+
+#if defined(__SASC) && !defined(__PPC__) 
+__saveds __asm Uint32 RunThread(register __a0 char *args )
+#elif defined(__PPC__)
+Uint32 RunThread(char *args)
+#else
+Uint32 RunThread(char *args __asm("a0") )
+#endif
+{
+	thread_args *data=(thread_args *)atol(args);
+	struct Task *Father;
+
+	D(bug("Received data: %lx\n",data));
+	Father=data->wait;
+
+	SDL_RunThread(data);
+
+	Signal(Father,SIGBREAKF_CTRL_F);
+	return(0);
+}
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	/* Create the thread and go! */
+	char buffer[20];
+
+	D(bug("Sending %lx to the new thread...\n",args));
+
+	if(args)
+		sprintf(buffer,"%ld",args);
+
+
+	thread->handle=(struct Task *)CreateNewProcTags(NP_Output,Output(),
+					NP_Name,(ULONG)"SDL subtask",
+					NP_CloseOutput, FALSE,
+					NP_StackSize,20000,
+					NP_Entry,(ULONG)RunThread,
+					args ? NP_Arguments : TAG_IGNORE,(ULONG)buffer,
+					TAG_DONE);
+	if(!thread->handle)
+	{
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+}
+
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)FindTask(NULL));
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C);
+}
+
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/amigaos/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <exec/exec.h>
+#include <dos/dos.h>
+#include <dos/dostags.h>
+#ifdef __SASC
+#include <proto/dos.h>
+#include <proto/exec.h>
+#else
+#include <inline/dos.h>
+#include <inline/exec.h>
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "mydebug.h"
+
+extern struct ExecBase *SysBase;
+extern struct DosLibrary *DOSBase;
+
+#define SYS_ThreadHandle struct Task *
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/amigaos/SDL_thread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,275 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* System independent thread management routines for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+#include "SDL_thread_c.h"
+#include "SDL_systhread.h"
+
+#define ARRAY_CHUNKSIZE	32
+/* The array of threads currently active in the application
+   (except the main thread)
+   The manipulation of an array here is safer than using a linked list.
+*/
+static int SDL_maxthreads = 0;
+static int SDL_numthreads = 0;
+static SDL_Thread **SDL_Threads = NULL;
+static struct SignalSemaphore thread_lock;
+int thread_lock_created = 0;
+
+int SDL_ThreadsInit(void)
+{
+	InitSemaphore(&thread_lock);
+	thread_lock_created=1;
+	return 0;
+}
+
+/* This should never be called...
+   If this is called by SDL_Quit(), we don't know whether or not we should
+   clean up threads here.  If any threads are still running after this call,
+   they will no longer have access to any per-thread data.
+ */
+void SDL_ThreadsQuit()
+{
+	thread_lock_created=0;
+}
+
+/* Routines for manipulating the thread list */
+static void SDL_AddThread(SDL_Thread *thread)
+{
+	SDL_Thread **threads;
+
+	/* WARNING:
+	   If the very first threads are created simultaneously, then
+	   there could be a race condition causing memory corruption.
+	   In practice, this isn't a problem because by definition there
+	   is only one thread running the first time this is called.
+	*/
+	if ( !thread_lock_created ) {
+		if ( SDL_ThreadsInit() < 0 ) {
+			return;
+		}
+	}
+	ObtainSemaphore(&thread_lock);
+
+	/* Expand the list of threads, if necessary */
+#ifdef DEBUG_THREADS
+	printf("Adding thread (%d already - %d max)\n",
+			SDL_numthreads, SDL_maxthreads);
+#endif
+	if ( SDL_numthreads == SDL_maxthreads ) {
+		threads=(SDL_Thread **)malloc((SDL_maxthreads+ARRAY_CHUNKSIZE)*
+		                              (sizeof *threads));
+		if ( threads == NULL ) {
+			SDL_OutOfMemory();
+			goto done;
+		}
+		memcpy(threads, SDL_Threads, SDL_numthreads*(sizeof *threads));
+		SDL_maxthreads += ARRAY_CHUNKSIZE;
+		if ( SDL_Threads ) {
+			free(SDL_Threads);
+		}
+		SDL_Threads = threads;
+	}
+	SDL_Threads[SDL_numthreads++] = thread;
+done:
+	ReleaseSemaphore(&thread_lock);
+}
+
+static void SDL_DelThread(SDL_Thread *thread)
+{
+	int i;
+
+	if ( thread_lock_created ) {
+		ObtainSemaphore(&thread_lock);
+		for ( i=0; i<SDL_numthreads; ++i ) {
+			if ( thread == SDL_Threads[i] ) {
+				break;
+			}
+		}
+		if ( i < SDL_numthreads ) {
+			--SDL_numthreads;
+			while ( i < SDL_numthreads ) {
+				SDL_Threads[i] = SDL_Threads[i+1];
+				++i;
+			}
+#ifdef DEBUG_THREADS
+			printf("Deleting thread (%d left - %d max)\n",
+					SDL_numthreads, SDL_maxthreads);
+#endif
+		}
+		ReleaseSemaphore(&thread_lock);
+	}
+}
+
+/* The default (non-thread-safe) global error variable */
+static SDL_error SDL_global_error;
+
+/* Routine to get the thread-specific error variable */
+SDL_error *SDL_GetErrBuf(void)
+{
+	SDL_error *errbuf;
+
+	errbuf = &SDL_global_error;
+	if ( SDL_Threads ) {
+		int i;
+		Uint32 this_thread;
+
+		this_thread = SDL_ThreadID();
+		ObtainSemaphore(&thread_lock);
+		for ( i=0; i<SDL_numthreads; ++i ) {
+			if ( this_thread == SDL_Threads[i]->threadid ) {
+				errbuf = &SDL_Threads[i]->errbuf;
+				break;
+			}
+		}
+		ReleaseSemaphore(&thread_lock);
+	}
+	return(errbuf);
+}
+
+
+/* Arguments and callback to setup and run the user thread function */
+typedef struct {
+	int (*func)(void *);
+	void *data;
+	SDL_Thread *info;
+	struct Task *wait;
+} thread_args;
+
+void SDL_RunThread(void *data)
+{
+	thread_args *args;
+	int (*userfunc)(void *);
+	void *userdata;
+	int *statusloc;
+
+	/* Perform any system-dependent setup
+	   - this function cannot fail, and cannot use SDL_SetError()
+	 */
+	SDL_SYS_SetupThread();
+
+	/* Get the thread id */
+	args = (thread_args *)data;
+	args->info->threadid = SDL_ThreadID();
+
+	/* Figure out what function to run */
+	userfunc = args->func;
+	userdata = args->data;
+	statusloc = &args->info->status;
+
+	/* Wake up the parent thread */
+	Signal(args->wait,SIGBREAKF_CTRL_E);
+
+	/* Run the function */
+	*statusloc = userfunc(userdata);
+}
+
+SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data)
+{
+	SDL_Thread *thread;
+	thread_args *args;
+	int ret;
+
+	/* Allocate memory for the thread info structure */
+	thread = (SDL_Thread *)malloc(sizeof(*thread));
+	if ( thread == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(thread, 0, (sizeof *thread));
+	thread->status = -1;
+
+	/* Set up the arguments for the thread */
+	args = (thread_args *)malloc(sizeof(*args));
+	if ( args == NULL ) {
+		SDL_OutOfMemory();
+		free(thread);
+		return(NULL);
+	}
+	args->func = fn;
+	args->data = data;
+	args->info = thread;
+	args->wait = FindTask(NULL);
+	if ( args->wait == NULL ) {
+		free(thread);
+		free(args);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+
+	/* Add the thread to the list of available threads */
+	SDL_AddThread(thread);
+
+	D(bug("Starting thread...\n"));
+
+	/* Create the thread and go! */
+	ret = SDL_SYS_CreateThread(thread, args);
+	if ( ret >= 0 ) {
+		D(bug("Waiting for thread CTRL_E...\n"));
+		/* Wait for the thread function to use arguments */
+		Wait(SIGBREAKF_CTRL_E);
+		D(bug("  Arrived."));
+	} else {
+		/* Oops, failed.  Gotta free everything */
+		SDL_DelThread(thread);
+		free(thread);
+		thread = NULL;
+	}
+	free(args);
+
+	/* Everything is running now */
+	return(thread);
+}
+
+void SDL_WaitThread(SDL_Thread *thread, int *status)
+{
+	if ( thread ) {
+		SDL_SYS_WaitThread(thread);
+		if ( status ) {
+			*status = thread->status;
+		}
+		SDL_DelThread(thread);
+		free(thread);
+	}
+}
+
+void SDL_KillThread(SDL_Thread *thread)
+{
+	if ( thread ) {
+		SDL_SYS_KillThread(thread);
+		SDL_WaitThread(thread, NULL);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/beos/SDL_syssem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,141 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Semaphores in the BeOS environment */
+
+#include <be/kernel/OS.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+
+
+struct SDL_semaphore {
+	sem_id id;
+};
+
+/* Create a counting semaphore */
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_sem *sem;
+
+	sem = (SDL_sem *)malloc(sizeof(*sem));
+	if ( sem ) {
+		sem->id = create_sem(initial_value, "SDL semaphore");
+		if ( sem->id < B_NO_ERROR ) {
+			SDL_SetError("create_sem() failed");
+			free(sem);
+			sem = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return(sem);
+}
+
+/* Free the semaphore */
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	if ( sem ) {
+		if ( sem->id >= B_NO_ERROR ) {
+			delete_sem(sem->id);
+		}
+		free(sem);
+	}
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int32 val;
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+  tryagain:
+	if ( timeout == SDL_MUTEX_MAXWAIT ) {
+		val = acquire_sem(sem->id);
+	} else {
+		timeout *= 1000; /* BeOS uses a timeout in microseconds */
+		val = acquire_sem_etc(sem->id, 1, B_RELATIVE_TIMEOUT, timeout);
+	}
+	switch (val) {
+	    case B_INTERRUPTED:
+		goto tryagain;
+	    case B_NO_ERROR:
+		retval = 0;
+		break;
+	    default:
+		SDL_SetError("acquire_sem() failed");
+		retval = -1;
+		break;
+	}
+
+	return retval;
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, 0);
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+}
+
+/* Returns the current count of the semaphore */
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	int32 count;
+	Uint32 value;
+
+	value = 0;
+	if ( sem ) {
+		get_sem_count(sem->id, &count);
+		if ( count > 0 ) {
+			value = (Uint32)count;
+		}
+	}
+	return value;
+}
+
+/* Atomically increases the semaphore's count (not blocking) */
+int SDL_SemPost(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	if ( release_sem(sem->id) != B_NO_ERROR ) {
+		SDL_SetError("release_sem() failed");
+		return -1;
+	}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/beos/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,101 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* BeOS thread management routines for SDL */
+
+#include <stdio.h>
+#include <signal.h>
+#include <be/kernel/OS.h>
+
+#include "SDL_error.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+#include "SDL_thread_c.h"
+#include "SDL_systhread.h"
+
+
+static int sig_list[] = {
+	SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
+};
+
+void SDL_MaskSignals(sigset_t *omask)
+{
+	sigset_t mask;
+	int i;
+
+	sigemptyset(&mask);
+	for ( i=0; sig_list[i]; ++i ) {
+		sigaddset(&mask, sig_list[i]);
+	}
+	sigprocmask(SIG_BLOCK, &mask, omask);
+}
+void SDL_UnmaskSignals(sigset_t *omask)
+{
+	sigprocmask(SIG_SETMASK, omask, NULL);
+}
+
+static int32 RunThread(void *data)
+{
+	SDL_RunThread(data);
+	return(0);
+}
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	/* Create the thread and go! */
+	thread->handle=spawn_thread(RunThread, "SDL", B_NORMAL_PRIORITY, args);
+	if ( (thread->handle == B_NO_MORE_THREADS) ||
+	     (thread->handle == B_NO_MEMORY) ) {
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+	resume_thread(thread->handle);
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+	/* Mask asynchronous signals for this thread */
+	SDL_MaskSignals(NULL);
+}
+
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)find_thread(NULL));
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	status_t the_status;
+
+	wait_for_thread(thread->handle, &the_status);
+}
+
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	kill_thread(thread->handle);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/beos/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <signal.h>
+#include <be/kernel/OS.h>
+
+typedef thread_id SYS_ThreadHandle;
+
+/* Functions needed to work with system threads in other portions of SDL */
+extern void SDL_MaskSignals(sigset_t *omask);
+extern void SDL_UnmaskSignals(sigset_t *omask);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_syscond.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,223 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* An implementation of condition variables using semaphores and mutexes */
+/*
+   This implementation borrows heavily from the BeOS condition variable
+   implementation, written by Christopher Tate and Owen Smith.  Thanks!
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+
+struct SDL_cond
+{
+	SDL_mutex *lock;
+	int waiting;
+	int signals;
+	SDL_sem *wait_sem;
+	SDL_sem *wait_done;
+};
+
+/* Create a condition variable */
+SDL_cond * SDL_CreateCond(void)
+{
+	SDL_cond *cond;
+
+	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
+	if ( cond ) {
+		cond->lock = SDL_CreateMutex();
+		cond->wait_sem = SDL_CreateSemaphore(0);
+		cond->wait_done = SDL_CreateSemaphore(0);
+		cond->waiting = cond->signals = 0;
+		if ( ! cond->lock || ! cond->wait_sem || ! cond->wait_done ) {
+			SDL_DestroyCond(cond);
+			cond = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return(cond);
+}
+
+/* Destroy a condition variable */
+void SDL_DestroyCond(SDL_cond *cond)
+{
+	if ( cond ) {
+		if ( cond->wait_sem ) {
+			SDL_DestroySemaphore(cond->wait_sem);
+		}
+		if ( cond->wait_done ) {
+			SDL_DestroySemaphore(cond->wait_done);
+		}
+		if ( cond->lock ) {
+			SDL_DestroyMutex(cond->lock);
+		}
+		free(cond);
+	}
+}
+
+/* Restart one of the threads that are waiting on the condition variable */
+int SDL_CondSignal(SDL_cond *cond)
+{
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	/* If there are waiting threads not already signalled, then
+	   signal the condition and wait for the thread to respond.
+	*/
+	SDL_LockMutex(cond->lock);
+	if ( cond->waiting > cond->signals ) {
+		++cond->signals;
+		SDL_SemPost(cond->wait_sem);
+		SDL_UnlockMutex(cond->lock);
+		SDL_SemWait(cond->wait_done);
+	} else {
+		SDL_UnlockMutex(cond->lock);
+	}
+
+	return 0;
+}
+
+/* Restart all threads that are waiting on the condition variable */
+int SDL_CondBroadcast(SDL_cond *cond)
+{
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	/* If there are waiting threads not already signalled, then
+	   signal the condition and wait for the thread to respond.
+	*/
+	SDL_LockMutex(cond->lock);
+	if ( cond->waiting > cond->signals ) {
+		int i, num_waiting;
+
+		num_waiting = (cond->waiting - cond->signals);
+		cond->signals = cond->waiting;
+		for ( i=0; i<num_waiting; ++i ) {
+			SDL_SemPost(cond->wait_sem);
+		}
+		/* Now all released threads are blocked here, waiting for us.
+		   Collect them all (and win fabulous prizes!) :-)
+		 */
+		SDL_UnlockMutex(cond->lock);
+		for ( i=0; i<num_waiting; ++i ) {
+			SDL_SemWait(cond->wait_done);
+		}
+	} else {
+		SDL_UnlockMutex(cond->lock);
+	}
+
+	return 0;
+}
+
+/* Wait on the condition variable for at most 'ms' milliseconds.
+   The mutex must be locked before entering this function!
+   The mutex is unlocked during the wait, and locked again after the wait.
+
+Typical use:
+
+Thread A:
+	SDL_LockMutex(lock);
+	while ( ! condition ) {
+		SDL_CondWait(cond);
+	}
+	SDL_UnlockMutex(lock);
+
+Thread B:
+	SDL_LockMutex(lock);
+	...
+	condition = true;
+	...
+	SDL_UnlockMutex(lock);
+ */
+int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
+{
+	int retval;
+
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	/* Obtain the protection mutex, and increment the number of waiters.
+	   This allows the signal mechanism to only perform a signal if there
+	   are waiting threads.
+	 */
+	SDL_LockMutex(cond->lock);
+	++cond->waiting;
+	SDL_UnlockMutex(cond->lock);
+
+	/* Unlock the mutex, as is required by condition variable semantics */
+	SDL_UnlockMutex(mutex);
+
+	/* Wait for a signal */
+	if ( ms == SDL_MUTEX_MAXWAIT ) {
+		retval = SDL_SemWait(cond->wait_sem);
+	} else {
+		retval = SDL_SemWaitTimeout(cond->wait_sem, ms);
+	}
+
+	/* Let the signaler know we have completed the wait, otherwise
+           the signaler can race ahead and get the condition semaphore
+           if we are stopped between the mutex unlock and semaphore wait,
+           giving a deadlock.  See the following URL for details:
+        http://www-classic.be.com/aboutbe/benewsletter/volume_III/Issue40.html
+	*/
+	SDL_LockMutex(cond->lock);
+	if ( cond->signals > 0 ) {
+		/* If we timed out, we need to eat a condition signal */
+		if ( retval > 0 ) {
+			SDL_SemWait(cond->wait_sem);
+		}
+		/* We always notify the signal thread that we are done */
+		SDL_SemPost(cond->wait_done);
+
+		/* Signal handshake complete */
+		--cond->signals;
+	}
+	--cond->waiting;
+	SDL_UnlockMutex(cond->lock);
+
+	/* Lock the mutex, as is required by condition variable semantics */
+	SDL_LockMutex(mutex);
+
+	return retval;
+}
+
+/* Wait on the condition variable forever */
+int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
+{
+	return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_syscond_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_sysmutex.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,137 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* An implementation of mutexes using semaphores */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread_c.h"
+
+
+struct SDL_mutex {
+	int recursive;
+	Uint32 owner;
+	SDL_sem *sem;
+};
+
+/* Create a mutex */
+SDL_mutex *SDL_CreateMutex(void)
+{
+	SDL_mutex *mutex;
+
+	/* Allocate mutex memory */
+	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
+	if ( mutex ) {
+		/* Create the mutex semaphore, with initial value 1 */
+		mutex->sem = SDL_CreateSemaphore(1);
+		mutex->recursive = 0;
+		mutex->owner = 0;
+		if ( ! mutex->sem ) {
+			free(mutex);
+			mutex = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return mutex;
+}
+
+/* Free the mutex */
+void SDL_DestroyMutex(SDL_mutex *mutex)
+{
+	if ( mutex ) {
+		if ( mutex->sem ) {
+			SDL_DestroySemaphore(mutex->sem);
+		}
+		free(mutex);
+	}
+}
+
+/* Lock the semaphore */
+int SDL_mutexP(SDL_mutex *mutex)
+{
+#ifdef DISABLE_THREADS
+	return 0;
+#else
+	Uint32 this_thread;
+
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+
+	this_thread = SDL_ThreadID();
+	if ( mutex->owner == this_thread ) {
+		++mutex->recursive;
+	} else {
+		/* The order of operations is important.
+		   We set the locking thread id after we obtain the lock
+		   so unlocks from other threads will fail.
+		*/
+		SDL_SemWait(mutex->sem);
+		mutex->owner = this_thread;
+		mutex->recursive = 0;
+	}
+
+	return 0;
+#endif /* DISABLE_THREADS */
+}
+
+/* Unlock the mutex */
+int SDL_mutexV(SDL_mutex *mutex)
+{
+#ifdef DISABLE_THREADS
+	return 0;
+#else
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+
+	/* If we don't own the mutex, we can't unlock it */
+	if ( SDL_ThreadID() != mutex->owner ) {
+		SDL_SetError("mutex not owned by this thread");
+		return -1;
+	}
+
+	if ( mutex->recursive ) {
+		--mutex->recursive;
+	} else {
+		/* The order of operations is important.
+		   First reset the owner so another thread doesn't lock
+		   the mutex and set the ownership before we reset it,
+		   then release the lock semaphore.
+		 */
+		mutex->owner = 0;
+		SDL_SemPost(mutex->sem);
+	}
+	return 0;
+#endif /* DISABLE_THREADS */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_sysmutex_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_syssem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,214 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* An implementation of semaphores using mutexes and condition variables */
+
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_thread.h"
+#include "SDL_systhread_c.h"
+
+
+#ifdef DISABLE_THREADS
+
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_SetError("SDL not configured with thread support");
+	return (SDL_sem *)0;
+}
+
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	return;
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	SDL_SetError("SDL not configured with thread support");
+	return -1;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	SDL_SetError("SDL not configured with thread support");
+	return -1;
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	SDL_SetError("SDL not configured with thread support");
+	return -1;
+}
+
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	return 0;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	SDL_SetError("SDL not configured with thread support");
+	return -1;
+}
+
+#else
+
+struct SDL_semaphore
+{
+	Uint32 count;
+	Uint32 waiters_count;
+	SDL_mutex *count_lock;
+	SDL_cond *count_nonzero;
+};
+
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_sem *sem;
+
+	sem = (SDL_sem *)malloc(sizeof(*sem));
+	if ( ! sem ) {
+		SDL_OutOfMemory();
+		return(0);
+	}
+	sem->count = initial_value;
+	sem->waiters_count = 0;
+
+	sem->count_lock = SDL_CreateMutex();
+	sem->count_nonzero = SDL_CreateCond();
+	if ( ! sem->count_lock || ! sem->count_nonzero ) {
+		SDL_DestroySemaphore(sem);
+		return(0);
+	}
+
+	return(sem);
+}
+
+/* WARNING:
+   You cannot call this function when another thread is using the semaphore.
+*/
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	if ( sem ) {
+		sem->count = 0xFFFFFFFF;
+		while ( sem->waiters_count > 0) {
+			SDL_CondSignal(sem->count_nonzero);
+			SDL_Delay(10);
+		}
+		SDL_DestroyCond(sem->count_nonzero);
+		SDL_mutexP(sem->count_lock);
+		SDL_mutexV(sem->count_lock);
+		SDL_DestroyMutex(sem->count_lock);
+		free(sem);
+	}
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	retval = SDL_MUTEX_TIMEDOUT;
+	SDL_LockMutex(sem->count_lock);
+	if ( sem->count > 0 ) {
+		--sem->count;
+		retval = 0;
+	}
+	SDL_UnlockMutex(sem->count_lock);
+
+	return retval;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	/* A timeout of 0 is an easy case */
+	if ( timeout == 0 ) {
+		return SDL_SemTryWait(sem);
+	}
+
+	SDL_LockMutex(sem->count_lock);
+	++sem->waiters_count;
+	retval = 0;
+	while ( (sem->count == 0) && (retval != SDL_MUTEX_TIMEDOUT) ) {
+		retval = SDL_CondWaitTimeout(sem->count_nonzero,
+		                             sem->count_lock, timeout);
+	}
+	--sem->waiters_count;
+	--sem->count;
+	SDL_UnlockMutex(sem->count_lock);
+
+	return retval;
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+}
+
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	Uint32 value;
+	
+	value = 0;
+	if ( sem ) {
+		SDL_LockMutex(sem->count_lock);
+		value = sem->count;
+		SDL_UnlockMutex(sem->count_lock);
+	}
+	return value;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	SDL_LockMutex(sem->count_lock);
+	if ( sem->waiters_count > 0 ) {
+		SDL_CondSignal(sem->count_nonzero);
+	}
+	++sem->count;
+	SDL_UnlockMutex(sem->count_lock);
+
+	return 0;
+}
+
+#endif /* DISABLE_THREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_syssem_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,59 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Thread management routines for SDL */
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread.h"
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	SDL_SetError("Threads are not supported on this platform");
+	return(-1);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+	return;
+}
+
+Uint32 SDL_ThreadID(void)
+{
+	return(0);
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	return;
+}
+
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	return;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/generic/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+/* Stub until we implement threads on this platform */
+typedef int SYS_ThreadHandle;
+
+#define DISABLE_THREADS
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/irix/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,91 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* IRIX thread management routines for SDL */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <sys/prctl.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread.h"
+
+
+static int sig_list[] = {
+	SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCLD, SIGWINCH,
+	SIGVTALRM, SIGPROF, 0
+};
+
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	/* Create the thread and go! */
+	if ( sproc(SDL_RunThread, PR_SALL, args) < 0 ) {
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+	int i;
+	sigset_t mask;
+
+	/* Mask asynchronous signals for this thread */
+	sigemptyset(&mask);
+	for ( i=0; sig_list[i]; ++i ) {
+		sigaddset(&mask, sig_list[i]);
+	}
+	sigprocmask(SIG_BLOCK, &mask, NULL);
+}
+
+/* WARNING:  This may not work for systems with 64-bit pid_t */
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)getpid());
+}
+
+/* WARNING:  This may not work for systems with 64-bit pid_t */
+void SDL_WaitThread(SDL_Thread *thread, int *status)
+{
+	errno = 0;
+	while ( errno != ECHILD ) {
+		waitpid(thread->handle, NULL, 0);
+	}
+}
+
+/* WARNING:  This may not work for systems with 64-bit pid_t */
+void SDL_KillThread(SDL_Thread *thread)
+{
+	kill(thread->handle, SIGKILL);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/irix/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#include <sys/types.h>
+
+typedef pid_t SYS_ThreadHandle;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_syscond.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,189 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifdef linux
+/* Look to see if glibc is available, and if so, what version */
+#include <features.h>
+
+#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+#warning Working around a bug in glibc 2.0 pthreads
+#undef SDL_USE_PTHREADS
+/* The bug is actually a problem where threads are suspended, but don't
+   wake up when the thread manager sends them a signal.  This is a problem
+   with thread creation too, but it happens less often. :-/
+   We avoid this by using System V IPC for mutexes.
+ */
+#endif /* glibc 2.0 */
+#endif /* linux */
+
+#ifdef SDL_USE_PTHREADS
+
+#include <sys/time.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_sysmutex_c.h"
+
+
+#if defined(PTHREAD_NO_RECURSIVE_MUTEX) && !defined(__bsdi__)
+#error You need to use the generic condition variable implementation
+#endif
+
+struct SDL_cond
+{
+	pthread_cond_t cond;
+};
+
+/* Create a condition variable */
+SDL_cond * SDL_CreateCond(void)
+{
+	SDL_cond *cond;
+
+	cond = (SDL_cond *) malloc(sizeof(SDL_cond));
+	if ( cond ) {
+		if ( pthread_cond_init(&cond->cond, NULL) < 0 ) {
+			SDL_SetError("pthread_cond_init() failed");
+			free(cond);
+			cond = NULL;
+		}
+	}
+	return(cond);
+}
+
+/* Destroy a condition variable */
+void SDL_DestroyCond(SDL_cond *cond)
+{
+	if ( cond ) {
+		pthread_cond_destroy(&cond->cond);
+		free(cond);
+	}
+}
+
+/* Restart one of the threads that are waiting on the condition variable */
+int SDL_CondSignal(SDL_cond *cond)
+{
+	int retval;
+
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	retval = 0;
+	if ( pthread_cond_signal(&cond->cond) != 0 ) {
+		SDL_SetError("pthread_cond_signal() failed");
+		retval = -1;
+	}
+	return retval;
+}
+
+/* Restart all threads that are waiting on the condition variable */
+int SDL_CondBroadcast(SDL_cond *cond)
+{
+	int retval;
+
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	retval = 0;
+	if ( pthread_cond_broadcast(&cond->cond) != 0 ) {
+		SDL_SetError("pthread_cond_broadcast() failed");
+		retval = -1;
+	}
+	return retval;
+}
+
+int SDL_CondWaitTimeout(SDL_cond *cond, SDL_mutex *mutex, Uint32 ms)
+{
+	int retval;
+	struct timeval delta;
+	struct timespec abstime;
+
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	gettimeofday(&delta, NULL);
+
+	abstime.tv_sec = delta.tv_sec + (ms/1000);
+	abstime.tv_nsec = (delta.tv_usec+(ms%1000)) * 1000;
+        if ( abstime.tv_nsec > 1000000 ) {
+          abstime.tv_sec += 1;
+          abstime.tv_nsec -= 1000000;
+        }
+
+  tryagain:
+	retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
+	switch (retval) {
+	    case EINTR:
+		goto tryagain;
+		break;
+	    case ETIMEDOUT:
+		retval = SDL_MUTEX_TIMEDOUT;
+		break;
+	    case 0:
+		break;
+	    default:
+		SDL_SetError("pthread_cond_timedwait() failed");
+		retval = -1;
+		break;
+	}
+	return retval;
+}
+
+/* Wait on the condition variable, unlocking the provided mutex.
+   The mutex must be locked before entering this function!
+ */
+int SDL_CondWait(SDL_cond *cond, SDL_mutex *mutex)
+{
+	int retval;
+
+	if ( ! cond ) {
+		SDL_SetError("Passed a NULL condition variable");
+		return -1;
+	}
+
+	retval = 0;
+	if ( pthread_cond_wait(&cond->cond, &mutex->id) != 0 ) {
+		SDL_SetError("pthread_cond_wait() failed");
+		retval = -1;
+	}
+	return retval;
+}
+
+#else /* Use semaphore implementation */
+
+#include "generic/SDL_syscond.c"
+
+#endif /* SDL_USE_PTHREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_sysmutex.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,181 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifdef linux
+/* Look to see if glibc is available, and if so, what version */
+#include <features.h>
+
+#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+#warning Working around a bug in glibc 2.0 pthreads
+#undef SDL_USE_PTHREADS
+/* The bug is actually a problem where threads are suspended, but don't
+   wake up when the thread manager sends them a signal.  This is a problem
+   with thread creation too, but it happens less often. :-/
+   We avoid this by using System V IPC for mutexes.
+ */
+#endif /* glibc 2.0 */
+#endif /* linux */
+
+#ifdef SDL_USE_PTHREADS
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <pthread.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+
+
+struct SDL_mutex {
+	pthread_mutex_t id;
+#ifdef PTHREAD_NO_RECURSIVE_MUTEX
+	int recursive;
+	pthread_t owner;
+#endif
+};
+
+SDL_mutex *SDL_CreateMutex (void)
+{
+	SDL_mutex *mutex;
+	pthread_mutexattr_t attr;
+
+	/* Allocate the structure */
+	mutex = (SDL_mutex *)calloc(1, sizeof(*mutex));
+	if ( mutex ) {
+		pthread_mutexattr_init(&attr);
+#ifdef PTHREAD_NO_RECURSIVE_MUTEX
+		/* No extra attributes necessary */
+#else
+#ifdef linux
+		pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
+#else
+		pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
+#endif
+#endif /* PTHREAD_NO_RECURSIVE_MUTEX */
+		if ( pthread_mutex_init(&mutex->id, &attr) != 0 ) {
+			SDL_SetError("pthread_mutex_init() failed");
+			free(mutex);
+			mutex = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return(mutex);
+}
+
+void SDL_DestroyMutex(SDL_mutex *mutex)
+{
+	if ( mutex ) {
+		pthread_mutex_destroy(&mutex->id);
+		free(mutex);
+	}
+}
+
+/* Lock the mutex */
+int SDL_mutexP(SDL_mutex *mutex)
+{
+	int retval;
+#ifdef PTHREAD_NO_RECURSIVE_MUTEX
+	pthread_t this_thread;
+#endif
+
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+
+	retval = 0;
+#ifdef PTHREAD_NO_RECURSIVE_MUTEX
+	this_thread = pthread_self();
+	if ( mutex->owner == this_thread ) {
+		++mutex->recursive;
+	} else {
+		/* The order of operations is important.
+		   We set the locking thread id after we obtain the lock
+		   so unlocks from other threads will fail.
+		*/
+		if ( pthread_mutex_lock(&mutex->id) == 0 ) {
+			mutex->owner = this_thread;
+			mutex->recursive = 0;
+		} else {
+			SDL_SetError("pthread_mutex_lock() failed");
+			retval = -1;
+		}
+	}
+#else
+	if ( pthread_mutex_lock(&mutex->id) < 0 ) {
+		SDL_SetError("pthread_mutex_lock() failed");
+		retval = -1;
+	}
+#endif
+	return retval;
+}
+
+int SDL_mutexV(SDL_mutex *mutex)
+{
+	int retval;
+
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+
+	retval = 0;
+#ifdef PTHREAD_NO_RECURSIVE_MUTEX
+	/* We can only unlock the mutex if we own it */
+	if ( pthread_self() == mutex->owner ) {
+		if ( mutex->recursive ) {
+			--mutex->recursive;
+		} else {
+			/* The order of operations is important.
+			   First reset the owner so another thread doesn't lock
+			   the mutex and set the ownership before we reset it,
+			   then release the lock semaphore.
+			 */
+			mutex->owner = 0;
+			pthread_mutex_unlock(&mutex->id);
+		}
+	} else {
+		SDL_SetError("mutex not owned by this thread");
+		retval = -1;
+	}
+
+#else
+	if ( pthread_mutex_unlock(&mutex->id) < 0 ) {
+		SDL_SetError("pthread_mutex_unlock() failed");
+		retval = -1;
+	}
+#endif /* PTHREAD_NO_RECURSIVE_MUTEX */
+
+	return retval;
+}
+
+#else /* Use semaphore implementation */
+
+#include "generic/SDL_sysmutex.c"
+
+#endif /* SDL_USE_PTHREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_sysmutex_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,43 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_mutex_c_h
+#define _SDL_mutex_c_h
+
+#ifdef SDL_USE_PTHREADS
+/* Recursive mutexes aren't widespread among pthread implementations yet */
+#if 0
+#define PTHREAD_NO_RECURSIVE_MUTEX
+#endif
+
+struct SDL_mutex {
+	pthread_mutex_t id;
+};
+#endif /* SDL_USE_PTHREADS */
+
+
+#endif /* _SDL_mutex_c_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_syssem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,445 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_timer.h"
+
+#ifdef linux
+/* Look to see if glibc is available, and if so, what version */
+#include <features.h>
+
+#if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
+#warning Working around a bug in glibc 2.0 pthreads
+#undef SDL_USE_PTHREADS
+/* The bug is actually a problem where threads are suspended, but don't
+   wake up when the thread manager sends them a signal.  This is a problem
+   with thread creation too, but it happens less often. :-/
+   We avoid this by using System V IPC for semaphores.
+ */
+#endif /* glibc 2.0 */
+#endif /* linux */
+
+#ifdef SDL_USE_PTHREADS
+
+#ifdef SDL_NO_PTHREAD_SEMAPHORES
+#include "generic/SDL_sem.c"
+#else
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>			/* For getpid() */
+#include <semaphore.h>
+
+/* Wrapper around POSIX 1003.1b semaphores */
+
+#ifdef MACOSX
+#define USE_NAMED_SEMAPHORES
+/* Broken sem_getvalue() in MacOS X Public Beta */
+#define BROKEN_SEMGETVALUE
+#endif /* MACOSX */
+
+struct SDL_semaphore {
+	sem_t *sem;
+#ifndef USE_NAMED_SEMAPHORES
+	sem_t sem_data;
+#endif
+#ifdef BROKEN_SEMGETVALUE
+	/* This is a little hack for MacOS X -
+	   It's not thread-safe, but it's better than nothing
+	 */
+	int sem_value;
+#endif
+};
+
+/* Create a semaphore, initialized with value */
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_sem *sem = (SDL_sem *) malloc(sizeof(SDL_sem));
+	if ( sem ) {
+#ifdef USE_NAMED_SEMAPHORES
+		static int semnum = 0;
+		char name[32];
+
+		sprintf(name, "/SDL_sem-%d-%4.4d", getpid(), semnum++);
+		sem->sem = sem_open(name, O_CREAT, 0600, initial_value);
+		if ( sem->sem == (sem_t *)SEM_FAILED ) {
+			SDL_SetError("sem_open(%s) failed", name);
+			free(sem);
+			sem = NULL;
+		} else {
+			sem_unlink(name);
+		}
+#else
+		if ( sem_init(&sem->sem_data, 0, initial_value) < 0 ) {
+			SDL_SetError("sem_init() failed");
+			free(sem);
+			sem = NULL;
+		} else {
+			sem->sem = &sem->sem_data;
+		}
+#endif /* USE_NAMED_SEMAPHORES */
+
+#ifdef BROKEN_SEMGETVALUE
+		if ( sem ) {
+			sem->sem_value = initial_value;
+		}
+#endif /* BROKEN_SEMGETVALUE */
+	} else {
+		SDL_OutOfMemory();
+	}
+	return sem;
+}
+
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	if ( sem ) {
+#ifdef USE_NAMED_SEMAPHORES
+		sem_close(sem->sem);
+#else
+		sem_destroy(sem->sem);
+#endif
+		free(sem);
+	}
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+	retval = SDL_MUTEX_TIMEDOUT;
+	if ( sem_trywait(sem->sem) == 0 ) {
+#ifdef BROKEN_SEMGETVALUE
+		--sem->sem_value;
+#endif
+		retval = 0;
+	}
+	return retval;
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+#ifdef BROKEN_SEMGETVALUE
+	--sem->sem_value;
+#endif
+	retval = sem_wait(sem->sem);
+	if ( retval < 0 ) {
+		SDL_SetError("sem_wait() failed");
+	}
+	return retval;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	/* Try the easy cases first */
+	if ( timeout == 0 ) {
+		return SDL_SemTryWait(sem);
+	}
+	if ( timeout == SDL_MUTEX_MAXWAIT ) {
+		return SDL_SemWait(sem);
+	}
+
+	/* Ack!  We have to busy wait... */
+	timeout += SDL_GetTicks();
+	do {
+		retval = SDL_SemTryWait(sem);
+		if ( retval == 0 ) {
+			break;
+		}
+		SDL_Delay(1);
+	} while ( SDL_GetTicks() < timeout );
+
+	return retval;
+}
+
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	int ret = 0;
+	if ( sem ) {
+#ifdef BROKEN_SEMGETVALUE
+		ret = sem->sem_value;
+#else
+		sem_getvalue(sem->sem, &ret);
+#endif
+		if ( ret < 0 ) {
+			ret = 0;
+		}
+	}
+	return (Uint32)ret;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+#ifdef BROKEN_SEMGETVALUE
+	++sem->sem_value;
+#endif
+	retval = sem_post(sem->sem);
+	if ( retval < 0 ) {
+		SDL_SetError("sem_post() failed");
+	}
+	return retval;
+}
+
+#endif /* NO_PTHREAD_SEMAPHORES */
+
+#else /* System V IPC implementation */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <errno.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+
+
+struct SDL_semaphore {
+	int id;
+};
+
+/* Not defined by many operating systems, use configure to detect */
+#if !defined(HAVE_SEMUN)
+union semun {
+	int val;
+	struct semid_ds *buf;
+	ushort *array;
+};
+#endif
+
+static struct sembuf op_trywait[2] = {
+	{ 0, -1, (IPC_NOWAIT|SEM_UNDO) } /* Decrement semaphore, no block */
+};
+static struct sembuf op_wait[2] = {
+	{ 0, -1, SEM_UNDO }		/* Decrement semaphore */
+};
+static struct sembuf op_post[1] = {
+	{ 0, 1, (IPC_NOWAIT|SEM_UNDO) }	/* Increment semaphore */
+};
+
+/* Create a blockable semaphore */
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	extern int _creating_thread_lock;	/* SDL_threads.c */
+	SDL_sem *sem;
+	union semun init;
+	key_t key;
+
+	sem = (SDL_sem *)malloc(sizeof(*sem));
+	if ( sem == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	/* This flag is true if we are creating the thread manager sem,
+	   which is never freed.  This allows us to reuse the same sem.
+	*/
+	if ( _creating_thread_lock ) {
+		key = 'S'+'D'+'L';
+	} else {
+		key = IPC_PRIVATE;
+	}
+	/* Keep trying to create sem while we don't own the requested key */
+	do {
+		if ( key != IPC_PRIVATE ) {
+			++key;
+		}
+		sem->id = semget(key, 1, (0600|IPC_CREAT));
+	} while ((sem->id < 0) && (key != IPC_PRIVATE) && (errno == EACCES));
+
+	/* Report the error if we eventually failed */
+	if ( sem->id < 0 ) {
+		SDL_SetError("Couldn't create semaphore");
+		free(sem);
+		return(NULL);
+	}
+	init.val = initial_value;	/* Initialize semaphore */
+	semctl(sem->id, 0, SETVAL, init);
+	return(sem);
+}
+
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	if ( sem ) {
+#ifdef _SGI_SOURCE
+		semctl(sem->id, 0, IPC_RMID);
+#else
+		union semun dummy;
+		dummy.val = 0;
+		semctl(sem->id, 0, IPC_RMID, dummy);
+#endif
+		free(sem);
+	}
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	retval = 0;
+  tryagain:
+	if ( semop(sem->id, op_trywait, 1) < 0 ) {
+		if ( errno == EINTR ) {
+			goto tryagain;
+		}
+		retval = SDL_MUTEX_TIMEDOUT;
+	}
+	return retval;
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	retval = 0;
+  tryagain:
+	if ( semop(sem->id, op_wait, 1) < 0 ) {
+		if ( errno == EINTR ) {
+			goto tryagain;
+		}
+		SDL_SetError("Semaphore operation error");
+		retval = -1;
+	}
+	return retval;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	/* Try the easy cases first */
+	if ( timeout == 0 ) {
+		return SDL_SemTryWait(sem);
+	}
+	if ( timeout == SDL_MUTEX_MAXWAIT ) {
+		return SDL_SemWait(sem);
+	}
+
+	/* Ack!  We have to busy wait... */
+	timeout += SDL_GetTicks();
+	do {
+		retval = SDL_SemTryWait(sem);
+		if ( retval == 0 ) {
+			break;
+		}
+		SDL_Delay(1);
+	} while ( SDL_GetTicks() < timeout );
+
+	return retval;
+}
+
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	int semval;
+	Uint32 value;
+	
+	value = 0;
+	if ( sem ) {
+	  tryagain:
+#ifdef _SGI_SOURCE
+		semval = semctl(sem->id, 0, GETVAL);
+#else
+		{
+		union semun arg;
+		arg.val = 0;
+		semval = semctl(sem->id, 0, GETVAL, arg);
+		}
+#endif
+		if ( semval < 0 ) {
+			if ( errno == EINTR ) {
+				goto tryagain;
+			}
+		} else {
+			value = (Uint32)semval;
+		}
+	}
+	return value;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	int retval;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL semaphore");
+		return -1;
+	}
+
+	retval = 0;
+  tryagain:
+	if ( semop(sem->id, op_post, 1) < 0 ) {
+		if ( errno == EINTR ) {
+			goto tryagain;
+		}
+		SDL_SetError("Semaphore operation error");
+		retval = -1;
+	}
+	return retval;
+}
+
+#endif /* SDL_USE_PTHREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,255 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Linux thread management routines for SDL */
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread.h"
+
+#ifdef FORK_HACK
+
+#include <unistd.h>
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	SDL_SetError("Threads are not supported on this platform");
+	return(-1);
+}
+void SDL_SYS_SetupThread(void)
+{
+	return;
+}
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)getpid());
+}
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	return;
+}
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	return;
+}
+
+#else
+
+#include <signal.h>
+
+#if !defined(MACOSX) /* pthread_sigmask seems to be missing on MacOS X? */
+/* List of signals to mask in the subthreads */
+static int sig_list[] = {
+	SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
+	SIGVTALRM, SIGPROF, 0
+};
+#endif /* !MACOSX */
+
+#ifdef SDL_USE_PTHREADS
+
+#include <pthread.h>
+
+
+static void *RunThread(void *data)
+{
+	SDL_RunThread(data);
+	pthread_exit((void*)0);
+	return((void *)0);		/* Prevent compiler warning */
+}
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	pthread_attr_t type;
+
+	/* Set the thread attributes */
+	if ( pthread_attr_init(&type) != 0 ) {
+		SDL_SetError("Couldn't initialize pthread attributes");
+		return(-1);
+	}
+	pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
+
+	/* Create the thread and go! */
+	if ( pthread_create(&thread->handle, &type, RunThread, args) != 0 ) {
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+#if !defined(MACOSX) /* pthread_sigmask seems to be missing on MacOS X? */
+	int i;
+	sigset_t mask;
+
+	/* Mask asynchronous signals for this thread */
+	sigemptyset(&mask);
+	for ( i=0; sig_list[i]; ++i ) {
+		sigaddset(&mask, sig_list[i]);
+	}
+	pthread_sigmask(SIG_BLOCK, &mask, 0);
+#endif /* !MACOSX */
+
+#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
+	/* Allow ourselves to be asynchronously cancelled */
+	{ int oldstate;
+		pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
+	}
+#endif
+}
+
+/* WARNING:  This may not work for systems with 64-bit pid_t */
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)pthread_self());
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	pthread_join(thread->handle, 0);
+}
+
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
+	pthread_cancel(thread->handle);
+#else
+#ifdef __FreeBSD__
+#warning For some reason, this doesnt actually kill a thread - FreeBSD 3.2
+#endif
+	pthread_kill(thread->handle, SIGKILL);
+#endif
+}
+
+#else /* Linux-specific clone() based implementation */
+
+#include <stdlib.h>
+#include <errno.h>
+#include <unistd.h>
+#include <sys/wait.h>
+
+
+/* Stack size for child thread */
+#define STACKSIZE 16384*4		/* 16384 is too small */
+
+#ifdef __GLIBC__
+#include <sched.h>
+#else
+/* From <linux/sched.h> */
+#define CLONE_VM      0x00000100   /* set if VM shared */
+#define CLONE_FS      0x00000200   /* set if fs info shared */
+#define CLONE_FILES   0x00000400   /* set if open files shared */
+#define CLONE_SIGHAND 0x00000800   /* set if signal handlers shared */
+#define CLONE_PID     0x00001000   /* set if pid shared */
+
+/* The infamous "start_thread" function, courtesy Linus Torvalds */
+extern int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg);
+#endif
+
+static int RunThread(void *data)
+{
+	SDL_RunThread(data);
+	return(0);
+}
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	void *stack;
+
+	/* Allocate memory for thread stack */
+	stack = malloc(STACKSIZE);
+	if ( stack == (void *)0 ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	thread->data = stack;
+
+	/* Adjust the stack since it actually grows down */
+        stack = (void *) ((char *)stack + STACKSIZE);
+
+	/* Create the thread and go! */
+	thread->handle = clone(RunThread, stack,
+			(CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND), args);
+	if ( thread->handle < 0 ) {
+		free(thread->data);
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+	int i;
+	sigset_t mask;
+
+	/* Mask asynchronous signals for this thread */
+	sigemptyset(&mask);
+	for ( i=0; sig_list[i]; ++i ) {
+		sigaddset(&mask, sig_list[i]);
+	}
+	sigprocmask(SIG_BLOCK, &mask, 0);
+}
+
+/* WARNING:  This may not work for systems with 64-bit pid_t */
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)getpid());
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+#ifdef __WCLONE
+	errno = 0;
+	while ( errno != ECHILD ) {
+		waitpid(thread->handle, 0, __WCLONE);
+	}
+#else
+	/* Ack, ugly ugly hack --
+	   wait() doesn't work, waitpid() doesn't work, and ignoring SIG_CHLD
+	   doesn't work .. and the child thread is still a zombie, so kill()
+	   doesn't work.
+	*/
+	char command[1024];
+
+	sprintf(command,
+		"ps ax|fgrep -v fgrep|fgrep -v '<zombie>'|fgrep %d >/dev/null",
+								thread->handle);
+	while ( system(command) == 0 )
+		sleep(1);
+#endif
+	free(thread->data);
+}
+
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	kill(thread->handle, SIGKILL);
+}
+
+#endif /* SDL_USE_PTHREADS */
+
+#endif /* FORK_HACK */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SDL_USE_PTHREADS
+
+#include <pthread.h>
+
+typedef pthread_t SYS_ThreadHandle;
+
+#else
+
+#include <sys/types.h>
+
+typedef pid_t SYS_ThreadHandle;
+
+#endif /* SDL_USE_PTHREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/linux/clone.S	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,186 @@
+
+/* Taken with thanks from LinuxThreads 0.6 */
+
+/* This is no longer necessary with glibc-2.1, which has it's own clone() */
+#ifdef linux
+/* Look to see if glibc is available, and if so, what version */
+#include <features.h>
+
+#if (__GLIBC__ > 2) || ((__GLIBC__ == 2) && (__GLIBC_MINOR__ >= 1))
+#define HAVE_CLONE
+#endif /* glibc 2.1 or newer */
+#endif /* linux */
+
+#if defined(linux) && !defined(SDL_USE_PTHREADS) && !defined(HAVE_CLONE)
+
+#if defined(__i386__)
+/************************************************************************/
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Contributed by Richard Henderson (rth@tamu.edu)
+
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+Cambridge, MA 02139, USA.  */
+
+/* clone() is even more special than fork() as it mucks with stacks
+   and invokes a function in the right context after its all over.  */
+
+#include <asm/errno.h>
+#include <asm/unistd.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+        .text
+	.align	4
+	.globl	__clone
+        .type   __clone,@function
+	.weak	clone
+	clone   = __clone
+__clone:
+	/* Sanity check arguments.  */
+	movl	$-EINVAL,%eax
+	movl	4(%esp),%ecx		/* no NULL function pointers */
+	testl	%ecx,%ecx
+	jz	syscall_error
+	movl	8(%esp),%ecx		/* no NULL stack pointers */
+	testl	%ecx,%ecx
+	jz	syscall_error
+
+	/* Insert the argument onto the new stack.  */
+	subl	$8,%ecx
+	movl	16(%esp),%eax
+	movl	%eax,4(%ecx)
+
+	/* Save the function pointer as the zeroth argument. */
+	/* It will be popped off in the child in the ebx frobbing below.  */
+	movl	4(%esp),%eax
+	movl	%eax,0(%ecx)
+
+	/* Do the system call */
+	pushl	%ebx
+	movl	16(%esp),%ebx
+	movl	$__NR_clone,%eax
+	int	$0x80
+	popl	%ebx
+
+	test	%eax,%eax
+	jl	syscall_error
+	jz	thread_start
+
+	ret
+
+syscall_error:
+	negl    %eax
+        pushl   %eax
+#ifdef __PIC__
+        call    __errno_location@PLT
+#else
+        call    __errno_location
+#endif
+        popl    0(%eax)
+	movl	$-1, %eax
+	ret
+
+thread_start:
+	subl	%ebp,%ebp	/* terminate the stack frame */
+	call	*%ebx
+        pushl   %eax
+#ifdef __PIC__
+	call	_exit@PLT
+#else
+	call	_exit
+#endif
+/************************************************************************/
+#elif defined(sparc)
+/************************************************************************/
+/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Contributed by Miguel de Icaza (miguel@nuclecu.unam.mx)
+   Based on code written for the Intel by Richard 
+   Henderson (rth@tamu.edu)
+	
+The GNU C Library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public License as
+published by the Free Software Foundation; either version 2 of the
+License, or (at your option) any later version.
+
+The GNU C Library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with the GNU C Library; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 675 Mass Ave,
+Cambridge, MA 02139, USA.  */
+
+/* clone() is even more special than fork() as it mucks with stacks
+   and invokes a function in the right context after its all over.  */
+	
+#include <asm/errno.h>
+#include <asm/unistd.h>
+
+/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */
+
+	.text
+	.align	4
+	.globl	__clone
+	.type	__clone,@function
+	.weak	clone
+	clone   = __clone
+__clone:	
+	save	%sp,-96,%sp
+	/* sanity check arguments */
+	tst	%i0
+	be	__clone_syscall_error
+	tst	%i1
+	be	__clone_syscall_error
+        nop
+
+	/* Do the system call */
+	mov	%i1,%o1
+	mov	%i2,%o0
+	set	__NR_clone,%g1
+	ta	0x10
+	bcs	__clone_syscall_error
+	tst	%o1
+	bne	__thread_start
+	nop
+	mov	%o0,%i0
+	ret
+	restore
+	
+__clone_syscall_error:
+	call	__errno_location
+	set	EINVAL,%i0
+	st	%i0,[%o0]
+	mov	-1,%i0
+	ret
+	restore
+
+__thread_start:
+	call	%i0
+	mov	%i3,%o0
+	call	_exit,0
+	nop
+/************************************************************************/
+#else 
+#error "Unknown Linux architecture"
+#endif
+
+#endif /* Linux && ! SDL_USE_PTHREADS */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/win32/SDL_sysmutex.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,101 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Mutex functions using the Win32 API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#include "SDL_error.h"
+#include "SDL_mutex.h"
+
+
+struct SDL_mutex {
+	HANDLE id;
+};
+
+/* Create a mutex */
+SDL_mutex *SDL_CreateMutex(void)
+{
+	SDL_mutex *mutex;
+
+	/* Allocate mutex memory */
+	mutex = (SDL_mutex *)malloc(sizeof(*mutex));
+	if ( mutex ) {
+		/* Create the mutex, with initial value signaled */
+		mutex->id = CreateMutex(NULL, FALSE, NULL);
+		if ( ! mutex->id ) {
+			SDL_SetError("Couldn't create mutex");
+			free(mutex);
+			mutex = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return(mutex);
+}
+
+/* Free the mutex */
+void SDL_DestroyMutex(SDL_mutex *mutex)
+{
+	if ( mutex ) {
+		if ( mutex->id ) {
+			CloseHandle(mutex->id);
+			mutex->id = 0;
+		}
+		free(mutex);
+	}
+}
+
+/* Lock the mutex */
+int SDL_mutexP(SDL_mutex *mutex)
+{
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+	if ( WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED ) {
+		SDL_SetError("Couldn't wait on mutex");
+		return -1;
+	}
+	return(0);
+}
+
+/* Unlock the mutex */
+int SDL_mutexV(SDL_mutex *mutex)
+{
+	if ( mutex == NULL ) {
+		SDL_SetError("Passed a NULL mutex");
+		return -1;
+	}
+	if ( ReleaseMutex(mutex->id) == FALSE ) {
+		SDL_SetError("Couldn't release mutex");
+		return -1;
+	}
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/win32/SDL_syssem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,195 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Semaphore functions using the Win32 API */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+
+#if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
+
+/* No semaphores on Windows CE earlier than 3.0, hmm... */
+
+/* Create a semaphore */
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_SetError("Semaphores not supported on WinCE");
+	return(NULL);
+}
+
+/* Free the semaphore */
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	return;
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	SDL_SetError("Semaphores not supported on WinCE");
+	return(-1);
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, 0);
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+}
+
+/* Returns the current count of the semaphore */
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	return(0);
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	SDL_SetError("Semaphores not supported on WinCE");
+	return(-1);
+}
+
+#else
+
+struct SDL_semaphore {
+	HANDLE id;
+	Uint32 volatile count;
+};
+
+
+/* Create a semaphore */
+SDL_sem *SDL_CreateSemaphore(Uint32 initial_value)
+{
+	SDL_sem *sem;
+
+	/* Allocate sem memory */
+	sem = (SDL_sem *)malloc(sizeof(*sem));
+	if ( sem ) {
+		/* Create the semaphore, with max value 32K */
+		sem->id = CreateSemaphore(NULL, initial_value, 32*1024, NULL);
+		sem->count = initial_value;
+		if ( ! sem->id ) {
+			SDL_SetError("Couldn't create semaphore");
+			free(sem);
+			sem = NULL;
+		}
+	} else {
+		SDL_OutOfMemory();
+	}
+	return(sem);
+}
+
+/* Free the semaphore */
+void SDL_DestroySemaphore(SDL_sem *sem)
+{
+	if ( sem ) {
+		if ( sem->id ) {
+			CloseHandle(sem->id);
+			sem->id = 0;
+		}
+		free(sem);
+	}
+}
+
+int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout)
+{
+	int retval;
+	DWORD dwMilliseconds;
+
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL sem");
+		return -1;
+	}
+
+	if ( timeout == SDL_MUTEX_MAXWAIT ) {
+		dwMilliseconds = INFINITE;
+	} else {
+		dwMilliseconds = (DWORD)timeout;
+	}
+	switch (WaitForSingleObject(sem->id, dwMilliseconds)) {
+	    case WAIT_OBJECT_0:
+		--sem->count;
+		retval = 0;
+		break;
+	    case WAIT_TIMEOUT:
+		retval = SDL_MUTEX_TIMEDOUT;
+		break;
+	    default:
+		SDL_SetError("WaitForSingleObject() failed");
+		retval = -1;
+		break;
+	}
+	return retval;
+}
+
+int SDL_SemTryWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, 0);
+}
+
+int SDL_SemWait(SDL_sem *sem)
+{
+	return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT);
+}
+
+/* Returns the current count of the semaphore */
+Uint32 SDL_SemValue(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL sem");
+		return 0;
+	}
+	return sem->count;
+}
+
+int SDL_SemPost(SDL_sem *sem)
+{
+	if ( ! sem ) {
+		SDL_SetError("Passed a NULL sem");
+		return -1;
+	}
+	/* Increase the counter in the first place, because
+	 * after a successful release the semaphore may
+	 * immediately get destroyed by another thread which
+	 * is waiting for this semaphore.
+	 */
+	++sem->count;
+	if ( ReleaseSemaphore(sem->id, 1, NULL) == FALSE ) {
+		--sem->count;	/* restore */
+		SDL_SetError("ReleaseSemaphore() failed");
+		return -1;
+	}
+	return 0;
+}
+
+#endif /* _WIN32_WCE */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/win32/SDL_systhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,80 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Win32 thread management routines for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <windows.h>
+
+#include "SDL_error.h"
+#include "SDL_thread.h"
+#include "SDL_systhread.h"
+
+
+static DWORD WINAPI RunThread(LPVOID data)
+{
+	SDL_RunThread(data);
+	return(0);
+}
+
+int SDL_SYS_CreateThread(SDL_Thread *thread, void *args)
+{
+	DWORD  threadnum;
+
+	thread->handle = CreateThread(NULL, 0, RunThread, args, 0, &threadnum);
+	if (thread->handle == NULL) {
+		SDL_SetError("Not enough resources to create thread");
+		return(-1);
+	}
+	return(0);
+}
+
+void SDL_SYS_SetupThread(void)
+{
+	return;
+}
+
+Uint32 SDL_ThreadID(void)
+{
+	return((Uint32)GetCurrentThreadId());
+}
+
+void SDL_SYS_WaitThread(SDL_Thread *thread)
+{
+	WaitForSingleObject(thread->handle, INFINITE);
+	CloseHandle(thread->handle);
+}
+
+/* WARNING: This function is really a last resort.
+ * Threads should be signaled and then exit by themselves.
+ * TerminateThread() doesn't perform stack and DLL cleanup.
+ */
+void SDL_SYS_KillThread(SDL_Thread *thread)
+{
+	TerminateThread(thread->handle, FALSE);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/thread/win32/SDL_systhread_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#include <windows.h>
+
+typedef HANDLE SYS_ThreadHandle;
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,7 @@
+Makefile.in
+SDL_timer.c
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,27 @@
+
+## Makefile.am for the SDL timer library
+
+noinst_LTLIBRARIES = libtimer.la
+
+ARCH_SUBDIRS = amigaos beos linux macos win32
+
+# Include the architecture-independent sources
+COMMON_SRCS = SDL_timer.c SDL_timer_c.h SDL_systimer.h
+
+# Include the architecture-specific sources
+ARCH_SRCS = SDL_systimer.c
+
+libtimer_la_SOURCES = $(COMMON_SRCS) $(ARCH_SRCS)
+
+## Let automake know that it shouldn't distribute linked sources
+BUILT_SOURCES = $(ARCH_SRCS)
+
+## Let automake know that it should remove these for distribution
+DISTCLEANFILES = $(ARCH_SRCS)
+
+# The architecture specific directories need to be copied into place
+# when building a distribution.
+dist-hook:
+	(cd $(distdir) && rm -f $(BUILT_SOURCES))
+	cp -rp $(ARCH_SUBDIRS) $(distdir)
+	(cd $(distdir) && rm -rf `find . -name CVS`)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/SDL_systimer.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,46 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    5635-34 Springhouse Dr.
+    Pleasanton, CA 94588 (USA)
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* The system dependent timer handling functions */
+
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+
+
+/* Initialize the system dependent timer subsystem */
+extern int SDL_SYS_TimerInit(void);
+
+/* Quit the system dependent timer subsystem */
+extern void SDL_SYS_TimerQuit(void);
+
+/* Start a timer set up by SDL_SetTimer() */
+extern int SDL_SYS_StartTimer(void);
+
+/* Stop a previously started timer */
+extern void SDL_SYS_StopTimer(void);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/SDL_timer_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,52 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    5635-34 Springhouse Dr.
+    Pleasanton, CA 94588 (USA)
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful functions and variables from SDL_timer.c */
+#include "SDL_timer.h"
+
+#define ROUND_RESOLUTION(X)	\
+	(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
+
+extern int SDL_timer_started;
+extern int SDL_timer_running;
+
+/* Data to handle a single periodic alarm */
+extern Uint32 SDL_alarm_interval;
+extern SDL_TimerCallback SDL_alarm_callback;
+
+/* Set whether or not the timer should use a thread.
+   This should be called while the timer subsystem is running.
+*/
+extern int SDL_SetTimerThreaded(int value);
+
+extern int SDL_TimerInit(void);
+extern void SDL_TimerQuit(void);
+
+/* This function is called from the SDL event thread if it is available */
+extern void SDL_ThreadedTimerCheck(void);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/amigaos/SDL_systimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,145 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+
+/* The first ticks value of the application */
+static struct timeval start;
+
+void SDL_StartTicks(void)
+{
+	/* Set first ticks value */
+	gettimeofday(&start, NULL);
+}
+
+Uint32 SDL_GetTicks (void)
+{
+	struct timeval now;
+	Uint32 ticks;
+
+	gettimeofday(&now, NULL);
+	ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
+	return(ticks);
+}
+
+void SDL_Delay (Uint32 ms)
+{
+	int was_error;
+#ifndef linux	/* Non-Linux implementations need to calculate time left */
+	Uint32 then, now, elapsed;
+#endif
+	struct timeval tv;
+
+	/* Set the timeout interval - Linux only needs to do this once */
+#ifdef linux
+	tv.tv_sec = ms/1000;
+	tv.tv_usec = (ms%1000)*1000;
+#else
+	then = SDL_GetTicks();
+#endif
+	do {
+		errno = 0;
+#ifndef linux
+		/* Calculate the time interval left (in case of interrupt) */
+		now = SDL_GetTicks();
+		elapsed = (now-then);
+		then = now;
+		if ( elapsed >= ms ) {
+			break;
+		}
+		ms -= elapsed;
+		tv.tv_sec = ms/1000;
+		tv.tv_usec = (ms%1000)*1000;
+#endif
+		was_error = select(0, NULL, NULL, NULL, &tv);
+	} while ( was_error && (errno == EINTR) );
+}
+
+#include "SDL_thread.h"
+
+/* Data to handle a single periodic alarm */
+static int timer_alive = 0;
+static SDL_Thread *timer = NULL;
+
+static int RunTimer(void *unused)
+{
+	while ( timer_alive ) {
+		if ( SDL_timer_running ) {
+			SDL_ThreadedTimerCheck();
+		}
+		SDL_Delay(1);
+	}
+	return(0);
+}
+
+/* This is only called if the event thread is not running */
+int SDL_SYS_TimerInit(void)
+{
+#ifdef NO_AMIGADEBUG
+	fprintf(stderr,"Creo il thread per il timer (NOITMER)...\n");
+#endif
+	timer_alive = 1;
+	timer = SDL_CreateThread(RunTimer, NULL);
+	if ( timer == NULL )
+	{
+#ifdef NO_AMIGADEBUG
+		fprintf(stderr,"Creazione del thread fallita...\n");
+#endif
+
+		return(-1);
+	}
+	return(SDL_SetTimerThreaded(1));
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	timer_alive = 0;
+	if ( timer ) {
+		SDL_WaitThread(timer, NULL);
+		timer = NULL;
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	SDL_SetError("Internal logic error: Linux uses threaded timer");
+	return(-1);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/beos/SDL_systimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,96 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <be/kernel/OS.h>
+
+#include "SDL_thread.h"
+#include "SDL_timer.h"
+#include "SDL_error.h"
+#include "SDL_timer_c.h"
+
+static bigtime_t start;
+
+void SDL_StartTicks(void)
+{
+	/* Set first ticks value */
+	start = system_time();
+}
+
+Uint32 SDL_GetTicks(void)
+{
+	return((system_time()-start)/1000);
+}
+
+void SDL_Delay(Uint32 ms)
+{
+	snooze(ms*1000);
+}
+
+/* Data to handle a single periodic alarm */
+static int timer_alive = 0;
+static SDL_Thread *timer = NULL;
+
+static int RunTimer(void *unused)
+{
+	while ( timer_alive ) {
+		if ( SDL_timer_running ) {
+			SDL_ThreadedTimerCheck();
+		}
+		SDL_Delay(10);
+	}
+	return(0);
+}
+
+/* This is only called if the event thread is not running */
+int SDL_SYS_TimerInit(void)
+{
+	timer_alive = 1;
+	timer = SDL_CreateThread(RunTimer, NULL);
+	if ( timer == NULL )
+		return(-1);
+	return(SDL_SetTimerThreaded(1));
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	timer_alive = 0;
+	if ( timer ) {
+		SDL_WaitThread(timer, NULL);
+		timer = NULL;
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	SDL_SetError("Internal logic error: BeOS uses threaded timer");
+	return(-1);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	return;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/linux/SDL_systimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,222 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+
+#if defined(DISABLE_THREADS) || defined(FORK_HACK)
+#define USE_ITIMER
+#endif
+
+/* The following defines should really be determined at configure time */
+
+#ifdef linux
+/* Linux select() changes its timeout parameter upon return to contain
+   the remaining time. Most other unixen leave it unchanged or undefined. */
+#define SELECT_SETS_REMAINING
+#elif defined(__bsdi__) || defined(__FreeBSD__) || defined(__sun__)
+#define USE_NANOSLEEP
+#endif
+
+
+/* The first ticks value of the application */
+static struct timeval start;
+
+void SDL_StartTicks(void)
+{
+	/* Set first ticks value */
+	gettimeofday(&start, NULL);
+}
+
+Uint32 SDL_GetTicks (void)
+{
+	struct timeval now;
+	Uint32 ticks;
+
+	gettimeofday(&now, NULL);
+	ticks=(now.tv_sec-start.tv_sec)*1000+(now.tv_usec-start.tv_usec)/1000;
+	return(ticks);
+}
+
+void SDL_Delay (Uint32 ms)
+{
+	int was_error;
+
+#ifdef USE_NANOSLEEP
+	struct timespec elapsed, tv;
+#else
+	struct timeval tv;
+#ifndef SELECT_SETS_REMAINING
+	Uint32 then, now, elapsed;
+#endif
+#endif
+
+	/* Set the timeout interval - Linux only needs to do this once */
+#ifdef SELECT_SETS_REMAINING
+	tv.tv_sec = ms/1000;
+	tv.tv_usec = (ms%1000)*1000;
+#elif defined(USE_NANOSLEEP)
+	elapsed.tv_sec = ms/1000;
+	elapsed.tv_nsec = (ms%1000)*1000000;
+#else
+	then = SDL_GetTicks();
+#endif
+	do {
+		errno = 0;
+
+#ifdef USE_NANOSLEEP
+		tv.tv_sec = elapsed.tv_sec;
+		tv.tv_nsec = elapsed.tv_nsec;
+		was_error = nanosleep(&tv, &elapsed);
+#else
+#ifndef SELECT_SETS_REMAINING
+		/* Calculate the time interval left (in case of interrupt) */
+		now = SDL_GetTicks();
+		elapsed = (now-then);
+		then = now;
+		if ( elapsed >= ms ) {
+			break;
+		}
+		ms -= elapsed;
+		tv.tv_sec = ms/1000;
+		tv.tv_usec = (ms%1000)*1000;
+#endif
+		was_error = select(0, NULL, NULL, NULL, &tv);
+#endif /* USE_NANOSLEEP */
+	} while ( was_error && (errno == EINTR) );
+}
+
+#ifdef USE_ITIMER
+
+static void HandleAlarm(int sig)
+{
+	Uint32 ms;
+
+	if ( SDL_alarm_callback ) {
+		ms = (*SDL_alarm_callback)(SDL_alarm_interval);
+		if ( ms != SDL_alarm_interval ) {
+			SDL_SetTimer(ms, SDL_alarm_callback);
+		}
+	}
+}
+
+int SDL_SYS_TimerInit(void)
+{
+	struct sigaction action;
+
+	/* Set the alarm handler (Linux specific) */
+	memset(&action, 0, sizeof(action));
+	action.sa_handler = HandleAlarm;
+	action.sa_flags = SA_RESTART;
+	sigemptyset(&action.sa_mask);
+	sigaction(SIGALRM, &action, NULL);
+	return(0);
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	SDL_SetTimer(0, NULL);
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	struct itimerval timer;
+
+	timer.it_value.tv_sec = (SDL_alarm_interval/1000);
+	timer.it_value.tv_usec = (SDL_alarm_interval%1000)*1000;
+	timer.it_interval.tv_sec = (SDL_alarm_interval/1000);
+	timer.it_interval.tv_usec = (SDL_alarm_interval%1000)*1000;
+	setitimer(ITIMER_REAL, &timer, NULL);
+	return(0);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	struct itimerval timer;
+
+	memset(&timer, 0, (sizeof timer));
+	setitimer(ITIMER_REAL, &timer, NULL);
+}
+
+#else /* USE_ITIMER */
+
+#include "SDL_thread.h"
+
+/* Data to handle a single periodic alarm */
+static int timer_alive = 0;
+static SDL_Thread *timer = NULL;
+
+static int RunTimer(void *unused)
+{
+	while ( timer_alive ) {
+		if ( SDL_timer_running ) {
+			SDL_ThreadedTimerCheck();
+		}
+		SDL_Delay(1);
+	}
+	return(0);
+}
+
+/* This is only called if the event thread is not running */
+int SDL_SYS_TimerInit(void)
+{
+	timer_alive = 1;
+	timer = SDL_CreateThread(RunTimer, NULL);
+	if ( timer == NULL )
+		return(-1);
+	return(SDL_SetTimerThreaded(1));
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	timer_alive = 0;
+	if ( timer ) {
+		SDL_WaitThread(timer, NULL);
+		timer = NULL;
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	SDL_SetError("Internal logic error: Linux uses threaded timer");
+	return(-1);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	return;
+}
+
+#endif /* USE_ITIMER */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/macos/FastTimes.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,347 @@
+/* File "FastTimes.c" - Original code by Matt Slot <fprefect@ambrosiasw.com>  */
+/* Created 4/24/99    - This file is hereby placed in the public domain       */
+/* Updated 5/21/99    - Calibrate to VIA, add TBR support, renamed functions  */
+/* Updated 10/4/99    - Use AbsoluteToNanoseconds() in case Absolute = double */
+/* Updated 2/15/00    - Check for native Time Manager, no need to calibrate   */
+/* Updated 2/19/00    - Fixed default value for gScale under native Time Mgr  */
+/* Updated 3/21/00    - Fixed ns conversion, create 2 different scale factors */
+/* Updated 5/03/00    - Added copyright and placed into PD. No code changes   */
+/* Updated 8/01/00    - Made "Carbon-compatible" by replacing LMGetTicks()    */
+
+/* This file is Copyright (C) Matt Slot, 1999-2000. It is hereby placed into 
+   the public domain. The author makes no warranty as to fitness or stability */
+
+#include <Gestalt.h>
+#include <LowMem.h>
+#include <CodeFragments.h>
+#include <DriverServices.h>
+#include <Timer.h>
+
+#include "FastTimes.h"
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/*
+	On 680x0 machines, we just use Microseconds().
+	
+	On PowerPC machines, we try several methods:
+	  * DriverServicesLib is available on all PCI PowerMacs, and perhaps
+	    some NuBus PowerMacs. If it is, we use UpTime() : Overhead = 2.1 µsec.
+	  * The PowerPC 601 has a built-in "real time clock" RTC, and we fall
+	    back to that, accessing it directly from asm. Overhead = 1.3 µsec.
+	  * Later PowerPCs have an accurate "time base register" TBR, and we 
+	    fall back to that, access it from PowerPC asm. Overhead = 1.3 µsec.
+	  * We can also try Microseconds() which is emulated : Overhead = 36 µsec.
+
+	On PowerPC machines, we avoid the following:
+	  * OpenTransport is available on all PCI and some NuBus PowerMacs, but it
+	    uses UpTime() if available and falls back to Microseconds() otherwise.
+	  * InputSprocket is available on many PowerMacs, but again it uses
+	    UpTime() if available and falls back to Microseconds() otherwise.
+
+	Another PowerPC note: certain configurations, especially 3rd party upgrade
+	cards, may return inaccurate timings for the CPU or memory bus -- causing
+	skew in various system routines (up to 20% drift!). The VIA chip is very
+	accurate, and it's the basis for the Time Manager and Microseconds().
+	Unfortunately, it's also very slow because the MacOS has to (a) switch to
+	68K and (b) poll for a VIA event.
+	
+	We compensate for the drift by calibrating a floating point scale factor
+	between our fast method and the accurate timer at startup, then convert
+	each sample quickly on the fly. I'd rather not have the initialization 
+	overhead -- but it's simply necessary for accurate timing. You can drop
+	it down to 30 ticks if you prefer, but that's as low as I'd recommend.
+
+	Under MacOS 9, "new world" Macs (iMacs, B+W G3s and G+W G4s) have a native
+	Time Manager implementation: UpTime(), Microseconds(), and TickCount() are
+	all based on the same underlying counter. This makes it silly to calibrate
+	UpTime() against TickCount(). We now check for this feature using Gestalt(),
+	and skip the whole calibration step if possible.
+
+*/
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+#define RTCToNano(w)	((double) (w).hi * 1000000000.0 + (double) (w).lo)
+#define WideTo64bit(w)	(*(UInt64 *) &(w))
+
+/* LMGetTicks() is not in Carbon and TickCount() has a fair bit of overhead,
+   so for speed we always read lowmem directly. This is a MacOS X no-no, but 
+   it always work on those systems that don't have a native Time Manager (ie,
+   anything before MacOS 9) -- regardless whether we are in Carbon or not! */
+#define MyLMGetTicks()	(*(volatile UInt32 *) 0x16A)
+
+#if GENERATINGPOWERPC
+
+static asm UnsignedWide PollRTC(void);
+static asm UnsignedWide PollTBR(void);
+static Ptr FindFunctionInSharedLib(StringPtr libName, StringPtr funcName);
+
+static Boolean			gInited = false;
+static Boolean			gNative = false;
+static Boolean			gUseRTC = false;
+static Boolean			gUseTBR = false;
+static double			gScaleUSec = 1.0 / 1000.0;    /* 1 / ( nsec / usec) */
+static double			gScaleMSec = 1.0 / 1000000.0; /* 1 / ( nsec / msec) */
+
+/* Functions loaded from DriverServicesLib */
+typedef AbsoluteTime 	(*UpTimeProcPtr)(void);
+typedef Nanoseconds 	(*A2NSProcPtr)(AbsoluteTime);
+static UpTimeProcPtr 	gUpTime = NULL;
+static A2NSProcPtr 		gA2NS = NULL;
+
+#endif /* GENERATINGPOWERPC */
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+void FastInitialize() {
+	SInt32			result;
+
+	if (!gInited) {
+
+#if GENERATINGPOWERPC
+
+		/* Initialize the feature flags */
+		gNative = gUseRTC = gUseTBR = false;
+
+		/* We use CFM to find and load needed symbols from shared libraries, so
+		   the application doesn't have to weak-link them, for convenience.   */
+		gUpTime = (UpTimeProcPtr) FindFunctionInSharedLib(
+				"\pDriverServicesLib", "\pUpTime");
+		if (gUpTime) gA2NS = (A2NSProcPtr) FindFunctionInSharedLib(
+				"\pDriverServicesLib", "\pAbsoluteToNanoseconds");
+		if (!gA2NS) gUpTime = nil; /* Pedantic but necessary */
+
+		if (gUpTime) {
+			/* If we loaded UpTime(), then we need to know if the system has
+			   a native implementation of the Time Manager. If so, then it's
+			   pointless to calculate a scale factor against the missing VIA */
+
+			/* gestaltNativeTimeMgr = 4 in some future version of the headers */
+			if (!Gestalt(gestaltTimeMgrVersion, &result) &&
+					(result > gestaltExtendedTimeMgr)) 
+				gNative = true;
+			}
+		  else {
+			/* If no DriverServicesLib, use Gestalt() to get the processor type. 
+			   Only NuBus PowerMacs with old System Software won't have DSL, so
+			   we know it should either be a 601 or 603. */
+
+			/* Use the processor gestalt to determine which register to use */
+		 	if (!Gestalt(gestaltNativeCPUtype, &result)) {
+				if (result == gestaltCPU601) gUseRTC = true;
+				  else if (result > gestaltCPU601) gUseTBR = true;
+				}
+			}
+
+		/* Now calculate a scale factor to keep us accurate. */
+		if ((gUpTime && !gNative) || gUseRTC || gUseTBR) {
+			UInt64			tick, usec1, usec2;
+			UnsignedWide	wide;
+
+			/* Wait for the beginning of the very next tick */
+			for(tick = MyLMGetTicks() + 1; tick > MyLMGetTicks(); );
+			
+			/* Poll the selected timer and prepare it (since we have time) */
+			wide = (gUpTime) ? (*gA2NS)((*gUpTime)()) : 
+					((gUseRTC) ? PollRTC() : PollTBR());
+			usec1 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide);
+			
+			/* Wait for the exact 60th tick to roll over */
+			while(tick + 60 > MyLMGetTicks());
+
+			/* Poll the selected timer again and prepare it  */
+			wide = (gUpTime) ? (*gA2NS)((*gUpTime)()) : 
+					((gUseRTC) ? PollRTC() : PollTBR());
+			usec2 = (gUseRTC) ? RTCToNano(wide) : WideTo64bit(wide);
+			
+			/* Calculate a scale value that will give microseconds per second.
+			   Remember, there are actually 60.15 ticks in a second, not 60.  */
+			gScaleUSec = (60.0 * 1000000.0) / ((usec2 - usec1) * 60.15);
+			gScaleMSec = gScaleUSec / 1000.0;
+			}
+
+#endif /* GENERATINGPOWERPC */
+
+		/* We've initialized our globals */
+		gInited = true;
+		}
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+UInt64 FastMicroseconds() {
+	UnsignedWide	wide;
+	UInt64			usec;
+	
+#if GENERATINGPOWERPC
+	/* Initialize globals the first time we are called */
+	if (!gInited) FastInitialize();
+	
+	if (gNative) {
+		/* Use DriverServices if it's available -- it's fast and compatible */
+		wide = (*gA2NS)((*gUpTime)());
+		usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
+		}
+	  else if (gUpTime) {
+		/* Use DriverServices if it's available -- it's fast and compatible */
+		wide = (*gA2NS)((*gUpTime)());
+		usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
+		}
+	  else if (gUseTBR) {
+		/* On a recent PowerPC, we poll the TBR directly */
+		wide = PollTBR();
+		usec = (double) WideTo64bit(wide) * gScaleUSec + 0.5;
+		}
+	  else if (gUseRTC) {
+		/* On a 601, we can poll the RTC instead */
+		wide = PollRTC();
+		usec = (double) RTCToNano(wide) * gScaleUSec + 0.5;
+		}
+	  else 
+#endif /* GENERATINGPOWERPC */
+		{
+		/* If all else fails, suffer the mixed mode overhead */
+		Microseconds(&wide);
+		usec = WideTo64bit(wide);
+		}
+
+	return(usec);
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+UInt64 FastMilliseconds() {
+	UnsignedWide	wide;
+	UInt64			msec;	
+	
+#if GENERATINGPOWERPC
+	/* Initialize globals the first time we are called */
+	if (!gInited) FastInitialize();
+	
+	if (gNative) {
+		/* Use DriverServices if it's available -- it's fast and compatible */
+		wide = (*gA2NS)((*gUpTime)());
+		msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
+		}
+	  else if (gUpTime) {
+		/* Use DriverServices if it's available -- it's fast and compatible */
+		wide = (*gA2NS)((*gUpTime)());
+		msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
+		}
+	  else if (gUseTBR) {
+		/* On a recent PowerPC, we poll the TBR directly */
+		wide = PollTBR();
+		msec = (double) WideTo64bit(wide) * gScaleMSec + 0.5;
+		}
+	  else if (gUseRTC) {
+		/* On a 601, we can poll the RTC instead */
+		wide = PollRTC();
+		msec = (double) RTCToNano(wide) * gScaleMSec + 0.5;
+		}
+	  else 
+#endif /* GENERATINGPOWERPC */
+		{
+		/* If all else fails, suffer the mixed mode overhead */
+		Microseconds(&wide);
+		msec = ((double) WideTo64bit(wide) + 500.0) / 1000.0;
+		}
+
+	return(msec);
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+StringPtr FastMethod() {
+	StringPtr	method = "\p<Unknown>";
+
+#if GENERATINGPOWERPC
+	/* Initialize globals the first time we are called */
+	if (!gInited) FastInitialize();
+	
+	if (gNative) {
+		/* The Time Manager and UpTime() are entirely native on this machine */
+		method = "\pNative UpTime()";
+		}
+	  else if (gUpTime) {
+		/* Use DriverServices if it's available -- it's fast and compatible */
+		method = "\pUpTime()";
+		}
+	  else if (gUseTBR) {
+		/* On a recent PowerPC, we poll the TBR directly */
+		method = "\pPowerPC TBR";
+		}
+	  else if (gUseRTC) {
+		/* On a 601, we can poll the RTC instead */
+		method = "\pPowerPC RTC";
+		}
+	  else 
+#endif /* GENERATINGPOWERPC */
+		{
+		/* If all else fails, suffer the mixed mode overhead */
+		method = "\pMicroseconds()";
+		}
+
+	return(method);
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+#pragma mark -
+
+#if GENERATINGPOWERPC
+asm static UnsignedWide PollRTC_() {
+entry PollRTC /* Avoid CodeWarrior glue */
+	machine 601
+@AGAIN:
+	mfrtcu	r4 /* RTCU = SPR 4 */
+	mfrtcl	r5 /* RTCL = SPR 5 */
+	mfrtcu	r6
+	cmpw	r4,r6
+	bne		@AGAIN
+	stw		r4,0(r3)
+	stw		r5,4(r3)
+	blr
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+asm static UnsignedWide PollTBR_() {
+entry PollTBR /* Avoid CodeWarrior glue */
+	machine 604
+@AGAIN:
+	mftbu	r4 /* TBRU = SPR 268 */
+	mftb	r5 /* TBRL = SPR 269 */
+	mftbu	r6
+	cmpw	r4,r6
+	bne		@AGAIN
+	stw		r4,0(r3)
+	stw		r5,4(r3)
+	blr
+	}
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+static Ptr FindFunctionInSharedLib(StringPtr libName, StringPtr funcName) {
+	OSErr				error = noErr;
+	Str255				errorStr;
+	Ptr					func = NULL;
+	Ptr					entry = NULL;
+	CFragSymbolClass	symClass;
+	CFragConnectionID	connID;
+	
+	/* Find CFM containers for the current archecture -- CFM-PPC or CFM-68K */
+	if (/* error = */ GetSharedLibrary(libName, kCompiledCFragArch,
+			kLoadCFrag, &connID, &entry, errorStr)) return(NULL);
+	if (/* error = */ FindSymbol(connID, funcName, &func, &symClass))
+		return(NULL);
+	
+	return(func);
+	}
+#endif /* GENERATINGPOWERPC */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/macos/FastTimes.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,26 @@
+/* File "FastTimes.h" - Original code by Matt Slot <fprefect@ambrosiasw.com>  */
+/* Created 4/24/99    - This file is hereby placed in the public domain       */
+/* Updated 5/21/99    - Calibrate to VIA, add TBR support, renamed functions  */
+/* Updated 10/4/99    - Use AbsoluteToNanoseconds() in case Absolute = double */
+/* Updated 2/15/00    - Check for native Time Manager, no need to calibrate   */
+/* Updated 3/21/00    - Fixed ns conversion, create 2 different scale factors */
+/* Updated 5/03/00    - Added copyright and placed into PD. No code changes   */
+
+/* This file is Copyright (C) Matt Slot, 1999-2000. It is hereby placed into 
+   the public domain. The author makes no warranty as to fitness or stability */
+
+#ifndef __FAST_TIMES_HEADER__
+#define __FAST_TIMES_HEADER__
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+extern void			FastInitialize(void);
+extern UInt64		FastMicroseconds(void);
+extern UInt64		FastMilliseconds(void);
+extern StringPtr	FastMethod(void);
+
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+/* **** **** **** **** **** **** **** **** **** **** **** **** **** **** **** */
+
+#endif /* __FAST_TIMES_HEADER__ */
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/macos/SDL_MPWtimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,152 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <Types.h>
+#include <Timer.h>
+#include <OSUtils.h>
+#include <Gestalt.h>
+#include <Processes.h>
+
+#include <LowMem.h>
+
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+
+#define MS_PER_TICK	(1000/60)		/* MacOS tick = 1/60 second */
+
+/* Note: This is only a step above the original 1/60s implementation.
+ *       For a good implementation, see FastTimes.[ch], by Matt Slot.
+ */
+#define USE_MICROSECONDS
+#define WideTo64bit(w)	(*(UInt64 *) &(w))
+
+UInt64 start;
+
+void SDL_StartTicks(void)
+{
+#ifdef USE_MICROSECONDS
+	UnsignedWide now;
+	
+	Microseconds(&now);
+	start = WideTo64bit(now);
+#else
+	/* FIXME: Should we implement a wrapping algorithm, like Win32? */
+#endif
+}
+
+Uint32 SDL_GetTicks(void)
+{
+#ifdef USE_MICROSECONDS
+	UnsignedWide now;
+	
+	Microseconds(&now);
+	return (Uint32)((WideTo64bit(now)-start)/1000);
+#else
+	return(LMGetTicks()*MS_PER_TICK);
+#endif
+}
+
+void SDL_Delay(Uint32 ms)
+{
+#ifdef USE_MICROSECONDS
+	Uint32 end_ms;
+	
+	end_ms = SDL_GetTicks() + ms;
+	do {
+		/* FIXME: Yield CPU? */ ;
+	} while ( SDL_GetTicks() < end_ms );
+#else
+	UInt32		unused; /* MJS */
+	Delay(ms/MS_PER_TICK, &unused);
+#endif
+}
+
+
+/* Data to handle a single periodic alarm */
+typedef struct _ExtendedTimerRec
+{
+	TMTask		     tmTask;
+	ProcessSerialNumber  taskPSN;
+} ExtendedTimerRec, *ExtendedTimerPtr;
+
+static ExtendedTimerRec gExtendedTimerRec;
+
+
+int SDL_SYS_TimerInit(void)
+{
+	/* We don't need a setup? */
+	return(0);
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	/* We don't need a cleanup? */
+	return;
+}
+
+/* Our Stub routine to set up and then call the real routine. */
+pascal void TimerCallbackProc(TMTaskPtr tmTaskPtr)
+{
+	Uint32 ms;
+
+	WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN);
+
+	ms = SDL_alarm_callback(SDL_alarm_interval);
+	if ( ms ) {
+		SDL_alarm_interval = ROUND_RESOLUTION(ms);
+		PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask,
+		          SDL_alarm_interval);
+	} else {
+		SDL_alarm_interval = 0;
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	/*
+	 * Configure the global structure that stores the timing information.
+	 */
+	gExtendedTimerRec.tmTask.qLink = NULL;
+	gExtendedTimerRec.tmTask.qType = 0;
+	gExtendedTimerRec.tmTask.tmAddr = NewTimerUPP(TimerCallbackProc);
+	gExtendedTimerRec.tmTask.tmCount = 0;
+	gExtendedTimerRec.tmTask.tmWakeUp = 0;
+	gExtendedTimerRec.tmTask.tmReserved = 0;
+	GetCurrentProcess(&gExtendedTimerRec.taskPSN);
+
+	/* Install the task record */
+	InsXTime((QElemPtr)&gExtendedTimerRec.tmTask);
+
+	/* Go! */
+	PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask, SDL_alarm_interval);
+	return(0);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	RmvTime((QElemPtr)&gExtendedTimerRec.tmTask);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/macos/SDL_systimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,178 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <Types.h>
+#include <Timer.h>
+#include <OSUtils.h>
+#include <Gestalt.h>
+#include <Processes.h>
+
+#include <LowMem.h>
+
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+
+#include "FastTimes.h"
+
+#define MS_PER_TICK	(1000.0/60.0)		/* MacOS tick = 1/60 second */
+
+
+#define kTwoPower32     (4294967296.0)          /* 2^32 */
+
+static double start_tick;
+static int    is_fast_inited = 0;
+
+void SDL_StartTicks(void)
+{
+        if ( ! is_fast_inited )     // important to check or FastTime may hang machine!
+            SDL_SYS_TimerInit();
+
+        start_tick = FastMicroseconds();
+}
+
+Uint32 SDL_GetTicks(void)
+{
+        
+        if ( ! is_fast_inited )
+            SDL_SYS_TimerInit();
+         
+        return FastMilliseconds();
+}
+
+void SDL_Delay(Uint32 ms)
+{
+        Uint32 stop, now;
+
+        stop = SDL_GetTicks() + ms;
+        do {
+                SystemTask();
+
+                now = SDL_GetTicks();
+
+        } while ( stop > now );
+}
+
+/*
+void SDL_StartTicks(void)
+{
+	// FIXME: Should we implement a wrapping algorithm, like Win32? 
+}
+
+Uint32 SDL_GetTicks(void)
+{
+	UnsignedWide ms;
+	
+	Microseconds (&ms);
+	
+	return ( ms.lo / 1000 );
+}
+
+void SDL_Delay(Uint32 ms)
+{
+	
+	UnsignedWide microsecs;
+	UInt32       stop;
+	
+	Microseconds (&microsecs);
+	
+	stop = microsecs.lo + (ms * 1000);
+	
+	while ( stop > microsecs.lo ) {
+	
+	   SystemTask ();
+	   
+	   Microseconds (&microsecs);
+	}
+
+}*/
+ 
+/* Data to handle a single periodic alarm */
+typedef struct _ExtendedTimerRec
+{
+	TMTask		     tmTask;
+	ProcessSerialNumber  taskPSN;
+} ExtendedTimerRec, *ExtendedTimerPtr;
+
+static ExtendedTimerRec gExtendedTimerRec;
+
+
+int SDL_SYS_TimerInit(void)
+{
+	FastInitialize ();
+	is_fast_inited = 1;
+	
+	return(0);
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	/* We don't need a cleanup? */
+	return;
+}
+
+/* Our Stub routine to set up and then call the real routine. */
+pascal void TimerCallbackProc(TMTaskPtr tmTaskPtr)
+{
+	Uint32 ms;
+
+	WakeUpProcess(&((ExtendedTimerPtr) tmTaskPtr)->taskPSN);
+
+	ms = SDL_alarm_callback(SDL_alarm_interval);
+	if ( ms ) {
+		SDL_alarm_interval = ROUND_RESOLUTION(ms);
+		PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask,
+		          SDL_alarm_interval);
+	} else {
+		SDL_alarm_interval = 0;
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	/*
+	 * Configure the global structure that stores the timing information.
+	 */
+	gExtendedTimerRec.tmTask.qLink = NULL;
+	gExtendedTimerRec.tmTask.qType = 0;
+	gExtendedTimerRec.tmTask.tmAddr = NewTimerProc(TimerCallbackProc);
+	gExtendedTimerRec.tmTask.tmCount = 0;
+	gExtendedTimerRec.tmTask.tmWakeUp = 0;
+	gExtendedTimerRec.tmTask.tmReserved = 0;
+	GetCurrentProcess(&gExtendedTimerRec.taskPSN);
+
+	/* Install the task record */
+	InsXTime((QElemPtr)&gExtendedTimerRec.tmTask);
+
+	/* Go! */
+	PrimeTime((QElemPtr)&gExtendedTimerRec.tmTask, SDL_alarm_interval);
+	return(0);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	RmvTime((QElemPtr)&gExtendedTimerRec.tmTask);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/timer/win32/SDL_systimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,181 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <windows.h>
+#include <mmsystem.h>
+
+#include "SDL_timer.h"
+#include "SDL_timer_c.h"
+#include "SDL_error.h"
+
+#ifdef _WIN32_WCE
+#define USE_GETTICKCOUNT
+#define USE_SETTIMER
+#endif
+
+#define TIME_WRAP_VALUE	(~(DWORD)0)
+
+/* The first ticks value of the application */
+static DWORD start;
+
+void SDL_StartTicks(void)
+{
+	/* Set first ticks value */
+#ifdef USE_GETTICKCOUNT
+	start = GetTickCount();
+#else
+	start = timeGetTime();
+#endif
+}
+
+Uint32 SDL_GetTicks(void)
+{
+	DWORD now, ticks;
+
+#ifdef USE_GETTICKCOUNT
+	now = GetTickCount();
+#else
+	now = timeGetTime();
+#endif
+	if ( now < start ) {
+		ticks = (TIME_WRAP_VALUE-start) + now;
+	} else {
+		ticks = (now - start);
+	}
+	return(ticks);
+}
+
+void SDL_Delay(Uint32 ms)
+{
+	Sleep(ms);
+}
+
+#ifdef USE_SETTIMER
+
+static UINT WIN_timer;
+
+int SDL_SYS_TimerInit(void)
+{
+	return(0);
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	return;
+}
+
+/* Forward declaration because this is called by the timer callback */
+int SDL_SYS_StartTimer(void);
+
+static VOID CALLBACK TimerCallbackProc(HWND hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
+{
+	Uint32 ms;
+
+	ms = SDL_alarm_callback(SDL_alarm_interval);
+	if ( ms != SDL_alarm_interval ) {
+		KillTimer(NULL, idEvent);
+		if ( ms ) {
+			SDL_alarm_interval = ROUND_RESOLUTION(ms);
+			SDL_SYS_StartTimer();
+		} else {
+			SDL_alarm_interval = 0;
+		}
+	}
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	int retval;
+
+	WIN_timer = SetTimer(NULL, 0, SDL_alarm_interval, TimerCallbackProc);
+	if ( WIN_timer ) {
+		retval = 0;
+	} else {
+		retval = -1;
+	}
+	return retval;
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	if ( WIN_timer ) {
+		KillTimer(NULL, WIN_timer);
+		WIN_timer = 0;
+	}
+}
+
+#else /* !USE_SETTIMER */
+
+/* Data to handle a single periodic alarm */
+static UINT timerID = 0;
+
+static void CALLBACK HandleAlarm(UINT uID,  UINT uMsg, DWORD dwUser,
+						DWORD dw1, DWORD dw2)
+{
+	SDL_ThreadedTimerCheck();
+}
+
+
+int SDL_SYS_TimerInit(void)
+{
+	MMRESULT result;
+
+	/* Set timer resolution */
+	result = timeBeginPeriod(TIMER_RESOLUTION);
+	if ( result != TIMERR_NOERROR ) {
+		SDL_SetError("Warning: Can't set %d ms timer resolution",
+							TIMER_RESOLUTION);
+	}
+	/* Allow 10 ms of drift so we don't chew on CPU */
+	timerID = timeSetEvent(TIMER_RESOLUTION,1,HandleAlarm,0,TIME_PERIODIC);
+	if ( ! timerID ) {
+		SDL_SetError("timeSetEvent() failed");
+		return(-1);
+	}
+	return(SDL_SetTimerThreaded(1));
+}
+
+void SDL_SYS_TimerQuit(void)
+{
+	if ( timerID ) {
+		timeKillEvent(timerID);
+	}
+	timeEndPeriod(TIMER_RESOLUTION);
+}
+
+int SDL_SYS_StartTimer(void)
+{
+	SDL_SetError("Internal logic error: Win32 uses threaded timer");
+	return(-1);
+}
+
+void SDL_SYS_StopTimer(void)
+{
+	return;
+}
+
+#endif /* USE_SETTIMER */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+
+## Makefile.am for the SDL video library
+
+noinst_LTLIBRARIES = libvideo.la
+
+# Define which subdirectories need to be built
+SUBDIRS = @VIDEO_SUBDIRS@
+DIST_SUBDIRS = x11 dga fbcon svga ggi aalib \
+               wincommon windib windx5 \
+               maccommon macdsp macrom bwindow photon cybergfx
+
+DRIVERS = @VIDEO_DRIVERS@
+
+# Include the architecture-independent sources
+COMMON_SRCS =			\
+	SDL_RLEaccel.c		\
+	SDL_RLEaccel_c.h	\
+	SDL_blit.c		\
+	SDL_blit.h		\
+	SDL_blit_0.c		\
+	SDL_blit_1.c		\
+	SDL_blit_A.c		\
+	SDL_blit_A.h		\
+	SDL_blit_N.c		\
+	SDL_bmp.c		\
+	SDL_cursor.c		\
+	SDL_cursor_c.h		\
+	SDL_gamma.c		\
+	SDL_glfuncs.h		\
+	SDL_leaks.h		\
+	SDL_memops.h		\
+	SDL_pixels.c		\
+	SDL_pixels_c.h		\
+	SDL_surface.c		\
+	SDL_stretch.c		\
+	SDL_stretch_c.h		\
+	SDL_sysvideo.h		\
+	SDL_video.c		\
+	SDL_yuv.c		\
+	SDL_yuvfuncs.h		\
+	SDL_yuv_sw.c		\
+	SDL_yuv_sw_c.h		\
+	SDL_yuv_mmx.c		\
+	blank_cursor.h		\
+	default_cursor.h
+
+libvideo_la_SOURCES = $(COMMON_SRCS)
+libvideo_la_LIBADD = $(DRIVERS)
+libvideo_la_DEPENDENCIES = $(DRIVERS)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_RLEaccel.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1547 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/*
+ * RLE encoding for software colorkey and alpha-channel acceleration
+ *
+ * Original version by Sam Lantinga
+ *
+ * Mattias Engdegård (Yorick): Rewrite. New encoding format, encoder and
+ * decoder. Added per-surface alpha blitter. Added per-pixel alpha
+ * format, encoder and blitter.
+ *
+ * Many thanks to Xark and johns for hints, benchmarks and useful comments
+ * leading to this code.
+ *
+ * Welcome to Macro Mayhem.
+ */
+
+/*
+ * The encoding translates the image data to a stream of segments of the form
+ *
+ * <skip> <run> <data>
+ *
+ * where <skip> is the number of transparent pixels to skip,
+ *       <run>  is the number of opaque pixels to blit,
+ * and   <data> are the pixels themselves.
+ *
+ * This basic structure is used both for colorkeyed surfaces, used for simple
+ * binary transparency and for per-surface alpha blending, and for surfaces
+ * with per-pixel alpha. The details differ, however:
+ *
+ * Encoding of colorkeyed surfaces:
+ *
+ *   Encoded pixels always have the same format as the target surface.
+ *   <skip> and <run> are unsigned 8 bit integers, except for 32 bit depth
+ *   where they are 16 bit. This makes the pixel data aligned at all times.
+ *   Segments never wrap around from one scan line to the next.
+ *
+ *   The end of the sequence is marked by a zero <skip>,<run> pair at the *
+ *   beginning of a line.
+ *
+ * Encoding of surfaces with per-pixel alpha:
+ *
+ *   The sequence begins with a struct RLEDestFormat describing the target
+ *   pixel format, to provide reliable un-encoding.
+ *
+ *   Each scan line is encoded twice: First all completely opaque pixels,
+ *   encoded in the target format as described above, and then all
+ *   partially transparent (translucent) pixels (where 1 <= alpha <= 254),
+ *   in the following 32-bit format:
+ *
+ *   For 32-bit targets, each pixel has the target RGB format but with
+ *   the alpha value occupying the highest 8 bits. The <skip> and <run>
+ *   counts are 16 bit.
+ * 
+ *   For 16-bit targets, each pixel has the target RGB format, but with
+ *   the middle component (usually green) shifted 16 steps to the left,
+ *   and the hole filled with the 5 most significant bits of the alpha value.
+ *   i.e. if the target has the format         rrrrrggggggbbbbb,
+ *   the encoded pixel will be 00000gggggg00000rrrrr0aaaaabbbbb.
+ *   The <skip> and <run> counts are 8 bit for the opaque lines, 16 bit
+ *   for the translucent lines. Two padding bytes may be inserted
+ *   before each translucent line to keep them 32-bit aligned.
+ *
+ *   The end of the sequence is marked by a zero <skip>,<run> pair at the
+ *   beginning of an opaque line.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_error.h"
+#include "SDL_sysvideo.h"
+#include "SDL_blit.h"
+#include "SDL_memops.h"
+#include "SDL_RLEaccel_c.h"
+
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/*
+ * Various colorkey blit methods, for opaque and per-surface alpha
+ */
+
+#define OPAQUE_BLIT(to, from, length, bpp, alpha)	\
+    SDL_memcpy(to, from, (unsigned)(length * bpp))
+
+/*
+ * For 32bpp pixels on the form 0x00rrggbb:
+ * If we treat the middle component separately, we can process the two
+ * remaining in parallel. This is safe to do because of the gap to the left
+ * of each component, so the bits from the multiplication don't collide.
+ * This can be used for any RGB permutation of course.
+ */
+#define ALPHA_BLIT32_888(to, from, length, bpp, alpha)		\
+    do {							\
+        int i;							\
+	Uint32 *src = (Uint32 *)(from);				\
+	Uint32 *dst = (Uint32 *)(to);				\
+	for(i = 0; i < (int)(length); i++) {			\
+	    Uint32 s = *src++;					\
+	    Uint32 d = *dst;					\
+	    Uint32 s1 = s & 0xff00ff;				\
+	    Uint32 d1 = d & 0xff00ff;				\
+	    d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;	\
+	    s &= 0xff00;					\
+	    d &= 0xff00;					\
+	    d = (d + ((s - d) * alpha >> 8)) & 0xff00;		\
+	    *dst++ = d1 | d;					\
+	}							\
+    } while(0)
+
+/*
+ * For 16bpp pixels we can go a step further: put the middle component
+ * in the high 16 bits of a 32 bit word, and process all three RGB
+ * components at the same time. Since the smallest gap is here just
+ * 5 bits, we have to scale alpha down to 5 bits as well.
+ */
+#define ALPHA_BLIT16_565(to, from, length, bpp, alpha)	\
+    do {						\
+        int i;						\
+	Uint16 *src = (Uint16 *)(from);			\
+	Uint16 *dst = (Uint16 *)(to);			\
+	for(i = 0; i < (int)(length); i++) {		\
+	    Uint32 s = *src++;				\
+	    Uint32 d = *dst;				\
+	    s = (s | s << 16) & 0x07e0f81f;		\
+	    d = (d | d << 16) & 0x07e0f81f;		\
+	    d += (s - d) * alpha >> 5;			\
+	    d &= 0x07e0f81f;				\
+	    *dst++ = d | d >> 16;			\
+	}						\
+    } while(0)
+
+#define ALPHA_BLIT16_555(to, from, length, bpp, alpha)	\
+    do {						\
+        int i;						\
+	Uint16 *src = (Uint16 *)(from);			\
+	Uint16 *dst = (Uint16 *)(to);			\
+	for(i = 0; i < (int)(length); i++) {		\
+	    Uint32 s = *src++;				\
+	    Uint32 d = *dst;				\
+	    s = (s | s << 16) & 0x03e07c1f;		\
+	    d = (d | d << 16) & 0x03e07c1f;		\
+	    d += (s - d) * alpha >> 5;			\
+	    d &= 0x03e07c1f;				\
+	    *dst++ = d | d >> 16;			\
+	}						\
+    } while(0)
+
+/*
+ * The general slow catch-all function, for remaining depths and formats
+ */
+#define ALPHA_BLIT_ANY(to, from, length, bpp, alpha)			\
+    do {								\
+        int i;								\
+	Uint8 *src = from;						\
+	Uint8 *dst = to;						\
+	for(i = 0; i < (int)(length); i++) {				\
+	    Uint32 s, d;						\
+	    unsigned rs, gs, bs, rd, gd, bd;				\
+	    switch(bpp) {						\
+	    case 2:							\
+		s = *(Uint16 *)src;					\
+		d = *(Uint16 *)dst;					\
+		break;							\
+	    case 3:							\
+		if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {			\
+		    s = (src[0] << 16) | (src[1] << 8) | src[2];	\
+		    d = (dst[0] << 16) | (dst[1] << 8) | dst[2];	\
+		} else {						\
+		    s = (src[2] << 16) | (src[1] << 8) | src[0];	\
+		    d = (dst[2] << 16) | (dst[1] << 8) | dst[0];	\
+		}							\
+		break;							\
+	    case 4:							\
+		s = *(Uint32 *)src;					\
+		d = *(Uint32 *)dst;					\
+		break;							\
+	    }								\
+	    RGB_FROM_PIXEL(s, fmt, rs, gs, bs);				\
+	    RGB_FROM_PIXEL(d, fmt, rd, gd, bd);				\
+	    rd += (rs - rd) * alpha >> 8;				\
+	    gd += (gs - gd) * alpha >> 8;				\
+	    bd += (bs - bd) * alpha >> 8;				\
+	    PIXEL_FROM_RGB(d, fmt, rd, gd, bd);				\
+	    switch(bpp) {						\
+	    case 2:							\
+		*(Uint16 *)dst = d;					\
+		break;							\
+	    case 3:							\
+		if(SDL_BYTEORDER == SDL_BIG_ENDIAN) {			\
+		    dst[0] = d >> 16;					\
+		    dst[1] = d >> 8;					\
+		    dst[2] = d;						\
+		} else {						\
+		    dst[0] = d;						\
+		    dst[1] = d >> 8;					\
+		    dst[2] = d >> 16;					\
+		}							\
+		break;							\
+	    case 4:							\
+		*(Uint32 *)dst = d;					\
+		break;							\
+	    }								\
+	    src += bpp;							\
+	    dst += bpp;							\
+	}								\
+    } while(0)
+
+
+/*
+ * Special case: 50% alpha (alpha=128)
+ * This is treated specially because it can be optimized very well, and
+ * since it is good for many cases of semi-translucency.
+ * The theory is to do all three components at the same time:
+ * First zero the lowest bit of each component, which gives us room to
+ * add them. Then shift right and add the sum of the lowest bits.
+ */
+#define ALPHA_BLIT32_888_50(to, from, length, bpp, alpha)		\
+    do {								\
+        int i;								\
+	Uint32 *src = (Uint32 *)(from);					\
+	Uint32 *dst = (Uint32 *)(to);					\
+	for(i = 0; i < (int)(length); i++) {				\
+	    Uint32 s = *src++;						\
+	    Uint32 d = *dst;						\
+	    *dst++ = (((s & 0x00fefefe) + (d & 0x00fefefe)) >> 1)	\
+		     + (s & d & 0x00010101);				\
+	}								\
+    } while(0)
+
+/*
+ * For 16bpp, we can actually blend two pixels in parallel, if we take
+ * care to shift before we add, not after.
+ */
+
+/* helper: blend a single 16 bit pixel at 50% */
+#define BLEND16_50(dst, src, mask)			\
+    do {						\
+        Uint32 s = *src++;				\
+	Uint32 d = *dst;				\
+	*dst++ = (((s & mask) + (d & mask)) >> 1)	\
+	         + (s & d & (~mask & 0xffff));		\
+    } while(0)
+
+/* basic 16bpp blender. mask is the pixels to keep when adding. */
+#define ALPHA_BLIT16_50(to, from, length, bpp, alpha, mask)		\
+    do {								\
+	unsigned n = (length);						\
+	Uint16 *src = (Uint16 *)(from);					\
+	Uint16 *dst = (Uint16 *)(to);					\
+	if(((unsigned long)src ^ (unsigned long)dst) & 3) {		\
+	    /* source and destination not in phase, blit one by one */	\
+	    while(n--)							\
+		BLEND16_50(dst, src, mask);				\
+	} else {							\
+	    if((unsigned long)src & 3) {				\
+		/* first odd pixel */					\
+		BLEND16_50(dst, src, mask);				\
+		n--;							\
+	    }								\
+	    for(; n > 1; n -= 2) {					\
+		Uint32 s = *(Uint32 *)src;				\
+		Uint32 d = *(Uint32 *)dst;				\
+		*(Uint32 *)dst = ((s & (mask | mask << 16)) >> 1)	\
+		               + ((d & (mask | mask << 16)) >> 1)	\
+		               + (s & d & (~(mask | mask << 16)));	\
+		src += 2;						\
+		dst += 2;						\
+	    }								\
+	    if(n)							\
+		BLEND16_50(dst, src, mask); /* last odd pixel */	\
+	}								\
+    } while(0)
+
+#define ALPHA_BLIT16_565_50(to, from, length, bpp, alpha)	\
+    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xf7de)
+
+#define ALPHA_BLIT16_555_50(to, from, length, bpp, alpha)	\
+    ALPHA_BLIT16_50(to, from, length, bpp, alpha, 0xfbde)
+
+
+#define CHOOSE_BLIT(blitter, alpha, fmt)				\
+    do {								\
+        if(alpha == 255) {						\
+	    switch(fmt->BytesPerPixel) {				\
+	    case 1: blitter(1, Uint8, OPAQUE_BLIT); break;		\
+	    case 2: blitter(2, Uint8, OPAQUE_BLIT); break;		\
+	    case 3: blitter(3, Uint8, OPAQUE_BLIT); break;		\
+	    case 4: blitter(4, Uint16, OPAQUE_BLIT); break;		\
+	    }								\
+	} else {							\
+	    switch(fmt->BytesPerPixel) {				\
+	    case 1:							\
+		/* No 8bpp alpha blitting */				\
+		break;							\
+									\
+	    case 2:							\
+		switch(fmt->Rmask | fmt->Gmask | fmt->Bmask) {		\
+		case 0xffff:						\
+		    if(fmt->Gmask == 0x07e0				\
+		       || fmt->Rmask == 0x07e0				\
+		       || fmt->Bmask == 0x07e0) {			\
+			if(alpha == 128)				\
+			    blitter(2, Uint8, ALPHA_BLIT16_565_50);	\
+			else {						\
+			    alpha >>= 3; /* use 5 bit alpha */		\
+			    blitter(2, Uint8, ALPHA_BLIT16_565);	\
+			}						\
+		    } else						\
+			goto general16;					\
+		    break;						\
+									\
+		case 0x7fff:						\
+		    if(fmt->Gmask == 0x03e0				\
+		       || fmt->Rmask == 0x03e0				\
+		       || fmt->Bmask == 0x03e0) {			\
+			if(alpha == 128)				\
+			    blitter(2, Uint8, ALPHA_BLIT16_555_50);	\
+			else {						\
+			    alpha >>= 3; /* use 5 bit alpha */		\
+			    blitter(2, Uint8, ALPHA_BLIT16_555);	\
+			}						\
+			break;						\
+		    }							\
+		    /* fallthrough */					\
+									\
+		default:						\
+		general16:						\
+		    blitter(2, Uint8, ALPHA_BLIT_ANY);			\
+		}							\
+		break;							\
+									\
+	    case 3:							\
+		blitter(3, Uint8, ALPHA_BLIT_ANY);			\
+		break;							\
+									\
+	    case 4:							\
+		if((fmt->Rmask | fmt->Gmask | fmt->Bmask) == 0x00ffffff	\
+		   && (fmt->Gmask == 0xff00 || fmt->Rmask == 0xff00	\
+		       || fmt->Bmask == 0xff00)) {			\
+		    if(alpha == 128)					\
+			blitter(4, Uint16, ALPHA_BLIT32_888_50);	\
+		    else						\
+			blitter(4, Uint16, ALPHA_BLIT32_888);		\
+		} else							\
+		    blitter(4, Uint16, ALPHA_BLIT_ANY);			\
+		break;							\
+	    }								\
+	}								\
+    } while(0)
+
+
+/*
+ * This takes care of the case when the surface is clipped on the left and/or
+ * right. Top clipping has already been taken care of.
+ */
+static void RLEClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst,
+			Uint8 *dstbuf, SDL_Rect *srcrect, unsigned alpha)
+{
+    SDL_PixelFormat *fmt = dst->format;
+
+#define RLECLIPBLIT(bpp, Type, do_blit)					   \
+    do {								   \
+	int linecount = srcrect->h;					   \
+	int ofs = 0;							   \
+	int left = srcrect->x;						   \
+	int right = left + srcrect->w;					   \
+	dstbuf -= left * bpp;						   \
+	for(;;) {							   \
+	    int run;							   \
+	    ofs += *(Type *)srcbuf;					   \
+	    run = ((Type *)srcbuf)[1];					   \
+	    srcbuf += 2 * sizeof(Type);					   \
+	    if(run) {							   \
+		/* clip to left and right borders */			   \
+		if(ofs < right) {					   \
+		    int start = 0;					   \
+		    int len = run;					   \
+		    int startcol;					   \
+		    if(left - ofs > 0) {				   \
+			start = left - ofs;				   \
+			len -= start;					   \
+			if(len <= 0)					   \
+			    goto nocopy ## bpp ## do_blit;		   \
+		    }							   \
+		    startcol = ofs + start;				   \
+		    if(len > right - startcol)				   \
+			len = right - startcol;				   \
+		    do_blit(dstbuf + startcol * bpp, srcbuf + start * bpp, \
+			    len, bpp, alpha);				   \
+		}							   \
+	    nocopy ## bpp ## do_blit:					   \
+		srcbuf += run * bpp;					   \
+		ofs += run;						   \
+	    } else if(!ofs)						   \
+		break;							   \
+	    if(ofs == w) {						   \
+		ofs = 0;						   \
+		dstbuf += dst->pitch;					   \
+		if(!--linecount)					   \
+		    break;						   \
+	    }								   \
+	}								   \
+    } while(0)
+
+    CHOOSE_BLIT(RLECLIPBLIT, alpha, fmt);
+
+#undef RLECLIPBLIT
+
+}
+
+
+/* blit a colorkeyed RLE surface */
+int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
+		SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	Uint8 *dstbuf;
+	Uint8 *srcbuf;
+	int x, y;
+	int w = src->w;
+	unsigned alpha;
+
+	/* Lock the destination if necessary */
+	if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		if ( video->LockHWSurface(this, dst) < 0 ) {
+			return(-1);
+		}
+	}
+
+	/* Set up the source and destination pointers */
+	x = dstrect->x;
+	y = dstrect->y;
+	dstbuf = (Uint8 *)dst->pixels + dst->offset
+	         + y * dst->pitch + x * src->format->BytesPerPixel;
+	srcbuf = (Uint8 *)src->map->sw_data->aux_data;
+
+	{
+	    /* skip lines at the top if neccessary */
+	    int vskip = srcrect->y;
+	    int ofs = 0;
+	    if(vskip) {
+
+#define RLESKIP(bpp, Type)			\
+		for(;;) {			\
+		    int run;			\
+		    ofs += *(Type *)srcbuf;	\
+		    run = ((Type *)srcbuf)[1];	\
+		    srcbuf += sizeof(Type) * 2;	\
+		    if(run) {			\
+			srcbuf += run * bpp;	\
+			ofs += run;		\
+		    } else if(!ofs)		\
+			goto done;		\
+		    if(ofs == w) {		\
+			ofs = 0;		\
+			if(!--vskip)		\
+			    break;		\
+		    }				\
+		}
+
+		switch(src->format->BytesPerPixel) {
+		case 1: RLESKIP(1, Uint8); break;
+		case 2: RLESKIP(2, Uint8); break;
+		case 3: RLESKIP(3, Uint8); break;
+		case 4: RLESKIP(4, Uint16); break;
+		}
+
+#undef RLESKIP
+
+	    }
+	}
+
+	alpha = (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA
+	        ? src->format->alpha : 255;
+	/* if left or right edge clipping needed, call clip blit */
+	if ( srcrect->x || srcrect->w != src->w ) {
+	    RLEClipBlit(w, srcbuf, dst, dstbuf, srcrect, alpha);
+	} else {
+	    SDL_PixelFormat *fmt = src->format;
+
+#define RLEBLIT(bpp, Type, do_blit)					      \
+	    do {							      \
+		int linecount = srcrect->h;				      \
+		int ofs = 0;						      \
+		for(;;) {						      \
+		    unsigned run;					      \
+		    ofs += *(Type *)srcbuf;				      \
+		    run = ((Type *)srcbuf)[1];				      \
+		    srcbuf += 2 * sizeof(Type);				      \
+		    if(run) {						      \
+			do_blit(dstbuf + ofs * bpp, srcbuf, run, bpp, alpha); \
+			srcbuf += run * bpp;				      \
+			ofs += run;					      \
+		    } else if(!ofs)					      \
+			break;						      \
+		    if(ofs == w) {					      \
+			ofs = 0;					      \
+			dstbuf += dst->pitch;				      \
+			if(!--linecount)				      \
+			    break;					      \
+		    }							      \
+		}							      \
+	    } while(0)
+
+	    CHOOSE_BLIT(RLEBLIT, alpha, fmt);
+
+#undef RLEBLIT
+	}
+
+done:
+	/* Unlock the destination if necessary */
+	if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->UnlockHWSurface(this, dst);
+	}
+	return(0);
+}
+
+#undef OPAQUE_BLIT
+
+/*
+ * Per-pixel blitting macros for translucent pixels:
+ * These use the same techniques as the per-surface blitting macros
+ */
+
+/*
+ * For 32bpp pixels, we have made sure the alpha is stored in the top
+ * 8 bits, so proceed as usual
+ */
+#define BLIT_TRANSL_888(src, dst)				\
+    do {							\
+        Uint32 s = src;						\
+	Uint32 d = dst;						\
+	unsigned alpha = s >> 24;				\
+	Uint32 s1 = s & 0xff00ff;				\
+	Uint32 d1 = d & 0xff00ff;				\
+	d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;	\
+	s &= 0xff00;						\
+	d &= 0xff00;						\
+	d = (d + ((s - d) * alpha >> 8)) & 0xff00;		\
+	dst = d1 | d;						\
+    } while(0)
+
+/*
+ * For 16bpp pixels, we have stored the 5 most significant alpha bits in
+ * bits 5-10. As before, we can process all 3 RGB components at the same time.
+ */
+#define BLIT_TRANSL_565(src, dst)		\
+    do {					\
+        Uint32 s = src;				\
+	Uint32 d = dst;				\
+	unsigned alpha = (s & 0x3e0) >> 5;	\
+	s &= 0x07e0f81f;			\
+	d = (d | d << 16) & 0x07e0f81f;		\
+	d += (s - d) * alpha >> 5;		\
+	d &= 0x07e0f81f;			\
+	dst = d | d >> 16;			\
+    } while(0)
+
+#define BLIT_TRANSL_555(src, dst)		\
+    do {					\
+        Uint32 s = src;				\
+	Uint32 d = dst;				\
+	unsigned alpha = (s & 0x3e0) >> 5;	\
+	s &= 0x03e07c1f;			\
+	d = (d | d << 16) & 0x03e07c1f;		\
+	d += (s - d) * alpha >> 5;		\
+	d &= 0x03e07c1f;			\
+	dst = d | d >> 16;			\
+    } while(0)
+
+/* used to save the destination format in the encoding. Designed to be
+   macro-compatible with SDL_PixelFormat but without the unneeded fields */
+typedef struct {
+    	Uint8  BytesPerPixel;
+	Uint8  Rloss;
+	Uint8  Gloss;
+	Uint8  Bloss;
+	Uint8  Rshift;
+	Uint8  Gshift;
+	Uint8  Bshift;
+	Uint8  Ashift;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	Uint32 Amask;
+} RLEDestFormat;
+
+/* blit a pixel-alpha RLE surface clipped at the right and/or left edges */
+static void RLEAlphaClipBlit(int w, Uint8 *srcbuf, SDL_Surface *dst,
+			     Uint8 *dstbuf, SDL_Rect *srcrect)
+{
+    SDL_PixelFormat *df = dst->format;
+    /*
+     * clipped blitter: Ptype is the destination pixel type,
+     * Ctype the translucent count type, and do_blend the macro
+     * to blend one pixel.
+     */
+#define RLEALPHACLIPBLIT(Ptype, Ctype, do_blend)			  \
+    do {								  \
+	int linecount = srcrect->h;					  \
+	int left = srcrect->x;						  \
+	int right = left + srcrect->w;					  \
+	dstbuf -= left * sizeof(Ptype);					  \
+	do {								  \
+	    int ofs = 0;						  \
+	    /* blit opaque pixels on one line */			  \
+	    do {							  \
+		unsigned run;						  \
+		ofs += ((Ctype *)srcbuf)[0];				  \
+		run = ((Ctype *)srcbuf)[1];				  \
+		srcbuf += 2 * sizeof(Ctype);				  \
+		if(run) {						  \
+		    /* clip to left and right borders */		  \
+		    int cofs = ofs;					  \
+		    int crun = run;					  \
+		    if(left - cofs > 0) {				  \
+			crun -= left - cofs;				  \
+			cofs = left;					  \
+		    }							  \
+		    if(crun > right - cofs)				  \
+			crun = right - cofs;				  \
+		    if(crun > 0)					  \
+			SDL_memcpy(dstbuf + cofs * sizeof(Ptype),	  \
+				   srcbuf + (cofs - ofs) * sizeof(Ptype), \
+				   (unsigned)crun * sizeof(Ptype));	  \
+		    srcbuf += run * sizeof(Ptype);			  \
+		    ofs += run;						  \
+		} else if(!ofs)						  \
+		    return;						  \
+	    } while(ofs < w);						  \
+	    /* skip padding if necessary */				  \
+	    if(sizeof(Ptype) == 2)					  \
+		srcbuf += (unsigned long)srcbuf & 2;			  \
+	    /* blit translucent pixels on the same line */		  \
+	    ofs = 0;							  \
+	    do {							  \
+		unsigned run;						  \
+		ofs += ((Uint16 *)srcbuf)[0];				  \
+		run = ((Uint16 *)srcbuf)[1];				  \
+		srcbuf += 4;						  \
+		if(run) {						  \
+		    /* clip to left and right borders */		  \
+		    int cofs = ofs;					  \
+		    int crun = run;					  \
+		    if(left - cofs > 0) {				  \
+			crun -= left - cofs;				  \
+			cofs = left;					  \
+		    }							  \
+		    if(crun > right - cofs)				  \
+			crun = right - cofs;				  \
+		    if(crun > 0) {					  \
+			Ptype *dst = (Ptype *)dstbuf + cofs;		  \
+			Uint32 *src = (Uint32 *)srcbuf + (cofs - ofs);	  \
+			int i;						  \
+			for(i = 0; i < crun; i++)			  \
+			    do_blend(src[i], dst[i]);			  \
+		    }							  \
+		    srcbuf += run * 4;					  \
+		    ofs += run;						  \
+		}							  \
+	    } while(ofs < w);						  \
+	    dstbuf += dst->pitch;					  \
+	} while(--linecount);						  \
+    } while(0)
+
+    switch(df->BytesPerPixel) {
+    case 2:
+	if(df->Gmask == 0x07e0 || df->Rmask == 0x07e0
+	   || df->Bmask == 0x07e0)
+	    RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_565);
+	else
+	    RLEALPHACLIPBLIT(Uint16, Uint8, BLIT_TRANSL_555);
+	break;
+    case 4:
+	RLEALPHACLIPBLIT(Uint32, Uint16, BLIT_TRANSL_888);
+	break;
+    }
+}
+
+/* blit a pixel-alpha RLE surface */
+int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect,
+		     SDL_Surface *dst, SDL_Rect *dstrect)
+{
+    int x, y;
+    int w = src->w;
+    Uint8 *srcbuf, *dstbuf;
+    SDL_PixelFormat *df = dst->format;
+
+    /* Lock the destination if necessary */
+    if(dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT)) {
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	if(video->LockHWSurface(this, dst) < 0) {
+	    return -1;
+	}
+    }
+
+    x = dstrect->x;
+    y = dstrect->y;
+    dstbuf = (Uint8 *)dst->pixels + dst->offset
+	     + y * dst->pitch + x * df->BytesPerPixel;
+    srcbuf = (Uint8 *)src->map->sw_data->aux_data + sizeof(RLEDestFormat);
+
+    {
+	/* skip lines at the top if necessary */
+	int vskip = srcrect->y;
+	if(vskip) {
+	    int ofs;
+	    if(df->BytesPerPixel == 2) {
+		/* the 16/32 interleaved format */
+		do {
+		    /* skip opaque line */
+		    ofs = 0;
+		    do {
+			int run;
+			ofs += srcbuf[0];
+			run = srcbuf[1];
+			srcbuf += 2;
+			if(run) {
+			    srcbuf += 2 * run;
+			    ofs += run;
+			} else if(!ofs)
+			    goto done;
+		    } while(ofs < w);
+
+		    /* skip padding */
+		    srcbuf += (unsigned long)srcbuf & 2;
+
+		    /* skip translucent line */
+		    ofs = 0;
+		    do {
+			int run;
+			ofs += ((Uint16 *)srcbuf)[0];
+			run = ((Uint16 *)srcbuf)[1];
+			srcbuf += 4 * (run + 1);
+			ofs += run;
+		    } while(ofs < w);
+		} while(--vskip);
+	    } else {
+		/* the 32/32 interleaved format */
+		vskip <<= 1;	/* opaque and translucent have same format */
+		do {
+		    ofs = 0;
+		    do {
+			int run;
+			ofs += ((Uint16 *)srcbuf)[0];
+			run = ((Uint16 *)srcbuf)[1];
+			srcbuf += 4;
+			if(run) {
+			    srcbuf += 4 * run;
+			    ofs += run;
+			} else if(!ofs)
+			    goto done;
+		    } while(ofs < w);
+		} while(--vskip);
+	    }
+	}
+    }
+
+    /* if left or right edge clipping needed, call clip blit */
+    if(srcrect->x || srcrect->w != src->w) {
+	RLEAlphaClipBlit(w, srcbuf, dst, dstbuf, srcrect);
+    } else {
+
+	/*
+	 * non-clipped blitter. Ptype is the destination pixel type,
+	 * Ctype the translucent count type, and do_blend the
+	 * macro to blend one pixel.
+	 */
+#define RLEALPHABLIT(Ptype, Ctype, do_blend)				 \
+	do {								 \
+	    int linecount = srcrect->h;					 \
+	    do {							 \
+		int ofs = 0;						 \
+		/* blit opaque pixels on one line */			 \
+		do {							 \
+		    unsigned run;					 \
+		    ofs += ((Ctype *)srcbuf)[0];			 \
+		    run = ((Ctype *)srcbuf)[1];				 \
+		    srcbuf += 2 * sizeof(Ctype);			 \
+		    if(run) {						 \
+			SDL_memcpy(dstbuf + ofs * sizeof(Ptype), srcbuf, \
+				   run * sizeof(Ptype));		 \
+			srcbuf += run * sizeof(Ptype);			 \
+			ofs += run;					 \
+		    } else if(!ofs)					 \
+			goto done;					 \
+		} while(ofs < w);					 \
+		/* skip padding if necessary */				 \
+		if(sizeof(Ptype) == 2)					 \
+		    srcbuf += (unsigned long)srcbuf & 2;		 \
+		/* blit translucent pixels on the same line */		 \
+		ofs = 0;						 \
+		do {							 \
+		    unsigned run;					 \
+		    ofs += ((Uint16 *)srcbuf)[0];			 \
+		    run = ((Uint16 *)srcbuf)[1];			 \
+		    srcbuf += 4;					 \
+		    if(run) {						 \
+			Ptype *dst = (Ptype *)dstbuf + ofs;		 \
+			unsigned i;					 \
+			for(i = 0; i < run; i++) {			 \
+			    Uint32 src = *(Uint32 *)srcbuf;		 \
+			    do_blend(src, *dst);			 \
+			    srcbuf += 4;				 \
+			    dst++;					 \
+			}						 \
+			ofs += run;					 \
+		    }							 \
+		} while(ofs < w);					 \
+		dstbuf += dst->pitch;					 \
+	    } while(--linecount);					 \
+	} while(0)
+
+	switch(df->BytesPerPixel) {
+	case 2:
+	    if(df->Gmask == 0x07e0 || df->Rmask == 0x07e0
+	       || df->Bmask == 0x07e0)
+		RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_565);
+	    else
+		RLEALPHABLIT(Uint16, Uint8, BLIT_TRANSL_555);
+	    break;
+	case 4:
+	    RLEALPHABLIT(Uint32, Uint16, BLIT_TRANSL_888);
+	    break;
+	}
+    }
+
+ done:
+    /* Unlock the destination if necessary */
+    if(dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT)) {
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	video->UnlockHWSurface(this, dst);
+    }
+    return 0;
+}
+
+/*
+ * Auxiliary functions:
+ * The encoding functions take 32bpp rgb + a, and
+ * return the number of bytes copied to the destination.
+ * The decoding functions copy to 32bpp rgb + a, and
+ * return the number of bytes copied from the source.
+ * These are only used in the encoder and un-RLE code and are therefore not
+ * highly optimised.
+ */
+
+/* encode 32bpp rgb + a into 16bpp rgb, losing alpha */
+static int copy_opaque_16(void *dst, Uint32 *src, int n,
+			  SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint16 *d = dst;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b;
+	RGB_FROM_PIXEL(*src, sfmt, r, g, b);
+	PIXEL_FROM_RGB(*d, dfmt, r, g, b);
+	src++;
+	d++;
+    }
+    return n * 2;
+}
+
+/* decode opaque pixels from 16bpp to 32bpp rgb + a */
+static int uncopy_opaque_16(Uint32 *dst, void *src, int n,
+			    RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint16 *s = src;
+    unsigned alpha = dfmt->Amask ? 255 : 0;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b;
+	RGB_FROM_PIXEL(*s, sfmt, r, g, b);
+	PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, alpha);
+	s++;
+	dst++;
+    }
+    return n * 2;
+}
+
+
+
+/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 565 */
+static int copy_transl_565(void *dst, Uint32 *src, int n,
+			   SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint32 *d = dst;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b, a;
+	Uint16 pix;
+	RGBA_FROM_8888(*src, sfmt, r, g, b, a);
+	PIXEL_FROM_RGB(pix, dfmt, r, g, b);
+	*d = ((pix & 0x7e0) << 16) | (pix & 0xf81f) | ((a << 2) & 0x7e0);
+	src++;
+	d++;
+    }
+    return n * 4;
+}
+
+/* encode 32bpp rgb + a into 32bpp G0RAB format for blitting into 555 */
+static int copy_transl_555(void *dst, Uint32 *src, int n,
+			   SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint32 *d = dst;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b, a;
+	Uint16 pix;
+	RGBA_FROM_8888(*src, sfmt, r, g, b, a);
+	PIXEL_FROM_RGB(pix, dfmt, r, g, b);
+	*d = ((pix & 0x3e0) << 16) | (pix & 0xfc1f) | ((a << 2) & 0x3e0);
+	src++;
+	d++;
+    }
+    return n * 4;
+}
+
+/* decode translucent pixels from 32bpp GORAB to 32bpp rgb + a */
+static int uncopy_transl_16(Uint32 *dst, void *src, int n,
+			    RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint32 *s = src;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b, a;
+	Uint32 pix = *s++;
+	a = (pix & 0x3e0) >> 2;
+	pix = (pix & ~0x3e0) | pix >> 16;
+	RGB_FROM_PIXEL(pix, sfmt, r, g, b);
+	PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a);
+	dst++;
+    }
+    return n * 4;
+}
+
+/* encode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
+static int copy_32(void *dst, Uint32 *src, int n,
+		   SDL_PixelFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint32 *d = dst;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b, a;
+	Uint32 pixel;
+	RGBA_FROM_8888(*src, sfmt, r, g, b, a);
+	PIXEL_FROM_RGB(pixel, dfmt, r, g, b);
+	*d++ = pixel | a << 24;
+	src++;
+    }
+    return n * 4;
+}
+
+/* decode 32bpp rgba into 32bpp rgba, keeping alpha (dual purpose) */
+static int uncopy_32(Uint32 *dst, void *src, int n,
+		     RLEDestFormat *sfmt, SDL_PixelFormat *dfmt)
+{
+    int i;
+    Uint32 *s = src;
+    for(i = 0; i < n; i++) {
+	unsigned r, g, b, a;
+	Uint32 pixel = *s++;
+	RGB_FROM_PIXEL(pixel, sfmt, r, g, b);
+	a = pixel >> 24;
+	PIXEL_FROM_RGBA(*dst, dfmt, r, g, b, a);
+	dst++;
+    }
+    return n * 4;
+}
+
+#define ISOPAQUE(pixel, fmt) ((((pixel) & fmt->Amask) >> fmt->Ashift) == 255)
+
+#define ISTRANSL(pixel, fmt)	\
+    ((unsigned)((((pixel) & fmt->Amask) >> fmt->Ashift) - 1U) < 254U)
+
+/* convert surface to be quickly alpha-blittable onto dest, if possible */
+static int RLEAlphaSurface(SDL_Surface *surface)
+{
+    SDL_Surface *dest;
+    SDL_PixelFormat *df;
+    int maxsize = 0;
+    int max_opaque_run;
+    int max_transl_run = 65535;
+    unsigned masksum;
+    Uint8 *rlebuf, *dst;
+    int (*copy_opaque)(void *, Uint32 *, int,
+		       SDL_PixelFormat *, SDL_PixelFormat *);
+    int (*copy_transl)(void *, Uint32 *, int,
+		       SDL_PixelFormat *, SDL_PixelFormat *);
+
+    dest = surface->map->dst;
+    if(!dest)
+	return -1;
+    df = dest->format;
+    if(surface->format->BitsPerPixel != 32)
+	return -1;		/* only 32bpp source supported */
+
+    /* find out whether the destination is one we support,
+       and determine the max size of the encoded result */
+    masksum = df->Rmask | df->Gmask | df->Bmask;
+    switch(df->BytesPerPixel) {
+    case 2:
+	/* 16bpp: only support 565 and 555 formats */
+	switch(masksum) {
+	case 0xffff:
+	    if(df->Gmask == 0x07e0
+	       || df->Rmask == 0x07e0 || df->Bmask == 0x07e0) {
+		copy_opaque = copy_opaque_16;
+		copy_transl = copy_transl_565;
+	    } else
+		return -1;
+	    break;
+	case 0x7fff:
+	    if(df->Gmask == 0x03e0
+	       || df->Rmask == 0x03e0 || df->Bmask == 0x03e0) {
+		copy_opaque = copy_opaque_16;
+		copy_transl = copy_transl_555;
+	    } else
+		return -1;
+	    break;
+	default:
+	    return -1;
+	}
+	max_opaque_run = 255;	/* runs stored as bytes */
+
+	/* worst case is alternating opaque and translucent pixels,
+	   with room for alignment padding between lines */
+	maxsize = surface->h * (2 + (4 + 2) * (surface->w + 1)) + 2;
+	break;
+    case 4:
+	if(masksum != 0x00ffffff)
+	    return -1;		/* requires unused high byte */
+	copy_opaque = copy_32;
+	copy_transl = copy_32;
+	max_opaque_run = 255;	/* runs stored as short ints */
+
+	/* worst case is alternating opaque and translucent pixels */
+	maxsize = surface->h * 2 * 4 * (surface->w + 1) + 4;
+	break;
+    default:
+	return -1;		/* anything else unsupported right now */
+    }
+
+    maxsize += sizeof(RLEDestFormat);
+    rlebuf = (Uint8 *)malloc(maxsize);
+    if(!rlebuf) {
+	SDL_OutOfMemory();
+	return -1;
+    }
+    {
+	/* save the destination format so we can undo the encoding later */
+	RLEDestFormat *r = (RLEDestFormat *)rlebuf;
+	r->BytesPerPixel = df->BytesPerPixel;
+	r->Rloss = df->Rloss;
+	r->Gloss = df->Gloss;
+	r->Bloss = df->Bloss;
+	r->Rshift = df->Rshift;
+	r->Gshift = df->Gshift;
+	r->Bshift = df->Bshift;
+	r->Ashift = df->Ashift;
+	r->Rmask = df->Rmask;
+	r->Gmask = df->Gmask;
+	r->Bmask = df->Bmask;
+	r->Amask = df->Amask;
+    }
+    dst = rlebuf + sizeof(RLEDestFormat);
+
+    /* Do the actual encoding */
+    {
+	int x, y;
+	int h = surface->h, w = surface->w;
+	SDL_PixelFormat *sf = surface->format;
+	Uint32 *src = (Uint32 *)((Uint8 *)surface->pixels + surface->offset);
+	Uint8 *lastline = dst;	/* end of last non-blank line */
+
+	/* opaque counts are 8 or 16 bits, depending on target depth */
+#define ADD_OPAQUE_COUNTS(n, m)			\
+	if(df->BytesPerPixel == 4) {		\
+	    ((Uint16 *)dst)[0] = n;		\
+	    ((Uint16 *)dst)[1] = m;		\
+	    dst += 4;				\
+	} else {				\
+	    dst[0] = n;				\
+	    dst[1] = m;				\
+	    dst += 2;				\
+	}
+
+	/* translucent counts are always 16 bit */
+#define ADD_TRANSL_COUNTS(n, m)		\
+	(((Uint16 *)dst)[0] = n, ((Uint16 *)dst)[1] = m, dst += 4)
+
+	for(y = 0; y < h; y++) {
+	    int runstart, skipstart;
+	    int blankline = 0;
+	    /* First encode all opaque pixels of a scan line */
+	    x = 0;
+	    do {
+		int run, skip, len;
+		skipstart = x;
+		while(x < w && !ISOPAQUE(src[x], sf))
+		    x++;
+		runstart = x;
+		while(x < w && ISOPAQUE(src[x], sf))
+		    x++;
+		skip = runstart - skipstart;
+		if(skip == w)
+		    blankline = 1;
+		run = x - runstart;
+		while(skip > max_opaque_run) {
+		    ADD_OPAQUE_COUNTS(max_opaque_run, 0);
+		    skip -= max_opaque_run;
+		}
+		len = MIN(run, max_opaque_run);
+		ADD_OPAQUE_COUNTS(skip, len);
+		dst += copy_opaque(dst, src + runstart, len, sf, df);
+		runstart += len;
+		run -= len;
+		while(run) {
+		    len = MIN(run, max_opaque_run);
+		    ADD_OPAQUE_COUNTS(0, len);
+		    dst += copy_opaque(dst, src + runstart, len, sf, df);
+		    runstart += len;
+		    run -= len;
+		}
+	    } while(x < w);
+
+	    /* Make sure the next output address is 32-bit aligned */
+	    dst += (unsigned long)dst & 2;
+
+	    /* Next, encode all translucent pixels of the same scan line */
+	    x = 0;
+	    do {
+		int run, skip, len;
+		skipstart = x;
+		while(x < w && !ISTRANSL(src[x], sf))
+		    x++;
+		runstart = x;
+		while(x < w && ISTRANSL(src[x], sf))
+		    x++;
+		skip = runstart - skipstart;
+		blankline &= (skip == w);
+		run = x - runstart;
+		while(skip > max_transl_run) {
+		    ADD_TRANSL_COUNTS(max_transl_run, 0);
+		    skip -= max_transl_run;
+		}
+		len = MIN(run, max_transl_run);
+		ADD_TRANSL_COUNTS(skip, len);
+		dst += copy_transl(dst, src + runstart, len, sf, df);
+		runstart += len;
+		run -= len;
+		while(run) {
+		    len = MIN(run, max_transl_run);
+		    ADD_TRANSL_COUNTS(0, len);
+		    dst += copy_transl(dst, src + runstart, len, sf, df);
+		    runstart += len;
+		    run -= len;
+		}
+		if(!blankline)
+		    lastline = dst;
+	    } while(x < w);
+
+	    src += surface->pitch >> 2;
+	}
+	dst = lastline;		/* back up past trailing blank lines */
+	ADD_OPAQUE_COUNTS(0, 0);
+    }
+
+#undef ADD_OPAQUE_COUNTS
+#undef ADD_TRANSL_COUNTS
+
+    /* Now that we have it encoded, release the original pixels */
+    if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
+       && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
+	free( surface->pixels );
+	surface->pixels = NULL;
+    }
+
+    /* realloc the buffer to release unused memory */
+    {
+	Uint8 *p = realloc(rlebuf, dst - rlebuf);
+	if(!p)
+	    p = rlebuf;
+	surface->map->sw_data->aux_data = p;
+    }
+
+    return 0;
+}
+
+static Uint32 getpix_8(Uint8 *srcbuf)
+{
+    return *srcbuf;
+}
+
+static Uint32 getpix_16(Uint8 *srcbuf)
+{
+    return *(Uint16 *)srcbuf;
+}
+
+static Uint32 getpix_24(Uint8 *srcbuf)
+{
+    if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
+	return srcbuf[0] + (srcbuf[1] << 8) + (srcbuf[2] << 16);
+    else
+	return (srcbuf[0] << 16) + (srcbuf[1] << 8) + srcbuf[2];
+}
+
+static Uint32 getpix_32(Uint8 *srcbuf)
+{
+    return *(Uint32 *)srcbuf;
+}
+
+typedef Uint32 (*getpix_func)(Uint8 *);
+
+static getpix_func getpixes[4] = {
+    getpix_8, getpix_16, getpix_24, getpix_32
+};
+
+static int RLEColorkeySurface(SDL_Surface *surface)
+{
+        Uint8 *rlebuf, *dst;
+	int maxn;
+	int y;
+	Uint8 *srcbuf, *curbuf, *lastline;
+	int maxsize = 0;
+	int skip, run;
+	int bpp = surface->format->BytesPerPixel;
+	getpix_func getpix;
+	Uint32 ckey, rgbmask;
+	int w, h;
+
+	/* calculate the worst case size for the compressed surface */
+	switch(bpp) {
+	case 1:
+	    /* worst case is alternating opaque and transparent pixels,
+	       starting with an opaque pixel */
+	    maxsize = surface->h * 3 * (surface->w / 2 + 1) + 2;
+	    break;
+	case 2:
+	case 3:
+	    /* worst case is solid runs, at most 255 pixels wide */
+	    maxsize = surface->h * (2 * (surface->w / 255 + 1)
+				    + surface->w * bpp) + 2;
+	    break;
+	case 4:
+	    /* worst case is solid runs, at most 65535 pixels wide */
+	    maxsize = surface->h * (4 * (surface->w / 65535 + 1)
+				    + surface->w * 4) + 4;
+	    break;
+	}
+
+	rlebuf = (Uint8 *)malloc(maxsize);
+	if ( rlebuf == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+
+	/* Set up the conversion */
+	srcbuf = (Uint8 *)surface->pixels+surface->offset;
+	curbuf = srcbuf;
+	maxn = bpp == 4 ? 65535 : 255;
+	skip = run = 0;
+	dst = rlebuf;
+	rgbmask = ~surface->format->Amask;
+	ckey = surface->format->colorkey & rgbmask;
+	lastline = dst;
+	getpix = getpixes[bpp - 1];
+	w = surface->w;
+	h = surface->h;
+
+#define ADD_COUNTS(n, m)			\
+	if(bpp == 4) {				\
+	    ((Uint16 *)dst)[0] = n;		\
+	    ((Uint16 *)dst)[1] = m;		\
+	    dst += 4;				\
+	} else {				\
+	    dst[0] = n;				\
+	    dst[1] = m;				\
+	    dst += 2;				\
+	}
+
+	for(y = 0; y < h; y++) {
+	    int x = 0;
+	    int blankline = 0;
+	    do {
+		int run, skip, len;
+		int runstart;
+		int skipstart = x;
+
+		/* find run of transparent, then opaque pixels */
+		while(x < w && (getpix(srcbuf + x * bpp) & rgbmask) == ckey)
+		    x++;
+		runstart = x;
+		while(x < w && (getpix(srcbuf + x * bpp) & rgbmask) != ckey)
+		    x++;
+		skip = runstart - skipstart;
+		if(skip == w)
+		    blankline = 1;
+		run = x - runstart;
+
+		/* encode segment */
+		while(skip > maxn) {
+		    ADD_COUNTS(maxn, 0);
+		    skip -= maxn;
+		}
+		len = MIN(run, maxn);
+		ADD_COUNTS(skip, len);
+		memcpy(dst, srcbuf + runstart * bpp, len * bpp);
+		dst += len * bpp;
+		run -= len;
+		runstart += len;
+		while(run) {
+		    len = MIN(run, maxn);
+		    ADD_COUNTS(0, len);
+		    memcpy(dst, srcbuf + runstart * bpp, len * bpp);
+		    dst += len * bpp;
+		    runstart += len;
+		    run -= len;
+		}
+		if(!blankline)
+		    lastline = dst;
+	    } while(x < w);
+
+	    srcbuf += surface->pitch;
+	}
+	dst = lastline;		/* back up bast trailing blank lines */
+	ADD_COUNTS(0, 0);
+
+#undef ADD_COUNTS
+
+	/* Now that we have it encoded, release the original pixels */
+	if((surface->flags & SDL_PREALLOC) != SDL_PREALLOC
+	   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
+	    free( surface->pixels );
+	    surface->pixels = NULL;
+	}
+
+	/* realloc the buffer to release unused memory */
+	{
+	    /* If realloc returns NULL, the original block is left intact */
+	    Uint8 *p = realloc(rlebuf, dst - rlebuf);
+	    if(!p)
+		p = rlebuf;
+	    surface->map->sw_data->aux_data = p;
+	}
+
+	return(0);
+}
+
+int SDL_RLESurface(SDL_Surface *surface)
+{
+	int retcode;
+
+	/* Clear any previous RLE conversion */
+	if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+		SDL_UnRLESurface(surface, 1);
+	}
+
+	/* We don't support RLE encoding of bitmaps */
+	if ( surface->format->BitsPerPixel < 8 ) {
+		return(-1);
+	}
+
+	/* Lock the surface if it's in hardware */
+	if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		if ( video->LockHWSurface(this, surface) < 0 ) {
+			return(-1);
+		}
+	}
+
+	/* Encode */
+	if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
+	    retcode = RLEColorkeySurface(surface);
+	} else {
+	    if((surface->flags & SDL_SRCALPHA) == SDL_SRCALPHA
+	       && surface->format->Amask != 0)
+		retcode = RLEAlphaSurface(surface);
+	    else
+		retcode = -1;	/* no RLE for per-surface alpha sans ckey */
+	}
+
+	/* Unlock the surface if it's in hardware */
+	if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->UnlockHWSurface(this, surface);
+	}
+
+	if(retcode < 0)
+	    return -1;
+
+	/* The surface is now accelerated */
+	surface->flags |= SDL_RLEACCEL;
+
+	return(0);
+}
+
+/*
+ * Un-RLE a surface with pixel alpha
+ * This may not give back exactly the image before RLE-encoding; all
+ * completely transparent pixels will be lost, and colour and alpha depth
+ * may have been reduced (when encoding for 16bpp targets).
+ */
+static void UnRLEAlpha(SDL_Surface *surface)
+{
+    Uint8 *srcbuf;
+    Uint32 *dst;
+    SDL_PixelFormat *sf = surface->format;
+    RLEDestFormat *df = surface->map->sw_data->aux_data;
+    int (*uncopy_opaque)(Uint32 *, void *, int,
+			 RLEDestFormat *, SDL_PixelFormat *);
+    int (*uncopy_transl)(Uint32 *, void *, int,
+			 RLEDestFormat *, SDL_PixelFormat *);
+    int w = surface->w;
+    int bpp = df->BytesPerPixel;
+
+    if(bpp == 2) {
+	uncopy_opaque = uncopy_opaque_16;
+	uncopy_transl = uncopy_transl_16;
+    } else {
+	uncopy_opaque = uncopy_transl = uncopy_32;
+    }
+
+    surface->pixels = malloc(surface->h * surface->pitch);
+    /* fill background with transparent pixels */
+    memset(surface->pixels, 0, surface->h * surface->pitch);
+
+    dst = surface->pixels;
+    srcbuf = (Uint8 *)(df + 1);
+    for(;;) {
+	/* copy opaque pixels */
+	int ofs = 0;
+	do {
+	    unsigned run;
+	    if(bpp == 2) {
+		ofs += srcbuf[0];
+		run = srcbuf[1];
+		srcbuf += 2;
+	    } else {
+		ofs += ((Uint16 *)srcbuf)[0];
+		run = ((Uint16 *)srcbuf)[1];
+		srcbuf += 4;
+	    }
+	    if(run) {
+		srcbuf += uncopy_opaque(dst + ofs, srcbuf, run, df, sf);
+		ofs += run;
+	    } else if(!ofs)
+		return;
+	} while(ofs < w);
+
+	/* skip padding if needed */
+	if(bpp == 2)
+	    srcbuf += (unsigned long)srcbuf & 2;
+	
+	/* copy translucent pixels */
+	ofs = 0;
+	do {
+	    unsigned run;
+	    ofs += ((Uint16 *)srcbuf)[0];
+	    run = ((Uint16 *)srcbuf)[1];
+	    srcbuf += 4;
+	    if(run) {
+		srcbuf += uncopy_transl(dst + ofs, srcbuf, run, df, sf);
+		ofs += run;
+	    }
+	} while(ofs < w);
+	dst += surface->pitch >> 2;
+    }
+}
+
+void SDL_UnRLESurface(SDL_Surface *surface, int recode)
+{
+    if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+	surface->flags &= ~SDL_RLEACCEL;
+
+	if(recode && (surface->flags & SDL_PREALLOC) != SDL_PREALLOC
+	   && (surface->flags & SDL_HWSURFACE) != SDL_HWSURFACE) {
+	    if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
+		SDL_Rect full;
+		unsigned alpha_flag;
+
+		/* re-create the original surface */
+		surface->pixels = malloc(surface->h * surface->pitch);
+
+		/* fill it with the background colour */
+		SDL_FillRect(surface, NULL, surface->format->colorkey);
+
+		/* now render the encoded surface */
+		full.x = full.y = 0;
+		full.w = surface->w;
+		full.h = surface->h;
+		alpha_flag = surface->flags & SDL_SRCALPHA;
+		surface->flags &= ~SDL_SRCALPHA; /* opaque blit */
+		SDL_RLEBlit(surface, &full, surface, &full);
+		surface->flags |= alpha_flag;
+	    } else
+		UnRLEAlpha(surface);
+	}
+
+	if ( surface->map && surface->map->sw_data->aux_data ) {
+	    free(surface->map->sw_data->aux_data);
+	    surface->map->sw_data->aux_data = NULL;
+	}
+    }
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_RLEaccel_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful functions and variables from SDL_RLEaccel.c */
+
+extern int SDL_RLESurface(SDL_Surface *surface);
+extern int SDL_RLEBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect);
+extern int SDL_RLEAlphaBlit(SDL_Surface *src, SDL_Rect *srcrect,
+			    SDL_Surface *dst, SDL_Rect *dstrect);
+extern void SDL_UnRLESurface(SDL_Surface *surface, int recode);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,294 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+#include "SDL_blit.h"
+#include "SDL_RLEaccel_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_memops.h"
+
+/* The general purpose software blit routine */
+static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect,
+			SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	int okay;
+	int src_locked;
+	int dst_locked;
+
+	/* Everything is okay at the beginning...  */
+	okay = 1;
+
+	/* Lock the destination if it's in hardware */
+	dst_locked = 0;
+	if ( dst->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		if ( video->LockHWSurface(this, dst) < 0 ) {
+			okay = 0;
+		} else {
+			dst_locked = 1;
+		}
+	}
+	/* Lock the source if it's in hardware */
+	src_locked = 0;
+	if ( src->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		if ( video->LockHWSurface(this, src) < 0 ) {
+			okay = 0;
+		} else {
+			src_locked = 1;
+		}
+	}
+
+	/* Unencode the destination if it's RLE encoded */
+	if ( dst->flags & SDL_RLEACCEL ) {
+		SDL_UnRLESurface(dst, 1);
+		dst->flags |= SDL_RLEACCEL;	/* save accel'd state */
+	}
+
+	/* Set up source and destination buffer pointers, and BLIT! */
+	if ( okay  && srcrect->w && srcrect->h ) {
+		SDL_BlitInfo info;
+		SDL_loblit RunBlit;
+
+		/* Set up the blit information */
+		info.s_pixels = (Uint8 *)src->pixels + src->offset +
+				(Uint16)srcrect->y*src->pitch +
+				(Uint16)srcrect->x*src->format->BytesPerPixel;
+		info.s_width = srcrect->w;
+		info.s_height = srcrect->h;
+		info.s_skip=src->pitch-info.s_width*src->format->BytesPerPixel;
+		info.d_pixels = (Uint8 *)dst->pixels + dst->offset +
+				(Uint16)dstrect->y*dst->pitch +
+				(Uint16)dstrect->x*dst->format->BytesPerPixel;
+		info.d_width = dstrect->w;
+		info.d_height = dstrect->h;
+		info.d_skip=dst->pitch-info.d_width*dst->format->BytesPerPixel;
+		info.aux_data = src->map->sw_data->aux_data;
+		info.src = src->format;
+		info.table = src->map->table;
+		info.dst = dst->format;
+		RunBlit = src->map->sw_data->blit;
+
+		/* Run the actual software blit */
+		RunBlit(&info);
+	}
+
+	/* Re-encode the destination if it's RLE encoded */
+	if ( dst->flags & SDL_RLEACCEL ) {
+	        dst->flags &= ~SDL_RLEACCEL; /* stop lying */
+		SDL_RLESurface(dst);
+	}
+
+	/* We need to unlock the surfaces if they're locked */
+	if ( dst_locked ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->UnlockHWSurface(this, dst);
+	} else
+	if ( src_locked ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->UnlockHWSurface(this, src);
+	}
+	/* Blit is done! */
+	return(okay ? 0 : -1);
+}
+
+static void SDL_BlitCopy(SDL_BlitInfo *info)
+{
+	Uint8 *src, *dst;
+	int w, h;
+	int srcskip, dstskip;
+
+	w = info->d_width*info->dst->BytesPerPixel;
+	h = info->d_height;
+	src = info->s_pixels;
+	dst = info->d_pixels;
+	srcskip = w+info->s_skip;
+	dstskip = w+info->d_skip;
+	while ( h-- ) {
+		SDL_memcpy(dst, src, w);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void SDL_BlitCopyOverlap(SDL_BlitInfo *info)
+{
+	Uint8 *src, *dst;
+	int w, h;
+	int srcskip, dstskip;
+
+	w = info->d_width*info->dst->BytesPerPixel;
+	h = info->d_height;
+	src = info->s_pixels;
+	dst = info->d_pixels;
+	srcskip = w+info->s_skip;
+	dstskip = w+info->d_skip;
+	if ( dst < src ) {
+		while ( h-- ) {
+			SDL_memcpy(dst, src, w);
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		src += ((h-1) * srcskip);
+		dst += ((h-1) * dstskip);
+		while ( h-- ) {
+			SDL_revcpy(dst, src, w);
+			src -= srcskip;
+			dst -= dstskip;
+		}
+	}
+}
+
+/* Figure out which of many blit routines to set up on a surface */
+int SDL_CalculateBlit(SDL_Surface *surface)
+{
+	int blit_index;
+
+	/* Clean everything out to start */
+	if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+		SDL_UnRLESurface(surface, 1);
+	}
+	surface->map->sw_blit = NULL;
+
+	/* Figure out if an accelerated hardware blit is possible */
+	surface->flags &= ~SDL_HWACCEL;
+	if ( surface->map->identity ) {
+		int hw_blit_ok;
+
+		if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+			/* We only support accelerated blitting to hardware */
+			if ( surface->map->dst->flags & SDL_HWSURFACE ) {
+				hw_blit_ok = current_video->info.blit_hw;
+			} else {
+				hw_blit_ok = 0;
+			}
+			if (hw_blit_ok && (surface->flags & SDL_SRCCOLORKEY)) {
+				hw_blit_ok = current_video->info.blit_hw_CC;
+			}
+			if ( hw_blit_ok && (surface->flags & SDL_SRCALPHA) ) {
+				hw_blit_ok = current_video->info.blit_hw_A;
+			}
+		} else {
+			/* We only support accelerated blitting to hardware */
+			if ( surface->map->dst->flags & SDL_HWSURFACE ) {
+				hw_blit_ok = current_video->info.blit_sw;
+			} else {
+				hw_blit_ok = 0;
+			}
+			if (hw_blit_ok && (surface->flags & SDL_SRCCOLORKEY)) {
+				hw_blit_ok = current_video->info.blit_sw_CC;
+			}
+			if ( hw_blit_ok && (surface->flags & SDL_SRCALPHA) ) {
+				hw_blit_ok = current_video->info.blit_sw_A;
+			}
+		}
+		if ( hw_blit_ok ) {
+			SDL_VideoDevice *video = current_video;
+			SDL_VideoDevice *this  = current_video;
+			video->CheckHWBlit(this, surface, surface->map->dst);
+		}
+	}
+
+	/* Get the blit function index, based on surface mode */
+	/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
+	blit_index = 0;
+	blit_index |= (!!(surface->flags & SDL_SRCCOLORKEY))      << 0;
+	if ( surface->flags & SDL_SRCALPHA
+	     && (surface->format->alpha != SDL_ALPHA_OPAQUE
+		 || surface->format->Amask) ) {
+	        blit_index |= 2;
+	}
+
+	/* Check for special "identity" case -- copy blit */
+	if ( surface->map->identity && blit_index == 0 ) {
+	        surface->map->sw_data->blit = SDL_BlitCopy;
+
+		/* Handle overlapping blits on the same surface */
+		if ( surface == surface->map->dst ) {
+		        surface->map->sw_data->blit = SDL_BlitCopyOverlap;
+		}
+	} else {
+		if ( surface->format->BitsPerPixel < 8 ) {
+			surface->map->sw_data->blit =
+			    SDL_CalculateBlit0(surface, blit_index);
+		} else {
+			switch ( surface->format->BytesPerPixel ) {
+			    case 1:
+				surface->map->sw_data->blit =
+				    SDL_CalculateBlit1(surface, blit_index);
+				break;
+			    case 2:
+			    case 3:
+			    case 4:
+				surface->map->sw_data->blit =
+				    SDL_CalculateBlitN(surface, blit_index);
+				break;
+			    default:
+				surface->map->sw_data->blit = NULL;
+				break;
+			}
+		}
+	}
+	/* Make sure we have a blit function */
+	if ( surface->map->sw_data->blit == NULL ) {
+		SDL_InvalidateMap(surface->map);
+		SDL_SetError("Blit combination not supported");
+		return(-1);
+	}
+
+	/* Choose software blitting function */
+	if(surface->flags & SDL_RLEACCELOK
+	   && (surface->flags & SDL_HWACCEL) != SDL_HWACCEL) {
+
+	        if(surface->map->identity
+		   && (blit_index == 1
+		       || (blit_index == 3 && !surface->format->Amask))) {
+		        if ( SDL_RLESurface(surface) == 0 )
+			        surface->map->sw_blit = SDL_RLEBlit;
+		} else if(blit_index == 2 && surface->format->Amask) {
+		        if ( SDL_RLESurface(surface) == 0 )
+			        surface->map->sw_blit = SDL_RLEAlphaBlit;
+		}
+	}
+	
+	if ( surface->map->sw_blit == NULL ) {
+		surface->map->sw_blit = SDL_SoftBlit;
+	}
+	return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,437 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_blit_h
+#define _SDL_blit_h
+
+#include "SDL_endian.h"
+
+/* The structure passed to the low level blit functions */
+typedef struct {
+	Uint8 *s_pixels;
+	int s_width;
+	int s_height;
+	int s_skip;
+	Uint8 *d_pixels;
+	int d_width;
+	int d_height;
+	int d_skip;
+	void *aux_data;
+	SDL_PixelFormat *src;
+	Uint8 *table;
+	SDL_PixelFormat *dst;
+} SDL_BlitInfo;
+
+/* The type definition for the low level blit functions */
+typedef void (*SDL_loblit)(SDL_BlitInfo *info);
+
+/* This is the private info structure for software accelerated blits */
+struct private_swaccel {
+	SDL_loblit blit;
+	void *aux_data;
+};
+
+/* Blit mapping definition */
+typedef struct SDL_BlitMap {
+	SDL_Surface *dst;
+	int identity;
+	Uint8 *table;
+	SDL_blit hw_blit;
+	SDL_blit sw_blit;
+	struct private_hwaccel *hw_data;
+	struct private_swaccel *sw_data;
+
+	/* the version count matches the destination; mismatch indicates
+	   an invalid mapping */
+        unsigned int format_version;
+} SDL_BlitMap;
+
+
+/* Definitions for special global blit functions */
+#include "SDL_blit_A.h"
+
+/* Functions found in SDL_blit.c */
+extern int SDL_CalculateBlit(SDL_Surface *surface);
+
+/* Functions found in SDL_blit_{0,1,N,A}.c */
+extern SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int complex);
+extern SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int complex);
+extern SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int complex);
+extern SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int complex);
+
+/*
+ * Useful macros for blitting routines
+ */
+
+#define FORMAT_EQUAL(A, B)						\
+    ((A)->BitsPerPixel == (B)->BitsPerPixel				\
+     && ((A)->Rmask == (B)->Rmask) && ((A)->Amask == (B)->Amask))
+
+/* Load pixel of the specified format from a buffer and get its R-G-B values */
+/* FIXME: rescale values to 0..255 here? */
+#define RGB_FROM_PIXEL(pixel, fmt, r, g, b)				\
+{									\
+	r = (((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss); 		\
+	g = (((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss); 		\
+	b = (((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss); 		\
+}
+#define RGB_FROM_RGB565(pixel, r, g, b)					\
+{									\
+	r = (((pixel&0xF800)>>11)<<3);		 			\
+	g = (((pixel&0x07E0)>>5)<<2); 					\
+	b = ((pixel&0x001F)<<3); 					\
+}
+#define RGB_FROM_RGB555(pixel, r, g, b)					\
+{									\
+	r = (((pixel&0x7C00)>>10)<<3);		 			\
+	g = (((pixel&0x03E0)>>5)<<3); 					\
+	b = ((pixel&0x001F)<<3); 					\
+}
+#define RGB_FROM_RGB888(pixel, r, g, b)					\
+{									\
+	r = ((pixel&0xFF0000)>>16);		 			\
+	g = ((pixel&0xFF00)>>8);		 			\
+	b = (pixel&0xFF);			 			\
+}
+#define RETRIEVE_RGB_PIXEL(buf, bpp, pixel)				   \
+do {									   \
+	switch (bpp) {							   \
+		case 2:							   \
+			pixel = *((Uint16 *)(buf));			   \
+		break;							   \
+									   \
+		case 3: {						   \
+		        Uint8 *B = (Uint8 *)(buf);			   \
+			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
+			        pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
+			} else {					   \
+			        pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
+			}						   \
+		}							   \
+		break;							   \
+									   \
+		case 4:							   \
+			pixel = *((Uint32 *)(buf));			   \
+		break;							   \
+									   \
+		default:						   \
+			pixel = 0; /* appease gcc */			   \
+		break;							   \
+	}								   \
+} while(0)
+
+#define DISEMBLE_RGB(buf, bpp, fmt, pixel, r, g, b)			   \
+do {									   \
+	switch (bpp) {							   \
+		case 2:							   \
+			pixel = *((Uint16 *)(buf));			   \
+		break;							   \
+									   \
+		case 3: {						   \
+		        Uint8 *B = (Uint8 *)buf;			   \
+			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
+			        pixel = B[0] + (B[1] << 8) + (B[2] << 16); \
+			} else {					   \
+			        pixel = (B[0] << 16) + (B[1] << 8) + B[2]; \
+			}						   \
+		}							   \
+		break;							   \
+									   \
+		case 4:							   \
+			pixel = *((Uint32 *)(buf));			   \
+		break;							   \
+									   \
+	        default:						   \
+		        pixel = 0;	/* prevent gcc from complaining */ \
+		break;							   \
+	}								   \
+	RGB_FROM_PIXEL(pixel, fmt, r, g, b);				   \
+} while(0)
+
+/* Assemble R-G-B values into a specified pixel format and store them */
+#define PIXEL_FROM_RGB(pixel, fmt, r, g, b)				\
+{									\
+	pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
+		((g>>fmt->Gloss)<<fmt->Gshift)|				\
+		((b>>fmt->Bloss)<<fmt->Bshift);				\
+}
+#define RGB565_FROM_RGB(pixel, r, g, b)					\
+{									\
+	pixel = ((r>>3)<<11)|((g>>2)<<5)|(b>>3);			\
+}
+#define RGB555_FROM_RGB(pixel, r, g, b)					\
+{									\
+	pixel = ((r>>3)<<10)|((g>>3)<<5)|(b>>3);			\
+}
+#define RGB888_FROM_RGB(pixel, r, g, b)					\
+{									\
+	pixel = (r<<16)|(g<<8)|b;					\
+}
+#define ASSEMBLE_RGB(buf, bpp, fmt, r, g, b) 				\
+{									\
+	switch (bpp) {							\
+		case 2: {						\
+			Uint16 pixel;					\
+									\
+			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
+			*((Uint16 *)(buf)) = pixel;			\
+		}							\
+		break;							\
+									\
+		case 3: {						\
+                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
+			        *((buf)+fmt->Rshift/8) = r;		\
+				*((buf)+fmt->Gshift/8) = g;		\
+				*((buf)+fmt->Bshift/8) = b;		\
+			} else {					\
+			        *((buf)+2-fmt->Rshift/8) = r;		\
+				*((buf)+2-fmt->Gshift/8) = g;		\
+				*((buf)+2-fmt->Bshift/8) = b;		\
+			}						\
+		}							\
+		break;							\
+									\
+		case 4: {						\
+			Uint32 pixel;					\
+									\
+			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
+			*((Uint32 *)(buf)) = pixel;			\
+		}							\
+		break;							\
+	}								\
+}
+#define ASSEMBLE_RGB_AMASK(buf, bpp, fmt, r, g, b, Amask)		\
+{									\
+	switch (bpp) {							\
+		case 2: {						\
+			Uint16 *bufp;					\
+			Uint16 pixel;					\
+									\
+			bufp = (Uint16 *)buf;				\
+			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
+			*bufp = pixel | (*bufp & Amask);		\
+		}							\
+		break;							\
+									\
+		case 3: {						\
+                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
+			        *((buf)+fmt->Rshift/8) = r;		\
+				*((buf)+fmt->Gshift/8) = g;		\
+				*((buf)+fmt->Bshift/8) = b;		\
+			} else {					\
+			        *((buf)+2-fmt->Rshift/8) = r;		\
+				*((buf)+2-fmt->Gshift/8) = g;		\
+				*((buf)+2-fmt->Bshift/8) = b;		\
+			}						\
+		}							\
+		break;							\
+									\
+		case 4: {						\
+			Uint32 *bufp;					\
+			Uint32 pixel;					\
+									\
+			bufp = (Uint32 *)buf;				\
+			PIXEL_FROM_RGB(pixel, fmt, r, g, b);		\
+			*bufp = pixel | (*bufp & Amask);		\
+		}							\
+		break;							\
+	}								\
+}
+
+/* FIXME: Should we rescale alpha into 0..255 here? */
+#define RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a)				\
+{									\
+	r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; 		\
+	g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; 		\
+	b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; 		\
+	a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss;	 	\
+}
+#define RGBA_FROM_8888(pixel, fmt, r, g, b, a)	\
+{						\
+	r = (pixel&fmt->Rmask)>>fmt->Rshift;	\
+	g = (pixel&fmt->Gmask)>>fmt->Gshift;	\
+	b = (pixel&fmt->Bmask)>>fmt->Bshift;	\
+	a = (pixel&fmt->Amask)>>fmt->Ashift;	\
+}
+#define RGBA_FROM_RGBA8888(pixel, r, g, b, a)				\
+{									\
+	r = (pixel>>24);						\
+	g = ((pixel>>16)&0xFF);						\
+	b = ((pixel>>8)&0xFF);						\
+	a = (pixel&0xFF);						\
+}
+#define RGBA_FROM_ARGB8888(pixel, r, g, b, a)				\
+{									\
+	r = ((pixel>>16)&0xFF);						\
+	g = ((pixel>>8)&0xFF);						\
+	b = (pixel&0xFF);						\
+	a = (pixel>>24);						\
+}
+#define RGBA_FROM_ABGR8888(pixel, r, g, b, a)				\
+{									\
+	r = (pixel&0xFF);						\
+	g = ((pixel>>8)&0xFF);						\
+	b = ((pixel>>16)&0xFF);						\
+	a = (pixel>>24);						\
+}
+#define DISEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a)			   \
+do {									   \
+	switch (bpp) {							   \
+		case 2:							   \
+			pixel = *((Uint16 *)(buf));			   \
+		break;							   \
+									   \
+		case 3:	{/* FIXME: broken code (no alpha) */		   \
+		        Uint8 *b = (Uint8 *)buf;			   \
+			if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		   \
+			        pixel = b[0] + (b[1] << 8) + (b[2] << 16); \
+			} else {					   \
+			        pixel = (b[0] << 16) + (b[1] << 8) + b[2]; \
+			}						   \
+		}							   \
+		break;							   \
+									   \
+		case 4:							   \
+			pixel = *((Uint32 *)(buf));			   \
+		break;							   \
+									   \
+		default:						   \
+		        pixel = 0; /* stop gcc complaints */		   \
+		break;							   \
+	}								   \
+	RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a);			   \
+	pixel &= ~fmt->Amask;						   \
+} while(0)
+
+/* FIXME: this isn't correct, especially for Alpha (maximum != 255) */
+#define PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a)				\
+{									\
+	pixel = ((r>>fmt->Rloss)<<fmt->Rshift)|				\
+		((g>>fmt->Gloss)<<fmt->Gshift)|				\
+		((b>>fmt->Bloss)<<fmt->Bshift)|				\
+		((a<<fmt->Aloss)<<fmt->Ashift);				\
+}
+#define ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a)			\
+{									\
+	switch (bpp) {							\
+		case 2: {						\
+			Uint16 pixel;					\
+									\
+			PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a);	\
+			*((Uint16 *)(buf)) = pixel;			\
+		}							\
+		break;							\
+									\
+		case 3: { /* FIXME: broken code (no alpha) */		\
+                        if(SDL_BYTEORDER == SDL_LIL_ENDIAN) {		\
+			        *((buf)+fmt->Rshift/8) = r;		\
+				*((buf)+fmt->Gshift/8) = g;		\
+				*((buf)+fmt->Bshift/8) = b;		\
+			} else {					\
+			        *((buf)+2-fmt->Rshift/8) = r;		\
+				*((buf)+2-fmt->Gshift/8) = g;		\
+				*((buf)+2-fmt->Bshift/8) = b;		\
+			}						\
+		}							\
+		break;							\
+									\
+		case 4: {						\
+			Uint32 pixel;					\
+									\
+			PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a);	\
+			*((Uint32 *)(buf)) = pixel;			\
+		}							\
+		break;							\
+	}								\
+}
+
+/* Blend the RGB values of two pixels based on a source alpha value */
+#define ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB)	\
+do {						\
+	dR = (((sR-dR)*(A))>>8)+dR;		\
+	dG = (((sG-dG)*(A))>>8)+dG;		\
+	dB = (((sB-dB)*(A))>>8)+dB;		\
+} while(0)
+
+/* This is a very useful loop for optimizing blitters */
+#define USE_DUFFS_LOOP
+#ifdef USE_DUFFS_LOOP
+
+/* 8-times unrolled loop */
+#define DUFFS_LOOP8(pixel_copy_increment, width)			\
+{ int n = (width+7)/8;							\
+	switch (width % 8) {						\
+	case 0: do {	pixel_copy_increment;				\
+	case 7:		pixel_copy_increment;				\
+	case 6:		pixel_copy_increment;				\
+	case 5:		pixel_copy_increment;				\
+	case 4:		pixel_copy_increment;				\
+	case 3:		pixel_copy_increment;				\
+	case 2:		pixel_copy_increment;				\
+	case 1:		pixel_copy_increment;				\
+		} while ( --n > 0 );					\
+	}								\
+}
+
+/* 4-times unrolled loop */
+#define DUFFS_LOOP4(pixel_copy_increment, width)			\
+{ int n = (width+3)/4;							\
+	switch (width % 4) {						\
+	case 0: do {	pixel_copy_increment;				\
+	case 3:		pixel_copy_increment;				\
+	case 2:		pixel_copy_increment;				\
+	case 1:		pixel_copy_increment;				\
+		} while ( --n > 0 );					\
+	}								\
+}
+
+/* Use the 8-times version of the loop by default */
+#define DUFFS_LOOP(pixel_copy_increment, width)				\
+	DUFFS_LOOP8(pixel_copy_increment, width)
+
+#else
+
+/* Don't use Duff's device to unroll loops */
+#define DUFFS_LOOP(pixel_copy_increment, width)				\
+{ int n;								\
+	for ( n=width; n > 0; --n ) {					\
+		pixel_copy_increment;					\
+	}								\
+}
+#define DUFFS_LOOP8(pixel_copy_increment, width)			\
+	DUFFS_LOOP(pixel_copy_increment, width)
+#define DUFFS_LOOP4(pixel_copy_increment, width)			\
+	DUFFS_LOOP(pixel_copy_increment, width)
+
+#endif /* USE_DUFFS_LOOP */
+
+/* Prevent Visual C++ 6.0 from printing out stupid warnings */
+#if defined(_MSC_VER) && (_MSC_VER >= 600)
+#pragma warning(disable: 4550)
+#endif
+
+#endif /* _SDL_blit_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_0.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,475 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+
+/* Functions to blit from bitmaps to other surfaces */
+
+static void BlitBto1(SDL_BlitInfo *info)
+{
+	int c;
+	int width, height;
+	Uint8 *src, *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+	srcskip += width-(width+7)/8;
+
+	if ( map ) {
+		while ( height-- ) {
+		        Uint8 byte = 0, bit;
+	    		for ( c=0; c<width; ++c ) {
+				if ( (c%8) == 0 ) {
+					byte = *src++;
+				}
+				bit = (byte&0x80)>>7;
+				if ( 1 ) {
+				  *dst = map[bit];
+				}
+				dst++;
+				byte <<= 1;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		while ( height-- ) {
+		        Uint8 byte = 0, bit;
+	    		for ( c=0; c<width; ++c ) {
+				if ( (c%8) == 0 ) {
+					byte = *src++;
+				}
+				bit = (byte&0x80)>>7;
+				if ( 1 ) {
+				  *dst = bit;
+				}
+				dst++;
+				byte <<= 1;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+static void BlitBto2(SDL_BlitInfo *info)
+{
+	int c;
+	int width, height;
+	Uint8 *src;
+	Uint16 *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = (Uint16 *)info->d_pixels;
+	dstskip = info->d_skip/2;
+	map = (Uint16 *)info->table;
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( 1 ) {
+				*dst = map[bit];
+			}
+			byte <<= 1;
+			dst++;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+static void BlitBto3(SDL_BlitInfo *info)
+{
+	int c, o;
+	int width, height;
+	Uint8 *src, *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( 1 ) {
+				o = bit * 4;
+				dst[0] = map[o++];
+				dst[1] = map[o++];
+				dst[2] = map[o++];
+			}
+			byte <<= 1;
+			dst += 3;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+static void BlitBto4(SDL_BlitInfo *info)
+{
+	int width, height;
+	Uint8 *src;
+	Uint32 *map, *dst;
+	int srcskip, dstskip;
+	int c;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = (Uint32 *)info->d_pixels;
+	dstskip = info->d_skip/4;
+	map = (Uint32 *)info->table;
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( 1 ) {
+				*dst = map[bit];
+			}
+			byte <<= 1;
+			dst++;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitBto1Key(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint8 *dst = info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	Uint8 *palmap = info->table;
+	int c;
+
+	/* Set up some basic variables */
+	srcskip += width-(width+7)/8;
+
+	if ( palmap ) {
+		while ( height-- ) {
+		        Uint8  byte = 0, bit;
+	    		for ( c=0; c<width; ++c ) {
+				if ( (c%8) == 0 ) {
+					byte = *src++;
+				}
+				bit = (byte&0x80)>>7;
+				if ( bit != ckey ) {
+				  *dst = palmap[bit];
+				}
+				dst++;
+				byte <<= 1;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		while ( height-- ) {
+		        Uint8  byte = 0, bit;
+	    		for ( c=0; c<width; ++c ) {
+				if ( (c%8) == 0 ) {
+					byte = *src++;
+				}
+				bit = (byte&0x80)>>7;
+				if ( bit != ckey ) {
+				  *dst = bit;
+				}
+				dst++;
+				byte <<= 1;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+
+static void BlitBto2Key(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	Uint8 *palmap = info->table;
+	int c;
+
+	/* Set up some basic variables */
+	srcskip += width-(width+7)/8;
+	dstskip /= 2;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( bit != ckey ) {
+				*dstp=((Uint16 *)palmap)[bit];
+			}
+			byte <<= 1;
+			dstp++;
+		}
+		src += srcskip;
+		dstp += dstskip;
+	}
+}
+
+static void BlitBto3Key(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint8 *dst = info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	Uint8 *palmap = info->table;
+	int c;
+
+	/* Set up some basic variables */
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8  byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( bit != ckey ) {
+				memcpy(dst, &palmap[bit*4], 3);
+			}
+			byte <<= 1;
+			dst += 3;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitBto4Key(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint32 *dstp = (Uint32 *)info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	Uint8 *palmap = info->table;
+	int c;
+
+	/* Set up some basic variables */
+	srcskip += width-(width+7)/8;
+	dstskip /= 4;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( bit != ckey ) {
+				*dstp=((Uint32 *)palmap)[bit];
+			}
+			byte <<= 1;
+			dstp++;
+		}
+		src += srcskip;
+		dstp += dstskip;
+	}
+}
+
+static void BlitBtoNAlpha(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint8 *dst = info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	const SDL_Color *srcpal	= info->src->palette->colors;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int  dstbpp;
+	int c;
+	const int A = info->src->alpha;
+
+	/* Set up some basic variables */
+	dstbpp = dstfmt->BytesPerPixel;
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8 byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( 1 ) {
+			        Uint32 pixel;
+			        unsigned sR, sG, sB;
+				unsigned dR, dG, dB;
+				sR = srcpal[bit].r;
+				sG = srcpal[bit].g;
+				sB = srcpal[bit].b;
+				DISEMBLE_RGB(dst, dstbpp, dstfmt,
+							pixel, dR, dG, dB);
+				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
+			}
+			byte <<= 1;
+			dst += dstbpp;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitBtoNAlphaKey(SDL_BlitInfo *info)
+{
+        int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	Uint8 *dst = info->d_pixels;
+	int srcskip = info->s_skip;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	const SDL_Color *srcpal	= srcfmt->palette->colors;
+	int dstbpp;
+	int c;
+	const int A = srcfmt->alpha;
+	Uint32 ckey = srcfmt->colorkey;
+
+	/* Set up some basic variables */
+	dstbpp = dstfmt->BytesPerPixel;
+	srcskip += width-(width+7)/8;
+
+	while ( height-- ) {
+	        Uint8  byte = 0, bit;
+	    	for ( c=0; c<width; ++c ) {
+			if ( (c%8) == 0 ) {
+				byte = *src++;
+			}
+			bit = (byte&0x80)>>7;
+			if ( bit != ckey ) {
+			        int sR, sG, sB;
+				int dR, dG, dB;
+				Uint32 pixel;
+				sR = srcpal[bit].r;
+				sG = srcpal[bit].g;
+				sB = srcpal[bit].b;
+				DISEMBLE_RGB(dst, dstbpp, dstfmt,
+							pixel, dR, dG, dB);
+				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
+			}
+			byte <<= 1;
+			dst += dstbpp;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static SDL_loblit bitmap_blit[] = {
+	NULL, BlitBto1, BlitBto2, BlitBto3, BlitBto4
+};
+
+static SDL_loblit colorkey_blit[] = {
+    NULL, BlitBto1Key, BlitBto2Key, BlitBto3Key, BlitBto4Key
+};
+
+SDL_loblit SDL_CalculateBlit0(SDL_Surface *surface, int blit_index)
+{
+	int which;
+
+	if ( surface->map->dst->format->BitsPerPixel < 8 ) {
+		which = 0;
+	} else {
+		which = surface->map->dst->format->BytesPerPixel;
+	}
+	switch(blit_index) {
+	case 0:			/* copy */
+	    return bitmap_blit[which];
+
+	case 1:			/* colorkey */
+	    return colorkey_blit[which];
+
+	case 2:			/* alpha */
+	    return which >= 2 ? BlitBtoNAlpha : NULL;
+
+	case 4:			/* alpha + colorkey */
+	    return which >= 2 ? BlitBtoNAlphaKey : NULL;
+	}
+	return NULL;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_1.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,530 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_sysvideo.h"
+#include "SDL_endian.h"
+
+/* Functions to blit from 8-bit surfaces to other surfaces */
+
+static void Blit1to1(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint8 *src, *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+
+	while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+		DUFFS_LOOP(
+			{
+			  *dst = map[*src];
+			}
+			dst++;
+			src++;
+		, width);
+#else
+		for ( c=width; c; --c ) {
+		        *dst = map[*src];
+			dst++;
+			src++;
+		}
+#endif
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+/* This is now endian dependent */
+#if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
+#define HI	1
+#define LO	0
+#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
+#define HI	0
+#define LO	1
+#endif
+static void Blit1to2(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint8 *src, *dst;
+	Uint16 *map;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = (Uint16 *)info->table;
+
+#ifdef USE_DUFFS_LOOP
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			*(Uint16 *)dst = map[*src++];
+			dst += 2;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+#else
+	/* Memory align at 4-byte boundary, if necessary */
+	if ( (long)dst & 0x03 ) {
+		/* Don't do anything if width is 0 */
+		if ( width == 0 ) {
+			return;
+		}
+		--width;
+
+		while ( height-- ) {
+			/* Perform copy alignment */
+			*(Uint16 *)dst = map[*src++];
+			dst += 2;
+
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				*(Uint32 *)dst =
+					(map[src[HI]]<<16)|(map[src[LO]]);
+				src += 2;
+				dst += 4;
+				*(Uint32 *)dst =
+					(map[src[HI]]<<16)|(map[src[LO]]);
+				src += 2;
+				dst += 4;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					*(Uint16 *)dst = map[*src++];
+					dst += 2;
+				case 2:
+					*(Uint32 *)dst =
+					  (map[src[HI]]<<16)|(map[src[LO]]);
+					src += 2;
+					dst += 4;
+					break;
+				case 1:
+					*(Uint16 *)dst = map[*src++];
+					dst += 2;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else { 
+		while ( height-- ) {
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				*(Uint32 *)dst =
+					(map[src[HI]]<<16)|(map[src[LO]]);
+				src += 2;
+				dst += 4;
+				*(Uint32 *)dst =
+					(map[src[HI]]<<16)|(map[src[LO]]);
+				src += 2;
+				dst += 4;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					*(Uint16 *)dst = map[*src++];
+					dst += 2;
+				case 2:
+					*(Uint32 *)dst =
+					  (map[src[HI]]<<16)|(map[src[LO]]);
+					src += 2;
+					dst += 4;
+					break;
+				case 1:
+					*(Uint16 *)dst = map[*src++];
+					dst += 2;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+#endif /* USE_DUFFS_LOOP */
+}
+static void Blit1to3(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int o;
+	int width, height;
+	Uint8 *src, *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+
+	while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+		DUFFS_LOOP(
+			{
+				o = *src * 4;
+				dst[0] = map[o++];
+				dst[1] = map[o++];
+				dst[2] = map[o++];
+			}
+			src++;
+			dst += 3;
+		, width);
+#else
+		for ( c=width; c; --c ) {
+			o = *src * 4;
+			dst[0] = map[o++];
+			dst[1] = map[o++];
+			dst[2] = map[o++];
+			src++;
+			dst += 3;
+		}
+#endif /* USE_DUFFS_LOOP */
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+static void Blit1to4(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint8 *src;
+	Uint32 *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = (Uint32 *)info->d_pixels;
+	dstskip = info->d_skip/4;
+	map = (Uint32 *)info->table;
+
+	while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+		DUFFS_LOOP(
+			*dst++ = map[*src++];
+		, width);
+#else
+		for ( c=width/4; c; --c ) {
+			*dst++ = map[*src++];
+			*dst++ = map[*src++];
+			*dst++ = map[*src++];
+			*dst++ = map[*src++];
+		}
+		switch ( width % 4 ) {
+			case 3:
+				*dst++ = map[*src++];
+			case 2:
+				*dst++ = map[*src++];
+			case 1:
+				*dst++ = map[*src++];
+		}
+#endif /* USE_DUFFS_LOOP */
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void Blit1to1Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint8 *palmap = info->table;
+	Uint32 ckey = info->src->colorkey;
+        
+	if ( palmap ) {
+		while ( height-- ) {
+			DUFFS_LOOP(
+			{
+				if ( *src != ckey ) {
+				  *dst = palmap[*src];
+				}
+				dst++;
+				src++;
+			},
+			width);
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		while ( height-- ) {
+			DUFFS_LOOP(
+			{
+				if ( *src != ckey ) {
+				  *dst = *src;
+				}
+				dst++;
+				src++;
+			},
+			width);
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+
+static void Blit1to2Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint16 *palmap = (Uint16 *)info->table;
+	Uint32 ckey = info->src->colorkey;
+
+	/* Set up some basic variables */
+	dstskip /= 2;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			if ( *src != ckey ) {
+				*dstp=palmap[*src];
+			}
+			src++;
+			dstp++;
+		},
+		width);
+		src += srcskip;
+		dstp += dstskip;
+	}
+}
+
+static void Blit1to3Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint8 *palmap = info->table;
+	Uint32 ckey = info->src->colorkey;
+	int o;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			if ( *src != ckey ) {
+				o = *src * 4;
+				dst[0] = palmap[o++];
+				dst[1] = palmap[o++];
+				dst[2] = palmap[o++];
+			}
+			src++;
+			dst += 3;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void Blit1to4Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint32 *dstp = (Uint32 *)info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint32 *palmap = (Uint32 *)info->table;
+	Uint32 ckey = info->src->colorkey;
+
+	/* Set up some basic variables */
+	dstskip /= 4;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			if ( *src != ckey ) {
+				*dstp = palmap[*src];
+			}
+			src++;
+			dstp++;
+		},
+		width);
+		src += srcskip;
+		dstp += dstskip;
+	}
+}
+
+static void Blit1toNAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *dstfmt = info->dst;
+	const SDL_Color *srcpal	= info->src->palette->colors;
+	int dstbpp;
+	const int A = info->src->alpha;
+
+	/* Set up some basic variables */
+	dstbpp = dstfmt->BytesPerPixel;
+
+	while ( height-- ) {
+	        int sR, sG, sB;
+		int dR, dG, dB;
+	    	DUFFS_LOOP4(
+			{
+			        Uint32 pixel;
+				sR = srcpal[*src].r;
+				sG = srcpal[*src].g;
+				sB = srcpal[*src].b;
+				DISEMBLE_RGB(dst, dstbpp, dstfmt,
+					     pixel, dR, dG, dB);
+				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
+				src++;
+				dst += dstbpp;
+			},
+			width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void Blit1toNAlphaKey(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	const SDL_Color *srcpal	= info->src->palette->colors;
+	Uint32 ckey = srcfmt->colorkey;
+	int dstbpp;
+	const int A = srcfmt->alpha;
+
+	/* Set up some basic variables */
+	dstbpp = dstfmt->BytesPerPixel;
+
+	while ( height-- ) {
+	        int sR, sG, sB;
+		int dR, dG, dB;
+		DUFFS_LOOP(
+		{
+			if ( *src != ckey ) {
+			        Uint32 pixel;
+				sR = srcpal[*src].r;
+				sG = srcpal[*src].g;
+				sB = srcpal[*src].b;
+				DISEMBLE_RGB(dst, dstbpp, dstfmt,
+							pixel, dR, dG, dB);
+				ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+			  	ASSEMBLE_RGB(dst, dstbpp, dstfmt, dR, dG, dB);
+			}
+			src++;
+			dst += dstbpp;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static SDL_loblit one_blit[] = {
+	NULL, Blit1to1, Blit1to2, Blit1to3, Blit1to4
+};
+
+static SDL_loblit one_blitkey[] = {
+        NULL, Blit1to1Key, Blit1to2Key, Blit1to3Key, Blit1to4Key
+};
+
+SDL_loblit SDL_CalculateBlit1(SDL_Surface *surface, int blit_index)
+{
+	int which;
+	SDL_PixelFormat *dstfmt;
+
+	dstfmt = surface->map->dst->format;
+	if ( dstfmt->BitsPerPixel < 8 ) {
+		which = 0;
+	} else {
+		which = dstfmt->BytesPerPixel;
+	}
+	switch(blit_index) {
+	case 0:			/* copy */
+	    return one_blit[which];
+
+	case 1:			/* colorkey */
+	    return one_blitkey[which];
+
+	case 2:			/* alpha */
+	    /* Supporting 8bpp->8bpp alpha is doable but requires lots of
+	       tables which consume space and takes time to precompute,
+	       so is better left to the user */
+	    return which >= 2 ? Blit1toNAlpha : NULL;
+
+	case 3:			/* alpha + colorkey */
+	    return which >= 2 ? Blit1toNAlphaKey : NULL;
+
+	}
+	return NULL;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_A.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,633 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+
+/* Functions to perform alpha blended blitting */
+
+/* N->1 blending with per-surface alpha */
+static void BlitNto1SurfaceAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint8 *palmap = info->table;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int srcbpp = srcfmt->BytesPerPixel;
+
+	const unsigned A = srcfmt->alpha;
+
+	while ( height-- ) {
+	    DUFFS_LOOP4(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
+		dR = dstfmt->palette->colors[*dst].r;
+		dG = dstfmt->palette->colors[*dst].g;
+		dB = dstfmt->palette->colors[*dst].b;
+		ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+		dR &= 0xff;
+		dG &= 0xff;
+		dB &= 0xff;
+		/* Pack RGB into 8bit pixel */
+		if ( palmap == NULL ) {
+		    *dst =((dR>>5)<<(3+2))|
+			  ((dG>>5)<<(2))|
+			  ((dB>>6)<<(0));
+		} else {
+		    *dst = palmap[((dR>>5)<<(3+2))|
+				  ((dG>>5)<<(2))  |
+				  ((dB>>6)<<(0))];
+		}
+		dst++;
+		src += srcbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+/* N->1 blending with pixel alpha */
+static void BlitNto1PixelAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint8 *palmap = info->table;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int srcbpp = srcfmt->BytesPerPixel;
+
+	/* FIXME: fix alpha bit field expansion here too? */
+	while ( height-- ) {
+	    DUFFS_LOOP4(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned sA;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		DISEMBLE_RGBA(src,srcbpp,srcfmt,pixel,sR,sG,sB,sA);
+		dR = dstfmt->palette->colors[*dst].r;
+		dG = dstfmt->palette->colors[*dst].g;
+		dB = dstfmt->palette->colors[*dst].b;
+		ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
+		dR &= 0xff;
+		dG &= 0xff;
+		dB &= 0xff;
+		/* Pack RGB into 8bit pixel */
+		if ( palmap == NULL ) {
+		    *dst =((dR>>5)<<(3+2))|
+			  ((dG>>5)<<(2))|
+			  ((dB>>6)<<(0));
+		} else {
+		    *dst = palmap[((dR>>5)<<(3+2))|
+				  ((dG>>5)<<(2))  |
+				  ((dB>>6)<<(0))  ];
+		}
+		dst++;
+		src += srcbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+/* colorkeyed N->1 blending with per-surface alpha */
+static void BlitNto1SurfaceAlphaKey(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint8 *palmap = info->table;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int srcbpp = srcfmt->BytesPerPixel;
+	Uint32 ckey = srcfmt->colorkey;
+
+	const int A = srcfmt->alpha;
+
+	while ( height-- ) {
+	    DUFFS_LOOP(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
+		if ( pixel != ckey ) {
+		    dR = dstfmt->palette->colors[*dst].r;
+		    dG = dstfmt->palette->colors[*dst].g;
+		    dB = dstfmt->palette->colors[*dst].b;
+		    ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB);
+		    dR &= 0xff;
+		    dG &= 0xff;
+		    dB &= 0xff;
+		    /* Pack RGB into 8bit pixel */
+		    if ( palmap == NULL ) {
+			*dst =((dR>>5)<<(3+2))|
+			      ((dG>>5)<<(2)) |
+			      ((dB>>6)<<(0));
+		    } else {
+			*dst = palmap[((dR>>5)<<(3+2))|
+				      ((dG>>5)<<(2))  |
+				      ((dB>>6)<<(0))  ];
+		    }
+		}
+		dst++;
+		src += srcbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+/* fast RGB888->(A)RGB888 blending with surface alpha */
+static void BlitRGBtoRGBSurfaceAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint32 *srcp = (Uint32 *)info->s_pixels;
+	int srcskip = info->s_skip >> 2;
+	Uint32 *dstp = (Uint32 *)info->d_pixels;
+	int dstskip = info->d_skip >> 2;
+	SDL_PixelFormat *srcfmt = info->src;
+	unsigned alpha = srcfmt->alpha;
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		Uint32 s;
+		Uint32 d;
+		Uint32 s1;
+		Uint32 d1;
+		s = *srcp;
+		d = *dstp;
+		s1 = s & 0xff00ff;
+		d1 = d & 0xff00ff;
+		d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
+		s &= 0xff00;
+		d &= 0xff00;
+		d = (d + ((s - d) * alpha >> 8)) & 0xff00;
+		*dstp = d1 | d | 0xff000000;
+		++srcp;
+		++dstp;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* fast ARGB888->(A)RGB888 blending with pixel alpha */
+static void BlitRGBtoRGBPixelAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint32 *srcp = (Uint32 *)info->s_pixels;
+	int srcskip = info->s_skip >> 2;
+	Uint32 *dstp = (Uint32 *)info->d_pixels;
+	int dstskip = info->d_skip >> 2;
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		Uint32 dalpha;
+		Uint32 d;
+		Uint32 s1;
+		Uint32 d1;
+		Uint32 s = *srcp;
+		Uint32 alpha = s >> 24;
+		/* FIXME: Here we special-case opaque alpha since the
+		   compositioning used (>>8 instead of /255) doesn't handle
+		   it correctly. Also special-case alpha=0 for speed?
+		   Benchmark this! */
+		if(alpha == SDL_ALPHA_OPAQUE) {
+		    *dstp = (s & 0x00ffffff) | (*dstp & 0xff000000);
+		} else {
+		    /*
+		     * take out the middle component (green), and process
+		     * the other two in parallel. One multiply less.
+		     */
+		    d = *dstp;
+		    dalpha = d & 0xff000000;
+		    s1 = s & 0xff00ff;
+		    d1 = d & 0xff00ff;
+		    d1 = (d1 + ((s1 - d1) * alpha >> 8)) & 0xff00ff;
+		    s &= 0xff00;
+		    d &= 0xff00;
+		    d = (d + ((s - d) * alpha >> 8)) & 0xff00;
+		    *dstp = d1 | d | dalpha;
+		}
+		++srcp;
+		++dstp;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* fast RGB565->RGB565 blending with surface alpha */
+static void Blit565to565SurfaceAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint16 *srcp = (Uint16 *)info->s_pixels;
+	int srcskip = info->s_skip >> 1;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip >> 1;
+	unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		Uint32 s = *srcp++;
+		Uint32 d = *dstp;
+		/*
+		 * shift out the middle component (green) to the high 16
+		 * bits, and process all three RGB components at the same
+		 * time.
+		 */
+		s = (s | s << 16) & 0x07e0f81f;
+		d = (d | d << 16) & 0x07e0f81f;
+		d += (s - d) * alpha >> 5;
+		d &= 0x07e0f81f;
+		*dstp++ = d | d >> 16;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* fast RGB555->RGB555 blending with surface alpha */
+static void Blit555to555SurfaceAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint16 *srcp = (Uint16 *)info->s_pixels;
+	int srcskip = info->s_skip >> 1;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip >> 1;
+	unsigned alpha = info->src->alpha >> 3; /* downscale alpha to 5 bits */
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		Uint32 s = *srcp++;
+		Uint32 d = *dstp;
+		/*
+		 * shift out the middle component (green) to the high 16
+		 * bits, and process all three RGB components at the same
+		 * time.
+		 */
+		s = (s | s << 16) & 0x03e07c1f;
+		d = (d | d << 16) & 0x03e07c1f;
+		d += (s - d) * alpha >> 5;
+		d &= 0x03e07c1f;
+		*dstp++ = d | d >> 16;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* fast ARGB8888->RGB565 blending with pixel alpha */
+static void BlitARGBto565PixelAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint32 *srcp = (Uint32 *)info->s_pixels;
+	int srcskip = info->s_skip >> 2;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip >> 1;
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		Uint32 s = *srcp;
+		unsigned alpha = s >> 27; /* downscale alpha to 5 bits */
+		/* FIXME: Here we special-case opaque alpha since the
+		   compositioning used (>>8 instead of /255) doesn't handle
+		   it correctly. Also special-case alpha=0 for speed?
+		   Benchmark this! */
+		if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
+		    *dstp = (s >> 8 & 0xf800) + (s >> 5 & 0x7e0)
+			  + (s >> 3  & 0x1f);
+		} else {
+		    Uint32 d = *dstp;
+		    /*
+		     * convert source and destination to G0RAB65565
+		     * and blend all components at the same time
+		     */
+		    s = ((s & 0xfc00) << 11) + (s >> 8 & 0xf800)
+		      + (s >> 3 & 0x1f);
+		    d = (d | d << 16) & 0x07e0f81f;
+		    d += (s - d) * alpha >> 5;
+		    d &= 0x07e0f81f;
+		    *dstp = d | d >> 16;
+		}
+		srcp++;
+		dstp++;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* fast ARGB8888->RGB555 blending with pixel alpha */
+static void BlitARGBto555PixelAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint32 *srcp = (Uint32 *)info->s_pixels;
+	int srcskip = info->s_skip >> 2;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip >> 1;
+
+	while(height--) {
+	    DUFFS_LOOP4({
+		unsigned alpha;
+		Uint32 s = *srcp;
+		alpha = s >> 27; /* downscale alpha to 5 bits */
+		/* FIXME: Here we special-case opaque alpha since the
+		   compositioning used (>>8 instead of /255) doesn't handle
+		   it correctly. Also special-case alpha=0 for speed?
+		   Benchmark this! */
+		if(alpha == (SDL_ALPHA_OPAQUE >> 3)) {
+		    *dstp = (s >> 9 & 0x7c00) + (s >> 6 & 0x3e0)
+			  + (s >> 3  & 0x1f);
+		} else {
+		    Uint32 d = *dstp;
+		    /*
+		     * convert source and destination to G0RAB65565
+		     * and blend all components at the same time
+		     */
+		    s = ((s & 0xf800) << 10) + (s >> 9 & 0x7c00)
+		      + (s >> 3 & 0x1f);
+		    d = (d | d << 16) & 0x03e07c1f;
+		    d += (s - d) * alpha >> 5;
+		    d &= 0x03e07c1f;
+		    *dstp = d | d >> 16;
+		}
+		srcp++;
+		dstp++;
+	    }, width);
+	    srcp += srcskip;
+	    dstp += dstskip;
+	}
+}
+
+/* General (slow) N->N blending with per-surface alpha */
+static void BlitNtoNSurfaceAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int srcbpp = srcfmt->BytesPerPixel;
+	int dstbpp = dstfmt->BytesPerPixel;
+	unsigned sA = srcfmt->alpha;
+	unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
+
+	while ( height-- ) {
+	    DUFFS_LOOP4(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
+		DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB);
+		ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
+		ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
+		src += srcbpp;
+		dst += dstbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+/* General (slow) colorkeyed N->N blending with per-surface alpha */
+static void BlitNtoNSurfaceAlphaKey(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	Uint32 ckey = srcfmt->colorkey;
+	int srcbpp = srcfmt->BytesPerPixel;
+	int dstbpp = dstfmt->BytesPerPixel;
+	unsigned sA = srcfmt->alpha;
+	unsigned dA = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
+
+	while ( height-- ) {
+	    DUFFS_LOOP4(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		RETRIEVE_RGB_PIXEL(src, srcbpp, pixel);
+		if(pixel != ckey) {
+		    RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB);
+		    DISEMBLE_RGB(dst, dstbpp, dstfmt, pixel, dR, dG, dB);
+		    ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
+		    ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
+		}
+		src += srcbpp;
+		dst += dstbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+/* General (slow) N->N blending with pixel alpha */
+static void BlitNtoNPixelAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+
+	int  srcbpp;
+	int  dstbpp;
+
+	/* Set up some basic variables */
+	srcbpp = srcfmt->BytesPerPixel;
+	dstbpp = dstfmt->BytesPerPixel;
+
+	/* FIXME: for 8bpp source alpha, this doesn't get opaque values
+	   quite right. for <8bpp source alpha, it gets them very wrong
+	   (check all macros!)
+	   It is unclear whether there is a good general solution that doesn't
+	   need a branch (or a divide). */
+	while ( height-- ) {
+	    DUFFS_LOOP4(
+	    {
+		Uint32 pixel;
+		unsigned sR;
+		unsigned sG;
+		unsigned sB;
+		unsigned dR;
+		unsigned dG;
+		unsigned dB;
+		unsigned sA;
+		unsigned dA;
+		DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA);
+		DISEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
+		ALPHA_BLEND(sR, sG, sB, sA, dR, dG, dB);
+		ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
+		src += srcbpp;
+		dst += dstbpp;
+	    },
+	    width);
+	    src += srcskip;
+	    dst += dstskip;
+	}
+}
+
+
+SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index)
+{
+    SDL_PixelFormat *sf = surface->format;
+    SDL_PixelFormat *df = surface->map->dst->format;
+
+    if(sf->Amask == 0) {
+	if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
+	    if(df->BytesPerPixel == 1)
+		return BlitNto1SurfaceAlphaKey;
+	    else
+		return BlitNtoNSurfaceAlphaKey;
+	} else {
+	    /* Per-surface alpha blits */
+	    switch(df->BytesPerPixel) {
+	    case 1:
+		return BlitNto1SurfaceAlpha;
+
+	    case 2:
+		if(surface->map->identity) {
+		    if(df->Gmask == 0x7e0)
+			return Blit565to565SurfaceAlpha;
+		    else if(df->Gmask == 0x3e0)
+			return Blit555to555SurfaceAlpha;
+		}
+		return BlitNtoNSurfaceAlpha;
+
+	    case 4:
+		if(sf->Rmask == df->Rmask
+		   && sf->Gmask == df->Gmask
+		   && sf->Bmask == df->Bmask
+		   && (sf->Rmask | sf->Gmask | sf->Bmask) == 0xffffff
+		   && sf->BytesPerPixel == 4)
+		    return BlitRGBtoRGBSurfaceAlpha;
+		else
+		    return BlitNtoNSurfaceAlpha;
+
+	    case 3:
+	    default:
+		return BlitNtoNSurfaceAlpha;
+	    }
+	}
+    } else {
+	/* Per-pixel alpha blits */
+	switch(df->BytesPerPixel) {
+	case 1:
+	    return BlitNto1PixelAlpha;
+
+	case 2:
+	    if(sf->BytesPerPixel == 4 && sf->Amask == 0xff000000
+	       && sf->Gmask == 0xff00
+	       && ((sf->Rmask == 0xff && df->Rmask == 0x1f)
+		   || (sf->Bmask == 0xff && df->Bmask == 0x1f))) {
+		if(df->Gmask == 0x7e0)
+		    return BlitARGBto565PixelAlpha;
+		else if(df->Gmask == 0x3e0)
+		    return BlitARGBto555PixelAlpha;
+	    }
+	    return BlitNtoNPixelAlpha;
+
+	case 4:
+	    if(sf->Amask == 0xff000000
+	       && sf->Rmask == df->Rmask
+	       && sf->Gmask == df->Gmask
+	       && sf->Bmask == df->Bmask
+	       && sf->BytesPerPixel == 4)
+		return BlitRGBtoRGBPixelAlpha;
+	    return BlitNtoNPixelAlpha;
+
+	case 3:
+	default:
+	    return BlitNtoNPixelAlpha;
+	}
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_A.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Functions from SDL_blitalpha.c */
+extern void SDL_BlitAlpha(SDL_BlitInfo *info);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_blit_N.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1607 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_byteorder.h"
+
+/* Function to check the CPU flags */
+#define MMX_CPU		0x800000
+#ifdef USE_ASMBLIT
+#define CPU_Flags()	Hermes_X86_CPU()
+#else
+#define CPU_Flags()	0L
+#endif
+
+/* Functions to blit from N-bit surfaces to other surfaces */
+
+#ifdef USE_ASMBLIT
+
+/* Heheheh, we coerce Hermes into using SDL blit information */
+#define X86_ASSEMBLER
+#define HermesConverterInterface	SDL_BlitInfo
+#define HermesClearInterface		void
+#define STACKCALL
+typedef Uint32 int32;
+
+#include "HeadMMX.h"
+#include "HeadX86.h"
+
+#else
+
+/* This is now endian dependent */
+#if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
+#define HI	1
+#define LO	0
+#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
+#define HI	0
+#define LO	1
+#endif
+
+/* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
+#define RGB888_RGB332(dst, src) { \
+	dst = (((src)&0x00E00000)>>16)| \
+	      (((src)&0x0000E000)>>11)| \
+	      (((src)&0x000000C0)>>6); \
+}
+static void Blit_RGB888_index8(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint32 *src;
+	Uint8 *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = (Uint32 *)info->s_pixels;
+	srcskip = info->s_skip/4;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+
+	if ( map == NULL ) {
+		while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+			DUFFS_LOOP(
+				RGB888_RGB332(*dst++, *src);
+			, width);
+#else
+			for ( c=width/4; c; --c ) {
+				/* Pack RGB into 8bit pixel */
+				++src;
+				RGB888_RGB332(*dst++, *src);
+				++src;
+				RGB888_RGB332(*dst++, *src);
+				++src;
+				RGB888_RGB332(*dst++, *src);
+				++src;
+			}
+			switch ( width % 4 ) {
+				case 3:
+					RGB888_RGB332(*dst++, *src);
+					++src;
+				case 2:
+					RGB888_RGB332(*dst++, *src);
+					++src;
+				case 1:
+					RGB888_RGB332(*dst++, *src);
+					++src;
+			}
+#endif /* USE_DUFFS_LOOP */
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		int pixel;
+
+		while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+			DUFFS_LOOP(
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+			, width);
+#else
+			for ( c=width/4; c; --c ) {
+				/* Pack RGB into 8bit pixel */
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+			}
+			switch ( width % 4 ) {
+				case 3:
+					RGB888_RGB332(pixel, *src);
+					*dst++ = map[pixel];
+					++src;
+				case 2:
+					RGB888_RGB332(pixel, *src);
+					*dst++ = map[pixel];
+					++src;
+				case 1:
+					RGB888_RGB332(pixel, *src);
+					*dst++ = map[pixel];
+					++src;
+			}
+#endif /* USE_DUFFS_LOOP */
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+/* Special optimized blit for RGB 8-8-8 --> RGB 5-5-5 */
+#define RGB888_RGB555(dst, src) { \
+	*(Uint16 *)(dst) = (((*src)&0x00F80000)>>9)| \
+	                   (((*src)&0x0000F800)>>6)| \
+	                   (((*src)&0x000000F8)>>3); \
+}
+#define RGB888_RGB555_TWO(dst, src) { \
+	*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>9)| \
+	                     (((src[HI])&0x0000F800)>>6)| \
+	                     (((src[HI])&0x000000F8)>>3))<<16)| \
+	                     (((src[LO])&0x00F80000)>>9)| \
+	                     (((src[LO])&0x0000F800)>>6)| \
+	                     (((src[LO])&0x000000F8)>>3); \
+}
+static void Blit_RGB888_RGB555(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint32 *src;
+	Uint16 *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = (Uint32 *)info->s_pixels;
+	srcskip = info->s_skip/4;
+	dst = (Uint16 *)info->d_pixels;
+	dstskip = info->d_skip/2;
+
+#ifdef USE_DUFFS_LOOP
+	while ( height-- ) {
+		DUFFS_LOOP(
+			RGB888_RGB555(dst, src);
+			++src;
+			++dst;
+		, width);
+		src += srcskip;
+		dst += dstskip;
+	}
+#else
+	/* Memory align at 4-byte boundary, if necessary */
+	if ( (long)dst & 0x03 ) {
+		/* Don't do anything if width is 0 */
+		if ( width == 0 ) {
+			return;
+		}
+		--width;
+
+		while ( height-- ) {
+			/* Perform copy alignment */
+			RGB888_RGB555(dst, src);
+			++src;
+			++dst;
+
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				RGB888_RGB555_TWO(dst, src);
+				src += 2;
+				dst += 2;
+				RGB888_RGB555_TWO(dst, src);
+				src += 2;
+				dst += 2;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					RGB888_RGB555(dst, src);
+					++src;
+					++dst;
+				case 2:
+					RGB888_RGB555_TWO(dst, src);
+					src += 2;
+					dst += 2;
+					break;
+				case 1:
+					RGB888_RGB555(dst, src);
+					++src;
+					++dst;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else { 
+		while ( height-- ) {
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				RGB888_RGB555_TWO(dst, src);
+				src += 2;
+				dst += 2;
+				RGB888_RGB555_TWO(dst, src);
+				src += 2;
+				dst += 2;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					RGB888_RGB555(dst, src);
+					++src;
+					++dst;
+				case 2:
+					RGB888_RGB555_TWO(dst, src);
+					src += 2;
+					dst += 2;
+					break;
+				case 1:
+					RGB888_RGB555(dst, src);
+					++src;
+					++dst;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+#endif /* USE_DUFFS_LOOP */
+}
+/* Special optimized blit for RGB 8-8-8 --> RGB 5-6-5 */
+#define RGB888_RGB565(dst, src) { \
+	*(Uint16 *)(dst) = (((*src)&0x00F80000)>>8)| \
+	                   (((*src)&0x0000FC00)>>5)| \
+	                   (((*src)&0x000000F8)>>3); \
+}
+#define RGB888_RGB565_TWO(dst, src) { \
+	*(Uint32 *)(dst) = (((((src[HI])&0x00F80000)>>8)| \
+	                     (((src[HI])&0x0000FC00)>>5)| \
+	                     (((src[HI])&0x000000F8)>>3))<<16)| \
+	                     (((src[LO])&0x00F80000)>>8)| \
+	                     (((src[LO])&0x0000FC00)>>5)| \
+	                     (((src[LO])&0x000000F8)>>3); \
+}
+static void Blit_RGB888_RGB565(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint32 *src;
+	Uint16 *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = (Uint32 *)info->s_pixels;
+	srcskip = info->s_skip/4;
+	dst = (Uint16 *)info->d_pixels;
+	dstskip = info->d_skip/2;
+
+#ifdef USE_DUFFS_LOOP
+	while ( height-- ) {
+		DUFFS_LOOP(
+			RGB888_RGB565(dst, src);
+			++src;
+			++dst;
+		, width);
+		src += srcskip;
+		dst += dstskip;
+	}
+#else
+	/* Memory align at 4-byte boundary, if necessary */
+	if ( (long)dst & 0x03 ) {
+		/* Don't do anything if width is 0 */
+		if ( width == 0 ) {
+			return;
+		}
+		--width;
+
+		while ( height-- ) {
+			/* Perform copy alignment */
+			RGB888_RGB565(dst, src);
+			++src;
+			++dst;
+
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				RGB888_RGB565_TWO(dst, src);
+				src += 2;
+				dst += 2;
+				RGB888_RGB565_TWO(dst, src);
+				src += 2;
+				dst += 2;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					RGB888_RGB565(dst, src);
+					++src;
+					++dst;
+				case 2:
+					RGB888_RGB565_TWO(dst, src);
+					src += 2;
+					dst += 2;
+					break;
+				case 1:
+					RGB888_RGB565(dst, src);
+					++src;
+					++dst;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else { 
+		while ( height-- ) {
+			/* Copy in 4 pixel chunks */
+			for ( c=width/4; c; --c ) {
+				RGB888_RGB565_TWO(dst, src);
+				src += 2;
+				dst += 2;
+				RGB888_RGB565_TWO(dst, src);
+				src += 2;
+				dst += 2;
+			}
+			/* Get any leftovers */
+			switch (width % 4) {
+				case 3:
+					RGB888_RGB565(dst, src);
+					++src;
+					++dst;
+				case 2:
+					RGB888_RGB565_TWO(dst, src);
+					src += 2;
+					dst += 2;
+					break;
+				case 1:
+					RGB888_RGB565(dst, src);
+					++src;
+					++dst;
+					break;
+			}
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+#endif /* USE_DUFFS_LOOP */
+}
+
+#endif /* USE_ASMBLIT */
+
+
+/* Special optimized blit for RGB 5-6-5 --> 32-bit RGB surfaces */
+#if ( SDL_BYTEORDER == SDL_LIL_ENDIAN )
+#define RGB565_32(dst, src, map) (map[src[0]*2] + map[src[1]*2+1])
+#else /* ( SDL_BYTEORDER == SDL_BIG_ENDIAN ) */
+#define RGB565_32(dst, src, map) (map[src[1]*2] + map[src[0]*2+1])
+#endif
+static void Blit_RGB565_32(SDL_BlitInfo *info, Uint32 *map)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint8 *src;
+	Uint32 *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = (Uint8 *)info->s_pixels;
+	srcskip = info->s_skip;
+	dst = (Uint32 *)info->d_pixels;
+	dstskip = info->d_skip/4;
+
+#ifdef USE_DUFFS_LOOP
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			*dst++ = RGB565_32(dst, src, map);
+			src += 2;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+#else
+	while ( height-- ) {
+		/* Copy in 4 pixel chunks */
+		for ( c=width/4; c; --c ) {
+			*dst++ = RGB565_32(dst, src, map);
+			src += 2;
+			*dst++ = RGB565_32(dst, src, map);
+			src += 2;
+			*dst++ = RGB565_32(dst, src, map);
+			src += 2;
+			*dst++ = RGB565_32(dst, src, map);
+			src += 2;
+		}
+		/* Get any leftovers */
+		switch (width % 4) {
+			case 3:
+				*dst++ = RGB565_32(dst, src, map);
+				src += 2;
+			case 2:
+				*dst++ = RGB565_32(dst, src, map);
+				src += 2;
+			case 1:
+				*dst++ = RGB565_32(dst, src, map);
+				src += 2;
+				break;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+#endif /* USE_DUFFS_LOOP */
+}
+
+/* Special optimized blit for RGB 5-6-5 --> ARGB 8-8-8-8 */
+static Uint32 RGB565_ARGB8888_LUT[512] = {
+		0x00000000, 0xff000000, 0x00000008, 0xff002000,
+		0x00000010, 0xff004000, 0x00000018, 0xff006100,
+		0x00000020, 0xff008100, 0x00000029, 0xff00a100,
+		0x00000031, 0xff00c200, 0x00000039, 0xff00e200,
+		0x00000041, 0xff080000, 0x0000004a, 0xff082000,
+		0x00000052, 0xff084000, 0x0000005a, 0xff086100,
+		0x00000062, 0xff088100, 0x0000006a, 0xff08a100,
+		0x00000073, 0xff08c200, 0x0000007b, 0xff08e200,
+		0x00000083, 0xff100000, 0x0000008b, 0xff102000,
+		0x00000094, 0xff104000, 0x0000009c, 0xff106100,
+		0x000000a4, 0xff108100, 0x000000ac, 0xff10a100,
+		0x000000b4, 0xff10c200, 0x000000bd, 0xff10e200,
+		0x000000c5, 0xff180000, 0x000000cd, 0xff182000,
+		0x000000d5, 0xff184000, 0x000000de, 0xff186100,
+		0x000000e6, 0xff188100, 0x000000ee, 0xff18a100,
+		0x000000f6, 0xff18c200, 0x000000ff, 0xff18e200,
+		0x00000400, 0xff200000, 0x00000408, 0xff202000,
+		0x00000410, 0xff204000, 0x00000418, 0xff206100,
+		0x00000420, 0xff208100, 0x00000429, 0xff20a100,
+		0x00000431, 0xff20c200, 0x00000439, 0xff20e200,
+		0x00000441, 0xff290000, 0x0000044a, 0xff292000,
+		0x00000452, 0xff294000, 0x0000045a, 0xff296100,
+		0x00000462, 0xff298100, 0x0000046a, 0xff29a100,
+		0x00000473, 0xff29c200, 0x0000047b, 0xff29e200,
+		0x00000483, 0xff310000, 0x0000048b, 0xff312000,
+		0x00000494, 0xff314000, 0x0000049c, 0xff316100,
+		0x000004a4, 0xff318100, 0x000004ac, 0xff31a100,
+		0x000004b4, 0xff31c200, 0x000004bd, 0xff31e200,
+		0x000004c5, 0xff390000, 0x000004cd, 0xff392000,
+		0x000004d5, 0xff394000, 0x000004de, 0xff396100,
+		0x000004e6, 0xff398100, 0x000004ee, 0xff39a100,
+		0x000004f6, 0xff39c200, 0x000004ff, 0xff39e200,
+		0x00000800, 0xff410000, 0x00000808, 0xff412000,
+		0x00000810, 0xff414000, 0x00000818, 0xff416100,
+		0x00000820, 0xff418100, 0x00000829, 0xff41a100,
+		0x00000831, 0xff41c200, 0x00000839, 0xff41e200,
+		0x00000841, 0xff4a0000, 0x0000084a, 0xff4a2000,
+		0x00000852, 0xff4a4000, 0x0000085a, 0xff4a6100,
+		0x00000862, 0xff4a8100, 0x0000086a, 0xff4aa100,
+		0x00000873, 0xff4ac200, 0x0000087b, 0xff4ae200,
+		0x00000883, 0xff520000, 0x0000088b, 0xff522000,
+		0x00000894, 0xff524000, 0x0000089c, 0xff526100,
+		0x000008a4, 0xff528100, 0x000008ac, 0xff52a100,
+		0x000008b4, 0xff52c200, 0x000008bd, 0xff52e200,
+		0x000008c5, 0xff5a0000, 0x000008cd, 0xff5a2000,
+		0x000008d5, 0xff5a4000, 0x000008de, 0xff5a6100,
+		0x000008e6, 0xff5a8100, 0x000008ee, 0xff5aa100,
+		0x000008f6, 0xff5ac200, 0x000008ff, 0xff5ae200,
+		0x00000c00, 0xff620000, 0x00000c08, 0xff622000,
+		0x00000c10, 0xff624000, 0x00000c18, 0xff626100,
+		0x00000c20, 0xff628100, 0x00000c29, 0xff62a100,
+		0x00000c31, 0xff62c200, 0x00000c39, 0xff62e200,
+		0x00000c41, 0xff6a0000, 0x00000c4a, 0xff6a2000,
+		0x00000c52, 0xff6a4000, 0x00000c5a, 0xff6a6100,
+		0x00000c62, 0xff6a8100, 0x00000c6a, 0xff6aa100,
+		0x00000c73, 0xff6ac200, 0x00000c7b, 0xff6ae200,
+		0x00000c83, 0xff730000, 0x00000c8b, 0xff732000,
+		0x00000c94, 0xff734000, 0x00000c9c, 0xff736100,
+		0x00000ca4, 0xff738100, 0x00000cac, 0xff73a100,
+		0x00000cb4, 0xff73c200, 0x00000cbd, 0xff73e200,
+		0x00000cc5, 0xff7b0000, 0x00000ccd, 0xff7b2000,
+		0x00000cd5, 0xff7b4000, 0x00000cde, 0xff7b6100,
+		0x00000ce6, 0xff7b8100, 0x00000cee, 0xff7ba100,
+		0x00000cf6, 0xff7bc200, 0x00000cff, 0xff7be200,
+		0x00001000, 0xff830000, 0x00001008, 0xff832000,
+		0x00001010, 0xff834000, 0x00001018, 0xff836100,
+		0x00001020, 0xff838100, 0x00001029, 0xff83a100,
+		0x00001031, 0xff83c200, 0x00001039, 0xff83e200,
+		0x00001041, 0xff8b0000, 0x0000104a, 0xff8b2000,
+		0x00001052, 0xff8b4000, 0x0000105a, 0xff8b6100,
+		0x00001062, 0xff8b8100, 0x0000106a, 0xff8ba100,
+		0x00001073, 0xff8bc200, 0x0000107b, 0xff8be200,
+		0x00001083, 0xff940000, 0x0000108b, 0xff942000,
+		0x00001094, 0xff944000, 0x0000109c, 0xff946100,
+		0x000010a4, 0xff948100, 0x000010ac, 0xff94a100,
+		0x000010b4, 0xff94c200, 0x000010bd, 0xff94e200,
+		0x000010c5, 0xff9c0000, 0x000010cd, 0xff9c2000,
+		0x000010d5, 0xff9c4000, 0x000010de, 0xff9c6100,
+		0x000010e6, 0xff9c8100, 0x000010ee, 0xff9ca100,
+		0x000010f6, 0xff9cc200, 0x000010ff, 0xff9ce200,
+		0x00001400, 0xffa40000, 0x00001408, 0xffa42000,
+		0x00001410, 0xffa44000, 0x00001418, 0xffa46100,
+		0x00001420, 0xffa48100, 0x00001429, 0xffa4a100,
+		0x00001431, 0xffa4c200, 0x00001439, 0xffa4e200,
+		0x00001441, 0xffac0000, 0x0000144a, 0xffac2000,
+		0x00001452, 0xffac4000, 0x0000145a, 0xffac6100,
+		0x00001462, 0xffac8100, 0x0000146a, 0xffaca100,
+		0x00001473, 0xffacc200, 0x0000147b, 0xfface200,
+		0x00001483, 0xffb40000, 0x0000148b, 0xffb42000,
+		0x00001494, 0xffb44000, 0x0000149c, 0xffb46100,
+		0x000014a4, 0xffb48100, 0x000014ac, 0xffb4a100,
+		0x000014b4, 0xffb4c200, 0x000014bd, 0xffb4e200,
+		0x000014c5, 0xffbd0000, 0x000014cd, 0xffbd2000,
+		0x000014d5, 0xffbd4000, 0x000014de, 0xffbd6100,
+		0x000014e6, 0xffbd8100, 0x000014ee, 0xffbda100,
+		0x000014f6, 0xffbdc200, 0x000014ff, 0xffbde200,
+		0x00001800, 0xffc50000, 0x00001808, 0xffc52000,
+		0x00001810, 0xffc54000, 0x00001818, 0xffc56100,
+		0x00001820, 0xffc58100, 0x00001829, 0xffc5a100,
+		0x00001831, 0xffc5c200, 0x00001839, 0xffc5e200,
+		0x00001841, 0xffcd0000, 0x0000184a, 0xffcd2000,
+		0x00001852, 0xffcd4000, 0x0000185a, 0xffcd6100,
+		0x00001862, 0xffcd8100, 0x0000186a, 0xffcda100,
+		0x00001873, 0xffcdc200, 0x0000187b, 0xffcde200,
+		0x00001883, 0xffd50000, 0x0000188b, 0xffd52000,
+		0x00001894, 0xffd54000, 0x0000189c, 0xffd56100,
+		0x000018a4, 0xffd58100, 0x000018ac, 0xffd5a100,
+		0x000018b4, 0xffd5c200, 0x000018bd, 0xffd5e200,
+		0x000018c5, 0xffde0000, 0x000018cd, 0xffde2000,
+		0x000018d5, 0xffde4000, 0x000018de, 0xffde6100,
+		0x000018e6, 0xffde8100, 0x000018ee, 0xffdea100,
+		0x000018f6, 0xffdec200, 0x000018ff, 0xffdee200,
+		0x00001c00, 0xffe60000, 0x00001c08, 0xffe62000,
+		0x00001c10, 0xffe64000, 0x00001c18, 0xffe66100,
+		0x00001c20, 0xffe68100, 0x00001c29, 0xffe6a100,
+		0x00001c31, 0xffe6c200, 0x00001c39, 0xffe6e200,
+		0x00001c41, 0xffee0000, 0x00001c4a, 0xffee2000,
+		0x00001c52, 0xffee4000, 0x00001c5a, 0xffee6100,
+		0x00001c62, 0xffee8100, 0x00001c6a, 0xffeea100,
+		0x00001c73, 0xffeec200, 0x00001c7b, 0xffeee200,
+		0x00001c83, 0xfff60000, 0x00001c8b, 0xfff62000,
+		0x00001c94, 0xfff64000, 0x00001c9c, 0xfff66100,
+		0x00001ca4, 0xfff68100, 0x00001cac, 0xfff6a100,
+		0x00001cb4, 0xfff6c200, 0x00001cbd, 0xfff6e200,
+		0x00001cc5, 0xffff0000, 0x00001ccd, 0xffff2000,
+		0x00001cd5, 0xffff4000, 0x00001cde, 0xffff6100,
+		0x00001ce6, 0xffff8100, 0x00001cee, 0xffffa100,
+		0x00001cf6, 0xffffc200, 0x00001cff, 0xffffe200
+};
+static void Blit_RGB565_ARGB8888(SDL_BlitInfo *info)
+{
+    Blit_RGB565_32(info, RGB565_ARGB8888_LUT);
+}
+
+/* Special optimized blit for RGB 5-6-5 --> ABGR 8-8-8-8 */
+static Uint32 RGB565_ABGR8888_LUT[512] = {
+		0xff000000, 0x00000000, 0xff080000, 0x00002000,
+		0xff100000, 0x00004000, 0xff180000, 0x00006100,
+		0xff200000, 0x00008100, 0xff290000, 0x0000a100,
+		0xff310000, 0x0000c200, 0xff390000, 0x0000e200,
+		0xff410000, 0x00000008, 0xff4a0000, 0x00002008,
+		0xff520000, 0x00004008, 0xff5a0000, 0x00006108,
+		0xff620000, 0x00008108, 0xff6a0000, 0x0000a108,
+		0xff730000, 0x0000c208, 0xff7b0000, 0x0000e208,
+		0xff830000, 0x00000010, 0xff8b0000, 0x00002010,
+		0xff940000, 0x00004010, 0xff9c0000, 0x00006110,
+		0xffa40000, 0x00008110, 0xffac0000, 0x0000a110,
+		0xffb40000, 0x0000c210, 0xffbd0000, 0x0000e210,
+		0xffc50000, 0x00000018, 0xffcd0000, 0x00002018,
+		0xffd50000, 0x00004018, 0xffde0000, 0x00006118,
+		0xffe60000, 0x00008118, 0xffee0000, 0x0000a118,
+		0xfff60000, 0x0000c218, 0xffff0000, 0x0000e218,
+		0xff000400, 0x00000020, 0xff080400, 0x00002020,
+		0xff100400, 0x00004020, 0xff180400, 0x00006120,
+		0xff200400, 0x00008120, 0xff290400, 0x0000a120,
+		0xff310400, 0x0000c220, 0xff390400, 0x0000e220,
+		0xff410400, 0x00000029, 0xff4a0400, 0x00002029,
+		0xff520400, 0x00004029, 0xff5a0400, 0x00006129,
+		0xff620400, 0x00008129, 0xff6a0400, 0x0000a129,
+		0xff730400, 0x0000c229, 0xff7b0400, 0x0000e229,
+		0xff830400, 0x00000031, 0xff8b0400, 0x00002031,
+		0xff940400, 0x00004031, 0xff9c0400, 0x00006131,
+		0xffa40400, 0x00008131, 0xffac0400, 0x0000a131,
+		0xffb40400, 0x0000c231, 0xffbd0400, 0x0000e231,
+		0xffc50400, 0x00000039, 0xffcd0400, 0x00002039,
+		0xffd50400, 0x00004039, 0xffde0400, 0x00006139,
+		0xffe60400, 0x00008139, 0xffee0400, 0x0000a139,
+		0xfff60400, 0x0000c239, 0xffff0400, 0x0000e239,
+		0xff000800, 0x00000041, 0xff080800, 0x00002041,
+		0xff100800, 0x00004041, 0xff180800, 0x00006141,
+		0xff200800, 0x00008141, 0xff290800, 0x0000a141,
+		0xff310800, 0x0000c241, 0xff390800, 0x0000e241,
+		0xff410800, 0x0000004a, 0xff4a0800, 0x0000204a,
+		0xff520800, 0x0000404a, 0xff5a0800, 0x0000614a,
+		0xff620800, 0x0000814a, 0xff6a0800, 0x0000a14a,
+		0xff730800, 0x0000c24a, 0xff7b0800, 0x0000e24a,
+		0xff830800, 0x00000052, 0xff8b0800, 0x00002052,
+		0xff940800, 0x00004052, 0xff9c0800, 0x00006152,
+		0xffa40800, 0x00008152, 0xffac0800, 0x0000a152,
+		0xffb40800, 0x0000c252, 0xffbd0800, 0x0000e252,
+		0xffc50800, 0x0000005a, 0xffcd0800, 0x0000205a,
+		0xffd50800, 0x0000405a, 0xffde0800, 0x0000615a,
+		0xffe60800, 0x0000815a, 0xffee0800, 0x0000a15a,
+		0xfff60800, 0x0000c25a, 0xffff0800, 0x0000e25a,
+		0xff000c00, 0x00000062, 0xff080c00, 0x00002062,
+		0xff100c00, 0x00004062, 0xff180c00, 0x00006162,
+		0xff200c00, 0x00008162, 0xff290c00, 0x0000a162,
+		0xff310c00, 0x0000c262, 0xff390c00, 0x0000e262,
+		0xff410c00, 0x0000006a, 0xff4a0c00, 0x0000206a,
+		0xff520c00, 0x0000406a, 0xff5a0c00, 0x0000616a,
+		0xff620c00, 0x0000816a, 0xff6a0c00, 0x0000a16a,
+		0xff730c00, 0x0000c26a, 0xff7b0c00, 0x0000e26a,
+		0xff830c00, 0x00000073, 0xff8b0c00, 0x00002073,
+		0xff940c00, 0x00004073, 0xff9c0c00, 0x00006173,
+		0xffa40c00, 0x00008173, 0xffac0c00, 0x0000a173,
+		0xffb40c00, 0x0000c273, 0xffbd0c00, 0x0000e273,
+		0xffc50c00, 0x0000007b, 0xffcd0c00, 0x0000207b,
+		0xffd50c00, 0x0000407b, 0xffde0c00, 0x0000617b,
+		0xffe60c00, 0x0000817b, 0xffee0c00, 0x0000a17b,
+		0xfff60c00, 0x0000c27b, 0xffff0c00, 0x0000e27b,
+		0xff001000, 0x00000083, 0xff081000, 0x00002083,
+		0xff101000, 0x00004083, 0xff181000, 0x00006183,
+		0xff201000, 0x00008183, 0xff291000, 0x0000a183,
+		0xff311000, 0x0000c283, 0xff391000, 0x0000e283,
+		0xff411000, 0x0000008b, 0xff4a1000, 0x0000208b,
+		0xff521000, 0x0000408b, 0xff5a1000, 0x0000618b,
+		0xff621000, 0x0000818b, 0xff6a1000, 0x0000a18b,
+		0xff731000, 0x0000c28b, 0xff7b1000, 0x0000e28b,
+		0xff831000, 0x00000094, 0xff8b1000, 0x00002094,
+		0xff941000, 0x00004094, 0xff9c1000, 0x00006194,
+		0xffa41000, 0x00008194, 0xffac1000, 0x0000a194,
+		0xffb41000, 0x0000c294, 0xffbd1000, 0x0000e294,
+		0xffc51000, 0x0000009c, 0xffcd1000, 0x0000209c,
+		0xffd51000, 0x0000409c, 0xffde1000, 0x0000619c,
+		0xffe61000, 0x0000819c, 0xffee1000, 0x0000a19c,
+		0xfff61000, 0x0000c29c, 0xffff1000, 0x0000e29c,
+		0xff001400, 0x000000a4, 0xff081400, 0x000020a4,
+		0xff101400, 0x000040a4, 0xff181400, 0x000061a4,
+		0xff201400, 0x000081a4, 0xff291400, 0x0000a1a4,
+		0xff311400, 0x0000c2a4, 0xff391400, 0x0000e2a4,
+		0xff411400, 0x000000ac, 0xff4a1400, 0x000020ac,
+		0xff521400, 0x000040ac, 0xff5a1400, 0x000061ac,
+		0xff621400, 0x000081ac, 0xff6a1400, 0x0000a1ac,
+		0xff731400, 0x0000c2ac, 0xff7b1400, 0x0000e2ac,
+		0xff831400, 0x000000b4, 0xff8b1400, 0x000020b4,
+		0xff941400, 0x000040b4, 0xff9c1400, 0x000061b4,
+		0xffa41400, 0x000081b4, 0xffac1400, 0x0000a1b4,
+		0xffb41400, 0x0000c2b4, 0xffbd1400, 0x0000e2b4,
+		0xffc51400, 0x000000bd, 0xffcd1400, 0x000020bd,
+		0xffd51400, 0x000040bd, 0xffde1400, 0x000061bd,
+		0xffe61400, 0x000081bd, 0xffee1400, 0x0000a1bd,
+		0xfff61400, 0x0000c2bd, 0xffff1400, 0x0000e2bd,
+		0xff001800, 0x000000c5, 0xff081800, 0x000020c5,
+		0xff101800, 0x000040c5, 0xff181800, 0x000061c5,
+		0xff201800, 0x000081c5, 0xff291800, 0x0000a1c5,
+		0xff311800, 0x0000c2c5, 0xff391800, 0x0000e2c5,
+		0xff411800, 0x000000cd, 0xff4a1800, 0x000020cd,
+		0xff521800, 0x000040cd, 0xff5a1800, 0x000061cd,
+		0xff621800, 0x000081cd, 0xff6a1800, 0x0000a1cd,
+		0xff731800, 0x0000c2cd, 0xff7b1800, 0x0000e2cd,
+		0xff831800, 0x000000d5, 0xff8b1800, 0x000020d5,
+		0xff941800, 0x000040d5, 0xff9c1800, 0x000061d5,
+		0xffa41800, 0x000081d5, 0xffac1800, 0x0000a1d5,
+		0xffb41800, 0x0000c2d5, 0xffbd1800, 0x0000e2d5,
+		0xffc51800, 0x000000de, 0xffcd1800, 0x000020de,
+		0xffd51800, 0x000040de, 0xffde1800, 0x000061de,
+		0xffe61800, 0x000081de, 0xffee1800, 0x0000a1de,
+		0xfff61800, 0x0000c2de, 0xffff1800, 0x0000e2de,
+		0xff001c00, 0x000000e6, 0xff081c00, 0x000020e6,
+		0xff101c00, 0x000040e6, 0xff181c00, 0x000061e6,
+		0xff201c00, 0x000081e6, 0xff291c00, 0x0000a1e6,
+		0xff311c00, 0x0000c2e6, 0xff391c00, 0x0000e2e6,
+		0xff411c00, 0x000000ee, 0xff4a1c00, 0x000020ee,
+		0xff521c00, 0x000040ee, 0xff5a1c00, 0x000061ee,
+		0xff621c00, 0x000081ee, 0xff6a1c00, 0x0000a1ee,
+		0xff731c00, 0x0000c2ee, 0xff7b1c00, 0x0000e2ee,
+		0xff831c00, 0x000000f6, 0xff8b1c00, 0x000020f6,
+		0xff941c00, 0x000040f6, 0xff9c1c00, 0x000061f6,
+		0xffa41c00, 0x000081f6, 0xffac1c00, 0x0000a1f6,
+		0xffb41c00, 0x0000c2f6, 0xffbd1c00, 0x0000e2f6,
+		0xffc51c00, 0x000000ff, 0xffcd1c00, 0x000020ff,
+		0xffd51c00, 0x000040ff, 0xffde1c00, 0x000061ff,
+		0xffe61c00, 0x000081ff, 0xffee1c00, 0x0000a1ff,
+		0xfff61c00, 0x0000c2ff, 0xffff1c00, 0x0000e2ff
+};
+static void Blit_RGB565_ABGR8888(SDL_BlitInfo *info)
+{
+    Blit_RGB565_32(info, RGB565_ABGR8888_LUT);
+}
+
+/* Special optimized blit for RGB 5-6-5 --> RGBA 8-8-8-8 */
+static Uint32 RGB565_RGBA8888_LUT[512] = {
+		0x000000ff, 0x00000000, 0x000008ff, 0x00200000,
+		0x000010ff, 0x00400000, 0x000018ff, 0x00610000,
+		0x000020ff, 0x00810000, 0x000029ff, 0x00a10000,
+		0x000031ff, 0x00c20000, 0x000039ff, 0x00e20000,
+		0x000041ff, 0x08000000, 0x00004aff, 0x08200000,
+		0x000052ff, 0x08400000, 0x00005aff, 0x08610000,
+		0x000062ff, 0x08810000, 0x00006aff, 0x08a10000,
+		0x000073ff, 0x08c20000, 0x00007bff, 0x08e20000,
+		0x000083ff, 0x10000000, 0x00008bff, 0x10200000,
+		0x000094ff, 0x10400000, 0x00009cff, 0x10610000,
+		0x0000a4ff, 0x10810000, 0x0000acff, 0x10a10000,
+		0x0000b4ff, 0x10c20000, 0x0000bdff, 0x10e20000,
+		0x0000c5ff, 0x18000000, 0x0000cdff, 0x18200000,
+		0x0000d5ff, 0x18400000, 0x0000deff, 0x18610000,
+		0x0000e6ff, 0x18810000, 0x0000eeff, 0x18a10000,
+		0x0000f6ff, 0x18c20000, 0x0000ffff, 0x18e20000,
+		0x000400ff, 0x20000000, 0x000408ff, 0x20200000,
+		0x000410ff, 0x20400000, 0x000418ff, 0x20610000,
+		0x000420ff, 0x20810000, 0x000429ff, 0x20a10000,
+		0x000431ff, 0x20c20000, 0x000439ff, 0x20e20000,
+		0x000441ff, 0x29000000, 0x00044aff, 0x29200000,
+		0x000452ff, 0x29400000, 0x00045aff, 0x29610000,
+		0x000462ff, 0x29810000, 0x00046aff, 0x29a10000,
+		0x000473ff, 0x29c20000, 0x00047bff, 0x29e20000,
+		0x000483ff, 0x31000000, 0x00048bff, 0x31200000,
+		0x000494ff, 0x31400000, 0x00049cff, 0x31610000,
+		0x0004a4ff, 0x31810000, 0x0004acff, 0x31a10000,
+		0x0004b4ff, 0x31c20000, 0x0004bdff, 0x31e20000,
+		0x0004c5ff, 0x39000000, 0x0004cdff, 0x39200000,
+		0x0004d5ff, 0x39400000, 0x0004deff, 0x39610000,
+		0x0004e6ff, 0x39810000, 0x0004eeff, 0x39a10000,
+		0x0004f6ff, 0x39c20000, 0x0004ffff, 0x39e20000,
+		0x000800ff, 0x41000000, 0x000808ff, 0x41200000,
+		0x000810ff, 0x41400000, 0x000818ff, 0x41610000,
+		0x000820ff, 0x41810000, 0x000829ff, 0x41a10000,
+		0x000831ff, 0x41c20000, 0x000839ff, 0x41e20000,
+		0x000841ff, 0x4a000000, 0x00084aff, 0x4a200000,
+		0x000852ff, 0x4a400000, 0x00085aff, 0x4a610000,
+		0x000862ff, 0x4a810000, 0x00086aff, 0x4aa10000,
+		0x000873ff, 0x4ac20000, 0x00087bff, 0x4ae20000,
+		0x000883ff, 0x52000000, 0x00088bff, 0x52200000,
+		0x000894ff, 0x52400000, 0x00089cff, 0x52610000,
+		0x0008a4ff, 0x52810000, 0x0008acff, 0x52a10000,
+		0x0008b4ff, 0x52c20000, 0x0008bdff, 0x52e20000,
+		0x0008c5ff, 0x5a000000, 0x0008cdff, 0x5a200000,
+		0x0008d5ff, 0x5a400000, 0x0008deff, 0x5a610000,
+		0x0008e6ff, 0x5a810000, 0x0008eeff, 0x5aa10000,
+		0x0008f6ff, 0x5ac20000, 0x0008ffff, 0x5ae20000,
+		0x000c00ff, 0x62000000, 0x000c08ff, 0x62200000,
+		0x000c10ff, 0x62400000, 0x000c18ff, 0x62610000,
+		0x000c20ff, 0x62810000, 0x000c29ff, 0x62a10000,
+		0x000c31ff, 0x62c20000, 0x000c39ff, 0x62e20000,
+		0x000c41ff, 0x6a000000, 0x000c4aff, 0x6a200000,
+		0x000c52ff, 0x6a400000, 0x000c5aff, 0x6a610000,
+		0x000c62ff, 0x6a810000, 0x000c6aff, 0x6aa10000,
+		0x000c73ff, 0x6ac20000, 0x000c7bff, 0x6ae20000,
+		0x000c83ff, 0x73000000, 0x000c8bff, 0x73200000,
+		0x000c94ff, 0x73400000, 0x000c9cff, 0x73610000,
+		0x000ca4ff, 0x73810000, 0x000cacff, 0x73a10000,
+		0x000cb4ff, 0x73c20000, 0x000cbdff, 0x73e20000,
+		0x000cc5ff, 0x7b000000, 0x000ccdff, 0x7b200000,
+		0x000cd5ff, 0x7b400000, 0x000cdeff, 0x7b610000,
+		0x000ce6ff, 0x7b810000, 0x000ceeff, 0x7ba10000,
+		0x000cf6ff, 0x7bc20000, 0x000cffff, 0x7be20000,
+		0x001000ff, 0x83000000, 0x001008ff, 0x83200000,
+		0x001010ff, 0x83400000, 0x001018ff, 0x83610000,
+		0x001020ff, 0x83810000, 0x001029ff, 0x83a10000,
+		0x001031ff, 0x83c20000, 0x001039ff, 0x83e20000,
+		0x001041ff, 0x8b000000, 0x00104aff, 0x8b200000,
+		0x001052ff, 0x8b400000, 0x00105aff, 0x8b610000,
+		0x001062ff, 0x8b810000, 0x00106aff, 0x8ba10000,
+		0x001073ff, 0x8bc20000, 0x00107bff, 0x8be20000,
+		0x001083ff, 0x94000000, 0x00108bff, 0x94200000,
+		0x001094ff, 0x94400000, 0x00109cff, 0x94610000,
+		0x0010a4ff, 0x94810000, 0x0010acff, 0x94a10000,
+		0x0010b4ff, 0x94c20000, 0x0010bdff, 0x94e20000,
+		0x0010c5ff, 0x9c000000, 0x0010cdff, 0x9c200000,
+		0x0010d5ff, 0x9c400000, 0x0010deff, 0x9c610000,
+		0x0010e6ff, 0x9c810000, 0x0010eeff, 0x9ca10000,
+		0x0010f6ff, 0x9cc20000, 0x0010ffff, 0x9ce20000,
+		0x001400ff, 0xa4000000, 0x001408ff, 0xa4200000,
+		0x001410ff, 0xa4400000, 0x001418ff, 0xa4610000,
+		0x001420ff, 0xa4810000, 0x001429ff, 0xa4a10000,
+		0x001431ff, 0xa4c20000, 0x001439ff, 0xa4e20000,
+		0x001441ff, 0xac000000, 0x00144aff, 0xac200000,
+		0x001452ff, 0xac400000, 0x00145aff, 0xac610000,
+		0x001462ff, 0xac810000, 0x00146aff, 0xaca10000,
+		0x001473ff, 0xacc20000, 0x00147bff, 0xace20000,
+		0x001483ff, 0xb4000000, 0x00148bff, 0xb4200000,
+		0x001494ff, 0xb4400000, 0x00149cff, 0xb4610000,
+		0x0014a4ff, 0xb4810000, 0x0014acff, 0xb4a10000,
+		0x0014b4ff, 0xb4c20000, 0x0014bdff, 0xb4e20000,
+		0x0014c5ff, 0xbd000000, 0x0014cdff, 0xbd200000,
+		0x0014d5ff, 0xbd400000, 0x0014deff, 0xbd610000,
+		0x0014e6ff, 0xbd810000, 0x0014eeff, 0xbda10000,
+		0x0014f6ff, 0xbdc20000, 0x0014ffff, 0xbde20000,
+		0x001800ff, 0xc5000000, 0x001808ff, 0xc5200000,
+		0x001810ff, 0xc5400000, 0x001818ff, 0xc5610000,
+		0x001820ff, 0xc5810000, 0x001829ff, 0xc5a10000,
+		0x001831ff, 0xc5c20000, 0x001839ff, 0xc5e20000,
+		0x001841ff, 0xcd000000, 0x00184aff, 0xcd200000,
+		0x001852ff, 0xcd400000, 0x00185aff, 0xcd610000,
+		0x001862ff, 0xcd810000, 0x00186aff, 0xcda10000,
+		0x001873ff, 0xcdc20000, 0x00187bff, 0xcde20000,
+		0x001883ff, 0xd5000000, 0x00188bff, 0xd5200000,
+		0x001894ff, 0xd5400000, 0x00189cff, 0xd5610000,
+		0x0018a4ff, 0xd5810000, 0x0018acff, 0xd5a10000,
+		0x0018b4ff, 0xd5c20000, 0x0018bdff, 0xd5e20000,
+		0x0018c5ff, 0xde000000, 0x0018cdff, 0xde200000,
+		0x0018d5ff, 0xde400000, 0x0018deff, 0xde610000,
+		0x0018e6ff, 0xde810000, 0x0018eeff, 0xdea10000,
+		0x0018f6ff, 0xdec20000, 0x0018ffff, 0xdee20000,
+		0x001c00ff, 0xe6000000, 0x001c08ff, 0xe6200000,
+		0x001c10ff, 0xe6400000, 0x001c18ff, 0xe6610000,
+		0x001c20ff, 0xe6810000, 0x001c29ff, 0xe6a10000,
+		0x001c31ff, 0xe6c20000, 0x001c39ff, 0xe6e20000,
+		0x001c41ff, 0xee000000, 0x001c4aff, 0xee200000,
+		0x001c52ff, 0xee400000, 0x001c5aff, 0xee610000,
+		0x001c62ff, 0xee810000, 0x001c6aff, 0xeea10000,
+		0x001c73ff, 0xeec20000, 0x001c7bff, 0xeee20000,
+		0x001c83ff, 0xf6000000, 0x001c8bff, 0xf6200000,
+		0x001c94ff, 0xf6400000, 0x001c9cff, 0xf6610000,
+		0x001ca4ff, 0xf6810000, 0x001cacff, 0xf6a10000,
+		0x001cb4ff, 0xf6c20000, 0x001cbdff, 0xf6e20000,
+		0x001cc5ff, 0xff000000, 0x001ccdff, 0xff200000,
+		0x001cd5ff, 0xff400000, 0x001cdeff, 0xff610000,
+		0x001ce6ff, 0xff810000, 0x001ceeff, 0xffa10000,
+		0x001cf6ff, 0xffc20000, 0x001cffff, 0xffe20000,
+};
+static void Blit_RGB565_RGBA8888(SDL_BlitInfo *info)
+{
+    Blit_RGB565_32(info, RGB565_RGBA8888_LUT);
+}
+
+/* Special optimized blit for RGB 5-6-5 --> BGRA 8-8-8-8 */
+static Uint32 RGB565_BGRA8888_LUT[512] = {
+		0x00000000, 0x000000ff, 0x08000000, 0x002000ff,
+		0x10000000, 0x004000ff, 0x18000000, 0x006100ff,
+		0x20000000, 0x008100ff, 0x29000000, 0x00a100ff,
+		0x31000000, 0x00c200ff, 0x39000000, 0x00e200ff,
+		0x41000000, 0x000008ff, 0x4a000000, 0x002008ff,
+		0x52000000, 0x004008ff, 0x5a000000, 0x006108ff,
+		0x62000000, 0x008108ff, 0x6a000000, 0x00a108ff,
+		0x73000000, 0x00c208ff, 0x7b000000, 0x00e208ff,
+		0x83000000, 0x000010ff, 0x8b000000, 0x002010ff,
+		0x94000000, 0x004010ff, 0x9c000000, 0x006110ff,
+		0xa4000000, 0x008110ff, 0xac000000, 0x00a110ff,
+		0xb4000000, 0x00c210ff, 0xbd000000, 0x00e210ff,
+		0xc5000000, 0x000018ff, 0xcd000000, 0x002018ff,
+		0xd5000000, 0x004018ff, 0xde000000, 0x006118ff,
+		0xe6000000, 0x008118ff, 0xee000000, 0x00a118ff,
+		0xf6000000, 0x00c218ff, 0xff000000, 0x00e218ff,
+		0x00040000, 0x000020ff, 0x08040000, 0x002020ff,
+		0x10040000, 0x004020ff, 0x18040000, 0x006120ff,
+		0x20040000, 0x008120ff, 0x29040000, 0x00a120ff,
+		0x31040000, 0x00c220ff, 0x39040000, 0x00e220ff,
+		0x41040000, 0x000029ff, 0x4a040000, 0x002029ff,
+		0x52040000, 0x004029ff, 0x5a040000, 0x006129ff,
+		0x62040000, 0x008129ff, 0x6a040000, 0x00a129ff,
+		0x73040000, 0x00c229ff, 0x7b040000, 0x00e229ff,
+		0x83040000, 0x000031ff, 0x8b040000, 0x002031ff,
+		0x94040000, 0x004031ff, 0x9c040000, 0x006131ff,
+		0xa4040000, 0x008131ff, 0xac040000, 0x00a131ff,
+		0xb4040000, 0x00c231ff, 0xbd040000, 0x00e231ff,
+		0xc5040000, 0x000039ff, 0xcd040000, 0x002039ff,
+		0xd5040000, 0x004039ff, 0xde040000, 0x006139ff,
+		0xe6040000, 0x008139ff, 0xee040000, 0x00a139ff,
+		0xf6040000, 0x00c239ff, 0xff040000, 0x00e239ff,
+		0x00080000, 0x000041ff, 0x08080000, 0x002041ff,
+		0x10080000, 0x004041ff, 0x18080000, 0x006141ff,
+		0x20080000, 0x008141ff, 0x29080000, 0x00a141ff,
+		0x31080000, 0x00c241ff, 0x39080000, 0x00e241ff,
+		0x41080000, 0x00004aff, 0x4a080000, 0x00204aff,
+		0x52080000, 0x00404aff, 0x5a080000, 0x00614aff,
+		0x62080000, 0x00814aff, 0x6a080000, 0x00a14aff,
+		0x73080000, 0x00c24aff, 0x7b080000, 0x00e24aff,
+		0x83080000, 0x000052ff, 0x8b080000, 0x002052ff,
+		0x94080000, 0x004052ff, 0x9c080000, 0x006152ff,
+		0xa4080000, 0x008152ff, 0xac080000, 0x00a152ff,
+		0xb4080000, 0x00c252ff, 0xbd080000, 0x00e252ff,
+		0xc5080000, 0x00005aff, 0xcd080000, 0x00205aff,
+		0xd5080000, 0x00405aff, 0xde080000, 0x00615aff,
+		0xe6080000, 0x00815aff, 0xee080000, 0x00a15aff,
+		0xf6080000, 0x00c25aff, 0xff080000, 0x00e25aff,
+		0x000c0000, 0x000062ff, 0x080c0000, 0x002062ff,
+		0x100c0000, 0x004062ff, 0x180c0000, 0x006162ff,
+		0x200c0000, 0x008162ff, 0x290c0000, 0x00a162ff,
+		0x310c0000, 0x00c262ff, 0x390c0000, 0x00e262ff,
+		0x410c0000, 0x00006aff, 0x4a0c0000, 0x00206aff,
+		0x520c0000, 0x00406aff, 0x5a0c0000, 0x00616aff,
+		0x620c0000, 0x00816aff, 0x6a0c0000, 0x00a16aff,
+		0x730c0000, 0x00c26aff, 0x7b0c0000, 0x00e26aff,
+		0x830c0000, 0x000073ff, 0x8b0c0000, 0x002073ff,
+		0x940c0000, 0x004073ff, 0x9c0c0000, 0x006173ff,
+		0xa40c0000, 0x008173ff, 0xac0c0000, 0x00a173ff,
+		0xb40c0000, 0x00c273ff, 0xbd0c0000, 0x00e273ff,
+		0xc50c0000, 0x00007bff, 0xcd0c0000, 0x00207bff,
+		0xd50c0000, 0x00407bff, 0xde0c0000, 0x00617bff,
+		0xe60c0000, 0x00817bff, 0xee0c0000, 0x00a17bff,
+		0xf60c0000, 0x00c27bff, 0xff0c0000, 0x00e27bff,
+		0x00100000, 0x000083ff, 0x08100000, 0x002083ff,
+		0x10100000, 0x004083ff, 0x18100000, 0x006183ff,
+		0x20100000, 0x008183ff, 0x29100000, 0x00a183ff,
+		0x31100000, 0x00c283ff, 0x39100000, 0x00e283ff,
+		0x41100000, 0x00008bff, 0x4a100000, 0x00208bff,
+		0x52100000, 0x00408bff, 0x5a100000, 0x00618bff,
+		0x62100000, 0x00818bff, 0x6a100000, 0x00a18bff,
+		0x73100000, 0x00c28bff, 0x7b100000, 0x00e28bff,
+		0x83100000, 0x000094ff, 0x8b100000, 0x002094ff,
+		0x94100000, 0x004094ff, 0x9c100000, 0x006194ff,
+		0xa4100000, 0x008194ff, 0xac100000, 0x00a194ff,
+		0xb4100000, 0x00c294ff, 0xbd100000, 0x00e294ff,
+		0xc5100000, 0x00009cff, 0xcd100000, 0x00209cff,
+		0xd5100000, 0x00409cff, 0xde100000, 0x00619cff,
+		0xe6100000, 0x00819cff, 0xee100000, 0x00a19cff,
+		0xf6100000, 0x00c29cff, 0xff100000, 0x00e29cff,
+		0x00140000, 0x0000a4ff, 0x08140000, 0x0020a4ff,
+		0x10140000, 0x0040a4ff, 0x18140000, 0x0061a4ff,
+		0x20140000, 0x0081a4ff, 0x29140000, 0x00a1a4ff,
+		0x31140000, 0x00c2a4ff, 0x39140000, 0x00e2a4ff,
+		0x41140000, 0x0000acff, 0x4a140000, 0x0020acff,
+		0x52140000, 0x0040acff, 0x5a140000, 0x0061acff,
+		0x62140000, 0x0081acff, 0x6a140000, 0x00a1acff,
+		0x73140000, 0x00c2acff, 0x7b140000, 0x00e2acff,
+		0x83140000, 0x0000b4ff, 0x8b140000, 0x0020b4ff,
+		0x94140000, 0x0040b4ff, 0x9c140000, 0x0061b4ff,
+		0xa4140000, 0x0081b4ff, 0xac140000, 0x00a1b4ff,
+		0xb4140000, 0x00c2b4ff, 0xbd140000, 0x00e2b4ff,
+		0xc5140000, 0x0000bdff, 0xcd140000, 0x0020bdff,
+		0xd5140000, 0x0040bdff, 0xde140000, 0x0061bdff,
+		0xe6140000, 0x0081bdff, 0xee140000, 0x00a1bdff,
+		0xf6140000, 0x00c2bdff, 0xff140000, 0x00e2bdff,
+		0x00180000, 0x0000c5ff, 0x08180000, 0x0020c5ff,
+		0x10180000, 0x0040c5ff, 0x18180000, 0x0061c5ff,
+		0x20180000, 0x0081c5ff, 0x29180000, 0x00a1c5ff,
+		0x31180000, 0x00c2c5ff, 0x39180000, 0x00e2c5ff,
+		0x41180000, 0x0000cdff, 0x4a180000, 0x0020cdff,
+		0x52180000, 0x0040cdff, 0x5a180000, 0x0061cdff,
+		0x62180000, 0x0081cdff, 0x6a180000, 0x00a1cdff,
+		0x73180000, 0x00c2cdff, 0x7b180000, 0x00e2cdff,
+		0x83180000, 0x0000d5ff, 0x8b180000, 0x0020d5ff,
+		0x94180000, 0x0040d5ff, 0x9c180000, 0x0061d5ff,
+		0xa4180000, 0x0081d5ff, 0xac180000, 0x00a1d5ff,
+		0xb4180000, 0x00c2d5ff, 0xbd180000, 0x00e2d5ff,
+		0xc5180000, 0x0000deff, 0xcd180000, 0x0020deff,
+		0xd5180000, 0x0040deff, 0xde180000, 0x0061deff,
+		0xe6180000, 0x0081deff, 0xee180000, 0x00a1deff,
+		0xf6180000, 0x00c2deff, 0xff180000, 0x00e2deff,
+		0x001c0000, 0x0000e6ff, 0x081c0000, 0x0020e6ff,
+		0x101c0000, 0x0040e6ff, 0x181c0000, 0x0061e6ff,
+		0x201c0000, 0x0081e6ff, 0x291c0000, 0x00a1e6ff,
+		0x311c0000, 0x00c2e6ff, 0x391c0000, 0x00e2e6ff,
+		0x411c0000, 0x0000eeff, 0x4a1c0000, 0x0020eeff,
+		0x521c0000, 0x0040eeff, 0x5a1c0000, 0x0061eeff,
+		0x621c0000, 0x0081eeff, 0x6a1c0000, 0x00a1eeff,
+		0x731c0000, 0x00c2eeff, 0x7b1c0000, 0x00e2eeff,
+		0x831c0000, 0x0000f6ff, 0x8b1c0000, 0x0020f6ff,
+		0x941c0000, 0x0040f6ff, 0x9c1c0000, 0x0061f6ff,
+		0xa41c0000, 0x0081f6ff, 0xac1c0000, 0x00a1f6ff,
+		0xb41c0000, 0x00c2f6ff, 0xbd1c0000, 0x00e2f6ff,
+		0xc51c0000, 0x0000ffff, 0xcd1c0000, 0x0020ffff,
+		0xd51c0000, 0x0040ffff, 0xde1c0000, 0x0061ffff,
+		0xe61c0000, 0x0081ffff, 0xee1c0000, 0x00a1ffff,
+		0xf61c0000, 0x00c2ffff, 0xff1c0000, 0x00e2ffff
+};
+static void Blit_RGB565_BGRA8888(SDL_BlitInfo *info)
+{
+    Blit_RGB565_32(info, RGB565_BGRA8888_LUT);
+}
+
+/* Special optimized blit for RGB 8-8-8 --> RGB 3-3-2 */
+#ifndef RGB888_RGB332
+#define RGB888_RGB332(dst, src) { \
+	dst = (((src)&0x00E00000)>>16)| \
+	      (((src)&0x0000E000)>>11)| \
+	      (((src)&0x000000C0)>>6); \
+}
+#endif
+static void Blit_RGB888_index8_map(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int pixel;
+	int width, height;
+	Uint32 *src;
+	Uint8 *map, *dst;
+	int srcskip, dstskip;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = (Uint32 *)info->s_pixels;
+	srcskip = info->s_skip/4;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+
+#ifdef USE_DUFFS_LOOP
+	while ( height-- ) {
+		DUFFS_LOOP(
+			RGB888_RGB332(pixel, *src);
+			*dst++ = map[pixel];
+			++src;
+		, width);
+		src += srcskip;
+		dst += dstskip;
+	}
+#else
+	while ( height-- ) {
+		for ( c=width/4; c; --c ) {
+			/* Pack RGB into 8bit pixel */
+			RGB888_RGB332(pixel, *src);
+			*dst++ = map[pixel];
+			++src;
+			RGB888_RGB332(pixel, *src);
+			*dst++ = map[pixel];
+			++src;
+			RGB888_RGB332(pixel, *src);
+			*dst++ = map[pixel];
+			++src;
+			RGB888_RGB332(pixel, *src);
+			*dst++ = map[pixel];
+			++src;
+		}
+		switch ( width % 4 ) {
+			case 3:
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+			case 2:
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+			case 1:
+				RGB888_RGB332(pixel, *src);
+				*dst++ = map[pixel];
+				++src;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+#endif /* USE_DUFFS_LOOP */
+}
+static void BlitNto1(SDL_BlitInfo *info)
+{
+#ifndef USE_DUFFS_LOOP
+	int c;
+#endif
+	int width, height;
+	Uint8 *src, *map, *dst;
+	int srcskip, dstskip;
+	int srcbpp;
+	Uint32 pixel;
+	int  sR, sG, sB;
+	SDL_PixelFormat *srcfmt;
+
+	/* Set up some basic variables */
+	width = info->d_width;
+	height = info->d_height;
+	src = info->s_pixels;
+	srcskip = info->s_skip;
+	dst = info->d_pixels;
+	dstskip = info->d_skip;
+	map = info->table;
+	srcfmt = info->src;
+	srcbpp = srcfmt->BytesPerPixel;
+
+	if ( map == NULL ) {
+		while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+			DUFFS_LOOP(
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( 1 ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = ((sR>>5)<<(3+2))|
+					        ((sG>>5)<<(2)) |
+					        ((sB>>6)<<(0)) ;
+				}
+				dst++;
+				src += srcbpp;
+			, width);
+#else
+			for ( c=width; c; --c ) {
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( 1 ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = ((sR>>5)<<(3+2))|
+					        ((sG>>5)<<(2)) |
+					        ((sB>>6)<<(0)) ;
+				}
+				dst++;
+				src += srcbpp;
+			}
+#endif
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		while ( height-- ) {
+#ifdef USE_DUFFS_LOOP
+			DUFFS_LOOP(
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( 1 ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = map[((sR>>5)<<(3+2))|
+						   ((sG>>5)<<(2))  |
+						   ((sB>>6)<<(0))  ];
+				}
+				dst++;
+				src += srcbpp;
+			, width);
+#else
+			for ( c=width; c; --c ) {
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( 1 ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = map[((sR>>5)<<(3+2))|
+						   ((sG>>5)<<(2))  |
+						   ((sB>>6)<<(0))  ];
+				}
+				dst++;
+				src += srcbpp;
+			}
+#endif /* USE_DUFFS_LOOP */
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+static void BlitNtoN(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	int srcbpp = srcfmt->BytesPerPixel;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int dstbpp = dstfmt->BytesPerPixel;
+	unsigned alpha = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+		        Uint32 pixel;
+			unsigned sR;
+			unsigned sG;
+			unsigned sB;
+			DISEMBLE_RGB(src, srcbpp, srcfmt, pixel, sR, sG, sB);
+			ASSEMBLE_RGBA(dst, dstbpp, dstfmt, sR, sG, sB, alpha);
+			dst += dstbpp;
+			src += srcbpp;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitNtoNCopyAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	int srcbpp = srcfmt->BytesPerPixel;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int dstbpp = dstfmt->BytesPerPixel;
+	int c;
+
+	/* FIXME: should map alpha to [0..255] correctly! */
+	while ( height-- ) {
+		for ( c=width; c; --c ) {
+		        Uint32 pixel;
+			unsigned sR, sG, sB, sA;
+			DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel,
+				      sR, sG, sB, sA);
+			ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
+				      sR, sG, sB, sA);
+			dst += dstbpp;
+			src += srcbpp;
+		}
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitNto1Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	SDL_PixelFormat *srcfmt = info->src;
+	Uint8 *palmap = info->table;
+	Uint32 ckey = srcfmt->colorkey;
+	Uint32 rgbmask = ~srcfmt->Amask;
+	int srcbpp;
+	Uint32 pixel;
+	Uint8  sR, sG, sB;
+
+	/* Set up some basic variables */
+	srcbpp = srcfmt->BytesPerPixel;
+	ckey &= rgbmask;
+
+	if ( palmap == NULL ) {
+		while ( height-- ) {
+			DUFFS_LOOP(
+			{
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( (pixel & rgbmask) != ckey ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = ((sR>>5)<<(3+2))|
+						((sG>>5)<<(2)) |
+						((sB>>6)<<(0)) ;
+				}
+				dst++;
+				src += srcbpp;
+			},
+			width);
+			src += srcskip;
+			dst += dstskip;
+		}
+	} else {
+		while ( height-- ) {
+			DUFFS_LOOP(
+			{
+				DISEMBLE_RGB(src, srcbpp, srcfmt, pixel,
+								sR, sG, sB);
+				if ( (pixel & rgbmask) != ckey ) {
+				  	/* Pack RGB into 8bit pixel */
+				  	*dst = palmap[((sR>>5)<<(3+2))|
+							((sG>>5)<<(2))  |
+							((sB>>6)<<(0))  ];
+				}
+				dst++;
+				src += srcbpp;
+			},
+			width);
+			src += srcskip;
+			dst += dstskip;
+		}
+	}
+}
+
+static void Blit2to2Key(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint16 *srcp = (Uint16 *)info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint16 *dstp = (Uint16 *)info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	Uint32 rgbmask = ~info->src->Amask;
+
+	/* Set up some basic variables */
+        srcskip /= 2;
+        dstskip /= 2;
+	ckey &= rgbmask;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			if ( (*srcp & rgbmask) != ckey ) {
+				*dstp = *srcp;
+			}
+			dstp++;
+			srcp++;
+		},
+		width);
+		srcp += srcskip;
+		dstp += dstskip;
+	}
+}
+
+static void BlitNtoNKey(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	int srcbpp = srcfmt->BytesPerPixel;
+	int dstbpp = dstfmt->BytesPerPixel;
+	unsigned alpha = dstfmt->Amask ? SDL_ALPHA_OPAQUE : 0;
+
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+		        Uint32 pixel;
+			unsigned sR;
+			unsigned sG;
+			unsigned sB;
+			RETRIEVE_RGB_PIXEL(src, srcbpp, pixel);
+			if ( pixel != ckey ) {
+			        RGB_FROM_PIXEL(pixel, srcfmt, sR, sG, sB);
+				ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
+					      sR, sG, sB, alpha);
+			}
+			dst += dstbpp;
+			src += srcbpp;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info)
+{
+	int width = info->d_width;
+	int height = info->d_height;
+	Uint8 *src = info->s_pixels;
+	int srcskip = info->s_skip;
+	Uint8 *dst = info->d_pixels;
+	int dstskip = info->d_skip;
+	Uint32 ckey = info->src->colorkey;
+	SDL_PixelFormat *srcfmt = info->src;
+	SDL_PixelFormat *dstfmt = info->dst;
+	Uint32 rgbmask = ~srcfmt->Amask;
+
+	Uint8 srcbpp;
+	Uint8 dstbpp;
+	Uint32 pixel;
+	Uint8  sR, sG, sB, sA;
+
+	/* Set up some basic variables */
+	srcbpp = srcfmt->BytesPerPixel;
+	dstbpp = dstfmt->BytesPerPixel;
+	ckey &= rgbmask;
+
+	/* FIXME: should map alpha to [0..255] correctly! */
+	while ( height-- ) {
+		DUFFS_LOOP(
+		{
+			DISEMBLE_RGBA(src, srcbpp, srcfmt, pixel,
+				      sR, sG, sB, sA);
+			if ( (pixel & rgbmask) != ckey ) {
+				  ASSEMBLE_RGBA(dst, dstbpp, dstfmt,
+						sR, sG, sB, sA);
+			}
+			dst += dstbpp;
+			src += srcbpp;
+		},
+		width);
+		src += srcskip;
+		dst += dstskip;
+	}
+}
+
+/* Normal N to N optimized blitters */
+struct blit_table {
+	Uint32 srcR, srcG, srcB;
+	int dstbpp;
+	Uint32 dstR, dstG, dstB;
+	Uint32 cpu_flags;
+	void *aux_data;
+	SDL_loblit blitfunc;
+        enum { NO_ALPHA, SET_ALPHA, COPY_ALPHA } alpha;
+};
+static struct blit_table normal_blit_1[] = {
+	/* Default for 8-bit RGB source, an invalid combination */
+	{ 0,0,0, 0, 0,0,0, 0, NULL, NULL },
+};
+static struct blit_table normal_blit_2[] = {
+#ifdef USE_ASMBLIT
+    { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000007E0,0x0000F800,
+      0, ConvertX86p16_16BGR565, ConvertX86, NO_ALPHA },
+    { 0x0000F800,0x000007E0,0x0000001F, 2, 0x00007C00,0x000003E0,0x0000001F,
+      0, ConvertX86p16_16RGB555, ConvertX86, NO_ALPHA },
+    { 0x0000F800,0x000007E0,0x0000001F, 2, 0x0000001F,0x000003E0,0x00007C00,
+      0, ConvertX86p16_16BGR555, ConvertX86, NO_ALPHA },
+#endif
+    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x00FF0000,0x0000FF00,0x000000FF,
+      0, NULL, Blit_RGB565_ARGB8888, SET_ALPHA },
+    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x000000FF,0x0000FF00,0x00FF0000,
+      0, NULL, Blit_RGB565_ABGR8888, SET_ALPHA },
+    { 0x0000F800,0x000007E0,0x0000001F, 4, 0xFF000000,0x00FF0000,0x0000FF00,
+      0, NULL, Blit_RGB565_RGBA8888, SET_ALPHA },
+    { 0x0000F800,0x000007E0,0x0000001F, 4, 0x0000FF00,0x00FF0000,0xFF000000,
+      0, NULL, Blit_RGB565_BGRA8888, SET_ALPHA },
+
+    /* Default for 16-bit RGB source, used if no other blitter matches */
+    { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
+};
+static struct blit_table normal_blit_3[] = {
+	/* Default for 24-bit RGB source, never optimized */
+    { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
+};
+static struct blit_table normal_blit_4[] = {
+#ifdef USE_ASMBLIT
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
+      MMX_CPU, ConvertMMXpII32_16RGB565, ConvertMMX, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
+      0, ConvertX86p32_16RGB565, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
+      MMX_CPU, ConvertMMXpII32_16BGR565, ConvertMMX, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000007E0,0x0000F800,
+      0, ConvertX86p32_16BGR565, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
+      MMX_CPU, ConvertMMXpII32_16RGB555, ConvertMMX, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
+      0, ConvertX86p32_16RGB555, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
+      MMX_CPU, ConvertMMXpII32_16BGR555, ConvertMMX, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000001F,0x000003E0,0x00007C00,
+      0, ConvertX86p32_16BGR555, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x00FF0000,0x0000FF00,0x000000FF,
+      0, ConvertX86p32_24RGB888, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x000000FF,0x0000FF00,0x00FF0000,
+      0, ConvertX86p32_24BGR888, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0x000000FF,0x0000FF00,0x00FF0000,
+      0, ConvertX86p32_32BGR888, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0xFF000000,0x00FF0000,0x0000FF00,
+      0, ConvertX86p32_32RGBA888, ConvertX86, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0x0000FF00,0x00FF0000,0xFF000000,
+      0, ConvertX86p32_32BGRA888, ConvertX86, NO_ALPHA },
+#else
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F,
+      0, NULL, Blit_RGB888_RGB565, NO_ALPHA },
+    { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x00007C00,0x000003E0,0x0000001F,
+      0, NULL, Blit_RGB888_RGB555, NO_ALPHA },
+#endif
+	/* Default for 32-bit RGB source, used if no other blitter matches */
+	{ 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 }
+};
+static struct blit_table *normal_blit[] = {
+	normal_blit_1, normal_blit_2, normal_blit_3, normal_blit_4
+};
+
+SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index)
+{
+	struct private_swaccel *sdata;
+	SDL_PixelFormat *srcfmt;
+	SDL_PixelFormat *dstfmt;
+	struct blit_table *table;
+	int which;
+	SDL_loblit blitfun;
+
+	/* Set up data for choosing the blit */
+	sdata = surface->map->sw_data;
+	srcfmt = surface->format;
+	dstfmt = surface->map->dst->format;
+
+	if ( blit_index & 2 ) {
+	        /* alpha or alpha+colorkey */
+	        return SDL_CalculateAlphaBlit(surface, blit_index);
+	}
+
+	/* We don't support destinations less than 8-bits */
+	if ( dstfmt->BitsPerPixel < 8 ) {
+		return(NULL);
+	}
+	
+	if(blit_index == 1) {
+	    /* colorkey blit: Here we don't have too many options, mostly
+	       because RLE is the preferred fast way to deal with this.
+	       If a particular case turns out to be useful we'll add it. */
+
+	    if(srcfmt->BytesPerPixel == 2
+	       && surface->map->identity)
+		return Blit2to2Key;
+	    else if(dstfmt->BytesPerPixel == 1)
+		return BlitNto1Key;
+	    else {
+		if(srcfmt->Amask && dstfmt->Amask)
+		    return BlitNtoNKeyCopyAlpha;
+		else
+		    return BlitNtoNKey;
+	    }
+	}
+
+	blitfun = NULL;
+	if ( dstfmt->BitsPerPixel == 8 ) {
+		/* We assume 8-bit destinations are palettized */
+		if ( (srcfmt->BytesPerPixel == 4) &&
+		     (srcfmt->Rmask == 0x00FF0000) &&
+		     (srcfmt->Gmask == 0x0000FF00) &&
+		     (srcfmt->Bmask == 0x000000FF) ) {
+			if ( surface->map->table ) {
+				blitfun = Blit_RGB888_index8_map;
+			} else {
+#ifdef USE_ASMBLIT
+				sdata->aux_data = ConvertX86p32_8RGB332;
+				blitfun = ConvertX86;
+#else
+				blitfun = Blit_RGB888_index8;
+#endif
+			}
+		} else {
+			blitfun = BlitNto1;
+		}
+	} else {
+		/* Now the meat, choose the blitter we want */
+	        int a_need = 0;
+		if(dstfmt->Amask)
+		    a_need = srcfmt->Amask ? COPY_ALPHA : SET_ALPHA;
+		table = normal_blit[srcfmt->BytesPerPixel-1];
+		for ( which=0; table[which].srcR; ++which ) {
+			if ( srcfmt->Rmask == table[which].srcR &&
+			     srcfmt->Gmask == table[which].srcG &&
+			     srcfmt->Bmask == table[which].srcB &&
+			     dstfmt->BytesPerPixel == table[which].dstbpp &&
+			     dstfmt->Rmask == table[which].dstR &&
+			     dstfmt->Gmask == table[which].dstG &&
+			     dstfmt->Bmask == table[which].dstB &&
+			     (a_need & table[which].alpha) == a_need &&
+			     (CPU_Flags()&table[which].cpu_flags) ==
+			     table[which].cpu_flags )
+				break;
+		}
+		sdata->aux_data = table[which].aux_data;
+		blitfun = table[which].blitfunc;
+		if(a_need == COPY_ALPHA && blitfun == BlitNtoN)
+		    blitfun = BlitNtoNCopyAlpha;
+	}
+
+#ifdef DEBUG_ASM
+#ifdef USE_ASMBLIT
+	if ( blitfun == ConvertMMX )
+		fprintf(stderr, "Using mmx blit\n");
+	else
+	if ( blitfun == ConvertX86 )
+		fprintf(stderr, "Using asm blit\n");
+	else
+#endif
+	if ( (blitfun == SDL_BlitNtoN) || (blitfun == SDL_BlitNto1) )
+		fprintf(stderr, "Using C blit\n");
+	else
+		fprintf(stderr, "Using optimized C blit\n");
+#endif /* DEBUG_ASM */
+
+	return(blitfun);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_bmp.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,527 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef DISABLE_FILE
+
+/* 
+   Code to load and save surfaces in Windows BMP format.
+
+   Why support BMP format?  Well, it's a native format for Windows, and
+   most image processing programs can read and write it.  It would be nice
+   to be able to have at least one image format that we can natively load
+   and save, and since PNG is so complex that it would bloat the library,
+   BMP is a good alternative. 
+
+   This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.
+*/
+
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_endian.h"
+
+/* Compression encodings for BMP files */
+#ifndef BI_RGB
+#define BI_RGB		0
+#define BI_RLE8		1
+#define BI_RLE4		2
+#define BI_BITFIELDS	3
+#endif
+
+
+SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
+{
+	int was_error;
+	long fp_offset;
+	int bmpPitch;
+	int i, pad;
+	SDL_Surface *surface;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	SDL_Palette *palette;
+	Uint8 *bits;
+	int ExpandBMP;
+
+	/* The Win32 BMP file header (14 bytes) */
+	char   magic[2];
+	Uint32 bfSize;
+	Uint16 bfReserved1;
+	Uint16 bfReserved2;
+	Uint32 bfOffBits;
+
+	/* The Win32 BITMAPINFOHEADER struct (40 bytes) */
+	Uint32 biSize;
+	Sint32 biWidth;
+	Sint32 biHeight;
+	Uint16 biPlanes;
+	Uint16 biBitCount;
+	Uint32 biCompression;
+	Uint32 biSizeImage;
+	Sint32 biXPelsPerMeter;
+	Sint32 biYPelsPerMeter;
+	Uint32 biClrUsed;
+	Uint32 biClrImportant;
+
+	/* Make sure we are passed a valid data source */
+	surface = NULL;
+	was_error = 0;
+	if ( src == NULL ) {
+		was_error = 1;
+		goto done;
+	}
+
+	/* Read in the BMP file header */
+	fp_offset = SDL_RWtell(src);
+	SDL_ClearError();
+	if ( SDL_RWread(src, magic, 1, 2) != 2 ) {
+		SDL_Error(SDL_EFREAD);
+		was_error = 1;
+		goto done;
+	}
+	if ( strncmp(magic, "BM", 2) != 0 ) {
+		SDL_SetError("File is not a Windows BMP file");
+		was_error = 1;
+		goto done;
+	}
+	bfSize		= SDL_ReadLE32(src);
+	bfReserved1	= SDL_ReadLE16(src);
+	bfReserved2	= SDL_ReadLE16(src);
+	bfOffBits	= SDL_ReadLE32(src);
+
+	/* Read the Win32 BITMAPINFOHEADER */
+	biSize		= SDL_ReadLE32(src);
+	if ( biSize == 12 ) {
+		biWidth		= (Uint32)SDL_ReadLE16(src);
+		biHeight	= (Uint32)SDL_ReadLE16(src);
+		biPlanes	= SDL_ReadLE16(src);
+		biBitCount	= SDL_ReadLE16(src);
+		biCompression	= BI_RGB;
+		biSizeImage	= 0;
+		biXPelsPerMeter	= 0;
+		biYPelsPerMeter	= 0;
+		biClrUsed	= 0;
+		biClrImportant	= 0;
+	} else {
+		biWidth		= SDL_ReadLE32(src);
+		biHeight	= SDL_ReadLE32(src);
+		biPlanes	= SDL_ReadLE16(src);
+		biBitCount	= SDL_ReadLE16(src);
+		biCompression	= SDL_ReadLE32(src);
+		biSizeImage	= SDL_ReadLE32(src);
+		biXPelsPerMeter	= SDL_ReadLE32(src);
+		biYPelsPerMeter	= SDL_ReadLE32(src);
+		biClrUsed	= SDL_ReadLE32(src);
+		biClrImportant	= SDL_ReadLE32(src);
+	}
+
+	/* Check for read error */
+	if ( strcmp(SDL_GetError(), "") != 0 ) {
+		was_error = 1;
+		goto done;
+	}
+
+	/* Expand 1 and 4 bit bitmaps to 8 bits per pixel */
+	switch (biBitCount) {
+		case 1:
+		case 4:
+			ExpandBMP = biBitCount;
+			biBitCount = 8;
+			break;
+		default:
+			ExpandBMP = 0;
+			break;
+	}
+
+	/* We don't support any BMP compression right now */
+	Rmask = Gmask = Bmask = 0;
+	switch (biCompression) {
+		case BI_RGB:
+			/* If there are no masks, use the defaults */
+			if ( bfOffBits == (14+biSize) ) {
+				/* Default values for the BMP format */
+				switch (biBitCount) {
+					case 15:
+					case 16:
+						Rmask = 0x7C00;
+						Gmask = 0x03E0;
+						Bmask = 0x001F;
+						break;
+					case 24:
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+					        Rmask = 0x000000FF;
+					        Gmask = 0x0000FF00;
+					        Bmask = 0x00FF0000;
+						break;
+#endif
+					case 32:
+						Rmask = 0x00FF0000;
+						Gmask = 0x0000FF00;
+						Bmask = 0x000000FF;
+						break;
+					default:
+						break;
+				}
+				break;
+			}
+			/* Fall through -- read the RGB masks */
+
+		case BI_BITFIELDS:
+			switch (biBitCount) {
+				case 15:
+				case 16:
+				case 32:
+					Rmask = SDL_ReadLE32(src);
+					Gmask = SDL_ReadLE32(src);
+					Bmask = SDL_ReadLE32(src);
+					break;
+				default:
+					break;
+			}
+			break;
+		default:
+			SDL_SetError("Compressed BMP files not supported");
+			was_error = 1;
+			goto done;
+	}
+
+	/* Create a compatible surface, note that the colors are RGB ordered */
+	surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+			biWidth, biHeight, biBitCount, Rmask, Gmask, Bmask, 0);
+	if ( surface == NULL ) {
+		was_error = 1;
+		goto done;
+	}
+
+	/* Load the palette, if any */
+	palette = (surface->format)->palette;
+	if ( palette ) {
+		if ( biClrUsed == 0 ) {
+			biClrUsed = 1 << biBitCount;
+		}
+		if ( biSize == 12 ) {
+			for ( i = 0; i < (int)biClrUsed; ++i ) {
+				SDL_RWread(src, &palette->colors[i].b, 1, 1);
+				SDL_RWread(src, &palette->colors[i].g, 1, 1);
+				SDL_RWread(src, &palette->colors[i].r, 1, 1);
+				palette->colors[i].unused = 0;
+			}	
+		} else {
+			for ( i = 0; i < (int)biClrUsed; ++i ) {
+				SDL_RWread(src, &palette->colors[i].b, 1, 1);
+				SDL_RWread(src, &palette->colors[i].g, 1, 1);
+				SDL_RWread(src, &palette->colors[i].r, 1, 1);
+				SDL_RWread(src, &palette->colors[i].unused, 1, 1);
+			}	
+		}
+		palette->ncolors = biClrUsed;
+	}
+
+	/* Read the surface pixels.  Note that the bmp image is upside down */
+	if ( SDL_RWseek(src, fp_offset+bfOffBits, SEEK_SET) < 0 ) {
+		SDL_Error(SDL_EFSEEK);
+		was_error = 1;
+		goto done;
+	}
+	bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
+	switch (ExpandBMP) {
+		case 1:
+			bmpPitch = (biWidth + 7) >> 3;
+			pad  = (((bmpPitch)%4) ? (4-((bmpPitch)%4)) : 0);
+			break;
+		case 4:
+			bmpPitch = (biWidth + 1) >> 1;
+			pad  = (((bmpPitch)%4) ? (4-((bmpPitch)%4)) : 0);
+			break;
+		default:
+			pad  = ((surface->pitch%4) ?
+					(4-(surface->pitch%4)) : 0);
+			break;
+	}
+	while ( bits > (Uint8 *)surface->pixels ) {
+		bits -= surface->pitch;
+		switch (ExpandBMP) {
+			case 1:
+			case 4: {
+			Uint8 pixel = 0;
+			int   shift = (8-ExpandBMP);
+			for ( i=0; i<surface->w; ++i ) {
+				if ( i%(8/ExpandBMP) == 0 ) {
+					if ( !SDL_RWread(src, &pixel, 1, 1) ) {
+						SDL_SetError(
+					"Error reading from BMP");
+						was_error = 1;
+						goto done;
+					}
+				}
+				*(bits+i) = (pixel>>shift);
+				pixel <<= ExpandBMP;
+			} }
+			break;
+
+			default:
+			if ( SDL_RWread(src, bits, 1, surface->pitch)
+							 != surface->pitch ) {
+				SDL_Error(SDL_EFREAD);
+				was_error = 1;
+				goto done;
+			}
+#if SDL_BYTEORDER == SDL_BIG_ENDIAN
+			/* Byte-swap the pixels if needed. Note that the 24bpp
+			   case has already been taken care of above. */
+			switch(biBitCount) {
+				case 15:
+				case 16: {
+				        Uint16 *pix = (Uint16 *)bits;
+					for(i = 0; i < surface->w; i++)
+					        pix[i] = SDL_Swap16(pix[i]);
+					break;
+				}
+
+				case 32: {
+				        Uint32 *pix = (Uint32 *)bits;
+					for(i = 0; i < surface->w; i++)
+					        pix[i] = SDL_Swap32(pix[i]);
+					break;
+				}
+			}
+#endif
+			break;
+		}
+		/* Skip padding bytes, ugh */
+		if ( pad ) {
+			Uint8 padbyte;
+			for ( i=0; i<pad; ++i ) {
+				SDL_RWread(src, &padbyte, 1, 1);
+			}
+		}
+	}
+done:
+	if ( was_error ) {
+		if ( surface ) {
+			SDL_FreeSurface(surface);
+		}
+		surface = NULL;
+	}
+	if ( freesrc && src ) {
+		SDL_RWclose(src);
+	}
+	return(surface);
+}
+
+int SDL_SaveBMP_RW (SDL_Surface *saveme, SDL_RWops *dst, int freedst)
+{
+	long fp_offset;
+	int i, pad;
+	SDL_Surface *surface;
+	Uint8 *bits;
+
+	/* The Win32 BMP file header (14 bytes) */
+	char   magic[2] = { 'B', 'M' };
+	Uint32 bfSize;
+	Uint16 bfReserved1;
+	Uint16 bfReserved2;
+	Uint32 bfOffBits;
+
+	/* The Win32 BITMAPINFOHEADER struct (40 bytes) */
+	Uint32 biSize;
+	Sint32 biWidth;
+	Sint32 biHeight;
+	Uint16 biPlanes;
+	Uint16 biBitCount;
+	Uint32 biCompression;
+	Uint32 biSizeImage;
+	Sint32 biXPelsPerMeter;
+	Sint32 biYPelsPerMeter;
+	Uint32 biClrUsed;
+	Uint32 biClrImportant;
+
+	/* Make sure we have somewhere to save */
+	surface = NULL;
+	if ( dst ) {
+		if ( saveme->format->palette ) {
+			if ( saveme->format->BitsPerPixel == 8 ) {
+				surface = saveme;
+			} else {
+				SDL_SetError("%d bpp BMP files not supported",
+						saveme->format->BitsPerPixel);
+			}
+		}
+		else if ( (saveme->format->BitsPerPixel == 24) &&
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+				(saveme->format->Rmask == 0x00FF0000) &&
+				(saveme->format->Gmask == 0x0000FF00) &&
+				(saveme->format->Bmask == 0x000000FF)
+#else
+				(saveme->format->Rmask == 0x000000FF) &&
+				(saveme->format->Gmask == 0x0000FF00) &&
+				(saveme->format->Bmask == 0x00FF0000)
+#endif
+			  ) {
+			surface = saveme;
+		} else {
+			SDL_Rect bounds;
+
+			/* Convert to 24 bits per pixel */
+			surface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+					saveme->w, saveme->h, 24,
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+					0x00FF0000, 0x0000FF00, 0x000000FF,
+#else
+					0x000000FF, 0x0000FF00, 0x00FF0000,
+#endif
+					0);
+			if ( surface != NULL ) {
+				bounds.x = 0;
+				bounds.y = 0;
+				bounds.w = saveme->w;
+				bounds.h = saveme->h;
+				if ( SDL_LowerBlit(saveme, &bounds, surface,
+							&bounds) < 0 ) {
+					SDL_FreeSurface(surface);
+					SDL_SetError(
+					"Couldn't convert image to 24 bpp");
+					surface = NULL;
+				}
+			}
+		}
+	}
+
+	if ( surface && (SDL_LockSurface(surface) == 0) ) {
+		/* Set the BMP file header values */
+		bfSize = 0;		 /* We'll write this when we're done */
+		bfReserved1 = 0;
+		bfReserved2 = 0;
+		bfOffBits = 0;		/* We'll write this when we're done */
+
+		/* Write the BMP file header values */
+		fp_offset = SDL_RWtell(dst);
+		SDL_ClearError();
+		SDL_RWwrite(dst, magic, 2, 1);
+		SDL_WriteLE32(dst, bfSize);
+		SDL_WriteLE16(dst, bfReserved1);
+		SDL_WriteLE16(dst, bfReserved2);
+		SDL_WriteLE32(dst, bfOffBits);
+
+		/* Set the BMP info values */
+		biSize = 40;
+		biWidth = surface->w;
+		biHeight = surface->h;
+		biPlanes = 1;
+		biBitCount = surface->format->BitsPerPixel;
+		biCompression = BI_RGB;
+		biSizeImage = surface->h*surface->pitch;
+		biXPelsPerMeter = 0;
+		biYPelsPerMeter = 0;
+		if ( surface->format->palette ) {
+			biClrUsed = surface->format->palette->ncolors;
+		} else {
+			biClrUsed = 0;
+		}
+		biClrImportant = 0;
+
+		/* Write the BMP info values */
+		SDL_WriteLE32(dst, biSize);
+		SDL_WriteLE32(dst, biWidth);
+		SDL_WriteLE32(dst, biHeight);
+		SDL_WriteLE16(dst, biPlanes);
+		SDL_WriteLE16(dst, biBitCount);
+		SDL_WriteLE32(dst, biCompression);
+		SDL_WriteLE32(dst, biSizeImage);
+		SDL_WriteLE32(dst, biXPelsPerMeter);
+		SDL_WriteLE32(dst, biYPelsPerMeter);
+		SDL_WriteLE32(dst, biClrUsed);
+		SDL_WriteLE32(dst, biClrImportant);
+
+		/* Write the palette (in BGR color order) */
+		if ( surface->format->palette ) {
+			SDL_Color *colors;
+			int       ncolors;
+
+			colors = surface->format->palette->colors;
+			ncolors = surface->format->palette->ncolors;
+			for ( i=0; i<ncolors; ++i ) {
+				SDL_RWwrite(dst, &colors[i].b, 1, 1);
+				SDL_RWwrite(dst, &colors[i].g, 1, 1);
+				SDL_RWwrite(dst, &colors[i].r, 1, 1);
+				SDL_RWwrite(dst, &colors[i].unused, 1, 1);
+			}
+		}
+
+		/* Write the bitmap offset */
+		bfOffBits = SDL_RWtell(dst)-fp_offset;
+		if ( SDL_RWseek(dst, fp_offset+10, SEEK_SET) < 0 ) {
+			SDL_Error(SDL_EFSEEK);
+		}
+		SDL_WriteLE32(dst, bfOffBits);
+		if ( SDL_RWseek(dst, fp_offset+bfOffBits, SEEK_SET) < 0 ) {
+			SDL_Error(SDL_EFSEEK);
+		}
+
+		/* Write the bitmap image upside down */
+		bits = (Uint8 *)surface->pixels+(surface->h*surface->pitch);
+		pad  = ((surface->pitch%4) ? (4-(surface->pitch%4)) : 0);
+		while ( bits > (Uint8 *)surface->pixels ) {
+			bits -= surface->pitch;
+			if ( SDL_RWwrite(dst, bits, 1, surface->pitch)
+							!= surface->pitch) {
+				SDL_Error(SDL_EFWRITE);
+				break;
+			}
+			if ( pad ) {
+				const Uint8 padbyte = 0;
+				for ( i=0; i<pad; ++i ) {
+					SDL_RWwrite(dst, &padbyte, 1, 1);
+				}
+			}
+		}
+
+		/* Write the BMP file size */
+		bfSize = SDL_RWtell(dst)-fp_offset;
+		if ( SDL_RWseek(dst, fp_offset+2, SEEK_SET) < 0 ) {
+			SDL_Error(SDL_EFSEEK);
+		}
+		SDL_WriteLE32(dst, bfSize);
+		if ( SDL_RWseek(dst, fp_offset+bfSize, SEEK_SET) < 0 ) {
+			SDL_Error(SDL_EFSEEK);
+		}
+
+		/* Close it up.. */
+		SDL_UnlockSurface(surface);
+		if ( surface != saveme ) {
+			SDL_FreeSurface(surface);
+		}
+	}
+
+	if ( freedst && dst ) {
+		SDL_RWclose(dst);
+	}
+	return((strcmp(SDL_GetError(), "") == 0) ? 0 : -1);
+}
+
+#endif /* ENABLE_FILE */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_cursor.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,743 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General cursor handling code for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_mutex.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_blit.h"
+#include "SDL_events_c.h"
+#include "SDL_sysvideo.h"
+#include "SDL_sysevents.h"
+#include "SDL_cursor_c.h"
+#include "SDL_pixels_c.h"
+#include "default_cursor.h"
+
+/* These are static for our cursor handling code */
+volatile int SDL_cursorstate = CURSOR_VISIBLE;
+SDL_Cursor *SDL_cursor = NULL;
+static SDL_Cursor *SDL_defcursor = NULL;
+SDL_mutex *SDL_cursorlock = NULL;
+
+/* Public functions */
+void SDL_CursorQuit(void)
+{
+	if ( SDL_cursor != NULL ) {
+		SDL_Cursor *cursor;
+
+		SDL_cursorstate &= ~CURSOR_VISIBLE;
+		if ( SDL_cursor != SDL_defcursor ) {
+			SDL_FreeCursor(SDL_cursor);
+		}
+		SDL_cursor = NULL;
+		if ( SDL_defcursor != NULL ) {
+			cursor = SDL_defcursor;
+			SDL_defcursor = NULL;
+			SDL_FreeCursor(cursor);
+		}
+	}
+	if ( SDL_cursorlock != NULL ) {
+		SDL_DestroyMutex(SDL_cursorlock);
+		SDL_cursorlock = NULL;
+	}
+}
+int SDL_CursorInit(Uint32 multithreaded)
+{
+	/* We don't have mouse focus, and the cursor isn't drawn yet */
+	SDL_cursorstate = CURSOR_VISIBLE;
+
+	/* Create the default cursor */
+	if ( SDL_defcursor == NULL ) {
+		SDL_defcursor = SDL_CreateCursor(default_cdata, default_cmask,
+					DEFAULT_CWIDTH, DEFAULT_CHEIGHT,
+						DEFAULT_CHOTX, DEFAULT_CHOTY);
+		SDL_SetCursor(SDL_defcursor);
+	}
+
+	/* Create a lock if necessary */
+	if ( multithreaded ) {
+		SDL_cursorlock = SDL_CreateMutex();
+	}
+
+	/* That's it! */
+	return(0);
+}
+
+/* Multi-thread support for cursors */
+#ifndef SDL_LockCursor
+void SDL_LockCursor(void)
+{
+	if ( SDL_cursorlock ) {
+		SDL_mutexP(SDL_cursorlock);
+	}
+}
+#endif
+#ifndef SDL_UnlockCursor
+void SDL_UnlockCursor(void)
+{
+	if ( SDL_cursorlock ) {
+		SDL_mutexV(SDL_cursorlock);
+	}
+}
+#endif
+
+/* Software cursor drawing support */
+SDL_Cursor * SDL_CreateCursor (Uint8 *data, Uint8 *mask, 
+					int w, int h, int hot_x, int hot_y)
+{
+	SDL_VideoDevice *video = current_video;
+	int savelen;
+	int i;
+	SDL_Cursor *cursor;
+
+	/* Make sure the width is a multiple of 8 */
+	w = ((w+7)&~7);
+
+	/* Sanity check the hot spot */
+	if ( (hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h) ) {
+		SDL_SetError("Cursor hot spot doesn't lie within cursor");
+		return(NULL);
+	}
+
+	/* Allocate memory for the cursor */
+	cursor = (SDL_Cursor *)malloc(sizeof *cursor);
+	if ( cursor == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	savelen = (w*4)*h;
+	cursor->area.x = 0;
+	cursor->area.y = 0;
+	cursor->area.w = w;
+	cursor->area.h = h;
+	cursor->hot_x = hot_x;
+	cursor->hot_y = hot_y;
+	cursor->data = (Uint8 *)malloc((w/8)*h*2);
+	cursor->mask = cursor->data+((w/8)*h);
+	cursor->save[0] = (Uint8 *)malloc(savelen*2);
+	cursor->save[1] = cursor->save[0] + savelen;
+	cursor->wm_cursor = NULL;
+	if ( ! cursor->data || ! cursor->save[0] ) {
+		SDL_FreeCursor(cursor);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	for ( i=((w/8)*h)-1; i>=0; --i ) {
+		cursor->data[i] = data[i];
+		cursor->mask[i] = mask[i] | data[i];
+	}
+	memset(cursor->save[0], 0, savelen*2);
+
+	/* If the window manager gives us a good cursor, we're done! */
+	if ( video->CreateWMCursor ) {
+		cursor->wm_cursor = video->CreateWMCursor(video, data, mask,
+							w, h, hot_x, hot_y);
+	} else {
+		cursor->wm_cursor = NULL;
+	}
+	return(cursor);
+}
+
+/* SDL_SetCursor(NULL) can be used to force the cursor redraw,
+   if this is desired for any reason.  This is used when setting
+   the video mode and when the SDL window gains the mouse focus.
+ */
+void SDL_SetCursor (SDL_Cursor *cursor)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	/* Make sure that the video subsystem has been initialized */
+	if ( ! video ) {
+		return;
+	}
+
+	/* Prevent the event thread from moving the mouse */
+	SDL_LockCursor();
+
+	/* Set the new cursor */
+	if ( cursor && (cursor != SDL_cursor) ) {
+		/* Erase the current mouse position */
+		if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
+			SDL_EraseCursor(SDL_VideoSurface);
+		} else if ( video->MoveWMCursor ) {
+			/* If the video driver is moving the cursor directly,
+			   it needs to hide the old cursor before (possibly)
+			   showing the new one.  (But don't erase NULL cursor)
+			 */
+			if ( SDL_cursor ) {
+				video->ShowWMCursor(this, NULL);
+			}
+		}
+		SDL_cursor = cursor;
+	}
+
+	/* Draw the new mouse cursor */
+	if ( SDL_cursor && (SDL_cursorstate&CURSOR_VISIBLE) ) {
+		/* Use window manager cursor if possible */
+		if ( SDL_cursor->wm_cursor && 
+	             video->ShowWMCursor(this, SDL_cursor->wm_cursor) )
+			SDL_cursorstate &= ~CURSOR_USINGSW;
+		else {
+			SDL_cursorstate |= CURSOR_USINGSW;
+			if ( video->ShowWMCursor ) {
+				video->ShowWMCursor(this, NULL);
+			}
+			{ int x, y;
+				SDL_GetMouseState(&x, &y);
+				SDL_cursor->area.x = (x - SDL_cursor->hot_x);
+				SDL_cursor->area.y = (y - SDL_cursor->hot_y);
+			}
+			SDL_DrawCursor(SDL_VideoSurface);
+		}
+	} else {
+		/* Erase window manager mouse (cursor not visible) */
+		if ( SDL_cursor && (SDL_cursorstate & CURSOR_USINGSW) ) {
+			SDL_EraseCursor(SDL_VideoSurface);
+		} else {
+			if ( video ) {
+				video->ShowWMCursor(this, NULL);
+			}
+		}
+	}
+	SDL_UnlockCursor();
+}
+
+SDL_Cursor * SDL_GetCursor (void)
+{
+	return(SDL_cursor);
+}
+
+void SDL_FreeCursor (SDL_Cursor *cursor)
+{
+	if ( cursor ) {
+		if ( cursor == SDL_cursor ) {
+			SDL_SetCursor(SDL_defcursor);
+		}
+		if ( cursor != SDL_defcursor ) {
+			if ( cursor->data ) {
+				free(cursor->data);
+			}
+			if ( cursor->save[0] ) {
+				free(cursor->save[0]);
+			}
+			if ( cursor->wm_cursor ) {
+				SDL_VideoDevice *video = current_video;
+				SDL_VideoDevice *this  = current_video;
+				video->FreeWMCursor(this, cursor->wm_cursor);
+			}
+			free(cursor);
+		}
+	}
+}
+
+int SDL_ShowCursor (int toggle)
+{
+	int showing;
+
+	showing = (SDL_cursorstate & CURSOR_VISIBLE);
+	if ( toggle >= 0 ) {
+		SDL_LockCursor();
+		if ( toggle ) {
+			SDL_cursorstate |= CURSOR_VISIBLE;
+		} else {
+			SDL_cursorstate &= ~CURSOR_VISIBLE;
+		}
+		SDL_UnlockCursor();
+		if ( (SDL_cursorstate & CURSOR_VISIBLE) != showing ) {
+			SDL_VideoDevice *video = current_video;
+			SDL_VideoDevice *this  = current_video;
+
+			SDL_SetCursor(NULL);
+			if ( video && video->CheckMouseMode ) {
+				video->CheckMouseMode(this);
+			}
+		}
+	} else {
+		/* Query current state */ ;
+	}
+	return(showing ? 1 : 0);
+}
+
+void SDL_WarpMouse (Uint16 x, Uint16 y)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	/* This generates a mouse motion event */
+	if ( video->WarpWMCursor ) {
+		video->WarpWMCursor(this, x, y);
+	} else {
+		x += (this->screen->offset % this->screen->pitch) /
+		      this->screen->format->BytesPerPixel;
+		y += (this->screen->offset / this->screen->pitch);
+		SDL_PrivateMouseMotion(0, 0, x, y);
+	}
+}
+
+void SDL_MoveCursor(int x, int y)
+{
+	SDL_VideoDevice *video = current_video;
+
+	/* Erase and update the current mouse position */
+	if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
+		/* Erase and redraw mouse cursor in new position */
+		SDL_LockCursor();
+		SDL_EraseCursor(SDL_VideoSurface);
+		SDL_cursor->area.x = (x - SDL_cursor->hot_x);
+		SDL_cursor->area.y = (y - SDL_cursor->hot_y);
+		SDL_DrawCursor(SDL_VideoSurface);
+		SDL_UnlockCursor();
+	} else if ( video->MoveWMCursor ) {
+		video->MoveWMCursor(video, x, y);
+	}
+}
+
+/* Keep track of the current cursor colors */
+static int palette_changed = 1;
+static Uint32 pixels8[2];
+
+void SDL_CursorPaletteChanged(void)
+{
+	palette_changed = 1;
+}
+
+void SDL_MouseRect(SDL_Rect *area)
+{
+	int clip_diff;
+
+	*area = SDL_cursor->area;
+	if ( area->x < 0 ) {
+		area->w += area->x;
+		area->x = 0;
+	}
+	if ( area->y < 0 ) {
+		area->h += area->y;
+		area->y = 0;
+	}
+	clip_diff = (area->x+area->w)-SDL_VideoSurface->w;
+	if ( clip_diff > 0 ) {
+		area->w -= clip_diff;
+	}
+	clip_diff = (area->y+area->h)-SDL_VideoSurface->h;
+	if ( clip_diff > 0 ) {
+		area->h -= clip_diff;
+	}
+}
+
+static void SDL_DrawCursorFast(SDL_Surface *screen, SDL_Rect *area)
+{
+	const Uint32 pixels[2] = { 0xFFFFFFFF, 0x00000000 };
+	int i, w, h;
+	Uint8 *data, datab;
+	Uint8 *mask, maskb;
+
+	data = SDL_cursor->data + area->y * SDL_cursor->area.w/8;
+	mask = SDL_cursor->mask + area->y * SDL_cursor->area.w/8;
+	switch (screen->format->BytesPerPixel) {
+
+	    case 1: {
+		Uint8 *dst;
+		int dstskip;
+
+		if ( palette_changed ) {
+			pixels8[0] = SDL_MapRGB(screen->format, 255, 255, 255);
+			pixels8[1] = SDL_MapRGB(screen->format, 0, 0, 0);
+			palette_changed = 0;
+		}
+		dst = (Uint8 *)screen->pixels +
+                       (SDL_cursor->area.y+area->y)*screen->pitch +
+                       SDL_cursor->area.x;
+		dstskip = screen->pitch-area->w;
+
+		for ( h=area->h; h; h-- ) {
+			for ( w=area->w/8; w; w-- ) {
+				maskb = *mask++;
+				datab = *data++;
+				for ( i=0; i<8; ++i ) {
+					if ( maskb & 0x80 ) {
+						*dst = pixels8[datab>>7];
+					}
+					maskb <<= 1;
+					datab <<= 1;
+					dst++;
+				}
+			}
+			dst += dstskip;
+		}
+	    }
+	    break;
+
+	    case 2: {
+		Uint16 *dst;
+		int dstskip;
+
+		dst = (Uint16 *)screen->pixels +
+                       (SDL_cursor->area.y+area->y)*screen->pitch/2 +
+                       SDL_cursor->area.x;
+		dstskip = (screen->pitch/2)-area->w;
+
+		for ( h=area->h; h; h-- ) {
+			for ( w=area->w/8; w; w-- ) {
+				maskb = *mask++;
+				datab = *data++;
+				for ( i=0; i<8; ++i ) {
+					if ( maskb & 0x80 ) {
+						*dst = pixels[datab>>7];
+					}
+					maskb <<= 1;
+					datab <<= 1;
+					dst++;
+				}
+			}
+			dst += dstskip;
+		}
+	    }
+	    break;
+
+	    case 3: {
+		Uint8 *dst;
+		int dstskip;
+
+		dst = (Uint8 *)screen->pixels +
+                       (SDL_cursor->area.y+area->y)*screen->pitch +
+                       SDL_cursor->area.x*3;
+		dstskip = screen->pitch-area->w*3;
+
+		for ( h=area->h; h; h-- ) {
+			for ( w=area->w/8; w; w-- ) {
+				maskb = *mask++;
+				datab = *data++;
+				for ( i=0; i<8; ++i ) {
+					if ( maskb & 0x80 ) {
+						memset(dst,pixels[datab>>7],3);
+					}
+					maskb <<= 1;
+					datab <<= 1;
+					dst += 3;
+				}
+			}
+			dst += dstskip;
+		}
+	    }
+	    break;
+
+	    case 4: {
+		Uint32 *dst;
+		int dstskip;
+
+		dst = (Uint32 *)screen->pixels +
+                       (SDL_cursor->area.y+area->y)*screen->pitch/4 +
+                       SDL_cursor->area.x;
+		dstskip = (screen->pitch/4)-area->w;
+
+		for ( h=area->h; h; h-- ) {
+			for ( w=area->w/8; w; w-- ) {
+				maskb = *mask++;
+				datab = *data++;
+				for ( i=0; i<8; ++i ) {
+					if ( maskb & 0x80 ) {
+						*dst = pixels[datab>>7];
+					}
+					maskb <<= 1;
+					datab <<= 1;
+					dst++;
+				}
+			}
+			dst += dstskip;
+		}
+	    }
+	    break;
+	}
+}
+
+static void SDL_DrawCursorSlow(SDL_Surface *screen, SDL_Rect *area)
+{
+	const Uint32 pixels[2] = { 0xFFFFFF, 0x000000 };
+	int h;
+	int x, minx, maxx;
+	Uint8 *data, datab = 0;
+	Uint8 *mask, maskb = 0;
+	Uint8 *dst;
+	int dstbpp, dstskip;
+
+	data = SDL_cursor->data + area->y * SDL_cursor->area.w/8;
+	mask = SDL_cursor->mask + area->y * SDL_cursor->area.w/8;
+	dstbpp = screen->format->BytesPerPixel;
+	dst = (Uint8 *)screen->pixels +
+                       (SDL_cursor->area.y+area->y)*screen->pitch +
+                       SDL_cursor->area.x*dstbpp;
+	dstskip = screen->pitch-SDL_cursor->area.w*dstbpp;
+
+	minx = area->x;
+	maxx = area->x+area->w;
+	if ( screen->format->BytesPerPixel == 1 ) {
+		if ( palette_changed ) {
+			pixels8[0] = SDL_MapRGB(screen->format, 255, 255, 255);
+			pixels8[1] = SDL_MapRGB(screen->format, 0, 0, 0);
+			palette_changed = 0;
+		}
+		for ( h=area->h; h; h-- ) {
+			for ( x=0; x<SDL_cursor->area.w; ++x ) {
+				if ( (x%8) == 0 ) {
+					maskb = *mask++;
+					datab = *data++;
+				}
+				if ( (x >= minx) && (x < maxx) ) {
+					if ( maskb & 0x80 ) {
+						memset(dst, pixels8[datab>>7], dstbpp);
+					}
+				}
+				maskb <<= 1;
+				datab <<= 1;
+				dst += dstbpp;
+			}
+			dst += dstskip;
+		}
+	} else {
+		for ( h=area->h; h; h-- ) {
+			for ( x=0; x<SDL_cursor->area.w; ++x ) {
+				if ( (x%8) == 0 ) {
+					maskb = *mask++;
+					datab = *data++;
+				}
+				if ( (x >= minx) && (x < maxx) ) {
+					if ( maskb & 0x80 ) {
+						memset(dst, pixels[datab>>7], dstbpp);
+					}
+				}
+				maskb <<= 1;
+				datab <<= 1;
+				dst += dstbpp;
+			}
+			dst += dstskip;
+		}
+	}
+}
+
+/* This handles the ugly work of converting the saved cursor background from
+   the pixel format of the shadow surface to that of the video surface.
+   This is only necessary when blitting from a shadow surface of a different
+   pixel format than the video surface, and using a software rendered cursor.
+*/
+static void SDL_ConvertCursorSave(SDL_Surface *screen, int w, int h)
+{
+	SDL_BlitInfo info;
+	SDL_loblit RunBlit;
+
+	/* Make sure we can steal the blit mapping */
+	if ( screen->map->dst != SDL_VideoSurface ) {
+		return;
+	}
+
+	/* Set up the blit information */
+	info.s_pixels = SDL_cursor->save[1];
+	info.s_width = w;
+	info.s_height = h;
+	info.s_skip = 0;
+	info.d_pixels = SDL_cursor->save[0];
+	info.d_width = w;
+	info.d_height = h;
+	info.d_skip = 0;
+	info.aux_data = screen->map->sw_data->aux_data;
+	info.src = screen->format;
+	info.table = screen->map->table;
+	info.dst = SDL_VideoSurface->format;
+	RunBlit = screen->map->sw_data->blit;
+
+	/* Run the actual software blit */
+	RunBlit(&info);
+}
+
+void SDL_DrawCursorNoLock(SDL_Surface *screen)
+{
+	SDL_Rect area;
+
+	/* Get the mouse rectangle, clipped to the screen */
+	SDL_MouseRect(&area);
+	if ( (area.w == 0) || (area.h == 0) ) {
+		return;
+	}
+
+	/* Copy mouse background */
+	{ int w, h, screenbpp;
+	  Uint8 *src, *dst;
+
+	  /* Set up the copy pointers */
+	  screenbpp = screen->format->BytesPerPixel;
+	  if ( (screen == SDL_VideoSurface) ||
+	          FORMAT_EQUAL(screen->format, SDL_VideoSurface->format) ) {
+		dst = SDL_cursor->save[0];
+	  } else {
+		dst = SDL_cursor->save[1];
+	  }
+	  src = (Uint8 *)screen->pixels + area.y * screen->pitch +
+                                          area.x * screenbpp;
+
+	  /* Perform the copy */
+	  w = area.w*screenbpp;
+	  h = area.h;
+	  while ( h-- ) {
+		  memcpy(dst, src, w);
+		  dst += w;
+		  src += screen->pitch;
+	  }
+	}
+
+	/* Draw the mouse cursor */
+	area.x -= SDL_cursor->area.x;
+	area.y -= SDL_cursor->area.y;
+	if ( (area.x == 0) && (area.w == SDL_cursor->area.w) ) {
+		SDL_DrawCursorFast(screen, &area);
+	} else {
+		SDL_DrawCursorSlow(screen, &area);
+	}
+}
+
+void SDL_DrawCursor(SDL_Surface *screen)
+{
+	/* Lock the screen if necessary */
+	if ( screen == NULL ) {
+		return;
+	}
+	if ( SDL_MUSTLOCK(screen) ) {
+		if ( SDL_LockSurface(screen) < 0 ) {
+			return;
+		}
+	}
+
+	SDL_DrawCursorNoLock(screen);
+
+	/* Unlock the screen and update if necessary */
+	if ( SDL_MUSTLOCK(screen) ) {
+		SDL_UnlockSurface(screen);
+	}
+	if ( (screen == SDL_VideoSurface) &&
+	     ((screen->flags & SDL_HWSURFACE) != SDL_HWSURFACE) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		SDL_Rect area;
+
+		SDL_MouseRect(&area);
+
+		/* This can be called before a video mode is set */
+		if ( video->UpdateRects ) {
+			video->UpdateRects(this, 1, &area);
+		}
+	}
+}
+
+void SDL_EraseCursorNoLock(SDL_Surface *screen)
+{
+	SDL_Rect area;
+
+	/* Get the mouse rectangle, clipped to the screen */
+	SDL_MouseRect(&area);
+	if ( (area.w == 0) || (area.h == 0) ) {
+		return;
+	}
+
+	/* Copy mouse background */
+	{ int w, h, screenbpp;
+	  Uint8 *src, *dst;
+
+	  /* Set up the copy pointers */
+	  screenbpp = screen->format->BytesPerPixel;
+	  if ( (screen == SDL_VideoSurface) ||
+	          FORMAT_EQUAL(screen->format, SDL_VideoSurface->format) ) {
+		src = SDL_cursor->save[0];
+	  } else {
+		src = SDL_cursor->save[1];
+	  }
+	  dst = (Uint8 *)screen->pixels + area.y * screen->pitch +
+                                          area.x * screenbpp;
+
+	  /* Perform the copy */
+	  w = area.w*screenbpp;
+	  h = area.h;
+	  while ( h-- ) {
+		  memcpy(dst, src, w);
+		  src += w;
+		  dst += screen->pitch;
+	  }
+
+	  /* Perform pixel conversion on cursor background */
+	  if ( src > SDL_cursor->save[1] ) {
+		SDL_ConvertCursorSave(screen, area.w, area.h);
+	  }
+	}
+}
+
+void SDL_EraseCursor(SDL_Surface *screen)
+{
+	/* Lock the screen if necessary */
+	if ( screen == NULL ) {
+		return;
+	}
+	if ( SDL_MUSTLOCK(screen) ) {
+		if ( SDL_LockSurface(screen) < 0 ) {
+			return;
+		}
+	}
+
+	SDL_EraseCursorNoLock(screen);
+
+	/* Unlock the screen and update if necessary */
+	if ( SDL_MUSTLOCK(screen) ) {
+		SDL_UnlockSurface(screen);
+	}
+	if ( (screen == SDL_VideoSurface) &&
+	     ((screen->flags & SDL_HWSURFACE) != SDL_HWSURFACE) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		SDL_Rect area;
+
+		SDL_MouseRect(&area);
+		video->UpdateRects(this, 1, &area);
+	}
+}
+
+/* Reset the cursor on video mode change
+   FIXME:  Keep track of all cursors, and reset them all.
+ */
+void SDL_ResetCursor(void)
+{
+	int savelen;
+
+	if ( SDL_cursor ) {
+		savelen = SDL_cursor->area.w*4*SDL_cursor->area.h;
+		SDL_cursor->area.x = 0;
+		SDL_cursor->area.y = 0;
+		memset(SDL_cursor->save[0], 0, savelen);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_cursor_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,77 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful variables and functions from SDL_cursor.c */
+#include "SDL_mouse.h"
+
+extern int  SDL_CursorInit(Uint32 flags);
+extern void SDL_CursorPaletteChanged(void);
+extern void SDL_DrawCursor(SDL_Surface *screen);
+extern void SDL_DrawCursorNoLock(SDL_Surface *screen);
+extern void SDL_EraseCursor(SDL_Surface *screen);
+extern void SDL_EraseCursorNoLock(SDL_Surface *screen);
+extern void SDL_UpdateCursor(SDL_Surface *screen);
+extern void SDL_ResetCursor(void);
+extern void SDL_MoveCursor(int x, int y);
+extern void SDL_CursorQuit(void);
+
+#define INLINE_MOUSELOCK
+#ifdef INLINE_MOUSELOCK
+/* Inline (macro) versions of the mouse lock functions */
+#include "SDL_mutex.h"
+
+extern SDL_mutex *SDL_cursorlock;
+
+#define SDL_LockCursor()						\
+	do {								\
+		if ( SDL_cursorlock ) {					\
+			SDL_mutexP(SDL_cursorlock);			\
+		}							\
+	} while ( 0 )
+#define SDL_UnlockCursor()						\
+	do {								\
+		if ( SDL_cursorlock ) {					\
+			SDL_mutexV(SDL_cursorlock);			\
+		}							\
+	} while ( 0 )
+#else
+extern void SDL_LockCursor(void);
+extern void SDL_UnlockCursor(void);
+#endif /* INLINE_MOUSELOCK */
+
+/* Only for low-level mouse cursor drawing */
+extern SDL_Cursor *SDL_cursor;
+extern void SDL_MouseRect(SDL_Rect *area);
+
+/* State definitions for the SDL cursor */
+#define CURSOR_VISIBLE	0x01
+#define CURSOR_USINGSW	0x10
+#define SHOULD_DRAWCURSOR(X) 						\
+			(((X)&(CURSOR_VISIBLE|CURSOR_USINGSW)) ==  	\
+					(CURSOR_VISIBLE|CURSOR_USINGSW))
+
+extern volatile int SDL_cursorstate;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_gamma.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,242 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Gamma correction support */
+
+#define USE_MATH_H	/* Used for calculating gamma ramps */
+
+#ifdef USE_MATH_H
+#include <math.h>
+#endif
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_sysvideo.h"
+
+#ifdef USE_MATH_H
+static void CalculateGammaRamp(float gamma, Uint16 *ramp)
+{
+	int i;
+
+	/* 0.0 gamma is all black */
+	if ( gamma <= 0.0 ) {
+		for ( i=0; i<256; ++i ) {
+			ramp[i] = 0;
+		}
+		return;
+	} else
+	/* 1.0 gamma is identity */
+	if ( gamma == 1.0 ) {
+		for ( i=0; i<256; ++i ) {
+			ramp[i] = (i << 8) | i;
+		}
+		return;
+	} else
+	/* Calculate a real gamma ramp */
+	{ int value;
+		gamma = 1.0f / gamma;
+		for ( i=0; i<256; ++i ) {
+			value = (int)(pow((double)i/256.0, gamma)*65535.0+0.5);
+			if ( value > 65535 ) {
+				value = 65535;
+			}
+			ramp[i] = (Uint16)value;
+		}
+	}
+}
+static void CalculateGammaFromRamp(float *gamma, Uint16 *ramp)
+{
+	/* The following is adapted from a post by Garrett Bass on OpenGL
+	   Gamedev list, March 4, 2000.
+	 */
+	float sum = 0.0;
+	int i, count = 0;
+
+	*gamma = 1.0;
+	for ( i = 1; i < 256; ++i ) {
+	    if ( (ramp[i] != 0) && (ramp[i] != 65535) ) {
+	        double B = (double)i / 256.0;
+	        double A = ramp[i] / 65535.0;
+	        sum += (float) ( log(A) / log(B) );
+	        count++;
+	    }
+	}
+	if ( count && sum ) {
+		*gamma = 1.0f / (sum / count);
+	}
+}
+#endif /* USE_MATH_H */
+
+int SDL_SetGamma(float red, float green, float blue)
+{
+	int succeeded;
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;	
+
+	succeeded = -1;
+#ifdef USE_MATH_H
+	/* Prefer using SetGammaRamp(), as it's more flexible */
+	{
+		Uint16 ramp[3][256];
+
+		CalculateGammaRamp(red, ramp[0]);
+		CalculateGammaRamp(green, ramp[1]);
+		CalculateGammaRamp(blue, ramp[2]);
+		succeeded = SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]);
+	}
+#else
+	SDL_SetError("Gamma correction not supported");
+#endif
+	if ( (succeeded < 0) && video->SetGamma ) {
+		SDL_ClearError();
+		succeeded = video->SetGamma(this, red, green, blue);
+	}
+	return succeeded;
+}
+
+/* Calculating the gamma by integrating the gamma ramps isn't exact,
+   so this function isn't officially supported.
+*/
+int SDL_GetGamma(float *red, float *green, float *blue)
+{
+	int succeeded;
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;	
+
+	succeeded = -1;
+#ifdef USE_MATH_H
+	/* Prefer using GetGammaRamp(), as it's more flexible */
+	{
+		Uint16 ramp[3][256];
+
+		succeeded = SDL_GetGammaRamp(ramp[0], ramp[1], ramp[2]);
+		if ( succeeded >= 0 ) {
+			CalculateGammaFromRamp(red, ramp[0]);
+			CalculateGammaFromRamp(green, ramp[1]);
+			CalculateGammaFromRamp(blue, ramp[2]);
+		}
+	}
+#else
+	SDL_SetError("Gamma correction not supported");
+#endif
+	if ( (succeeded < 0) && video->GetGamma ) {
+		SDL_ClearError();
+		succeeded = video->GetGamma(this, red, green, blue);
+	}
+	return succeeded;
+}
+
+int SDL_SetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
+{
+	int succeeded;
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;	
+	SDL_Surface *screen = SDL_PublicSurface;
+
+	/* Verify the screen parameter */
+	if ( !screen ) {
+		SDL_SetError("No video mode has been set");
+		return -1;
+	}
+
+	/* Lazily allocate the gamma tables */
+	if ( ! video->gamma ) {
+		SDL_GetGammaRamp(0, 0, 0);
+	}
+
+	/* Fill the gamma table with the new values */
+	if ( red ) {
+		memcpy(&video->gamma[0*256], red, 256*sizeof(*video->gamma));
+	}
+	if ( green ) {
+		memcpy(&video->gamma[1*256], green, 256*sizeof(*video->gamma));
+	}
+	if ( blue ) {
+		memcpy(&video->gamma[2*256], blue, 256*sizeof(*video->gamma));
+	}
+
+	/* Gamma correction always possible on split palettes */
+	if ( (screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) {
+		SDL_Palette *pal = screen->format->palette;
+
+		/* If physical palette has been set independently, use it */
+		if(video->physpal)
+		        pal = video->physpal;
+		      
+		SDL_SetPalette(screen, SDL_PHYSPAL,
+			       pal->colors, 0, pal->ncolors);
+		return 0;
+	}
+
+	/* Try to set the gamma ramp in the driver */
+	succeeded = -1;
+	if ( video->SetGammaRamp ) {
+		succeeded = video->SetGammaRamp(this, video->gamma);
+	} else {
+		SDL_SetError("Gamma ramp manipulation not supported");
+	}
+	return succeeded;
+}
+
+int SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16 *blue)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;	
+
+	/* Lazily allocate the gamma table */
+	if ( ! video->gamma ) {
+		video->gamma = malloc(3*256*sizeof(*video->gamma));
+		if ( ! video->gamma ) {
+			SDL_OutOfMemory();
+			return -1;
+		}
+		if ( video->GetGammaRamp ) {
+			/* Get the real hardware gamma */
+			video->GetGammaRamp(this, video->gamma);
+		} else {
+			/* Assume an identity gamma */
+			int i;
+			for ( i=0; i<256; ++i ) {
+				video->gamma[0*256+i] = (i << 8) | i;
+				video->gamma[1*256+i] = (i << 8) | i;
+				video->gamma[2*256+i] = (i << 8) | i;
+			}
+		}
+	}
+
+	/* Just copy from our internal table */
+	if ( red ) {
+		memcpy(red, &video->gamma[0*256], 256*sizeof(*red));
+	}
+	if ( green ) {
+		memcpy(green, &video->gamma[1*256], 256*sizeof(*green));
+	}
+	if ( blue ) {
+		memcpy(blue, &video->gamma[2*256], 256*sizeof(*blue));
+	}
+	return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_glfuncs.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,341 @@
+/* list of OpenGL functions sorted alphabetically
+   If you need to use a GL function from the SDL video subsystem,
+   change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild.
+*/
+#define SDL_PROC_UNUSED(ret,func,params)
+SDL_PROC_UNUSED(void,glAccum,(GLenum,GLfloat))
+SDL_PROC_UNUSED(void,glAlphaFunc,(GLenum,GLclampf))
+SDL_PROC_UNUSED(GLboolean,glAreTexturesResident,(GLsizei,const GLuint*,GLboolean*))
+SDL_PROC_UNUSED(void,glArrayElement,(GLint))
+SDL_PROC(void,glBegin,(GLenum))
+SDL_PROC(void,glBindTexture,(GLenum,GLuint))
+SDL_PROC_UNUSED(void,glBitmap,(GLsizei,GLsizei,GLfloat,GLfloat,GLfloat,GLfloat,const GLubyte*))
+SDL_PROC(void,glBlendFunc,(GLenum,GLenum))
+SDL_PROC_UNUSED(void,glCallList,(GLuint))
+SDL_PROC_UNUSED(void,glCallLists,(GLsizei,GLenum,const GLvoid*))
+SDL_PROC_UNUSED(void,glClear,(GLbitfield))
+SDL_PROC_UNUSED(void,glClearAccum,(GLfloat,GLfloat,GLfloat,GLfloat))
+SDL_PROC_UNUSED(void,glClearColor,(GLclampf,GLclampf,GLclampf,GLclampf))
+SDL_PROC_UNUSED(void,glClearDepth,(GLclampd))
+SDL_PROC_UNUSED(void,glClearIndex,(GLfloat))
+SDL_PROC_UNUSED(void,glClearStencil,(GLint))
+SDL_PROC_UNUSED(void,glClipPlane,(GLenum,const GLdouble*))
+SDL_PROC_UNUSED(void,glColor3b,(GLbyte,GLbyte,GLbyte))
+SDL_PROC_UNUSED(void,glColor3bv,(const GLbyte*))
+SDL_PROC_UNUSED(void,glColor3d,(GLdouble,GLdouble,GLdouble))
+SDL_PROC_UNUSED(void,glColor3dv,(const GLdouble*))
+SDL_PROC_UNUSED(void,glColor3f,(GLfloat,GLfloat,GLfloat))
+SDL_PROC_UNUSED(void,glColor3fv,(const GLfloat*))
+SDL_PROC_UNUSED(void,glColor3i,(GLint,GLint,GLint))
+SDL_PROC_UNUSED(void,glColor3iv,(const GLint*))
+SDL_PROC_UNUSED(void,glColor3s,(GLshort,GLshort,GLshort))
+SDL_PROC_UNUSED(void,glColor3sv,(const GLshort*))
+SDL_PROC_UNUSED(void,glColor3ub,(GLubyte,GLubyte,GLubyte))
+SDL_PROC_UNUSED(void,glColor3ubv,(const GLubyte*))
+SDL_PROC_UNUSED(void,glColor3ui,(GLuint,GLuint,GLuint))
+SDL_PROC_UNUSED(void,glColor3uiv,(const GLuint*))
+SDL_PROC_UNUSED(void,glColor3us,(GLushort,GLushort,GLushort))
+SDL_PROC_UNUSED(void,glColor3usv,(const GLushort*))
+SDL_PROC_UNUSED(void,glColor4b,(GLbyte,GLbyte,GLbyte,GLbyte))
+SDL_PROC_UNUSED(void,glColor4bv,(const GLbyte*))
+SDL_PROC_UNUSED(void,glColor4d,(GLdouble,GLdouble,GLdouble,GLdouble))
+SDL_PROC_UNUSED(void,glColor4dv,(const GLdouble*))
+SDL_PROC(void,glColor4f,(GLfloat,GLfloat,GLfloat,GLfloat))
+SDL_PROC_UNUSED(void,glColor4fv,(const GLfloat*))
+SDL_PROC_UNUSED(void,glColor4i,(GLint,GLint,GLint,GLint))
+SDL_PROC_UNUSED(void,glColor4iv,(const GLint*))
+SDL_PROC_UNUSED(void,glColor4s,(GLshort,GLshort,GLshort,GLshort))
+SDL_PROC_UNUSED(void,glColor4sv,(const GLshort*))
+SDL_PROC_UNUSED(void,glColor4ub,(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
+SDL_PROC_UNUSED(void,glColor4ubv,(const GLubyte *v))
+SDL_PROC_UNUSED(void,glColor4ui,(GLuint red, GLuint green, GLuint blue, GLuint alpha))
+SDL_PROC_UNUSED(void,glColor4uiv,(const GLuint *v))
+SDL_PROC_UNUSED(void,glColor4us,(GLushort red, GLushort green, GLushort blue, GLushort alpha))
+SDL_PROC_UNUSED(void,glColor4usv,(const GLushort *v))
+SDL_PROC_UNUSED(void,glColorMask,(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha))
+SDL_PROC_UNUSED(void,glColorMaterial,(GLenum face, GLenum mode))
+SDL_PROC_UNUSED(void,glColorPointer,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))
+SDL_PROC_UNUSED(void,glCopyPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum type))
+SDL_PROC(void,glCopyTexImage1D,(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLint border))
+SDL_PROC_UNUSED(void,glCopyTexImage2D,(GLenum target, GLint level, GLenum internalFormat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border))
+SDL_PROC_UNUSED(void,glCopyTexSubImage1D,(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width))
+SDL_PROC_UNUSED(void,glCopyTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height))
+SDL_PROC_UNUSED(void,glCullFace,(GLenum mode))
+SDL_PROC_UNUSED(void,glDeleteLists,(GLuint list, GLsizei range))
+SDL_PROC_UNUSED(void,glDeleteTextures,(GLsizei n, const GLuint *textures))
+SDL_PROC_UNUSED(void,glDepthFunc,(GLenum func))
+SDL_PROC_UNUSED(void,glDepthMask,(GLboolean flag))
+SDL_PROC_UNUSED(void,glDepthRange,(GLclampd zNear, GLclampd zFar))
+SDL_PROC(void,glDisable,(GLenum cap))
+SDL_PROC_UNUSED(void,glDisableClientState,(GLenum array))
+SDL_PROC_UNUSED(void,glDrawArrays,(GLenum mode, GLint first, GLsizei count))
+SDL_PROC_UNUSED(void,glDrawBuffer,(GLenum mode))
+SDL_PROC_UNUSED(void,glDrawElements,(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices))
+SDL_PROC_UNUSED(void,glDrawPixels,(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
+SDL_PROC_UNUSED(void,glEdgeFlag,(GLboolean flag))
+SDL_PROC_UNUSED(void,glEdgeFlagPointer,(GLsizei stride, const GLvoid *pointer))
+SDL_PROC_UNUSED(void,glEdgeFlagv,(const GLboolean *flag))
+SDL_PROC(void,glEnable,(GLenum cap))
+SDL_PROC_UNUSED(void,glEnableClientState,(GLenum array))
+SDL_PROC(void,glEnd,(void))
+SDL_PROC_UNUSED(void,glEndList,(void))
+SDL_PROC_UNUSED(void,glEvalCoord1d,(GLdouble u))
+SDL_PROC_UNUSED(void,glEvalCoord1dv,(const GLdouble *u))
+SDL_PROC_UNUSED(void,glEvalCoord1f,(GLfloat u))
+SDL_PROC_UNUSED(void,glEvalCoord1fv,(const GLfloat *u))
+SDL_PROC_UNUSED(void,glEvalCoord2d,(GLdouble u, GLdouble v))
+SDL_PROC_UNUSED(void,glEvalCoord2dv,(const GLdouble *u))
+SDL_PROC_UNUSED(void,glEvalCoord2f,(GLfloat u, GLfloat v))
+SDL_PROC_UNUSED(void,glEvalCoord2fv,(const GLfloat *u))
+SDL_PROC_UNUSED(void,glEvalMesh1,(GLenum mode, GLint i1, GLint i2))
+SDL_PROC_UNUSED(void,glEvalMesh2,(GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2))
+SDL_PROC_UNUSED(void,glEvalPoint1,(GLint i))
+SDL_PROC_UNUSED(void,glEvalPoint2,(GLint i, GLint j))
+SDL_PROC_UNUSED(void,glFeedbackBuffer,(GLsizei size, GLenum type, GLfloat *buffer))
+SDL_PROC_UNUSED(void,glFinish,(void))
+SDL_PROC(void,glFlush,(void))
+SDL_PROC_UNUSED(void,glFogf,(GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glFogfv,(GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glFogi,(GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glFogiv,(GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glFrontFace,(GLenum mode))
+SDL_PROC_UNUSED(void,glFrustum,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar))
+SDL_PROC_UNUSED(GLuint,glGenLists,(GLsizei range))
+SDL_PROC(void,glGenTextures,(GLsizei n, GLuint *textures))
+SDL_PROC_UNUSED(void,glGetBooleanv,(GLenum pname, GLboolean *params))
+SDL_PROC_UNUSED(void,glGetClipPlane,(GLenum plane, GLdouble *equation))
+SDL_PROC_UNUSED(void,glGetDoublev,(GLenum pname, GLdouble *params))
+SDL_PROC_UNUSED(GLenum,glGetError,(void))
+SDL_PROC_UNUSED(void,glGetFloatv,(GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetIntegerv,(GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetLightfv,(GLenum light, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetLightiv,(GLenum light, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetMapdv,(GLenum target, GLenum query, GLdouble *v))
+SDL_PROC_UNUSED(void,glGetMapfv,(GLenum target, GLenum query, GLfloat *v))
+SDL_PROC_UNUSED(void,glGetMapiv,(GLenum target, GLenum query, GLint *v))
+SDL_PROC_UNUSED(void,glGetMaterialfv,(GLenum face, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetMaterialiv,(GLenum face, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetPixelMapfv,(GLenum map, GLfloat *values))
+SDL_PROC_UNUSED(void,glGetPixelMapuiv,(GLenum map, GLuint *values))
+SDL_PROC_UNUSED(void,glGetPixelMapusv,(GLenum map, GLushort *values))
+SDL_PROC_UNUSED(void,glGetPointerv,(GLenum pname, GLvoid* *params))
+SDL_PROC_UNUSED(void,glGetPolygonStipple,(GLubyte *mask))
+SDL_PROC(const GLubyte *,glGetString,(GLenum name))
+SDL_PROC_UNUSED(void,glGetTexEnvfv,(GLenum target, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetTexEnviv,(GLenum target, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetTexGendv,(GLenum coord, GLenum pname, GLdouble *params))
+SDL_PROC_UNUSED(void,glGetTexGenfv,(GLenum coord, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetTexGeniv,(GLenum coord, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetTexImage,(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels))
+SDL_PROC_UNUSED(void,glGetTexLevelParameterfv,(GLenum target, GLint level, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetTexLevelParameteriv,(GLenum target, GLint level, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glGetTexParameterfv,(GLenum target, GLenum pname, GLfloat *params))
+SDL_PROC_UNUSED(void,glGetTexParameteriv,(GLenum target, GLenum pname, GLint *params))
+SDL_PROC_UNUSED(void,glHint,(GLenum target, GLenum mode))
+SDL_PROC_UNUSED(void,glIndexMask,(GLuint mask))
+SDL_PROC_UNUSED(void,glIndexPointer,(GLenum type, GLsizei stride, const GLvoid *pointer))
+SDL_PROC_UNUSED(void,glIndexd,(GLdouble c))
+SDL_PROC_UNUSED(void,glIndexdv,(const GLdouble *c))
+SDL_PROC_UNUSED(void,glIndexf,(GLfloat c))
+SDL_PROC_UNUSED(void,glIndexfv,(const GLfloat *c))
+SDL_PROC_UNUSED(void,glIndexi,(GLint c))
+SDL_PROC_UNUSED(void,glIndexiv,(const GLint *c))
+SDL_PROC_UNUSED(void,glIndexs,(GLshort c))
+SDL_PROC_UNUSED(void,glIndexsv,(const GLshort *c))
+SDL_PROC_UNUSED(void,glIndexub,(GLubyte c))
+SDL_PROC_UNUSED(void,glIndexubv,(const GLubyte *c))
+SDL_PROC_UNUSED(void,glInitNames,(void))
+SDL_PROC_UNUSED(void,glInterleavedArrays,(GLenum format, GLsizei stride, const GLvoid *pointer))
+SDL_PROC_UNUSED(GLboolean,glIsEnabled,(GLenum cap))
+SDL_PROC_UNUSED(GLboolean,glIsList,(GLuint list))
+SDL_PROC_UNUSED(GLboolean,glIsTexture,(GLuint texture))
+SDL_PROC_UNUSED(void,glLightModelf,(GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glLightModelfv,(GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glLightModeli,(GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glLightModeliv,(GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glLightf,(GLenum light, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glLightfv,(GLenum light, GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glLighti,(GLenum light, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glLightiv,(GLenum light, GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glLineStipple,(GLint factor, GLushort pattern))
+SDL_PROC_UNUSED(void,glLineWidth,(GLfloat width))
+SDL_PROC_UNUSED(void,glListBase,(GLuint base))
+SDL_PROC(void,glLoadIdentity,(void))
+SDL_PROC_UNUSED(void,glLoadMatrixd,(const GLdouble *m))
+SDL_PROC_UNUSED(void,glLoadMatrixf,(const GLfloat *m))
+SDL_PROC_UNUSED(void,glLoadName,(GLuint name))
+SDL_PROC_UNUSED(void,glLogicOp,(GLenum opcode))
+SDL_PROC_UNUSED(void,glMap1d,(GLenum target, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points))
+SDL_PROC_UNUSED(void,glMap1f,(GLenum target, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points))
+SDL_PROC_UNUSED(void,glMap2d,(GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points))
+SDL_PROC_UNUSED(void,glMap2f,(GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points))
+SDL_PROC_UNUSED(void,glMapGrid1d,(GLint un, GLdouble u1, GLdouble u2))
+SDL_PROC_UNUSED(void,glMapGrid1f,(GLint un, GLfloat u1, GLfloat u2))
+SDL_PROC_UNUSED(void,glMapGrid2d,(GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2))
+SDL_PROC_UNUSED(void,glMapGrid2f,(GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2))
+SDL_PROC_UNUSED(void,glMaterialf,(GLenum face, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glMaterialfv,(GLenum face, GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glMateriali,(GLenum face, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glMaterialiv,(GLenum face, GLenum pname, const GLint *params))
+SDL_PROC(void,glMatrixMode,(GLenum mode))
+SDL_PROC_UNUSED(void,glMultMatrixd,(const GLdouble *m))
+SDL_PROC_UNUSED(void,glMultMatrixf,(const GLfloat *m))
+SDL_PROC_UNUSED(void,glNewList,(GLuint list, GLenum mode))
+SDL_PROC_UNUSED(void,glNormal3b,(GLbyte nx, GLbyte ny, GLbyte nz))
+SDL_PROC_UNUSED(void,glNormal3bv,(const GLbyte *v))
+SDL_PROC_UNUSED(void,glNormal3d,(GLdouble nx, GLdouble ny, GLdouble nz))
+SDL_PROC_UNUSED(void,glNormal3dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glNormal3f,(GLfloat nx, GLfloat ny, GLfloat nz))
+SDL_PROC_UNUSED(void,glNormal3fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glNormal3i,(GLint nx, GLint ny, GLint nz))
+SDL_PROC_UNUSED(void,glNormal3iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glNormal3s,(GLshort nx, GLshort ny, GLshort nz))
+SDL_PROC_UNUSED(void,glNormal3sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glNormalPointer,(GLenum type, GLsizei stride, const GLvoid *pointer))
+SDL_PROC(void,glOrtho,(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar))
+SDL_PROC_UNUSED(void,glPassThrough,(GLfloat token))
+SDL_PROC_UNUSED(void,glPixelMapfv,(GLenum map, GLsizei mapsize, const GLfloat *values))
+SDL_PROC_UNUSED(void,glPixelMapuiv,(GLenum map, GLsizei mapsize, const GLuint *values))
+SDL_PROC_UNUSED(void,glPixelMapusv,(GLenum map, GLsizei mapsize, const GLushort *values))
+SDL_PROC_UNUSED(void,glPixelStoref,(GLenum pname, GLfloat param))
+SDL_PROC(void,glPixelStorei,(GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glPixelTransferf,(GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glPixelTransferi,(GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glPixelZoom,(GLfloat xfactor, GLfloat yfactor))
+SDL_PROC_UNUSED(void,glPointSize,(GLfloat size))
+SDL_PROC_UNUSED(void,glPolygonMode,(GLenum face, GLenum mode))
+SDL_PROC_UNUSED(void,glPolygonOffset,(GLfloat factor, GLfloat units))
+SDL_PROC_UNUSED(void,glPolygonStipple,(const GLubyte *mask))
+SDL_PROC(void,glPopAttrib,(void))
+SDL_PROC(void,glPopClientAttrib,(void))
+SDL_PROC(void,glPopMatrix,(void))
+SDL_PROC_UNUSED(void,glPopName,(void))
+SDL_PROC_UNUSED(void,glPrioritizeTextures,(GLsizei n, const GLuint *textures, const GLclampf *priorities))
+SDL_PROC(void,glPushAttrib,(GLbitfield mask))
+SDL_PROC(void,glPushClientAttrib,(GLbitfield mask))
+SDL_PROC(void,glPushMatrix,(void))
+SDL_PROC_UNUSED(void,glPushName,(GLuint name))
+SDL_PROC_UNUSED(void,glRasterPos2d,(GLdouble x, GLdouble y))
+SDL_PROC_UNUSED(void,glRasterPos2dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glRasterPos2f,(GLfloat x, GLfloat y))
+SDL_PROC_UNUSED(void,glRasterPos2fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glRasterPos2i,(GLint x, GLint y))
+SDL_PROC_UNUSED(void,glRasterPos2iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glRasterPos2s,(GLshort x, GLshort y))
+SDL_PROC_UNUSED(void,glRasterPos2sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glRasterPos3d,(GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void,glRasterPos3dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glRasterPos3f,(GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void,glRasterPos3fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glRasterPos3i,(GLint x, GLint y, GLint z))
+SDL_PROC_UNUSED(void,glRasterPos3iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glRasterPos3s,(GLshort x, GLshort y, GLshort z))
+SDL_PROC_UNUSED(void,glRasterPos3sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glRasterPos4d,(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
+SDL_PROC_UNUSED(void,glRasterPos4dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glRasterPos4f,(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+SDL_PROC_UNUSED(void,glRasterPos4fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glRasterPos4i,(GLint x, GLint y, GLint z, GLint w))
+SDL_PROC_UNUSED(void,glRasterPos4iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glRasterPos4s,(GLshort x, GLshort y, GLshort z, GLshort w))
+SDL_PROC_UNUSED(void,glRasterPos4sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glReadBuffer,(GLenum mode))
+SDL_PROC_UNUSED(void,glReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels))
+SDL_PROC_UNUSED(void,glRectd,(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
+SDL_PROC_UNUSED(void,glRectdv,(const GLdouble *v1, const GLdouble *v2))
+SDL_PROC_UNUSED(void,glRectf,(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
+SDL_PROC_UNUSED(void,glRectfv,(const GLfloat *v1, const GLfloat *v2))
+SDL_PROC_UNUSED(void,glRecti,(GLint x1, GLint y1, GLint x2, GLint y2))
+SDL_PROC_UNUSED(void,glRectiv,(const GLint *v1, const GLint *v2))
+SDL_PROC_UNUSED(void,glRects,(GLshort x1, GLshort y1, GLshort x2, GLshort y2))
+SDL_PROC_UNUSED(void,glRectsv,(const GLshort *v1, const GLshort *v2))
+SDL_PROC_UNUSED(GLint,glRenderMode,(GLenum mode))
+SDL_PROC_UNUSED(void,glRotated,(GLdouble angle, GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void,glRotatef,(GLfloat angle, GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void,glScaled,(GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void,glScalef,(GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void,glScissor,(GLint x, GLint y, GLsizei width, GLsizei height))
+SDL_PROC_UNUSED(void,glSelectBuffer,(GLsizei size, GLuint *buffer))
+SDL_PROC_UNUSED(void,glShadeModel,(GLenum mode))
+SDL_PROC_UNUSED(void,glStencilFunc,(GLenum func, GLint ref, GLuint mask))
+SDL_PROC_UNUSED(void,glStencilMask,(GLuint mask))
+SDL_PROC_UNUSED(void,glStencilOp,(GLenum fail, GLenum zfail, GLenum zpass))
+SDL_PROC_UNUSED(void,glTexCoord1d,(GLdouble s))
+SDL_PROC_UNUSED(void,glTexCoord1dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glTexCoord1f,(GLfloat s))
+SDL_PROC_UNUSED(void,glTexCoord1fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glTexCoord1i,(GLint s))
+SDL_PROC_UNUSED(void,glTexCoord1iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glTexCoord1s,(GLshort s))
+SDL_PROC_UNUSED(void,glTexCoord1sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glTexCoord2d,(GLdouble s, GLdouble t))
+SDL_PROC_UNUSED(void,glTexCoord2dv,(const GLdouble *v))
+SDL_PROC(void,glTexCoord2f,(GLfloat s, GLfloat t))
+SDL_PROC_UNUSED(void,glTexCoord2fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glTexCoord2i,(GLint s, GLint t))
+SDL_PROC_UNUSED(void,glTexCoord2iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glTexCoord2s,(GLshort s, GLshort t))
+SDL_PROC_UNUSED(void,glTexCoord2sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glTexCoord3d,(GLdouble s, GLdouble t, GLdouble r))
+SDL_PROC_UNUSED(void,glTexCoord3dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glTexCoord3f,(GLfloat s, GLfloat t, GLfloat r))
+SDL_PROC_UNUSED(void,glTexCoord3fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glTexCoord3i,(GLint s, GLint t, GLint r))
+SDL_PROC_UNUSED(void,glTexCoord3iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glTexCoord3s,(GLshort s, GLshort t, GLshort r))
+SDL_PROC_UNUSED(void,glTexCoord3sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glTexCoord4d,(GLdouble s, GLdouble t, GLdouble r, GLdouble q))
+SDL_PROC_UNUSED(void,glTexCoord4dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glTexCoord4f,(GLfloat s, GLfloat t, GLfloat r, GLfloat q))
+SDL_PROC_UNUSED(void,glTexCoord4fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glTexCoord4i,(GLint s, GLint t, GLint r, GLint q))
+SDL_PROC_UNUSED(void,glTexCoord4iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glTexCoord4s,(GLshort s, GLshort t, GLshort r, GLshort q))
+SDL_PROC_UNUSED(void,glTexCoord4sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glTexCoordPointer,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))
+SDL_PROC(void,glTexEnvf,(GLenum target, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glTexEnvfv,(GLenum target, GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glTexEnvi,(GLenum target, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glTexEnviv,(GLenum target, GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glTexGend,(GLenum coord, GLenum pname, GLdouble param))
+SDL_PROC_UNUSED(void,glTexGendv,(GLenum coord, GLenum pname, const GLdouble *params))
+SDL_PROC_UNUSED(void,glTexGenf,(GLenum coord, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glTexGenfv,(GLenum coord, GLenum pname, const GLfloat *params))
+SDL_PROC_UNUSED(void,glTexGeni,(GLenum coord, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glTexGeniv,(GLenum coord, GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glTexImage1D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels))
+SDL_PROC(void,glTexImage2D,(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels))
+SDL_PROC_UNUSED(void,glTexParameterf,(GLenum target, GLenum pname, GLfloat param))
+SDL_PROC_UNUSED(void,glTexParameterfv,(GLenum target, GLenum pname, const GLfloat *params))
+SDL_PROC(void,glTexParameteri,(GLenum target, GLenum pname, GLint param))
+SDL_PROC_UNUSED(void,glTexParameteriv,(GLenum target, GLenum pname, const GLint *params))
+SDL_PROC_UNUSED(void,glTexSubImage1D,(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels))
+SDL_PROC(void,glTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
+SDL_PROC_UNUSED(void,glTranslated,(GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void,glTranslatef,(GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void,glVertex2d,(GLdouble x, GLdouble y))
+SDL_PROC_UNUSED(void,glVertex2dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glVertex2f,(GLfloat x, GLfloat y))
+SDL_PROC_UNUSED(void,glVertex2fv,(const GLfloat *v))
+SDL_PROC(void,glVertex2i,(GLint x, GLint y))
+SDL_PROC_UNUSED(void,glVertex2iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glVertex2s,(GLshort x, GLshort y))
+SDL_PROC_UNUSED(void,glVertex2sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glVertex3d,(GLdouble x, GLdouble y, GLdouble z))
+SDL_PROC_UNUSED(void,glVertex3dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glVertex3f,(GLfloat x, GLfloat y, GLfloat z))
+SDL_PROC_UNUSED(void,glVertex3fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glVertex3i,(GLint x, GLint y, GLint z))
+SDL_PROC_UNUSED(void,glVertex3iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glVertex3s,(GLshort x, GLshort y, GLshort z))
+SDL_PROC_UNUSED(void,glVertex3sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glVertex4d,(GLdouble x, GLdouble y, GLdouble z, GLdouble w))
+SDL_PROC_UNUSED(void,glVertex4dv,(const GLdouble *v))
+SDL_PROC_UNUSED(void,glVertex4f,(GLfloat x, GLfloat y, GLfloat z, GLfloat w))
+SDL_PROC_UNUSED(void,glVertex4fv,(const GLfloat *v))
+SDL_PROC_UNUSED(void,glVertex4i,(GLint x, GLint y, GLint z, GLint w))
+SDL_PROC_UNUSED(void,glVertex4iv,(const GLint *v))
+SDL_PROC_UNUSED(void,glVertex4s,(GLshort x, GLshort y, GLshort z, GLshort w))
+SDL_PROC_UNUSED(void,glVertex4sv,(const GLshort *v))
+SDL_PROC_UNUSED(void,glVertexPointer,(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer))
+SDL_PROC(void,glViewport,(GLint x, GLint y, GLsizei width, GLsizei height))
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_leaks.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Define this if you want surface leak detection code enabled */
+/*#define CHECK_LEAKS*/
+
+/* Global variables used to check leaks in code using SDL */
+
+#ifdef CHECK_LEAKS
+extern int surfaces_allocated;
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_memops.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,127 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_memops_h
+#define _SDL_memops_h
+
+/* System dependent optimized memory manipulation routines:
+*/
+#include <string.h>
+
+#if defined(__GNUC__) && defined(i386)
+/* Thanks to Brennan "Bas" Underwood, for the inspiration. :)
+ */
+#define SDL_memcpy(dst, src, len)					  \
+do {									  \
+	int u0, u1, u2;						  \
+	__asm__ __volatile__ (						  \
+		"cld\n\t"						  \
+		"rep ; movsl\n\t"					  \
+		"testb $2,%b4\n\t"					  \
+		"je 1f\n\t"						  \
+		"movsw\n"						  \
+		"1:\ttestb $1,%b4\n\t"					  \
+		"je 2f\n\t"						  \
+		"movsb\n"						  \
+		"2:"							  \
+		: "=&c" (u0), "=&D" (u1), "=&S" (u2)			  \
+		: "0" ((unsigned)(len)/4), "q" (len), "1" (dst),"2" (src) \
+		: "memory" );						  \
+} while(0)
+
+#define SDL_revcpy(dst, src, len)			\
+do {							\
+	int u0, u1, u2;					\
+	char *dstp = (char *)(dst);			\
+	char *srcp = (char *)(src);			\
+	int n = (len);					\
+	if ( n >= 4 ) {					\
+	__asm__ __volatile__ (				\
+		"std\n\t"				\
+		"rep ; movsl\n\t"			\
+		: "=&c" (u0), "=&D" (u1), "=&S" (u2)	\
+		: "0" (n >> 2),				\
+		  "1" (dstp+(n-4)), "2" (srcp+(n-4))	\
+		: "memory" );				\
+	}						\
+	switch (n & 3) {				\
+		case 3: dstp[2] = srcp[2];		\
+		case 2: dstp[1] = srcp[1];		\
+		case 1: dstp[0] = srcp[0];		\
+			break;				\
+		default:				\
+			break;				\
+	}						\
+} while(0)
+
+#define SDL_memmove(dst, src, len)			\
+do {							\
+	if ( (dst) < (src) ) {				\
+		SDL_memcpy((dst), (src), (len));	\
+	} else {					\
+		SDL_revcpy((dst), (src), (len));	\
+	}						\
+} while(0)
+
+#define SDL_memset4(dst, val, len)				\
+do {								\
+	int u0, u1, u2;					\
+	__asm__ __volatile__ (					\
+		"cld\n\t"					\
+		"rep ; stosl\n\t"				\
+		: "=&D" (u0), "=&a" (u1), "=&c" (u2)		\
+		: "0" (dst), "1" (val), "2" ((Uint32)(len))	\
+		: "memory" );					\
+} while(0)
+
+#endif /* GNU C and x86 */
+
+/* If there are no optimized versions, define the normal versions */
+#ifndef SDL_memcpy
+#define SDL_memcpy(dst, src, len)	memcpy(dst, src, len)
+#endif
+#ifndef SDL_revcpy
+#define SDL_revcpy(dst, src, len)	memmove(dst, src, len)
+#endif
+#ifndef SDL_memset4
+#define SDL_memset4(dst, val, len)		\
+do {						\
+	unsigned _count = (len);		\
+	unsigned _n = (_count + 3) / 4;		\
+	Uint32 *_p = (Uint32 *)(dst);		\
+	Uint32 _val = (val);			\
+        switch (_count % 4) {			\
+        case 0: do {    *_p++ = _val;		\
+        case 3:         *_p++ = _val;		\
+        case 2:         *_p++ = _val;		\
+        case 1:         *_p++ = _val;		\
+		} while ( --_n );		\
+	}					\
+} while(0)
+#endif
+
+#endif /* _SDL_memops_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_pixels.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,619 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* General (mostly internal) pixel/color manipulation routines for SDL */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+#include "SDL_blit.h"
+#include "SDL_pixels_c.h"
+#include "SDL_RLEaccel_c.h"
+
+/* Helper functions */
+/*
+ * Allocate a pixel format structure and fill it according to the given info.
+ */
+SDL_PixelFormat *SDL_AllocFormat(int bpp,
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
+{
+	SDL_PixelFormat *format;
+	Uint32 mask;
+
+	/* Allocate an empty pixel format structure */
+	format = malloc(sizeof(*format));
+	if ( format == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(format, 0, sizeof(*format));
+	format->alpha = SDL_ALPHA_OPAQUE;
+
+	/* Set up the format */
+	format->BitsPerPixel = bpp;
+	format->BytesPerPixel = (bpp+7)/8;
+	switch (bpp) {
+		case 1:
+			/* Create the 2 color black-white palette */
+			format->palette = (SDL_Palette *)malloc(
+							sizeof(SDL_Palette));
+			if ( format->palette == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			(format->palette)->ncolors = 2;
+			(format->palette)->colors = (SDL_Color *)malloc(
+				(format->palette)->ncolors*sizeof(SDL_Color));
+			if ( (format->palette)->colors == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			format->palette->colors[0].r = 0xFF;
+			format->palette->colors[0].g = 0xFF;
+			format->palette->colors[0].b = 0xFF;
+			format->palette->colors[1].r = 0x00;
+			format->palette->colors[1].g = 0x00;
+			format->palette->colors[1].b = 0x00;
+			format->Rloss = 8;
+			format->Gloss = 8;
+			format->Bloss = 8;
+			format->Aloss = 8;
+			format->Rshift = 0;
+			format->Gshift = 0;
+			format->Bshift = 0;
+			format->Ashift = 0;
+			format->Rmask = 0;
+			format->Gmask = 0;
+			format->Bmask = 0;
+			format->Amask = 0;
+			break;
+
+		case 4:
+			/* Create the 16 color VGA palette */
+			format->palette = (SDL_Palette *)malloc(
+							sizeof(SDL_Palette));
+			if ( format->palette == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			(format->palette)->ncolors = 16;
+			(format->palette)->colors = (SDL_Color *)malloc(
+				(format->palette)->ncolors*sizeof(SDL_Color));
+			if ( (format->palette)->colors == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			/* Punt for now, will this ever be used? */
+			memset((format->palette)->colors, 0,
+				(format->palette)->ncolors*sizeof(SDL_Color));
+
+			/* Palettized formats have no mask info */
+			format->Rloss = 8;
+			format->Gloss = 8;
+			format->Bloss = 8;
+			format->Aloss = 8;
+			format->Rshift = 0;
+			format->Gshift = 0;
+			format->Bshift = 0;
+			format->Ashift = 0;
+			format->Rmask = 0;
+			format->Gmask = 0;
+			format->Bmask = 0;
+			format->Amask = 0;
+			break;
+
+		case 8:
+			/* Create an empty 256 color palette */
+			format->palette = (SDL_Palette *)malloc(
+							sizeof(SDL_Palette));
+			if ( format->palette == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			(format->palette)->ncolors = 256;
+			(format->palette)->colors = (SDL_Color *)malloc(
+				(format->palette)->ncolors*sizeof(SDL_Color));
+			if ( (format->palette)->colors == NULL ) {
+				SDL_FreeFormat(format);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			memset((format->palette)->colors, 0,
+				(format->palette)->ncolors*sizeof(SDL_Color));
+
+			/* Palettized formats have no mask info */
+			format->Rloss = 8;
+			format->Gloss = 8;
+			format->Bloss = 8;
+			format->Aloss = 8;
+			format->Rshift = 0;
+			format->Gshift = 0;
+			format->Bshift = 0;
+			format->Ashift = 0;
+			format->Rmask = 0;
+			format->Gmask = 0;
+			format->Bmask = 0;
+			format->Amask = 0;
+			break;
+
+		default:
+			/* No palette, just packed pixel info */
+			format->palette = NULL;
+			format->Rshift = 0;
+			format->Rloss = 8;
+			if ( Rmask ) {
+				for ( mask = Rmask; !(mask&0x01); mask >>= 1 )
+					++format->Rshift;
+				for ( ; (mask&0x01); mask >>= 1 )
+					--format->Rloss;
+			}
+			format->Gshift = 0;
+			format->Gloss = 8;
+			if ( Gmask ) {
+				for ( mask = Gmask; !(mask&0x01); mask >>= 1 )
+					++format->Gshift;
+				for ( ; (mask&0x01); mask >>= 1 )
+					--format->Gloss;
+			}
+			format->Bshift = 0;
+			format->Bloss = 8;
+			if ( Bmask ) {
+				for ( mask = Bmask; !(mask&0x01); mask >>= 1 )
+					++format->Bshift;
+				for ( ; (mask&0x01); mask >>= 1 )
+					--format->Bloss;
+			}
+			format->Ashift = 0;
+			format->Aloss = 8;
+			if ( Amask ) {
+				for ( mask = Amask; !(mask&0x01); mask >>= 1 )
+					++format->Ashift;
+				for ( ; (mask&0x01); mask >>= 1 )
+					--format->Aloss;
+			}
+			format->Rmask = Rmask;
+			format->Gmask = Gmask;
+			format->Bmask = Bmask;
+			format->Amask = Amask;
+			break;
+	}
+	/* Calculate some standard bitmasks, if necessary 
+	 * Note:  This could conflict with an alpha mask, if given.
+	 */
+	if ( (bpp > 8) && !format->Rmask && !format->Gmask && !format->Bmask ) {
+		/* R-G-B */
+		if ( bpp > 24 )
+			bpp = 24;
+		format->Rloss = 8-(bpp/3);
+		format->Gloss = 8-(bpp/3)-(bpp%3);
+		format->Bloss = 8-(bpp/3);
+		format->Rshift = ((bpp/3)+(bpp%3))+(bpp/3);
+		format->Gshift = (bpp/3);
+		format->Bshift = 0;
+		format->Rmask = ((0xFF>>format->Rloss)<<format->Rshift);
+		format->Gmask = ((0xFF>>format->Gloss)<<format->Gshift);
+		format->Bmask = ((0xFF>>format->Bloss)<<format->Bshift);
+	}
+	return(format);
+}
+SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
+{
+	if ( surface->format ) {
+		SDL_FreeFormat(surface->format);
+		SDL_FormatChanged(surface);
+	}
+	surface->format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask);
+	return surface->format;
+}
+
+/*
+ * Change any previous mappings from/to the new surface format
+ */
+void SDL_FormatChanged(SDL_Surface *surface)
+{
+	surface->format_version++;
+	SDL_InvalidateMap(surface->map);
+}
+/*
+ * Free a previously allocated format structure
+ */
+void SDL_FreeFormat(SDL_PixelFormat *format)
+{
+	if ( format ) {
+		if ( format->palette ) {
+			if ( format->palette->colors ) {
+				free(format->palette->colors);
+			}
+			free(format->palette);
+		}
+		free(format);
+	}
+}
+/*
+ * Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors
+ */
+void SDL_DitherColors(SDL_Color *colors, int bpp)
+{
+	int i;
+	if(bpp != 8)
+		return;		/* only 8bpp supported right now */
+
+	for(i = 0; i < 256; i++) {
+		int r, g, b;
+		/* map each bit field to the full [0, 255] interval,
+		   so 0 is mapped to (0, 0, 0) and 255 to (255, 255, 255) */
+		r = i & 0xe0;
+		r |= r >> 3 | r >> 6;
+		colors[i].r = r;
+		g = (i << 3) & 0xe0;
+		g |= g >> 3 | g >> 6;
+		colors[i].g = g;
+		b = i & 0x3;
+		b |= b << 2;
+		b |= b << 4;
+		colors[i].b = b;
+	}
+}
+/* 
+ * Calculate the pad-aligned scanline width of a surface
+ */
+Uint16 SDL_CalculatePitch(SDL_Surface *surface)
+{
+	Uint16 pitch;
+
+	/* Surface should be 4-byte aligned for speed */
+	pitch = surface->w*surface->format->BytesPerPixel;
+	switch (surface->format->BitsPerPixel) {
+		case 1:
+			pitch = (pitch+7)/8;
+			break;
+		case 4:
+			pitch = (pitch+1)/2;
+			break;
+		default:
+			break;
+	}
+	pitch = (pitch + 3) & ~3;	/* 4-byte aligning */
+	return(pitch);
+}
+/*
+ * Match an RGB value to a particular palette index
+ */
+Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b)
+{
+	/* Do colorspace distance matching */
+	unsigned int smallest;
+	unsigned int distance;
+	int rd, gd, bd;
+	int i;
+	Uint8 pixel=0;
+		
+	smallest = ~0;
+	for ( i=0; i<pal->ncolors; ++i ) {
+		rd = pal->colors[i].r - r;
+		gd = pal->colors[i].g - g;
+		bd = pal->colors[i].b - b;
+		distance = (rd*rd)+(gd*gd)+(bd*bd);
+		if ( distance < smallest ) {
+			pixel = i;
+			if ( distance == 0 ) { /* Perfect match! */
+				break;
+			}
+			smallest = distance;
+		}
+	}
+	return(pixel);
+}
+
+/* Find the opaque pixel value corresponding to an RGB triple */
+Uint32 SDL_MapRGB(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b)
+{
+	if ( format->palette == NULL ) {
+		return (r >> format->Rloss) << format->Rshift
+		       | (g >> format->Gloss) << format->Gshift
+		       | (b >> format->Bloss) << format->Bshift
+		       | format->Amask;
+	} else {
+		return SDL_FindColor(format->palette, r, g, b);
+	}
+}
+
+/* Find the pixel value corresponding to an RGBA quadruple */
+Uint32 SDL_MapRGBA(SDL_PixelFormat *format, Uint8 r, Uint8 g, Uint8 b, Uint8 a)
+{
+	if ( format->palette == NULL ) {
+	        return (r >> format->Rloss) << format->Rshift
+		    | (g >> format->Gloss) << format->Gshift
+		    | (b >> format->Bloss) << format->Bshift
+		    | ((a >> format->Aloss) << format->Ashift & format->Amask);
+	} else {
+		return SDL_FindColor(format->palette, r, g, b);
+	}
+}
+
+void SDL_GetRGBA(Uint32 pixel, SDL_PixelFormat *fmt,
+		 Uint8 *r, Uint8 *g, Uint8 *b, Uint8 *a)
+{
+	if ( fmt->palette == NULL ) {
+	        /*
+		 * This makes sure that the result is mapped to the
+		 * interval [0..255], and the maximum value for each
+		 * component is 255. This is important to make sure
+		 * that white is indeed reported as (255, 255, 255),
+		 * and that opaque alpha is 255.
+		 * This only works for RGB bit fields at least 4 bit
+		 * wide, which is almost always the case.
+		 */
+	        unsigned rv, gv, bv, av;
+		rv = (pixel & fmt->Rmask) >> fmt->Rshift;
+		*r = (rv << fmt->Rloss) + (rv >> (8 - fmt->Rloss));
+		gv = (pixel & fmt->Gmask) >> fmt->Gshift;
+		*g = (gv << fmt->Gloss) + (gv >> (8 - fmt->Gloss));
+		bv = (pixel & fmt->Bmask) >> fmt->Bshift;
+		*b = (bv << fmt->Bloss) + (bv >> (8 - fmt->Bloss));
+		if(fmt->Amask) {
+		        av = (pixel & fmt->Amask) >> fmt->Ashift;
+			*a = (av << fmt->Aloss) + (av >> (8 - fmt->Aloss));
+		} else
+		        *a = SDL_ALPHA_OPAQUE;
+	} else {
+		*r = fmt->palette->colors[pixel].r;
+		*g = fmt->palette->colors[pixel].g;
+		*b = fmt->palette->colors[pixel].b;
+		*a = SDL_ALPHA_OPAQUE;
+	}
+}
+
+void SDL_GetRGB(Uint32 pixel, SDL_PixelFormat *fmt, Uint8 *r,Uint8 *g,Uint8 *b)
+{
+	if ( fmt->palette == NULL ) {
+	        /* the note for SDL_GetRGBA above applies here too */
+	        unsigned rv, gv, bv;
+		rv = (pixel & fmt->Rmask) >> fmt->Rshift;
+		*r = (rv << fmt->Rloss) + (rv >> (8 - fmt->Rloss));
+		gv = (pixel & fmt->Gmask) >> fmt->Gshift;
+		*g = (gv << fmt->Gloss) + (gv >> (8 - fmt->Gloss));
+		bv = (pixel & fmt->Bmask) >> fmt->Bshift;
+		*b = (bv << fmt->Bloss) + (bv >> (8 - fmt->Bloss));
+	} else {
+		*r = fmt->palette->colors[pixel].r;
+		*g = fmt->palette->colors[pixel].g;
+		*b = fmt->palette->colors[pixel].b;
+	}
+}
+
+/* Apply gamma to a set of colors - this is easy. :) */
+void SDL_ApplyGamma(Uint16 *gamma, SDL_Color *colors, SDL_Color *output,
+							int ncolors)
+{
+	int i;
+
+	for ( i=0; i<ncolors; ++i ) {
+		output[i].r = gamma[0*256 + colors[i].r] >> 8;
+		output[i].g = gamma[1*256 + colors[i].g] >> 8;
+		output[i].b = gamma[2*256 + colors[i].b] >> 8;
+	}
+}
+
+/* Map from Palette to Palette */
+static Uint8 *Map1to1(SDL_Palette *src, SDL_Palette *dst, int *identical)
+{
+	Uint8 *map;
+	int i;
+
+	if ( identical ) {
+		if ( src->ncolors <= dst->ncolors ) {
+			/* If an identical palette, no need to map */
+			if ( memcmp(src->colors, dst->colors, src->ncolors*
+						sizeof(SDL_Color)) == 0 ) {
+				*identical = 1;
+				return(NULL);
+			}
+		}
+		*identical = 0;
+	}
+	map = (Uint8 *)malloc(src->ncolors);
+	if ( map == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	for ( i=0; i<src->ncolors; ++i ) {
+		map[i] = SDL_FindColor(dst,
+			src->colors[i].r, src->colors[i].g, src->colors[i].b);
+	}
+	return(map);
+}
+/* Map from Palette to BitField */
+static Uint8 *Map1toN(SDL_Palette *src, SDL_PixelFormat *dst)
+{
+	Uint8 *map;
+	int i;
+	int  bpp;
+	unsigned alpha;
+
+	bpp = ((dst->BytesPerPixel == 3) ? 4 : dst->BytesPerPixel);
+	map = (Uint8 *)malloc(src->ncolors*bpp);
+	if ( map == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+
+	alpha = dst->Amask ? SDL_ALPHA_OPAQUE : 0;
+	/* We memory copy to the pixel map so the endianness is preserved */
+	for ( i=0; i<src->ncolors; ++i ) {
+		ASSEMBLE_RGBA(&map[i*bpp], dst->BytesPerPixel, dst,
+			      src->colors[i].r, src->colors[i].g,
+			      src->colors[i].b, alpha);
+	}
+	return(map);
+}
+/* Map from BitField to Dithered-Palette to Palette */
+static Uint8 *MapNto1(SDL_PixelFormat *src, SDL_Palette *dst, int *identical)
+{
+	/* Generate a 256 color dither palette */
+	SDL_Palette dithered;
+	SDL_Color colors[256];
+
+	dithered.ncolors = 256;
+	SDL_DitherColors(colors, 8);
+	dithered.colors = colors;
+	return(Map1to1(&dithered, dst, identical));
+}
+
+SDL_BlitMap *SDL_AllocBlitMap(void)
+{
+	SDL_BlitMap *map;
+
+	/* Allocate the empty map */
+	map = (SDL_BlitMap *)malloc(sizeof(*map));
+	if ( map == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(map, 0, sizeof(*map));
+
+	/* Allocate the software blit data */
+	map->sw_data = (struct private_swaccel *)malloc(sizeof(*map->sw_data));
+	if ( map->sw_data == NULL ) {
+		SDL_FreeBlitMap(map);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(map->sw_data, 0, sizeof(*map->sw_data));
+
+	/* It's ready to go */
+	return(map);
+}
+void SDL_InvalidateMap(SDL_BlitMap *map)
+{
+	if ( ! map ) {
+		return;
+	}
+	map->dst = NULL;
+	map->format_version = (unsigned int)-1;
+	if ( map->table ) {
+		free(map->table);
+		map->table = NULL;
+	}
+}
+int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst)
+{
+	SDL_PixelFormat *srcfmt;
+	SDL_PixelFormat *dstfmt;
+	SDL_BlitMap *map;
+
+	/* Clear out any previous mapping */
+	map = src->map;
+	if ( (src->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+		SDL_UnRLESurface(src, 1);
+	}
+	SDL_InvalidateMap(map);
+
+	/* Figure out what kind of mapping we're doing */
+	map->identity = 0;
+	srcfmt = src->format;
+	dstfmt = dst->format;
+	switch (srcfmt->BytesPerPixel) {
+	    case 1:
+		switch (dstfmt->BytesPerPixel) {
+		    case 1:
+			/* Palette --> Palette */
+			/* If both SDL_HWSURFACE, assume have same palette */
+			if ( ((src->flags & SDL_HWSURFACE) == SDL_HWSURFACE) &&
+			     ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) ) {
+				map->identity = 1;
+			} else {
+				map->table = Map1to1(srcfmt->palette,
+					dstfmt->palette, &map->identity);
+			}
+			if ( ! map->identity ) {
+				if ( map->table == NULL ) {
+					return(-1);
+				}
+			}
+			if (srcfmt->BitsPerPixel!=dstfmt->BitsPerPixel)
+				map->identity = 0;
+			break;
+
+		    default:
+			/* Palette --> BitField */
+			map->table = Map1toN(srcfmt->palette, dstfmt);
+			if ( map->table == NULL ) {
+				return(-1);
+			}
+			break;
+		}
+		break;
+	default:
+		switch (dstfmt->BytesPerPixel) {
+		    case 1:
+			/* BitField --> Palette */
+			map->table = MapNto1(srcfmt,
+					dstfmt->palette, &map->identity);
+			if ( ! map->identity ) {
+				if ( map->table == NULL ) {
+					return(-1);
+				}
+			}
+			map->identity = 0;	/* Don't optimize to copy */
+			break;
+		    default:
+			/* BitField --> BitField */
+			if ( FORMAT_EQUAL(srcfmt, dstfmt) )
+				map->identity = 1;
+			break;
+		}
+		break;
+	}
+
+	map->dst = dst;
+	map->format_version = dst->format_version;
+
+	/* Choose your blitters wisely */
+	return(SDL_CalculateBlit(src));
+}
+void SDL_FreeBlitMap(SDL_BlitMap *map)
+{
+	if ( map ) {
+		SDL_InvalidateMap(map);
+		if ( map->sw_data != NULL ) {
+			free(map->sw_data);
+		}
+		free(map);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_pixels_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,50 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Useful functions and variables from SDL_pixel.c */
+
+#include "SDL_blit.h"
+
+/* Pixel format functions */
+extern SDL_PixelFormat *SDL_AllocFormat(int bpp,
+		Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+extern SDL_PixelFormat *SDL_ReallocFormat(SDL_Surface *surface, int bpp,
+		Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
+extern void SDL_FormatChanged(SDL_Surface *surface);
+extern void SDL_FreeFormat(SDL_PixelFormat *format);
+
+/* Blit mapping functions */
+extern SDL_BlitMap *SDL_AllocBlitMap(void);
+extern void SDL_InvalidateMap(SDL_BlitMap *map);
+extern int SDL_MapSurface (SDL_Surface *src, SDL_Surface *dst);
+extern void SDL_FreeBlitMap(SDL_BlitMap *map);
+
+/* Miscellaneous functions */
+extern Uint16 SDL_CalculatePitch(SDL_Surface *surface);
+extern void SDL_DitherColors(SDL_Color *colors, int bpp);
+extern Uint8 SDL_FindColor(SDL_Palette *pal, Uint8 r, Uint8 g, Uint8 b);
+extern void SDL_ApplyGamma(Uint16 *gamma, SDL_Color *colors, SDL_Color *output, int ncolors);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_stretch.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,312 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This a stretch blit implementation based on ideas given to me by
+   Tomasz Cejner - thanks! :)
+
+   April 27, 2000 - Sam Lantinga
+*/
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+
+/* This isn't ready for general consumption yet - it should be folded
+   into the general blitting mechanism.
+*/
+
+#if (defined(WIN32) && !defined(_M_ALPHA) && !defined(_WIN32_WCE)) || \
+    defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
+#define USE_ASM_STRETCH
+#endif
+
+#ifdef USE_ASM_STRETCH
+
+#if defined(WIN32) || defined(i386)
+#define PREFIX16	0x66
+#define STORE_BYTE	0xAA
+#define STORE_WORD	0xAB
+#define LOAD_BYTE	0xAC
+#define LOAD_WORD	0xAD
+#define RETURN		0xC3
+#else
+#error Need assembly opcodes for this architecture
+#endif
+
+#if defined(__ELF__) && defined(__GNUC__)
+extern unsigned char _copy_row[4096] __attribute__ ((alias ("copy_row")));
+#endif
+static unsigned char copy_row[4096];
+
+static int generate_rowbytes(int src_w, int dst_w, int bpp)
+{
+	static struct {
+		int bpp;
+		int src_w;
+		int dst_w;
+	} last;
+
+	int i;
+	int pos, inc;
+	unsigned char *eip;
+	unsigned char load, store;
+
+	/* See if we need to regenerate the copy buffer */
+	if ( (src_w == last.src_w) &&
+	     (dst_w == last.src_w) && (bpp == last.bpp) ) {
+		return(0);
+	}
+	last.bpp = bpp;
+	last.src_w = src_w;
+	last.dst_w = dst_w;
+
+	switch (bpp) {
+	    case 1:
+		load = LOAD_BYTE;
+		store = STORE_BYTE;
+		break;
+	    case 2:
+	    case 4:
+		load = LOAD_WORD;
+		store = STORE_WORD;
+		break;
+	    default:
+		SDL_SetError("ASM stretch of %d bytes isn't supported\n", bpp);
+		return(-1);
+	}
+	pos = 0x10000;
+	inc = (src_w << 16) / dst_w;
+	eip = copy_row;
+	for ( i=0; i<dst_w; ++i ) {
+		while ( pos >= 0x10000L ) {
+			if ( bpp == 2 ) {
+				*eip++ = PREFIX16;
+			}
+			*eip++ = load;
+			pos -= 0x10000L;
+		}
+		if ( bpp == 2 ) {
+			*eip++ = PREFIX16;
+		}
+		*eip++ = store;
+		pos += inc;
+	}
+	*eip++ = RETURN;
+
+	/* Verify that we didn't overflow (too late) */
+	if ( eip > (copy_row+sizeof(copy_row)) ) {
+		SDL_SetError("Copy buffer overflow");
+		return(-1);
+	}
+	return(0);
+}
+
+#else
+
+#define DEFINE_COPY_ROW(name, type)			\
+void name(type *src, int src_w, type *dst, int dst_w)	\
+{							\
+	int i;						\
+	int pos, inc;					\
+	type pixel = 0;					\
+							\
+	pos = 0x10000;					\
+	inc = (src_w << 16) / dst_w;			\
+	for ( i=dst_w; i>0; --i ) {			\
+		while ( pos >= 0x10000L ) {		\
+			pixel = *src++;			\
+			pos -= 0x10000L;		\
+		}					\
+		*dst++ = pixel;				\
+		pos += inc;				\
+	}						\
+}
+DEFINE_COPY_ROW(copy_row1, Uint8)
+DEFINE_COPY_ROW(copy_row2, Uint16)
+DEFINE_COPY_ROW(copy_row4, Uint32)
+
+#endif /* USE_ASM_STRETCH */
+
+/* The ASM code doesn't handle 24-bpp stretch blits */
+void copy_row3(Uint8 *src, int src_w, Uint8 *dst, int dst_w)
+{
+	int i;
+	int pos, inc;
+	Uint8 pixel[3];
+
+	pos = 0x10000;
+	inc = (src_w << 16) / dst_w;
+	for ( i=dst_w; i>0; --i ) {
+		while ( pos >= 0x10000L ) {
+			pixel[0] = *src++;
+			pixel[1] = *src++;
+			pixel[2] = *src++;
+			pos -= 0x10000L;
+		}
+		*dst++ = pixel[0];
+		*dst++ = pixel[1];
+		*dst++ = pixel[2];
+		pos += inc;
+	}
+}
+
+/* Perform a stretch blit between two surfaces of the same format.
+   NOTE:  This function is not safe to call from multiple threads!
+*/
+int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
+                    SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	int pos, inc;
+	int dst_width;
+	int dst_maxrow;
+	int src_row, dst_row;
+	Uint8 *srcp = NULL;
+	Uint8 *dstp;
+	SDL_Rect full_src;
+	SDL_Rect full_dst;
+#if defined(USE_ASM_STRETCH) && defined(__GNUC__)
+	int u1, u2;
+#endif
+	const int bpp = dst->format->BytesPerPixel;
+
+	if ( src->format->BitsPerPixel != dst->format->BitsPerPixel ) {
+		SDL_SetError("Only works with same format surfaces");
+		return(-1);
+	}
+
+	/* Verify the blit rectangles */
+	if ( srcrect ) {
+		if ( (srcrect->x < 0) || (srcrect->y < 0) ||
+		     ((srcrect->x+srcrect->w) > src->w) ||
+		     ((srcrect->y+srcrect->h) > src->h) ) {
+			SDL_SetError("Invalid source blit rectangle");
+			return(-1);
+		}
+	} else {
+		full_src.x = 0;
+		full_src.y = 0;
+		full_src.w = src->w;
+		full_src.h = src->h;
+		srcrect = &full_src;
+	}
+	if ( dstrect ) {
+		if ( (dstrect->x < 0) || (dstrect->y < 0) ||
+		     ((dstrect->x+dstrect->w) > dst->w) ||
+		     ((dstrect->y+dstrect->h) > dst->h) ) {
+			SDL_SetError("Invalid destination blit rectangle");
+			return(-1);
+		}
+	} else {
+		full_dst.x = 0;
+		full_dst.y = 0;
+		full_dst.w = dst->w;
+		full_dst.h = dst->h;
+		dstrect = &full_dst;
+	}
+
+	/* Set up the data... */
+	pos = 0x10000;
+	inc = (srcrect->h << 16) / dstrect->h;
+	src_row = srcrect->y;
+	dst_row = dstrect->y;
+	dst_width = dstrect->w*bpp;
+
+#ifdef USE_ASM_STRETCH
+	/* Write the opcodes for this stretch */
+	if ( (bpp != 3) &&
+	     (generate_rowbytes(srcrect->w, dstrect->w, bpp) < 0) ) {
+		return(-1);
+	}
+#endif
+
+	/* Perform the stretch blit */
+	for ( dst_maxrow = dst_row+dstrect->h; dst_row<dst_maxrow; ++dst_row ) {
+		dstp = (Uint8 *)dst->pixels + (dst_row*dst->pitch)
+		                            + (dstrect->x*bpp);
+		while ( pos >= 0x10000L ) {
+			srcp = (Uint8 *)src->pixels + (src_row*src->pitch)
+			                            + (srcrect->x*bpp);
+			++src_row;
+			pos -= 0x10000L;
+		}
+#ifdef USE_ASM_STRETCH
+		switch (bpp) {
+		    case 3:
+			copy_row3(srcp, srcrect->w, dstp, dstrect->w);
+			break;
+		    default:
+#ifdef __GNUC__
+			__asm__ __volatile__ ("
+				call _copy_row
+			"
+			: "=&D" (u1), "=&S" (u2)
+			: "0" (dstp), "1" (srcp)
+			: "memory" );
+#else
+#ifdef WIN32
+		{ void *code = &copy_row;
+			__asm {
+				push edi
+				push esi
+	
+				mov edi, dstp
+				mov esi, srcp
+				call dword ptr code
+
+				pop esi
+				pop edi
+			}
+		}
+#else
+#error Need inline assembly for this compiler
+#endif
+#endif /* __GNUC__ */
+			break;
+		}
+#else
+		switch (bpp) {
+		    case 1:
+			copy_row1(srcp, srcrect->w, dstp, dstrect->w);
+			break;
+		    case 2:
+			copy_row2((Uint16 *)srcp, srcrect->w,
+			          (Uint16 *)dstp, dstrect->w);
+			break;
+		    case 3:
+			copy_row3(srcp, srcrect->w, dstp, dstrect->w);
+			break;
+		    case 4:
+			copy_row4((Uint32 *)srcp, srcrect->w,
+			          (Uint32 *)dstp, dstrect->w);
+			break;
+		}
+#endif
+		pos += inc;
+	}
+	return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_stretch_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Perform a stretch blit between two surfaces of the same format.
+   NOTE:  This function is not safe to call from multiple threads!
+*/
+extern int SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
+                           SDL_Surface *dst, SDL_Rect *dstrect);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_surface.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,820 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+#include "SDL_cursor_c.h"
+#include "SDL_blit.h"
+#include "SDL_RLEaccel_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_memops.h"
+#include "SDL_leaks.h"
+
+/* Public routines */
+/*
+ * Create an empty RGB surface of the appropriate depth
+ */
+SDL_Surface * SDL_CreateRGBSurface (Uint32 flags,
+			int width, int height, int depth,
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	SDL_Surface *screen;
+	SDL_Surface *surface;
+
+	/* Check to see if we desire the surface in video memory */
+	if ( video ) {
+		screen = SDL_PublicSurface;
+	} else {
+		screen = NULL;
+	}
+	if ( screen && ((screen->flags&SDL_HWSURFACE) == SDL_HWSURFACE) ) {
+		if ( (flags&(SDL_SRCCOLORKEY|SDL_SRCALPHA)) != 0 ) {
+			flags |= SDL_HWSURFACE;
+		}
+		if ( (flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+			if ( ! current_video->info.blit_hw_CC ) {
+				flags &= ~SDL_HWSURFACE;
+			}
+		}
+		if ( (flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+			if ( ! current_video->info.blit_hw_A ) {
+				flags &= ~SDL_HWSURFACE;
+			}
+		}
+	} else {
+		flags &= ~SDL_HWSURFACE;
+	}
+
+	/* Allocate the surface */
+	surface = (SDL_Surface *)malloc(sizeof(*surface));
+	if ( surface == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	surface->flags = SDL_SWSURFACE;
+	if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		depth = screen->format->BitsPerPixel;
+		Rmask = screen->format->Rmask;
+		Gmask = screen->format->Gmask;
+		Bmask = screen->format->Bmask;
+		Amask = screen->format->Amask;
+	}
+	surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask);
+	if ( surface->format == NULL ) {
+		free(surface);
+		return(NULL);
+	}
+	if ( Amask ) {
+		surface->flags |= SDL_SRCALPHA;
+	}
+	surface->w = width;
+	surface->h = height;
+	surface->pitch = SDL_CalculatePitch(surface);
+	surface->pixels = NULL;
+	surface->offset = 0;
+	surface->hwdata = NULL;
+	surface->locked = 0;
+	surface->map = NULL;
+	surface->format_version = 0;
+	SDL_SetClipRect(surface, NULL);
+
+	/* Get the pixels */
+	if ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) || 
+				(video->AllocHWSurface(this, surface) < 0) ) {
+		if ( surface->w && surface->h ) {
+			surface->pixels = malloc(surface->h*surface->pitch);
+			if ( surface->pixels == NULL ) {
+				SDL_FreeSurface(surface);
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+			/* This is important for bitmaps */
+			memset(surface->pixels, 0, surface->h*surface->pitch);
+		}
+	}
+
+	/* Allocate an empty mapping */
+	surface->map = SDL_AllocBlitMap();
+	if ( surface->map == NULL ) {
+		SDL_FreeSurface(surface);
+		return(NULL);
+	}
+
+	/* The surface is ready to go */
+	surface->refcount = 1;
+#ifdef CHECK_LEAKS
+	++surfaces_allocated;
+#endif
+	return(surface);
+}
+/*
+ * Create an RGB surface from an existing memory buffer
+ */
+SDL_Surface * SDL_CreateRGBSurfaceFrom (void *pixels,
+			int width, int height, int depth, int pitch,
+			Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask)
+{
+	SDL_Surface *surface;
+
+	surface = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, depth,
+	                               Rmask, Gmask, Bmask, Amask);
+	if ( surface != NULL ) {
+		surface->flags |= SDL_PREALLOC;
+		surface->pixels = pixels;
+		surface->w = width;
+		surface->h = height;
+		surface->pitch = pitch;
+		SDL_SetClipRect(surface, NULL);
+	}
+	return(surface);
+}
+/*
+ * Set the color key in a blittable surface
+ */
+int SDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key)
+{
+	/* Sanity check the flag as it gets passed in */
+	if ( flag & SDL_SRCCOLORKEY ) {
+		if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
+			flag = (SDL_SRCCOLORKEY | SDL_RLEACCELOK);
+		} else {
+			flag = SDL_SRCCOLORKEY;
+		}
+	} else {
+		flag = 0;
+	}
+
+	/* Optimize away operations that don't change anything */
+	if ( (flag == (surface->flags & (SDL_SRCCOLORKEY|SDL_RLEACCELOK))) &&
+	     (key == surface->format->colorkey) ) {
+		return(0);
+	}
+
+	/* UnRLE surfaces before we change the colorkey */
+	if ( surface->flags & SDL_RLEACCEL ) {
+	        SDL_UnRLESurface(surface, 1);
+	}
+
+	if ( flag ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+
+
+		surface->flags |= SDL_SRCCOLORKEY;
+		surface->format->colorkey = key;
+		if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+			if ( (video->SetHWColorKey == NULL) ||
+			     (video->SetHWColorKey(this, surface, key) < 0) ) {
+				surface->flags &= ~SDL_HWACCEL;
+			}
+		}
+		if ( flag & SDL_RLEACCELOK ) {
+			surface->flags |= SDL_RLEACCELOK;
+		} else {
+			surface->flags &= ~SDL_RLEACCELOK;
+		}
+	} else {
+		surface->flags &= ~(SDL_SRCCOLORKEY|SDL_RLEACCELOK);
+		surface->format->colorkey = 0;
+	}
+	SDL_InvalidateMap(surface->map);
+	return(0);
+}
+int SDL_SetAlpha (SDL_Surface *surface, Uint32 flag, Uint8 value)
+{
+	Uint32 oldflags = surface->flags;
+	Uint32 oldalpha = surface->format->alpha;
+
+	/* Sanity check the flag as it gets passed in */
+	if ( flag & SDL_SRCALPHA ) {
+		if ( flag & (SDL_RLEACCEL|SDL_RLEACCELOK) ) {
+			flag = (SDL_SRCALPHA | SDL_RLEACCELOK);
+		} else {
+			flag = SDL_SRCALPHA;
+		}
+	} else {
+		flag = 0;
+	}
+
+	/* Optimize away operations that don't change anything */
+	if ( (flag == (surface->flags & (SDL_SRCALPHA|SDL_RLEACCELOK))) &&
+	     (!flag || value == oldalpha) ) {
+		return(0);
+	}
+
+	if(!(flag & SDL_RLEACCELOK) && (surface->flags & SDL_RLEACCEL))
+		SDL_UnRLESurface(surface, 1);
+
+	if ( flag ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+
+		surface->flags |= SDL_SRCALPHA;
+		surface->format->alpha = value;
+		if ( (surface->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+			if ( (video->SetHWAlpha == NULL) ||
+			     (video->SetHWAlpha(this, surface, value) < 0) ) {
+				surface->flags &= ~SDL_HWACCEL;
+			}
+		}
+		if ( flag & SDL_RLEACCELOK ) {
+		        surface->flags |= SDL_RLEACCELOK;
+		} else {
+		        surface->flags &= ~SDL_RLEACCELOK;
+		}
+	} else {
+		surface->flags &= ~SDL_SRCALPHA;
+		surface->format->alpha = SDL_ALPHA_OPAQUE;
+	}
+	/*
+	 * The representation for software surfaces is independent of
+	 * per-surface alpha, so no need to invalidate the blit mapping
+	 * if just the alpha value was changed. (If either is 255, we still
+	 * need to invalidate.)
+	 */
+	if((surface->flags & SDL_HWACCEL) == SDL_HWACCEL
+	   || oldflags != surface->flags
+	   || (((oldalpha + 1) ^ (value + 1)) & 0x100))
+		SDL_InvalidateMap(surface->map);
+	return(0);
+}
+
+/*
+ * A function to calculate the intersection of two rectangles:
+ * return true if the rectangles intersect, false otherwise
+ */
+static __inline__
+SDL_bool SDL_IntersectRect(SDL_Rect *A, SDL_Rect *B, SDL_Rect *intersection)
+{
+	int Amin, Amax, Bmin, Bmax;
+
+	/* Horizontal intersection */
+	Amin = A->x;
+	Amax = Amin + A->w;
+	Bmin = B->x;
+	Bmax = Bmin + B->w;
+	if(Bmin > Amin)
+	        Amin = Bmin;
+	intersection->x = Amin;
+	if(Bmax < Amax)
+	        Amax = Bmax;
+	intersection->w = Amax - Amin > 0 ? Amax - Amin : 0;
+
+	/* Vertical intersection */
+	Amin = A->y;
+	Amax = Amin + A->h;
+	Bmin = B->y;
+	Bmax = Bmin + B->h;
+	if(Bmin > Amin)
+	        Amin = Bmin;
+	intersection->y = Amin;
+	if(Bmax < Amax)
+	        Amax = Bmax;
+	intersection->h = Amax - Amin > 0 ? Amax - Amin : 0;
+
+	return (intersection->w && intersection->h);
+}
+/*
+ * Set the clipping rectangle for a blittable surface
+ */
+SDL_bool SDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect)
+{
+	SDL_Rect full_rect;
+
+	/* Don't do anything if there's no surface to act on */
+	if ( ! surface ) {
+		return SDL_FALSE;
+	}
+
+	/* Set up the full surface rectangle */
+	full_rect.x = 0;
+	full_rect.y = 0;
+	full_rect.w = surface->w;
+	full_rect.h = surface->h;
+
+	/* Set the clipping rectangle */
+	if ( ! rect ) {
+		surface->clip_rect = full_rect;
+		return 1;
+	}
+	return SDL_IntersectRect(rect, &full_rect, &surface->clip_rect);
+}
+void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect)
+{
+	if ( surface && rect ) {
+		*rect = surface->clip_rect;
+	}
+}
+/* 
+ * Set up a blit between two surfaces -- split into three parts:
+ * The upper part, SDL_UpperBlit(), performs clipping and rectangle 
+ * verification.  The lower part is a pointer to a low level
+ * accelerated blitting function.
+ *
+ * These parts are separated out and each used internally by this 
+ * library in the optimimum places.  They are exported so that if
+ * you know exactly what you are doing, you can optimize your code
+ * by calling the one(s) you need.
+ */
+int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect,
+				SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	SDL_blit do_blit;
+
+	/* Check to make sure the blit mapping is valid */
+	if ( (src->map->dst != dst) ||
+             (src->map->dst->format_version != src->map->format_version) ) {
+		if ( SDL_MapSurface(src, dst) < 0 ) {
+			return(-1);
+		}
+	}
+
+	/* Figure out which blitter to use */
+	if ( (src->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+		do_blit = src->map->hw_blit;
+	} else {
+		do_blit = src->map->sw_blit;
+	}
+	return(do_blit(src, srcrect, dst, dstrect));
+}
+
+
+int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect,
+		   SDL_Surface *dst, SDL_Rect *dstrect)
+{
+        SDL_Rect fulldst;
+	int srcx, srcy, w, h;
+
+	/* Make sure the surfaces aren't locked */
+	if ( ! src || ! dst ) {
+		SDL_SetError("SDL_UpperBlit: passed a NULL surface");
+		return(-1);
+	}
+	if ( src->locked || dst->locked ) {
+		SDL_SetError("Surfaces must not be locked during blit");
+		return(-1);
+	}
+
+	/* If the destination rectangle is NULL, use the entire dest surface */
+	if ( dstrect == NULL ) {
+	        fulldst.x = fulldst.y = 0;
+		dstrect = &fulldst;
+	}
+
+	/* clip the source rectangle to the source surface */
+	if(srcrect) {
+	        int maxw, maxh;
+	
+		srcx = srcrect->x;
+		w = srcrect->w;
+		if(srcx < 0) {
+		        w += srcx;
+			dstrect->x -= srcx;
+			srcx = 0;
+		}
+		maxw = src->w - srcx;
+		if(maxw < w)
+			w = maxw;
+
+		srcy = srcrect->y;
+		h = srcrect->h;
+		if(srcy < 0) {
+		        h += srcy;
+			dstrect->y -= srcy;
+			srcy = 0;
+		}
+		maxh = src->h - srcy;
+		if(maxh < h)
+			h = maxh;
+	    
+	} else {
+	        srcx = srcy = 0;
+		w = src->w;
+		h = src->h;
+	}
+
+	/* clip the destination rectangle against the clip rectangle */
+	{
+	        SDL_Rect *clip = &dst->clip_rect;
+		int dx, dy;
+
+		dx = clip->x - dstrect->x;
+		if(dx > 0) {
+			w -= dx;
+			dstrect->x += dx;
+			srcx += dx;
+		}
+		dx = dstrect->x + w - clip->x - clip->w;
+		if(dx > 0)
+			w -= dx;
+
+		dy = clip->y - dstrect->y;
+		if(dy > 0) {
+			h -= dy;
+			dstrect->y += dy;
+			srcy += dy;
+		}
+		dy = dstrect->y + h - clip->y - clip->h;
+		if(dy > 0)
+			h -= dy;
+	}
+
+	if(w > 0 && h > 0) {
+	        SDL_Rect sr;
+	        sr.x = srcx;
+		sr.y = srcy;
+		sr.w = dstrect->w = w;
+		sr.h = dstrect->h = h;
+		return SDL_LowerBlit(src, &sr, dst, dstrect);
+	}
+	dstrect->w = dstrect->h = 0;
+	return 0;
+}
+
+/* 
+ * This function performs a fast fill of the given rectangle with 'color'
+ */
+int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	int x, y;
+	Uint8 *row;
+
+	/* If 'dstrect' == NULL, then fill the whole surface */
+	if ( dstrect ) {
+		/* Perform clipping */
+		if ( !SDL_IntersectRect(dstrect, &dst->clip_rect, dstrect) ) {
+			return(0);
+		}
+	} else {
+		dstrect = &dst->clip_rect;
+	}
+
+	/* Check for hardware acceleration */
+	if ( ((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) &&
+					video->info.blit_fill ) {
+		return(video->FillHWRect(this, dst, dstrect, color));
+	}
+
+	/* Perform software fill */
+	if ( SDL_LockSurface(dst) != 0 ) {
+		return(-1);
+	}
+	row = (Uint8 *)dst->pixels+dstrect->y*dst->pitch+
+			dstrect->x*dst->format->BytesPerPixel;
+	if ( dst->format->palette || (color == 0) ) {
+		x = dstrect->w*dst->format->BytesPerPixel;
+		if ( !color && !((long)row&3) && !(x&3) && !(dst->pitch&3) ) {
+			int n = x >> 2;
+			for ( y=dstrect->h; y; --y ) {
+				SDL_memset4(row, 0, n);
+				row += dst->pitch;
+			}
+		} else {
+#ifdef __powerpc__
+			/*
+			 * memset() on PPC (both glibc and codewarrior) uses
+			 * the dcbz (Data Cache Block Zero) instruction, which
+			 * causes an alignment exception if the destination is
+			 * uncachable, so only use it on software surfaces
+			 */
+			if((dst->flags & SDL_HWSURFACE) == SDL_HWSURFACE) {
+				if(dstrect->w >= 8) {
+					/*
+					 * 64-bit stores are probably most
+					 * efficient to uncached video memory
+					 */
+					double fill;
+					memset(&fill, color, (sizeof fill));
+					for(y = dstrect->h; y; y--) {
+						Uint8 *d = row;
+						unsigned n = x;
+						unsigned nn;
+						Uint8 c = color;
+						double f = fill;
+						while((unsigned long)d
+						      & (sizeof(double) - 1)) {
+							*d++ = c;
+							n--;
+						}
+						nn = n / (sizeof(double) * 4);
+						while(nn) {
+							((double *)d)[0] = f;
+							((double *)d)[1] = f;
+							((double *)d)[2] = f;
+							((double *)d)[3] = f;
+							d += 4*sizeof(double);
+							nn--;
+						}
+						n &= ~(sizeof(double) * 4 - 1);
+						nn = n / sizeof(double);
+						while(nn) {
+							*(double *)d = f;
+							d += sizeof(double);
+							nn--;
+						}
+						n &= ~(sizeof(double) - 1);
+						while(n) {
+							*d++ = c;
+							n--;
+						}
+						row += dst->pitch;
+					}
+				} else {
+					/* narrow boxes */
+					for(y = dstrect->h; y; y--) {
+						Uint8 *d = row;
+						Uint8 c = color;
+						int n = x;
+						while(n) {
+							*d++ = c;
+							n--;
+						}
+						row += dst->pitch;
+					}
+				}
+			} else
+#endif /* __powerpc__ */
+			{
+				for(y = dstrect->h; y; y--) {
+					memset(row, color, x);
+					row += dst->pitch;
+				}
+			}
+		}
+	} else {
+		switch (dst->format->BytesPerPixel) {
+		    case 2:
+			for ( y=dstrect->h; y; --y ) {
+				Uint16 *pixels = (Uint16 *)row;
+				Uint16 c = color;
+				Uint32 cc = (Uint32)c << 16 | c;
+				int n = dstrect->w;
+				if((unsigned long)pixels & 3) {
+					*pixels++ = c;
+					n--;
+				}
+				if(n >> 1)
+					SDL_memset4(pixels, cc, n >> 1);
+				if(n & 1)
+					pixels[n - 1] = c;
+				row += dst->pitch;
+			}
+			break;
+
+		    case 3:
+			if(SDL_BYTEORDER == SDL_BIG_ENDIAN)
+				color <<= 8;
+			for ( y=dstrect->h; y; --y ) {
+				Uint8 *pixels = row;
+				for ( x=dstrect->w; x; --x ) {
+					memcpy(pixels, &color, 3);
+					pixels += 3;
+				}
+				row += dst->pitch;
+			}
+			break;
+
+		    case 4:
+			for(y = dstrect->h; y; --y) {
+				SDL_memset4(row, color, dstrect->w);
+				row += dst->pitch;
+			}
+			break;
+		}
+	}
+	SDL_UnlockSurface(dst);
+
+	/* We're done! */
+	return(0);
+}
+
+/*
+ * Lock a surface to directly access the pixels
+ * -- Do not call this from any blit function, as SDL_DrawCursor() may recurse
+ *    Instead, use:
+ *    if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE )
+ *               video->LockHWSurface(video, surface);
+ */
+int SDL_LockSurface (SDL_Surface *surface)
+{
+	if ( ! surface->locked ) {
+		/* Perform the lock */
+		if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+			SDL_VideoDevice *video = current_video;
+			SDL_VideoDevice *this  = current_video;
+			if ( video->LockHWSurface(this, surface) < 0 ) {
+				return(-1);
+			}
+		}
+		if ( surface->flags & SDL_RLEACCEL ) {
+			SDL_UnRLESurface(surface, 1);
+			surface->flags |= SDL_RLEACCEL;	/* save accel'd state */
+		}
+		/* This needs to be done here in case pixels changes value */
+		surface->pixels = (Uint8 *)surface->pixels + surface->offset;
+	}
+
+	/* Increment the surface lock count, for recursive locks */
+	++surface->locked;
+
+	/* Ready to go.. */
+	return(0);
+}
+/*
+ * Unlock a previously locked surface
+ * -- Do not call this from any blit function, as SDL_DrawCursor() may recurse
+ *    Instead, use:
+ *    if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE )
+ *               video->UnlockHWSurface(video, surface);
+ */
+void SDL_UnlockSurface (SDL_Surface *surface)
+{
+	/* Only perform an unlock if we are locked */
+	if ( ! surface->locked || (--surface->locked > 0) ) {
+		return;
+	}
+
+	/* Perform the unlock */
+	surface->pixels = (Uint8 *)surface->pixels - surface->offset;
+
+	/* Unlock hardware or accelerated surfaces */
+	if ( surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT) ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->UnlockHWSurface(this, surface);
+	} else {
+		/* Update RLE encoded surface with new data */
+		if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+		        surface->flags &= ~SDL_RLEACCEL; /* stop lying */
+			SDL_RLESurface(surface);
+		}
+	}
+}
+
+/* 
+ * Convert a surface into the specified pixel format.
+ */
+SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface,
+					SDL_PixelFormat *format, Uint32 flags)
+{
+	SDL_Surface *convert;
+	Uint32 colorkey = 0;
+	Uint8 alpha = 0;
+	Uint32 surface_flags;
+	SDL_Rect bounds;
+
+	/* Check for empty destination palette! (results in empty image) */
+	if ( format->palette != NULL ) {
+		int i;
+		for ( i=0; i<format->palette->ncolors; ++i ) {
+			if ( (format->palette->colors[i].r != 0) ||
+			     (format->palette->colors[i].g != 0) ||
+			     (format->palette->colors[i].b != 0) )
+				break;
+		}
+		if ( i == format->palette->ncolors ) {
+			SDL_SetError("Empty destination palette");
+			return(NULL);
+		}
+	}
+
+	/* Create a new surface with the desired format */
+	convert = SDL_CreateRGBSurface(flags,
+				surface->w, surface->h, format->BitsPerPixel,
+		format->Rmask, format->Gmask, format->Bmask, format->Amask);
+	if ( convert == NULL ) {
+		return(NULL);
+	}
+
+	/* Copy the palette if any */
+	if ( format->palette && convert->format->palette ) {
+		memcpy(convert->format->palette->colors,
+				format->palette->colors,
+				format->palette->ncolors*sizeof(SDL_Color));
+		convert->format->palette->ncolors = format->palette->ncolors;
+	}
+
+	/* Save the original surface color key and alpha */
+	surface_flags = surface->flags;
+	if ( (surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		/* Convert colourkeyed surfaces to RGBA if requested */
+		if((flags & SDL_SRCCOLORKEY) != SDL_SRCCOLORKEY
+		   && format->Amask) {
+			surface_flags &= ~SDL_SRCCOLORKEY;
+		} else {
+			colorkey = surface->format->colorkey;
+			SDL_SetColorKey(surface, 0, 0);
+		}
+	}
+	if ( (surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		alpha = surface->format->alpha;
+		SDL_SetAlpha(surface, 0, 0);
+	}
+
+	/* Copy over the image data */
+	bounds.x = 0;
+	bounds.y = 0;
+	bounds.w = surface->w;
+	bounds.h = surface->h;
+	SDL_LowerBlit(surface, &bounds, convert, &bounds);
+
+	/* Clean up the original surface, and update converted surface */
+	if ( convert != NULL ) {
+		SDL_SetClipRect(convert, &surface->clip_rect);
+	}
+	if ( (surface_flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		Uint32 cflags = surface_flags&(SDL_SRCCOLORKEY|SDL_RLEACCELOK);
+		if ( convert != NULL ) {
+			Uint8 keyR, keyG, keyB;
+
+			SDL_GetRGB(colorkey,surface->format,&keyR,&keyG,&keyB);
+			SDL_SetColorKey(convert, cflags|(flags&SDL_RLEACCELOK),
+				SDL_MapRGB(convert->format, keyR, keyG, keyB));
+		}
+		SDL_SetColorKey(surface, cflags, colorkey);
+	}
+	if ( (surface_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		Uint32 aflags = surface_flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
+		if ( convert != NULL ) {
+		        SDL_SetAlpha(convert, aflags|(flags&SDL_RLEACCELOK),
+				alpha);
+		}
+		SDL_SetAlpha(surface, aflags, alpha);
+	}
+
+	/* We're ready to go! */
+	return(convert);
+}
+
+/*
+ * Free a surface created by the above function.
+ */
+void SDL_FreeSurface (SDL_Surface *surface)
+{
+	/* Free anything that's not NULL, and not the screen surface */
+	if ((surface == NULL) ||
+	    (current_video &&
+	    ((surface == SDL_ShadowSurface)||(surface == SDL_VideoSurface)))) {
+		return;
+	}
+	if ( --surface->refcount > 0 ) {
+		return;
+	}
+	if ( (surface->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+	        SDL_UnRLESurface(surface, 0);
+	}
+	if ( surface->format ) {
+		SDL_FreeFormat(surface->format);
+		surface->format = NULL;
+	}
+	if ( surface->map != NULL ) {
+		SDL_FreeBlitMap(surface->map);
+		surface->map = NULL;
+	}
+	if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+		video->FreeHWSurface(this, surface);
+	}
+	if ( surface->pixels &&
+	     ((surface->flags & SDL_PREALLOC) != SDL_PREALLOC) ) {
+		free(surface->pixels);
+	}
+	free(surface);
+#ifdef CHECK_LEAKS
+	--surfaces_allocated;
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_sysvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,382 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_sysvideo_h
+#define _SDL_sysvideo_h
+
+#include "SDL_mouse.h"
+#define SDL_PROTOTYPES_ONLY
+#include "SDL_syswm.h"
+#undef SDL_PROTOTYPES_ONLY
+
+/* This file prototypes the video driver implementation.
+   This is designed to be easily converted to C++ in the future.
+ */
+
+/* OpenGL is pretty much available on all Windows systems */
+#ifdef WIN32
+#ifndef _WIN32_WCE
+#define HAVE_OPENGL
+#endif
+#include <windows.h>
+#endif
+
+#ifdef HAVE_OPENGL
+#ifdef MACOSX
+#include <OpenGL/gl.h>  /* OpenGL.framework */
+#else
+#include <GL/gl.h>
+#endif /* MACOSX */
+#endif /* HAVE_OPENGL */
+
+/* The SDL video driver */
+typedef struct SDL_VideoDevice SDL_VideoDevice;
+
+/* Define the SDL video driver structure */
+#define _THIS	SDL_VideoDevice *_this
+#ifndef _STATUS
+#define _STATUS	SDL_status *status
+#endif
+struct SDL_VideoDevice {
+	/* * * */
+	/* The name of this audio driver */
+	const char *name;
+
+	/* * * */
+	/* Initialization/Query functions */
+
+	/* Initialize the native video subsystem, filling 'vformat' with the 
+	   "best" display pixel format, returning 0 or -1 if there's an error.
+	 */
+	int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
+
+	/* List the available video modes for the given pixel format, sorted
+	   from largest to smallest.
+	 */
+	SDL_Rect **(*ListModes)(_THIS, SDL_PixelFormat *format, Uint32 flags);
+
+	/* Set the requested video mode, returning a surface which will be
+	   set to the SDL_VideoSurface.  The width and height will already
+	   be verified by ListModes(), and the video subsystem is free to
+	   set the mode to a supported bit depth different from the one
+	   specified -- the desired bpp will be emulated with a shadow
+	   surface if necessary.  If a new mode is returned, this function
+	   should take care of cleaning up the current mode.
+	 */
+	SDL_Surface *(*SetVideoMode)(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags);
+
+	/* Toggle the fullscreen mode */
+	int (*ToggleFullScreen)(_THIS, int on);
+
+	/* This is called after the video mode has been set, to get the
+	   initial mouse state.  It should queue events as necessary to
+	   properly represent the current mouse focus and position.
+	 */
+	void (*UpdateMouse)(_THIS);
+
+	/* Create a YUV video surface (possibly overlay) of the given
+	   format.  The hardware should be able to perform at least 2x
+	   scaling on display.
+	 */
+	SDL_Overlay *(*CreateYUVOverlay)(_THIS, int width, int height,
+	                                 Uint32 format, SDL_Surface *display);
+
+        /* Sets the color entries { firstcolor .. (firstcolor+ncolors-1) }
+	   of the physical palette to those in 'colors'. If the device is
+	   using a software palette (SDL_HWPALETTE not set), then the
+	   changes are reflected in the logical palette of the screen
+	   as well.
+	   The return value is 1 if all entries could be set properly
+	   or 0 otherwise.
+	*/
+	int (*SetColors)(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+
+	/* This pointer should exist in the native video subsystem and should
+	   point to an appropriate update function for the current video mode
+	 */
+	void (*UpdateRects)(_THIS, int numrects, SDL_Rect *rects);
+
+	/* Reverse the effects VideoInit() -- called if VideoInit() fails
+	   or if the application is shutting down the video subsystem.
+	*/
+	void (*VideoQuit)(_THIS);
+
+	/* * * */
+	/* Hardware acceleration functions */
+
+	/* Information about the video hardware */
+	SDL_VideoInfo info;
+
+	/* Allocates a surface in video memory */
+	int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
+
+	/* Sets the hardware accelerated blit function, if any, based
+	   on the current flags of the surface (colorkey, alpha, etc.)
+	 */
+	int (*CheckHWBlit)(_THIS, SDL_Surface *src, SDL_Surface *dst);
+
+	/* Fills a surface rectangle with the given color */
+	int (*FillHWRect)(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
+
+	/* Sets video mem colorkey and accelerated blit function */
+	int (*SetHWColorKey)(_THIS, SDL_Surface *surface, Uint32 key);
+
+	/* Sets per surface hardware alpha value */
+	int (*SetHWAlpha)(_THIS, SDL_Surface *surface, Uint8 value);
+
+	/* Returns a readable/writable surface */
+	int (*LockHWSurface)(_THIS, SDL_Surface *surface);
+	void (*UnlockHWSurface)(_THIS, SDL_Surface *surface);
+
+	/* Performs hardware flipping */
+	int (*FlipHWSurface)(_THIS, SDL_Surface *surface);
+
+	/* Frees a previously allocated video surface */
+	void (*FreeHWSurface)(_THIS, SDL_Surface *surface);
+
+	/* * * */
+	/* Gamma support */
+
+	Uint16 *gamma;
+
+	/* Set the gamma correction directly (emulated with gamma ramps) */
+	int (*SetGamma)(_THIS, float red, float green, float blue);
+
+	/* Get the gamma correction directly (emulated with gamma ramps) */
+	int (*GetGamma)(_THIS, float *red, float *green, float *blue);
+
+	/* Set the gamma ramp */
+	int (*SetGammaRamp)(_THIS, Uint16 *ramp);
+
+	/* Get the gamma ramp */
+	int (*GetGammaRamp)(_THIS, Uint16 *ramp);
+
+	/* * * */
+	/* OpenGL support */
+
+	/* Sets the dll to use for OpenGL and loads it */
+	int (*GL_LoadLibrary)(_THIS, const char *path);
+
+	/* Retrieves the address of a function in the gl library */
+	void* (*GL_GetProcAddress)(_THIS, const char *proc);
+
+        /* Get attribute information from the windowing system. */
+        int (*GL_GetAttribute)(_THIS, SDL_GLattr attrib, int* value);
+
+        /* Make the context associated with this driver current */
+        int (*GL_MakeCurrent)(_THIS);
+
+	/* Swap the current buffers in double buffer mode. */
+	void (*GL_SwapBuffers)(_THIS);
+
+  	/* OpenGL functions for SDL_OPENGLBLIT */
+#ifdef HAVE_OPENGL
+#ifndef WIN32
+#define WINAPI
+#endif
+#define SDL_PROC(ret,func,params) ret (WINAPI *func) params;
+#include "SDL_glfuncs.h"
+#undef SDL_PROC
+
+	/* Texture id */
+	GLuint texture;
+#endif
+	int is_32bit;
+ 
+	/* * * */
+	/* Window manager functions */
+
+	/* Set the title and icon text */
+	void (*SetCaption)(_THIS, const char *title, const char *icon);
+
+	/* Set the window icon image */
+	void (*SetIcon)(_THIS, SDL_Surface *icon, Uint8 *mask);
+
+	/* Iconify the window.
+	   This function returns 1 if there is a window manager and the
+	   window was actually iconified, it returns 0 otherwise.
+	*/
+	int (*IconifyWindow)(_THIS);
+
+	/* Grab or ungrab keyboard and mouse input */
+	SDL_GrabMode (*GrabInput)(_THIS, SDL_GrabMode mode);
+
+	/* Get some platform dependent window information */
+	int (*GetWMInfo)(_THIS, SDL_SysWMinfo *info);
+
+	/* * * */
+	/* Cursor manager functions */
+
+	/* Free a window manager cursor
+	   This function can be NULL if CreateWMCursor is also NULL.
+	 */
+	void (*FreeWMCursor)(_THIS, WMcursor *cursor);
+
+	/* If not NULL, create a black/white window manager cursor */
+	WMcursor *(*CreateWMCursor)(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+
+	/* Show the specified cursor, or hide if cursor is NULL */
+	int (*ShowWMCursor)(_THIS, WMcursor *cursor);
+
+	/* Warp the window manager cursor to (x,y)
+	   If NULL, a mouse motion event is posted internally.
+	 */
+	void (*WarpWMCursor)(_THIS, Uint16 x, Uint16 y);
+
+	/* If not NULL, this is called when a mouse motion event occurs */
+	void (*MoveWMCursor)(_THIS, int x, int y);
+
+	/* Determine whether the mouse should be in relative mode or not.
+	   This function is called when the input grab state or cursor
+	   visibility state changes.
+	   If the cursor is not visible, and the input is grabbed, the
+	   driver can place the mouse in relative mode, which may result
+	   in higher accuracy sampling of the pointer motion.
+	*/
+	void (*CheckMouseMode)(_THIS);
+
+	/* * * */
+	/* Event manager functions */
+
+	/* Initialize keyboard mapping for this driver */
+	void (*InitOSKeymap)(_THIS);
+
+	/* Handle any queued OS events */
+	void (*PumpEvents)(_THIS);
+
+	/* * * */
+	/* Data common to all drivers */
+	SDL_Surface *screen;
+	SDL_Surface *shadow;
+	SDL_Surface *visible;
+        SDL_Palette *physpal;	/* physical palette, if != logical palette */
+        SDL_Color *gammacols;	/* gamma-corrected colours, or NULL */
+	char *wm_title;
+	char *wm_icon;
+	int offset_x;
+	int offset_y;
+	SDL_GrabMode input_grab;
+
+	/* Driver information flags */
+	int handles_any_size;	/* Driver handles any size video mode */
+
+	/* * * */
+	/* Data used by the GL drivers */
+	struct {
+		int red_size;
+		int green_size;
+		int blue_size;
+		int alpha_size;
+		int depth_size;
+	        int buffer_size;
+		int stencil_size;
+		int double_buffer;
+                int accum_red_size;
+                int accum_green_size;
+                int accum_blue_size;
+                int accum_alpha_size;
+		int driver_loaded;
+		char driver_path[256];
+		void* dll_handle;
+	} gl_config;
+
+	/* * * */
+	/* Data private to this driver */
+	struct SDL_PrivateVideoData *hidden;
+	struct SDL_PrivateGLData *gl_data;
+
+	/* * * */
+	/* The function used to dispose of this structure */
+	void (*free)(_THIS);
+};
+#undef _THIS
+
+typedef struct VideoBootStrap {
+	const char *name;
+	const char *desc;
+	int (*available)(void);
+	SDL_VideoDevice *(*create)(int devindex);
+} VideoBootStrap;
+
+#ifdef ENABLE_X11
+extern VideoBootStrap X11_bootstrap;
+#endif
+#ifdef ENABLE_DGA
+extern VideoBootStrap DGA_bootstrap;
+#endif
+#ifdef ENABLE_FBCON
+extern VideoBootStrap FBCON_bootstrap;
+#endif
+#ifdef ENABLE_PS2GS
+extern VideoBootStrap PS2GS_bootstrap;
+#endif
+#ifdef ENABLE_GGI
+extern VideoBootStrap GGI_bootstrap;
+#endif
+#ifdef ENABLE_SVGALIB
+extern VideoBootStrap SVGALIB_bootstrap;
+#endif
+#ifdef ENABLE_AALIB
+extern VideoBootStrap AALIB_bootstrap;
+#endif
+#ifdef ENABLE_WINDIB
+extern VideoBootStrap WINDIB_bootstrap;
+#endif
+#ifdef ENABLE_DIRECTX
+extern VideoBootStrap DIRECTX_bootstrap;
+#endif
+#ifdef ENABLE_BWINDOW
+extern VideoBootStrap BWINDOW_bootstrap;
+#endif
+/* MacOS X gets the proper defines from configure */
+#if defined(macintosh) && !defined(MACOSX)
+#define ENABLE_TOOLBOX
+#if !TARGET_API_MAC_CARBON
+#define ENABLE_DRAWSPROCKET
+#endif
+#endif
+#ifdef ENABLE_TOOLBOX
+extern VideoBootStrap TOOLBOX_bootstrap;
+#endif
+#ifdef ENABLE_DRAWSPROCKET
+extern VideoBootStrap DSp_bootstrap;
+#endif
+#ifdef ENABLE_CYBERGRAPHICS
+extern VideoBootStrap CGX_bootstrap;
+#endif
+
+/* This is the current video device */
+extern SDL_VideoDevice *current_video;
+
+#define SDL_VideoSurface	(current_video->screen)
+#define SDL_ShadowSurface	(current_video->shadow)
+#define SDL_PublicSurface	(current_video->visible)
+
+#endif /* _SDL_sysvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_video.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1783 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* The high-level video driver subsystem */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_events.h"
+#include "SDL_mutex.h"
+#include "SDL_sysvideo.h"
+#include "SDL_sysevents.h"
+#include "SDL_blit.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+
+/* Available video drivers */
+static VideoBootStrap *bootstrap[] = {
+#ifdef ENABLE_X11
+	&X11_bootstrap,
+#endif
+#ifdef ENABLE_DGA
+	&DGA_bootstrap,
+#endif
+#ifdef ENABLE_FBCON
+	&FBCON_bootstrap,
+#endif
+#ifdef ENABLE_PS2GS
+	&PS2GS_bootstrap,
+#endif
+#ifdef ENABLE_GGI
+	&GGI_bootstrap,
+#endif
+#ifdef ENABLE_SVGALIB
+	&SVGALIB_bootstrap,
+#endif
+#ifdef ENABLE_AALIB
+    &AALIB_bootstrap,
+#endif
+#ifdef ENABLE_DIRECTX
+	&DIRECTX_bootstrap,
+#endif
+#ifdef ENABLE_WINDIB
+	&WINDIB_bootstrap,
+#endif
+#ifdef ENABLE_BWINDOW
+	&BWINDOW_bootstrap,
+#endif
+#ifdef ENABLE_TOOLBOX
+	&TOOLBOX_bootstrap,
+#endif
+#ifdef ENABLE_DRAWSPROCKET
+	&DSp_bootstrap,
+#endif
+#ifdef ENABLE_CYBERGRAPHICS
+	&CGX_bootstrap,
+#endif
+	NULL
+};
+SDL_VideoDevice *current_video = NULL;
+
+/* Places to store title and icon text for the app */
+static char *wm_title = NULL;
+static char *wm_icon  = NULL;
+
+/* Various local functions */
+int SDL_VideoInit(const char *driver_name, Uint32 flags);
+void SDL_VideoQuit(void);
+void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects);
+
+static SDL_GrabMode SDL_WM_GrabInputOff(void);
+#ifdef HAVE_OPENGL
+static int lock_count = 0;
+#endif
+
+
+/*
+ * Initialize the video and event subsystems -- determine native pixel format
+ */
+int SDL_VideoInit (const char *driver_name, Uint32 flags)
+{
+	SDL_VideoDevice *video;
+	int index;
+	int i;
+	SDL_PixelFormat vformat;
+	Uint32 video_flags;
+
+	/* Toggle the event thread flags, based on OS requirements */
+#if defined(MUST_THREAD_EVENTS)
+	flags |= SDL_INIT_EVENTTHREAD;
+#elif defined(CANT_THREAD_EVENTS)
+	if ( (flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD ) {
+		SDL_SetError("OS doesn't support threaded events");
+		return(-1);
+	}
+#endif
+
+	/* Check to make sure we don't overwrite 'current_video' */
+	if ( current_video != NULL ) {
+		SDL_VideoQuit();
+	}
+
+	/* Select the proper video driver */
+	index = 0;
+	video = NULL;
+	if ( driver_name != NULL ) {
+#if 0	/* This will be replaced with a better driver selection API */
+		if ( strrchr(driver_name, ':') != NULL ) {
+			index = atoi(strrchr(driver_name, ':')+1);
+		}
+#endif
+		for ( i=0; bootstrap[i]; ++i ) {
+			if ( strncmp(bootstrap[i]->name, driver_name,
+			             strlen(bootstrap[i]->name)) == 0 ) {
+				if ( bootstrap[i]->available() ) {
+					video = bootstrap[i]->create(index);
+					break;
+				}
+			}
+		}
+	} else {
+		for ( i=0; bootstrap[i]; ++i ) {
+			if ( bootstrap[i]->available() ) {
+				video = bootstrap[i]->create(index);
+				if ( video != NULL ) {
+					break;
+				}
+			}
+		}
+	}
+	if ( video == NULL ) {
+		SDL_SetError("No available video device");
+		return(-1);
+	}
+	current_video = video;
+	current_video->name = bootstrap[i]->name;
+
+	/* Do some basic variable initialization */
+	video->screen = NULL;
+	video->shadow = NULL;
+	video->visible = NULL;
+	video->physpal = NULL;
+	video->gammacols = NULL;
+	video->gamma = NULL;
+	video->wm_title = NULL;
+	video->wm_icon  = NULL;
+	video->offset_x = 0;
+	video->offset_y = 0;
+	memset(&video->info, 0, (sizeof video->info));
+
+	/* Set some very sane GL defaults */
+	video->gl_config.driver_loaded = 0;
+	video->gl_config.dll_handle = NULL;
+	video->gl_config.red_size = 5;
+#if 1 /* This seems to work on more video cards, as a default */
+	video->gl_config.green_size = 5;
+#else
+	video->gl_config.green_size = 6;
+#endif
+	video->gl_config.blue_size = 5;
+	video->gl_config.alpha_size = 0;
+	video->gl_config.buffer_size = 0;
+	video->gl_config.depth_size = 16;
+	video->gl_config.stencil_size = 0;
+	video->gl_config.double_buffer = 1;
+	video->gl_config.accum_red_size = 0;
+	video->gl_config.accum_green_size = 0;
+	video->gl_config.accum_blue_size = 0;
+	video->gl_config.accum_alpha_size = 0;
+	
+	/* Initialize the video subsystem */
+	memset(&vformat, 0, sizeof(vformat));
+	if ( video->VideoInit(video, &vformat) < 0 ) {
+		SDL_VideoQuit();
+		return(-1);
+	}
+
+	/* Create a zero sized video surface of the appropriate format */
+	video_flags = SDL_SWSURFACE;
+	SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0,
+				vformat.BitsPerPixel,
+				vformat.Rmask, vformat.Gmask, vformat.Bmask, 0);
+	if ( SDL_VideoSurface == NULL ) {
+		SDL_VideoQuit();
+		return(-1);
+	}
+	SDL_PublicSurface = NULL;	/* Until SDL_SetVideoMode() */
+
+#if 0 /* Don't change the current palette - may be used by other programs.
+       * The application can't do anything with the display surface until
+       * a video mode has been set anyway. :)
+       */
+	/* If we have a palettized surface, create a default palette */
+	if ( SDL_VideoSurface->format->palette ) {
+	        SDL_PixelFormat *vf = SDL_VideoSurface->format;
+		SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
+		video->SetColors(video,
+				 0, vf->palette->ncolors, vf->palette->colors);
+	}
+#endif
+	video->info.vfmt = SDL_VideoSurface->format;
+
+	/* Start the event loop */
+	if ( SDL_StartEventLoop(flags) < 0 ) {
+		SDL_VideoQuit();
+		return(-1);
+	}
+	SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD);
+
+	/* We're ready to go! */
+	return(0);
+}
+
+char *SDL_VideoDriverName(char *namebuf, int maxlen)
+{
+	if ( current_video != NULL ) {
+		strncpy(namebuf, current_video->name, maxlen-1);
+		namebuf[maxlen-1] = '\0';
+		return(namebuf);
+	}
+	return(NULL);
+}
+
+/*
+ * Get the current display surface
+ */
+SDL_Surface *SDL_GetVideoSurface(void)
+{
+	SDL_Surface *visible;
+
+	visible = NULL;
+	if ( current_video ) {
+		visible = current_video->visible;
+	}
+	return(visible);
+}
+
+/*
+ * Get the current information about the video hardware
+ */
+const SDL_VideoInfo *SDL_GetVideoInfo(void)
+{
+	const SDL_VideoInfo *info;
+
+	info = NULL;
+	if ( current_video ) {
+		info = &current_video->info;
+	}
+	return(info);
+}
+
+/*
+ * Return a pointer to an array of available screen dimensions for the
+ * given format, sorted largest to smallest.  Returns NULL if there are
+ * no dimensions available for a particular format, or (SDL_Rect **)-1
+ * if any dimension is okay for the given format.  If 'format' is NULL,
+ * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt
+ */
+SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	SDL_Rect **modes;
+
+	modes = NULL;
+	if ( SDL_VideoSurface ) {
+		if ( format == NULL ) {
+			format = SDL_VideoSurface->format;
+		}
+		modes = video->ListModes(this, format, flags);
+	}
+	return(modes);
+}
+
+/*
+ * Check to see if a particular video mode is supported.
+ * It returns 0 if the requested mode is not supported under any bit depth,
+ * or returns the bits-per-pixel of the closest available mode with the
+ * given width and height.  If this bits-per-pixel is different from the
+ * one used when setting the video mode, SDL_SetVideoMode() will succeed,
+ * but will emulate the requested bits-per-pixel with a shadow surface.
+ */
+static Uint8 SDL_closest_depths[4][8] = {
+	/* 8 bit closest depth ordering */
+	{ 0, 8, 16, 15, 32, 24, 0, 0 },
+	/* 15,16 bit closest depth ordering */
+	{ 0, 16, 15, 32, 24, 8, 0, 0 },
+	/* 24 bit closest depth ordering */
+	{ 0, 24, 32, 16, 15, 8, 0, 0 },
+	/* 32 bit closest depth ordering */
+	{ 0, 32, 16, 15, 24, 8, 0, 0 }
+};
+
+int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) 
+{
+	int table, b, i;
+	int supported;
+	SDL_PixelFormat format;
+	SDL_Rect **sizes;
+
+	/* Currently 1 and 4 bpp are not supported */
+	if ( bpp < 8 || bpp > 32 ) {
+		return(0);
+	}
+	if ( (width == 0) || (height == 0) ) {
+		return(0);
+	}
+
+	/* Search through the list valid of modes */
+	memset(&format, 0, sizeof(format));
+	supported = 0;
+	table = ((bpp+7)/8)-1;
+	SDL_closest_depths[table][0] = bpp;
+	SDL_closest_depths[table][7] = 0;
+	for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
+		format.BitsPerPixel = SDL_closest_depths[table][b];
+		sizes = SDL_ListModes(&format, flags);
+		if ( sizes == (SDL_Rect **)0 ) {
+			/* No sizes supported at this bit-depth */
+			continue;
+		} else 
+#ifdef macintosh /* MPW optimization bug? */
+		if ( (sizes == (SDL_Rect **)0xFFFFFFFF) ||
+#else
+		if ( (sizes == (SDL_Rect **)-1) ||
+#endif
+		     current_video->handles_any_size ) {
+			/* Any size supported at this bit-depth */
+			supported = 1;
+			continue;
+		} else
+		for ( i=0; sizes[i]; ++i ) {
+			if ((sizes[i]->w == width) && (sizes[i]->h == height)) {
+				supported = 1;
+				break;
+			}
+		}
+	}
+	if ( supported ) {
+		--b;
+		return(SDL_closest_depths[table][b]);
+	} else {
+		return(0);
+	}
+}
+
+/*
+ * Get the closest non-emulated video mode to the one requested
+ */
+static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags)
+{
+	int table, b, i;
+	int supported;
+	int native_bpp;
+	SDL_PixelFormat format;
+	SDL_Rect **sizes;
+
+	/* Try the original video mode, get the closest depth */
+	native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags);
+	if ( native_bpp == *BitsPerPixel ) {
+		return(1);
+	}
+	if ( native_bpp > 0 ) {
+		*BitsPerPixel = native_bpp;
+		return(1);
+	}
+
+	/* No exact size match at any depth, look for closest match */
+	memset(&format, 0, sizeof(format));
+	supported = 0;
+	table = ((*BitsPerPixel+7)/8)-1;
+	SDL_closest_depths[table][0] = *BitsPerPixel;
+	SDL_closest_depths[table][7] = SDL_VideoSurface->format->BitsPerPixel;
+	for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) {
+		format.BitsPerPixel = SDL_closest_depths[table][b];
+		sizes = SDL_ListModes(&format, flags);
+		if ( sizes == (SDL_Rect **)0 ) {
+			/* No sizes supported at this bit-depth */
+			continue;
+		}
+		for ( i=0; sizes[i]; ++i ) {
+			if ((sizes[i]->w < *w) || (sizes[i]->h < *h)) {
+				if ( i > 0 ) {
+					--i;
+					*w = sizes[i]->w;
+					*h = sizes[i]->h;
+					*BitsPerPixel = SDL_closest_depths[table][b];
+					supported = 1;
+				} else {
+					/* Largest mode too small... */;
+				}
+				break;
+			}
+		}
+		if ( (i > 0) && ! sizes[i] ) {
+			/* The smallest mode was larger than requested, OK */
+			--i;
+			*w = sizes[i]->w;
+			*h = sizes[i]->h;
+			*BitsPerPixel = SDL_closest_depths[table][b];
+			supported = 1;
+		}
+	}
+	if ( ! supported ) {
+		SDL_SetError("No video mode large enough for %dx%d", *w, *h);
+	}
+	return(supported);
+}
+
+/* This should probably go somewhere else -- like SDL_surface.c */
+static void SDL_ClearSurface(SDL_Surface *surface)
+{
+	Uint32 black;
+
+	black = SDL_MapRGB(surface->format, 0, 0, 0);
+	SDL_FillRect(surface, NULL, black);
+	if ((surface->flags&SDL_HWSURFACE) && (surface->flags&SDL_DOUBLEBUF)) {
+		SDL_Flip(surface);
+		SDL_FillRect(surface, NULL, black);
+	}
+	SDL_Flip(surface);
+}
+
+/*
+ * Create a shadow surface suitable for fooling the app. :-)
+ */
+static void SDL_CreateShadowSurface(int depth)
+{
+	Uint32 Rmask, Gmask, Bmask;
+
+	/* Allocate the shadow surface */
+	if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
+		Rmask = (SDL_VideoSurface->format)->Rmask;
+		Gmask = (SDL_VideoSurface->format)->Gmask;
+		Bmask = (SDL_VideoSurface->format)->Bmask;
+	} else {
+		Rmask = Gmask = Bmask = 0;
+	}
+	SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE,
+				SDL_VideoSurface->w, SDL_VideoSurface->h,
+						depth, Rmask, Gmask, Bmask, 0);
+	if ( SDL_ShadowSurface == NULL ) {
+		return;
+	}
+
+	/* 8-bit shadow surfaces report that they have exclusive palette */
+	if ( SDL_ShadowSurface->format->palette ) {
+		SDL_ShadowSurface->flags |= SDL_HWPALETTE;
+		if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) {
+			memcpy(SDL_ShadowSurface->format->palette->colors,
+				SDL_VideoSurface->format->palette->colors,
+				SDL_VideoSurface->format->palette->ncolors*
+							sizeof(SDL_Color));
+		} else {
+			SDL_DitherColors(
+			SDL_ShadowSurface->format->palette->colors, depth);
+		}
+	}
+
+	/* If the video surface is resizable, the shadow should say so */
+	if ( (SDL_VideoSurface->flags & SDL_RESIZABLE) == SDL_RESIZABLE ) {
+		SDL_ShadowSurface->flags |= SDL_RESIZABLE;
+	}
+	/* If the video surface has no frame, the shadow should say so */
+	if ( (SDL_VideoSurface->flags & SDL_NOFRAME) == SDL_NOFRAME ) {
+		SDL_ShadowSurface->flags |= SDL_NOFRAME;
+	}
+	/* If the video surface is fullscreen, the shadow should say so */
+	if ( (SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		SDL_ShadowSurface->flags |= SDL_FULLSCREEN;
+	}
+	/* If the video surface is flippable, the shadow should say so */
+	if ( (SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		SDL_ShadowSurface->flags |= SDL_DOUBLEBUF;
+	}
+	return;
+}
+
+/*
+ * Set the requested video mode, allocating a shadow buffer if necessary.
+ */
+SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
+{
+	SDL_VideoDevice *video, *this;
+	SDL_Surface *prev_mode, *mode;
+	int video_w;
+	int video_h;
+	int video_bpp;
+	int is_opengl;
+	SDL_GrabMode saved_grab;
+
+	/* Start up the video driver, if necessary..
+	   WARNING: This is the only function protected this way!
+	 */
+	if ( ! current_video ) {
+		if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0 ) {
+			return(NULL);
+		}
+	}
+	this = video = current_video;
+
+	/* Default to the current video bpp */
+	if ( bpp == 0 ) {
+		flags |= SDL_ANYFORMAT;
+		bpp = SDL_VideoSurface->format->BitsPerPixel;
+	}
+
+	/* Get a good video mode, the closest one possible */
+	video_w = width;
+	video_h = height;
+	video_bpp = bpp;
+	if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) {
+		return(NULL);
+	}
+
+	/* Check the requested flags */
+	/* There's no palette in > 8 bits-per-pixel mode */
+	if ( video_bpp > 8 ) {
+		flags &= ~SDL_HWPALETTE;
+	}
+#if 0
+	if ( (flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
+		/* There's no windowed double-buffering */
+		flags &= ~SDL_DOUBLEBUF;
+	}
+#endif
+	if ( (flags&SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		/* Use hardware surfaces when double-buffering */
+		flags |= SDL_HWSURFACE;
+	}
+
+	is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL );
+	if ( is_opengl ) {
+		/* These flags are for 2D video modes only */
+		flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
+	}
+
+	/* Clean up any previous video mode */
+	if ( SDL_PublicSurface != NULL ) {
+		SDL_PublicSurface = NULL;
+	}
+	if ( SDL_ShadowSurface != NULL ) {
+		SDL_Surface *ready_to_go;
+		ready_to_go = SDL_ShadowSurface;
+		SDL_ShadowSurface = NULL;
+		SDL_FreeSurface(ready_to_go);
+	}
+	if ( video->physpal ) {
+		free(video->physpal->colors);
+		free(video->physpal);
+		video->physpal = NULL;
+	}
+	if( video->gammacols) {
+	        free(video->gammacols);
+		video->gammacols = NULL;
+	}
+
+	/* Save the previous grab state and turn off grab for mode switch */
+	saved_grab = SDL_WM_GrabInputOff();
+
+	/* Try to set the video mode, along with offset and clipping */
+	prev_mode = SDL_VideoSurface;
+	SDL_LockCursor();
+	SDL_VideoSurface = NULL;	/* In case it's freed by driver */
+	mode = video->SetVideoMode(this, prev_mode,video_w,video_h,video_bpp,flags);
+	if ( mode ) { /* Prevent resize events from mode change */
+	    SDL_PrivateResize(mode->w, mode->h);
+        }
+	/*
+	 * rcg11292000
+	 * If you try to set an SDL_OPENGL surface, and fail to find a
+	 * matching  visual, then the next call to SDL_SetVideoMode()
+	 * will segfault, since  we no longer point to a dummy surface,
+	 * but rather NULL.
+	 * Sam 11/29/00
+	 * WARNING, we need to make sure that the previous mode hasn't
+	 * already been freed by the video driver.  What do we do in
+	 * that case?  Should we call SDL_VideoInit() again?
+	 */
+	SDL_VideoSurface = (mode != NULL) ? mode : prev_mode;
+
+	if ( (mode != NULL) && (!is_opengl) ) {
+		/* Sanity check */
+		if ( (mode->w < width) || (mode->h < height) ) {
+			SDL_SetError("Video mode smaller than requested");
+			return(NULL);
+		}
+
+		/* If we have a palettized surface, create a default palette */
+		if ( mode->format->palette ) {
+	        	SDL_PixelFormat *vf = mode->format;
+			SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel);
+			video->SetColors(this, 0, vf->palette->ncolors,
+			                           vf->palette->colors);
+		}
+
+		/* Clear the surface to black */
+		video->offset_x = 0;
+		video->offset_y = 0;
+		mode->offset = 0;
+		SDL_SetClipRect(mode, NULL);
+		SDL_ClearSurface(mode);
+
+		/* Now adjust the offsets to match the desired mode */
+		video->offset_x = (mode->w-width)/2;
+		video->offset_y = (mode->h-height)/2;
+		mode->offset = video->offset_y*mode->pitch +
+				video->offset_x*mode->format->BytesPerPixel;
+#ifdef DEBUG_VIDEO
+  fprintf(stderr,
+	"Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n",
+		width, height, bpp,
+		mode->w, mode->h, mode->format->BitsPerPixel, mode->offset);
+#endif
+		mode->w = width;
+		mode->h = height;
+		SDL_SetClipRect(mode, NULL);
+	}
+	SDL_ResetCursor();
+	SDL_UnlockCursor();
+
+	/* If we failed setting a video mode, return NULL... (Uh Oh!) */
+	if ( mode == NULL ) {
+		return(NULL);
+	}
+
+	/* If there is no window manager, set the SDL_NOFRAME flag */
+	if ( ! video->info.wm_available ) {
+		mode->flags |= SDL_NOFRAME;
+	}
+
+	/* Reset the mouse cursor and grab for new video mode */
+	SDL_SetCursor(NULL);
+	if ( video->UpdateMouse ) {
+		video->UpdateMouse(this);
+	}
+	SDL_WM_GrabInput(saved_grab);
+	SDL_GetRelativeMouseState(NULL, NULL); /* Clear first large delta */
+
+	/* If we're running OpenGL, make the context current */
+	if ( (video->screen->flags & SDL_OPENGL) &&
+	      video->GL_MakeCurrent ) {
+		if ( video->GL_MakeCurrent(this) < 0 ) {
+			return(NULL);
+		}
+	}
+
+	/* Set up a fake SDL surface for OpenGL "blitting" */
+	if ( (flags & SDL_OPENGLBLIT) == SDL_OPENGLBLIT ) {
+		/* Load GL functions for performing the texture updates */
+#ifdef HAVE_OPENGL
+#define SDL_PROC(ret,func,params) \
+do { \
+	video->func = SDL_GL_GetProcAddress(#func); \
+	if ( ! video->func ) { \
+		SDL_SetError("Couldn't load GL function: %s\n", #func); \
+		return(NULL); \
+	} \
+} while ( 0 );
+#include "SDL_glfuncs.h"
+#undef SDL_PROC	
+
+		/* Create a software surface for blitting */
+#ifdef GL_VERSION_1_2
+		/* If the implementation either supports the packed pixels
+		   extension, or implements the core OpenGL 1.2 API, it will
+		   support the GL_UNSIGNED_SHORT_5_6_5 texture format.
+		 */
+		if ( (bpp == 16) &&
+		     (strstr((const char *)video->glGetString(GL_EXTENSIONS),
+		                           "GL_EXT_packed_pixels") ||
+		     (strncmp((const char *)video->glGetString(GL_VERSION),
+		              "1.2", 3) == 0)) )
+		{
+			video->is_32bit = 0;
+			SDL_VideoSurface = SDL_CreateRGBSurface(
+				flags, 
+				width, 
+				height,  
+				16,
+				31 << 11,
+				63 << 5,
+				31,
+				0
+				);
+		}
+		else
+#endif /* OpenGL 1.2 */
+		{
+			video->is_32bit = 1;
+			SDL_VideoSurface = SDL_CreateRGBSurface(
+				flags, 
+				width, 
+				height, 
+				32, 
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+				0x000000FF,
+				0x0000FF00,
+				0x00FF0000,
+				0xFF000000
+#else
+				0xFF000000,
+				0x00FF0000,
+				0x0000FF00,
+				0x000000FF
+#endif
+				);
+		}
+		if ( ! SDL_VideoSurface ) {
+			return(NULL);
+		}
+		SDL_VideoSurface->flags = mode->flags | SDL_OPENGLBLIT;
+
+		/* Free the original video mode surface (is this safe?) */
+		SDL_FreeSurface(mode);
+
+                /* Set the surface completely opaque & white by default */
+		memset( SDL_VideoSurface->pixels, 255, SDL_VideoSurface->h * SDL_VideoSurface->pitch );
+		video->glGenTextures( 1, &video->texture );
+		video->glBindTexture( GL_TEXTURE_2D, video->texture );
+		video->glTexImage2D(
+			GL_TEXTURE_2D,
+			0,
+			video->is_32bit ? GL_RGBA : GL_RGB,
+			256,
+			256,
+			0,
+			video->is_32bit ? GL_RGBA : GL_RGB,
+#ifdef GL_VERSION_1_2
+			video->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
+#else
+			GL_UNSIGNED_BYTE,
+#endif
+			NULL);
+
+		video->UpdateRects = SDL_GL_UpdateRectsLock;
+#else
+		SDL_SetError("Somebody forgot to #define HAVE_OPENGL");
+		return(NULL);
+#endif
+	}
+
+	/* Create a shadow surface if necessary */
+	/* There are three conditions under which we create a shadow surface:
+		1.  We need a particular bits-per-pixel that we didn't get.
+		2.  We need a hardware palette and didn't get one.
+		3.  We need a software surface and got a hardware surface.
+	*/
+	if ( !(SDL_VideoSurface->flags & SDL_OPENGL) &&
+	     (
+	     (  !(flags&SDL_ANYFORMAT) &&
+			(SDL_VideoSurface->format->BitsPerPixel != bpp)) ||
+	     (   (flags&SDL_HWPALETTE) && 
+				!(SDL_VideoSurface->flags&SDL_HWPALETTE)) ||
+		/* If the surface is in hardware, video writes are visible
+		   as soon as they are performed, so we need to buffer them
+		 */
+	     (   ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) &&
+				(SDL_VideoSurface->flags&SDL_HWSURFACE))
+	     ) ) {
+		SDL_CreateShadowSurface(bpp);
+		if ( SDL_ShadowSurface == NULL ) {
+			SDL_SetError("Couldn't create shadow surface");
+			return(NULL);
+		}
+		SDL_PublicSurface = SDL_ShadowSurface;
+	} else {
+		SDL_PublicSurface = SDL_VideoSurface;
+	}
+	video->info.vfmt = SDL_VideoSurface->format;
+
+	/* We're done! */
+	return(SDL_PublicSurface);
+}
+
+/* 
+ * Convert a surface into the video pixel format.
+ */
+SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
+{
+	Uint32 flags;
+
+	if ( ! SDL_PublicSurface ) {
+		SDL_SetError("No video mode has been set");
+		return(NULL);
+	}
+	/* Set the flags appropriate for copying to display surface */
+	flags  = (SDL_PublicSurface->flags&SDL_HWSURFACE);
+#ifdef AUTORLE_DISPLAYFORMAT
+	flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA));
+	flags |= SDL_RLEACCELOK;
+#else
+	flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK);
+#endif
+	return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags));
+}
+
+/*
+ * Convert a surface into a format that's suitable for blitting to
+ * the screen, but including an alpha channel.
+ */
+SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface)
+{
+	SDL_PixelFormat *vf;
+	SDL_PixelFormat *format;
+	SDL_Surface *converted;
+	Uint32 flags;
+	/* default to ARGB8888 */
+	Uint32 amask = 0xff000000;
+	Uint32 rmask = 0x00ff0000;
+	Uint32 gmask = 0x0000ff00;
+	Uint32 bmask = 0x000000ff;
+
+	if ( ! SDL_PublicSurface ) {
+		SDL_SetError("No video mode has been set");
+		return(NULL);
+	}
+	vf = SDL_PublicSurface->format;
+
+	switch(vf->BytesPerPixel) {
+	    case 2:
+		/* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}.
+		   For anything else (like ARGB4444) it doesn't matter
+		   since we have no special code for it anyway */
+		if ( (vf->Rmask == 0x1f) &&
+		     (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) {
+			rmask = 0xff;
+			bmask = 0xff0000;
+		}
+		break;
+
+	    case 3:
+	    case 4:
+		/* Keep the video format, as long as the high 8 bits are
+		   unused or alpha */
+		if ( (vf->Rmask == 0xff) && (vf->Bmask == 0xff0000) ) {
+			rmask = 0xff;
+			bmask = 0xff0000;
+		}
+		break;
+
+	    default:
+		/* We have no other optimised formats right now. When/if a new
+		   optimised alpha format is written, add the converter here */
+		break;
+	}
+	format = SDL_AllocFormat(32, rmask, gmask, bmask, amask);
+	flags = SDL_PublicSurface->flags & SDL_HWSURFACE;
+	flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK);
+	converted = SDL_ConvertSurface(surface, format, flags);
+	SDL_FreeFormat(format);
+	return(converted);
+}
+
+/*
+ * Update a specific portion of the physical screen
+ */
+void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h)
+{
+	if ( screen ) {
+		SDL_Rect rect;
+
+		/* Perform some checking */
+		if ( w == 0 )
+			w = screen->w;
+		if ( h == 0 )
+			h = screen->h;
+		if ( (int)(x+w) > screen->w )
+			return;
+		if ( (int)(y+h) > screen->h )
+			return;
+
+		/* Fill the rectangle */
+		rect.x = x;
+		rect.y = y;
+		rect.w = w;
+		rect.h = h;
+		SDL_UpdateRects(screen, 1, &rect);
+	}
+}
+void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
+{
+	int i;
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this = current_video;
+
+	if ( screen == SDL_ShadowSurface ) {
+		/* Blit the shadow surface using saved mapping */
+	        SDL_Palette *pal = screen->format->palette;
+		SDL_Color *saved_colors = NULL;
+	        if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
+			/* simulated 8bpp, use correct physical palette */
+			saved_colors = pal->colors;
+			if ( video->gammacols ) {
+				/* gamma-corrected palette */
+				pal->colors = video->gammacols;
+			} else if ( video->physpal ) {
+				/* physical palette different from logical */
+				pal->colors = video->physpal->colors;
+			}
+		}
+		if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) {
+			SDL_LockCursor();
+			SDL_DrawCursor(SDL_ShadowSurface);
+			for ( i=0; i<numrects; ++i ) {
+				SDL_LowerBlit(SDL_ShadowSurface, &rects[i], 
+						SDL_VideoSurface, &rects[i]);
+			}
+			SDL_EraseCursor(SDL_ShadowSurface);
+			SDL_UnlockCursor();
+		} else {
+			for ( i=0; i<numrects; ++i ) {
+				SDL_LowerBlit(SDL_ShadowSurface, &rects[i], 
+						SDL_VideoSurface, &rects[i]);
+			}
+		}
+		if ( saved_colors )
+			pal->colors = saved_colors;
+
+		/* Fall through to video surface update */
+		screen = SDL_VideoSurface;
+	}
+	if ( screen == SDL_VideoSurface ) {
+		/* Update the video surface */
+		if ( screen->offset ) {
+			for ( i=0; i<numrects; ++i ) {
+				rects[i].x += video->offset_x;
+				rects[i].y += video->offset_y;
+			}
+			video->UpdateRects(this, numrects, rects);
+			for ( i=0; i<numrects; ++i ) {
+				rects[i].x -= video->offset_x;
+				rects[i].y -= video->offset_y;
+			}
+		} else {
+			video->UpdateRects(this, numrects, rects);
+		}
+	}
+}
+
+/*
+ * Performs hardware double buffering, if possible, or a full update if not.
+ */
+int SDL_Flip(SDL_Surface *screen)
+{
+	SDL_VideoDevice *video = current_video;
+	/* Copy the shadow surface to the video surface */
+	if ( screen == SDL_ShadowSurface ) {
+		SDL_Rect rect;
+	        SDL_Palette *pal = screen->format->palette;
+		SDL_Color *saved_colors = NULL;
+	        if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) {
+			/* simulated 8bpp, use correct physical palette */
+			saved_colors = pal->colors;
+			if ( video->gammacols ) {
+				/* gamma-corrected palette */
+				pal->colors = video->gammacols;
+			} else if ( video->physpal ) {
+				/* physical palette different from logical */
+				pal->colors = video->physpal->colors;
+			}
+		}
+
+		rect.x = 0;
+		rect.y = 0;
+		rect.w = screen->w;
+		rect.h = screen->h;
+		SDL_LowerBlit(SDL_ShadowSurface,&rect, SDL_VideoSurface,&rect);
+
+		if ( saved_colors )
+			pal->colors = saved_colors;
+		screen = SDL_VideoSurface;
+	}
+	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		SDL_VideoDevice *this  = current_video;
+		return(video->FlipHWSurface(this, SDL_VideoSurface));
+	} else {
+		SDL_UpdateRect(screen, 0, 0, 0, 0);
+	}
+	return(0);
+}
+
+static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors,
+			       int firstcolor, int ncolors)
+{
+        SDL_Palette *pal = screen->format->palette;
+	SDL_Palette *vidpal;
+
+	if ( colors != (pal->colors + firstcolor) ) {
+	        memcpy(pal->colors + firstcolor, colors,
+		       ncolors * sizeof(*colors));
+	}
+
+	vidpal = SDL_VideoSurface->format->palette;
+	if ( (screen == SDL_ShadowSurface) && vidpal ) {
+	        /*
+		 * This is a shadow surface, and the physical
+		 * framebuffer is also indexed. Propagate the
+		 * changes to its logical palette so that
+		 * updates are always identity blits
+		 */
+		memcpy(vidpal->colors + firstcolor, colors,
+		       ncolors * sizeof(*colors));
+	}
+	SDL_FormatChanged(screen);
+}
+
+static int SetPalette_physical(SDL_Surface *screen,
+                               SDL_Color *colors, int firstcolor, int ncolors)
+{
+	SDL_VideoDevice *video = current_video;
+	int gotall = 1;
+
+	if ( video->physpal ) {
+		/* We need to copy the new colors, since we haven't
+		 * already done the copy in the logical set above.
+		 */
+		memcpy(video->physpal->colors + firstcolor,
+		       colors, ncolors * sizeof(*colors));
+	}
+	if ( screen == SDL_ShadowSurface ) {
+		if ( SDL_VideoSurface->flags & SDL_HWPALETTE ) {
+			/*
+			 * The real screen is also indexed - set its physical
+			 * palette. The physical palette does not include the
+			 * gamma modification, we apply it directly instead,
+			 * but this only happens if we have hardware palette.
+			 */
+			screen = SDL_VideoSurface;
+		} else {
+			/*
+			 * The video surface is not indexed - invalidate any
+			 * active shadow-to-video blit mappings.
+			 */
+			if ( screen->map->dst == SDL_VideoSurface ) {
+				SDL_InvalidateMap(screen->map);
+			}
+			if ( video->gamma ) {
+				if( ! video->gammacols ) {
+					SDL_Palette *pp = video->physpal;
+					if(!pp)
+						pp = screen->format->palette;
+					video->gammacols = malloc(pp->ncolors
+							  * sizeof(SDL_Color));
+					SDL_ApplyGamma(video->gamma,
+						       pp->colors,
+						       video->gammacols,
+						       pp->ncolors);
+				} else {
+					SDL_ApplyGamma(video->gamma, colors,
+						       video->gammacols
+						       + firstcolor,
+						       ncolors);
+				}
+			}
+			SDL_UpdateRect(screen, 0, 0, 0, 0);
+		}
+	}
+
+	if ( screen == SDL_VideoSurface ) {
+		SDL_Color gcolors[256];
+
+	        if ( video->gamma ) {
+		        SDL_ApplyGamma(video->gamma, colors, gcolors, ncolors);
+			colors = gcolors;
+		}
+		gotall = video->SetColors(video, firstcolor, ncolors, colors);
+		if ( ! gotall ) {
+			/* The video flags shouldn't have SDL_HWPALETTE, and
+			   the video driver is responsible for copying back the
+			   correct colors into the video surface palette.
+			*/
+			;
+		}
+		SDL_CursorPaletteChanged();
+	}
+	return gotall;
+}
+
+/*
+ * Set the physical and/or logical colormap of a surface:
+ * Only the screen has a physical colormap. It determines what is actually
+ * sent to the display.
+ * The logical colormap is used to map blits to/from the surface.
+ * 'which' is one or both of SDL_LOGPAL, SDL_PHYSPAL
+ *
+ * Return nonzero if all colours were set as requested, or 0 otherwise.
+ */
+int SDL_SetPalette(SDL_Surface *screen, int which,
+		   SDL_Color *colors, int firstcolor, int ncolors)
+{
+        SDL_Palette *pal;
+	int gotall;
+	int palsize;
+
+	if ( screen != SDL_PublicSurface ) {
+	        /* only screens have physical palettes */
+	        which &= ~SDL_PHYSPAL;
+	} else if( (screen->flags & SDL_HWPALETTE) != SDL_HWPALETTE ) {
+	        /* hardware palettes required for split colormaps */
+	        which |= SDL_PHYSPAL | SDL_LOGPAL;
+	}
+
+	/* Verify the parameters */
+	pal = screen->format->palette;
+	if( !pal ) {
+	        return 0;	/* not a palettized surface */
+	}
+	gotall = 1;
+	palsize = 1 << screen->format->BitsPerPixel;
+	if ( ncolors > (palsize - firstcolor) ) {
+	        ncolors = (palsize - firstcolor);
+		gotall = 0;
+	}
+
+	if ( which & SDL_LOGPAL ) {
+		/*
+		 * Logical palette change: The actual screen isn't affected,
+		 * but the internal colormap is altered so that the
+		 * interpretation of the pixel values (for blits etc) is
+		 * changed.
+		 */
+	        SetPalette_logical(screen, colors, firstcolor, ncolors);
+	}
+	if ( which & SDL_PHYSPAL ) {
+		SDL_VideoDevice *video = current_video;
+	        /*
+		 * Physical palette change: This doesn't affect the
+		 * program's idea of what the screen looks like, but changes
+		 * its actual appearance.
+		 */
+	        if(!video)
+		        return gotall;	/* video not yet initialized */
+		if(!video->physpal && !(which & SDL_LOGPAL) ) {
+			/* Lazy physical palette allocation */
+		        int size;
+			SDL_Palette *pp = malloc(sizeof(*pp));
+			current_video->physpal = pp;
+			pp->ncolors = pal->ncolors;
+			size = pp->ncolors * sizeof(SDL_Color);
+			pp->colors = malloc(size);
+			memcpy(pp->colors, pal->colors, size);
+		}
+		if ( ! SetPalette_physical(screen,
+		                           colors, firstcolor, ncolors) ) {
+			gotall = 0;
+		}
+	}
+	return gotall;
+}
+
+int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor,
+		  int ncolors)
+{
+        return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL,
+			      colors, firstcolor, ncolors);
+}
+
+/*
+ * Clean up the video subsystem
+ */
+void SDL_VideoQuit (void)
+{
+	SDL_Surface *ready_to_go;
+
+	if ( current_video ) {
+		SDL_VideoDevice *video = current_video;
+		SDL_VideoDevice *this  = current_video;
+
+		/* Halt event processing before doing anything else */
+		SDL_StopEventLoop();
+
+		/* Clean up allocated window manager items */
+		if ( SDL_PublicSurface ) {
+			SDL_PublicSurface = NULL;
+		}
+		SDL_CursorQuit();
+
+		/* Just in case... */
+		SDL_WM_GrabInputOff();
+
+		/* Clean up the system video */
+		video->VideoQuit(this);
+
+		/* Free any lingering surfaces */
+		ready_to_go = SDL_ShadowSurface;
+		SDL_ShadowSurface = NULL;
+		SDL_FreeSurface(ready_to_go);
+		if ( SDL_VideoSurface != NULL ) {
+			ready_to_go = SDL_VideoSurface;
+			SDL_VideoSurface = NULL;
+			SDL_FreeSurface(ready_to_go);
+		}
+		SDL_PublicSurface = NULL;
+
+		/* Clean up miscellaneous memory */
+		if ( video->physpal ) {
+			free(video->physpal->colors);
+			free(video->physpal);
+			video->physpal = NULL;
+		}
+		if ( video->gammacols ) {
+			free(video->gammacols);
+			video->gammacols = NULL;
+		}
+		if ( video->gamma ) {
+			free(video->gamma);
+			video->gamma = NULL;
+		}
+		if ( wm_title != NULL ) {
+			free(wm_title);
+			wm_title = NULL;
+		}
+		if ( wm_icon != NULL ) {
+			free(wm_icon);
+			wm_icon = NULL;
+		}
+
+		/* Finish cleaning up video subsystem */
+		video->free(this);
+		current_video = NULL;
+	}
+	return;
+}
+
+/* Load the GL driver library */
+int SDL_GL_LoadLibrary(const char *path)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this = current_video;
+	int retval;
+
+	retval = -1;
+	if ( video->GL_LoadLibrary ) {
+		retval = video->GL_LoadLibrary(this, path);
+	} else {
+		SDL_SetError("No dynamic GL support in video driver");
+	}
+	return(retval);
+}
+
+void *SDL_GL_GetProcAddress(const char* proc)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this = current_video;
+	void *func;
+
+	func = NULL;
+	if ( video->GL_GetProcAddress ) {
+		if ( video->gl_config.driver_loaded ) {
+			func = video->GL_GetProcAddress(this, proc);
+		} else {
+			SDL_SetError("No GL driver has been loaded");
+		}
+	} else {
+		SDL_SetError("No dynamic GL support in video driver");
+	}
+	return func;
+}
+
+/* Set the specified GL attribute for setting up a GL video mode */
+int SDL_GL_SetAttribute( SDL_GLattr attr, int value )
+{
+	int retval;
+	SDL_VideoDevice *video = current_video;
+
+	retval = 0;
+	switch (attr) {
+		case SDL_GL_RED_SIZE:
+			video->gl_config.red_size = value;
+			break;
+		case SDL_GL_GREEN_SIZE:
+			video->gl_config.green_size = value;
+			break;
+		case SDL_GL_BLUE_SIZE:
+			video->gl_config.blue_size = value;
+			break;
+		case SDL_GL_ALPHA_SIZE:
+			video->gl_config.alpha_size = value;
+			break;
+		case SDL_GL_DOUBLEBUFFER:
+			video->gl_config.double_buffer = value;
+			break;
+        	case SDL_GL_BUFFER_SIZE:
+	        	video->gl_config.buffer_size = value;
+			break;
+		case SDL_GL_DEPTH_SIZE:
+			video->gl_config.depth_size = value;
+			break;
+		case SDL_GL_STENCIL_SIZE:
+			video->gl_config.stencil_size = value;
+			break;
+	        case SDL_GL_ACCUM_RED_SIZE:
+			video->gl_config.accum_red_size = value;
+			break;
+	        case SDL_GL_ACCUM_GREEN_SIZE:
+			video->gl_config.accum_green_size = value;
+			break;
+	        case SDL_GL_ACCUM_BLUE_SIZE:
+			video->gl_config.accum_blue_size = value;
+			break;
+	        case SDL_GL_ACCUM_ALPHA_SIZE:
+			video->gl_config.accum_alpha_size = value;
+			break;
+		default:
+			SDL_SetError("Unknown OpenGL attribute");
+			retval = -1;
+			break;
+	}
+	return(retval);
+}
+
+/* Retrieve an attribute value from the windowing system. */
+int SDL_GL_GetAttribute(SDL_GLattr attr, int* value)
+{
+	int retval = -1;
+	SDL_VideoDevice* video = current_video;
+	SDL_VideoDevice* this = current_video;
+
+	if ( video->GL_GetAttribute ) {
+		retval = this->GL_GetAttribute(this, attr, value);
+	}
+
+	return retval;
+}
+
+/* Perform a GL buffer swap on the current GL context */
+void SDL_GL_SwapBuffers(void)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this = current_video;
+
+	if ( video->screen->flags & SDL_OPENGL ) {
+		video->GL_SwapBuffers( this );
+	}
+}
+
+/* Update rects with locking */
+void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects)
+{
+	SDL_GL_Lock();
+ 	SDL_GL_UpdateRects(numrects, rects);
+	SDL_GL_Unlock();
+}
+
+/* Update rects without state setting and changing (the caller is responsible for it) */
+void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects)
+{
+#ifdef HAVE_OPENGL
+	SDL_VideoDevice *this = current_video;
+	SDL_Rect update, tmp;
+	int x, y, i;
+
+	for ( i = 0; i < numrects; i++ )
+	{
+		tmp.y = rects[i].y;
+		tmp.h = rects[i].h;
+		for ( y = 0; y <= rects[i].h / 256; y++ )
+		{
+			tmp.x = rects[i].x;
+			tmp.w = rects[i].w;
+			for ( x = 0; x <= rects[i].w / 256; x++ )
+			{
+				update.x = tmp.x;
+				update.y = tmp.y;
+				update.w = tmp.w;
+				update.h = tmp.h;
+
+				if ( update.w > 256 )
+					update.w = 256;
+
+				if ( update.h > 256 )
+					update.h = 256;
+			
+				this->glFlush();
+				this->glTexSubImage2D( 
+					GL_TEXTURE_2D, 
+					0, 
+					0, 
+					0, 
+					update.w, 
+					update.h, 
+					this->is_32bit? GL_RGBA : GL_RGB,
+#ifdef GL_VERSION_1_2
+					this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5,
+#else
+					GL_UNSIGNED_BYTE,
+#endif
+					(Uint8 *)this->screen->pixels + 
+						this->screen->format->BytesPerPixel * update.x + 
+						update.y * this->screen->pitch );
+	
+				this->glFlush();
+				/*
+				* Note the parens around the function name:
+				* This is because some OpenGL implementations define glTexCoord etc 
+				* as macros, and we don't want them expanded here.
+				*/
+				this->glBegin(GL_TRIANGLE_STRIP);
+					(this->glTexCoord2f)( 0.0, 0.0 );	
+					(this->glVertex2i)( update.x, update.y );
+					(this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 );	
+					(this->glVertex2i)( update.x + update.w, update.y );
+					(this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) );
+					(this->glVertex2i)( update.x, update.y + update.h );
+					(this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) );	
+					(this->glVertex2i)( update.x + update.w	, update.y + update.h );
+				this->glEnd();	
+			
+				tmp.x += 256;
+				tmp.w -= 256;
+			}
+			tmp.y += 256;
+			tmp.h -= 256;
+		}
+	}
+#endif
+}
+
+/* Lock == save current state */
+void SDL_GL_Lock()
+{
+#ifdef HAVE_OPENGL
+	lock_count--;
+	if (lock_count==-1)
+	{
+		SDL_VideoDevice *this = current_video;
+
+		this->glPushAttrib( GL_ALL_ATTRIB_BITS );	/* TODO: narrow range of what is saved */
+		this->glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT );
+
+		this->glEnable(GL_TEXTURE_2D);
+		this->glEnable(GL_BLEND);
+		this->glDisable(GL_FOG);
+		this->glDisable(GL_ALPHA_TEST);
+		this->glDisable(GL_DEPTH_TEST);
+		this->glDisable(GL_SCISSOR_TEST);	
+		this->glDisable(GL_STENCIL_TEST);
+		this->glDisable(GL_CULL_FACE);
+
+		this->glBindTexture( GL_TEXTURE_2D, this->texture );
+		this->glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE );
+		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
+		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
+		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT );
+		this->glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT );
+
+		this->glPixelStorei( GL_UNPACK_ROW_LENGTH, this->screen->pitch / this->screen->format->BytesPerPixel );
+		this->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+		(this->glColor4f)(1.0, 1.0, 1.0, 1.0);		/* Solaris workaround */
+
+		this->glViewport(0, 0, this->screen->w, this->screen->h);
+		this->glMatrixMode(GL_PROJECTION);
+		this->glPushMatrix();
+		this->glLoadIdentity();
+
+		this->glOrtho(0.0, (GLdouble) this->screen->w, (GLdouble) this->screen->h, 0.0, 0.0, 1.0);
+
+		this->glMatrixMode(GL_MODELVIEW);
+		this->glPushMatrix();
+		this->glLoadIdentity();
+	}
+#endif
+}
+
+/* Unlock == restore saved state */
+void SDL_GL_Unlock()
+{
+#ifdef HAVE_OPENGL
+	lock_count++;
+	if (lock_count==0)
+	{
+		SDL_VideoDevice *this = current_video;
+
+		this->glPopMatrix();
+		this->glMatrixMode(GL_PROJECTION);
+		this->glPopMatrix();
+
+		this->glPopClientAttrib();
+		this->glPopAttrib();
+	}
+#endif
+}
+
+/*
+ * Sets/Gets the title and icon text of the display window, if any.
+ */
+void SDL_WM_SetCaption (const char *title, const char *icon)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	if ( title ) {
+		if ( wm_title ) {
+			free(wm_title);
+		}
+		wm_title = (char *)malloc(strlen(title)+1);
+		if ( wm_title != NULL ) {
+			strcpy(wm_title, title);
+		}
+	}
+	if ( icon ) {
+		if ( wm_icon ) {
+			free(wm_icon);
+		}
+		wm_icon = (char *)malloc(strlen(icon)+1);
+		if ( wm_icon != NULL ) {
+			strcpy(wm_icon, icon);
+		}
+	}
+	if ( (title || icon) && video && (video->SetCaption != NULL) ) {
+		video->SetCaption(this, wm_title, wm_icon);
+	}
+}
+void SDL_WM_GetCaption (char **title, char **icon)
+{
+	if ( title ) {
+		*title = wm_title;
+	}
+	if ( icon ) {
+		*icon = wm_icon;
+	}
+}
+
+/* Utility function used by SDL_WM_SetIcon() */
+static void CreateMaskFromColorKey(SDL_Surface *icon, Uint8 *mask)
+{
+	int x, y;
+	Uint32 colorkey;
+#define SET_MASKBIT(icon, x, y, mask) \
+	mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8)))
+
+	colorkey = icon->format->colorkey;
+	switch (icon->format->BytesPerPixel) {
+		case 1: { Uint8 *pixels;
+			for ( y=0; y<icon->h; ++y ) {
+				pixels = (Uint8 *)icon->pixels + y*icon->pitch;
+				for ( x=0; x<icon->w; ++x ) {
+					if ( *pixels++ == colorkey ) {
+						SET_MASKBIT(icon, x, y, mask);
+					}
+				}
+			}
+		}
+		break;
+
+		case 2: { Uint16 *pixels;
+			for ( y=0; y<icon->h; ++y ) {
+				pixels = (Uint16 *)icon->pixels +
+				                   y*icon->pitch/2;
+				for ( x=0; x<icon->w; ++x ) {
+					if ( *pixels++ == colorkey ) {
+						SET_MASKBIT(icon, x, y, mask);
+					}
+				}
+			}
+		}
+		break;
+
+		case 4: { Uint32 *pixels;
+			for ( y=0; y<icon->h; ++y ) {
+				pixels = (Uint32 *)icon->pixels +
+				                   y*icon->pitch/4;
+				for ( x=0; x<icon->w; ++x ) {
+					if ( *pixels++ == colorkey ) {
+						SET_MASKBIT(icon, x, y, mask);
+					}
+				}
+			}
+		}
+		break;
+	}
+}
+
+/*
+ * Sets the window manager icon for the display window.
+ */
+void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	if ( icon && video->SetIcon ) {
+		/* Generate a mask if necessary, and create the icon! */
+		if ( mask == NULL ) {
+			int mask_len = icon->h*(icon->w+7)/8;
+			mask = (Uint8 *)malloc(mask_len);
+			if ( mask == NULL ) {
+				return;
+			}
+			memset(mask, ~0, mask_len);
+			if ( icon->flags & SDL_SRCCOLORKEY ) {
+				CreateMaskFromColorKey(icon, mask);
+			}
+			video->SetIcon(video, icon, mask);
+			free(mask);
+		} else {
+			video->SetIcon(this, icon, mask);
+		}
+	}
+}
+
+/*
+ * Grab or ungrab the keyboard and mouse input.
+ * This function returns the final grab mode after calling the
+ * driver dependent function.
+ */
+static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	/* Only do something if we have support for grabs */
+	if ( video->GrabInput == NULL ) {
+		return(video->input_grab);
+	}
+
+	/* If the final grab mode if off, only then do we actually grab */
+#ifdef DEBUG_GRAB
+  printf("SDL_WM_GrabInputRaw(%d) ... ", mode);
+#endif
+	if ( mode == SDL_GRAB_OFF ) {
+		if ( video->input_grab != SDL_GRAB_OFF ) {
+			mode = video->GrabInput(this, mode);
+		}
+	} else {
+		if ( video->input_grab == SDL_GRAB_OFF ) {
+			mode = video->GrabInput(this, mode);
+		}
+	}
+	if ( mode != video->input_grab ) {
+		video->input_grab = mode;
+		if ( video->CheckMouseMode ) {
+			video->CheckMouseMode(this);
+		}
+	}
+#ifdef DEBUG_GRAB
+  printf("Final mode %d\n", video->input_grab);
+#endif
+
+	/* Return the final grab state */
+	if ( mode >= SDL_GRAB_FULLSCREEN ) {
+		mode -= SDL_GRAB_FULLSCREEN;
+	}
+	return(mode);
+}
+SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode)
+{
+	SDL_VideoDevice *video = current_video;
+
+    /* If the video isn't initialized yet, we can't do anything */
+    if ( ! video ) {
+        return SDL_GRAB_OFF;
+    }
+
+	/* Return the current mode on query */
+	if ( mode == SDL_GRAB_QUERY ) {
+		mode = video->input_grab;
+		if ( mode >= SDL_GRAB_FULLSCREEN ) {
+			mode -= SDL_GRAB_FULLSCREEN;
+		}
+		return(mode);
+	}
+
+#ifdef DEBUG_GRAB
+  printf("SDL_WM_GrabInput(%d) ... ", mode);
+#endif
+	/* If the video surface is fullscreen, we always grab */
+	if ( mode >= SDL_GRAB_FULLSCREEN ) {
+		mode -= SDL_GRAB_FULLSCREEN;
+	}
+	if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) {
+		mode += SDL_GRAB_FULLSCREEN;
+	}
+	return(SDL_WM_GrabInputRaw(mode));
+}
+static SDL_GrabMode SDL_WM_GrabInputOff(void)
+{
+	SDL_GrabMode mode;
+
+	/* First query the current grab state */
+	mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+
+	/* Now explicitly turn off input grab */
+	SDL_WM_GrabInputRaw(SDL_GRAB_OFF);
+
+	/* Return the old state */
+	return(mode);
+}
+
+/*
+ * Iconify the window in window managed environments.
+ * A successful iconification will result in an SDL_APPACTIVE loss event.
+ */
+int SDL_WM_IconifyWindow(void)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	int retval;
+
+	retval = 0;
+	if ( video->IconifyWindow ) {
+		retval = video->IconifyWindow(this);
+	}
+	return(retval);
+}
+
+/*
+ * Toggle fullscreen mode
+ */
+int SDL_WM_ToggleFullScreen(SDL_Surface *surface)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	int toggled;
+
+	toggled = 0;
+	if ( SDL_PublicSurface && (surface == SDL_PublicSurface) &&
+	     video->ToggleFullScreen ) {
+		if ( surface->flags & SDL_FULLSCREEN ) {
+			toggled = video->ToggleFullScreen(this, 0);
+			if ( toggled ) {
+				SDL_VideoSurface->flags &= ~SDL_FULLSCREEN;
+				SDL_PublicSurface->flags &= ~SDL_FULLSCREEN;
+			}
+		} else {
+			toggled = video->ToggleFullScreen(this, 1);
+			if ( toggled ) {
+				SDL_VideoSurface->flags |= SDL_FULLSCREEN;
+				SDL_PublicSurface->flags |= SDL_FULLSCREEN;
+			}
+		}
+		/* Double-check the grab state inside SDL_WM_GrabInput() */
+		if ( toggled ) {
+			SDL_WM_GrabInput(video->input_grab);
+		}
+	}
+	return(toggled);
+}
+
+/*
+ * Get some platform dependent window manager information
+ */
+int SDL_GetWMInfo (SDL_SysWMinfo *info)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+
+	if ( video && video->GetWMInfo ) {
+		return(video->GetWMInfo(this, info));
+	} else {
+		return(0);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_yuv.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,93 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the implementation of the YUV video surface support */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_getenv.h"
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+#include "SDL_yuvfuncs.h"
+#include "SDL_yuv_sw_c.h"
+
+
+SDL_Overlay *SDL_CreateYUVOverlay(int w, int h, Uint32 format,
+                                  SDL_Surface *display)
+{
+	SDL_VideoDevice *video = current_video;
+	SDL_VideoDevice *this  = current_video;
+	const char *yuv_hwaccel;
+	SDL_Overlay *overlay;
+
+	overlay = NULL;
+
+	/* Display directly on video surface, if possible */
+#if 0
+	if ( (display == SDL_PublicSurface) &&
+	     ((SDL_VideoSurface->format->BytesPerPixel == 2) ||
+	      (SDL_VideoSurface->format->BytesPerPixel == 4)) ) {
+		display = SDL_VideoSurface;
+	}
+#endif
+        yuv_hwaccel = getenv("SDL_VIDEO_YUV_HWACCEL");
+	if ( ((display == SDL_VideoSurface) && video->CreateYUVOverlay) &&
+	     (!yuv_hwaccel || (atoi(yuv_hwaccel) > 0)) ) {
+		overlay = video->CreateYUVOverlay(this, w, h, format, display);
+	}
+	/* If hardware YUV overlay failed ... */
+	if ( overlay == NULL ) {
+		overlay = SDL_CreateYUV_SW(this, w, h, format, display);
+	}
+	return overlay;
+}
+
+int SDL_LockYUVOverlay(SDL_Overlay *overlay)
+{
+	return overlay->hwfuncs->Lock(current_video, overlay);
+}
+
+void SDL_UnlockYUVOverlay(SDL_Overlay *overlay)
+{
+	overlay->hwfuncs->Unlock(current_video, overlay);
+}
+
+int SDL_DisplayYUVOverlay(SDL_Overlay *overlay, SDL_Rect *dstrect)
+{
+	return overlay->hwfuncs->Display(current_video, overlay, dstrect);
+}
+
+void SDL_FreeYUVOverlay(SDL_Overlay *overlay)
+{
+	if ( overlay ) {
+		if ( overlay->hwfuncs ) {
+			overlay->hwfuncs->FreeHW(current_video, overlay);
+		}
+		free(overlay);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_yuv_mmx.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,421 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+
+#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
+
+#include "SDL_types.h"
+
+#ifdef __ELF__
+#define ASM_VAR(X) _##X
+#else
+#define ASM_VAR(X) X
+#endif
+
+static unsigned int  ASM_VAR(MMX_0080w)[]    = {0x00800080, 0x00800080};
+static unsigned int  ASM_VAR(MMX_00FFw)[]    = {0x00ff00ff, 0x00ff00ff}; 
+static unsigned int  ASM_VAR(MMX_FF00w)[]    = {0xff00ff00, 0xff00ff00}; 
+
+static unsigned short ASM_VAR(MMX_Ycoeff)[]  = {0x004a, 0x004a, 0x004a, 0x004a}; 
+
+static unsigned short ASM_VAR(MMX_UbluRGB)[] = {0x0072, 0x0072, 0x0072, 0x0072};    
+static unsigned short ASM_VAR(MMX_VredRGB)[] = {0x0059, 0x0059, 0x0059, 0x0059};  
+static unsigned short ASM_VAR(MMX_UgrnRGB)[] = {0xffea, 0xffea, 0xffea, 0xffea}; 
+static unsigned short ASM_VAR(MMX_VgrnRGB)[] = {0xffd2, 0xffd2, 0xffd2, 0xffd2};  
+
+static unsigned short ASM_VAR(MMX_Ublu5x5)[] = {0x0081, 0x0081, 0x0081, 0x0081};
+static unsigned short ASM_VAR(MMX_Vred5x5)[] = {0x0066, 0x0066, 0x0066, 0x0066};
+static unsigned short ASM_VAR(MMX_Ugrn555)[] = {0xffe7, 0xffe7, 0xffe7, 0xffe7};
+static unsigned short ASM_VAR(MMX_Vgrn555)[] = {0xffcc, 0xffcc, 0xffcc, 0xffcc};
+static unsigned short ASM_VAR(MMX_Ugrn565)[] = {0xffe8, 0xffe8, 0xffe8, 0xffe8};
+static unsigned short ASM_VAR(MMX_Vgrn565)[] = {0xffcd, 0xffcd, 0xffcd, 0xffcd};
+
+static unsigned short ASM_VAR(MMX_red555)[]  = {0x7c00, 0x7c00, 0x7c00, 0x7c00};
+static unsigned short ASM_VAR(MMX_red565)[]  = {0xf800, 0xf800, 0xf800, 0xf800};
+static unsigned short ASM_VAR(MMX_grn555)[]  = {0x03e0, 0x03e0, 0x03e0, 0x03e0};
+static unsigned short ASM_VAR(MMX_grn565)[]  = {0x07e0, 0x07e0, 0x07e0, 0x07e0};
+static unsigned short ASM_VAR(MMX_blu5x5)[]  = {0x001f, 0x001f, 0x001f, 0x001f};
+
+/**
+   This MMX assembler is my first assembler/MMX program ever.
+   Thus it maybe buggy.
+   Send patches to:
+   mvogt@rhrk.uni-kl.de
+
+   After it worked fine I have "obfuscated" the code a bit to have
+   more parallism in the MMX units. This means I moved
+   initilisation around and delayed other instruction.
+   Performance measurement did not show that this brought any advantage
+   but in theory it _should_ be faster this way.
+
+   The overall performanve gain to the C based dither was 30%-40%.
+   The MMX routine calculates 256bit=8RGB values in each cycle
+   (4 for row1 & 4 for row2)
+
+   The red/green/blue.. coefficents are taken from the mpeg_play 
+   player. They look nice, but I dont know if you can have
+   better values, to avoid integer rounding errors.
+   
+
+   IMPORTANT:
+   ==========
+
+   It is a requirement that the cr/cb/lum are 8 byte aligned and
+   the out are 16byte aligned or you will/may get segfaults
+
+*/
+
+void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                              unsigned char *lum, unsigned char *cr,
+                              unsigned char *cb, unsigned char *out,
+                              int rows, int cols, int mod )
+{
+    Uint32 *row1;
+    Uint32 *row2;
+
+    unsigned char* y = lum +cols*rows;    // Pointer to the end
+    int x=0;
+    row1 = (Uint32 *)out;                 // 32 bit target
+    row2 = (Uint32 *)out+cols+mod;        // start of second row 
+    mod = (mod+cols+mod)*4;               // increment for row1 in byte
+
+    __asm__ __volatile__ (
+/* We don't really care about PIC - the code should be rewritten to use
+   relative addressing for the static tables, so right now we take the
+   COW hit on the pages this code resides. Big deal.
+   This spill is just to reduce register pressure in the PIC case. */
+		 "pushl %%ebx\n"
+		 "movl %0, %%ebx\n"
+
+	         ".align 8\n"
+		 "1:\n"
+		
+		 // create Cr (result in mm1)
+		 "movd (%%ebx), %%mm1\n"   //         0  0  0  0  v3 v2 v1 v0
+		 "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
+		 "movd (%2), %%mm2\n"           //    0  0  0  0 l3 l2 l1 l0
+		 "punpcklbw %%mm7,%%mm1\n" //         0  v3 0  v2 00 v1 00 v0
+		 "punpckldq %%mm1,%%mm1\n" //         00 v1 00 v0 00 v1 00 v0
+		 "psubw _MMX_0080w,%%mm1\n"  // mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 
+
+		 // create Cr_g (result in mm0)
+		 "movq %%mm1,%%mm0\n"           // r1 r1 r0 r0 r1 r1 r0 r0
+		 "pmullw _MMX_VgrnRGB,%%mm0\n"// red*-46dec=0.7136*64
+		 "pmullw _MMX_VredRGB,%%mm1\n"// red*89dec=1.4013*64
+		 "psraw  $6, %%mm0\n"           // red=red/64
+		 "psraw  $6, %%mm1\n"           // red=red/64
+		 
+		 // create L1 L2 (result in mm2,mm4)
+		 // L2=lum+cols
+		 "movq (%2,%4),%%mm3\n"         //    0  0  0  0 L3 L2 L1 L0
+		 "punpckldq %%mm3,%%mm2\n"      //   L3 L2 L1 L0 l3 l2 l1 l0
+		 "movq %%mm2,%%mm4\n"           //   L3 L2 L1 L0 l3 l2 l1 l0
+		 "pand _MMX_FF00w,%%mm2\n"      //   L3 0  L1  0 l3  0 l1  0
+		 "pand _MMX_00FFw,%%mm4\n"      //   0  L2  0 L0  0 l2  0 l0
+		 "psrlw $8,%%mm2\n"             //   0  L3  0 L1  0 l3  0 l1
+
+		 // create R (result in mm6)
+		 "movq %%mm2,%%mm5\n"           //   0 L3  0 L1  0 l3  0 l1
+		 "movq %%mm4,%%mm6\n"           //   0 L2  0 L0  0 l2  0 l0
+		 "paddsw  %%mm1, %%mm5\n"       // lum1+red:x R3 x R1 x r3 x r1
+		 "paddsw  %%mm1, %%mm6\n"       // lum1+red:x R2 x R0 x r2 x r0
+		 "packuswb %%mm5,%%mm5\n"       //  R3 R1 r3 r1 R3 R1 r3 r1
+		 "packuswb %%mm6,%%mm6\n"       //  R2 R0 r2 r0 R2 R0 r2 r0
+		 "pxor %%mm7,%%mm7\n"      //         00 00 00 00 00 00 00 00
+		 "punpcklbw %%mm5,%%mm6\n"      //  R3 R2 R1 R0 r3 r2 r1 r0
+
+		 // create Cb (result in mm1)
+		 "movd (%1), %%mm1\n"      //         0  0  0  0  u3 u2 u1 u0
+		 "punpcklbw %%mm7,%%mm1\n" //         0  u3 0  u2 00 u1 00 u0
+		 "punpckldq %%mm1,%%mm1\n" //         00 u1 00 u0 00 u1 00 u0
+		 "psubw _MMX_0080w,%%mm1\n"  // mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 
+		 // create Cb_g (result in mm5)
+		 "movq %%mm1,%%mm5\n"            // u1 u1 u0 u0 u1 u1 u0 u0
+		 "pmullw _MMX_UgrnRGB,%%mm5\n"    // blue*-109dec=1.7129*64
+		 "pmullw _MMX_UbluRGB,%%mm1\n"    // blue*114dec=1.78125*64
+		 "psraw  $6, %%mm5\n"            // blue=red/64
+		 "psraw  $6, %%mm1\n"            // blue=blue/64
+
+		 // create G (result in mm7)
+		 "movq %%mm2,%%mm3\n"      //   0  L3  0 L1  0 l3  0 l1
+		 "movq %%mm4,%%mm7\n"      //   0  L2  0 L0  0 l2  0 l1
+		 "paddsw  %%mm5, %%mm3\n"  // lum1+Cb_g:x G3t x G1t x g3t x g1t
+		 "paddsw  %%mm5, %%mm7\n"  // lum1+Cb_g:x G2t x G0t x g2t x g0t
+		 "paddsw  %%mm0, %%mm3\n"  // lum1+Cr_g:x G3  x G1  x g3  x g1
+		 "paddsw  %%mm0, %%mm7\n"  // lum1+blue:x G2  x G0  x g2  x g0
+		 "packuswb %%mm3,%%mm3\n"  // G3 G1 g3 g1 G3 G1 g3 g1
+		 "packuswb %%mm7,%%mm7\n"  // G2 G0 g2 g0 G2 G0 g2 g0
+		 "punpcklbw %%mm3,%%mm7\n" // G3 G2 G1 G0 g3 g2 g1 g0
+		 
+		 // create B (result in mm5)
+		 "movq %%mm2,%%mm3\n"         //   0  L3  0 L1  0 l3  0 l1
+		 "movq %%mm4,%%mm5\n"         //   0  L2  0 L0  0 l2  0 l1
+		 "paddsw  %%mm1, %%mm3\n"     // lum1+blue:x B3 x B1 x b3 x b1
+		 "paddsw  %%mm1, %%mm5\n"     // lum1+blue:x B2 x B0 x b2 x b0
+		 "packuswb %%mm3,%%mm3\n"     // B3 B1 b3 b1 B3 B1 b3 b1
+		 "packuswb %%mm5,%%mm5\n"     // B2 B0 b2 b0 B2 B0 b2 b0
+		 "punpcklbw %%mm3,%%mm5\n"    // B3 B2 B1 B0 b3 b2 b1 b0
+
+		 // fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
+
+		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+		 "pxor %%mm4,%%mm4\n"           //  0  0  0  0  0  0  0  0
+		 "movq %%mm6,%%mm1\n"           // R3 R2 R1 R0 r3 r2 r1 r0
+		 "movq %%mm5,%%mm3\n"           // B3 B2 B1 B0 b3 b2 b1 b0
+		 // process lower lum
+		 "punpcklbw %%mm4,%%mm1\n"      //  0 r3  0 r2  0 r1  0 r0
+		 "punpcklbw %%mm4,%%mm3\n"      //  0 b3  0 b2  0 b1  0 b0
+		 "movq %%mm1,%%mm2\n"           //  0 r3  0 r2  0 r1  0 r0
+		 "movq %%mm3,%%mm0\n"           //  0 b3  0 b2  0 b1  0 b0
+		 "punpcklwd %%mm1,%%mm3\n"      //  0 r1  0 b1  0 r0  0 b0
+		 "punpckhwd %%mm2,%%mm0\n"      //  0 r3  0 b3  0 r2  0 b2
+
+		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+		 "movq %%mm7,%%mm1\n"           // G3 G2 G1 G0 g3 g2 g1 g0
+		 "punpcklbw %%mm1,%%mm2\n"      // g3  0 g2  0 g1  0 g0  0
+		 "punpcklwd %%mm4,%%mm2\n"      //  0  0 g1  0  0  0 g0  0 
+		 "por  %%mm3, %%mm2\n"          //  0 r1 g1 b1  0 r0 g0 b0
+		 "movq   %%mm2,(%3)\n"          // wrote out ! row1
+
+		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+		 "punpcklbw %%mm1,%%mm4\n"      // g3  0 g2  0 g1  0 g0  0
+		 "punpckhwd %%mm2,%%mm4\n"      //  0  0 g3  0  0  0 g2  0 
+		 "por  %%mm0, %%mm4\n"          //  0 r3 g3 b3  0 r2 g2 b2
+		 "movq   %%mm4,8(%3)\n"         // wrote out ! row1
+		 
+		 // fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb)
+		 // this can be done "destructive"
+		 "pxor %%mm2,%%mm2\n"           //  0  0  0  0  0  0  0  0
+		 "punpckhbw %%mm2,%%mm6\n"      //  0 R3  0 R2  0 R1  0 R0
+		 "punpckhbw %%mm1,%%mm5\n"      // G3 B3 G2 B2 G1 B1 G0 B0
+		 "movq %%mm5,%%mm1\n"           // G3 B3 G2 B2 G1 B1 G0 B0
+		 "punpcklwd %%mm6,%%mm1\n"      //  0 R1 G1 B1  0 R0 G0 B0
+		 "movq   %%mm1,(%5)\n"          // wrote out ! row2
+		 "punpckhwd %%mm6,%%mm5\n"      //  0 R3 G3 B3  0 R2 G2 B2
+		 "movq   %%mm5,8(%5)\n"         // wrote out ! row2
+		 
+		 "addl  $4,%2\n"            // lum+4
+		 "leal  16(%3),%3\n"        // row1+16
+		 "leal  16(%5),%5\n"        // row2+16
+		 "addl  $2, %%ebx\n"        // cr+2
+		 "addl  $2, %1\n"           // cb+2
+
+		 "addl  $4,%6\n"            // x+4
+		 "cmpl  %4,%6\n"
+
+		 "jl    1b\n"
+		 "addl           %4,     %2\n" // lum += cols 
+		 "addl           %8,     %3\n" // row1+= mod
+		 "addl           %8,     %5\n" // row2+= mod
+		 "movl           $0,     %6\n" // x=0
+		 "cmpl           %7,     %2\n"
+		 "jl             1b\n"
+		 "emms\n"
+		 "popl %%ebx\n"
+		 :
+		 : "m" (cr), "r"(cb),"r"(lum),
+		 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod)
+		 : "%ebx"
+		 );
+}
+
+void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                             unsigned char *lum, unsigned char *cr,
+                             unsigned char *cb, unsigned char *out,
+                             int rows, int cols, int mod )
+{
+    Uint16 *row1;
+    Uint16 *row2;
+
+    unsigned char* y = lum +cols*rows;    /* Pointer to the end */
+    int x=0;
+    row1 = (Uint16 *)out;                 /* 16 bit target */
+    row2 = (Uint16 *)out+cols+mod;        /* start of second row  */
+    mod = (mod+cols+mod)*2;               /* increment for row1 in byte */
+
+
+      __asm__ __volatile__(
+         "pushl %%ebx\n"
+	 "movl %0, %%ebx\n"
+
+         ".align 8\n"
+         "1:\n"
+         "movd           (%1),                   %%mm0\n" // 4 Cb         0  0  0  0 u3 u2 u1 u0
+         "pxor           %%mm7,                  %%mm7\n"
+         "movd           (%%ebx),                %%mm1\n" // 4 Cr                0  0  0  0 v3 v2 v1 v0
+         "punpcklbw      %%mm7,                  %%mm0\n" // 4 W cb   0 u3  0 u2  0 u1  0 u0
+         "punpcklbw      %%mm7,                  %%mm1\n" // 4 W cr   0 v3  0 v2  0 v1  0 v0
+         "psubw          _MMX_0080w,             %%mm0\n"
+         "psubw          _MMX_0080w,             %%mm1\n"
+         "movq           %%mm0,                  %%mm2\n" // Cb                   0 u3  0 u2  0 u1  0 u0
+         "movq           %%mm1,                  %%mm3\n" // Cr
+         "pmullw         _MMX_Ugrn565,           %%mm2\n" // Cb2green 0 R3  0 R2  0 R1  0 R0
+         "movq           (%2),                   %%mm6\n" // L1      l7 L6 L5 L4 L3 L2 L1 L0
+         "pmullw         _MMX_Ublu5x5,           %%mm0\n" // Cb2blue
+         "pand           _MMX_00FFw,             %%mm6\n" // L1      00 L6 00 L4 00 L2 00 L0
+         "pmullw         _MMX_Vgrn565,           %%mm3\n" // Cr2green
+         "movq           (%2),                   %%mm7\n" // L2
+         "pmullw         _MMX_Vred5x5,           %%mm1\n" // Cr2red
+         "psrlw          $8,                     %%mm7\n"        // L2           00 L7 00 L5 00 L3 00 L1
+         "pmullw         _MMX_Ycoeff,            %%mm6\n" // lum1
+         "paddw          %%mm3,                  %%mm2\n" // Cb2green + Cr2green == green
+         "pmullw         _MMX_Ycoeff,            %%mm7\n" // lum2
+
+         "movq           %%mm6,                  %%mm4\n" // lum1
+         "paddw          %%mm0,                  %%mm6\n" // lum1 +blue 00 B6 00 B4 00 B2 00 B0
+         "movq           %%mm4,                  %%mm5\n" // lum1
+         "paddw          %%mm1,                  %%mm4\n" // lum1 +red  00 R6 00 R4 00 R2 00 R0
+         "paddw          %%mm2,                  %%mm5\n" // lum1 +green 00 G6 00 G4 00 G2 00 G0
+         "psraw          $6,                     %%mm4\n" // R1 0 .. 64
+         "movq           %%mm7,                  %%mm3\n" // lum2                       00 L7 00 L5 00 L3 00 L1
+         "psraw          $6,                     %%mm5\n" // G1  - .. +
+         "paddw          %%mm0,                  %%mm7\n" // Lum2 +blue 00 B7 00 B5 00 B3 00 B1
+         "psraw          $6,                     %%mm6\n" // B1         0 .. 64
+         "packuswb       %%mm4,                  %%mm4\n" // R1 R1
+         "packuswb       %%mm5,                  %%mm5\n" // G1 G1
+         "packuswb       %%mm6,                  %%mm6\n" // B1 B1
+         "punpcklbw      %%mm4,                  %%mm4\n"
+         "punpcklbw      %%mm5,                  %%mm5\n"
+
+         "pand           _MMX_red565,            %%mm4\n"
+         "psllw          $3,                     %%mm5\n" // GREEN       1
+         "punpcklbw      %%mm6,                  %%mm6\n"
+         "pand           _MMX_grn565,            %%mm5\n"
+         "pand           _MMX_red565,            %%mm6\n"
+         "por            %%mm5,                  %%mm4\n" //
+         "psrlw          $11,                    %%mm6\n" // BLUE        1
+         "movq           %%mm3,                  %%mm5\n" // lum2
+         "paddw          %%mm1,                  %%mm3\n" // lum2 +red      00 R7 00 R5 00 R3 00 R1
+         "paddw          %%mm2,                  %%mm5\n" // lum2 +green 00 G7 00 G5 00 G3 00 G1
+         "psraw          $6,                     %%mm3\n" // R2
+         "por            %%mm6,                  %%mm4\n" // MM4
+         "psraw          $6,                     %%mm5\n" // G2
+         "movq           (%2, %4),               %%mm6\n" // L3 load lum2
+         "psraw          $6,                     %%mm7\n"
+         "packuswb       %%mm3,                  %%mm3\n"
+         "packuswb       %%mm5,                  %%mm5\n"
+         "packuswb       %%mm7,                  %%mm7\n"
+         "pand           _MMX_00FFw,             %%mm6\n" // L3
+         "punpcklbw      %%mm3,                  %%mm3\n"
+         "punpcklbw      %%mm5,                  %%mm5\n"
+         "pmullw         _MMX_Ycoeff,            %%mm6\n" // lum3
+         "punpcklbw      %%mm7,                  %%mm7\n"
+         "psllw          $3,                     %%mm5\n" // GREEN 2
+         "pand           _MMX_red565,            %%mm7\n"
+         "pand           _MMX_red565,            %%mm3\n"
+         "psrlw          $11,                    %%mm7\n" // BLUE  2
+         "pand           _MMX_grn565,            %%mm5\n"
+         "por            %%mm7,                  %%mm3\n"
+         "movq           (%2,%4),                %%mm7\n" // L4 load lum2
+         "por            %%mm5,                  %%mm3\n" //
+         "psrlw          $8,                     %%mm7\n" // L4
+         "movq           %%mm4,                  %%mm5\n"
+         "punpcklwd      %%mm3,                  %%mm4\n"
+         "pmullw         _MMX_Ycoeff,            %%mm7\n" // lum4
+         "punpckhwd      %%mm3,                  %%mm5\n"
+
+         "movq           %%mm4,                  (%3)\n"  // write row1
+         "movq           %%mm5,                  8(%3)\n" // write row1
+
+         "movq           %%mm6,                  %%mm4\n" // Lum3
+         "paddw          %%mm0,                  %%mm6\n" // Lum3 +blue
+
+         "movq           %%mm4,                  %%mm5\n" // Lum3
+         "paddw          %%mm1,                  %%mm4\n" // Lum3 +red
+         "paddw          %%mm2,                  %%mm5\n" // Lum3 +green
+         "psraw          $6,                     %%mm4\n"
+         "movq           %%mm7,                  %%mm3\n" // Lum4
+         "psraw          $6,                     %%mm5\n"
+         "paddw          %%mm0,                  %%mm7\n" // Lum4 +blue
+         "psraw          $6,                     %%mm6\n" // Lum3 +blue
+         "movq           %%mm3,                  %%mm0\n" // Lum4
+         "packuswb       %%mm4,                  %%mm4\n"
+         "paddw          %%mm1,                  %%mm3\n" // Lum4 +red
+         "packuswb       %%mm5,                  %%mm5\n"
+         "paddw          %%mm2,                  %%mm0\n" // Lum4 +green
+         "packuswb       %%mm6,                  %%mm6\n"
+         "punpcklbw      %%mm4,                  %%mm4\n"
+         "punpcklbw      %%mm5,                  %%mm5\n"
+         "punpcklbw      %%mm6,                  %%mm6\n"
+         "psllw          $3,                     %%mm5\n" // GREEN 3
+         "pand           _MMX_red565,            %%mm4\n"
+         "psraw          $6,                     %%mm3\n" // psr 6
+         "psraw          $6,                     %%mm0\n"
+         "pand           _MMX_red565,            %%mm6\n" // BLUE
+         "pand           _MMX_grn565,            %%mm5\n"
+         "psrlw          $11,                    %%mm6\n" // BLUE  3
+         "por            %%mm5,                  %%mm4\n"
+         "psraw          $6,                     %%mm7\n"
+         "por            %%mm6,                  %%mm4\n"
+         "packuswb       %%mm3,                  %%mm3\n"
+         "packuswb       %%mm0,                  %%mm0\n"
+         "packuswb       %%mm7,                  %%mm7\n"
+         "punpcklbw      %%mm3,                  %%mm3\n"
+         "punpcklbw      %%mm0,                  %%mm0\n"
+         "punpcklbw      %%mm7,                  %%mm7\n"
+         "pand           _MMX_red565,            %%mm3\n"
+         "pand           _MMX_red565,            %%mm7\n" // BLUE
+         "psllw          $3,                     %%mm0\n" // GREEN 4
+         "psrlw          $11,                    %%mm7\n"
+         "pand           _MMX_grn565,            %%mm0\n"
+         "por            %%mm7,                  %%mm3\n"
+         "por            %%mm0,                  %%mm3\n"
+
+         "movq           %%mm4,                  %%mm5\n"
+
+         "punpcklwd      %%mm3,                  %%mm4\n"
+         "punpckhwd      %%mm3,                  %%mm5\n"
+
+         "movq           %%mm4,                  (%5)\n"
+	 "movq           %%mm5,                  8(%5)\n"
+
+         "addl           $8,                     %6\n"
+         "addl           $8,                     %2\n"
+         "addl           $4,                     %%ebx\n"
+         "addl           $4,                     %1\n"
+         "cmpl           %4,                     %6\n"
+         "leal           16(%3),                 %3\n"
+	 "leal           16(%5),%5\n" // row2+16
+
+
+         "jl             1b\n"
+	 "addl           %4,     %2\n" // lum += cols 
+	 "addl           %8,     %3\n" // row1+= mod
+	 "addl           %8,     %5\n" // row2+= mod
+	 "movl           $0,     %6\n" // x=0
+	 "cmpl           %7,     %2\n"
+	 "jl             1b\n"
+         "emms\n"
+	 "popl %%ebx\n"
+         :
+         :"m" (cr), "r"(cb),"r"(lum),
+	 "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod)
+	 : "%ebx"
+         );
+}
+
+#endif /* GCC i386 inline assembly */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_yuv_sw.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1313 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the software implementation of the YUV video overlay support */
+
+/* This code was derived from code carrying the following copyright notices:
+
+ * Copyright (c) 1995 The Regents of the University of California.
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
+ * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+ * Copyright (c) 1995 Erik Corry
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement is
+ * hereby granted, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+ * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
+ * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+ * BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
+ * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+ * Portions of this software Copyright (c) 1995 Brown University.
+ * All rights reserved.
+ * 
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose, without fee, and without written agreement
+ * is hereby granted, provided that the above copyright notice and the
+ * following two paragraphs appear in all copies of this software.
+ * 
+ * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
+ * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
+ * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * 
+ * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
+ * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
+ * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_stretch_c.h"
+#include "SDL_yuvfuncs.h"
+#include "SDL_yuv_sw_c.h"
+
+/* Function to check the CPU flags */
+#define MMX_CPU		0x800000
+#ifdef USE_ASMBLIT
+#define CPU_Flags()	Hermes_X86_CPU()
+#else
+#define CPU_Flags()	0L
+#endif
+
+#ifdef USE_ASMBLIT
+#define X86_ASSEMBLER
+#define HermesConverterInterface	void
+#define HermesClearInterface		void
+#define STACKCALL
+typedef Uint32 int32;
+
+#include "HeadX86.h"
+#endif
+
+/* The functions used to manipulate software video overlays */
+static struct private_yuvhwfuncs sw_yuvfuncs = {
+	SDL_LockYUV_SW,
+	SDL_UnlockYUV_SW,
+	SDL_DisplayYUV_SW,
+	SDL_FreeYUV_SW
+};
+
+/* RGB conversion lookup tables */
+struct private_yuvhwdata {
+	SDL_Surface *stretch;
+	SDL_Surface *display;
+	Uint8 *pixels;
+	int *colortab;
+	Uint32 *rgb_2_pix;
+	void (*Display1X)(int *colortab, Uint32 *rgb_2_pix,
+                          unsigned char *lum, unsigned char *cr,
+                          unsigned char *cb, unsigned char *out,
+                          int rows, int cols, int mod );
+	void (*Display2X)(int *colortab, Uint32 *rgb_2_pix,
+	                  unsigned char *lum, unsigned char *cr,
+                          unsigned char *cb, unsigned char *out,
+                          int rows, int cols, int mod );
+
+	/* These are just so we don't have to allocate them separately */
+	Uint16 pitches[3];
+	Uint8 *planes[3];
+};
+
+
+/* The colorspace conversion functions */
+
+extern void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                                     unsigned char *lum, unsigned char *cr,
+                                     unsigned char *cb, unsigned char *out,
+                                     int rows, int cols, int mod );
+extern void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
+                                     unsigned char *lum, unsigned char *cr,
+                                     unsigned char *cb, unsigned char *out,
+                                     int rows, int cols, int mod );
+
+static void Color16DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned short* row1;
+    unsigned short* row2;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = (unsigned short*) out;
+    row2 = row1 + cols + mod;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void Color24DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int value;
+    unsigned char* row1;
+    unsigned char* row2;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = out;
+    row2 = row1 + cols*3 + mod*3;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+    mod *= 3;
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row1++ = (value      ) & 0xFF;
+            *row1++ = (value >>  8) & 0xFF;
+            *row1++ = (value >> 16) & 0xFF;
+
+            L = *lum++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row1++ = (value      ) & 0xFF;
+            *row1++ = (value >>  8) & 0xFF;
+            *row1++ = (value >> 16) & 0xFF;
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row2++ = (value      ) & 0xFF;
+            *row2++ = (value >>  8) & 0xFF;
+            *row2++ = (value >> 16) & 0xFF;
+
+            L = *lum2++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row2++ = (value      ) & 0xFF;
+            *row2++ = (value >>  8) & 0xFF;
+            *row2++ = (value >> 16) & 0xFF;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void Color32DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row1;
+    unsigned int* row2;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row1 = (unsigned int*) out;
+    row2 = row1 + cols + mod;
+    lum2 = lum + cols;
+
+    mod += cols + mod;
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum++;
+            *row1++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+
+            /* Now, do second row.  */
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum2++;
+            *row2++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+/*
+ * In this function I make use of a nasty trick. The tables have the lower
+ * 16 bits replicated in the upper 16. This means I can write ints and get
+ * the horisontal doubling for free (almost).
+ */
+static void Color16DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row1 = (unsigned int*) out;
+    const int next_row = cols+(mod/2);
+    unsigned int* row2 = row1 + 2*next_row;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = (next_row * 3) + (mod/2);
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            row1[0] = row1[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row1++;
+
+            L = *lum++;
+            row1[0] = row1[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row1++;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            row2[0] = row2[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row2++;
+
+            L = *lum2++;
+            row2[0] = row2[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row2++;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void Color24DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int value;
+    unsigned char* row1 = out;
+    const int next_row = (cols*2 + mod) * 3;
+    unsigned char* row2 = row1 + 2*next_row;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = next_row*3 + mod*3;
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row1[0+0] = row1[3+0] = row1[next_row+0] = row1[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row1[0+1] = row1[3+1] = row1[next_row+1] = row1[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row1[0+2] = row1[3+2] = row1[next_row+2] = row1[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row1 += 2*3;
+
+            L = *lum++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row1[0+0] = row1[3+0] = row1[next_row+0] = row1[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row1[0+1] = row1[3+1] = row1[next_row+1] = row1[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row1[0+2] = row1[3+2] = row1[next_row+2] = row1[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row1 += 2*3;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row2[0+0] = row2[3+0] = row2[next_row+0] = row2[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row2[0+1] = row2[3+1] = row2[next_row+1] = row2[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row2[0+2] = row2[3+2] = row2[next_row+2] = row2[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row2 += 2*3;
+
+            L = *lum2++;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row2[0+0] = row2[3+0] = row2[next_row+0] = row2[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row2[0+1] = row2[3+1] = row2[next_row+1] = row2[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row2[0+2] = row2[3+2] = row2[next_row+2] = row2[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row2 += 2*3;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void Color32DitherYV12Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row1 = (unsigned int*) out;
+    const int next_row = cols*2+mod;
+    unsigned int* row2 = row1 + 2*next_row;
+    unsigned char* lum2;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    lum2 = lum + cols;
+
+    mod = (next_row * 3) + mod;
+
+    y = rows / 2;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            ++cr; ++cb;
+
+            L = *lum++;
+            row1[0] = row1[1] = row1[next_row] = row1[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row1 += 2;
+
+            L = *lum++;
+            row1[0] = row1[1] = row1[next_row] = row1[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row1 += 2;
+
+
+            /* Now, do second row. */
+
+            L = *lum2++;
+            row2[0] = row2[1] = row2[next_row] = row2[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row2 += 2;
+
+            L = *lum2++;
+            row2[0] = row2[1] = row2[next_row] = row2[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row2 += 2;
+        }
+
+        /*
+         * These values are at the start of the next line, (due
+         * to the ++'s above),but they need to be at the start
+         * of the line after that.
+         */
+        lum  += cols;
+        lum2 += cols;
+        row1 += mod;
+        row2 += mod;
+    }
+}
+
+static void Color16DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned short* row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned short*) out;
+
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            *row++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum; lum += 2;
+            *row++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+        }
+
+        row += mod;
+    }
+}
+
+static void Color24DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int value;
+    unsigned char* row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned char*) out;
+    mod *= 3;
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row++ = (value      ) & 0xFF;
+            *row++ = (value >>  8) & 0xFF;
+            *row++ = (value >> 16) & 0xFF;
+
+            L = *lum; lum += 2;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            *row++ = (value      ) & 0xFF;
+            *row++ = (value >>  8) & 0xFF;
+            *row++ = (value >> 16) & 0xFF;
+
+        }
+        row += mod;
+    }
+}
+
+static void Color32DitherYUY2Mod1X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    row = (unsigned int*) out;
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            *row++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+            L = *lum; lum += 2;
+            *row++ = (rgb_2_pix[ L + cr_r ] |
+                       rgb_2_pix[ L + crb_g ] |
+                       rgb_2_pix[ L + cb_b ]);
+
+
+        }
+        row += mod;
+    }
+}
+
+/*
+ * In this function I make use of a nasty trick. The tables have the lower
+ * 16 bits replicated in the upper 16. This means I can write ints and get
+ * the horisontal doubling for free (almost).
+ */
+static void Color16DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row = (unsigned int*) out;
+    const int next_row = cols+(mod/2);
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            row[0] = row[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row++;
+
+            L = *lum; lum += 2;
+            row[0] = row[next_row] = (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row++;
+
+        }
+        row += next_row;
+    }
+}
+
+static void Color24DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int value;
+    unsigned char* row = out;
+    const int next_row = (cols*2 + mod) * 3;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row[0+0] = row[3+0] = row[next_row+0] = row[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row[0+1] = row[3+1] = row[next_row+1] = row[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row[0+2] = row[3+2] = row[next_row+2] = row[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row += 2*3;
+
+            L = *lum; lum += 2;
+            value = (rgb_2_pix[ L + cr_r ] |
+                     rgb_2_pix[ L + crb_g ] |
+                     rgb_2_pix[ L + cb_b ]);
+            row[0+0] = row[3+0] = row[next_row+0] = row[next_row+3+0] =
+                     (value      ) & 0xFF;
+            row[0+1] = row[3+1] = row[next_row+1] = row[next_row+3+1] =
+                     (value >>  8) & 0xFF;
+            row[0+2] = row[3+2] = row[next_row+2] = row[next_row+3+2] =
+                     (value >> 16) & 0xFF;
+            row += 2*3;
+
+        }
+        row += next_row;
+    }
+}
+
+static void Color32DitherYUY2Mod2X( int *colortab, Uint32 *rgb_2_pix,
+                                    unsigned char *lum, unsigned char *cr,
+                                    unsigned char *cb, unsigned char *out,
+                                    int rows, int cols, int mod )
+{
+    unsigned int* row = (unsigned int*) out;
+    const int next_row = cols*2+mod;
+    int x, y;
+    int cr_r;
+    int crb_g;
+    int cb_b;
+    int cols_2 = cols / 2;
+    mod+=mod;
+    y = rows;
+    while( y-- )
+    {
+        x = cols_2;
+        while( x-- )
+        {
+            register int L;
+
+            cr_r   = 0*768+256 + colortab[ *cr + 0*256 ];
+            crb_g  = 1*768+256 + colortab[ *cr + 1*256 ]
+                               + colortab[ *cb + 2*256 ];
+            cb_b   = 2*768+256 + colortab[ *cb + 3*256 ];
+            cr += 4; cb += 4;
+
+            L = *lum; lum += 2;
+            row[0] = row[1] = row[next_row] = row[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row += 2;
+
+            L = *lum; lum += 2;
+            row[0] = row[1] = row[next_row] = row[next_row+1] =
+                                       (rgb_2_pix[ L + cr_r ] |
+                                        rgb_2_pix[ L + crb_g ] |
+                                        rgb_2_pix[ L + cb_b ]);
+            row += 2;
+
+
+        }
+
+        row += next_row;
+    }
+}
+
+/*
+ * How many 1 bits are there in the Uint32.
+ * Low performance, do not call often.
+ */
+static int number_of_bits_set( Uint32 a )
+{
+    if(!a) return 0;
+    if(a & 1) return 1 + number_of_bits_set(a >> 1);
+    return(number_of_bits_set(a >> 1));
+}
+
+/*
+ * How many 0 bits are there at least significant end of Uint32.
+ * Low performance, do not call often.
+ */
+static int free_bits_at_bottom( Uint32 a )
+{
+      /* assume char is 8 bits */
+    if(!a) return sizeof(Uint32) * 8;
+    if(((Sint32)a) & 1l) return 0;
+    return 1 + free_bits_at_bottom ( a >> 1);
+}
+
+
+SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
+{
+	SDL_Overlay *overlay;
+	struct private_yuvhwdata *swdata;
+	int *Cr_r_tab;
+	int *Cr_g_tab;
+	int *Cb_g_tab;
+	int *Cb_b_tab;
+	Uint32 *r_2_pix_alloc;
+	Uint32 *g_2_pix_alloc;
+	Uint32 *b_2_pix_alloc;
+	int i, cpu_mmx;
+	int CR, CB;
+	Uint32 Rmask, Gmask, Bmask;
+
+	/* Only RGB packed pixel conversion supported */
+	if ( (display->format->BytesPerPixel != 2) &&
+	     (display->format->BytesPerPixel != 3) &&
+	     (display->format->BytesPerPixel != 4) ) {
+		SDL_SetError("Can't use YUV data on non 16/24/32 bit surfaces");
+		return(NULL);
+	}
+
+	/* Verify that we support the format */
+	switch (format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+	    case SDL_YUY2_OVERLAY:
+	    case SDL_UYVY_OVERLAY:
+	    case SDL_YVYU_OVERLAY:
+		break;
+	    default:
+		SDL_SetError("Unsupported YUV format");
+		return(NULL);
+	}
+
+	/* Create the overlay structure */
+	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
+	if ( overlay == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(overlay, 0, (sizeof *overlay));
+
+	/* Fill in the basic members */
+	overlay->format = format;
+	overlay->w = width;
+	overlay->h = height;
+
+	/* Set up the YUV surface function structure */
+	overlay->hwfuncs = &sw_yuvfuncs;
+
+	/* Create the pixel data and lookup tables */
+	swdata = (struct private_yuvhwdata *)malloc(sizeof *swdata);
+	overlay->hwdata = swdata;
+	if ( swdata == NULL ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	swdata->stretch = NULL;
+	swdata->display = display;
+	swdata->pixels = (Uint8 *) malloc(width*height*2);
+	swdata->colortab = (int *)malloc(4*256*sizeof(int));
+	Cr_r_tab = &swdata->colortab[0*256];
+	Cr_g_tab = &swdata->colortab[1*256];
+	Cb_g_tab = &swdata->colortab[2*256];
+	Cb_b_tab = &swdata->colortab[3*256];
+	swdata->rgb_2_pix = (Uint32 *)malloc(3*768*sizeof(Uint32));
+	r_2_pix_alloc = &swdata->rgb_2_pix[0*768];
+	g_2_pix_alloc = &swdata->rgb_2_pix[1*768];
+	b_2_pix_alloc = &swdata->rgb_2_pix[2*768];
+	if ( ! swdata->pixels || ! swdata->colortab || ! swdata->rgb_2_pix ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+
+	/* Generate the tables for the display surface */
+	for (i=0; i<256; i++) {
+		/* Gamma correction (luminescence table) and chroma correction
+		   would be done here.  See the Berkeley mpeg_play sources.
+		*/
+		CB = CR = (i-128);
+		Cr_r_tab[i] = (int) ( (0.419/0.299) * CR);
+		Cr_g_tab[i] = (int) (-(0.299/0.419) * CR);
+		Cb_g_tab[i] = (int) (-(0.114/0.331) * CB); 
+		Cb_b_tab[i] = (int) ( (0.587/0.331) * CB);
+	}
+
+	/* 
+	 * Set up entries 0-255 in rgb-to-pixel value tables.
+	 */
+	Rmask = display->format->Rmask;
+	Gmask = display->format->Gmask;
+	Bmask = display->format->Bmask;
+	for ( i=0; i<256; ++i ) {
+		r_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Rmask));
+		r_2_pix_alloc[i+256] <<= free_bits_at_bottom(Rmask);
+		g_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Gmask));
+		g_2_pix_alloc[i+256] <<= free_bits_at_bottom(Gmask);
+		b_2_pix_alloc[i+256] = i >> (8 - number_of_bits_set(Bmask));
+		b_2_pix_alloc[i+256] <<= free_bits_at_bottom(Bmask);
+	}
+
+	/*
+	 * If we have 16-bit output depth, then we double the value
+	 * in the top word. This means that we can write out both
+	 * pixels in the pixel doubling mode with one op. It is 
+	 * harmless in the normal case as storing a 32-bit value
+	 * through a short pointer will lose the top bits anyway.
+	 */
+	if( display->format->BytesPerPixel == 2 ) {
+		for ( i=0; i<256; ++i ) {
+			r_2_pix_alloc[i+256] |= (r_2_pix_alloc[i+256]) << 16;
+			g_2_pix_alloc[i+256] |= (g_2_pix_alloc[i+256]) << 16;
+			b_2_pix_alloc[i+256] |= (b_2_pix_alloc[i+256]) << 16;
+		}
+	}
+
+	/*
+	 * Spread out the values we have to the rest of the array so that
+	 * we do not need to check for overflow.
+	 */
+	for ( i=0; i<256; ++i ) {
+		r_2_pix_alloc[i] = r_2_pix_alloc[256];
+		r_2_pix_alloc[i+512] = r_2_pix_alloc[511];
+		g_2_pix_alloc[i] = g_2_pix_alloc[256];
+		g_2_pix_alloc[i+512] = g_2_pix_alloc[511];
+		b_2_pix_alloc[i] = b_2_pix_alloc[256];
+		b_2_pix_alloc[i+512] = b_2_pix_alloc[511];
+	}
+
+	/* You have chosen wisely... */
+	switch (format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+		cpu_mmx = CPU_Flags() & MMX_CPU;
+		if ( display->format->BytesPerPixel == 2 ) {
+#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
+			/* inline assembly functions */
+			if ( cpu_mmx && (Rmask == 0xF800) &&
+			                (Gmask == 0x07E0) &&
+				        (Bmask == 0x001F) &&
+			                (width & 15) == 0) {
+/*printf("Using MMX 16-bit 565 dither\n");*/
+				swdata->Display1X = Color565DitherYV12MMX1X;
+			} else {
+/*printf("Using C 16-bit dither\n");*/
+				swdata->Display1X = Color16DitherYV12Mod1X;
+			}
+#else
+			swdata->Display1X = Color16DitherYV12Mod1X;
+#endif
+			swdata->Display2X = Color16DitherYV12Mod2X;
+		}
+		if ( display->format->BytesPerPixel == 3 ) {
+			swdata->Display1X = Color24DitherYV12Mod1X;
+			swdata->Display2X = Color24DitherYV12Mod2X;
+		}
+		if ( display->format->BytesPerPixel == 4 ) {
+#if defined(i386) && defined(__GNUC__) && defined(USE_ASMBLIT)
+			/* inline assembly functions */
+			if ( cpu_mmx && (Rmask == 0x00FF0000) &&
+			                (Gmask == 0x0000FF00) &&
+				        (Bmask == 0x000000FF) && 
+			                (width & 15) == 0) {
+/*printf("Using MMX 32-bit dither\n");*/
+				swdata->Display1X = ColorRGBDitherYV12MMX1X;
+			} else {
+/*printf("Using C 32-bit dither\n");*/
+				swdata->Display1X = Color32DitherYV12Mod1X;
+			}
+#else
+			swdata->Display1X = Color32DitherYV12Mod1X;
+#endif
+			swdata->Display2X = Color32DitherYV12Mod2X;
+		}
+		break;
+	    case SDL_YUY2_OVERLAY:
+	    case SDL_UYVY_OVERLAY:
+	    case SDL_YVYU_OVERLAY:
+		if ( display->format->BytesPerPixel == 2 ) {
+			swdata->Display1X = Color16DitherYUY2Mod1X;
+			swdata->Display2X = Color16DitherYUY2Mod2X;
+		}
+		if ( display->format->BytesPerPixel == 3 ) {
+			swdata->Display1X = Color24DitherYUY2Mod1X;
+			swdata->Display2X = Color24DitherYUY2Mod2X;
+		}
+		if ( display->format->BytesPerPixel == 4 ) {
+			swdata->Display1X = Color32DitherYUY2Mod1X;
+			swdata->Display2X = Color32DitherYUY2Mod2X;
+		}
+		break;
+	    default:
+		/* We should never get here (caught above) */
+		break;
+	}
+
+	/* Find the pitch and offset values for the overlay */
+	overlay->pitches = swdata->pitches;
+	overlay->pixels = swdata->planes;
+	switch (format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+		overlay->pitches[0] = overlay->w;
+		overlay->pitches[1] = overlay->pitches[0] / 2;
+		overlay->pitches[2] = overlay->pitches[0] / 2;
+	        overlay->pixels[0] = swdata->pixels;
+	        overlay->pixels[1] = overlay->pixels[0] +
+		                     overlay->pitches[0] * overlay->h;
+	        overlay->pixels[2] = overlay->pixels[1] +
+		                     overlay->pitches[1] * overlay->h / 2;
+		overlay->planes = 3;
+		break;
+	    case SDL_YUY2_OVERLAY:
+	    case SDL_UYVY_OVERLAY:
+	    case SDL_YVYU_OVERLAY:
+		overlay->pitches[0] = overlay->w*2;
+	        overlay->pixels[0] = swdata->pixels;
+		overlay->planes = 1;
+		break;
+	    default:
+		/* We should never get here (caught above) */
+		break;
+	}
+
+	/* We're all done.. */
+	return(overlay);
+}
+
+int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay)
+{
+	return(0);
+}
+
+void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay)
+{
+	return;
+}
+
+int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
+{
+	struct private_yuvhwdata *swdata;
+	SDL_Surface *stretch;
+	SDL_Surface *display;
+	int scale_2x;
+	Uint8 *lum, *Cr, *Cb;
+	Uint8 *dst;
+	int mod;
+
+	swdata = overlay->hwdata;
+	scale_2x = 0;
+	stretch = 0;
+	if ( (overlay->w != dstrect->w) || (overlay->h != dstrect->h) ) {
+		if ( (dstrect->w == 2*overlay->w) &&
+		     (dstrect->h == 2*overlay->h) ) {
+			scale_2x = 1;
+		} else {
+			if ( ! swdata->stretch ) {
+				display = swdata->display;
+				swdata->stretch = SDL_CreateRGBSurface(
+					SDL_SWSURFACE,
+					overlay->w, overlay->h,
+					display->format->BitsPerPixel,
+					display->format->Rmask,
+					display->format->Gmask,
+					display->format->Bmask, 0);
+				if ( ! swdata->stretch ) {
+					return(-1);
+				}
+			}
+			stretch = swdata->stretch;
+		}
+	}
+
+	if ( stretch ) {
+		display = stretch;
+	} else {
+		display = swdata->display;
+	}
+	switch (overlay->format) {
+	    case SDL_YV12_OVERLAY:
+		lum = overlay->pixels[0];
+		Cr =  overlay->pixels[1];
+		Cb =  overlay->pixels[2];
+		break;
+	    case SDL_IYUV_OVERLAY:
+		lum = overlay->pixels[0];
+		Cr =  overlay->pixels[2];
+		Cb =  overlay->pixels[1];
+		break;
+	    case SDL_YUY2_OVERLAY:
+		lum = overlay->pixels[0];
+		Cr = lum + 3;
+		Cb = lum + 1;
+		break;
+	    case SDL_UYVY_OVERLAY:
+		lum = overlay->pixels[0]+1;
+		Cr = lum + 1;
+		Cb = lum - 1;
+		break;
+	    case SDL_YVYU_OVERLAY:
+		lum = overlay->pixels[0];
+		Cr = lum + 1;
+		Cb = lum + 3;
+		break;
+	    default:
+		SDL_SetError("Unsupported YUV format in blit (??)");
+		return(-1);
+	}
+	if ( SDL_MUSTLOCK(display) ) {
+        	if ( SDL_LockSurface(display) < 0 ) {
+			return(-1);
+		}
+	}
+	if ( stretch ) {
+		dst = (Uint8 *)stretch->pixels;
+	} else {
+		dst = (Uint8 *)display->pixels
+			+ dstrect->x * display->format->BytesPerPixel
+			+ dstrect->y * display->pitch;
+	}
+	mod = (display->pitch / display->format->BytesPerPixel);
+
+	if ( scale_2x ) {
+		mod -= (overlay->w * 2);
+		swdata->Display2X(swdata->colortab, swdata->rgb_2_pix,
+		                  lum, Cr, Cb, dst, overlay->h, overlay->w,mod);
+	} else {
+		mod -= overlay->w;
+		swdata->Display1X(swdata->colortab, swdata->rgb_2_pix,
+		                  lum, Cr, Cb, dst, overlay->h, overlay->w,mod);
+	}
+	if ( SDL_MUSTLOCK(display) ) {
+		SDL_UnlockSurface(display);
+	}
+	if ( stretch ) {
+		display = swdata->display;
+		SDL_SoftStretch(stretch, NULL, display, dstrect);
+	}
+	SDL_UpdateRects(display, 1, dstrect);
+
+	return(0);
+}
+
+void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay)
+{
+	struct private_yuvhwdata *swdata;
+
+	swdata = overlay->hwdata;
+	if ( swdata ) {
+		if ( swdata->pixels ) {
+			free(swdata->pixels);
+		}
+		if ( swdata->colortab ) {
+			free(swdata->colortab);
+		}
+		if ( swdata->rgb_2_pix ) {
+			free(swdata->rgb_2_pix);
+		}
+		free(swdata);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_yuv_sw_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+
+/* This is the software implementation of the YUV video overlay support */
+
+extern SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
+
+extern int SDL_LockYUV_SW(_THIS, SDL_Overlay *overlay);
+
+extern void SDL_UnlockYUV_SW(_THIS, SDL_Overlay *overlay);
+
+extern int SDL_DisplayYUV_SW(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
+
+extern void SDL_FreeYUV_SW(_THIS, SDL_Overlay *overlay);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/SDL_yuvfuncs.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the definition of the YUV video surface function structure */
+
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+
+#ifndef _THIS
+#define _THIS	SDL_VideoDevice *_this
+#endif
+struct private_yuvhwfuncs {
+	int (*Lock)(_THIS, SDL_Overlay *overlay);
+	void (*Unlock)(_THIS, SDL_Overlay *overlay);
+	int (*Display)(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
+	void (*FreeHW)(_THIS, SDL_Overlay *overlay);
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the AAlib video driver
+
+noinst_LTLIBRARIES = libvideo_aa.la
+libvideo_aa_la_SOURCES = $(AA_SRCS)
+
+# The SDL AAlib video driver sources
+AA_SRCS = 			\
+	SDL_aavideo.h		\
+	SDL_aaevents.c	\
+	SDL_aaevents_c.h	\
+	SDL_aamouse.c		\
+	SDL_aamouse_c.h	\
+	SDL_aavideo.c
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aaevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,202 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting AA events into SDL events */
+
+#include <stdio.h>
+
+#include <aalib.h>
+
+#include "SDL.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_aavideo.h"
+#include "SDL_aaevents_c.h"
+
+/* The translation tables from a console scancode to a SDL keysym */
+static SDLKey keymap[401];
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+
+void AA_PumpEvents(_THIS)
+{
+	int posted = 0;
+	int mouse_button, mouse_x, mouse_y;
+	int evt;
+	SDL_keysym keysym;
+
+	static int prev_button = -1, prev_x = -1, prev_y = -1;
+
+	if( ! this->screen ) /* Wait till we got the screen initialized */
+	  return;
+
+	do {
+		posted = 0;
+		/* Gather events */
+
+		/* Get mouse status */
+		SDL_mutexP(AA_mutex);
+		aa_getmouse (AA_context, &mouse_x, &mouse_y, &mouse_button);
+		SDL_mutexV(AA_mutex);
+		mouse_x = mouse_x * this->screen->w / aa_scrwidth (AA_context);
+		mouse_y = mouse_y * this->screen->h / aa_scrheight (AA_context);
+
+		/* Compare against previous state and generate events */
+		if( prev_button != mouse_button ) {
+			if( mouse_button & AA_BUTTON1 ) {
+				if ( ! (prev_button & AA_BUTTON1) ) {
+					posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
+				}
+			} else {
+				if ( prev_button & AA_BUTTON1 ) {
+					posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
+				}
+			}
+			if( mouse_button & AA_BUTTON2 ) {
+				if ( ! (prev_button & AA_BUTTON2) ) {
+					posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0);
+				}
+			} else {
+				if ( prev_button & AA_BUTTON2 ) {
+					posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0);
+				}
+			}
+			if( mouse_button & AA_BUTTON3 ) {
+				if ( ! (prev_button & AA_BUTTON3) ) {
+					posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
+				}
+			} else {
+				if ( prev_button & AA_BUTTON3 ) {
+					posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
+				}
+			}
+		}
+		if ( prev_x != mouse_x || prev_y != mouse_y ) {
+			posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y);
+		}
+
+		prev_button = mouse_button;
+		prev_x = mouse_x; prev_y = mouse_y;
+
+		/* Get keyboard event */
+		SDL_mutexP(AA_mutex);
+		evt = aa_getevent(AA_context, 0);
+		SDL_mutexV(AA_mutex);
+		if ( (evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) && (evt != AA_RESIZE) ) {
+			/* Key pressed */
+/*    			printf("Key pressed: %d (%c)\n", evt, evt); */
+			posted += SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym));
+		} else if ( evt >= AA_RELEASE ) {
+			/* Key released */
+			evt &= ~AA_RELEASE;
+/*  			printf("Key released: %d (%c)\n", evt, evt); */
+			posted += SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym));
+		}
+	} while ( posted );
+}
+
+void AA_InitOSKeymap(_THIS)
+{
+	int i;
+	static const char *std_keys = " 01234567890&#'()_-|$*+-=/\\:;.,!?<>{}[]@~%^\x9";
+	const char *std;
+
+	/* Initialize the AAlib key translation table */
+	for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+		keymap[i] = SDLK_UNKNOWN;
+
+	keymap[AA_ESC] = SDLK_ESCAPE;
+	keymap[AA_UP] = SDLK_UP;
+	keymap[AA_DOWN] = SDLK_DOWN;
+	keymap[AA_LEFT] = SDLK_LEFT;
+	keymap[AA_RIGHT] = SDLK_RIGHT;
+
+	/* Alphabet keys */
+	for ( i = 0; i<26; ++i ){
+		keymap['a' + i] = SDLK_a+i;
+		keymap['A' + i] = SDLK_a+i;
+	}
+	/* Function keys */
+	for ( i = 0; i<12; ++i ){
+		keymap[334 + i] = SDLK_F1+i;
+	}
+	/* Keys that have the same symbols and don't have to be translated */
+	for( std = std_keys; *std; std ++ ) {
+		keymap[*std] = *std;
+	}
+
+	keymap[13] = SDLK_RETURN;
+	keymap[AA_BACKSPACE] = SDLK_BACKSPACE;
+
+	keymap[369] = SDLK_LSHIFT;
+	keymap[370] = SDLK_RSHIFT;
+	keymap[371] = SDLK_LCTRL;
+	keymap[372] = SDLK_RCTRL;
+	keymap[377] = SDLK_LALT;
+	keymap[270] = SDLK_RALT;
+	keymap[271] = SDLK_NUMLOCK;
+	keymap[373] = SDLK_CAPSLOCK;
+	keymap[164] = SDLK_SCROLLOCK;
+
+	keymap[243] = SDLK_INSERT;
+	keymap[304] = SDLK_DELETE;
+	keymap[224] = SDLK_HOME;
+	keymap[231] = SDLK_END;
+	keymap[229] = SDLK_PAGEUP;
+	keymap[230] = SDLK_PAGEDOWN;
+
+	keymap[241] = SDLK_PRINT;
+	keymap[163] = SDLK_BREAK;
+
+	keymap[302] = SDLK_KP0;
+	keymap[300] = SDLK_KP1;
+	keymap[297] = SDLK_KP2;
+	keymap[299] = SDLK_KP3;
+	keymap[294] = SDLK_KP4;
+	keymap[301] = SDLK_KP5;
+	keymap[296] = SDLK_KP6;
+	keymap[293] = SDLK_KP7;
+	keymap[295] = SDLK_KP8;
+	keymap[298] = SDLK_KP9;
+}
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->sym = keymap[scancode];
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE ) {
+		/* Populate the unicode field with the ASCII value */
+		keysym->unicode = scancode;
+	}
+	return(keysym);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aaevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_aavideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern void AA_initkeymaps(int fd);
+extern void AA_mousecallback(int button, int dx, int dy,
+                                 int u1,int u2,int u3, int u4);
+extern void AA_keyboardcallback(int scancode, int pressed);
+
+extern void AA_InitOSKeymap(_THIS);
+extern void AA_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aamouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+
+#include "SDL_aamouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	int unused;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aamouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_aavideo.h"
+
+/* Functions to be exported */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aavideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,396 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* AAlib based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+
+#include "SDL_aavideo.h"
+#include "SDL_aaevents_c.h"
+#include "SDL_aamouse_c.h"
+
+#include <aalib.h>
+
+/* Initialization/Query functions */
+static int AA_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void AA_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int AA_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int AA_LockHWSurface(_THIS, SDL_Surface *surface);
+static int AA_FlipHWSurface(_THIS, SDL_Surface *surface);
+static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void AA_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* Cache the VideoDevice struct */
+static struct SDL_VideoDevice *local_this;
+
+/* AAlib driver bootstrap functions */
+
+static int AA_Available(void)
+{
+	return 1; /* Always available ! */
+}
+
+static void AA_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *AA_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = AA_VideoInit;
+	device->ListModes = AA_ListModes;
+	device->SetVideoMode = AA_SetVideoMode;
+	device->CreateYUVOverlay = NULL;
+	device->SetColors = AA_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = AA_VideoQuit;
+	device->AllocHWSurface = AA_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = AA_LockHWSurface;
+	device->UnlockHWSurface = AA_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = AA_FreeHWSurface;
+	device->SetCaption = NULL;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->InitOSKeymap = AA_InitOSKeymap;
+	device->PumpEvents = AA_PumpEvents;
+
+	device->free = AA_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap AALIB_bootstrap = {
+	"aalib", "ASCII Art Library",
+	AA_Available, AA_CreateDevice
+};
+
+static void AA_ResizeHandler(aa_context *);
+
+int AA_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	int keyboard;
+	int i;
+
+	/* Initialize all variables that we clean on shutdown */
+	for ( i=0; i<SDL_NUMMODES; ++i ) {
+		SDL_modelist[i] = malloc(sizeof(SDL_Rect));
+		SDL_modelist[i]->x = SDL_modelist[i]->y = 0;
+	}
+	/* Modes sorted largest to smallest */
+	SDL_modelist[0]->w = 1024; SDL_modelist[0]->h = 768;
+	SDL_modelist[1]->w = 800; SDL_modelist[1]->h = 600;
+	SDL_modelist[2]->w = 640; SDL_modelist[2]->h = 480;
+	SDL_modelist[3]->w = 320; SDL_modelist[3]->h = 400;
+	SDL_modelist[4]->w = 320; SDL_modelist[4]->h = 240;
+	SDL_modelist[5]->w = 320; SDL_modelist[5]->h = 200;
+	SDL_modelist[6] = NULL;
+
+	/* Initialize the library */
+
+	AA_mutex = SDL_CreateMutex();
+
+	aa_parseoptions (NULL, NULL, NULL, NULL);
+
+	AA_context = aa_autoinit(&aa_defparams);
+	if ( ! AA_context ) {
+		SDL_SetError("Unable to initialize AAlib");
+		return(-1);
+	}
+
+	/* Enable mouse and keyboard support */
+
+	if ( ! aa_autoinitkbd (AA_context, AA_SENDRELEASE) ) {
+		SDL_SetError("Unable to initialize AAlib keyboard");
+		return(-1);
+	}
+	if ( ! aa_autoinitmouse (AA_context, AA_SENDRELEASE) ) {
+		fprintf(stderr,"Warning: Unable to initialize AAlib mouse");
+	}
+	AA_rparams = aa_getrenderparams();
+
+	local_this = this;
+
+	aa_resizehandler(AA_context, AA_ResizeHandler);
+
+	fprintf(stderr,"Using AAlib driver: %s (%s)\n", AA_context->driver->name, AA_context->driver->shortname);
+
+	AA_in_x11 = (strcmp(AA_context->driver->shortname,"X11") == 0);
+	/* Determine the screen depth (use default 8-bit depth) */
+	vformat->BitsPerPixel = 8;
+	vformat->BytesPerPixel = 1;
+
+	/* We're done! */
+	return(0);
+}
+
+SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+     if(format->BitsPerPixel != 8)
+ 		return NULL;
+
+	 if ( flags & SDL_FULLSCREEN ) {
+		 return SDL_modelist;
+	 } else {
+		 return (SDL_Rect **) -1;
+	 }
+}
+
+/* From aavga.c
+   AAlib does not give us the choice of the actual resolution, thus we have to simulate additional
+   resolution by scaling down manually each frame
+*/
+static void fastscale (register char *b1, register char *b2, int x1, int x2, int y1, int y2)
+{
+	register int ex, spx = 0, ddx, ddx1;
+	int ddy1, ddy, spy = 0, ey;
+	int x;
+	char *bb1 = b1;
+	if (!x1 || !x2 || !y1 || !y2)
+		return;
+	ddx = x1 + x1;
+	ddx1 = x2 + x2;
+	if (ddx1 < ddx)
+		spx = ddx / ddx1, ddx %= ddx1;
+	ddy = y1 + y1;
+	ddy1 = y2 + y2;
+	if (ddy1 < ddy)
+		spy = (ddy / ddy1) * x1, ddy %= ddy1;
+	ey = -ddy1;
+	for (; y2; y2--) {
+		ex = -ddx1;
+		for (x = x2; x; x--) {
+			*b2 = *b1;
+			b2++;
+			b1 += spx;
+			ex += ddx;
+			if (ex > 0) {
+				b1++;
+				ex -= ddx1;
+			}
+		}
+		bb1 += spy;
+		ey += ddy;
+		if (ey > 0) {
+			bb1 += x1;
+			ey -= ddy1;
+		}
+		b1 = bb1;
+	}
+}
+
+/* Various screen update functions available */
+static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	int mode;
+
+	if ( AA_buffer ) {
+		free( AA_buffer );
+	}
+
+	AA_buffer = malloc(width * height);
+	if ( ! AA_buffer ) {
+		SDL_SetError("Couldn't allocate buffer for requested mode");
+		return(NULL);
+	}
+
+/* 	printf("Setting mode %dx%d\n", width, height); */
+
+	memset(aa_image(AA_context), 0, aa_imgwidth(AA_context) * aa_imgheight(AA_context));
+	memset(AA_buffer, 0, width * height);
+
+	/* Allocate the new pixel format for the screen */
+	if ( ! SDL_ReallocFormat(current, 8, 0, 0, 0, 0) ) {
+		return(NULL);
+	}
+
+	/* Set up the new mode framebuffer */
+	current->flags = SDL_FULLSCREEN;
+	AA_w = current->w = width;
+	AA_h = current->h = height;
+	current->pitch = current->w;
+	current->pixels = AA_buffer;
+
+	AA_x_ratio = ((double)aa_imgwidth(AA_context)) / ((double)width);
+	AA_y_ratio = ((double)aa_imgheight(AA_context)) / ((double)height);
+
+	/* Set the blit function */
+	this->UpdateRects = AA_DirectUpdate;
+
+	/* We're done */
+	return(current);
+}
+
+static void AA_ResizeHandler(aa_context *context)
+{
+	aa_resize(context);
+	local_this->hidden->x_ratio = ((double)aa_imgwidth(context)) / ((double)local_this->screen->w);
+	local_this->hidden->y_ratio = ((double)aa_imgheight(context)) / ((double)local_this->screen->h);
+
+	fastscale (local_this->hidden->buffer, aa_image(context), local_this->hidden->w, aa_imgwidth (context), local_this->hidden->h, aa_imgheight (context));
+	aa_renderpalette(context, local_this->hidden->palette, local_this->hidden->rparams, 0, 0, aa_scrwidth(context), aa_scrheight(context));
+	aa_flush(context);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int AA_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void AA_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int AA_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	/* TODO ? */
+	return(0);
+}
+static void AA_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* FIXME: How is this done with AAlib? */
+static int AA_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	SDL_mutexP(AA_mutex);
+	aa_flush(AA_context);
+	SDL_mutexV(AA_mutex);
+	return(0);
+}
+
+static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	int i;
+	SDL_Rect *rect;
+
+	fastscale (AA_buffer, aa_image(AA_context), AA_w, aa_imgwidth (AA_context), AA_h, aa_imgheight (AA_context));
+#if 1
+	aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, aa_scrwidth(AA_context), aa_scrheight(AA_context));
+#else
+	/* Render only the rectangles in the list */
+	printf("Update rects : ");
+	for ( i=0; i < numrects; ++i ) {
+		rect = &rects[i];
+		printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h);
+		aa_renderpalette(AA_context, AA_palette, AA_rparams, rect->x * AA_x_ratio, rect->y * AA_y_ratio, rect->w * AA_x_ratio, rect->h * AA_y_ratio);
+	}
+	printf("\n");
+#endif
+	SDL_mutexP(AA_mutex);
+	aa_flush(AA_context);
+	SDL_mutexV(AA_mutex);
+	return;
+}
+
+int AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+
+	for ( i=0; i < ncolors; i++ ) {
+	        aa_setpalette(AA_palette, firstcolor + i,
+			      colors[i].r>>2,
+			      colors[i].g>>2,
+			      colors[i].b>>2);
+	}
+	return(1);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+void AA_VideoQuit(_THIS)
+{
+	int i;
+
+	aa_uninitkbd(AA_context);
+	aa_uninitmouse(AA_context);
+
+	/* Free video mode lists */
+	for ( i=0; i<SDL_NUMMODES; ++i ) {
+		if ( SDL_modelist[i] != NULL ) {
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+	}
+	
+	aa_close(AA_context);
+
+	SDL_DestroyMutex(AA_mutex);
+
+	this->screen->pixels = NULL;	
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/aalib/SDL_aavideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,70 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_aavideo_h
+#define _SDL_aavideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_mutex.h"
+
+#include <aalib.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+#define SDL_NUMMODES 6
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];
+	aa_context *context;
+	aa_palette palette;
+	aa_renderparams *rparams;
+	double x_ratio, y_ratio;
+    int w, h;
+    SDL_mutex *mutex;
+    int in_x11;
+    void *buffer;
+};
+
+/* Old variable names */
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define AA_context		    (this->hidden->context)
+#define AA_palette		    (this->hidden->palette)
+#define AA_rparams		    (this->hidden->rparams)
+#define AA_buffer		    (this->hidden->buffer)
+
+#define AA_x_ratio		    (this->hidden->x_ratio)
+#define AA_y_ratio		    (this->hidden->y_ratio)
+
+#define AA_mutex		    (this->hidden->mutex)
+#define AA_in_x11		    (this->hidden->in_x11)
+#define AA_w                (this->hidden->w)
+#define AA_h                (this->hidden->h)
+
+#endif /* _SDL_aavideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/blank_cursor.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ * A default blank 8x8 cursor                                                */
+
+#define BLANK_CWIDTH	8
+#define BLANK_CHEIGHT	8
+#define BLANK_CHOTX	0
+#define BLANK_CHOTY	0
+
+static unsigned char blank_cdata[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned char blank_cmask[8] = { 0, 0, 0, 0, 0, 0, 0, 0 };
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,19 @@
+
+## Makefile.am for SDL using the BeOS BWindow video driver
+
+noinst_LTLIBRARIES = libvideo_bwindow.la
+libvideo_bwindow_la_SOURCES = $(BWINDOW_SRCS)
+
+# The SDL BWindow video driver sources
+BWINDOW_SRCS = 			\
+	SDL_BView.h		\
+	SDL_BWin.h		\
+	SDL_lowvideo.h		\
+	SDL_sysevents.cc	\
+	SDL_sysevents_c.h	\
+	SDL_sysmouse.cc		\
+	SDL_sysmouse_c.h	\
+	SDL_sysvideo.cc		\
+	SDL_syswm.cc		\
+	SDL_syswm_c.h
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_BView.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,107 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the event handling and graphics update portion of SDL_BWin */
+
+extern "C" {
+#include "SDL_events_c.h"
+};
+
+class SDL_BView : public BView
+{
+public:
+	SDL_BView(BRect frame) : 
+		BView(frame, "SDL View", B_FOLLOW_ALL_SIDES,
+					(B_WILL_DRAW|B_FRAME_EVENTS)) {
+		image = NULL;
+		xoff = yoff = 0;
+		SetViewColor(0,0,0,0);
+		SetHighColor(0,0,0,0);
+	}
+	virtual ~SDL_BView() {
+		SetBitmap(NULL);
+	}
+	/* Set drawing offsets for fullscreen mode */
+	virtual void SetXYOffset(int x, int y) {
+		xoff = x;
+		yoff = y;
+	}
+	/* The view changed size. If it means we're in fullscreen, we
+	 * draw a nice black box in the entire view to get black borders.
+	 */
+	virtual void FrameResized(float width, float height) {
+		BRect bounds;
+		bounds.top = bounds.left = 0;
+		bounds.right = width;
+		bounds.bottom = height;
+		/* Fill the entire view with black */ 
+		FillRect(bounds, B_SOLID_HIGH);
+		/* And if there's an image, redraw it. */
+		if( image ) {
+			bounds = image->Bounds();
+			Draw(bounds);
+		}
+	}
+	
+	/* Drawing portion of this complete breakfast. :) */
+	virtual void SetBitmap(BBitmap *bitmap) {
+		if ( image ) {
+			delete image;
+		}
+		image = bitmap;
+	}
+	virtual void Draw(BRect updateRect) {
+		if ( image ) {
+			if(xoff || yoff) {	
+				BRect dest;
+				dest.top    = updateRect.top + yoff;
+				dest.left   = updateRect.left + xoff;
+				dest.bottom = updateRect.bottom + yoff;
+				dest.right  = updateRect.right + xoff;;
+				DrawBitmap(image, updateRect, dest);
+			} else {
+				DrawBitmap(image, updateRect, updateRect);
+			}
+		}
+	}
+	virtual void DrawAsync(BRect updateRect) {
+		if(xoff || yoff) {	
+			BRect dest;
+			dest.top    = updateRect.top + yoff;
+			dest.left   = updateRect.left + xoff;
+			dest.bottom = updateRect.bottom + yoff;
+			dest.right  = updateRect.right + xoff;;
+			DrawBitmapAsync(image, updateRect, dest);
+		} else {
+			DrawBitmapAsync(image, updateRect, updateRect);
+		}
+	}
+
+private:
+	BBitmap *image;
+	int xoff, yoff;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_BWin.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,212 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_BWin_h
+#define _SDL_BWin_h
+
+#include <stdio.h>
+#include <AppKit.h>
+#include <InterfaceKit.h>
+#include <be/game/DirectWindow.h>
+#ifdef HAVE_OPENGL
+#include <be/opengl/GLView.h>
+#endif
+
+#include "SDL_BeApp.h"
+#include "SDL_events.h"
+#include "SDL_BView.h"
+
+extern "C" {
+#include "SDL_events_c.h"
+};
+
+class SDL_BWin : public BDirectWindow
+{
+public:
+	SDL_BWin(BRect bounds) :
+			BDirectWindow(bounds, "Untitled", B_TITLED_WINDOW, 0) {
+		the_view = NULL;
+#ifdef HAVE_OPENGL
+		SDL_GLView = NULL;
+#endif
+		SDL_View = NULL;
+		Unlock();
+		shown = false;
+		inhibit_resize = false;
+	}
+	virtual ~SDL_BWin() {
+		Lock();
+		if ( the_view ) {
+#ifdef HAVE_OPENGL
+			if ( the_view == SDL_GLView ) {
+				SDL_GLView->UnlockGL();
+			}
+#endif
+			RemoveChild(the_view);
+			the_view = NULL;
+		}
+		Unlock();
+#ifdef HAVE_OPENGL
+		if ( SDL_GLView ) {
+			delete SDL_GLView;
+		}
+#endif
+		if ( SDL_View ) {
+			delete SDL_View;
+		}
+	}
+
+	/* Override the Show() method so we can tell when we've been shown */
+	virtual void Show(void) {
+		BWindow::Show();
+		shown = true;
+	}
+	virtual bool Shown(void) {
+		return (shown);
+	}
+	/* If called, the next resize event will not be forwarded to SDL. */
+	virtual void InhibitResize(void) {
+		inhibit_resize=true;
+	}
+	/* Handle resizing of the window */
+	virtual void FrameResized(float width, float height) {
+		if(inhibit_resize)
+			inhibit_resize = false;
+		else 
+			SDL_PrivateResize((int)width, (int)height);
+	}
+	virtual int CreateView(Uint32 flags) {
+		int retval;
+
+		retval = 0;
+		Lock();
+		if ( flags & SDL_OPENGL ) {
+#ifdef HAVE_OPENGL
+			if ( SDL_GLView == NULL ) {
+				/* FIXME: choose BGL type via user flags */
+				SDL_GLView = new BGLView(Bounds(), "SDL GLView",
+					 	B_FOLLOW_ALL_SIDES,
+                                        	(B_WILL_DRAW|B_FRAME_EVENTS),
+						(BGL_RGB|BGL_DOUBLE|BGL_DEPTH));
+			}
+			if ( the_view != SDL_GLView ) {
+				if ( the_view ) {
+					RemoveChild(the_view);
+				}
+				AddChild(SDL_GLView);
+				SDL_GLView->LockGL();
+				the_view = SDL_GLView;
+			}
+#else
+			SDL_SetError("OpenGL support not enabled");
+			retval = -1;
+#endif
+		} else {
+			if ( SDL_View == NULL ) {
+				SDL_View = new SDL_BView(Bounds());
+			}
+			if ( the_view != SDL_View ) {
+				if ( the_view ) {
+#ifdef HAVE_OPENGL
+					if ( the_view == SDL_GLView ) {
+						SDL_GLView->UnlockGL();
+					}
+#endif
+					RemoveChild(the_view);
+				}
+				AddChild(SDL_View);
+				the_view = SDL_View;
+			}
+		}
+		Unlock();
+		return(retval);
+	}
+	virtual void SetBitmap(BBitmap *bitmap) {
+		SDL_View->SetBitmap(bitmap);
+	}
+	virtual void SetXYOffset(int x, int y) {
+#ifdef HAVE_OPENGL
+		if ( the_view == SDL_GLView ) {
+			return;
+		}
+#endif
+		SDL_View->SetXYOffset(x, y);		
+	}
+	virtual bool BeginDraw(void) {
+		return(Lock());
+	}
+	virtual void DrawAsync(BRect updateRect) {
+		SDL_View->DrawAsync(updateRect);
+	}
+	virtual void EndDraw(void) {
+		SDL_View->Sync();
+		Unlock();
+	}
+#ifdef HAVE_OPENGL
+	virtual void SwapBuffers(void) {
+		SDL_GLView->UnlockGL();
+		SDL_GLView->LockGL();
+		SDL_GLView->SwapBuffers();
+	}
+#endif
+	virtual BView *View(void) {
+		return(the_view);
+	}
+
+	/* Hook functions -- overridden */
+	virtual void Minimize(bool minimize) {
+		/* This is only called when mimimized, not when restored */
+		//SDL_PrivateAppActive(minimize, SDL_APPACTIVE);
+		BWindow::Minimize(minimize);
+	}
+	virtual void WindowActivated(bool active) {
+		SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS);
+	}
+	virtual bool QuitRequested(void) {
+		if ( SDL_BeAppActive > 0 ) {
+			SDL_PrivateQuit();
+			/* We don't ever actually close the window here because
+			   the application should respond to the quit request,
+			   or ignore it as desired.
+			 */
+			return(false);
+		}
+		return(true);	/* Close the app window */
+	}
+
+private:
+#ifdef HAVE_OPENGL
+	BGLView *SDL_GLView;
+#endif
+	SDL_BView *SDL_View;
+	BView *the_view;
+
+	bool shown;
+	bool inhibit_resize;
+};
+
+#endif /* _SDL_BWin_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_lowvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,70 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowvideo_h
+#define _SDL_lowvideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *_this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+	/* The main window */
+	SDL_BWin *SDL_Win;
+
+	/* The fullscreen mode list */
+	display_mode saved_mode;
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+	int SDL_nummodes[NUM_MODELISTS];
+	SDL_Rect **SDL_modelist[NUM_MODELISTS];
+
+	/* A completely clear cursor */
+	WMcursor *BlankCursor;
+
+	/* Mouse state variables */
+	uint32 last_buttons;
+	BPoint last_point;
+
+	/* Keyboard state variables */
+	int key_flip;
+	struct key_info keyinfo[2];
+};
+/* Old variable names */
+#define SDL_Win		(_this->hidden->SDL_Win)
+#define saved_mode	(_this->hidden->saved_mode)
+#define SDL_nummodes	(_this->hidden->SDL_nummodes)
+#define SDL_modelist	(_this->hidden->SDL_modelist)
+#define SDL_BlankCursor	(_this->hidden->BlankCursor)
+#define last_buttons	(_this->hidden->last_buttons)
+#define last_point	(_this->hidden->last_point)
+#define key_flip	(_this->hidden->key_flip)
+#define keyinfo		(_this->hidden->keyinfo)
+
+#endif /* _SDL_lowvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_sysevents.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,433 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <support/UTF8.h>
+#include <stdio.h>
+#include <string.h>
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_BWin.h"
+#include "SDL_lowvideo.h"
+
+extern "C" {
+
+#include "SDL_events_c.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysevents_c.h"
+
+/* A note on why the polling loops are necessary.
+   The BeOS Preview 2 implementation of BView->MouseMoved() only notifies
+   the view when the mouse enters or leaves the view.  The documentation 
+   says that you should loop and use GetMouse() to detect mouse motion.
+   The BeOS Preview 2 implementation of BView->KeyDown() and BView->KeyUp()
+   are only called for keys that generate ASCII characters.  Since we want
+   to act like a low level raw keyboard, we need to poll the state of the
+   keys instead of catching the keys in callbacks.
+   These are documented portions of the BeBook for Preview Release 2
+*/
+ 
+/* Table to convert scancodes to SDL virtual keys */
+static SDLKey keymap[128];
+
+/* Function to convert from a key scancode to a UNICODE character */
+static key_map *be_keymap;
+static int32 *option_caps_map[2], *option_map[2], *caps_map[2], *normal_map[2];
+static char *unicode_map;
+static Uint16 TranslateScancode(int scancode)
+{
+	SDLMod modstate;
+	int shifted;
+	int32 index;		/* Index into system unicode map */
+	Uint16 unicode;
+
+	/* Set the default character -- no character */
+	unicode = 0;
+
+	/* See whether or not the shift state is set */
+	modstate = SDL_GetModState();
+	if ( modstate & KMOD_SHIFT ) {
+		shifted = 1;
+	} else {
+		shifted = 0;
+	}
+
+	if ( modstate & KMOD_NUM ) {
+	/* If numlock is on, numeric keypad keys have shift state inverted */
+		switch (keymap[scancode]) {
+		    case SDLK_KP0:
+		    case SDLK_KP1:
+		    case SDLK_KP2:
+		    case SDLK_KP3:
+		    case SDLK_KP4:
+		    case SDLK_KP5:
+		    case SDLK_KP6:
+		    case SDLK_KP7:
+		    case SDLK_KP8:
+		    case SDLK_KP9:
+		    case SDLK_KP_PERIOD:
+		    case SDLK_KP_DIVIDE:
+		    case SDLK_KP_MULTIPLY:
+		    case SDLK_KP_MINUS:
+		    case SDLK_KP_PLUS:
+		    case SDLK_KP_ENTER:
+		    case SDLK_KP_EQUALS:
+			shifted = !shifted;
+			break;
+		    default:
+			break;
+		}
+	}
+
+	/* Get the index based on modifier state */
+	if ( modstate & KMOD_CTRL )
+		index = be_keymap->control_map[scancode];
+	else
+	if ( (modstate & KMOD_META) && (modstate & KMOD_CAPS) )
+		index = option_caps_map[shifted][scancode];
+	else
+	if ( modstate & KMOD_META )
+		index = option_map[shifted][scancode];
+	else
+	if ( modstate & KMOD_CAPS )
+		index = caps_map[shifted][scancode];
+	else
+		index = normal_map[shifted][scancode];
+
+	/* If there is a mapping, convert character from UTF-8 to UNICODE */
+	if ( unicode_map[index] ) {
+		int32 state, srclen, dstlen;
+		unsigned char destbuf[2];
+
+		state = 0;
+		srclen = unicode_map[index++];
+		dstlen = sizeof(destbuf);
+		convert_from_utf8(B_UNICODE_CONVERSION,
+			&unicode_map[index], &srclen, (char *)destbuf, &dstlen,
+									&state);
+		unicode = destbuf[0];
+		unicode <<= 8;
+		unicode |= destbuf[1];
+
+		/* Keyboard input maps newline to carriage return */
+		if ( unicode == '\n' ) {
+			unicode = '\r';
+		}
+
+		/* For some reason function keys map to control characters */
+# define CTRL(X)	((X)-'@')
+		switch (unicode) {
+		    case CTRL('A'):
+		    case CTRL('B'):
+		    case CTRL('C'):
+		    case CTRL('D'):
+		    case CTRL('E'):
+		    case CTRL('K'):
+		    case CTRL('L'):
+		    case CTRL('P'):
+			if ( ! (modstate & KMOD_CTRL) )
+				unicode = 0;
+			break;
+		    default:
+			break;
+		}
+	}
+	return(unicode);
+}
+
+/* Function to translate a keyboard transition and queue the key event */
+static void QueueKey(int scancode, int pressed)
+{
+	SDL_keysym keysym;
+
+	/* Set the keysym information */
+	keysym.scancode = scancode;
+	keysym.sym = keymap[scancode];
+	keysym.mod = KMOD_NONE;
+	if ( SDL_TranslateUNICODE ) {
+		keysym.unicode = TranslateScancode(scancode);
+	} else {
+		keysym.unicode = 0;
+	}
+
+	/* NUMLOCK and CAPSLOCK are implemented as double-presses in reality */
+	if ( (keysym.sym == SDLK_NUMLOCK) || (keysym.sym == SDLK_CAPSLOCK) ) {
+		pressed = 1;
+	}
+
+	/* Queue the key event */
+	if ( pressed ) {
+		SDL_PrivateKeyboard(SDL_PRESSED, &keysym);
+	} else {
+		SDL_PrivateKeyboard(SDL_RELEASED, &keysym);
+	}
+}
+
+/* This is special because we know it will be run in a loop in a separate
+   thread.  Normally this function should loop as long as there are input
+   states changing, i.e. new events arriving.
+*/
+void BE_PumpEvents(_THIS)
+{
+	BView *view;
+	BRect bounds;
+	BPoint point;
+	uint32 buttons;
+	const uint32 button_masks[3] = {
+		B_PRIMARY_MOUSE_BUTTON,
+		B_TERTIARY_MOUSE_BUTTON, 
+		B_SECONDARY_MOUSE_BUTTON,
+	};
+	unsigned int    i, j;
+
+	/* Check out the mouse buttons and position (slight race condition) */
+	if ( SDL_Win->Lock() ) {
+		/* Don't do anything if we have no view */
+		view = SDL_Win->View();
+		if ( ! view ) {
+			SDL_Win->Unlock();
+			return;
+		}
+		bounds = view->Bounds();
+		/* Get new input state, if still active */
+		if ( SDL_Win->IsActive() ) {
+			key_flip = !key_flip;
+			get_key_info(&keyinfo[key_flip]);
+			view->GetMouse(&point, &buttons, true);
+		} else {
+			key_flip = key_flip;
+			point = last_point;
+			buttons = last_buttons;
+		}
+		SDL_Win->Unlock();
+	} else {
+		return;
+	}
+
+	/* If our view is active, we'll find key changes here */
+	if ( memcmp(keyinfo[0].key_states, keyinfo[1].key_states, 16) != 0 ) {
+		for ( i=0; i<16; ++i ) {
+			Uint8 new_state, transition;
+
+			new_state = keyinfo[key_flip].key_states[i];
+			transition = keyinfo[!key_flip].key_states[i] ^
+					keyinfo[ key_flip].key_states[i];
+			for ( j=0; j<8; ++j ) {
+				if ( transition&0x80 )
+					QueueKey(i*8+j, new_state&0x80);
+				transition <<= 1;
+				new_state <<= 1;
+			}
+		}
+	}
+
+	/* We check keyboard, but not mouse if mouse isn't in window */
+	if ( ! bounds.Contains(point) ) {
+		/* Mouse moved outside our view? */
+		if ( SDL_GetAppState() & SDL_APPMOUSEFOCUS ) {
+			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+			be_app->SetCursor(B_HAND_CURSOR);
+		}
+		return;
+	}
+	/* Has the mouse moved back into our view? */
+	if ( ! (SDL_GetAppState() & SDL_APPMOUSEFOCUS) ) {
+		/* Reset the B_HAND_CURSOR to our own */
+		SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+		SDL_SetCursor(NULL);
+	}
+
+	/* Check for mouse motion */
+	if ( point != last_point ) {
+		SDL_PrivateMouseMotion(0, 0, (int)point.x, (int)point.y);
+	}
+	last_point = point;
+
+	/* Add any mouse button events */
+	for ( i=0; i<SDL_TABLESIZE(button_masks); ++i ) {
+		if ( (buttons ^ last_buttons) & button_masks[i] ) {
+			if ( buttons & button_masks[i] ) {
+				SDL_PrivateMouseButton(SDL_PRESSED, 1+i, 0, 0);
+			} else {
+				SDL_PrivateMouseButton(SDL_RELEASED, 1+i, 0, 0);
+			}
+		}
+	}
+	last_buttons = buttons;
+}
+
+void BE_InitOSKeymap(_THIS)
+{
+	unsigned int i;
+
+	/* Initialize all the key states as "up" */
+	key_flip = 0;
+	memset(keyinfo[key_flip].key_states, 0, 16);
+
+	/* Initialize the BeOS key translation table */
+	/* Source: <be/interface/InterfaceDefs.h> and BeOS keyboard info */
+	for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+		keymap[i] = SDLK_UNKNOWN;
+
+	keymap[0x01]		= SDLK_ESCAPE;
+	keymap[B_F1_KEY]	= SDLK_F1;
+	keymap[B_F2_KEY]	= SDLK_F2;
+	keymap[B_F3_KEY]	= SDLK_F3;
+	keymap[B_F4_KEY]	= SDLK_F4;
+	keymap[B_F5_KEY]	= SDLK_F5;
+	keymap[B_F6_KEY]	= SDLK_F6;
+	keymap[B_F7_KEY]	= SDLK_F7;
+	keymap[B_F8_KEY]	= SDLK_F8;
+	keymap[B_F9_KEY]	= SDLK_F9;
+	keymap[B_F10_KEY]	= SDLK_F10;
+	keymap[B_F11_KEY]	= SDLK_F11;
+	keymap[B_F12_KEY]	= SDLK_F12;
+	keymap[B_PRINT_KEY]	= SDLK_PRINT;
+	//keymap[B_SCROLL_KEY]	= SDLK_SCROLLOCK;
+	keymap[B_PAUSE_KEY]	= SDLK_PAUSE;
+	keymap[0x11]		= SDLK_BACKQUOTE;
+	keymap[0x12]		= SDLK_1;
+	keymap[0x13]		= SDLK_2;
+	keymap[0x14]		= SDLK_3;
+	keymap[0x15]		= SDLK_4;
+	keymap[0x16]		= SDLK_5;
+	keymap[0x17]		= SDLK_6;
+	keymap[0x18]		= SDLK_7;
+	keymap[0x19]		= SDLK_8;
+	keymap[0x1a]		= SDLK_9;
+	keymap[0x1b]		= SDLK_0;
+	keymap[0x1c]		= SDLK_MINUS;
+	keymap[0x1d]		= SDLK_EQUALS;
+	keymap[0x1e]		= SDLK_BACKSPACE;
+	keymap[0x1f]		= SDLK_INSERT;
+	keymap[0x20]		= SDLK_HOME;
+	keymap[0x21]		= SDLK_PAGEUP;
+	//keymap[0x22]		= SDLK_NUMLOCK;
+	keymap[0x23]		= SDLK_KP_DIVIDE;
+	keymap[0x24]		= SDLK_KP_MULTIPLY;
+	keymap[0x25]		= SDLK_KP_MINUS;
+	keymap[0x26]		= SDLK_TAB;
+	keymap[0x27]		= SDLK_q;
+	keymap[0x28]		= SDLK_w;
+	keymap[0x29]		= SDLK_e;
+	keymap[0x2a]		= SDLK_r;
+	keymap[0x2b]		= SDLK_t;
+	keymap[0x2c]		= SDLK_y;
+	keymap[0x2d]		= SDLK_u;
+	keymap[0x2e]		= SDLK_i;
+	keymap[0x2f]		= SDLK_o;
+	keymap[0x30]		= SDLK_p;
+	keymap[0x31]		= SDLK_LEFTBRACKET;
+	keymap[0x32]		= SDLK_RIGHTBRACKET;
+	keymap[0x33]		= SDLK_BACKSLASH;
+	keymap[0x34]		= SDLK_DELETE;
+	keymap[0x35]		= SDLK_END;
+	keymap[0x36]		= SDLK_PAGEDOWN;
+	keymap[0x37]		= SDLK_KP7;
+	keymap[0x38]		= SDLK_KP8;
+	keymap[0x39]		= SDLK_KP9;
+	keymap[0x3a]		= SDLK_KP_PLUS;
+	//keymap[0x3b]		= SDLK_CAPSLOCK;
+	keymap[0x3c]		= SDLK_a;
+	keymap[0x3d]		= SDLK_s;
+	keymap[0x3e]		= SDLK_d;
+	keymap[0x3f]		= SDLK_f;
+	keymap[0x40]		= SDLK_g;
+	keymap[0x41]		= SDLK_h;
+	keymap[0x42]		= SDLK_j;
+	keymap[0x43]		= SDLK_k;
+	keymap[0x44]		= SDLK_l;
+	keymap[0x45]		= SDLK_SEMICOLON;
+	keymap[0x46]		= SDLK_QUOTE;
+	keymap[0x47]		= SDLK_RETURN;
+	keymap[0x48]		= SDLK_KP4;
+	keymap[0x49]		= SDLK_KP5;
+	keymap[0x4a]		= SDLK_KP6;
+	keymap[0x4b]		= SDLK_LSHIFT;
+	keymap[0x4c]		= SDLK_z;
+	keymap[0x4d]		= SDLK_x;
+	keymap[0x4e]		= SDLK_c;
+	keymap[0x4f]		= SDLK_v;
+	keymap[0x50]		= SDLK_b;
+	keymap[0x51]		= SDLK_n;
+	keymap[0x52]		= SDLK_m;
+	keymap[0x53]		= SDLK_COMMA;
+	keymap[0x54]		= SDLK_PERIOD;
+	keymap[0x55]		= SDLK_SLASH;
+	keymap[0x56]		= SDLK_RSHIFT;
+	keymap[0x57]		= SDLK_UP;
+	keymap[0x58]		= SDLK_KP1;
+	keymap[0x59]		= SDLK_KP2;
+	keymap[0x5a]		= SDLK_KP3;
+	keymap[0x5b]		= SDLK_KP_ENTER;
+	//keymap[0x5c]		= SDLK_LCTRL;
+	//keymap[0x5d]		= SDLK_LALT;
+	keymap[0x5e]		= SDLK_SPACE;
+	//keymap[0x5f]		= SDLK_RALT;
+	//keymap[0x60]		= SDLK_RCTRL;
+	keymap[0x61]		= SDLK_LEFT;
+	keymap[0x62]		= SDLK_DOWN;
+	keymap[0x63]		= SDLK_RIGHT;
+	keymap[0x64]		= SDLK_KP0;
+	keymap[0x65]		= SDLK_KP_PERIOD;
+	//keymap[0x66]		= SDLK_LMETA;
+	//keymap[0x67]		= SDLK_RMETA;
+	//keymap[0x68]		= SDLK_MENU;
+	keymap[0x69]		= SDLK_EURO;
+	keymap[0x6a]		= SDLK_KP_EQUALS;
+	keymap[0x6b]		= SDLK_POWER;
+
+	/* Get the system keymap and UNICODE table.
+	   Note that this leaks memory since the maps are never freed.
+	 */
+	get_key_map(&be_keymap, &unicode_map);
+
+	/* Set the modifier keys from the system keymap */
+	keymap[be_keymap->caps_key] = SDLK_CAPSLOCK;
+	keymap[be_keymap->scroll_key] = SDLK_SCROLLOCK;
+	keymap[be_keymap->num_key] = SDLK_NUMLOCK;
+	keymap[be_keymap->left_shift_key] = SDLK_LSHIFT;
+	keymap[be_keymap->right_shift_key] = SDLK_RSHIFT;
+	keymap[be_keymap->left_command_key] = SDLK_LALT;
+	keymap[be_keymap->right_command_key] = SDLK_RALT;
+	keymap[be_keymap->left_control_key] = SDLK_LCTRL;
+	keymap[be_keymap->right_control_key] = SDLK_RCTRL;
+	keymap[be_keymap->left_option_key] = SDLK_LMETA;
+	keymap[be_keymap->right_option_key] = SDLK_RMETA;
+	keymap[be_keymap->menu_key] = SDLK_MENU;
+
+	/* Set the modifier map pointers */
+	option_caps_map[0] = be_keymap->option_caps_map;
+	option_caps_map[1] = be_keymap->option_caps_shift_map;
+	option_map[0] = be_keymap->option_map;
+	option_map[1] = be_keymap->option_shift_map;
+	caps_map[0] = be_keymap->caps_map;
+	caps_map[1] = be_keymap->caps_shift_map;
+	normal_map[0] = be_keymap->normal_map;
+	normal_map[1] = be_keymap->shift_map;
+}
+
+}; /* Extern C */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_sysevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,35 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+
+extern void BE_InitOSKeymap(_THIS);
+extern void BE_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_sysmouse.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,146 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <AppKit.h>
+#include <GameKit.h>
+
+#include "SDL_error.h"
+#include "SDL_BWin.h"
+
+extern "C" {
+
+#include "SDL_sysmouse_c.h"
+
+/* Convert bits to padded bytes */
+#define PADDED_BITS(bits)  ((bits+7)/8)
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	char *bits;
+};
+
+/* Can this be done in the BeOS? */
+WMcursor *BE_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+	WMcursor *cursor;
+	int allowed_x;
+	int allowed_y;
+	int run, pad, i;
+	char *cptr;
+
+	allowed_x = 16;	/* BeOS limitation */
+	allowed_y = 16;	/* BeOS limitation */
+	if ( (w > allowed_x) || (h > allowed_y) ) {
+		SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
+							allowed_x, allowed_y);
+		return(NULL);
+	}
+
+	/* Allocate the cursor */
+	cursor = (WMcursor *)malloc(sizeof(WMcursor));
+	if ( cursor == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	cursor->bits = (char *)malloc(4+2*((allowed_x/8)*allowed_y));
+	if ( cursor->bits == NULL ) {
+		free(cursor);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	cursor->bits[0] = allowed_y;		/* Size of the cursor */
+	cursor->bits[1] = 1;			/* Bit depth of cursor */
+	cursor->bits[2] = hot_y;
+	cursor->bits[3] = hot_x;
+	cptr = &cursor->bits[4];
+
+	/* Pad out to the normal cursor size */
+	run = PADDED_BITS(w);
+	pad = PADDED_BITS(allowed_x)-run;
+	for ( i=0; i<h; ++i ) {
+		memcpy(cptr, data, run);
+		memset(cptr+run, 0, pad);
+		data += run;
+		cptr += (run+pad);
+	}
+	for ( ; i<allowed_y; ++i ) {
+		memset(cptr, 0, run+pad);
+		cptr += (run+pad);
+	}
+	for ( i=0; i<h; ++i ) {
+		/* FIXME: The mask should be OR'd with the data to turn 
+		   inverted color pixels black, since inverted color pixels
+		   aren't supported under BeOS.
+		 */
+		memcpy(cptr, mask, run);
+		memset(cptr+run, 0, pad);
+		mask += run;
+		cptr += (run+pad);
+	}
+	for ( ; i<allowed_y; ++i ) {
+		memset(cptr, 0, run+pad);
+		cptr += (run+pad);
+	}
+	return(cursor);
+}
+
+int BE_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	if ( be_app->Lock() ) {
+		if ( cursor == NULL ) {
+			if ( SDL_BlankCursor != NULL ) {
+				be_app->SetCursor(SDL_BlankCursor->bits);
+			}
+		} else {
+			be_app->SetCursor(cursor->bits);
+		}
+		be_app->Unlock();
+	}
+	return(1);
+}
+
+void BE_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+	free(cursor->bits);
+	free(cursor);
+}
+
+/* Implementation by Christian Bauer <cbauer@student.physik.uni-mainz.de> */
+void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+	BPoint pt(x, y);
+	SDL_Win->Lock();
+	SDL_Win->ConvertToScreen(&pt);
+	SDL_Win->Unlock();
+	set_mouse_position((int32)pt.x, (int32)pt.y);
+}
+
+}; /* Extern C */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_sysmouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Functions to be exported */
+extern void BE_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *BE_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int BE_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_sysvideo.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,673 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* BWindow based framebuffer implementation */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include "SDL.h"
+#include "SDL_BeApp.h"
+#include "SDL_BWin.h"
+#include "SDL_timer.h"
+#include "blank_cursor.h"
+
+extern "C" {
+
+#include "SDL_sysvideo.h"
+#include "SDL_sysmouse_c.h"
+#include "SDL_sysevents_c.h"
+#include "SDL_events_c.h"
+#include "SDL_syswm_c.h"
+#include "SDL_lowvideo.h"
+
+#define BEOS_HIDDEN_SIZE	32	/* starting hidden window size */
+
+/* Initialization/Query functions */
+static int BE_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static void BE_UpdateMouse(_THIS);
+static int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void BE_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int BE_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int BE_LockHWSurface(_THIS, SDL_Surface *surface);
+static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void BE_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+static int BE_ToggleFullScreen(_THIS, int fullscreen);
+
+/* OpenGL functions */
+#ifdef HAVE_OPENGL
+static void BE_GL_SwapBuffers(_THIS);
+#endif
+
+/* FB driver bootstrap functions */
+
+static int BE_Available(void)
+{
+	return(1);
+}
+
+static void BE_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *BE_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = BE_VideoInit;
+	device->ListModes = BE_ListModes;
+	device->SetVideoMode = BE_SetVideoMode;
+	device->UpdateMouse = BE_UpdateMouse;
+	device->SetColors = BE_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = BE_VideoQuit;
+	device->AllocHWSurface = BE_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = BE_LockHWSurface;
+	device->UnlockHWSurface = BE_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = BE_FreeHWSurface;
+#ifdef HAVE_OPENGL
+	device->GL_SwapBuffers = BE_GL_SwapBuffers;
+#endif
+	device->SetIcon = NULL;
+	device->SetCaption = BE_SetWMCaption;
+	device->GetWMInfo = NULL;
+	device->FreeWMCursor = BE_FreeWMCursor;
+	device->CreateWMCursor = BE_CreateWMCursor;
+	device->ShowWMCursor = BE_ShowWMCursor;
+	device->WarpWMCursor = BE_WarpWMCursor;
+	device->InitOSKeymap = BE_InitOSKeymap;
+	device->PumpEvents = BE_PumpEvents;
+
+	device->free = BE_DeleteDevice;
+	device->ToggleFullScreen = BE_ToggleFullScreen;
+
+	/* Set the driver flags */
+	device->handles_any_size = 1;
+	
+	return device;
+}
+
+VideoBootStrap BWINDOW_bootstrap = {
+	"bwindow", "BDirectWindow graphics",
+	BE_Available, BE_CreateDevice
+};
+
+static inline int ColorSpaceToBitsPerPixel(uint32 colorspace)
+{
+	int bitsperpixel;
+
+	bitsperpixel = 0;
+	switch (colorspace) {
+	    case B_CMAP8:
+		bitsperpixel = 8;
+		break;
+	    case B_RGB15:
+	    case B_RGBA15:
+	    case B_RGB15_BIG:
+	    case B_RGBA15_BIG:
+		bitsperpixel = 15;
+		break;
+	    case B_RGB16:
+	    case B_RGB16_BIG:
+		bitsperpixel = 16;
+		break;
+	    case B_RGB32:
+	    case B_RGBA32:
+	    case B_RGB32_BIG:
+	    case B_RGBA32_BIG:
+		bitsperpixel = 32;
+		break;
+	    default:
+		break;
+	}
+	return(bitsperpixel);
+}
+
+/* Function to sort the display_list in bscreen */
+static int CompareModes(const void *A, const void *B)
+{
+	const display_mode *a = (display_mode *)A;
+	const display_mode *b = (display_mode *)B;
+
+	if ( a->space == b->space ) {
+		return((b->virtual_width*b->virtual_height)-
+		       (a->virtual_width*a->virtual_height));
+	} else {
+		return(ColorSpaceToBitsPerPixel(b->space)-
+		       ColorSpaceToBitsPerPixel(a->space));
+	}
+}
+
+/* Yes, this isn't the fastest it could be, but it works nicely */
+static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h)
+{
+	SDL_Rect *mode;
+	int i;
+	int next_mode;
+
+	/* Check to see if we already have this mode */
+	if ( SDL_nummodes[index] > 0 ) {
+		for ( i=SDL_nummodes[index]-1; i >= 0; --i ) {
+			mode = SDL_modelist[index][i];
+			if ( (mode->w == w) && (mode->h == h) ) {
+#ifdef BWINDOW_DEBUG
+				fprintf(stderr, "We already have mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+				return(0);
+			}
+		}
+	}
+
+	/* Set up the new video mode rectangle */
+	mode = (SDL_Rect *)malloc(sizeof *mode);
+	if ( mode == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	mode->x = 0;
+	mode->y = 0;
+	mode->w = w;
+	mode->h = h;
+#ifdef BWINDOW_DEBUG
+	fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+
+	/* Allocate the new list of modes, and fill in the new mode */
+	next_mode = SDL_nummodes[index];
+	SDL_modelist[index] = (SDL_Rect **)
+	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist[index] == NULL ) {
+		SDL_OutOfMemory();
+		SDL_nummodes[index] = 0;
+		free(mode);
+		return(-1);
+	}
+	SDL_modelist[index][next_mode] = mode;
+	SDL_modelist[index][next_mode+1] = NULL;
+	SDL_nummodes[index]++;
+
+	return(0);
+}
+
+int BE_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	display_mode *modes;
+	uint32 i, nmodes;
+	int bpp;
+	BRect bounds;
+
+	/* Initialize the Be Application for appserver interaction */
+	if ( SDL_InitBeApp() < 0 ) {
+		return(-1);
+	}
+
+	/* It is important that this be created after SDL_InitBeApp() */
+	BScreen bscreen;
+
+	/* Save the current display mode */
+	bscreen.GetMode(&saved_mode);
+
+	/* Determine the screen depth */
+	vformat->BitsPerPixel = ColorSpaceToBitsPerPixel(bscreen.ColorSpace());
+	if ( vformat->BitsPerPixel == 0 ) {
+		SDL_SetError("Unknown BScreen colorspace: 0x%x",
+						bscreen.ColorSpace());
+		return(-1);
+	}
+
+	/* Get the video modes we can switch to in fullscreen mode */
+	bscreen.GetModeList(&modes, &nmodes);
+	qsort(modes, nmodes, sizeof *modes, CompareModes);
+	for ( i=0; i<nmodes; ++i ) {
+		bpp = ColorSpaceToBitsPerPixel(modes[i].space);
+		//if ( bpp != 0 ) { // There are bugs in changing colorspace
+		if ( modes[i].space == saved_mode.space ) {
+			BE_AddMode(_this, ((bpp+7)/8)-1,
+				modes[i].virtual_width,
+				modes[i].virtual_height);
+		}
+	}
+
+	/* Create the window and view */
+	bounds.top = 0; bounds.left = 0;
+	bounds.right = BEOS_HIDDEN_SIZE;
+	bounds.bottom = BEOS_HIDDEN_SIZE;
+	SDL_Win = new SDL_BWin(bounds);
+
+	/* Create the clear cursor */
+	SDL_BlankCursor = BE_CreateWMCursor(_this, blank_cdata, blank_cmask,
+			BLANK_CWIDTH, BLANK_CHEIGHT, BLANK_CHOTX, BLANK_CHOTY);
+
+	/* Fill in some window manager capabilities */
+	_this->info.wm_available = 1;
+
+	/* We're done! */
+	return(0);
+}
+
+/* We support any dimension at our bit-depth */
+SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	SDL_Rect **modes;
+
+	modes = ((SDL_Rect **)0);
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		modes = SDL_modelist[((format->BitsPerPixel+7)/8)-1];
+	} else {
+		if ( format->BitsPerPixel ==
+			_this->screen->format->BitsPerPixel ) {
+			modes = ((SDL_Rect **)-1);
+		}
+	}
+	return(modes);
+}
+
+/* Various screen update functions available */
+static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+
+/* Find the closest display mode for fullscreen */
+static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp,
+					 display_mode *mode)
+{
+	BScreen bscreen;
+	uint32 i, nmodes;
+	SDL_Rect **modes;
+	display_mode *dmodes;
+
+	modes = SDL_modelist[((bpp+7)/8)-1];
+	for ( i=0; modes[i] && (modes[i]->w > width) &&
+		      (modes[i]->h > height); ++i ) {
+		/* still looking */
+	}
+	if ( ! modes[i] || (modes[i]->w < width) || (modes[i]->h < width) ) {
+		--i;	/* We went too far */
+	}
+	width = modes[i]->w;
+	height = modes[i]->h;      
+	bscreen.GetModeList(&dmodes, &nmodes);
+	for ( i = 0; i < nmodes; ++i ) {
+		if ( (bpp == ColorSpaceToBitsPerPixel(dmodes[i].space)) &&
+		     (width == dmodes[i].virtual_width) &&
+		     (height == dmodes[i].virtual_height) ) {
+			break;
+		}
+	}
+	if ( i != nmodes ) {
+		*mode = dmodes[i];
+		return true;
+	} else {
+		return false;
+	}	
+}
+
+static int BE_ToggleFullScreen(_THIS, int fullscreen)
+{
+	bool needs_unlock, is_fullscreen;	
+	BScreen bscreen;
+	BRect bounds;
+	display_mode mode;
+	int width, height, bpp;
+
+	SDL_Win->SetFullScreen(fullscreen);
+	is_fullscreen = SDL_Win->IsFullScreen();
+					     
+	if(!((is_fullscreen && fullscreen) ||
+	     (!is_fullscreen && !fullscreen))) {
+		/* Modeswitch failed */
+		return 0;
+	}
+	
+	if(is_fullscreen)	_this->screen->flags |= SDL_FULLSCREEN;
+	else			_this->screen->flags &= ~SDL_FULLSCREEN;
+
+	width = _this->screen->w;
+	height = _this->screen->h;
+
+	/* Set the appropriate video mode */
+	if ( fullscreen ) {
+		bpp = _this->screen->format->BitsPerPixel;
+		bscreen.GetMode(&mode);
+		if ( (bpp != ColorSpaceToBitsPerPixel(mode.space)) ||
+		     (width != mode.virtual_width) ||
+		     (height != mode.virtual_height)) {
+			if(BE_FindClosestFSMode(_this, width, height, bpp, &mode)) {
+				bscreen.SetMode(&mode);
+				/* This simply stops the next resize event from being
+				 * sent to the SDL handler.
+				 */
+				SDL_Win->InhibitResize();
+			} else {
+				_this->screen->flags &= ~SDL_FULLSCREEN;
+			}
+		}
+		
+	} else {
+		bscreen.SetMode(&saved_mode);
+	}
+	
+	if ( SDL_Win->Lock() ) {
+		int xoff, yoff;
+		if ( SDL_Win->Shown() ) {
+			needs_unlock = 1;
+			SDL_Win->Hide();
+		} else {
+			needs_unlock = 0;
+		}
+		/* This resizes the window and view area, but inhibits resizing of
+		 * the BBitmap due to the InhibitResize call above. Thus the bitmap
+		 * (pixel data) never changes.
+		 */
+		SDL_Win->ResizeTo(width, height);
+		bounds = bscreen.Frame();
+		/* Calculate offsets - used either to center window (windowed mode)
+		 * or to set drawing offsets (fullscreen mode)
+		 */
+		xoff = (bounds.IntegerWidth() - _this->screen->w)/2;
+		yoff = (bounds.IntegerHeight() - _this->screen->h)/2;
+		if(fullscreen) {
+			/* Set offset for drawing */
+			SDL_Win->SetXYOffset(xoff, yoff);
+		} else {
+			/* Center window and reset the drawing offset */
+			SDL_Win->MoveTo(xoff > 0 ? (float)xoff : 0.0,
+					yoff > 0 ? (float)yoff : 0.0);
+			SDL_Win->SetXYOffset(0, 0);
+		}
+		SDL_Win->Show();
+		
+		/* Unlock the window manually after the first Show() */
+		if ( needs_unlock ) { SDL_Win->Unlock(); }
+	}
+	return(1);
+}
+
+/* FIXME: check return values and cleanup here */
+SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	BScreen bscreen;
+	display_mode mode;
+	BBitmap *bbitmap;
+	BRect bounds;
+	int needs_unlock;
+	int xoff = 0, yoff = 0;
+
+	/* Set the appropriate video mode */
+	if ( flags & SDL_FULLSCREEN ) { 
+		bscreen.GetMode(&mode);
+		if ( (bpp != ColorSpaceToBitsPerPixel(mode.space)) ||
+		     (width != mode.virtual_width) ||
+		     (height != mode.virtual_height) ) {
+			if(BE_FindClosestFSMode(_this, width, height, bpp, &mode)) {
+				bscreen.SetMode(&mode);
+				xoff = (mode.virtual_width - width)/2;
+				yoff = (mode.virtual_height - height)/2;
+			} else {
+				flags &= ~SDL_FULLSCREEN;
+			}
+		}
+	} else {
+		if ( current->flags & SDL_FULLSCREEN ) {
+			bscreen.SetMode(&saved_mode);
+		}
+	}
+
+	/* Create the view for this window */
+	if ( SDL_Win->CreateView(flags) < 0 ) {
+		return(NULL);
+	}
+
+	/* Set offsets */
+	SDL_Win->SetXYOffset(xoff, yoff);
+
+	current->flags = 0;		/* Clear flags */
+	current->w = width;
+	current->h = height;
+	if ( flags & SDL_FULLSCREEN ) {
+		SDL_Win->SetFullScreen(1);
+		current->flags |= SDL_FULLSCREEN;
+	} else {
+		SDL_Win->SetFullScreen(0);
+	}
+	SDL_Win->SetType(B_TITLED_WINDOW);
+	if ( flags & SDL_NOFRAME ) {
+		current->flags |= SDL_NOFRAME;
+		SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK);
+	} else {
+		if ( (flags & SDL_RESIZABLE) && !(flags & SDL_OPENGL) )  {
+			current->flags |= SDL_RESIZABLE;
+			/* We don't want opaque resizing (TM). :-) */
+			SDL_Win->SetFlags(B_OUTLINE_RESIZE);
+		} else {
+			SDL_Win->SetFlags(B_NOT_RESIZABLE|B_NOT_ZOOMABLE);
+		}
+	}
+
+	if ( flags & SDL_OPENGL ) {
+		current->flags |= SDL_OPENGL;
+		current->pitch = 0;
+		current->pixels = NULL;
+		_this->UpdateRects = NULL;		
+		//		_this->ToggleFullScreen = NULL;
+	} else {
+		/* Create the BBitmap framebuffer */
+		bounds.top = 0; bounds.left = 0;
+		bounds.right = width-1;
+		bounds.bottom = height-1;
+		bbitmap = new BBitmap(bounds, bscreen.ColorSpace());
+		if ( ! bbitmap->IsValid() ) {
+			SDL_SetError("Couldn't create screen bitmap");
+			delete bbitmap;
+			return(NULL);
+		}
+		current->pitch = bbitmap->BytesPerRow();
+		current->pixels = (void *)bbitmap->Bits();
+		SDL_Win->SetBitmap(bbitmap);
+		_this->UpdateRects = BE_NormalUpdate;
+	}
+
+	/* Hide the window for resizing */
+	if ( SDL_Win->Lock() ) {
+		if ( SDL_Win->Shown() ) {
+			needs_unlock = 1;
+			SDL_Win->Hide();
+		} else {
+			needs_unlock = 0;
+		}
+
+		/* Resize, but only if the window is different size than
+		 * before. Otherwise it jumps funnily when the user resizes.
+		 */
+		bounds = SDL_Win->Bounds();
+		if((int)bounds.Width() != width ||
+		   (int)bounds.Height() != height) {
+			SDL_Win->ResizeTo(width, height);
+			bounds = bscreen.Frame();
+			SDL_Win->MoveTo((bounds.Width()-width)/2,
+					(bounds.Height()-height)/2);
+		}
+		SDL_Win->Show();
+
+		/* Unlock the window manually after the first Show() */
+		if ( needs_unlock ) {
+			SDL_Win->Unlock();
+		}
+	}
+
+	/* We're done */
+	return(current);
+}
+
+/* Update the current mouse state and position */
+void BE_UpdateMouse(_THIS)
+{
+	BPoint point;
+	uint32 buttons;
+
+	if ( SDL_Win->Lock() ) {
+		/* Get new input state, if still active */
+		if ( SDL_Win->IsActive() ) {
+			(SDL_Win->View())->GetMouse(&point, &buttons, true);
+		} else {
+			point.x = -1;
+			point.y = -1;
+		}
+		SDL_Win->Unlock();
+
+		if ( (point.x >= 0) && (point.x < SDL_VideoSurface->w) &&
+		     (point.y >= 0) && (point.y < SDL_VideoSurface->h) ) {
+			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			SDL_PrivateMouseMotion(0, 0,
+					(Sint16)point.x, (Sint16)point.y);
+		} else {
+			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+		}
+	}
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int BE_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void BE_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+static int BE_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+static void BE_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	if ( SDL_Win->BeginDraw() ) {
+		int i;
+
+		for ( i=0; i<numrects; ++i ) {
+			BRect rect;
+
+			rect.top = rects[i].y;
+			rect.left = rects[i].x;
+			rect.bottom = rect.top+rects[i].h-1;
+			rect.right = rect.left+rects[i].w-1;
+			SDL_Win->DrawAsync(rect);
+		}
+		SDL_Win->EndDraw();
+	}
+}
+
+#ifdef HAVE_OPENGL
+void BE_GL_SwapBuffers(_THIS)
+{
+	SDL_Win->SwapBuffers();
+}
+#endif
+
+/* Is the system palette settable? */
+int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+	SDL_Palette *palette;
+	const color_map *cmap = BScreen().ColorMap();
+
+	/* Get the screen colormap */
+	palette = _this->screen->format->palette;
+	for ( i=0; i<256; ++i ) {
+		palette->colors[i].r = cmap->color_list[i].red;
+		palette->colors[i].g = cmap->color_list[i].green;
+		palette->colors[i].b = cmap->color_list[i].blue;
+	}
+	return(0);
+}
+
+void BE_VideoQuit(_THIS)
+{
+	int i, j;
+
+	if ( SDL_BlankCursor != NULL ) {
+		BE_FreeWMCursor(_this, SDL_BlankCursor);
+		SDL_BlankCursor = NULL;
+	}
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_modelist[i] ) {
+			for ( j=0; SDL_modelist[i][j]; ++j ) {
+				free(SDL_modelist[i][j]);
+			}
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+	}
+	/* Restore the original video mode */
+	if ( _this->screen ) {
+		if ( (_this->screen->flags&SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			BScreen bscreen;
+			bscreen.SetMode(&saved_mode);
+		}
+		_this->screen->pixels = NULL;
+	}
+	SDL_QuitBeApp();
+}
+
+}; /* Extern C */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_syswm.cc	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_BWin.h"
+
+extern "C" {
+
+#include "SDL_syswm_c.h"
+
+void BE_SetWMCaption(_THIS, const char *title, const char *icon)
+{
+	SDL_Win->SetTitle(title);
+}
+
+}; /* Extern C */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/bwindow/SDL_syswm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Functions to be exported */
+extern void BE_SetWMCaption(_THIS, const char *title, const char *icon);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+
+## Makefile.am for SDL using the CyberGFX video driver
+
+noinst_LTLIBRARIES = libvideo_cgx.la
+libvideo_cgx_la_SOURCES = $(CGX_SRCS)
+
+# The SDL CyberGFX video driver sources
+CGX_SRCS = 			\
+	SDL_amigaevents.c	\
+	SDL_amigaevents_c.h	\
+	SDL_amigamouse.c	\
+	SDL_amigamouse_c.h	\
+	SDL_cgxaccel.c		\
+	SDL_cgxgl.c		\
+	SDL_cgxgl_c.h		\
+	SDL_cgximage.c		\
+	SDL_cgximage_c.h	\
+	SDL_cgxmodes.c		\
+	SDL_cgxmodes_c.h	\
+	SDL_cgxvideo.c		\
+	SDL_cgxvideo.h		\
+	SDL_cgxwm.c		\
+	SDL_cgxwm_c.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_amigaevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,518 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting Amiga events into SDL events */
+#include "SDL.h"
+
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_cgxvideo.h"
+#include "SDL_cgxmodes_c.h"
+#include "SDL_cgximage_c.h"
+#include "SDL_cgxwm_c.h"
+#include "SDL_amigaevents_c.h"
+
+
+/* The translation tables from an Amiga keysym to a SDL keysym */
+static SDLKey MISC_keymap[256];
+SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym);
+struct IOStdReq *ConReq=NULL;
+struct MsgPort *ConPort=NULL;
+
+/* Note:  The X server buffers and accumulates mouse motion events, so
+   the motion event generated by the warp may not appear exactly as we
+   expect it to.  We work around this (and improve performance) by only
+   warping the pointer when it reaches the edge, and then wait for it.
+*/
+#define MOUSE_FUDGE_FACTOR	8
+
+#if 0
+
+static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m)
+{
+	int w, h, i;
+	int deltax, deltay;
+	int posted;
+
+	w = SDL_VideoSurface->w;
+	h = SDL_VideoSurface->h;
+	deltax = xevent->xmotion.x - mouse_last.x;
+	deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
+#endif
+	mouse_last.x = xevent->xmotion.x;
+	mouse_last.y = xevent->xmotion.y;
+	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+
+	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
+	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
+		/* Get the events that have accumulated */
+		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
+			deltax = xevent->xmotion.x - mouse_last.x;
+			deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
+#endif
+			mouse_last.x = xevent->xmotion.x;
+			mouse_last.y = xevent->xmotion.y;
+			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+		}
+		mouse_last.x = w/2;
+		mouse_last.y = h/2;
+		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
+					mouse_last.x, mouse_last.y);
+		for ( i=0; i<10; ++i ) {
+        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
+			if ( (xevent->xmotion.x >
+			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.x <
+			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y >
+			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y <
+			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
+				break;
+			}
+#ifdef DEBUG_XEVENTS
+  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
+#endif
+		}
+#ifdef DEBUG_XEVENTS
+		if ( i == 10 ) {
+			printf("Warning: didn't detect mouse warp motion\n");
+		}
+#endif
+	}
+	return(posted);
+}
+
+#endif
+
+static int amiga_GetButton(int code)
+{
+	switch(code)
+	{
+		case IECODE_MBUTTON:
+			return SDL_BUTTON_MIDDLE;
+		case IECODE_RBUTTON:
+			return SDL_BUTTON_RIGHT;
+		default:
+			return SDL_BUTTON_LEFT;
+	}
+}
+
+static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg)
+{
+	int class=msg->Class,code=msg->Code;
+	int posted;
+
+	posted = 0;
+	switch (class) {
+	    /* Gaining mouse coverage? */
+	    case IDCMP_ACTIVEWINDOW:
+			posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			break;
+
+	    /* Losing mouse coverage? */
+	    case IDCMP_INACTIVEWINDOW:
+			posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+			break;
+#if 0
+	    /* Gaining input focus? */
+	    case IDCMP_ACTIVEWINDOW: 
+			posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
+
+			/* Queue entry into fullscreen mode */
+			switch_waiting = 0x01 | SDL_FULLSCREEN;
+			switch_time = SDL_GetTicks() + 1500;
+		    break;
+
+	    /* Losing input focus? */
+	    case IDCMP_INACTIVEWINDOW:
+			posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
+
+		/* Queue leaving fullscreen mode */
+			switch_waiting = 0x01;
+			switch_time = SDL_GetTicks() + 200;
+		    break;
+#endif
+	    /* Mouse motion? */
+	    case IDCMP_MOUSEMOVE: 
+			if ( SDL_VideoSurface ) {
+				posted = SDL_PrivateMouseMotion(0, 0,
+						msg->MouseX-SDL_Window->BorderLeft,
+						msg->MouseY-SDL_Window->BorderTop);
+			}
+	    	break;
+
+	    /* Mouse button press? */
+		case IDCMP_MOUSEBUTTONS:
+
+			if(!(code&IECODE_UP_PREFIX))
+			{
+				posted = SDL_PrivateMouseButton(SDL_PRESSED, 
+						amiga_GetButton(code), 0, 0);
+			    }
+	    /* Mouse button release? */
+			else
+			{
+				code&=~IECODE_UP_PREFIX;
+				posted = SDL_PrivateMouseButton(SDL_RELEASED, 
+						amiga_GetButton(code), 0, 0);
+			}
+			break;
+
+	    case IDCMP_RAWKEY:
+
+		    /* Key press? */
+
+		    if( !(code&IECODE_UP_PREFIX) )
+		    {
+				SDL_keysym keysym;
+				posted = SDL_PrivateKeyboard(SDL_PRESSED,
+					amiga_TranslateKey(code, &keysym));
+		    }
+		    else
+		    {
+	    /* Key release? */
+
+				SDL_keysym keysym;
+				code&=~IECODE_UP_PREFIX;
+
+			/* Check to see if this is a repeated key */
+/*			if ( ! X11_KeyRepeat(SDL_Display, &xevent) )  */
+
+				posted = SDL_PrivateKeyboard(SDL_RELEASED, 
+					amiga_TranslateKey(code, &keysym));
+		    }
+		    break;
+	    /* Have we been iconified? */
+#if 0
+	    case UnmapNotify: {
+#ifdef DEBUG_XEVENTS
+printf("UnmapNotify!\n");
+#endif
+		posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS);
+	    }
+	    break;
+
+	    /* Have we been restored? */
+
+	    case MapNotify: {
+#ifdef DEBUG_XEVENTS
+printf("MapNotify!\n");
+#endif
+
+		posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
+
+		if ( SDL_VideoSurface &&
+		     (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) 
+		{
+			CGX_EnterFullScreen(this);
+		} else {
+			X11_GrabInputNoLock(this, this->input_grab);
+		}
+		if ( SDL_VideoSurface ) {
+			CGX_RefreshDisplay(this);
+		}
+	    }
+	    break;
+	    case Expose:
+		if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) {
+			CGX_RefreshDisplay(this);
+		}
+		break;
+#endif
+
+	    /* Have we been resized? */
+	    case IDCMP_NEWSIZE: 
+			SDL_PrivateResize(SDL_Window->Width,
+		                  SDL_Window->Height);
+			break;
+
+	    /* Have we been requested to quit? */
+	    case IDCMP_CLOSEWINDOW:
+		posted = SDL_PrivateQuit();
+		break;
+
+	    /* Do we need to refresh ourselves? */
+
+	    default: {
+		/* Only post the event if we're watching for it */
+		if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+			SDL_SysWMmsg wmmsg;
+
+			SDL_VERSION(&wmmsg.version);
+#if 0
+			wmmsg.subsystem = SDL_SYSWM_CGX;
+			wmmsg.event.xevent = xevent;
+#endif
+			posted = SDL_PrivateSysWMEvent(&wmmsg);
+		}
+	    }
+	    break;
+	}
+	ReplyMsg((struct Message *)msg);
+
+
+	return(posted);
+}
+
+void amiga_PumpEvents(_THIS)
+{
+	int pending;
+	struct IntuiMessage *m;
+
+	/* Keep processing pending events */
+	pending = 0;
+	while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) {
+		amiga_DispatchEvent(this,m);
+		++pending;
+	}
+}
+
+void amiga_InitKeymap(void)
+{
+	int i;
+
+	/* Map the miscellaneous keys */
+	for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i )
+		MISC_keymap[i] = SDLK_UNKNOWN;
+
+	/* These X keysyms have 0xFF as the high byte */
+	MISC_keymap[65] = SDLK_BACKSPACE;
+	MISC_keymap[66] = SDLK_TAB;
+	MISC_keymap[70] = SDLK_CLEAR;
+	MISC_keymap[70] = SDLK_DELETE;
+	MISC_keymap[68] = SDLK_RETURN;
+//	MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE;
+	MISC_keymap[69] = SDLK_ESCAPE;
+	MISC_keymap[70] = SDLK_DELETE;
+/*
+	SDLK_SPACE		= 32,
+	SDLK_MINUS		= 45,
+	SDLK_LESS		= 60,
+	SDLK_COMMA		= 44,
+	SDLK_PERIOD		= 46,
+	SDLK_0			= 48,
+	SDLK_1			= 49,
+	SDLK_2			= 50,
+	SDLK_3			= 51,
+	SDLK_4			= 52,
+	SDLK_5			= 53,
+	SDLK_6			= 54,
+	SDLK_7			= 55,
+	SDLK_8			= 56,
+	SDLK_9			= 57,
+	SDLK_BACKQUOTE		= 96,
+	SDLK_BACKSLASH		= 92,
+	SDLK_a			= 97,
+	SDLK_b			= 98,
+	SDLK_c			= 99,
+	SDLK_d			= 100,
+	SDLK_e			= 101,
+	SDLK_f			= 102,
+	SDLK_g			= 103,
+	SDLK_h			= 104,
+	SDLK_i			= 105,
+	SDLK_j			= 106,
+	SDLK_k			= 107,
+	SDLK_l			= 108,
+	SDLK_m			= 109,
+	SDLK_n			= 110,
+	SDLK_o			= 111,
+	SDLK_p			= 112,
+	SDLK_q			= 113,
+	SDLK_r			= 114,
+	SDLK_s			= 115,
+	SDLK_t			= 116,
+	SDLK_u			= 117,
+	SDLK_v			= 118,
+	SDLK_w			= 119,
+	SDLK_x			= 120,
+	SDLK_y			= 121,
+	SDLK_z			= 122,
+*/
+	MISC_keymap[15] = SDLK_KP0;		/* Keypad 0-9 */
+	MISC_keymap[29] = SDLK_KP1;
+	MISC_keymap[30] = SDLK_KP2;
+	MISC_keymap[31] = SDLK_KP3;
+	MISC_keymap[45] = SDLK_KP4;
+	MISC_keymap[46] = SDLK_KP5;
+	MISC_keymap[47] = SDLK_KP6;
+	MISC_keymap[61] = SDLK_KP7;
+	MISC_keymap[62] = SDLK_KP8;
+	MISC_keymap[63] = SDLK_KP9;
+	MISC_keymap[60] = SDLK_KP_PERIOD;
+	MISC_keymap[92] = SDLK_KP_DIVIDE;
+	MISC_keymap[93] = SDLK_KP_MULTIPLY;
+	MISC_keymap[74] = SDLK_KP_MINUS;
+	MISC_keymap[94] = SDLK_KP_PLUS;
+	MISC_keymap[67] = SDLK_KP_ENTER;
+//	MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS;
+
+	MISC_keymap[76] = SDLK_UP;
+	MISC_keymap[77] = SDLK_DOWN;
+	MISC_keymap[78] = SDLK_RIGHT;
+	MISC_keymap[79] = SDLK_LEFT;
+/*
+	MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT;
+	MISC_keymap[XK_Home&0xFF] = SDLK_HOME;
+	MISC_keymap[XK_End&0xFF] = SDLK_END;
+*/
+// Mappati sulle parentesi del taastierino
+	MISC_keymap[90] = SDLK_PAGEUP;
+	MISC_keymap[91] = SDLK_PAGEDOWN;
+
+	MISC_keymap[80] = SDLK_F1;
+	MISC_keymap[81] = SDLK_F2;
+	MISC_keymap[82] = SDLK_F3;
+	MISC_keymap[83] = SDLK_F4;
+	MISC_keymap[84] = SDLK_F5;
+	MISC_keymap[85] = SDLK_F6;
+	MISC_keymap[86] = SDLK_F7;
+	MISC_keymap[87] = SDLK_F8;
+	MISC_keymap[88] = SDLK_F9;
+	MISC_keymap[89] = SDLK_F10;
+//	MISC_keymap[XK_F11&0xFF] = SDLK_F11;
+//	MISC_keymap[XK_F12&0xFF] = SDLK_F12;
+//	MISC_keymap[XK_F13&0xFF] = SDLK_F13;
+//	MISC_keymap[XK_F14&0xFF] = SDLK_F14;
+//	MISC_keymap[XK_F15&0xFF] = SDLK_F15;
+
+//	MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK;
+	MISC_keymap[98] = SDLK_CAPSLOCK;
+//	MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
+	MISC_keymap[97] = SDLK_RSHIFT;
+	MISC_keymap[96] = SDLK_LSHIFT;
+	MISC_keymap[99] = SDLK_LCTRL;
+	MISC_keymap[99] = SDLK_LCTRL;
+	MISC_keymap[101] = SDLK_RALT;
+	MISC_keymap[100] = SDLK_LALT;
+//	MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA;
+//	MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA;
+	MISC_keymap[103] = SDLK_LSUPER; /* Left "Windows" */
+	MISC_keymap[102] = SDLK_RSUPER; /* Right "Windows */
+
+	MISC_keymap[95] = SDLK_HELP;
+}
+
+SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym)
+{
+	static struct Library *ConsoleDevice=NULL;
+
+	/* Get the raw keyboard scancode */
+	keysym->scancode = code;
+	keysym->sym = MISC_keymap[code];
+
+#ifdef DEBUG_KEYS
+	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode);
+#endif
+	/* Get the translated SDL virtual keysym */
+	if ( keysym->sym==SDLK_UNKNOWN ) 
+	{
+		if(!ConsoleDevice)
+		{
+			if(ConPort=CreateMsgPort())
+			{
+				if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq)))
+				{
+					if(!OpenDevice("console.device",-1,(struct IORequest *)ConReq,0))
+						ConsoleDevice=(struct Library *)ConReq->io_Device;
+					else
+					{
+						DeleteIORequest(ConReq);
+						ConReq=NULL;
+					}
+				}
+				else
+				{
+					DeleteMsgPort(ConPort);
+					ConPort=NULL;
+				}
+			}
+		}
+
+		if(ConsoleDevice)
+		{
+			struct InputEvent event;
+			long actual;
+			char buffer[5];
+
+			event.ie_Qualifier=0;
+			event.ie_Class=IECLASS_RAWKEY;
+			event.ie_SubClass=0L;
+			event.ie_Code=code;
+			event.ie_X=event.ie_Y=0;
+			event.ie_EventAddress=NULL;
+			event.ie_NextEvent=NULL;
+			event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0;
+
+			if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0)
+			{
+				if(actual>1)
+				{
+					D(bug("Warning (%ld) character conversion!\n",actual));
+				}
+				else if(actual==1)
+				{
+					keysym->sym=*buffer;
+					D(bug("Converted rawcode %ld to <%lc>\n",code,*buffer));
+// Bufferizzo x le successive chiamate!
+					MISC_keymap[code]=*buffer;
+				}
+			}
+		}
+
+	}
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE ) {
+#if 0
+		static XComposeStatus state;
+		/* Until we handle the IM protocol, use XLookupString() */
+		unsigned char keybuf[32];
+		if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf),
+							NULL, &state) ) {
+			keysym->unicode = keybuf[0];
+		}
+#endif
+	}
+	return(keysym);
+}
+
+void amiga_InitOSKeymap(_THIS)
+{
+	amiga_InitKeymap();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_amigaevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_cgxvideo.h"
+
+/* Functions to be exported */
+extern void amiga_InitOSKeymap(_THIS);
+extern void amiga_PumpEvents(_THIS);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_amigamouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,118 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_amigamouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+
+typedef void * WMCursor;
+
+void amiga_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+}
+
+WMcursor *amiga_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+	return (WMcursor *)1; // Amiga has an Hardware cursor, so it's ok to return something unuseful but true
+}
+
+int amiga_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	/* Don't do anything if the display is gone */
+	if ( SDL_Display == NULL) {
+		return(0);
+	}
+
+	/* Set the Amiga prefs cursor cursor, or blank if cursor is NULL */
+
+	if ( SDL_Window ) {
+		SDL_Lock_EventThread();
+		if ( cursor == NULL ) {
+			if ( SDL_BlankCursor != NULL ) {
+// Hide cursor HERE
+				SetPointer(SDL_Window,(UWORD *)SDL_BlankCursor,1,1,0,0);
+			}
+		} else {
+// Show cursor
+			ClearPointer(SDL_Window);
+		}
+		SDL_Unlock_EventThread();
+	}
+	return(1);
+}
+
+void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+/* FIXME: Not implemented */
+}
+
+/* Check to see if we need to enter or leave mouse relative mode */
+void amiga_CheckMouseMode(_THIS)
+{
+	/* If the mouse is hidden and input is grabbed, we use relative mode */
+#if 0
+	SDL_Lock_EventThread();
+	if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
+	     (this->input_grab != SDL_GRAB_OFF) ) {
+		mouse_relative = 1;
+		X11_EnableDGAMouse(this);
+		if ( ! (using_dga & DGA_MOUSE) ) {
+			char *use_mouse_accel;
+
+			SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
+			/* Use as raw mouse mickeys as possible */
+			XGetPointerControl(SDL_Display,
+						&mouse_accel.numerator, 
+						&mouse_accel.denominator,
+						&mouse_accel.threshold);
+			use_mouse_accel = getenv("SDL_VIDEO_X11_MOUSEACCEL");
+			if ( use_mouse_accel ) {
+				SetMouseAccel(this, use_mouse_accel);
+			}
+		}
+	} else {
+		if ( mouse_relative ) {
+			if ( using_dga & DGA_MOUSE ) {
+				X11_DisableDGAMouse(this);
+			} else {
+				XChangePointerControl(SDL_Display, True, True,
+						mouse_accel.numerator, 
+						mouse_accel.denominator,
+						mouse_accel.threshold);
+			}
+			mouse_relative = 0;
+		}
+	}
+	SDL_Unlock_EventThread();
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_amigamouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_cgxvideo.h"
+
+/* Functions to be exported */
+extern void amiga_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *amiga_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int amiga_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+extern void amiga_CheckMouseMode(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxaccel.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,237 @@
+#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_sysvideo.h"
+#include "SDL_blit.h"
+#include "SDL_video.h"
+#include "SDL_cgxvideo.h"
+
+static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+					SDL_Surface *dst, SDL_Rect *dstrect);
+
+// These are needed to avoid register troubles with gcc -O2!
+
+#if defined(__SASC) || defined(__PPC__)
+#define BMKBRP(a,b,c,d,e,f,g,h,i,j) BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j)
+#define	BBRP(a,b,c,d,e,f,g,h,i) BltBitMapRastPort(a,b,c,d,e,f,g,h,i)
+#define BBB(a,b,c,d,e,f,g,h,i,j,k) BltBitMap(a,b,c,d,e,f,g,h,i,j,k)
+#else
+void BMKBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,APTR j)
+{BltMaskBitMapRastPort(a,b,c,d,e,f,g,h,i,j);}
+
+void BBRP(struct BitMap *a,WORD b, WORD c,struct RastPort *d,WORD e,WORD f,WORD g,WORD h,UBYTE i) 
+{BltBitMapRastPort(a,b,c,d,e,f,g,h,i);}
+
+void BBB(struct BitMap *a,WORD b, WORD c,struct BitMap *d,WORD e,WORD f,WORD g,WORD h,UBYTE i,UBYTE j,UWORD *k) 
+{BltBitMap(a,b,c,d,e,f,g,h,i,j,k);}
+#endif
+
+int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key)
+{
+	if(surface->hwdata)
+	{
+		if(surface->hwdata->mask)
+			free(surface->hwdata->mask);
+
+		if(surface->hwdata->mask=malloc(RASSIZE(surface->w,surface->h)))
+		{
+			Uint32 pitch,ok=0;
+			APTR lock;
+
+			memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h));
+
+			D(bug("Costruisco colorkey: colore: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel));
+
+			if(lock=LockBitMapTags(surface->hwdata->bmap,LBMI_BASEADDRESS,(ULONG)&surface->pixels,
+					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))
+			{
+				switch(surface->format->BytesPerPixel)
+				{
+					case 1:
+					{
+						unsigned char k=key;
+						register int i,j,t;
+						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
+
+						pitch-=surface->w;
+
+						for(i=0;i<surface->h;i++)
+						{
+							for(t=128,j=0;j<surface->w;j++)
+							{
+								if(*map==k)
+									*dest&=~t;	
+
+								t>>=1;
+
+								if(t==0)
+								{
+									dest++;
+									t=128;
+								}
+								map++;
+							}
+							map+=pitch;
+						}
+					}
+					break;
+					case 2:
+					{
+						Uint16 k=key,*mapw;
+						register int i,j,t;
+						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
+
+						for(i=surface->h;i;--i)
+						{
+							mapw=(Uint16 *)map;
+
+							for(t=128,j=surface->w;j;--j)
+							{
+								if(*mapw==k)
+									*dest&=~t;
+
+								t>>=1;
+
+								if(t==0)
+								{
+									dest++;
+									t=128;
+								}
+								mapw++;
+							}
+							map+=pitch;
+						}
+					}
+					break;
+					case 4:
+					{
+						Uint32 *mapl;
+						register int i,j,t;
+						register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels;
+
+						for(i=surface->h;i;--i)
+						{
+							mapl=(Uint32 *)map;
+
+							for(t=128,j=surface->w;j;--j)
+							{
+								if(*mapl==key)
+									*dest&=~t;
+
+								t>>=1;
+
+								if(t==0)
+								{
+									dest++;
+									t=128;
+								}
+								mapl++;
+							}
+							map+=pitch;
+						}
+
+					}
+					break;
+					default:
+						D(bug("Pixel mode non supported for color key..."));
+						free(surface->hwdata->mask);
+						surface->hwdata->mask=NULL;
+						ok=-1;
+				}
+				UnLockBitMap(lock);
+				D(bug("...Colorkey costruito!\n"));
+				return ok;
+			}
+		}
+	}
+	D(bug("HW colorkey not supported for this depth\n"));
+
+	return -1;
+}
+
+int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst)
+{
+// Doesn't support yet alpha blitting
+
+	if(src->hwdata&& !(src->flags & (SDL_SRCALPHA)))
+	{
+		D(bug("CheckHW blit... OK!\n"));
+
+		if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+			if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 ) {
+				src->flags &= ~SDL_HWACCEL;
+				return -1;
+			}
+		}
+
+		src->flags|=SDL_HWACCEL;
+		src->map->hw_blit = CGX_HWAccelBlit;
+		return 1;
+	}
+	else
+		src->flags &= ~SDL_HWACCEL;
+
+	D(bug("CheckHW blit... NO!\n"));
+
+	return 0;
+}
+
+static int temprp_init=0;
+static struct RastPort temprp;
+
+static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+					SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	struct SDL_VideoDevice *this=src->hwdata->videodata;
+
+//	D(bug("Accel blit!\n"));
+
+	if(src->flags&SDL_SRCCOLORKEY && src->hwdata->mask)
+	{
+		if(dst==SDL_VideoSurface)
+		{
+			BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y,
+						SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,
+						srcrect->w,srcrect->h,0xc0,src->hwdata->mask);
+		}
+		else if(dst->hwdata)
+		{
+			if(!temprp_init)
+			{
+				InitRastPort(&temprp);
+				temprp_init=1;
+			}
+			temprp.BitMap=(struct BitMap *)dst->hwdata->bmap;
+
+			BMKBRP(src->hwdata->bmap,srcrect->x,srcrect->y,
+						&temprp,dstrect->x,dstrect->y,
+						srcrect->w,srcrect->h,0xc0,src->hwdata->mask);
+			
+		}
+	}
+	else if(dst==SDL_VideoSurface)
+	{
+		BBRP(src->hwdata->bmap,srcrect->x,srcrect->y,SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,srcrect->w,srcrect->h,0xc0);
+	}
+	else if(dst->hwdata)
+		BBB(src->hwdata->bmap,srcrect->x,srcrect->y,dst->hwdata->bmap,dstrect->x,dstrect->y,srcrect->w,srcrect->h,0xc0,0xff,NULL);
+}
+
+int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color)
+{
+	if(dst==SDL_VideoSurface)
+	{
+		FillPixelArray(SDL_RastPort,dstrect->x+SDL_Window->BorderLeft,dstrect->y+SDL_Window->BorderTop,dstrect->w,dstrect->h,color);
+	}
+	else if(dst->hwdata)
+	{
+		if(!temprp_init)
+		{
+			InitRastPort(&temprp);
+			temprp_init=1;
+		}
+
+		temprp.BitMap=(struct BitMap *)dst->hwdata->bmap;
+
+		FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxgl.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,389 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+// #include <stdlib.h>	/* For getenv() prototype */
+// #include <string.h>
+
+#include "SDL_events_c.h"
+#include "SDL_error.h"
+#include "SDL_cgxvideo.h"
+#include "SDL_cgxgl_c.h"
+
+#define DEFAULT_OPENGL	"libGL.so.1"
+
+/* return the preferred visual to use for openGL graphics */
+void *CGX_GL_GetVisual(_THIS)
+{
+#ifdef HAVE_OPENGL
+	/* 64 seems nice. */
+	int attribs[64];
+	int i;
+
+	/* load the gl driver from a default path */
+	if ( ! this->gl_config.driver_loaded ) {
+	        /* no driver has been loaded, use default (ourselves) */
+	        if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
+		        return NULL;
+		}
+	}
+
+	/* See if we already have a window which we must use */
+	if ( SDL_windowid ) {
+		XWindowAttributes a;
+		XVisualInfo vi_in;
+		int out_count;
+
+		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
+		vi_in.screen = SDL_Screen;
+		vi_in.visualid = XVisualIDFromVisual(a.visual);
+		glx_visualinfo = XGetVisualInfo(SDL_Display,
+	                     VisualScreenMask|VisualIDMask, &vi_in, &out_count);
+		return glx_visualinfo;
+	}
+
+        /* Setup our GLX attributes according to the gl_config. */
+        i = 0;
+        attribs[i++] = GLX_RGBA;
+	attribs[i++] = GLX_RED_SIZE;
+	attribs[i++] = this->gl_config.red_size;
+	attribs[i++] = GLX_GREEN_SIZE;
+	attribs[i++] = this->gl_config.green_size;
+	attribs[i++] = GLX_BLUE_SIZE;
+	attribs[i++] = this->gl_config.blue_size;
+
+	if( this->gl_config.alpha_size ) {
+		attribs[i++] = GLX_ALPHA_SIZE;
+		attribs[i++] = this->gl_config.alpha_size;
+	}
+
+	if( this->gl_config.buffer_size ) {
+                attribs[i++] = GLX_BUFFER_SIZE;
+	        attribs[i++] = this->gl_config.buffer_size;
+	}
+
+	if( this->gl_config.double_buffer ) {
+		attribs[i++] = GLX_DOUBLEBUFFER;
+	}
+
+	attribs[i++] = GLX_DEPTH_SIZE;
+	attribs[i++] = this->gl_config.depth_size;
+
+	if( this->gl_config.stencil_size ) {
+		attribs[i++] = GLX_STENCIL_SIZE;
+		attribs[i++] = this->gl_config.stencil_size;
+	}
+
+	if( this->gl_config.accum_red_size ) {
+	        attribs[i++] = GLX_ACCUM_RED_SIZE;
+		attribs[i++] = this->gl_config.accum_red_size;
+	}
+
+	if( this->gl_config.accum_green_size ) {
+	        attribs[i++] = GLX_ACCUM_GREEN_SIZE;
+		attribs[i++] = this->gl_config.accum_green_size;
+	}
+
+	if( this->gl_config.accum_blue_size ) {
+	        attribs[i++] = GLX_ACCUM_BLUE_SIZE;
+		attribs[i++] = this->gl_config.accum_blue_size;
+	}
+
+	if( this->gl_config.accum_alpha_size ) {
+	        attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
+		attribs[i++] = this->gl_config.accum_alpha_size;
+	}
+
+	attribs[i++] = None;
+
+ 	glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, 
+						  SDL_Screen, attribs);
+	if( !glx_visualinfo ) {
+		SDL_SetError( "Couldn't find matching GLX visual");
+		return NULL;
+	}
+	return glx_visualinfo;
+#else
+	SDL_SetError("CGX driver is not yet supporting OpenGL");
+	return NULL;
+#endif
+}
+
+int CGX_GL_CreateWindow(_THIS, int w, int h)
+{
+	int retval;
+#ifdef HAVE_OPENGL
+	XSetWindowAttributes attributes;
+	unsigned long mask;
+	unsigned long black;
+
+	black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
+						 	SDL_Screen))
+	       	? BlackPixel(SDL_Display, SDL_Screen) : 0;
+	attributes.background_pixel = black;
+	attributes.border_pixel = black;
+	attributes.colormap = SDL_XColorMap;
+	mask = CWBackPixel | CWBorderPixel | CWColormap;
+
+	SDL_Window = XCreateWindow(SDL_Display, WMwindow,
+			0, 0, w, h, 0, glx_visualinfo->depth,
+			InputOutput, glx_visualinfo->visual,
+			mask, &attributes);
+	if ( !SDL_Window ) {
+		SDL_SetError("Could not create window");
+		return -1;
+	}
+	retval = 0;
+#else
+	SDL_SetError("CGX driver is not yet supporting OpenGL");
+	retval = -1;
+#endif
+	return(retval);
+}
+
+int CGX_GL_CreateContext(_THIS)
+{
+	int retval;
+#ifdef HAVE_OPENGL
+	/* We do this to create a clean separation between X and GLX errors. */
+	XSync( SDL_Display, False );
+	glx_context = this->gl_data->glXCreateContext(GFX_Display, 
+				     glx_visualinfo, NULL, True);
+	XSync( GFX_Display, False );
+
+	if (glx_context == NULL) {
+		SDL_SetError("Could not create GL context");
+		return -1;
+	}
+
+	gl_active = 1;
+#else
+	SDL_SetError("CGX driver is not yet supporting OpenGL");
+#endif
+	if ( gl_active ) {
+		retval = 0;
+	} else {
+		retval = -1;
+	}
+	return(retval);
+}
+
+void CGX_GL_Shutdown(_THIS)
+{
+#ifdef HAVE_OPENGL
+	/* Clean up OpenGL */
+	if( glx_context ) {
+		this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
+
+		if (glx_context != NULL)
+			this->gl_data->glXDestroyContext(GFX_Display, glx_context);
+
+		if( this->gl_data->glXReleaseBuffersMESA ) {
+		    this->gl_data->glXReleaseBuffersMESA(GFX_Display,SDL_Window);
+		}
+		glx_context = NULL;
+	}
+	gl_active = 0;
+#endif /* HAVE_OPENGL */
+}
+
+#ifdef HAVE_OPENGL
+
+/* Make the current context active */
+int CGX_GL_MakeCurrent(_THIS)
+{
+	int retval;
+
+	retval = 0;
+	if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
+	                                     SDL_Window, glx_context) ) {
+		SDL_SetError("Unable to make GL context current");
+		retval = -1;
+	}
+	XSync( GFX_Display, False );
+
+	/* More Voodoo X server workarounds... Grr... */
+	SDL_Lock_EventThread();
+	X11_CheckDGAMouse(this);
+	SDL_Unlock_EventThread();
+
+	return(retval);
+}
+
+/* Get attribute data from glX. */
+int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
+{
+	int retval;
+	int glx_attrib = None;
+
+	switch( attrib ) {
+	    case SDL_GL_RED_SIZE:
+		glx_attrib = GLX_RED_SIZE;
+		break;
+	    case SDL_GL_GREEN_SIZE:
+		glx_attrib = GLX_GREEN_SIZE;
+		break;
+	    case SDL_GL_BLUE_SIZE:
+		glx_attrib = GLX_BLUE_SIZE;
+		break;
+	    case SDL_GL_ALPHA_SIZE:
+		glx_attrib = GLX_ALPHA_SIZE;
+		break;
+	    case SDL_GL_DOUBLEBUFFER:
+		glx_attrib = GLX_DOUBLEBUFFER;
+		break;
+	    case SDL_GL_BUFFER_SIZE:
+		glx_attrib = GLX_BUFFER_SIZE;
+		break;
+	    case SDL_GL_DEPTH_SIZE:
+		glx_attrib = GLX_DEPTH_SIZE;
+		break;
+	    case SDL_GL_STENCIL_SIZE:
+		glx_attrib = GLX_STENCIL_SIZE;
+		break;
+	    case SDL_GL_ACCUM_RED_SIZE:
+		glx_attrib = GLX_ACCUM_RED_SIZE;
+		break;
+	    case SDL_GL_ACCUM_GREEN_SIZE:
+		glx_attrib = GLX_ACCUM_GREEN_SIZE;
+		break;
+	    case SDL_GL_ACCUM_BLUE_SIZE:
+		glx_attrib = GLX_ACCUM_BLUE_SIZE;
+		break;
+	    case SDL_GL_ACCUM_ALPHA_SIZE:
+		glx_attrib = GLX_ACCUM_ALPHA_SIZE;
+		break;
+	    default:
+		return(-1);
+	}
+
+	retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
+
+	return retval;
+}
+
+void CGX_GL_SwapBuffers(_THIS)
+{
+	this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
+}
+
+#endif /* HAVE_OPENGL */
+
+void CGX_GL_UnloadLibrary(_THIS)
+{
+#ifdef HAVE_OPENGL
+	if ( this->gl_config.driver_loaded ) {
+		dlclose(this->gl_config.dll_handle);
+
+		this->gl_data->glXChooseVisual = NULL;
+		this->gl_data->glXCreateContext = NULL;
+		this->gl_data->glXDestroyContext = NULL;
+		this->gl_data->glXMakeCurrent = NULL;
+		this->gl_data->glXSwapBuffers = NULL;
+
+		this->gl_config.dll_handle = NULL;
+		this->gl_config.driver_loaded = 0;
+	}
+#endif
+}
+
+#ifdef HAVE_OPENGL
+
+/* Passing a NULL path means load pointers from the application */
+int CGX_GL_LoadLibrary(_THIS, const char* path) 
+{
+	void* handle;
+	int dlopen_flags;
+
+ 	if ( gl_active ) {
+ 		SDL_SetError("OpenGL context already created");
+ 		return -1;
+ 	}
+
+#ifdef RTLD_GLOBAL
+	dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
+#else
+	dlopen_flags = RTLD_LAZY;
+#endif
+	handle = dlopen(path, dlopen_flags);
+	/* Catch the case where the application isn't linked with GL */
+	if ( (dlsym(handle, "glXChooseVisual") == NULL) && (path == NULL) ) {
+		dlclose(handle);
+		path = getenv("SDL_VIDEO_GL_DRIVER");
+		if ( path == NULL ) {
+			path = DEFAULT_OPENGL;
+		}
+		handle = dlopen(path, dlopen_flags);
+	}
+	if ( handle == NULL ) {
+		SDL_SetError("Could not load OpenGL library");
+		return -1;
+	}
+
+	/* Unload the old driver and reset the pointers */
+	X11_GL_UnloadLibrary(this);
+
+	/* Load new function pointers */
+	this->gl_data->glXChooseVisual = dlsym(handle, "glXChooseVisual");
+	this->gl_data->glXCreateContext = dlsym(handle, "glXCreateContext");
+	this->gl_data->glXDestroyContext = dlsym(handle, "glXDestroyContext");
+	this->gl_data->glXMakeCurrent = dlsym(handle, "glXMakeCurrent");
+	this->gl_data->glXSwapBuffers = dlsym(handle, "glXSwapBuffers");
+	this->gl_data->glXGetConfig = dlsym(handle, "glXGetConfig");
+	/* We don't compare below for this in case we're not using Mesa. */
+	this->gl_data->glXReleaseBuffersMESA = dlsym( handle, "glXReleaseBuffersMESA" );
+
+	if ( (this->gl_data->glXChooseVisual == NULL) || 
+	     (this->gl_data->glXCreateContext == NULL) ||
+	     (this->gl_data->glXDestroyContext == NULL) ||
+	     (this->gl_data->glXMakeCurrent == NULL) ||
+	     (this->gl_data->glXSwapBuffers == NULL) ||
+	     (this->gl_data->glXGetConfig == NULL) ) {
+		SDL_SetError("Could not retrieve OpenGL functions");
+		return -1;
+	}
+
+	this->gl_config.dll_handle = handle;
+	this->gl_config.driver_loaded = 1;
+	if ( path ) {
+		strncpy(this->gl_config.driver_path, path,
+			sizeof(this->gl_config.driver_path)-1);
+	} else {
+		strcpy(this->gl_config.driver_path, "");
+	}
+	return 0;
+}
+
+void *CGX_GL_GetProcAddress(_THIS, const char* proc)
+{
+	void* handle;
+	
+	handle = this->gl_config.dll_handle;
+
+	return dlsym(handle, proc);
+}
+
+#endif /* HAVE_OPENGL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxgl_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,98 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#ifdef HAVE_OPENGL
+#include <GL/glx.h>
+#include <dlfcn.h>
+#endif
+#include "SDL_sysvideo.h"
+
+struct SDL_PrivateGLData {
+    int gl_active; /* to stop switching drivers while we have a valid context */
+
+#ifdef HAVE_OPENGL
+    GLXContext glx_context;	/* Current GL context */
+    XVisualInfo* glx_visualinfo; /* XVisualInfo* returned by glXChooseVisual */
+
+    XVisualInfo* (*glXChooseVisual)
+		( Display*		dpy,
+		  int			screen,
+		  int*		attribList );
+
+    GLXContext (*glXCreateContext)
+		( Display*		dpy,
+		  XVisualInfo*	vis,
+		  GLXContext		shareList,
+		  Bool		direct );
+
+    void (*glXDestroyContext)
+		( Display* 		dpy,
+		  GLXContext		ctx );
+
+    Bool (*glXMakeCurrent)
+		( Display*		dpy,
+		  GLXDrawable		drawable,
+		  GLXContext		ctx );
+
+    void (*glXSwapBuffers)
+		( Display*		dpy,
+		  GLXDrawable		drawable );
+
+    int (*glXGetConfig)
+	 ( Display* dpy,
+	   XVisualInfo* visual_info,
+	   int attrib,
+	   int* value );
+
+    void (*glXReleaseBuffersMESA)
+	 ( Display* dpy,
+	   GLXDrawable drawable );
+
+#endif /* HAVE_OPENGL */
+};
+
+/* Old variable names */
+#define gl_active		(this->gl_data->gl_active)
+#define glx_context		(this->gl_data->glx_context)
+#define glx_visualinfo		(this->gl_data->glx_visualinfo)
+
+/* OpenGL functions */
+extern void *CGX_GL_GetVisual(_THIS);
+extern int CGX_GL_CreateWindow(_THIS, int w, int h);
+extern int CGX_GL_CreateContext(_THIS);
+extern void CGX_GL_Shutdown(_THIS);
+#ifdef HAVE_OPENGL
+extern int CGX_GL_MakeCurrent(_THIS);
+extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+extern void CGX_GL_SwapBuffers(_THIS);
+extern int CGX_GL_LoadLibrary(_THIS, const char* path);
+extern void *CGX_GL_GetProcAddress(_THIS, const char* proc);
+#endif
+extern void CGX_GL_UnloadLibrary(_THIS);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgximage.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,885 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_cgximage_c.h"
+
+#ifdef HAVE_KSTAT
+#include <kstat.h>
+#endif
+
+#ifdef USE_CGX_WRITELUTPIXEL
+#if defined(__SASC) || defined(__PPC__)
+	#define WLUT WriteLUTPixelArray
+#else
+void WLUT(APTR a,UWORD b,UWORD c,UWORD d,struct RastPort *e,APTR f,UWORD g,UWORD h,UWORD i,UWORD l,UBYTE m)
+{	WriteLUTPixelArray(a,b,c,d,e,f,g,h,i,l,m); }
+#endif
+
+#endif
+
+/* Various screen update functions available */
+static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+BOOL SafeDisp=TRUE,SafeChange=TRUE;
+struct MsgPort *safeport=NULL,*dispport=NULL;
+ULONG safe_sigbit,disp_sigbit;
+
+int CGX_SetupImage(_THIS, SDL_Surface *screen)
+{
+	if(screen->flags&SDL_HWSURFACE)
+	{
+		SDL_Ximage=NULL;
+
+		if(!screen->hwdata)
+		{
+			if(!(screen->hwdata=malloc(sizeof(struct private_hwdata))))
+			{
+				return -1;
+			}
+			D(bug("Creating system accel struct\n"));
+			screen->hwdata->lock=0;
+			screen->hwdata->bmap=SDL_RastPort->BitMap;
+			screen->hwdata->videodata=this;
+		}
+
+		this->UpdateRects = CGX_FakeUpdate;
+
+		D(bug("Accel video image configured.\n"));
+		return 0;
+	}
+
+	screen->pixels = malloc(screen->h*screen->pitch);
+
+	if ( screen->pixels == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	SDL_Ximage=screen->pixels;
+
+	if ( SDL_Ximage == NULL ) {
+		SDL_SetError("Couldn't create XImage");
+		return(-1);
+	}
+
+	this->UpdateRects = CGX_NormalUpdate;
+
+	return(0);
+}
+
+void CGX_DestroyImage(_THIS, SDL_Surface *screen)
+{
+	if ( SDL_Ximage ) {
+		free(SDL_Ximage);
+		SDL_Ximage = NULL;
+	}
+	if ( screen ) {
+		screen->pixels = NULL;
+	}
+}
+
+int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
+{
+	int retval;
+
+	CGX_DestroyImage(this, screen);
+
+	if ( flags & SDL_OPENGL ) {  /* No image when using GL */
+        	retval = 0;
+	} else {
+		retval = CGX_SetupImage(this, screen);
+	}
+	return(retval);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+int CGX_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	D(bug("Alloc HW surface...%ld x %ld x %ld!\n",surface->w,surface->h,this->hidden->depth));
+
+	if(surface==SDL_VideoSurface)
+	{
+		D(bug("Allocation skipped, it's system one!\n"));
+		return 0;
+	}
+
+	if(!surface->hwdata)
+	{
+		if(!(surface->hwdata=malloc(sizeof(struct private_hwdata))))
+			return -1;
+		
+		surface->hwdata->lock=NULL;
+		surface->hwdata->videodata=this;
+	}
+
+	if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap))
+	{
+		surface->flags|=SDL_HWSURFACE;
+		D(bug("...OK\n"));
+		return 0;
+	}
+	else
+	{
+		free(surface->hwdata);
+		surface->hwdata=NULL;
+	}
+
+	return(-1);
+}
+void CGX_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	if(surface && surface!=SDL_VideoSurface && surface->hwdata)
+	{
+		D(bug("Free hw surface.\n"));
+
+		if(surface->hwdata->mask)
+			free(surface->hwdata->mask);
+
+		if(surface->hwdata->bmap)
+			FreeBitMap(surface->hwdata->bmap);
+
+		free(surface->hwdata);
+		surface->hwdata=NULL;
+	}
+	return;
+}
+
+int CGX_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if (surface->hwdata)
+	{
+//		D(bug("Locking a bitmap...\n"));
+		if(!surface->hwdata->lock)
+		{	
+			Uint32 pitch;
+
+			if(!(surface->hwdata->lock=LockBitMapTags(surface->hwdata->bmap,
+					LBMI_BASEADDRESS,(ULONG)&surface->pixels,
+					LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE)))
+				return -1;
+
+// surface->pitch e' a 16bit!
+
+			surface->pitch=pitch;
+
+			if(!currently_fullscreen&&surface==SDL_VideoSurface)
+				surface->pixels=((char *)surface->pixels)+(surface->pitch*(SDL_Window->BorderTop+SDL_Window->TopEdge)+
+					surface->format->BytesPerPixel*(SDL_Window->BorderLeft+SDL_Window->LeftEdge));
+		}
+		else
+			D(bug("Already locked!!!\n"));
+	}
+	return(0);
+}
+void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if(surface->hwdata && surface->hwdata->lock)
+	{
+		UnLockBitMap(surface->hwdata->lock);
+		surface->hwdata->lock=NULL;
+		surface->pixels=NULL;
+	}
+}
+
+int CGX_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	static int current=0;
+
+	if(this->hidden->dbuffer)
+	{
+		if(!SafeChange)
+		{
+			Wait(disp_sigbit);
+// Non faccio nulla, vuoto solo la porta
+			while(GetMsg(dispport)!=NULL) 
+				;
+			SafeChange=TRUE;
+		}
+
+		if(ChangeScreenBuffer(SDL_Display,this->hidden->SB[current^1]))
+		{
+			surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap;
+			SafeChange=FALSE;
+			SafeDisp=FALSE;
+			current^=1;
+		}
+
+		if(!SafeDisp)
+		{
+			Wait(safe_sigbit);
+			while(GetMsg(safeport)!=NULL) 
+				;
+			SafeDisp=TRUE;
+		}
+
+	}
+	return(0);
+}
+
+/* Byte-swap the pixels in the display image */
+static void CGX_SwapAllPixels(SDL_Surface *screen)
+{
+	int x, y;
+
+	switch (screen->format->BytesPerPixel) {
+	    case 2: {
+		Uint16 *spot;
+		for ( y=0; y<screen->h; ++y ) {
+			spot = (Uint16 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch);
+			for ( x=0; x<screen->w; ++x, ++spot ) {
+				*spot = SDL_Swap16(*spot);
+			}
+		}
+	    }
+	    break;
+
+	    case 4: {
+		Uint32 *spot;
+		for ( y=0; y<screen->h; ++y ) {
+			spot = (Uint32 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch);
+			for ( x=0; x<screen->w; ++x, ++spot ) {
+				*spot = SDL_Swap32(*spot);
+			}
+		}
+	    }
+	    break;
+
+	    default:
+		/* should never get here */
+		break;
+	}
+}
+static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects)
+{
+	int i;
+	int x, minx, maxx;
+	int y, miny, maxy;
+
+	switch (screen->format->BytesPerPixel) {
+	    case 2: {
+		Uint16 *spot;
+		for ( i=0; i<numrects; ++i ) {
+			minx = rects[i].x;
+			maxx = rects[i].x+rects[i].w;
+			miny = rects[i].y;
+			maxy = rects[i].y+rects[i].h;
+			for ( y=miny; y<maxy; ++y ) {
+				spot = (Uint16 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch + minx * 2);
+				for ( x=minx; x<maxx; ++x, ++spot ) {
+					*spot = SDL_Swap16(*spot);
+				}
+			}
+		}
+	    }
+	    break;
+
+	    case 4: {
+		Uint32 *spot;
+		for ( i=0; i<numrects; ++i ) {
+			minx = rects[i].x;
+			maxx = rects[i].x+rects[i].w;
+			miny = rects[i].y;
+			maxy = rects[i].y+rects[i].h;
+			for ( y=miny; y<maxy; ++y ) {
+				spot = (Uint32 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch + minx * 4);
+				for ( x=minx; x<maxx; ++x, ++spot ) {
+					*spot = SDL_Swap32(*spot);
+				}
+			}
+		}
+	    }
+	    break;
+
+	    default:
+		/* should never get here */
+		break;
+	}
+}
+
+#ifdef __SASC
+
+#define USE_WPA WritePixelArray
+#else
+
+void USE_WPA(char *a,int b,int c,int d, struct RastPort *e,int f,int g, int h, int i, Uint32 l)
+{
+		WritePixelArray(a,b,c,d,e,f,g,h,i,l);
+}
+
+#endif
+
+static void CGX_FakeUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+}
+
+static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	int i,format,customroutine=0;
+#ifndef USE_CGX_WRITELUTPIXEL
+	int bpp;
+#endif
+	if(this->hidden->same_format)
+	{
+		format=RECTFMT_RAW;
+	}
+	else switch(this->screen->format->BytesPerPixel)
+	{
+		case 4:
+			format=RECTFMT_RGBA;
+			break;
+		case 3:
+			format=RECTFMT_RGB;
+			break;
+		case 2:
+			customroutine=1;
+			break;
+		case 1:
+//			D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
+			if(this->hidden->depth>8)
+			{
+#ifndef USE_CGX_WRITELUTPIXEL
+				if(this->hidden->depth>32)
+					customroutine=4;
+				else if(this->hidden->depth>16)
+				{
+					bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp
+					customroutine=2; // The slow one!
+				}
+				else
+					customroutine=3;
+#else
+
+				customroutine=2;
+#endif
+				
+//				format=RECTFMT_LUT8;   Vecchia funzione x usare la WritePixelArray.
+			}
+			else
+				customroutine=1;
+			break;
+		default:
+			D(bug("Unable to blit this surface!\n"));	
+			return;
+	}
+
+	/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
+	if ( swap_pixels &&
+	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
+		D(bug("Swappo! Lento!\n"));
+		CGX_SwapPixels(this->screen, numrects, rects);
+		for ( i=0; i<numrects; ++i ) {
+			if ( ! rects[i].w ) { /* Clipped? */
+				continue;
+			}
+			USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
+					SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
+					rects[i].w,rects[i].h,format);
+		}
+		CGX_SwapPixels(this->screen, numrects, rects);
+	}
+	else if (customroutine==2)
+	{
+#ifdef USE_CGX_WRITELUTPIXEL
+		for ( i=0; i<numrects; ++i ) {
+			if ( ! rects[i].w ) { /* Clipped? */
+				continue;
+			}
+
+			WLUT(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
+					SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
+					rects[i].w,rects[i].h,CTABFMT_XRGB8);
+		}
+#else
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
+								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
+		{
+			int srcwidth;
+			unsigned char *destbase;
+			register int j,k,t;
+			register unsigned char *mask,*dst;
+			register unsigned char *src,*dest;
+
+// Aggiungo il bordo della finestra se sono fullscreen.
+			if(currently_fullscreen)
+				destbase=bm_address;
+			else
+				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+
+			for ( i=0; i<numrects; ++i ) 
+			{
+				srcwidth=rects[i].w;
+
+				if ( !srcwidth ) { /* Clipped? */
+					continue;
+				}
+
+				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
+				dest+=(rects[i].y*destpitch);
+				src=((char *)(this->screen->pixels))+rects[i].x;
+				src+=(rects[i].y*this->screen->pitch);
+				
+				for(j=rects[i].h;j;--j)
+				{
+					dst=dest;
+// SLOW routine, used for 8->24 bit mapping
+					for(k=0;k<srcwidth;k++)
+					{
+						mask=(unsigned char *)(&SDL_XPixels[src[k]]);
+						for(t=0;t<bpp;t++)
+						{
+							dst[t]=mask[t];
+						}
+						dst+=bpp;
+					}
+					src+=this->screen->pitch;
+					dest+=destpitch;
+				}
+			}
+			UnLockBitMap(handle);
+		}
+	}
+	else if (customroutine==3)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
+								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
+		{
+			int srcwidth;
+			unsigned char *destbase;
+			register int j,k;
+			register unsigned char *src,*dest;
+			register Uint16 *destl,*srcl;
+
+			if(currently_fullscreen)
+				destbase=bm_address;
+			else
+				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+
+			for ( i=0; i<numrects; ++i ) 
+			{
+				srcwidth=rects[i].w;
+
+				if ( !srcwidth ) { /* Clipped? */
+					continue;
+				}
+
+				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
+				dest+=(rects[i].y*destpitch);
+				src=((char *)(this->screen->pixels))+rects[i].x;
+				src+=(rects[i].y*this->screen->pitch);
+				
+// This is the fast, well not too slow, remapping code for 16bit displays
+
+				for(j=rects[i].h;j;--j)
+				{
+					destl=(Uint16 *)dest;
+
+					for(k=0;k<srcwidth;k++)
+					{
+						srcl=(Uint16 *)&SDL_XPixels[src[k]];
+						*destl=*srcl;
+						destl++;
+					}
+					src+=this->screen->pitch;
+					dest+=destpitch;
+				}
+			}
+			UnLockBitMap(handle);
+		}
+	}
+	else if (customroutine==4)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,&bm_address,
+								LBMI_BYTESPERROW,&destpitch,TAG_DONE))
+		{
+			int srcwidth;
+			unsigned char *destbase;
+			register int j,k;
+			register unsigned char *src,*dest;
+			register Uint32 *destl,*srcl;
+
+			if(currently_fullscreen)
+				destbase=bm_address;
+			else
+				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+
+			for ( i=0; i<numrects; ++i ) 
+			{
+				srcwidth=rects[i].w;
+
+				if ( !srcwidth ) { /* Clipped? */
+					continue;
+				}
+
+				dest=destbase+rects[i].x*this->hidden->BytesPerPixel;
+				dest+=(rects[i].y*destpitch);
+				src=((char *)(this->screen->pixels))+rects[i].x;
+				src+=(rects[i].y*this->screen->pitch);
+				
+// This is the fast, well not too slow, remapping code for 32bit displays
+
+				for(j=rects[i].h;j;--j)
+				{
+					destl=(Uint32 *)dest;
+
+					for(k=0;k<srcwidth;k++)
+					{
+						srcl=(Uint32 *)&SDL_XPixels[src[k]];
+						*destl=*srcl;
+						destl++;
+					}
+					src+=this->screen->pitch;
+					dest+=destpitch;
+				}
+			}
+			UnLockBitMap(handle);
+		}
+#endif
+	}
+	else if(customroutine)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+//		D(bug("Uso customroutine!\n"));
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
+								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
+		{
+			unsigned char *destbase;
+			register int j,srcwidth;
+			register unsigned char *src,*dest;
+
+// Aggiungo il bordo della finestra se sono fullscreen.
+			if(currently_fullscreen)
+				destbase=bm_address;
+			else
+				destbase=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel;
+
+			for ( i=0; i<numrects; ++i ) 
+			{
+				srcwidth=rects[i].w;
+
+				if ( !srcwidth ) { /* Clipped? */
+					continue;
+				}
+
+				dest=destbase+rects[i].x*this->screen->format->BytesPerPixel;
+				dest+=(rects[i].y*destpitch);
+				src=((char *)(this->screen->pixels))+rects[i].x*this->screen->format->BytesPerPixel;
+				src+=(rects[i].y*this->screen->pitch);
+				
+				srcwidth*=this->screen->format->BytesPerPixel;
+
+//				D(bug("Rects: %ld,%ld %ld,%ld Src:%lx Dest:%lx\n",rects[i].x,rects[i].y,rects[i].w,rects[i].h,src,dest));
+
+				for(j=rects[i].h;j;--j)
+				{
+					memcpy(dest,src,srcwidth);
+					src+=this->screen->pitch;
+					dest+=destpitch;
+				}
+			}
+			UnLockBitMap(handle);
+//			D(bug("Rectblit addr: %lx pitch: %ld rects:%ld srcptr: %lx srcpitch: %ld\n",bm_address,destpitch,numrects,this->screen->pixels,this->screen->pitch));
+		}
+	}
+	else
+	{
+		for ( i=0; i<numrects; ++i ) {
+			if ( ! rects[i].w ) { /* Clipped? */
+				continue;
+			}
+			USE_WPA(this->screen->pixels,rects[i].x, rects[i].y,this->screen->pitch,
+					SDL_RastPort,SDL_Window->BorderLeft+rects[i].x,SDL_Window->BorderTop+rects[i].y,
+					rects[i].w,rects[i].h,format);
+
+/*
+			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				rects[i].x, rects[i].y,
+				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+*/
+		}
+	}
+/*
+	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
+		++blit_queued;
+	} else {
+	}
+*/
+}
+
+void CGX_RefreshDisplay(_THIS)
+{
+	int format,customroutine=0;
+#ifndef USE_CGX_WRITELUTPIXEL
+	int bpp;
+#endif
+	/* Don't refresh a display that doesn't have an image (like GL) */
+	if ( ! SDL_Ximage ) {
+		return;
+	}
+
+	if(this->hidden->same_format)
+	{
+		format=RECTFMT_RAW;
+	}
+	else switch(this->screen->format->BytesPerPixel)
+	{
+		case 4:
+			format=RECTFMT_RGBA;
+			break;
+		case 3:
+			format=RECTFMT_RGB;
+			break;
+		case 2:
+			customroutine=1;
+			break;
+		case 1:
+//			D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth));
+			if(this->hidden->depth>8)
+			{
+#ifndef USE_CGX_WRITELUTPIXEL
+				if(this->hidden->depth>32)
+					customroutine=4;
+				else if(this->hidden->depth>16)
+				{
+					bpp=this->hidden->BytesPerPixel; // That one is the only one that needs bpp
+					customroutine=2; // The slow one!
+				}
+				else
+					customroutine=3;
+#else
+
+				customroutine=2;
+#endif
+//				format=RECTFMT_LUT8;
+			}
+			else
+				customroutine=1;
+			break;
+
+	}
+
+		/* Check for endian-swapped X server, swap if necessary */
+	if ( swap_pixels &&
+	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
+		CGX_SwapAllPixels(this->screen);
+		USE_WPA(this->screen->pixels,0,0,this->screen->pitch,
+				SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,
+				this->screen->w,this->screen->h,format);
+		CGX_SwapAllPixels(this->screen);
+	}
+	else if (customroutine==2)
+	{
+#ifdef USE_CGX_WRITELUTPIXEL
+		WLUT(this->screen->pixels,0,0,this->screen->pitch,
+					SDL_RastPort,SDL_XPixels,SDL_Window->BorderLeft,SDL_Window->BorderTop,
+					this->screen->w,this->screen->h,CTABFMT_XRGB8);
+#else
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
+								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
+		{
+			register int j,k,t;
+			register unsigned char *mask,*dst;
+			register unsigned char *src,*dest;
+
+// Aggiungo il bordo della finestra se sono fullscreen.
+			if(!currently_fullscreen)
+				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+			else
+				dest=bm_address;
+
+			src=this->screen->pixels;
+				
+			for(j=this->screen->h;j;--j)
+			{
+				dst=dest;
+// SLOW routine, used for 8->24 bit mapping
+				for(k=0;k<this->screen->w;k++)
+				{
+					mask=(unsigned char *)(&SDL_XPixels[src[k]]);
+					for(t=0;t<bpp;t++)
+					{
+						dst[t]=mask[t];
+					}
+					dst+=bpp;
+				}
+				src+=this->screen->pitch;
+				dest+=destpitch;
+			}
+			UnLockBitMap(handle);
+		}
+	}
+	else if (customroutine==3)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
+								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
+		{
+			register int j,k;
+			register unsigned char *src,*dest;
+			register Uint16 *destl,*srcl;
+
+			if(!currently_fullscreen)
+				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+			else
+				dest=bm_address;
+
+			src=this->screen->pixels;
+				
+// This is the fast, well not too slow, remapping code for 16bit displays
+
+			for(j=this->screen->h;j;--j)
+			{
+				destl=(Uint16 *)dest;
+
+				for(k=0;k<this->screen->w;k++)
+				{
+					srcl=(Uint16 *)&SDL_XPixels[src[k]];
+					*destl=*srcl;
+					destl++;
+				}
+				src+=this->screen->pitch;
+				dest+=destpitch;
+			}
+			UnLockBitMap(handle);
+		}
+	}
+	else if (customroutine==4)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,LBMI_BASEADDRESS,(ULONG)&bm_address,
+								LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
+		{
+			register int j,k;
+			register unsigned char *src,*dest;
+			register Uint32 *destl,*srcl;
+
+			if(!currently_fullscreen)
+				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->hidden->BytesPerPixel;
+			else
+				dest=bm_address;
+
+			src=this->screen->pixels;
+				
+// This is the fast, well not too slow, remapping code for 32bit displays
+
+			for(j=this->screen->h;j;--j)
+			{
+				destl=(Uint32 *)dest;
+
+				for(k=0;k<this->screen->w;k++)
+				{
+					srcl=(Uint32 *)&SDL_XPixels[src[k]];
+					*destl=*srcl;
+					destl++;
+				}
+				src+=this->screen->pitch;
+				dest+=destpitch;
+			}
+			UnLockBitMap(handle);
+		}
+#endif
+	}
+	else if(customroutine)
+	{
+		unsigned char *bm_address;
+		Uint32	destpitch;
+		APTR handle;
+
+		if(handle=LockBitMapTags(SDL_RastPort->BitMap,
+					LBMI_BASEADDRESS,(ULONG)&bm_address,
+					LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE))
+		{
+			register int j;
+			register unsigned char *src,*dest;
+
+			if(!currently_fullscreen)
+				dest=bm_address+(SDL_Window->TopEdge+SDL_Window->BorderTop)*destpitch+(SDL_Window->BorderLeft+SDL_Window->LeftEdge)*this->screen->format->BytesPerPixel;
+			else
+				dest=bm_address;
+
+			src=this->screen->pixels;
+				
+//			D(bug("addr: %lx pitch: %ld src:%lx srcpitch: %ld\n",dest,destpitch,this->screen->pixels,this->screen->pitch));
+
+			if(this->screen->pitch==destpitch)
+			{
+				memcpy(dest,src,this->screen->pitch*this->screen->h);
+			}
+			else
+			{
+				for(j=this->screen->h;j;--j)
+				{
+					memcpy(dest,src,this->screen->pitch);
+					src+=this->screen->pitch;
+					dest+=destpitch;
+				}
+			}
+
+			UnLockBitMap(handle);
+		}
+	}
+	else
+	{
+		USE_WPA(this->screen->pixels,0,0,this->screen->pitch,
+				SDL_RastPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,
+				this->screen->w,this->screen->h,format);
+	}
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgximage_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_cgxvideo.h"
+
+extern int CGX_SetupImage(_THIS, SDL_Surface *screen);
+extern void CGX_DestroyImage(_THIS, SDL_Surface *screen);
+extern int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
+
+extern int CGX_AllocHWSurface(_THIS, SDL_Surface *surface);
+extern void CGX_FreeHWSurface(_THIS, SDL_Surface *surface);
+extern int CGX_LockHWSurface(_THIS, SDL_Surface *surface);
+extern void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface);
+extern int CGX_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+extern void CGX_RefreshDisplay(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxmodes.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,331 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Utilities for getting and setting the X display mode */
+
+/*
+#include <stdlib.h>
+#include <string.h>
+*/
+
+#include "SDL_timer.h"
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_cgxvideo.h"
+#include "SDL_cgxwm_c.h"
+#include "SDL_cgxmodes_c.h"
+
+#define CGX_DEBUG
+
+static void set_best_resolution(_THIS, int width, int height)
+{
+	Uint32 idok;
+	int depth=8;
+
+	if(SDL_Display)
+		depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
+
+	idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width,
+				CYBRBIDTG_NominalHeight,height,
+				CYBRBIDTG_Depth,depth,
+				TAG_DONE);
+
+	if(idok!=INVALID_ID)
+	{
+		if(SDL_Display)
+		{
+			if(currently_fullscreen)
+				CloseScreen(SDL_Display);
+			else
+				UnlockPubScreen(NULL,SDL_Display);
+		}
+		SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height,
+											SA_Depth,depth,SA_DisplayID,idok,
+											TAG_DONE);
+	}
+}
+
+static void get_real_resolution(_THIS, int* w, int* h)
+{
+    *w = SDL_Display->Width;
+    *h = SDL_Display->Height;
+}
+
+static void add_visual(_THIS, int depth, int class)
+{
+	Uint32 tID;
+
+	tID=BestCModeIDTags(CYBRBIDTG_Depth,depth,
+						CYBRBIDTG_NominalWidth,640,
+						CYBRBIDTG_NominalHeight,480,
+						TAG_DONE);
+
+	if(tID!=INVALID_ID)
+	{
+		int n = this->hidden->nvisuals;
+
+		this->hidden->visuals[n].depth = depth;
+		this->hidden->visuals[n].visual = tID;
+		this->hidden->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX,tID);
+		this->hidden->nvisuals++;
+	}
+}
+
+#define TrueColor 1
+#define PseudoColor 2
+
+int CGX_GetVideoModes(_THIS)
+{
+    int i;
+	ULONG nextid;
+	int nmodes=0;
+
+	SDL_modelist=NULL;
+
+	nextid=NextDisplayInfo(INVALID_ID);
+
+	while(nextid!=INVALID_ID)
+	{
+		if(IsCyberModeID(nextid))
+		{
+			DisplayInfoHandle h;
+
+			if(h=FindDisplayInfo(nextid))
+			{
+				struct DimensionInfo info;
+
+				if(GetDisplayInfoData(h,(char *)&info,sizeof(struct DimensionInfo),DTAG_DIMS,NULL))
+				{
+					int ok=0;
+
+					for(i=0;i<nmodes;i++)
+					{
+						if(	SDL_modelist[i]->w == (info.Nominal.MaxX+1) &&
+							SDL_modelist[i]->h == (info.Nominal.MaxY+1) )
+							ok=1;
+					}
+
+					if(!ok)
+					{
+						nmodes++;
+
+						SDL_modelist = (SDL_Rect **)realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *));
+						SDL_modelist[nmodes]=NULL;
+
+						if ( SDL_modelist ) 
+						{
+							SDL_modelist[nmodes-1] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+
+							if ( SDL_modelist[nmodes-1] == NULL ) 
+								break;
+
+							SDL_modelist[nmodes-1]->x = 0;
+							SDL_modelist[nmodes-1]->y = 0;
+							SDL_modelist[nmodes-1]->w = info.Nominal.MaxX+1;
+							SDL_modelist[nmodes-1]->h = info.Nominal.MaxY+1;
+						}
+					}																	
+				}
+			}
+		}
+		nextid=NextDisplayInfo(nextid);
+	}
+
+
+	this->hidden->nvisuals = 0;
+	/* Search for the visuals in deepest-first order, so that the first
+	   will be the richest one */
+	add_visual(this, 32, TrueColor);
+	add_visual(this, 24, TrueColor);
+	add_visual(this, 16, TrueColor);
+	add_visual(this, 15, TrueColor);
+	add_visual(this, 8, PseudoColor);
+
+	if(this->hidden->nvisuals == 0) {
+	    SDL_SetError("Found no sufficiently capable CGX visuals");
+		    return -1;
+	}
+
+    if ( SDL_modelist == NULL ) {
+        SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *));
+        i = 0;
+        if ( SDL_modelist ) {
+            SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+            if ( SDL_modelist[i] ) {
+                SDL_modelist[i]->x = 0;
+                SDL_modelist[i]->y = 0;
+                SDL_modelist[i]->w = SDL_Display->Width;
+                SDL_modelist[i]->h = SDL_Display->Height;
+                ++i;
+            }
+            SDL_modelist[i] = NULL;
+        }
+    }
+
+    D( if ( SDL_modelist ) {
+        bug("CGX video mode list: (%ld)\n",nmodes);
+        for ( i=0; SDL_modelist[i]; ++i ) {
+            bug( "\t%ld x %ld\n",
+                SDL_modelist[i]->w, SDL_modelist[i]->h);
+        }
+    	}
+    );
+
+    D(  { bug("CGX visuals list: (%ld)\n",this->hidden->nvisuals);
+
+	for(i=0;i<this->hidden->nvisuals;i++)
+		bug("\t%lx - depth: %ld bpp: %ld\n",this->hidden->visuals[i].visual,this->hidden->visuals[i].depth,this->hidden->visuals[i].bpp);
+	}
+    );
+    return 0;
+}
+
+int CGX_SupportedVisual(_THIS, SDL_PixelFormat *format)
+{
+    int i;
+    for(i = 0; i < this->hidden->nvisuals; i++)
+	{
+		if(this->hidden->visuals[i].depth == format->BitsPerPixel) // Era bpp
+		    return 1;
+	}
+    return 0;
+}
+
+SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+    if ( CGX_SupportedVisual(this, format) ) {
+        if ( flags & SDL_FULLSCREEN ) {
+            return(SDL_modelist);
+        } else {
+            return((SDL_Rect **)-1);
+        }
+    } else {
+        return((SDL_Rect **)0);
+    }
+}
+
+void CGX_FreeVideoModes(_THIS)
+{
+    int i;
+
+    if ( SDL_modelist ) {
+        for ( i=0; SDL_modelist[i]; ++i ) {
+            free(SDL_modelist[i]);
+        }
+        free(SDL_modelist);
+        SDL_modelist = NULL;
+    }
+}
+
+int CGX_ResizeFullScreen(_THIS)
+{
+    int x, y;
+    int real_w, real_h;
+
+    if ( currently_fullscreen ) {
+/* Per ora non faccio nulla qui */
+    }
+    return(1);
+}
+
+void _QueueEnterFullScreen(_THIS)
+{
+}
+
+int CGX_EnterFullScreen(_THIS)
+{
+    int okay;
+
+    okay = 1;
+    if ( ! currently_fullscreen ) 
+	{
+        int real_w, real_h;
+
+        /* Map the fullscreen window to blank the screen */
+        get_real_resolution(this, &real_w, &real_h);
+		
+		CGX_DestroyWindow(this,this->screen);
+		set_best_resolution(this, real_w,real_h);
+
+        /* Grab the mouse on the fullscreen window
+           The event handling will know when we become active, and then
+           enter fullscreen mode if we can't grab the mouse this time.
+         */
+#if 0
+        if ( (XGrabPointer(SDL_Display, FSwindow, True, 0,
+                          GrabModeAsync, GrabModeAsync,
+                          FSwindow, None, CurrentTime) != GrabSuccess) ||
+             (XGrabKeyboard(SDL_Display, WMwindow, True,
+                          GrabModeAsync, GrabModeAsync, CurrentTime) != 0) ) {
+            XUnmapWindow(SDL_Display, FSwindow);
+            X11_WaitUnmapped(this, FSwindow);
+            X11_QueueEnterFullScreen(this);
+            return(0);
+        }
+#endif
+
+        currently_fullscreen = 1;
+
+		CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
+
+        /* Set the new resolution */
+        okay = CGX_ResizeFullScreen(this);
+        if ( ! okay ) {
+            CGX_LeaveFullScreen(this);
+        }
+	/* Set the colormap */
+/*
+		if ( SDL_XColorMap ) {
+			XInstallColormap(SDL_Display, SDL_XColorMap);
+		}
+*/
+    }    
+//    CGX_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
+    return(okay);
+}
+
+int CGX_LeaveFullScreen(_THIS)
+{
+    if ( currently_fullscreen ) {
+		int width,height;
+		if ( SDL_Window ) {
+			CloseWindow(SDL_Window);
+			SDL_Window=NULL;
+		}
+		CloseScreen(SDL_Display);
+
+		GFX_Display=SDL_Display=LockPubScreen(NULL);
+
+	        currently_fullscreen = 0;
+
+		CGX_CreateWindow(this,this->screen,this->screen->w,this->screen->h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags);
+		CGX_ResizeImage(this,this->screen,0L);
+    }
+
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxmodes_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,44 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Utilities for getting and setting the X display mode */
+
+#include "SDL_cgxvideo.h"
+
+/* Define this if you want to grab the keyboard in fullscreen mode.
+   If you do not define this, SDL will return from SDL_SetVideoMode()
+   immediately, but will not actually go fullscreen until the window
+   manager is idle.
+*/
+#define GRAB_FULLSCREEN
+
+extern int CGX_GetVideoModes(_THIS);
+extern SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+extern void CGX_FreeVideoModes(_THIS);
+extern int CGX_ResizeFullScreen(_THIS);
+extern int CGX_EnterFullScreen(_THIS);
+extern int CGX_LeaveFullScreen(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxvideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1221 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* CGX based SDL video driver implementation.
+*/
+
+/*
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#ifdef MTRR_SUPPORT
+#include <asm/mtrr.h>
+#include <sys/fcntl.h>
+#endif
+*/
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_thread.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_endian.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_cgxvideo.h"
+#include "SDL_cgxwm_c.h"
+#include "SDL_amigamouse_c.h"
+#include "SDL_amigaevents_c.h"
+#include "SDL_cgxmodes_c.h"
+#include "SDL_cgximage_c.h"
+#include "SDL_cgxyuv_c.h"
+#include "SDL_cgxgl_c.h"
+
+/* Initialization/Query functions */
+static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int CGX_ToggleFullScreen(_THIS, int on);
+static void CGX_UpdateMouse(_THIS);
+static int CGX_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static void CGX_VideoQuit(_THIS);
+
+/* CGX driver bootstrap functions */
+
+struct Library *CyberGfxBase=NULL;
+struct IntuitionBase *IntuitionBase=NULL;
+struct GfxBase *GfxBase=NULL;
+
+static void DestroyScreen(_THIS)
+{
+  	if(currently_fullscreen)
+	{
+		if(this->hidden->dbuffer)
+		{
+			extern struct MsgPort *safeport,*dispport;
+
+			this->hidden->dbuffer=0;
+
+			if(safeport)
+			{
+				while(GetMsg(safeport)!=NULL);
+				DeleteMsgPort(safeport);
+			}
+			if(dispport)
+			{
+				while(GetMsg(dispport)!=NULL);
+				DeleteMsgPort(dispport);
+			}
+
+			this->hidden->SB[0]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[0]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
+			this->hidden->SB[1]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=this->hidden->SB[1]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=NULL;
+
+			if(this->hidden->SB[1])
+				FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
+			if(this->hidden->SB[0])
+				FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
+
+
+			this->hidden->SB[0]=this->hidden->SB[1]=NULL;
+			free(SDL_RastPort);
+			SDL_RastPort=NULL;
+			this->hidden->dbuffer=0;
+		}
+		CloseScreen(GFX_Display);
+	}
+	else
+		UnlockPubScreen(NULL,GFX_Display);
+
+	GFX_Display = NULL;
+}
+
+static int CGX_Available(void)
+{
+	struct Library *l;
+
+	l = OpenLibrary("cybergraphics.library",NULL);
+
+	if ( l != NULL ) {
+		CloseLibrary(l);
+	}
+	return(l != NULL);
+}
+
+static void CGX_DeleteDevice(SDL_VideoDevice *device)
+{
+	if ( device ) {
+		if ( device->hidden ) {
+			free(device->hidden);
+		}
+		if ( device->gl_data ) {
+			free(device->gl_data);
+		}
+		free(device);
+	}
+}
+
+static SDL_VideoDevice *CGX_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+		device->gl_data = (struct SDL_PrivateGLData *)
+				malloc((sizeof *device->gl_data));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ||
+	                         (device->gl_data == NULL) ) {
+		SDL_OutOfMemory();
+		CGX_DeleteDevice(device);
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+	memset(device->gl_data, 0, (sizeof *device->gl_data));
+
+	/* Set the driver flags */
+	device->handles_any_size = 1;
+
+	/* Set the function pointers */
+	device->VideoInit = CGX_VideoInit;
+	device->ListModes = CGX_ListModes;
+	device->SetVideoMode = CGX_SetVideoMode;
+	device->ToggleFullScreen = CGX_ToggleFullScreen;
+	device->UpdateMouse = CGX_UpdateMouse;
+	device->SetColors = CGX_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = CGX_VideoQuit;
+	device->AllocHWSurface = CGX_AllocHWSurface;
+	device->CheckHWBlit = CGX_CheckHWBlit;
+	device->FillHWRect = CGX_FillHWRect;
+	device->SetHWColorKey = CGX_SetHWColorKey;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = CGX_LockHWSurface;
+	device->UnlockHWSurface = CGX_UnlockHWSurface;
+	device->FlipHWSurface = CGX_FlipHWSurface;
+	device->FreeHWSurface = CGX_FreeHWSurface;
+#ifdef HAVE_OPENGL
+	device->GL_LoadLibrary = X11_GL_LoadLibrary;
+	device->GL_GetProcAddress = X11_GL_GetProcAddress;
+	device->GL_GetAttribute = X11_GL_GetAttribute;
+	device->GL_MakeCurrent = X11_GL_MakeCurrent;
+	device->GL_SwapBuffers = X11_GL_SwapBuffers;
+#endif
+	device->SetCaption = CGX_SetCaption;
+	device->SetIcon = CGX_SetIcon;
+	device->IconifyWindow = NULL; /* CGX_IconifyWindow; */
+	device->GrabInput = NULL /* CGX_GrabInput*/; 
+	device->GetWMInfo = CGX_GetWMInfo;
+	device->FreeWMCursor = amiga_FreeWMCursor;
+	device->CreateWMCursor = amiga_CreateWMCursor;
+	device->ShowWMCursor = amiga_ShowWMCursor;
+	device->WarpWMCursor = amiga_WarpWMCursor;
+	device->CheckMouseMode = amiga_CheckMouseMode;
+	device->InitOSKeymap = amiga_InitOSKeymap;
+	device->PumpEvents = amiga_PumpEvents;
+
+	device->free = CGX_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap CGX_bootstrap = {
+	"CGX", "Amiga CyberGFX video",
+	CGX_Available, CGX_CreateDevice
+};
+
+
+Uint32 MakeBitMask(_THIS,int type,int format,int *bpp)
+{
+	D(if(type==0)bug("REAL pixel format: "));
+
+	if(this->hidden->depth==*bpp)
+	{
+		
+	switch(format)
+    	{
+		case PIXFMT_LUT8:
+			D(if(type==0)bug("LUT8\n"));
+			return 0;
+		case PIXFMT_BGR15:
+		case PIXFMT_RGB15PC:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGB15PC/BGR15\n"));
+					return 31;
+				case 1:
+					return 992;
+				case 2:
+					return 31744;
+			}
+		case PIXFMT_RGB15:
+		case PIXFMT_BGR15PC:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGB15/BGR15PC\n"));
+					return 31744;
+				case 1:
+					return 992;
+				case 2:
+					return 31;
+			}
+		case PIXFMT_BGR16PC:
+		case PIXFMT_RGB16:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGB16PC\n"));
+					return 63488;
+				case 1:
+					return 2016;
+				case 2:
+					return 31;
+			}
+		case PIXFMT_BGR16:
+		case PIXFMT_RGB16PC:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGB16PC/BGR16\n"));
+					return 31;
+				case 1:
+					return 2016;
+				case 2:
+					return 63488;
+			}
+
+		case PIXFMT_RGB24:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGB24/BGR24\n"));
+					return 0xff0000;
+				case 1:
+					return 0xff00;
+				case 2:
+					return 0xff;
+			}
+		case PIXFMT_BGR24:
+			switch(type)
+			{
+				case 0:
+					D(bug("BGR24\n"));
+					return 0xff;
+				case 1:
+					return 0xff00;
+				case 2:
+					return 0xff0000;
+			}
+		case PIXFMT_ARGB32:
+			switch(type)
+			{
+				case 0:
+					D(bug("ARGB32\n"));
+					return 0xff0000;
+				case 1:
+					return 0xff00;
+				case 2:
+					return 0xff;
+			}
+		case PIXFMT_BGRA32:
+			switch(type)
+			{
+				case 0:
+					D(bug("BGRA32\n"));
+					return 0xff00;
+				case 1:
+					return 0xff0000;
+				case 2:
+					return 0xff000000;
+			}
+		case PIXFMT_RGBA32:
+			switch(type)
+			{
+				case 0:
+					D(bug("RGBA32\n"));
+					return 0xff000000;
+				case 1:
+					return 0xff0000;
+				case 2:
+					return 0xff00;
+			}
+		default:
+			D(bug("Unknown pixel format! Default to 24bit\n"));
+			return (Uint32) (255<<(type*8));
+	}
+	}
+	else
+	{
+		D(if(type==0)bug("DIFFERENT from screen.\nAllocated screen format: "));
+	
+		switch(*bpp)
+		{
+			case 32:
+				D(if(type==0) bug("RGBA32\n"));
+				switch(type)
+				{
+					case 0:
+						return 0xff000000;
+					case 1:
+						return 0xff0000;
+					case 2:
+						return 0xff00;
+				}
+				break;
+			case 24:
+use_truecolor:
+				switch(type)
+				{
+					case 0:
+						D(bug("RGB24\n"));
+						return 0xff0000;
+					case 1:
+						return 0xff00;
+					case 2:
+						return 0xff;
+				}
+			case 16:
+			case 15:
+				D(if(type==0) bug("Not supported, switching to 24bit!\n"));
+				*bpp=24;
+				goto use_truecolor;
+				break;				
+			default:
+				D(if(type==0)bug("This is a chunky display\n"));
+// For chunky display mask is always 0;
+				return 0;
+		}
+	} 
+	return 0;
+}
+
+static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	int i;
+
+	if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L)))
+	{
+		SDL_SetError("Couldn't open intuition V39+");
+		return -1;
+	}
+	if(!(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L)))
+	{
+		SDL_SetError("Couldn't open graphics V39+");
+		return -1;
+	}
+	if(!(CyberGfxBase=OpenLibrary("cybergraphics.library",40L)))
+	{
+		SDL_SetError("Couldn't open cybergraphics.");
+		return(-1);
+	}
+
+	SDL_Display = LockPubScreen(NULL);
+
+	if ( SDL_Display == NULL ) {
+		SDL_SetError("Couldn't lock the display");
+		return(-1);
+	}
+
+	if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)))
+	{
+		Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width,
+				CYBRBIDTG_NominalHeight,SDL_Display->Height,
+				CYBRBIDTG_Depth,8,
+				TAG_DONE);
+
+		UnlockPubScreen(NULL,SDL_Display);
+
+		GFX_Display=NULL;
+
+		if(okid!=INVALID_ID)
+		{
+			GFX_Display=OpenScreenTags(NULL,
+									SA_Width,SDL_Display->Width,
+									SA_Height,SDL_Display->Height,
+									SA_Depth,8,SA_Quiet,TRUE,
+									SA_ShowTitle,FALSE,
+									SA_DisplayID,okid,
+									TAG_DONE);
+		}
+
+		if(!GFX_Display)
+		{
+			SDL_SetError("Unable to open a suited CGX display");
+			return -1;
+		}
+		else SDL_Display=GFX_Display;
+
+	}
+	else GFX_Display = SDL_Display;
+
+
+	/* See whether or not we need to swap pixels */
+
+	swap_pixels = 0;
+
+// Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente
+
+	if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
+			swap_pixels = 1;
+	}
+
+	/* Get the available video modes */
+	if(CGX_GetVideoModes(this) < 0)
+	    return -1;
+
+	/* Determine the default screen depth:
+	   Use the default visual (or at least one with the same depth) */
+
+	for(i = 0; i < this->hidden->nvisuals; i++)
+	    if(this->hidden->visuals[i].depth == GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH))
+					break;
+	if(i == this->hidden->nvisuals) {
+	    /* default visual was useless, take the deepest one instead */
+	    i = 0;
+	}
+	SDL_Visual = this->hidden->visuals[i].visual;
+
+	this->hidden->depth = this->hidden->visuals[i].depth;
+	D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
+	vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */
+
+	{
+		int form;
+		APTR handle;
+		struct DisplayInfo info;
+
+		if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual)))
+			return -1;
+
+		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL))
+			return -1;
+
+		form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
+
+// In this case I use makebitmask in a way that I'm sure I'll get PIXFMT pixel mask
+
+		if ( vformat->BitsPerPixel > 8 ) 
+		{
+			vformat->Rmask = MakeBitMask(this,0,form,&this->hidden->depth);
+	  		vformat->Gmask = MakeBitMask(this,1,form,&this->hidden->depth);
+		  	vformat->Bmask = MakeBitMask(this,2,form,&this->hidden->depth);
+		}
+	}
+
+	/* Create the fullscreen and managed windows */
+//	create_aux_windows(this);
+
+	/* Create the blank cursor */
+	SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR);
+
+	/* Fill in some window manager capabilities */
+	this->info.wm_available = 1;
+	this->info.blit_hw = 1;
+	this->info.blit_hw_CC = 1;
+	this->info.blit_sw = 1;
+	this->info.blit_fill = 1;
+	this->info.video_mem=2000000; // Not always true but almost any Amiga card has this memory!
+
+	this->hidden->same_format=0;
+	SDL_RastPort=&SDL_Display->RastPort;
+	/* We're done! */
+	return(0);
+}
+
+void CGX_DestroyWindow(_THIS, SDL_Surface *screen)
+{
+	/* Hide the managed window */
+	int was_fullscreen=0;
+
+	if ( screen && (screen->flags & SDL_FULLSCREEN) ) {	
+		was_fullscreen=1;
+		screen->flags &= ~SDL_FULLSCREEN;
+		CGX_LeaveFullScreen(this);
+	}
+
+	/* Destroy the output window */
+	if ( SDL_Window ) {
+		CloseWindow(SDL_Window);
+		SDL_Window=NULL;
+	}
+
+	/* Free the colormap entries */
+	if ( SDL_XPixels ) {
+		int numcolors;
+		unsigned long pixel;
+
+		if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen)
+		{
+			numcolors = 1<<this->screen->format->BitsPerPixel;
+
+			if(numcolors>256)
+				numcolors=256;
+
+			if(!was_fullscreen&&this->hidden->depth==8)
+			{
+				for ( pixel=0; pixel<numcolors; pixel++ ) 
+				{
+					if(SDL_XPixels[pixel]>=0)
+						ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
+				}
+			}
+		}
+		free(SDL_XPixels);
+		SDL_XPixels = NULL;
+	} 
+}
+
+static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags)
+{
+	if ( flags & SDL_RESIZABLE ) {
+		WindowLimits(SDL_Window, 32, 32,4096,4096);
+	} else {
+		WindowLimits(SDL_Window, w,h,w,h);
+	}
+	if ( flags & SDL_FULLSCREEN ) {
+		flags&=~SDL_RESIZABLE;
+	} else if ( getenv("SDL_VIDEO_CENTERED") ) {
+		int display_w, display_h;
+
+		display_w = SDL_Display->Width;
+		display_h = SDL_Display->Height;
+		ChangeWindowBox(SDL_Window,(display_w - w - SDL_Window->BorderLeft-SDL_Window->BorderRight)/2,
+					(display_h - h - SDL_Window->BorderTop-SDL_Window->BorderBottom)/2,
+					w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
+					h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
+	}
+}
+
+int CGX_CreateWindow(_THIS, SDL_Surface *screen,
+			    int w, int h, int bpp, Uint32 flags)
+{
+#if 0
+	int i, depth;
+	Uint32 vis;
+#endif
+	/* If a window is already present, destroy it and start fresh */
+	if ( SDL_Window ) {
+		CGX_DestroyWindow(this, screen);
+	}
+	SDL_Window = 0;
+
+	/* find out which visual we are going to use */
+#if 0
+/* questo l'ho spostato nell'apertura dello schermo, in quanto su Amiga le finestre
+   hanno il pixel mode degli schermi.
+ */
+	if ( flags & SDL_OPENGL ) {
+		SDL_SetError("OpenGL not supported by the Amiga SDL!");
+		return -1;
+	} 
+	else {
+		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
+			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
+				break;
+		}
+		if ( i == this->hidden->nvisuals ) {
+			SDL_SetError("No matching visual for requested depth");
+			return -1;	/* should never happen */
+		}
+		vis = this->hidden->visuals[i].visual;
+		depth = this->hidden->visuals[i].depth;
+	}
+	SDL_Visual = vis;
+	this->hidden->depth = depth;
+	D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
+#endif
+
+	/* Allocate the new pixel format for this video mode */
+	{
+		Uint32 form;
+		APTR handle;
+		struct DisplayInfo info;
+
+		if(!(handle=FindDisplayInfo(SDL_Visual)))
+			return -1;
+
+		if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL))
+			return -1;
+
+		form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual);
+
+		if(flags&SDL_HWSURFACE)
+		{
+			if(bpp!=this->hidden->depth)
+			{
+				bpp=this->hidden->depth;
+				D(bug("Accel forces bpp to be equal (%ld)\n",bpp));
+			}
+		}
+
+		D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
+
+/* With this call if needed I'll revert the wanted bpp to a bpp best suited for the display, actually occurs
+   only with requested format 15/16bit and display format != 15/16bit
+ */	
+
+		if ( ! SDL_ReallocFormat(screen, bpp,
+				MakeBitMask(this,0,form,&bpp), MakeBitMask(this,1,form,&bpp), MakeBitMask(this,2,form,&bpp), 0) )
+			return -1;
+
+		D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth));
+
+	}
+
+	/* Create the appropriate colormap */
+	if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) {
+	    int ncolors;
+	    D(bug("Alloco XPixels x la palette...\n"));
+
+	    /* Allocate the pixel flags */
+
+	    if(bpp==8)
+		ncolors=256;
+	    else
+		ncolors = 1 << screen->format->BitsPerPixel;
+
+	    SDL_XPixels = (Sint32 *)malloc(ncolors * sizeof(Sint32));
+		
+	    if(SDL_XPixels == NULL) {
+		SDL_OutOfMemory();
+		return -1;
+	    }
+
+	    memset(SDL_XPixels, -1, ncolors * sizeof(Sint32));
+
+	    /* always allocate a private colormap on non-default visuals */
+	    if(bpp==8)
+		flags |= SDL_HWPALETTE;
+
+	    if ( flags & SDL_HWPALETTE ) {
+		screen->flags |= SDL_HWPALETTE;
+	    }
+	}
+
+	/* resize the (possibly new) window manager window */
+
+	/* Create (or use) the X11 display window */
+	if ( flags & SDL_OPENGL ) {
+		return(-1);
+	} else {
+		if(flags & SDL_FULLSCREEN)
+			SDL_Window = OpenWindowTags(NULL,WA_Width,w,WA_Height,h,
+											WA_Flags,WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_BORDERLESS|WFLG_BACKDROP|WFLG_REPORTMOUSE,
+											WA_IDCMP,IDCMP_RAWKEY|IDCMP_MOUSEBUTTONS|IDCMP_MOUSEMOVE,
+											WA_CustomScreen,(ULONG)SDL_Display,
+											TAG_DONE);
+		else
+			SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h,
+											WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP|WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR| ((screen->flags&SDL_RESIZABLE) ? WFLG_SIZEGADGET|WFLG_SIZEBBOTTOM : 0),
+											WA_IDCMP,IDCMP_RAWKEY|IDCMP_CLOSEWINDOW|IDCMP_MOUSEBUTTONS|IDCMP_NEWSIZE|IDCMP_MOUSEMOVE,
+											WA_PubScreen,(ULONG)SDL_Display,
+											TAG_DONE);
+	}
+	/* Only manage our input if we own the window */
+	if(!SDL_Window)
+		return -1;
+
+	this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX);
+
+	if(screen->flags & SDL_DOUBLEBUF)
+	{
+		if(SDL_RastPort=malloc(sizeof(struct RastPort)))
+		{
+			InitRastPort(SDL_RastPort);
+			SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap;
+		}
+		else
+			return -1;
+	}
+	else SDL_RastPort=SDL_Window->RPort;
+#if 0
+
+	if(screen->flags & SDL_HWPALETTE) {
+	    /* Since the full-screen window might have got a nonzero background
+	       colour (0 is white on some displays), we should reset the
+	       background to 0 here since that is what the user expects
+	       with a private colormap */
+		SetAPen(SDL_Window->RPort,0);
+		RectFill(SDL_Window->RPort,SDL_Window->BorderLeft,SDL_Window->BorderTop,w+SDL_Window->BorderLeft,h+SDL_Window->BorderTop);
+	}
+#endif
+
+	if(flags&SDL_HWSURFACE)
+		screen->flags|=SDL_HWSURFACE;
+
+	CGX_SetSizeHints(this, w, h, flags);
+	current_w = w;
+	current_h = h;
+
+	/* Map them both and go fullscreen, if requested */
+	if ( flags & SDL_FULLSCREEN ) {
+		screen->flags |= SDL_FULLSCREEN;
+		currently_fullscreen=1;
+//		CGX_EnterFullScreen(this); Ci siamo gia'!
+	} else {
+		screen->flags &= ~SDL_FULLSCREEN;
+	}
+	return(0);
+}
+
+int CGX_ResizeWindow(_THIS,
+			SDL_Surface *screen, int w, int h, Uint32 flags)
+{
+	/* Resize the window manager window */
+	CGX_SetSizeHints(this, w, h, flags);
+	current_w = w;
+	current_h = h;
+
+	ChangeWindowBox(SDL_Window,SDL_Window->LeftEdge,SDL_Window->TopEdge, w+SDL_Window->BorderLeft+SDL_Window->BorderRight,
+				h+SDL_Window->BorderTop+SDL_Window->BorderBottom);
+
+	/* Resize the fullscreen and display windows */
+	if ( flags & SDL_FULLSCREEN ) {
+		if ( screen->flags & SDL_FULLSCREEN ) {
+			CGX_ResizeFullScreen(this);
+		} else {
+			screen->flags |= SDL_FULLSCREEN;
+			CGX_EnterFullScreen(this);
+		}
+	} else {
+		if ( screen->flags & SDL_FULLSCREEN ) {
+			screen->flags &= ~SDL_FULLSCREEN;
+			CGX_LeaveFullScreen(this);
+		}
+	}
+	return(0);
+}
+
+static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	Uint32 saved_flags;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+// Check if we need to close an already existing videomode... 
+
+	if(current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))
+	{
+		CGX_DestroyImage(this,current);
+		CGX_DestroyWindow(this,current);
+		DestroyScreen(this);
+	}
+	/* Check the combination of flags we were passed */
+	if ( flags & SDL_FULLSCREEN ) {
+		int i;
+	
+		/* Clear fullscreen flag if not supported */
+		if(current->flags&SDL_FULLSCREEN )
+		{
+			if(current->w!=width ||
+				current->h!=height ||
+				this->hidden->depth!=bpp)
+			{
+				CGX_DestroyImage(this,current);
+				CGX_DestroyWindow(this,current);
+				DestroyScreen(this);
+				goto buildnewscreen;
+			}
+		}
+		else
+buildnewscreen:
+		{
+			Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,width,
+				CYBRBIDTG_NominalHeight,height,
+				CYBRBIDTG_Depth,bpp,
+				TAG_DONE);
+
+			GFX_Display=NULL;
+
+			if(okid!=INVALID_ID)
+			{
+				GFX_Display=OpenScreenTags(NULL,
+								SA_Width,width,
+								SA_Height,height,
+								SA_Quiet,TRUE,SA_ShowTitle,FALSE,
+								SA_Depth,bpp,
+								SA_DisplayID,okid,
+								TAG_DONE);
+			}
+
+
+			if(!GFX_Display)
+			{
+				GFX_Display=SDL_Display;
+				flags &= ~SDL_FULLSCREEN;
+				flags &= ~SDL_DOUBLEBUF;
+			}
+			else
+			{
+				UnlockPubScreen(NULL,SDL_Display);
+				SDL_Display=GFX_Display;
+
+				if(flags&SDL_DOUBLEBUF)
+				{
+					int ok=0;
+
+					if(this->hidden->SB[0]=AllocScreenBuffer(SDL_Display,NULL,SB_SCREEN_BITMAP))
+					{
+						if(this->hidden->SB[1]=AllocScreenBuffer(SDL_Display,NULL,0L))
+						{
+							extern struct MsgPort *safeport,*dispport;
+
+							safeport=CreateMsgPort();
+							dispport=CreateMsgPort();
+
+							if(!safeport || !dispport)
+							{
+								if(safeport)
+								{
+									DeleteMsgPort(safeport);
+									safeport=NULL;
+								}
+								if(dispport)
+								{
+									DeleteMsgPort(dispport);
+									dispport=NULL;
+								}
+								FreeScreenBuffer(SDL_Display,this->hidden->SB[0]);
+								FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
+							}
+							else
+							{
+								extern ULONG safe_sigbit,disp_sigbit;
+								int i;
+
+								safe_sigbit=1L<< safeport->mp_SigBit;
+								disp_sigbit=1L<< dispport->mp_SigBit;
+	
+								for(i=0;i<2;i++)
+								{
+									this->hidden->SB[i]->sb_DBufInfo->dbi_SafeMessage.mn_ReplyPort=safeport;
+									this->hidden->SB[i]->sb_DBufInfo->dbi_DispMessage.mn_ReplyPort=dispport;
+								}
+
+								ok=1;
+								D(bug("Dbuffering enabled!\n"));
+								this->hidden->dbuffer=1;
+								current->flags|=SDL_DOUBLEBUF;
+							}
+						}
+						else 
+						{
+							FreeScreenBuffer(SDL_Display,this->hidden->SB[1]);
+							this->hidden->SB[0]=NULL;
+						}
+					}
+
+					if(!ok)
+					{
+						flags&=~SDL_DOUBLEBUF;
+					}
+				}
+			}
+
+			if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp)
+				this->hidden->same_format=1;				
+		}
+
+		bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH);
+		D(bug("Setto la profiondita' dello schermo a: %ld\n",this->hidden->depth));
+
+		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
+			if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */
+				break;
+		}
+		if ( i == this->hidden->nvisuals ) {
+			SDL_SetError("No matching visual for requested depth");
+			return NULL;	/* should never happen */
+		}
+		SDL_Visual = this->hidden->visuals[i].visual;
+
+	}
+
+	/* Set up the X11 window */
+	saved_flags = current->flags;
+
+	if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)
+	    && bpp == current->format->BitsPerPixel) {
+		if (CGX_ResizeWindow(this, current, width, height, flags) < 0) {
+			current = NULL;
+			goto done;
+		}
+	} else {
+		if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) {
+			current = NULL;
+			goto done;
+		}
+	}
+
+	/* Set up the new mode framebuffer */
+	if ( ((current->w != width) || (current->h != height)) ||
+             ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) {
+		current->w = width;
+		current->h = height;
+		current->pitch = SDL_CalculatePitch(current);
+		CGX_ResizeImage(this, current, flags);
+	}
+	current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it
+
+  done:
+	/* Release the event thread */
+	SDL_Unlock_EventThread();
+
+	/* We're done! */
+	return(current);
+}
+
+static int CGX_ToggleFullScreen(_THIS, int on)
+{
+	Uint32 event_thread;
+
+	/* Don't lock if we are the event thread */
+	event_thread = SDL_EventThreadID();
+	if ( event_thread && (SDL_ThreadID() == event_thread) ) {
+		event_thread = 0;
+	}
+	if ( event_thread ) {
+		SDL_Lock_EventThread();
+	}
+	if ( on ) {
+		this->screen->flags |= SDL_FULLSCREEN;
+		CGX_EnterFullScreen(this);
+	} else {
+		this->screen->flags &= ~SDL_FULLSCREEN;
+		CGX_LeaveFullScreen(this);
+	}
+	CGX_RefreshDisplay(this);
+	if ( event_thread ) {
+		SDL_Unlock_EventThread();
+	}
+	SDL_ResetKeyboard();
+	return(1);
+}
+
+static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c)
+{
+	switch(fmt)
+	{
+		case PIXFMT_BGR15:
+		case PIXFMT_RGB15PC:
+			{
+				Uint16 *t=(Uint16 *)c;
+				*t=(r>>3) | ((g>>3)<<5) | ((b>>3)<<10) ;
+			}
+			break;
+		case PIXFMT_RGB15:
+		case PIXFMT_BGR15PC:
+			{
+				Uint16 *t=(Uint16 *)c;
+				*t=(b>>3) | ((g>>3)<<5) | ((r>>3)<<10) ;
+			}
+			break;
+		case PIXFMT_BGR16PC:
+		case PIXFMT_RGB16:
+			{
+				Uint16 *t=(Uint16 *)c;
+				*t=(b>>3) | ((g>>2)<<5) | ((r>>3)<<11) ;
+			}
+			break;
+		case PIXFMT_BGR16:
+		case PIXFMT_RGB16PC:
+			{
+				Uint16 *t=(Uint16 *)c;
+				*t=(r>>3) | ((g>>2)<<5) | ((b>>3)<<11) ;
+			}
+			break;
+		case PIXFMT_RGB24:
+			c[0]=r;
+			c[1]=g;
+			c[2]=b;
+			c[3]=0;
+			break;
+		case PIXFMT_BGR24:
+			c[0]=b;
+			c[1]=g;
+			c[2]=r;
+			c[3]=0;
+			break;
+		case PIXFMT_ARGB32:
+			c[0]=0;
+			c[1]=r;
+			c[2]=g;
+			c[3]=b;
+			break;
+		case PIXFMT_BGRA32:
+			c[0]=b;
+			c[1]=g;
+			c[2]=r;
+			c[3]=0;
+			break;
+		case PIXFMT_RGBA32:
+			c[0]=r;
+			c[1]=g;
+			c[2]=b;
+			c[3]=0;
+			break;
+
+		default:
+			D(bug("Errore, SetSingleColor con PIXFMT %ld!\n",fmt));
+	}
+}
+
+/* Update the current mouse state and position */
+static void CGX_UpdateMouse(_THIS)
+{
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	if(currently_fullscreen)
+	{
+			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX, SDL_Display->MouseY);
+	}
+	else
+	{
+		if(	SDL_Display->MouseX>=(SDL_Window->LeftEdge+SDL_Window->BorderLeft) && SDL_Display->MouseX<(SDL_Window->LeftEdge+SDL_Window->Width-SDL_Window->BorderRight) &&
+			SDL_Display->MouseY>=(SDL_Window->TopEdge+SDL_Window->BorderLeft) && SDL_Display->MouseY<(SDL_Window->TopEdge+SDL_Window->Height-SDL_Window->BorderBottom) 
+			)
+		{
+			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			SDL_PrivateMouseMotion(0, 0, SDL_Display->MouseX-SDL_Window->LeftEdge-SDL_Window->BorderLeft, 
+										SDL_Display->MouseY-SDL_Window->TopEdge-SDL_Window->BorderTop);
+		}
+		else
+		{
+			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+		}
+	}
+	SDL_Unlock_EventThread();
+}
+
+static int CGX_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int      i;
+
+	/* Check to make sure we have a colormap allocated */
+
+// It's not needed to reload the whole palette each time on Amiga!
+//	ncolors = this->screen->format->palette->ncolors;
+
+	/* It's easy if we have a hidden colormap */
+	if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) 
+	{
+		ULONG  xcmap[256*3+2];
+
+		xcmap[0]=(ncolors<<16);
+		xcmap[0]+=firstcolor;
+
+//		D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors));
+
+		for ( i=0; i<ncolors; i++ ) {
+			xcmap[i*3+1] = colors[i].r<<24;
+			xcmap[i*3+2] = colors[i].g<<24;
+			xcmap[i*3+3] = colors[i].b<<24;
+		}
+		xcmap[ncolors*3+1]=0;
+		LoadRGB32(&GFX_Display->ViewPort,xcmap);
+	} else {
+// XPixels are not needed on 8bit screen with hwpalette
+		unsigned long pixel;
+
+		if ( SDL_XPixels == NULL ) {
+			D(bug("SetColors without colormap!"));
+			return(0);
+		}
+
+		colors = this->screen->format->palette->colors;
+		if(this->hidden->depth==8)
+		{
+// In this case I have to unalloc and realloc the full palette
+			D(bug("Obtaining %ld colors on the screen\n",ncolors));
+	
+		/* Free existing allocated colors */
+			for ( pixel=0; pixel<this->screen->format->palette->ncolors; ++pixel ) {
+				if(SDL_XPixels[pixel]>=0)
+					ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]);
+			}
+
+		/* Try to allocate all the colors */
+			for ( i=0; i<this->screen->format->palette->ncolors; ++i ) {
+				SDL_XPixels[i]=ObtainBestPenA(GFX_Display->ViewPort.ColorMap,colors[i].r<<24,colors[i].g<<24,colors[i].b<<24,NULL);
+			}
+		}
+		else
+		{			
+#ifndef USE_CGX_WRITELUTPIXEL
+			Uint32 fmt;
+			D(bug("Preparing a conversion pixel table...\n"));
+
+			fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT);
+
+			for(i=0;i<ncolors;i++)
+			{
+				SetSingleColor(fmt,colors[firstcolor+i].r,colors[firstcolor+i].g,colors[firstcolor+i].b,(unsigned char *)&SDL_XPixels[firstcolor+i]);
+			}
+#else
+//			D(bug("Eseguo remap degli XPixel(%lx): (da %ld, %ld colori) primo: r%ld g%ld b%ld\n",SDL_XPixels,firstcolor,ncolors,colors[firstcolor].r,colors[firstcolor].g,colors[firstcolor].b));
+			for(i=0;i<ncolors;i++)
+				SDL_XPixels[i+firstcolor]=(colors[firstcolor+i].r<<16)+(colors[firstcolor+i].g<<8)+colors[firstcolor+i].b;
+#endif
+		}
+	}
+
+// Actually it cannot fail!
+
+	return 1;
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+static void CGX_VideoQuit(_THIS)
+{
+	/* Shutdown everything that's still up */
+	/* The event thread should be done, so we can touch SDL_Display */
+	if ( SDL_Display != NULL ) {
+		/* Clean up OpenGL */
+
+		/* Start shutting down the windows */
+		CGX_DestroyImage(this, this->screen);
+		CGX_DestroyWindow(this, this->screen);
+// Otherwise SDL_VideoQuit will try to free it!
+		SDL_VideoSurface=NULL;
+		CGX_FreeVideoModes(this);
+
+		/* Free that blank cursor */
+		if ( SDL_BlankCursor != NULL ) {
+			FreeMem(SDL_BlankCursor,16);
+			SDL_BlankCursor = NULL;
+		}
+
+		/* Close the X11 graphics connection */
+		this->hidden->same_format=0;
+
+		if ( GFX_Display != NULL )
+			DestroyScreen(this);
+
+		/* Close the X11 display connection */
+		SDL_Display = NULL;
+
+		/* Unload GL library after X11 shuts down */
+	}
+
+	if( CyberGfxBase)
+	{
+		CloseLibrary(CyberGfxBase);
+		CyberGfxBase=NULL;
+	}
+
+	if (IntuitionBase)
+	{
+		CloseLibrary((struct Library *)IntuitionBase);
+		IntuitionBase=NULL;
+	}
+	if (GfxBase)
+	{
+		CloseLibrary((struct Library *)GfxBase);
+		GfxBase=NULL;
+	}
+
+	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
+		/* Direct screen access, no memory buffer */
+		this->screen->pixels = NULL;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,179 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_cgxvideo_h
+#define _SDL_cgxvideo_h
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <exec/exec.h>
+#include <cybergraphx/cybergraphics.h>
+#include <graphics/scale.h>
+#include <graphics/gfx.h>
+#include <intuition/intuition.h>
+#ifdef __SASC
+#include <proto/exec.h>
+#include <proto/cybergraphics.h>
+#include <proto/graphics.h>
+#include <proto/intuition.h>
+#include <proto/console.h>
+#else
+#include <inline/exec.h>
+#include <inline/cybergraphics.h>
+#include <inline/graphics.h>
+#include <inline/intuition.h>
+#include <inline/console.h>
+#endif
+
+#include "mydebug.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+#define USE_CGX_WRITELUTPIXEL
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+    struct Screen *Public_Display; /* Used for events and window management */
+    struct Screen *GFX_Display;	/* Used for graphics and colormap stuff */
+    Uint32 SDL_VisualUnused;		/* The visual used by our window */
+    struct Window *SDL_Window;	/* Shared by both displays (no X security?) */
+    unsigned char *BlankCursor;	/* The invisible cursor */
+
+    /* The variables used for displaying graphics */
+    Uint8 *Ximage;		/* The X image for our window */
+    int swap_pixels;		/* Flag: true if display is swapped endian */
+
+    /* The current width and height of the fullscreen mode */
+    int current_w;
+    int current_h;
+
+    /* Support for internal mouse warping */
+    struct {
+        int x;
+        int y;
+    } mouse_last;
+    struct {
+        int numerator;
+        int denominator;
+        int threshold;
+    } mouse_accel;
+    int mouse_relative;
+
+    /* The current list of available video modes */
+    SDL_Rect **modelist;
+
+    /* available visuals of interest to us, sorted deepest first */
+    struct {
+		Uint32 visual;
+		int depth;		/* number of significant bits/pixel */
+		int bpp;		/* pixel quantum in bits */
+    } visuals[5];		/* at most entries for 8, 15, 16, 24 */
+    int nvisuals;
+
+    Uint32 vis;		/* current visual in use */
+    int depth;			/* current visual depth (not bpp) */
+    int BytesPerPixel;
+    int currently_fullscreen,same_format,dbuffer;
+
+    /* Automatic mode switching support (entering/leaving fullscreen) */
+    Uint32 switch_waiting;
+    Uint32 switch_time;
+
+    /* Prevent too many XSync() calls */
+    int blit_queued;
+
+    /* Colormap handling */
+    LONG Pens;
+    Sint32 *XPixels;		/* A list of pixels that have been allocated, the size depends on the screen format */
+	struct ScreenBuffer *SB[2];
+	struct RastPort *RP;
+    short *iconcolors;		/* List of colors used by the icon */
+};
+
+/* Old variable names */
+#define local_X11		(this->hidden->local_X11)
+#define SDL_Display		(this->hidden->Public_Display)
+#define GFX_Display		(this->hidden->GFX_Display)
+#define SDL_Screen		DefaultScreen(this->hidden->Public_Display)
+
+#define SDL_Visual		(this->hidden->vis)
+
+#define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
+#define WMwindow		(this->hidden->WMwindow)
+#define FSwindow		(this->hidden->FSwindow)
+#define SDL_Window		(this->hidden->SDL_Window)
+#define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
+#define SDL_BlankCursor		(this->hidden->BlankCursor)
+#define SDL_Ximage		(this->hidden->Ximage)
+#define SDL_GC			(this->hidden->gc)
+#define swap_pixels		(this->hidden->swap_pixels)
+#define current_w		(this->hidden->current_w)
+#define current_h		(this->hidden->current_h)
+#define mouse_last		(this->hidden->mouse_last)
+#define mouse_accel		(this->hidden->mouse_accel)
+#define mouse_relative		(this->hidden->mouse_relative)
+#define SDL_modelist		(this->hidden->modelist)
+#define SDL_RastPort		(this->hidden->RP)
+#define saved_mode		(this->hidden->saved_mode)
+#define saved_view		(this->hidden->saved_view)
+#define currently_fullscreen	(this->hidden->currently_fullscreen)
+#define blit_queued		(this->hidden->blit_queued)
+#define SDL_DisplayColormap	(this->hidden->GFX_Display->ViewPort.ColorMap)
+#define SDL_XPixels		(this->hidden->XPixels)
+#define SDL_iconcolors		(this->hidden->iconcolors)
+
+extern int CGX_CreateWindow(_THIS, SDL_Surface *screen,
+			    int w, int h, int bpp, Uint32 flags);
+extern int CGX_ResizeWindow(_THIS,
+			SDL_Surface *screen, int w, int h, Uint32 flags);
+
+extern void CGX_DestroyWindow(_THIS, SDL_Surface *screen);
+
+extern struct Library *CyberGfxBase;
+extern struct IntuitionBase *IntuitionBase;
+extern struct GfxBase *GfxBase;
+extern struct ExecBase *SysBase;
+extern struct DosLibrary *DOSBase;
+
+struct private_hwdata
+{
+	struct BitMap *bmap;
+	APTR lock;
+	struct SDL_VideoDevice *videodata;
+	APTR mask;
+};
+
+int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst);
+int CGX_FillHWRect(_THIS,SDL_Surface *dst,SDL_Rect *dstrect,Uint32 color);
+int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key);
+#endif /* _SDL_x11video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxwm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,331 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_version.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_video.h"
+#include "SDL_syswm.h"
+#include "SDL_events_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_cgxmodes_c.h"
+#include "SDL_cgxwm_c.h"
+
+/* This is necessary for working properly with Enlightenment, etc. */
+#define USE_ICON_WINDOW
+
+void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
+{
+#if 0
+	SDL_Surface *sicon;
+	XWMHints *wmhints;
+	XImage *icon_image;
+	Pixmap icon_pixmap;
+	Pixmap mask_pixmap;
+#ifdef USE_ICON_WINDOW
+	Window icon_window;
+#endif
+	GC GC;
+	XGCValues GCvalues;
+	int i, b, dbpp;
+	SDL_Rect bounds;
+	Uint8 *LSBmask, *color_tried;
+	Visual *dvis;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	/* The icon must use the default visual, depth and colormap of the
+	   screen, so it might need a conversion */
+	dbpp = DefaultDepth(SDL_Display, SDL_Screen);
+	switch(dbpp) {
+	case 15:
+	    dbpp = 16; break;
+	case 24:
+	    dbpp = 32; break;
+	}
+	dvis = DefaultVisual(SDL_Display, SDL_Screen);
+
+	/* The Visual struct is supposed to be opaque but we cheat a little */
+	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
+				     dbpp,
+				     dvis->red_mask, dvis->green_mask,
+				     dvis->blue_mask, 0);
+
+	if ( sicon == NULL ) {
+		goto done;
+	}
+	/* If we already have allocated colours from the default colormap,
+	   copy them */
+	if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap
+	   && this->screen->format->palette && sicon->format->palette) {
+	    memcpy(sicon->format->palette->colors,
+		   this->screen->format->palette->colors,
+		   this->screen->format->palette->ncolors * sizeof(SDL_Color));
+	}
+
+	bounds.x = 0;
+	bounds.y = 0;
+	bounds.w = icon->w;
+	bounds.h = icon->h;
+	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 )
+		goto done;
+
+	/* Lock down the colors used in the colormap */
+	color_tried = NULL;
+	if ( sicon->format->BitsPerPixel == 8 ) {
+		SDL_Palette *palette;
+		Uint8 *p;
+		XColor wanted;
+
+		palette = sicon->format->palette;
+		color_tried = malloc(palette->ncolors);
+		if ( color_tried == NULL ) {
+			goto done;
+		}
+		if ( SDL_iconcolors != NULL ) {
+			free(SDL_iconcolors);
+		}
+		SDL_iconcolors = malloc(palette->ncolors
+					* sizeof(*SDL_iconcolors));
+		if ( SDL_iconcolors == NULL ) {
+			free(color_tried);
+			goto done;
+		}
+		memset(color_tried, 0, palette->ncolors);
+		memset(SDL_iconcolors, 0,
+		       palette->ncolors * sizeof(*SDL_iconcolors));
+
+		p = (Uint8 *)sicon->pixels; 
+		for ( i = sicon->w*sicon->h; i > 0; --i, ++p ) {
+			if ( ! color_tried[*p] ) {
+				wanted.pixel = *p;
+				wanted.red   = (palette->colors[*p].r<<8);
+				wanted.green = (palette->colors[*p].g<<8);
+				wanted.blue  = (palette->colors[*p].b<<8);
+				wanted.flags = (DoRed|DoGreen|DoBlue);
+				if (XAllocColor(SDL_Display,
+						SDL_DisplayColormap, &wanted)) {
+					++SDL_iconcolors[wanted.pixel];
+				}
+				color_tried[*p] = 1;
+			}
+		}
+	}
+	if ( color_tried != NULL ) {
+		free(color_tried);
+	}
+
+	/* Translate mask data to LSB order and set the icon mask */
+	i = (sicon->w/8)*sicon->h;
+	LSBmask = (Uint8 *)malloc(i);
+	if ( LSBmask == NULL ) {
+		goto done;
+	}
+	memset(LSBmask, 0, i);
+	while ( --i >= 0 ) {
+		for ( b=0; b<8; ++b )
+			LSBmask[i] |= (((mask[i]>>b)&0x01)<<(7-b));
+	}
+	mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
+					LSBmask, sicon->w, sicon->h, 1L, 0L, 1);
+
+	/* Transfer the image to an X11 pixmap */
+	icon_image = XCreateImage(SDL_Display,
+			DefaultVisual(SDL_Display, SDL_Screen),
+			DefaultDepth(SDL_Display, SDL_Screen),
+			ZPixmap, 0, (char *)sicon->pixels, sicon->w, sicon->h,
+			((sicon->format)->BytesPerPixel == 3) ? 32 :
+				(sicon->format)->BytesPerPixel*8, 0);
+	icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
+			DefaultDepth(SDL_Display, SDL_Screen));
+	GC = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
+	XPutImage(SDL_Display, icon_pixmap, GC, icon_image,
+					0, 0, 0, 0, sicon->w, sicon->h);
+	XFreeGC(SDL_Display, GC);
+	XDestroyImage(icon_image);
+	free(LSBmask);
+	sicon->pixels = NULL;
+
+#ifdef USE_ICON_WINDOW
+	/* Create an icon window and set the pixmap as its background */
+	icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
+					0, 0, sicon->w, sicon->h, 0,
+					CopyFromParent, CopyFromParent);
+	XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap);
+	XClearWindow(SDL_Display, icon_window);
+#endif
+
+	/* Set the window icon to the icon pixmap (and icon window) */
+	wmhints = XAllocWMHints();
+	wmhints->flags = (IconPixmapHint | IconMaskHint);
+	wmhints->icon_pixmap = icon_pixmap;
+	wmhints->icon_mask = mask_pixmap;
+#ifdef USE_ICON_WINDOW
+	wmhints->flags |= IconWindowHint;
+	wmhints->icon_window = icon_window;
+#endif
+	XSetWMHints(SDL_Display, WMwindow, wmhints);
+	XFree(wmhints);
+	XSync(SDL_Display, False);
+
+  done:
+	SDL_Unlock_EventThread();
+	if ( sicon != NULL ) {
+		SDL_FreeSurface(sicon);
+	}
+#endif
+	return;
+}
+
+void CGX_SetCaption(_THIS, const char *title, const char *icon)
+{
+	if(SDL_Window)
+		SetWindowTitles(SDL_Window,(char *)title,NULL);
+}
+
+/* Iconify the window */
+int CGX_IconifyWindow(_THIS)
+{
+#if 0
+	int result;
+
+	SDL_Lock_EventThread();
+	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+	return(result);
+#else
+	return 0;
+#endif
+}
+
+#if 0
+SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
+{
+	int numtries, result;
+
+	if ( this->screen == NULL ) {
+		return(SDL_GRAB_OFF);
+	}
+	if ( ! SDL_Window ) {
+		return(mode);	/* Will be set later on mode switch */
+	}
+	if ( mode == SDL_GRAB_OFF ) {
+		XUngrabPointer(SDL_Display, CurrentTime);
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Rebind the mouse to the fullscreen window */
+			for ( numtries = 0; numtries < 10; ++numtries ) {
+				result = XGrabPointer(SDL_Display, FSwindow,
+						True, 0,
+						GrabModeAsync, GrabModeAsync,
+						FSwindow, None, CurrentTime);
+				if ( result == AlreadyGrabbed ) {
+					break;
+				}
+				SDL_Delay(100);
+			}
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XUngrabKeyboard(SDL_Display, CurrentTime);
+	} else {
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Unbind the mouse from the fullscreen window */
+			XUngrabPointer(SDL_Display, CurrentTime);
+		}
+		/* Try to grab the mouse */
+		for ( numtries = 0; numtries < 10; ++numtries ) {
+			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
+						GrabModeAsync, GrabModeAsync,
+						SDL_Window, None, CurrentTime);
+			if ( result != AlreadyGrabbed ) {
+				break;
+			}
+			SDL_Delay(100);
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XGrabKeyboard(SDL_Display, WMwindow, True,
+			GrabModeAsync, GrabModeAsync, CurrentTime);
+	}
+	XSync(SDL_Display, False);
+
+	return(mode);
+}
+
+SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode)
+{
+	SDL_Lock_EventThread();
+	mode = X11_GrabInputNoLock(this, mode);
+	SDL_Unlock_EventThread();
+
+	return(mode);
+}
+
+/* If 'info' is the right version, this function fills it and returns 1.
+   Otherwise, in case of a version mismatch, it returns -1.
+*/
+static void lock_display(void)
+{
+	SDL_Lock_EventThread();
+}
+static void unlock_display(void)
+{
+	/* Make sure any X11 transactions are completed */
+	SDL_VideoDevice *this = current_video;
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+}
+
+#endif
+
+int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info)
+{
+	if ( info->version.major <= SDL_MAJOR_VERSION ) {
+#if 0
+		info->subsystem = SDL_SYSWM_X11;
+		info->info.x11.display = SDL_Display;
+		info->info.x11.window = SDL_Window;
+		if ( SDL_VERSIONNUM(info->version.major,
+		                    info->version.minor,
+		                    info->version.patch) >= 1002 ) {
+			info->info.x11.fswindow = FSwindow;
+			info->info.x11.wmwindow = WMwindow;
+		}
+		info->info.x11.lock_func = lock_display;
+		info->info.x11.unlock_func = unlock_display;
+#endif
+		return(1);
+	} else {
+		SDL_SetError("Application not compiled with SDL %d.%d\n",
+					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+		return(-1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/cybergfx/SDL_cgxwm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_cgxvideo.h"
+
+/* Functions to be exported */
+extern void CGX_SetCaption(_THIS, const char *title, const char *icon);
+extern void CGX_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
+extern int CGX_IconifyWindow(_THIS);
+extern SDL_GrabMode CGX_GrabInputNoLock(_THIS, SDL_GrabMode mode);
+extern SDL_GrabMode CGX_GrabInput(_THIS, SDL_GrabMode mode);
+extern int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/default_cursor.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,121 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 
+ * Default cursor - it happens to be the Mac cursor, but could be anything   */
+
+#define DEFAULT_CWIDTH	16
+#define DEFAULT_CHEIGHT	16
+#define DEFAULT_CHOTX	0
+#define DEFAULT_CHOTY	0
+
+/* Added a real MacOS cursor, at the request of Luc-Olivier de Charrière */
+#define USE_MACOS_CURSOR
+
+#ifdef USE_MACOS_CURSOR
+
+static unsigned char default_cdata[] =
+{
+ 0x00,0x00,
+ 0x40,0x00,
+ 0x60,0x00,
+ 0x70,0x00,
+ 0x78,0x00,
+ 0x7C,0x00,
+ 0x7E,0x00,
+ 0x7F,0x00,
+ 0x7F,0x80,
+ 0x7C,0x00,
+ 0x6C,0x00,
+ 0x46,0x00,
+ 0x06,0x00,
+ 0x03,0x00,
+ 0x03,0x00,
+ 0x00,0x00
+};
+static unsigned char default_cmask[] =
+{
+ 0xC0,0x00,
+ 0xE0,0x00,
+ 0xF0,0x00,
+ 0xF8,0x00,
+ 0xFC,0x00,
+ 0xFE,0x00,
+ 0xFF,0x00,
+ 0xFF,0x80,
+ 0xFF,0xC0,
+ 0xFF,0xE0,
+ 0xFE,0x00,
+ 0xEF,0x00,
+ 0xCF,0x00,
+ 0x87,0x80,
+ 0x07,0x80,
+ 0x03,0x00
+};
+
+#else
+
+static unsigned char default_cdata[] =
+{
+ 0x00,0x00,
+ 0x40,0x00,
+ 0x60,0x00,
+ 0x70,0x00,
+ 0x78,0x00,
+ 0x7C,0x00,
+ 0x7E,0x00,
+ 0x7F,0x00,
+ 0x7F,0x80,
+ 0x7C,0x00,
+ 0x6C,0x00,
+ 0x46,0x00,
+ 0x06,0x00,
+ 0x03,0x00,
+ 0x03,0x00,
+ 0x00,0x00
+};
+static unsigned char default_cmask[] =
+{
+ 0x40,0x00,
+ 0xE0,0x00,
+ 0xF0,0x00,
+ 0xF8,0x00,
+ 0xFC,0x00,
+ 0xFE,0x00,
+ 0xFF,0x00,
+ 0xFF,0x80,
+ 0xFF,0xC0,
+ 0xFF,0x80,
+ 0xFE,0x00,
+ 0xEF,0x00,
+ 0x4F,0x00,
+ 0x07,0x80,
+ 0x07,0x80,
+ 0x03,0x00
+};
+
+#endif /* TRUE_MACINTOSH_CURSOR */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,14 @@
+
+## Makefile.am for SDL using the DGA 2.0 video driver
+
+noinst_LTLIBRARIES = libvideo_dga.la
+libvideo_dga_la_SOURCES = $(DGA_SRCS)
+
+# The SDL DGA 2.0 video driver sources
+DGA_SRCS = 			\
+	SDL_dgaevents.c		\
+	SDL_dgaevents_c.h	\
+	SDL_dgamouse.c		\
+	SDL_dgamouse_c.h	\
+	SDL_dgavideo.c		\
+	SDL_dgavideo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgaevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,109 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting DGA events into SDL events */
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/xf86dga.h>
+
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_dgavideo.h"
+#include "SDL_dgaevents_c.h"
+
+/* Heheh we're using X11 event code */
+extern int X11_Pending(Display *display);
+extern void X11_InitKeymap(void);
+extern SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey,
+				    KeyCode kc, SDL_keysym *keysym);
+
+static int DGA_DispatchEvent(_THIS)
+{
+	int posted;
+	XDGAEvent xevent;
+
+	XNextEvent(DGA_Display, (XEvent *)&xevent);
+
+	posted = 0;
+	xevent.type -= DGA_event_base;
+	switch (xevent.type) {
+
+	    /* Mouse motion? */
+	    case MotionNotify: {
+		if ( SDL_VideoSurface ) {
+			posted = SDL_PrivateMouseMotion(0, 1,
+					xevent.xmotion.dx, xevent.xmotion.dy);
+		}
+	    }
+	    break;
+
+	    /* Mouse button press? */
+	    case ButtonPress: {
+		posted = SDL_PrivateMouseButton(SDL_PRESSED, 
+					xevent.xbutton.button, 0, 0);
+	    }
+	    break;
+
+	    /* Mouse button release? */
+	    case ButtonRelease: {
+		posted = SDL_PrivateMouseButton(SDL_RELEASED, 
+					xevent.xbutton.button, 0, 0);
+	    }
+	    break;
+
+	    /* Key press or release? */
+	    case KeyPress:
+	    case KeyRelease: {
+		SDL_keysym keysym;
+		XKeyEvent xkey;
+
+		XDGAKeyEventToXKeyEvent(&xevent.xkey, &xkey);
+		posted = SDL_PrivateKeyboard((xevent.type == KeyPress), 
+					X11_TranslateKey(DGA_Display,
+							 &xkey, xkey.keycode,
+							 &keysym));
+	    }
+	    break;
+
+	}
+	return(posted);
+}
+
+void DGA_PumpEvents(_THIS)
+{
+	/* Keep processing pending events */
+	while ( X11_Pending(DGA_Display) ) {
+		DGA_DispatchEvent(this);
+	}
+}
+
+void DGA_InitOSKeymap(_THIS)
+{
+	X11_InitKeymap();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgaevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_dgavideo.h"
+
+/* Functions to be exported */
+extern void DGA_PumpEvents(_THIS);
+extern void DGA_InitOSKeymap(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgamouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_dgavideo.h"
+#include "SDL_dgamouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	int unused;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgamouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_dgavideo.h"
+
+/* Functions to be exported */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgavideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,973 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* DGA 2.0 based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/extensions/xf86dga.h>
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_dgavideo.h"
+#include "SDL_dgamouse_c.h"
+#include "SDL_dgaevents_c.h"
+
+/* Initialization/Query functions */
+static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int DGA_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static int DGA_SetGammaRamp(_THIS, Uint16 *ramp);
+static void DGA_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int DGA_InitHWSurfaces(_THIS, Uint8 *base, int size);
+static void DGA_FreeHWSurfaces(_THIS);
+static int DGA_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
+static int DGA_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
+static int DGA_LockHWSurface(_THIS, SDL_Surface *surface);
+static void DGA_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface);
+static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+/* DGA driver bootstrap functions */
+
+static int DGA_Available(void)
+{
+	const char *display;
+	Display *dpy;
+	int available;
+
+	/* The driver is available is available if the display is local
+	   and the DGA 2.0+ extension is available, and we can map mem.
+	*/
+	available = 0;
+	display = NULL;
+	if ( (strncmp(XDisplayName(display), ":", 1) == 0) ||
+	     (strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
+		dpy = XOpenDisplay(display);
+		if ( dpy ) {
+			int events, errors, major, minor;
+
+			if ( XDGAQueryExtension(dpy, &events, &errors) &&
+			     XDGAQueryVersion(dpy, &major, &minor) ) {
+				int screen;
+
+				screen = DefaultScreen(dpy);
+				if ( (major >= 2) && 
+				     XDGAOpenFramebuffer(dpy, screen) ) {
+					available = 1;
+					XDGACloseFramebuffer(dpy, screen);
+				}
+			}
+			XCloseDisplay(dpy);
+		}
+	}
+	return(available);
+}
+
+static void DGA_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *DGA_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = DGA_VideoInit;
+	device->ListModes = DGA_ListModes;
+	device->SetVideoMode = DGA_SetVideoMode;
+	device->SetColors = DGA_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = DGA_VideoQuit;
+	device->AllocHWSurface = DGA_AllocHWSurface;
+	device->CheckHWBlit = DGA_CheckHWBlit;
+	device->FillHWRect = DGA_FillHWRect;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = DGA_LockHWSurface;
+	device->UnlockHWSurface = DGA_UnlockHWSurface;
+	device->FlipHWSurface = DGA_FlipHWSurface;
+	device->FreeHWSurface = DGA_FreeHWSurface;
+	device->SetGammaRamp = DGA_SetGammaRamp;
+	device->GetGammaRamp = NULL;
+	device->SetCaption = NULL;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->InitOSKeymap = DGA_InitOSKeymap;
+	device->PumpEvents = DGA_PumpEvents;
+
+	device->free = DGA_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap DGA_bootstrap = {
+	"dga", "XFree86 DGA 2.0",
+	DGA_Available, DGA_CreateDevice
+};
+
+static int DGA_AddMode(_THIS, int bpp, int w, int h)
+{
+	SDL_Rect *mode;
+	int i, index;
+	int next_mode;
+
+	/* Check to see if we already have this mode */
+	if ( bpp < 8 ) {  /* Not supported */
+		return(0);
+	}
+	index = ((bpp+7)/8)-1;
+	for ( i=0; i<SDL_nummodes[index]; ++i ) {
+		mode = SDL_modelist[index][i];
+		if ( (mode->w == w) && (mode->h == h) ) {
+			return(0);
+		}
+	}
+
+	/* Set up the new video mode rectangle */
+	mode = (SDL_Rect *)malloc(sizeof *mode);
+	if ( mode == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	mode->x = 0;
+	mode->y = 0;
+	mode->w = w;
+	mode->h = h;
+
+	/* Allocate the new list of modes, and fill in the new mode */
+	next_mode = SDL_nummodes[index];
+	SDL_modelist[index] = (SDL_Rect **)
+	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist[index] == NULL ) {
+		SDL_OutOfMemory();
+		SDL_nummodes[index] = 0;
+		free(mode);
+		return(-1);
+	}
+	SDL_modelist[index][next_mode] = mode;
+	SDL_modelist[index][next_mode+1] = NULL;
+	SDL_nummodes[index]++;
+
+	return(0);
+}
+
+/* This whole function is a hack. :) */
+static Uint32 get_video_size(_THIS)
+{
+	/* This is a non-exported function from libXxf86dga.a */
+	extern unsigned char *XDGAGetMappedMemory(int screen);
+	FILE *proc;
+	unsigned long mem;
+	unsigned start, stop;
+	char line[BUFSIZ];
+	Uint32 size;
+
+	mem = (unsigned long)XDGAGetMappedMemory(DGA_Screen);
+	size = 0;
+	proc = fopen("/proc/self/maps", "r");
+	if ( proc ) {
+		while ( fgets(line, sizeof(line)-1, proc) ) {
+			sscanf(line, "%x-%x", &start, &stop);
+			if ( start == mem ) {
+				size = (Uint32)((stop-start)/1024);
+				break;
+			}
+		}
+		fclose(proc);
+	}
+	return(size);
+}
+
+#ifdef DGA_DEBUG
+static void PrintMode(XDGAMode *mode)
+{
+	printf("Mode: %s (%dx%d) at %d bpp (%f refresh, %d pitch) num: %d\n",
+		mode->name,
+		mode->viewportWidth, mode->viewportHeight,
+		mode->depth == 24 ? mode->bitsPerPixel : mode->depth,
+		mode->verticalRefresh, mode->bytesPerScanline, mode->num);
+	printf("\tRGB: 0x%8.8x 0x%8.8x 0x%8.8x (%d - %s)\n",
+		mode->redMask, mode->greenMask, mode->blueMask,
+		mode->visualClass,
+		mode->visualClass == TrueColor ? "truecolor" :
+		mode->visualClass == DirectColor ? "directcolor" :
+		mode->visualClass == PseudoColor ? "pseudocolor" : "unknown");
+	printf("\tFlags: ");
+	if ( mode->flags & XDGAConcurrentAccess )
+		printf(" XDGAConcurrentAccess");
+	if ( mode->flags & XDGASolidFillRect )
+		printf(" XDGASolidFillRect");
+	if ( mode->flags & XDGABlitRect )
+		printf(" XDGABlitRect");
+	if ( mode->flags & XDGABlitTransRect )
+		printf(" XDGABlitTransRect");
+	if ( mode->flags & XDGAPixmap )
+		printf(" XDGAPixmap");
+	if ( mode->flags & XDGAInterlaced )
+		printf(" XDGAInterlaced");
+	if ( mode->flags & XDGADoublescan )
+		printf(" XDGADoublescan");
+	if ( mode->viewportFlags & XDGAFlipRetrace )
+		printf(" XDGAFlipRetrace");
+	if ( mode->viewportFlags & XDGAFlipImmediate )
+		printf(" XDGAFlipImmediate");
+	printf("\n");
+}
+#endif /* DGA_DEBUG */
+
+static int cmpmodes(const void *va, const void *vb)
+{
+    XDGAMode *a = (XDGAMode *)va;
+    XDGAMode *b = (XDGAMode *)vb;
+
+    /* Prefer DirectColor visuals for otherwise equal modes */
+    if ( (a->viewportWidth == b->viewportWidth) &&
+         (b->viewportHeight == a->viewportHeight) ) {
+         if ( a->visualClass == DirectColor )
+             return -1;
+         if ( b->visualClass == DirectColor )
+             return 1;
+         return 0;
+    } else {
+        if(a->viewportWidth > b->viewportWidth)
+            return -1;
+        return b->viewportHeight - a->viewportHeight;
+    }
+}
+static void UpdateHWInfo(_THIS, XDGAMode *mode)
+{
+	this->info.wm_available = 0;
+	this->info.hw_available = 1;
+	if ( mode->flags & XDGABlitRect ) {
+		this->info.blit_hw = 1;
+	} else {
+		this->info.blit_hw = 0;
+	}
+	if ( mode->flags & XDGABlitTransRect ) {
+		this->info.blit_hw_CC = 1;
+	} else {
+		this->info.blit_hw_CC = 0;
+	}
+	if ( mode->flags & XDGASolidFillRect ) {
+		this->info.blit_fill = 1;
+	} else {
+		this->info.blit_fill = 0;
+	}
+	this->info.video_mem = get_video_size(this);
+}
+
+static int DGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	const char *display;
+	int event_base, error_base;
+	int major_version, minor_version;
+	Visual *visual;
+	XDGAMode *modes;
+	int i, num_modes;
+
+	/* Open the X11 display */
+	display = NULL;		/* Get it from DISPLAY environment variable */
+
+	DGA_Display = XOpenDisplay(display);
+	if ( DGA_Display == NULL ) {
+		SDL_SetError("Couldn't open X11 display");
+		return(-1);
+	}
+
+	/* Check for the DGA extension */
+	if ( ! XDGAQueryExtension(DGA_Display, &event_base, &error_base) ||
+	     ! XDGAQueryVersion(DGA_Display, &major_version, &minor_version) ) {
+		SDL_SetError("DGA extension not available");
+		XCloseDisplay(DGA_Display);
+		return(-1);
+	}
+	if ( major_version < 2 ) {
+		SDL_SetError("DGA driver requires DGA 2.0 or newer");
+		XCloseDisplay(DGA_Display);
+		return(-1);
+	}
+	DGA_event_base = event_base;
+
+	/* Determine the current screen depth */
+	visual = DefaultVisual(DGA_Display, DGA_Screen);
+	{
+		XPixmapFormatValues *pix_format;
+		int i, num_formats;
+
+		vformat->BitsPerPixel = DefaultDepth(DGA_Display, DGA_Screen);
+		pix_format = XListPixmapFormats(DGA_Display, &num_formats);
+		if ( pix_format == NULL ) {
+			SDL_SetError("Couldn't determine screen formats");
+			XCloseDisplay(DGA_Display);
+			return(-1);
+		}
+		for ( i=0; i<num_formats; ++i ) {
+			if ( vformat->BitsPerPixel == pix_format[i].depth )
+				break;
+		}
+		if ( i != num_formats )
+			vformat->BitsPerPixel = pix_format[i].bits_per_pixel;
+		XFree((char *)pix_format);
+	}
+	if ( vformat->BitsPerPixel > 8 ) {
+		vformat->Rmask = visual->red_mask;
+		vformat->Gmask = visual->green_mask;
+		vformat->Bmask = visual->blue_mask;
+	}
+
+	/* Open access to the framebuffer */
+	if ( ! XDGAOpenFramebuffer(DGA_Display, DGA_Screen) ) {
+		SDL_SetError("Unable to map the video memory");
+		XCloseDisplay(DGA_Display);
+		return(-1);
+	}
+
+	/* Query for the list of available video modes */
+	modes = XDGAQueryModes(DGA_Display, DGA_Screen, &num_modes);
+	qsort(modes, num_modes, sizeof *modes, cmpmodes);
+	for ( i=0; i<num_modes; ++i ) {
+#ifdef DGA_DEBUG
+		PrintMode(&modes[i]);
+#endif
+		if ( (modes[i].visualClass == PseudoColor) ||
+		     (modes[i].visualClass == DirectColor) ||
+		     (modes[i].visualClass == TrueColor) ) {
+			DGA_AddMode(this, modes[i].bitsPerPixel,
+			            modes[i].viewportWidth,
+			            modes[i].viewportHeight);
+		}
+	}
+	UpdateHWInfo(this, modes);
+	XFree(modes);
+
+	/* Create the hardware surface lock mutex */
+	hw_lock = SDL_CreateMutex();
+	if ( hw_lock == NULL ) {
+		SDL_SetError("Unable to create lock mutex");
+		DGA_VideoQuit(this);
+		return(-1);
+	}
+
+	/* We're done! */
+	return(0);
+}
+
+SDL_Rect **DGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
+}
+
+/* Various screen update functions available */
+static void DGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *DGA_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	XDGAMode *modes;
+	int i, num_modes;
+	XDGADevice *mode;
+	int screen_len;
+	Uint8 *surfaces_mem;
+	int surfaces_len;
+
+	/* Free any previous colormap */
+	if ( DGA_colormap ) {
+		XFreeColormap(DGA_Display, DGA_colormap);
+		DGA_colormap = 0;
+	}
+
+	/* Search for a matching video mode */
+	modes = XDGAQueryModes(DGA_Display, DGA_Screen, &num_modes);
+	qsort(modes, num_modes, sizeof *modes, cmpmodes);
+	for ( i=0; i<num_modes; ++i ) {
+		int depth;
+
+		
+		depth = modes[i].depth;
+		if ( depth == 24 ) { /* Distinguish between 24 and 32 bpp */
+			depth = modes[i].bitsPerPixel;
+		}
+		if ( (depth == bpp) &&
+		     (modes[i].viewportWidth == width) &&
+		     (modes[i].viewportHeight == height) &&
+		     ((modes[i].visualClass == PseudoColor) ||
+		      (modes[i].visualClass == DirectColor) ||
+		      (modes[i].visualClass == TrueColor)) ) {
+			break;
+		}
+	}
+	if ( i == num_modes ) {
+		SDL_SetError("No matching video mode found");
+		return(NULL);
+	}
+
+	/* Set the video mode */
+	mode = XDGASetMode(DGA_Display, DGA_Screen, modes[i].num);
+	XFree(modes);
+	if ( mode == NULL ) {
+		SDL_SetError("Unable to switch to requested mode");
+		return(NULL);
+	}
+	DGA_visualClass = modes[i].visualClass;
+	memory_base = (Uint8 *)mode->data;
+	memory_pitch = mode->mode.bytesPerScanline;
+
+	/* Set up the new mode framebuffer */
+	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
+	current->w = mode->mode.viewportWidth;
+	current->h = mode->mode.viewportHeight;
+	current->pitch = memory_pitch;
+	current->pixels = memory_base;
+	if ( ! SDL_ReallocFormat(current, mode->mode.bitsPerPixel,
+	                                  mode->mode.redMask,
+	                                  mode->mode.greenMask,
+	                                  mode->mode.blueMask, 0) ) {
+		return(NULL);
+	}
+	screen_len = current->h*current->pitch;
+
+	/* Create a colormap if necessary */
+	if ( (DGA_visualClass == PseudoColor) ||
+             (DGA_visualClass == DirectColor) ) {
+		DGA_colormap = XDGACreateColormap(DGA_Display, DGA_Screen,
+							mode, AllocAll);
+		if ( DGA_visualClass == PseudoColor ) {
+			current->flags |= SDL_HWPALETTE;
+		} else {
+	    		/* Initialize the colormap to the identity mapping */
+	    		SDL_GetGammaRamp(0, 0, 0);
+	    		this->screen = current;
+	    		DGA_SetGammaRamp(this, this->gamma);
+			this->screen = NULL;
+		}
+	} else {
+		DGA_colormap = XDGACreateColormap(DGA_Display, DGA_Screen,
+							mode, AllocNone);
+	}
+	XDGAInstallColormap(DGA_Display, DGA_Screen, DGA_colormap);
+
+	/* Update the hardware capabilities */
+	UpdateHWInfo(this, &mode->mode);
+
+	/* Set up the information for hardware surfaces */
+	surfaces_mem = (Uint8 *)current->pixels + screen_len;
+	surfaces_len = (mode->mode.imageHeight*current->pitch - screen_len);
+
+	/* Update for double-buffering, if we can */
+	XDGASetViewport(DGA_Display, DGA_Screen, 0, 0, XDGAFlipRetrace);
+	if ( flags & SDL_DOUBLEBUF ) {
+		if ( mode->mode.imageHeight >= (current->h*2) ) {
+			current->flags |= SDL_DOUBLEBUF;
+			flip_page = 0;
+			flip_yoffset[0] = 0;
+			flip_yoffset[1] = current->h;
+			flip_address[0] = memory_base;
+			flip_address[1] = memory_base+screen_len;
+			surfaces_mem += screen_len;
+			surfaces_len -= screen_len;
+			DGA_FlipHWSurface(this, current);
+		}
+	}
+
+	/* Allocate memory tracking for hardware surfaces */
+	DGA_FreeHWSurfaces(this);
+	if ( surfaces_len < 0 ) {
+		surfaces_len = 0;
+	}
+	DGA_InitHWSurfaces(this, surfaces_mem, surfaces_len);
+
+	/* Set the update rectangle function */
+	this->UpdateRects = DGA_DirectUpdate;
+
+	/* Enable mouse and keyboard support */
+	{ long input_mask;
+	  input_mask = (KeyPressMask | KeyReleaseMask);
+	  input_mask |= (ButtonPressMask | ButtonReleaseMask);
+	  input_mask |= PointerMotionMask;
+	  XDGASelectInput(DGA_Display, DGA_Screen, input_mask);
+	}
+
+	/* We're done */
+	return(current);
+}
+
+#ifdef DGA_DEBUG
+static void DGA_DumpHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket;
+
+	printf("Memory left: %d (%d total)\n", surfaces_memleft, surfaces_memtotal);
+	printf("\n");
+	printf("         Base  Size\n");
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		printf("Bucket:  %p, %d (%s)\n", bucket->base, bucket->size, bucket->used ? "used" : "free");
+		if ( bucket->prev ) {
+			if ( bucket->base != bucket->prev->base+bucket->prev->size ) {
+				printf("Warning, corrupt bucket list! (prev)\n");
+			}
+		} else {
+			if ( bucket != &surfaces ) {
+				printf("Warning, corrupt bucket list! (!prev)\n");
+			}
+		}
+		if ( bucket->next ) {
+			if ( bucket->next->base != bucket->base+bucket->size ) {
+				printf("Warning, corrupt bucket list! (next)\n");
+			}
+		}
+	}
+	printf("\n");
+}
+#endif
+
+static int DGA_InitHWSurfaces(_THIS, Uint8 *base, int size)
+{
+	surfaces.prev = NULL;
+	surfaces.used = 0;
+	surfaces.base = base;
+	surfaces.size = size;
+	surfaces.next = NULL;
+	surfaces_memtotal = size;
+	surfaces_memleft = size;
+	return(0);
+}
+static void DGA_FreeHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	bucket = surfaces.next;
+	while ( bucket ) {
+		freeable = bucket;
+		bucket = bucket->next;
+		free(freeable);
+	}
+	surfaces.next = NULL;
+}
+
+static int DGA_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket;
+	int size;
+	int extra;
+
+/* Temporarily, we only allow surfaces the same width as display.
+   Some blitters require the pitch between two hardware surfaces
+   to be the same.  Others have interesting alignment restrictions.
+*/
+if ( surface->pitch > SDL_VideoSurface->pitch ) {
+	SDL_SetError("Surface requested wider than screen");
+	return(-1);
+}
+surface->pitch = SDL_VideoSurface->pitch;
+	size = surface->h * surface->pitch;
+#ifdef DGA_DEBUG
+	fprintf(stderr, "Allocating bucket of %d bytes\n", size);
+#endif
+
+	/* Quick check for available mem */
+	if ( size > surfaces_memleft ) {
+		SDL_SetError("Not enough video memory");
+		return(-1);
+	}
+
+	/* Search for an empty bucket big enough */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( ! bucket->used && (size <= bucket->size) ) {
+			break;
+		}
+	}
+	if ( bucket == NULL ) {
+		SDL_SetError("Video memory too fragmented");
+		return(-1);
+	}
+
+	/* Create a new bucket for left-over memory */
+	extra = (bucket->size - size);
+	if ( extra ) {
+		vidmem_bucket *newbucket;
+
+#ifdef DGA_DEBUG
+	fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
+#endif
+		newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket));
+		if ( newbucket == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		newbucket->prev = bucket;
+		newbucket->used = 0;
+		newbucket->base = bucket->base+size;
+		newbucket->size = extra;
+		newbucket->next = bucket->next;
+		if ( bucket->next ) {
+			bucket->next->prev = newbucket;
+		}
+		bucket->next = newbucket;
+	}
+
+	/* Set the current bucket values and return it! */
+	bucket->used = 1;
+	bucket->size = size;
+#ifdef DGA_DEBUG
+	fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
+#endif
+	surfaces_memleft -= size;
+	surface->flags |= SDL_HWSURFACE;
+	surface->pixels = bucket->base;
+	return(0);
+}
+static void DGA_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	/* Look for the bucket in the current list */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( bucket->base == (Uint8 *)surface->pixels ) {
+			break;
+		}
+	}
+	if ( (bucket == NULL) || ! bucket->used ) {
+		return;
+	}
+
+	/* Add the memory back to the total */
+#ifdef DGA_DEBUG
+	printf("Freeing bucket of %d bytes\n", bucket->size);
+#endif
+	surfaces_memleft += bucket->size;
+
+	/* Can we merge the space with surrounding buckets? */
+	bucket->used = 0;
+	if ( bucket->next && ! bucket->next->used ) {
+#ifdef DGA_DEBUG
+	printf("Merging with next bucket, for %d total bytes\n", bucket->size+bucket->next->size);
+#endif
+		freeable = bucket->next;
+		bucket->size += bucket->next->size;
+		bucket->next = bucket->next->next;
+		if ( bucket->next ) {
+			bucket->next->prev = bucket;
+		}
+		free(freeable);
+	}
+	if ( bucket->prev && ! bucket->prev->used ) {
+#ifdef DGA_DEBUG
+	printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size);
+#endif
+		freeable = bucket;
+		bucket->prev->size += bucket->size;
+		bucket->prev->next = bucket->next;
+		if ( bucket->next ) {
+			bucket->next->prev = bucket->prev;
+		}
+		free(freeable);
+	}
+	surface->pixels = NULL;
+}
+
+static __inline__ void dst_to_xy(_THIS, SDL_Surface *dst, int *x, int *y)
+{
+	*x = (long)((Uint8 *)dst->pixels - memory_base)%memory_pitch;
+	*y = (long)((Uint8 *)dst->pixels - memory_base)/memory_pitch;
+	if ( dst == this->screen ) {
+		*x += this->offset_x;
+		*y += this->offset_y;
+	}
+}
+
+static int DGA_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
+{
+	int x, y;
+	unsigned int w, h;
+
+	/* Don't fill the visible part of the screen, wait until flipped */
+	if ( was_flipped && (dst == this->screen) ) {
+		while ( XDGAGetViewportStatus(DGA_Display, DGA_Screen) )
+			/* Keep waiting for the hardware ... */ ;
+		was_flipped = 0;
+	}
+	dst_to_xy(this, dst, &x, &y);
+	x += rect->x;
+	y += rect->y;
+	w = rect->w;
+	h = rect->h;
+#if 0
+  printf("Hardware accelerated rectangle fill: %dx%d at %d,%d\n", w, h, x, y);
+#endif
+	XDGAFillRectangle(DGA_Display, DGA_Screen, x, y, w, h, color);
+	sync_needed++;
+	XFlush(DGA_Display);
+	return(0);
+}
+
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	SDL_VideoDevice *this;
+	int srcx, srcy;
+	int dstx, dsty;
+	unsigned int w, h;
+
+	this = current_video;
+	/* Don't blit to the visible part of the screen, wait until flipped */
+	if ( was_flipped && (dst == this->screen) ) {
+		while ( XDGAGetViewportStatus(DGA_Display, DGA_Screen) )
+			/* Keep waiting for the hardware ... */ ;
+		was_flipped = 0;
+	}
+	dst_to_xy(this, src, &srcx, &srcy);
+	srcx += srcrect->x;
+	srcy += srcrect->y;
+	dst_to_xy(this, dst, &dstx, &dsty);
+	dstx += dstrect->x;
+	dsty += dstrect->y;
+	w = srcrect->w;
+	h = srcrect->h;
+#if 0
+  printf("Blitting %dx%d from %d,%d to %d,%d\n", w, h, srcx, srcy, dstx, dsty);
+#endif
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		XDGACopyTransparentArea(DGA_Display, DGA_Screen,
+			srcx, srcy, w, h, dstx, dsty, src->format->colorkey);
+	} else {
+		XDGACopyArea(DGA_Display, DGA_Screen,
+			srcx, srcy, w, h, dstx, dsty);
+	}
+	sync_needed++;
+	XFlush(DGA_Display);
+	return(0);
+}
+
+static int DGA_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+	int accelerated;
+
+	/* Set initial acceleration on */
+	src->flags |= SDL_HWACCEL;
+
+	/* Set the surface attributes */
+	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		if ( ! this->info.blit_hw_A ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		if ( ! this->info.blit_hw_CC ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+
+	/* Check to see if final surface blit is accelerated */
+	accelerated = !!(src->flags & SDL_HWACCEL);
+	if ( accelerated ) {
+		src->map->hw_blit = HWAccelBlit;
+	}
+	return(accelerated);
+}
+
+static __inline__ void DGA_WaitHardware(_THIS)
+{
+	if ( sync_needed ) {
+		XDGASync(DGA_Display, DGA_Screen);
+		sync_needed = 0;
+	}
+	if ( was_flipped ) {
+		while ( XDGAGetViewportStatus(DGA_Display, DGA_Screen) )
+			/* Keep waiting for the hardware ... */ ;
+		was_flipped = 0;
+	}
+}
+
+static int DGA_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		SDL_mutexP(hw_lock);
+		DGA_WaitHardware(this);
+	}
+	return(0);
+}
+static void DGA_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		SDL_mutexV(hw_lock);
+	}
+}
+
+static int DGA_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	/* Wait for vertical retrace and then flip display */
+	DGA_WaitHardware(this);
+	XDGASetViewport(DGA_Display, DGA_Screen,
+	                0, flip_yoffset[flip_page], XDGAFlipRetrace);
+	XFlush(DGA_Display);
+	was_flipped = 1;
+	flip_page = !flip_page;
+
+	surface->pixels = flip_address[flip_page];
+	return(0);
+}
+
+static void DGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	/* The application is already updating the visible video memory */
+	return;
+}
+
+static int DGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+        int i;
+	XColor  *xcmap;
+
+	/* This happens on initialization */
+	if ( ! DGA_colormap ) {
+		return(0);
+	}
+	xcmap = (XColor *)alloca(ncolors*sizeof(*xcmap));
+	for ( i=0; i<ncolors; ++i ) {
+		xcmap[i].pixel = firstcolor + i;
+		xcmap[i].red   = (colors[i].r<<8)|colors[i].r;
+		xcmap[i].green = (colors[i].g<<8)|colors[i].g;
+		xcmap[i].blue  = (colors[i].b<<8)|colors[i].b;
+		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
+	}
+	XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
+	XSync(DGA_Display, False);
+
+	/* That was easy. :) */
+	return(1);
+}
+
+int DGA_SetGammaRamp(_THIS, Uint16 *ramp)
+{
+	int i, ncolors;
+	XColor xcmap[256];
+
+	/* See if actually setting the gamma is supported */
+	if ( DGA_visualClass != DirectColor ) {
+	    SDL_SetError("Gamma correction not supported on this visual");
+	    return(-1);
+	}
+
+	/* Calculate the appropriate palette for the given gamma ramp */
+	if ( this->screen->format->BitsPerPixel <= 16 ) {
+		ncolors = 64; /* Is this right? */
+	} else {
+		ncolors = 256;
+	}
+	for ( i=0; i<ncolors; ++i ) {
+		Uint8 c = (256 * i / ncolors);
+		xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
+		xcmap[i].red   = ramp[0*256+c];
+		xcmap[i].green = ramp[1*256+c];
+		xcmap[i].blue  = ramp[2*256+c];
+		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
+	}
+	XStoreColors(DGA_Display, DGA_colormap, xcmap, ncolors);
+	XSync(DGA_Display, False);
+	return(0);
+}
+
+void DGA_VideoQuit(_THIS)
+{
+	int i, j;
+
+	if ( DGA_Display ) {
+		/* Free colormap, if necessary */
+		if ( DGA_colormap ) {
+			XFreeColormap(DGA_Display, DGA_colormap);
+			DGA_colormap = 0;
+		}
+
+		/* Unmap memory and reset video mode */
+		XDGACloseFramebuffer(DGA_Display, DGA_Screen);
+		if ( this->screen ) {
+			/* Tell SDL not to free the pixels */
+			this->screen->pixels = NULL;
+		}
+		XDGASetMode(DGA_Display, DGA_Screen, 0);
+
+		/* Clear the lock mutex */
+		if ( hw_lock != NULL ) {
+			SDL_DestroyMutex(hw_lock);
+			hw_lock = NULL;
+		}
+
+		/* Clean up defined video modes */
+		for ( i=0; i<NUM_MODELISTS; ++i ) {
+			if ( SDL_modelist[i] != NULL ) {
+				for ( j=0; SDL_modelist[i][j]; ++j ) {
+					free(SDL_modelist[i][j]);
+				}
+				free(SDL_modelist[i]);
+				SDL_modelist[i] = NULL;
+			}
+		}
+
+		/* Clean up the memory bucket list */
+		DGA_FreeHWSurfaces(this);
+
+		/* Close up the display */
+		XCloseDisplay(DGA_Display);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/dga/SDL_dgavideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,106 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dgavideo_h
+#define _SDL_dgavideo_h
+
+#include <X11/Xlib.h>
+
+#include "SDL_mouse.h"
+#include "SDL_mutex.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+
+/* This is the structure we use to keep track of video memory */
+typedef struct vidmem_bucket {
+	struct vidmem_bucket *prev;
+	unsigned int used;
+	Uint8 *base;
+	unsigned int size;
+	struct vidmem_bucket *next;
+} vidmem_bucket;
+
+/* Information about the location of the surface in hardware memory */
+struct private_hwdata {
+	int x;
+	int y;
+};
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+	Display *DGA_Display;
+	Colormap DGA_colormap;
+	int visualClass;
+
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+	int SDL_nummodes[NUM_MODELISTS];
+	SDL_Rect **SDL_modelist[NUM_MODELISTS];
+
+	/* Information for the video surface */
+	Uint8 *memory_base;
+	int memory_pitch;
+	SDL_mutex *hw_lock;
+	int sync_needed;
+	int was_flipped;
+
+	/* Information for hardware surfaces */
+	vidmem_bucket surfaces;
+	int surfaces_memtotal;
+	int surfaces_memleft;
+
+	/* Information for double-buffering */
+	int flip_page;
+	int flip_yoffset[2];
+	Uint8 *flip_address[2];
+
+	/* Used to handle DGA events */
+	int event_base;
+};
+/* Old variable names */
+#define DGA_Display		(this->hidden->DGA_Display)
+#define DGA_Screen		DefaultScreen(DGA_Display)
+#define DGA_colormap		(this->hidden->DGA_colormap)
+#define DGA_visualClass		(this->hidden->visualClass)
+#define memory_base		(this->hidden->memory_base)
+#define memory_pitch		(this->hidden->memory_pitch)
+#define flip_page		(this->hidden->flip_page)
+#define flip_yoffset		(this->hidden->flip_yoffset)
+#define flip_address		(this->hidden->flip_address)
+#define sync_needed		(this->hidden->sync_needed)
+#define was_flipped		(this->hidden->was_flipped)
+#define SDL_nummodes		(this->hidden->SDL_nummodes)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define surfaces		(this->hidden->surfaces)
+#define surfaces_memtotal	(this->hidden->surfaces_memtotal)
+#define surfaces_memleft	(this->hidden->surfaces_memleft)
+#define hw_lock			(this->hidden->hw_lock)
+#define DGA_event_base		(this->hidden->event_base)
+
+#endif /* _SDL_dgavideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/3dfx_mmio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,60 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* 3Dfx register definitions */
+
+#include "3dfx_regs.h"
+
+/* 3Dfx control macros */
+
+#define tdfx_in8(reg)		*(volatile Uint8  *)(mapped_io + (reg))
+#define tdfx_in32(reg)		*(volatile Uint32 *)(mapped_io + (reg))
+
+#define tdfx_out8(reg,v)	*(volatile Uint8  *)(mapped_io + (reg)) = v;
+#define tdfx_out32(reg,v)	*(volatile Uint32 *)(mapped_io + (reg)) = v;
+
+
+/* Wait for fifo space */
+#define tdfx_wait(space)						\
+{									\
+	while ( (tdfx_in8(TDFX_STATUS) & 0x1F) < space )		\
+		;							\
+}
+
+
+/* Wait for idle accelerator */
+#define tdfx_waitidle()							\
+{									\
+	int i = 0;							\
+									\
+	tdfx_wait(1);							\
+	tdfx_out32(COMMAND_3D, COMMAND_3D_NOP);				\
+	do {								\
+		i = (tdfx_in32(TDFX_STATUS) & STATUS_BUSY) ? 0 : i + 1;	\
+	} while ( i != 3 );						\
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/3dfx_regs.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,87 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _3DFX_REGS_H
+#define _3DFX_REGS_H
+
+/* This information comes from the public 3Dfx specs for the Voodoo 3000 */
+
+/* mapped_io register offsets */
+#define TDFX_STATUS	0x00
+
+#define INTCTRL		(0x00100000 + 0x04)
+#define CLIP0MIN	(0x00100000 + 0x08)
+#define CLIP0MAX	(0x00100000 + 0x0c)
+#define DSTBASE		(0x00100000 + 0x10)
+#define DSTFORMAT	(0x00100000 + 0x14)
+#define SRCCOLORKEYMIN	(0x00100000 + 0x18)
+#define SRCCOLORKEYMAX	(0x00100000 + 0x1c)
+#define DSTCOLORKEYMIN	(0x00100000 + 0x20)
+#define DSTCOLORKEYMAX	(0x00100000 + 0x24)
+#define BRESERROR0	(0x00100000 + 0x28)
+#define BRESERROR1	(0x00100000 + 0x2c)
+#define ROP_2D		(0x00100000 + 0x30)
+#define SRCBASE		(0x00100000 + 0x34)
+#define COMMANDEXTRA_2D	(0x00100000 + 0x38)
+#define PATTERN0	(0x00100000 + 0x44)
+#define PATTERN1	(0x00100000 + 0x48)
+#define CLIP1MIN	(0x00100000 + 0x4c)
+#define CLIP1MAX	(0x00100000 + 0x50)
+#define SRCFORMAT	(0x00100000 + 0x54)
+#define SRCSIZE		(0x00100000 + 0x58)
+#define SRCXY		(0x00100000 + 0x5c)
+#define COLORBACK	(0x00100000 + 0x60)
+#define COLORFORE	(0x00100000 + 0x64)
+#define DSTSIZE		(0x00100000 + 0x68)
+#define DSTXY		(0x00100000 + 0x6c)
+#define COMMAND_2D	(0x00100000 + 0x70)
+#define LAUNCH_2D	(0x00100000 + 0x80)
+#define PATTERNBASE	(0x00100000 + 0x100)
+
+#define COMMAND_3D	(0x00200000 + 0x120)
+
+/* register bitfields (not all, only as needed) */
+
+#define BIT(x) (1UL << (x))
+
+#define COMMAND_2D_BITBLT		0x01
+#define COMMAND_2D_FILLRECT		0x05
+#define COMMAND_2D_LINE			0x06
+#define COMMAND_2D_POLYGON_FILL		0x08
+#define COMMAND_2D_INITIATE		BIT(8)
+#define COMMAND_2D_REVERSELINE		BIT(9)
+#define COMMAND_2D_STIPPLELINE		BIT(12)
+#define COMMAND_2D_MONOCHROME_PATT	BIT(13)
+#define COMMAND_2D_MONOCHROME_TRANSP    BIT(16)
+
+#define COMMAND_3D_NOP			0x00
+
+#define STATUS_RETRACE			BIT(6)
+#define STATUS_BUSY			BIT(9)
+
+#endif /* _3DFX_REGS_H */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,25 @@
+
+## Makefile.am for SDL using the framebuffer console video driver
+
+noinst_LTLIBRARIES = libvideo_fbcon.la
+libvideo_fbcon_la_SOURCES = $(FBCON_SRCS)
+
+# The SDL framebuffer console video driver sources
+FBCON_SRCS = 			\
+	SDL_fbkeys.h		\
+	SDL_fbvideo.h		\
+	SDL_fbelo.c \
+	SDL_fbelo.h \
+	SDL_fbevents.c		\
+	SDL_fbevents_c.h	\
+	SDL_fb3dfx.c		\
+	SDL_fb3dfx.h		\
+	SDL_fbmatrox.c		\
+	SDL_fbmatrox.h		\
+	SDL_fbmouse.c		\
+	SDL_fbmouse_c.h		\
+	SDL_fbvideo.c		\
+	3dfx_mmio.h		\
+	3dfx_regs.h		\
+	matrox_mmio.h		\
+	matrox_regs.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fb3dfx.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,204 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_fb3dfx.h"
+#include "3dfx_mmio.h"
+
+
+static int LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		tdfx_waitidle();
+	}
+	return(0);
+}
+static void UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* Wait for vertical retrace */
+static void WaitVBL(_THIS)
+{
+	/* find start of retrace */
+	tdfx_waitidle();
+	while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE )
+		;
+	/* wait until we're past the start */
+	while( (tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0 )
+		; 
+}
+
+/* Sets video mem colorkey and accelerated blit function */
+static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+	return(0);
+}
+
+static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
+{
+	int bpp;
+	char *dst_base;
+	Uint32 format;
+	int dstX, dstY;
+
+	/* Set the destination pixel format */
+	dst_base = (char *)((char *)dst->pixels - mapped_mem);
+	bpp = dst->format->BitsPerPixel;
+	format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
+
+	/* Calculate source and destination base coordinates */
+	dstX = rect->x;
+	dstY = rect->y;
+
+	/* Execute the fill command */
+	tdfx_wait(6);
+	tdfx_out32(DSTBASE, (Uint32)dst_base);
+	tdfx_out32(DSTFORMAT, format);
+	tdfx_out32(COLORFORE, color);
+	tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT);
+	tdfx_out32(DSTSIZE, rect->w | (rect->h << 16));
+	tdfx_out32(LAUNCH_2D, dstX | (dstY << 16));
+	return(0);
+}
+
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	SDL_VideoDevice *this;
+	int bpp;
+	Uint32 src_format;
+	Uint32 dst_format;
+	char *src_base;
+	char *dst_base;
+	int srcX, srcY;
+	int dstX, dstY;
+	Uint32 blitop;
+	Uint32 use_colorkey;
+
+	/* Set the source and destination pixel format */
+	this = current_video;
+	src_base = (char *)((char *)src->pixels - mapped_mem);
+	bpp = src->format->BitsPerPixel;
+	src_format = src->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
+	dst_base = (char *)((char *)dst->pixels - mapped_mem);
+	bpp = dst->format->BitsPerPixel;
+	dst_format = dst->pitch | ((bpp+((bpp==8) ? 0 : 8)) << 13);
+
+	srcX = srcrect->x;
+	srcY = srcrect->y;
+	dstX = dstrect->x;
+	dstY = dstrect->y;
+
+	/* Assemble the blit operation */
+	blitop = COMMAND_2D_BITBLT | (0xCC << 24);
+	if ( srcX <= dstX ) {
+		blitop |= BIT(14);
+		srcX += (dstrect->w - 1);
+		dstX += (dstrect->w - 1);
+	}
+	if ( srcY <= dstY ) {
+		blitop |= BIT(15);
+		srcY += (dstrect->h - 1);
+		dstY += (dstrect->h - 1);
+	}
+
+	/* Perform the blit! */
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+    		tdfx_wait(3);
+    		tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey);
+    		tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey);
+    		tdfx_out32(ROP_2D, 0xAA00);
+		use_colorkey = 1;
+	} else {
+		use_colorkey = 0;
+	}
+	tdfx_wait(9);
+	tdfx_out32(SRCBASE, (Uint32)src_base);
+	tdfx_out32(SRCFORMAT, src_format);
+	tdfx_out32(DSTBASE, (Uint32)dst_base);
+	tdfx_out32(DSTFORMAT, src_format);
+	tdfx_out32(COMMAND_2D, blitop);
+	tdfx_out32(COMMANDEXTRA_2D, use_colorkey);
+	tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16));
+	tdfx_out32(DSTXY, dstX | (dstY << 16));
+	tdfx_out32(LAUNCH_2D, srcX | (srcY << 16));
+
+	return(0);
+}
+
+static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+	int accelerated;
+
+	/* Set initial acceleration on */
+	src->flags |= SDL_HWACCEL;
+
+	/* Set the surface attributes */
+	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		if ( ! this->info.blit_hw_A ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		if ( ! this->info.blit_hw_CC ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+
+	/* Check to see if final surface blit is accelerated */
+	accelerated = !!(src->flags & SDL_HWACCEL);
+	if ( accelerated ) {
+		src->map->hw_blit = HWAccelBlit;
+	}
+	return(accelerated);
+}
+
+void FB_3DfxAccel(_THIS, __u32 card)
+{
+	/* We have hardware accelerated surface functions */
+	this->CheckHWBlit = CheckHWBlit;
+	this->LockHWSurface = LockHWSurface;
+	this->UnlockHWSurface = UnlockHWSurface;
+	wait_vbl = WaitVBL;
+
+	/* Reset the 3Dfx controller */
+	tdfx_out32(BRESERROR0, 0);
+	tdfx_out32(BRESERROR1, 0);
+
+	/* The 3Dfx has an accelerated color fill */
+	this->info.blit_fill = 1;
+	this->FillHWRect = FillHWRect;
+
+	/* The 3Dfx has accelerated normal and colorkey blits */
+	this->info.blit_hw = 1;
+	this->info.blit_hw_CC = 1;
+	this->SetHWColorKey = SetHWColorKey;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fb3dfx.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* 3Dfx hardware acceleration for the SDL framebuffer console driver */
+
+#include "SDL_fbvideo.h"
+
+/* Set up the driver for 3Dfx acceleration */
+extern void FB_3DfxAccel(_THIS, __u32 card);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbelo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,423 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/time.h>
+#include <ctype.h>
+
+#include "SDL_fbvideo.h"
+#include "SDL_fbelo.h"
+
+/*
+	calibration default values
+	values are read from the following environment variables:
+
+	SDL_ELO_MIN_X
+	SDL_ELO_MAX_X
+	SDL_ELO_MIN_Y
+	SDL_ELO_MAX_Y
+*/
+
+static int ELO_MIN_X = 400;
+static int ELO_MAX_X = 3670;
+static int ELO_MIN_Y = 500;
+static int ELO_MAX_Y = 3540;
+
+#define ELO_SNAP_SIZE 6
+#define ELO_TOUCH_BYTE		'T'	
+#define ELO_ID			'I'
+#define ELO_MODE		'M'
+#define ELO_PARAMETER		'P'
+#define ELO_REPORT		'B'
+#define ELO_ACK			'A'	
+
+#define ELO_INIT_CHECKSUM	0xAA
+
+#define ELO_BTN_PRESS		0x01	
+#define ELO_STREAM		0x02
+#define ELO_BTN_RELEASE		0x04
+
+#define ELO_TOUCH_MODE		0x01
+#define ELO_STREAM_MODE		0x02
+#define ELO_UNTOUCH_MODE	0x04
+#define ELO_RANGE_CHECK_MODE	0x40
+#define ELO_TRIM_MODE		0x02
+#define ELO_CALIB_MODE		0x04
+#define ELO_SCALING_MODE	0x08
+#define ELO_TRACKING_MODE	0x40
+
+#define ELO_SERIAL_MASK		0xF8
+
+#define ELO_SERIAL_IO		'0'
+
+#define ELO_MAX_TRIALS	3
+#define ELO_MAX_WAIT		100000
+#define ELO_UNTOUCH_DELAY	5
+#define ELO_REPORT_DELAY	1
+
+/*	eloParsePacket
+*/
+int eloParsePacket(unsigned char* mousebuf, int* dx, int* dy, int* button_state) {
+	static int elo_button = 0;
+	static int last_x = 0;
+	static int last_y = 0;
+	int x,y;
+
+	/* Check if we have a touch packet */
+	if (mousebuf[1] != ELO_TOUCH_BYTE) {
+		return 0;
+	}
+
+	x = ((mousebuf[4] << 8) | mousebuf[3]);
+	y = ((mousebuf[6] << 8) | mousebuf[5]);
+
+	if((abs(x - last_x) > ELO_SNAP_SIZE) || (abs(y - last_y) > ELO_SNAP_SIZE)) {
+		*dx = ((mousebuf[4] << 8) | mousebuf[3]);
+		*dy = ((mousebuf[6] << 8) | mousebuf[5]);
+	}
+	else {
+		*dx = last_x;
+		*dy = last_y;
+	}
+
+	last_x = *dx;
+	last_y = *dy;
+
+	if ( (mousebuf[2] & 0x07) == ELO_BTN_PRESS ) {
+		elo_button = 1;
+	}
+	if ( (mousebuf[2] & 0x07) == ELO_BTN_RELEASE ) {
+		elo_button = 0;
+	}
+
+	*button_state = elo_button;
+	return 1;
+}
+
+/*	Convert the raw coordinates from the ELO controller
+	to a screen position.
+*/
+void eloConvertXY(_THIS, int *dx,  int *dy) {
+	int input_x = *dx;
+	int input_y = *dy;
+	int width = ELO_MAX_X - ELO_MIN_X;
+	int height = ELO_MAX_Y - ELO_MIN_Y;
+
+	*dx = (cache_vinfo.xres - (cache_vinfo.xres * (input_x - ELO_MIN_X)) / width);
+	*dy = (cache_vinfo.yres * (input_y - ELO_MIN_Y)) / height;
+}
+
+
+/*	eloGetPacket
+*/
+int eloGetPacket(unsigned char* buffer, int* buffer_p, int* checksum, int fd) {
+	int num_bytes;
+	int ok;
+
+	if(fd == 0) {
+		num_bytes = ELO_PACKET_SIZE;
+	}
+	else {
+		num_bytes = read(fd,
+			(char *) (buffer + *buffer_p),
+			ELO_PACKET_SIZE - *buffer_p);
+	}
+
+	if (num_bytes < 0) {
+#ifdef DEBUG_MOUSE
+		fprintf(stderr, "System error while reading from Elographics touchscreen.\n");
+#endif
+		return 0;
+	}
+
+	while (num_bytes) {
+		if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) {
+			memcpy(&buffer[0], &buffer[1], num_bytes-1);
+		}
+		else {
+			if (*buffer_p < ELO_PACKET_SIZE-1) {
+				*checksum = *checksum + buffer[*buffer_p];
+				*checksum = *checksum % 256;
+			}
+			(*buffer_p)++;
+		}
+		num_bytes--;
+	}
+
+	if (*buffer_p == ELO_PACKET_SIZE) {
+		ok = (*checksum == buffer[ELO_PACKET_SIZE-1]);
+		*checksum = ELO_INIT_CHECKSUM;
+		*buffer_p = 0;
+
+		if (!ok) {
+			return 0;
+		}
+
+		return 1;
+	}
+	else {
+		return 0;
+	}
+}
+
+/* eloSendPacket
+*/
+
+int eloSendPacket(unsigned char* packet, int fd)
+{
+	int i, result;
+	int sum = ELO_INIT_CHECKSUM;
+
+	packet[0] = ELO_START_BYTE;
+	for (i = 0; i < ELO_PACKET_SIZE-1; i++) {
+		sum += packet[i];
+		sum &= 0xFF;
+	}
+	packet[ELO_PACKET_SIZE-1] = sum;
+
+	result = write(fd, packet, ELO_PACKET_SIZE);
+
+	if (result != ELO_PACKET_SIZE) {
+#ifdef DEBUG_MOUSE
+		printf("System error while sending to Elographics touchscreen.\n");
+#endif
+		return 0;
+	}
+	else {
+		return 1;
+	}
+}
+
+
+/*	eloWaitForInput
+ */
+int eloWaitForInput(int fd, int timeout)
+{
+	fd_set readfds;
+	struct timeval to;
+	int r;
+
+	FD_ZERO(&readfds);
+	FD_SET(fd, &readfds);
+	to.tv_sec = 0;
+	to.tv_usec = timeout;
+
+	r = select(FD_SETSIZE, &readfds, NULL, NULL, &to);
+	return r;
+}
+
+/*	eloWaitReply
+ */
+int eloWaitReply(unsigned char type, unsigned char *reply, int fd) {
+	int ok;
+	int i, result;
+	int reply_p = 0;
+	int sum = ELO_INIT_CHECKSUM;
+
+	i = ELO_MAX_TRIALS;
+	do {
+		ok = 0;
+
+		result = eloWaitForInput(fd, ELO_MAX_WAIT);
+
+		if (result > 0) {
+			ok = eloGetPacket(reply, &reply_p, &sum, fd);
+
+			if (ok && reply[1] != type && type != ELO_PARAMETER) {
+#ifdef DEBUG_MOUSE
+				fprintf(stderr, "Wrong reply received\n");
+#endif
+				ok = 0;
+			}
+		}
+		else {
+#ifdef DEBUG_MOUSE
+			fprintf(stderr, "No input!\n");
+#endif
+		}
+
+		if (result == 0) {
+			i--;
+		}
+	} while(!ok && (i>0));
+
+	return ok;
+}
+
+
+/*	eloWaitAck
+ */
+
+int eloWaitAck(int fd) {
+	unsigned char packet[ELO_PACKET_SIZE];
+	int i, nb_errors;
+
+	if (eloWaitReply(ELO_ACK, packet, fd)) {
+		for (i = 0, nb_errors = 0; i < 4; i++) {
+			if (packet[2 + i] != '0') {
+				nb_errors++;
+			}
+		}
+
+		if (nb_errors != 0) {
+#ifdef DEBUG_MOUSE
+			fprintf(stderr, "Elographics acknowledge packet reports %d errors\n", nb_errors);
+#endif
+		}
+		return 1;
+	}
+	else {
+		return 0;
+	}
+}
+
+
+/*	eloSendQuery --
+*/
+int eloSendQuery(unsigned char *request, unsigned char* reply, int fd) {
+	int ok;
+
+	if (eloSendPacket(request, fd)) {
+		ok = eloWaitReply(toupper(request[1]), reply, fd);
+		if (ok) {
+			ok = eloWaitAck(fd);
+		}
+		return ok;
+	}
+	else {
+		return 0;
+	}
+}
+
+
+/*	eloSendControl
+*/
+int eloSendControl(unsigned char* control, int fd) {
+	if (eloSendPacket(control, fd)) {
+		return eloWaitAck(fd);
+	}
+	else {
+		return 0;
+	}
+}
+
+/*	eloInitController
+*/
+int eloInitController(int fd) {
+	unsigned char req[ELO_PACKET_SIZE];
+	unsigned char reply[ELO_PACKET_SIZE];
+	const char *buffer = NULL;
+	int result = 0;
+
+	struct termios mouse_termios;
+
+	/* try to read the calibration values */
+	buffer = getenv("SDL_ELO_MIN_X");
+	if(buffer) {
+		ELO_MIN_X = atoi(buffer);
+	}
+	buffer = getenv("SDL_ELO_MAX_X");
+	if(buffer) {
+		ELO_MAX_X = atoi(buffer);
+	}
+	buffer = getenv("SDL_ELO_MIN_Y");
+	if(buffer) {
+		ELO_MIN_Y = atoi(buffer);
+	}
+	buffer = getenv("SDL_ELO_MAX_Y");
+	if(buffer) {
+		ELO_MAX_Y = atoi(buffer);
+	}
+
+#ifdef DEBUG_MOUSE
+	fprintf( stderr, "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n",
+		ELO_MIN_X,
+		ELO_MAX_X,
+		ELO_MIN_Y,
+		ELO_MAX_Y);
+#endif
+
+	/* set comm params */
+	memset(&mouse_termios, 0, sizeof(mouse_termios));
+	mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL;
+	mouse_termios.c_cc[VMIN] = 1;
+	result = tcsetattr(fd, TCSANOW, &mouse_termios);
+
+	if (result < 0) {
+#ifdef DEBUG_MOUSE
+		fprintf( stderr, "Unable to configure Elographics touchscreen port\n");
+#endif
+		return 0;
+	}
+
+	memset(req, 0, ELO_PACKET_SIZE);
+	req[1] = tolower(ELO_PARAMETER);
+	if (!eloSendQuery(req, reply, fd)) {
+#ifdef DEBUG_MOUSE
+		fprintf( stderr, "Not at the specified rate or model 2310, will continue\n");
+#endif
+	}
+
+	memset(req, 0, ELO_PACKET_SIZE);
+	req[1] = tolower(ELO_ID);
+	if (eloSendQuery(req, reply, fd)) {
+#ifdef DEBUG_MOUSE
+		fprintf(stderr, "Ok, controller configured!\n");
+#endif
+	}
+	else {
+#ifdef DEBUG_MOUSE
+		fprintf( stderr, "Unable to ask Elographics touchscreen identification\n");
+#endif
+		return 0;
+	}
+
+	memset(req, 0, ELO_PACKET_SIZE);
+	req[1] = ELO_MODE;
+	req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE;
+	req[4] = ELO_TRACKING_MODE;
+	if (!eloSendControl(req, fd)) {
+#ifdef DEBUG_MOUSE
+		fprintf( stderr, "Unable to change Elographics touchscreen operating mode\n");
+#endif
+		return 0;
+	}
+
+	memset(req, 0, ELO_PACKET_SIZE);
+	req[1] = ELO_REPORT;
+	req[2] = ELO_UNTOUCH_DELAY;
+	req[3] = ELO_REPORT_DELAY;
+	if (!eloSendControl(req, fd)) {
+#ifdef DEBUG_MOUSE
+		fprintf( stderr, "Unable to change Elographics touchscreen reports timings\n");
+#endif
+		return 0;
+	}
+
+	return 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbelo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,55 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef SDL_fbelo_h
+#define SDL_fbelo_h
+
+#include <stdlib.h>
+
+#include "SDL_fbvideo.h"
+
+/* ELO */
+#define ELO_PACKET_SIZE	10
+#define ELO_START_BYTE		'U'
+
+/*	eloConvertXY
+	Convert the raw coordinates from the ELO controller
+	to a screen position.
+*/
+void eloConvertXY(_THIS, int *dx,  int *dy);
+
+/*	eloInitController(int fd)
+	Initialize the ELO serial touchscreen controller
+*/
+int eloInitController(int fd);
+
+/*	eloParsePacket
+	extract position and button state from a packet
+*/
+int eloParsePacket(unsigned char* mousebuf, int* dx, int* dy, int* button_state);
+
+#endif	/* SDL_fbelo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1069 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting console events into SDL events */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+
+/* For parsing /proc */
+#include <dirent.h>
+#include <ctype.h>
+
+#include <linux/vt.h>
+#include <linux/kd.h>
+#include <linux/keyboard.h>
+
+#include "SDL.h"
+#include "SDL_mutex.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_fbvideo.h"
+#include "SDL_fbevents_c.h"
+#include "SDL_fbkeys.h"
+
+#include "SDL_fbelo.h"
+
+#ifndef GPM_NODE_FIFO
+#define GPM_NODE_FIFO	"/dev/gpmdata"
+#endif
+
+
+/* The translation tables from a console scancode to a SDL keysym */
+#define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
+static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
+static SDLKey keymap[128];
+static Uint16 keymap_temp[128]; /* only used at startup */
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+/* Ugh, we have to duplicate the kernel's keysym mapping code...
+   Oh, it's not so bad. :-)
+
+   FIXME: Add keyboard LED handling code
+ */
+static void FB_vgainitkeymaps(int fd)
+{
+	struct kbentry entry;
+	int map, i;
+
+	/* Don't do anything if we are passed a closed keyboard */
+	if ( fd < 0 ) {
+		return;
+	}
+
+	/* Load all the keysym mappings */
+	for ( map=0; map<NUM_VGAKEYMAPS; ++map ) {
+		memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16));
+		for ( i=0; i<NR_KEYS; ++i ) {
+			entry.kb_table = map;
+			entry.kb_index = i;
+			if ( ioctl(fd, KDGKBENT, &entry) == 0 ) {
+				/* fill keytemp. This replaces SDL_fbkeys.h */
+				if ( (map == 0) && (i<128) ) {
+					keymap_temp[i] = entry.kb_value;
+				}
+				/* The "Enter" key is a special case */
+				if ( entry.kb_value == K_ENTER ) {
+					entry.kb_value = K(KT_ASCII,13);
+				}
+				/* Handle numpad specially as well */
+				if ( KTYP(entry.kb_value) == KT_PAD ) {
+					switch ( entry.kb_value ) {
+					case K_P0:
+					case K_P1:
+					case K_P2:
+					case K_P3:
+					case K_P4:
+					case K_P5:
+					case K_P6:
+					case K_P7:
+					case K_P8:
+					case K_P9:
+						vga_keymap[map][i]=entry.kb_value;
+						vga_keymap[map][i]+= '0';
+						break;
+										case K_PPLUS:
+						vga_keymap[map][i]=K(KT_ASCII,'+');
+						break;
+										case K_PMINUS:
+						vga_keymap[map][i]=K(KT_ASCII,'-');
+						break;
+										case K_PSTAR:
+						vga_keymap[map][i]=K(KT_ASCII,'*');
+						break;
+										case K_PSLASH:
+						vga_keymap[map][i]=K(KT_ASCII,'/');
+						break;
+										case K_PENTER:
+						vga_keymap[map][i]=K(KT_ASCII,'\r');
+						break;
+										case K_PCOMMA:
+						vga_keymap[map][i]=K(KT_ASCII,',');
+						break;
+										case K_PDOT:
+						vga_keymap[map][i]=K(KT_ASCII,'.');
+						break;
+					default:
+						break;
+					}
+				}
+				/* Do the normal key translation */
+				if ( (KTYP(entry.kb_value) == KT_LATIN) ||
+					 (KTYP(entry.kb_value) == KT_ASCII) ||
+					 (KTYP(entry.kb_value) == KT_LETTER) ) {
+					vga_keymap[map][i] = entry.kb_value;
+				}
+			}
+		}
+	}
+}
+
+int FB_InGraphicsMode(_THIS)
+{
+	return((keyboard_fd >= 0) && (saved_kbd_mode >= 0));
+}
+
+int FB_EnterGraphicsMode(_THIS)
+{
+	struct termios keyboard_termios;
+
+	/* Set medium-raw keyboard mode */
+	if ( (keyboard_fd >= 0) && !FB_InGraphicsMode(this) ) {
+
+		/* Switch to the correct virtual terminal */
+		if ( current_vt > 0 ) {
+			struct vt_stat vtstate;
+
+			if ( ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0 ) {
+				saved_vt = vtstate.v_active;
+			}
+			if ( ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0 ) {
+				ioctl(keyboard_fd, VT_WAITACTIVE, current_vt);
+			}
+		}
+
+		/* Set the terminal input mode */
+		if ( tcgetattr(keyboard_fd, &saved_kbd_termios) < 0 ) {
+			SDL_SetError("Unable to get terminal attributes");
+			if ( keyboard_fd > 0 ) {
+				close(keyboard_fd);
+			}
+			keyboard_fd = -1;
+			return(-1);
+		}
+		if ( ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0 ) {
+			SDL_SetError("Unable to get current keyboard mode");
+			if ( keyboard_fd > 0 ) {
+				close(keyboard_fd);
+			}
+			keyboard_fd = -1;
+			return(-1);
+		}
+		keyboard_termios = saved_kbd_termios;
+		keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
+		keyboard_termios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
+		keyboard_termios.c_cc[VMIN] = 0;
+		keyboard_termios.c_cc[VTIME] = 0;
+		if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
+			FB_CloseKeyboard(this);
+			SDL_SetError("Unable to set terminal attributes");
+			return(-1);
+		}
+		/* This will fail if we aren't root or this isn't our tty */
+		if ( ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0 ) {
+			FB_CloseKeyboard(this);
+			SDL_SetError("Unable to set keyboard in raw mode");
+			return(-1);
+		}
+		if ( ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0 ) {
+			FB_CloseKeyboard(this);
+			SDL_SetError("Unable to set keyboard in graphics mode");
+			return(-1);
+		}
+	}
+	return(keyboard_fd);
+}
+
+void FB_LeaveGraphicsMode(_THIS)
+{
+	if ( FB_InGraphicsMode(this) ) {
+		ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
+		ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode);
+		tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
+		saved_kbd_mode = -1;
+
+		/* Head back over to the original virtual terminal */
+		if ( saved_vt > 0 ) {
+			ioctl(keyboard_fd, VT_ACTIVATE, saved_vt);
+		}
+	}
+}
+
+void FB_CloseKeyboard(_THIS)
+{
+	if ( keyboard_fd >= 0 ) {
+		FB_LeaveGraphicsMode(this);
+		if ( keyboard_fd > 0 ) {
+			close(keyboard_fd);
+		}
+	}
+	keyboard_fd = -1;
+}
+
+int FB_OpenKeyboard(_THIS)
+{
+	/* Open only if not already opened */
+ 	if ( keyboard_fd < 0 ) {
+		char *tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+		char *vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+		int i, tty0_fd;
+
+		/* Try to query for a free virtual terminal */
+		tty0_fd = -1;
+		for ( i=0; tty0[i] && (tty0_fd < 0); ++i ) {
+			tty0_fd = open(tty0[i], O_WRONLY, 0);
+		}
+		if ( tty0_fd < 0 ) {
+			tty0_fd = dup(0); /* Maybe stdin is a VT? */
+		}
+		ioctl(tty0_fd, VT_OPENQRY, &current_vt);
+		close(tty0_fd);
+		if ( (geteuid() == 0) && (current_vt > 0) ) {
+			for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) {
+				char vtpath[12];
+
+				sprintf(vtpath, vcs[i], current_vt);
+				keyboard_fd = open(vtpath, O_RDWR, 0);
+#ifdef DEBUG_KEYBOARD
+				fprintf(stderr, "vtpath = %s, fd = %d\n",
+					vtpath, keyboard_fd);
+#endif /* DEBUG_KEYBOARD */
+
+				/* This needs to be our controlling tty
+				   so that the kernel ioctl() calls work
+				*/
+				if ( keyboard_fd >= 0 ) {
+					tty0_fd = open("/dev/tty", O_RDWR, 0);
+					if ( tty0_fd >= 0 ) {
+						ioctl(tty0_fd, TIOCNOTTY, 0);
+						close(tty0_fd);
+					}
+				}
+			}
+		}
+ 		if ( keyboard_fd < 0 ) {
+			/* Last resort, maybe our tty is a usable VT */
+			current_vt = 0;
+			keyboard_fd = open("/dev/tty", O_RDWR);
+ 		}
+#ifdef DEBUG_KEYBOARD
+		fprintf(stderr, "Current VT: %d\n", current_vt);
+#endif
+ 		saved_kbd_mode = -1;
+
+		/* Make sure that our input is a console terminal */
+		{ int dummy;
+		  if ( ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0 ) {
+			close(keyboard_fd);
+			keyboard_fd = -1;
+			SDL_SetError("Unable to open a console terminal");
+		  }
+		}
+
+		/* Set up keymap */
+		FB_vgainitkeymaps(keyboard_fd);
+ 	}
+ 	return(keyboard_fd);
+}
+
+static enum {
+	MOUSE_NONE = -1,
+	MOUSE_GPM,	/* Note: GPM uses the MSC protocol */
+	MOUSE_PS2,
+	MOUSE_IMPS2,
+	MOUSE_MS,
+	MOUSE_BM,
+	MOUSE_ELO,
+	NUM_MOUSE_DRVS
+} mouse_drv = MOUSE_NONE;
+
+void FB_CloseMouse(_THIS)
+{
+	if ( mouse_fd > 0 ) {
+		close(mouse_fd);
+	}
+	mouse_fd = -1;
+}
+
+/* Returns processes listed in /proc with the desired name */
+static int find_pid(DIR *proc, const char *wanted_name)
+{
+	struct dirent *entry;
+	int pid;
+
+	/* First scan proc for the gpm process */
+	pid = 0;
+	while ( (pid == 0) && ((entry=readdir(proc)) != NULL) ) {
+		if ( isdigit(entry->d_name[0]) ) {
+			FILE *status;
+			char path[PATH_MAX];
+			char name[PATH_MAX];
+
+			sprintf(path, "/proc/%s/status", entry->d_name);
+			status=fopen(path, "r");
+			if ( status ) {
+				name[0] = '\0';
+				fscanf(status, "Name: %s", name);
+				if ( strcmp(name, wanted_name) == 0 ) {
+					pid = atoi(entry->d_name);
+				}
+				fclose(status);
+			}
+		}
+	}
+	return pid;
+}
+
+/* Returns true if /dev/gpmdata is being written to by gpm */
+static int gpm_available(void)
+{
+	int available;
+	DIR *proc;
+	int pid;
+	int cmdline, len, arglen;
+	char path[PATH_MAX];
+	char args[PATH_MAX], *arg;
+
+	/* Don't bother looking if the fifo isn't there */
+	if ( access(GPM_NODE_FIFO, F_OK) < 0 ) {
+		return(0);
+	}
+
+	available = 0;
+	proc = opendir("/proc");
+	if ( proc ) {
+		while ( (pid=find_pid(proc, "gpm")) > 0 ) {
+			sprintf(path, "/proc/%d/cmdline", pid);
+			cmdline = open(path, O_RDONLY, 0);
+			if ( cmdline >= 0 ) {
+				len = read(cmdline, args, sizeof(args));
+				arg = args;
+				while ( len > 0 ) {
+					if ( strcmp(arg, "-R") == 0 ) {
+						available = 1;
+					}
+					arglen = strlen(arg)+1;
+					len -= arglen;
+					arg += arglen;
+				}
+				close(cmdline);
+			}
+		}
+		closedir(proc);
+	}
+	return available;
+}
+
+/* Returns true if the mouse uses the IMPS/2 protocol */
+static int detect_imps2(int fd)
+{
+	int imps2;
+
+	imps2 = 0;
+	if ( getenv("SDL_MOUSEDEV_IMPS2") ) {
+		imps2 = 1;
+	}
+	if ( ! imps2 ) {
+		unsigned char query_ps2 = 0xF2;
+		fd_set fdset;
+		struct timeval tv;
+
+
+		/* Get rid of any mouse motion noise */
+		FD_ZERO(&fdset);
+		FD_SET(fd, &fdset);
+		tv.tv_sec = 0;
+		tv.tv_usec = 0;
+		while ( select(fd+1, &fdset, 0, 0, &tv) > 0 ) {
+			char temp[32];
+			read(fd, temp, sizeof(temp));
+		}
+
+		/* Query for the type of mouse protocol */
+		if ( write(fd, &query_ps2, 1) == 1 ) {
+			unsigned char ch = 0;
+
+			/* If you wanted to control the mouse mode:
+			   Set IMPS/2 protocol:
+				{0xf3,200,0xf3,100,0xf3,80}
+			   Reset mouse device:
+				{0xFF}
+			*/
+			/* Get the mouse protocol response */
+			do {
+				FD_ZERO(&fdset);
+				FD_SET(fd, &fdset);
+				tv.tv_sec = 1;
+				tv.tv_usec = 0;
+				if ( select(fd+1, &fdset, 0, 0, &tv) < 1 ) {
+					break;
+				}
+			} while ( (read(fd, &ch, 1) == 1) &&
+			          ((ch == 0xFA) || (ch == 0xAA)) );
+
+			/* Experimental values (Logitech wheelmouse) */
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Last mouse mode: 0x%x\n", ch);
+#endif
+			if ( ch == 3 ) {
+				imps2 = 1;
+			}
+		}
+	}
+	return imps2;
+}
+
+int FB_OpenMouse(_THIS)
+{
+	const char *mousedev;
+	const char *mousedrv;
+
+	mousedrv = getenv("SDL_MOUSEDRV");
+	mousedev = getenv("SDL_MOUSEDEV");
+	mouse_fd = -1;
+
+	/* ELO TOUCHSCREEN SUPPORT */
+
+	if( (mousedrv != NULL) && (strcmp(mousedrv, "ELO") == 0) ) {
+		mouse_fd = open(mousedev, O_RDWR);
+		if ( mouse_fd >= 0 ) {
+			if(eloInitController(mouse_fd)) {
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using ELO touchscreen\n");
+#endif
+   				mouse_drv = MOUSE_ELO;
+			}
+
+		}
+		else if ( mouse_fd < 0 ) {
+			mouse_drv = MOUSE_NONE;
+		}
+
+		return(mouse_fd);
+	}
+
+	/* STD MICE */
+
+	if ( mousedev == NULL ) {
+		/* First try to use GPM in repeater mode */
+		if ( mouse_fd < 0 ) {
+			if ( gpm_available() ) {
+				mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0);
+				if ( mouse_fd >= 0 ) {
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using GPM mouse\n");
+#endif
+					mouse_drv = MOUSE_GPM;
+				}
+			}
+		}
+		/* Now try to use the new HID unified mouse device */
+		if ( mouse_fd < 0 ) {
+			mouse_fd = open("/dev/input/mice", O_RDONLY, 0);
+			if ( mouse_fd >= 0 ) {
+				mouse_drv = MOUSE_IMPS2;
+			}
+		}
+		/* Now try to use a modern PS/2 port mouse */
+		if ( mouse_fd < 0 ) {
+			mouse_fd = open("/dev/psaux", O_RDWR, 0);
+			if ( mouse_fd < 0 ) {
+				mouse_fd = open("/dev/psaux", O_RDONLY, 0);
+			}
+			if ( mouse_fd >= 0 ) {
+				if ( detect_imps2(mouse_fd) ) {
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using IMPS/2 mouse\n");
+#endif
+					mouse_drv = MOUSE_IMPS2;
+				} else {
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using PS/2 mouse\n");
+#endif
+					mouse_drv = MOUSE_PS2;
+				}
+			}
+		}
+		/* Next try to use a PPC ADB port mouse */
+		if ( mouse_fd < 0 ) {
+			mouse_fd = open("/dev/adbmouse", O_RDONLY, 0);
+			if ( mouse_fd >= 0 ) {
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using ADB mouse\n");
+#endif
+				mouse_drv = MOUSE_BM;
+			}
+		}
+	}
+	/* Default to a serial Microsoft mouse */
+	if ( mouse_fd < 0 ) {
+		if ( mousedev == NULL ) {
+			mousedev = "/dev/mouse";
+		}
+		mouse_fd = open(mousedev, O_RDONLY, 0);
+		if ( mouse_fd >= 0 ) {
+			struct termios mouse_termios;
+
+			/* Set the sampling speed to 1200 baud */
+			tcgetattr(mouse_fd, &mouse_termios);
+			mouse_termios.c_iflag = IGNBRK | IGNPAR;
+			mouse_termios.c_oflag = 0;
+			mouse_termios.c_lflag = 0;
+			mouse_termios.c_line = 0;
+			mouse_termios.c_cc[VTIME] = 0;
+			mouse_termios.c_cc[VMIN] = 1;
+			mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL;
+			mouse_termios.c_cflag |= CS8;
+			mouse_termios.c_cflag |= B1200;
+			tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios);
+#ifdef DEBUG_MOUSE
+fprintf(stderr, "Using Microsoft mouse on %s\n", mousedev);
+#endif
+			mouse_drv = MOUSE_MS;
+		}
+	}
+	if ( mouse_fd < 0 ) {
+		mouse_drv = MOUSE_NONE;
+	}
+	return(mouse_fd);
+}
+
+static int posted = 0;
+
+void FB_vgamousecallback(int button, int relative, int dx, int dy)
+{
+	int button_1, button_3;
+	int button_state;
+	int state_changed;
+	int i;
+	Uint8 state;
+
+	if ( dx || dy ) {
+		posted += SDL_PrivateMouseMotion(0, relative, dx, dy);
+	}
+
+	/* Swap button 1 and 3 */
+	button_1 = (button & 0x04) >> 2;
+	button_3 = (button & 0x01) << 2;
+	button &= ~0x05;
+	button |= (button_1|button_3);
+
+	/* See what changed */
+	button_state = SDL_GetMouseState(NULL, NULL);
+	state_changed = button_state ^ button;
+	for ( i=0; i<8; ++i ) {
+		if ( state_changed & (1<<i) ) {
+			if ( button & (1<<i) ) {
+				state = SDL_PRESSED;
+			} else {
+				state = SDL_RELEASED;
+			}
+			posted += SDL_PrivateMouseButton(state, i+1, 0, 0);
+		}
+	}
+}
+
+/* For now, use GPM, PS/2, and MS protocols
+   Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
+ */
+static void handle_mouse(_THIS)
+{
+	static int start = 0;
+	static unsigned char mousebuf[BUFSIZ];
+	static int relative = 1;
+
+	int i, nread;
+	int button = 0;
+	int dx = 0, dy = 0;
+	int packetsize = 0;
+
+	/* Figure out the mouse packet size */
+	switch (mouse_drv) {
+		case MOUSE_NONE:
+			/* Ack! */
+			read(mouse_fd, mousebuf, BUFSIZ);
+			return;
+		case MOUSE_GPM:
+			packetsize = 5;
+			break;
+		case MOUSE_IMPS2:
+			packetsize = 4;
+			break;
+		case MOUSE_PS2:
+		case MOUSE_MS:
+		case MOUSE_BM:
+			packetsize = 3;
+			break;
+		case MOUSE_ELO:
+			packetsize = ELO_PACKET_SIZE;
+			relative = 0;
+			break;
+		case NUM_MOUSE_DRVS:
+			/* Uh oh.. */
+			packetsize = 0;
+			break;
+	}
+
+	/* Read as many packets as possible */
+	nread = read(mouse_fd, &mousebuf[start], BUFSIZ-start);
+	if ( nread < 0 ) {
+		return;
+	}
+	nread += start;
+#ifdef DEBUG_MOUSE
+	fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
+#endif
+	for ( i=0; i<(nread-(packetsize-1)); i += packetsize ) {
+		switch (mouse_drv) {
+			case MOUSE_NONE:
+				break;
+			case MOUSE_GPM:
+				/* GPM protocol has 0x80 in high byte */
+				if ( (mousebuf[i] & 0xF8) != 0x80 ) {
+					/* Go to next byte */
+					i -= (packetsize-1);
+					continue;
+				}
+				/* Get current mouse state */
+				button = (~mousebuf[i]) & 0x07;
+				dx =   (signed char)(mousebuf[i+1]) +
+				       (signed char)(mousebuf[i+3]);
+				dy = -((signed char)(mousebuf[i+2]) +
+				       (signed char)(mousebuf[i+4]));
+				break;
+			case MOUSE_PS2:
+				/* PS/2 protocol has nothing in high byte */
+				if ( (mousebuf[i] & 0xC0) != 0 ) {
+					/* Go to next byte */
+					i -= (packetsize-1);
+					continue;
+				}
+				/* Get current mouse state */
+				button = (mousebuf[i] & 0x04) >> 1 | /*Middle*/
+		  			 (mousebuf[i] & 0x02) >> 1 | /*Right*/
+		  			 (mousebuf[i] & 0x01) << 2;  /*Left*/
+		  		dx = (mousebuf[i] & 0x10) ?
+		  		      mousebuf[i+1] - 256 : mousebuf[i+1];
+		  		dy = (mousebuf[i] & 0x20) ?
+		  		      -(mousebuf[i+2] - 256) : -mousebuf[i+2];
+				break;
+			case MOUSE_IMPS2:
+				/* Get current mouse state */
+				button = (mousebuf[i] & 0x04) >> 1 | /*Middle*/
+		  			 (mousebuf[i] & 0x02) >> 1 | /*Right*/
+		  			 (mousebuf[i] & 0x01) << 2 | /*Left*/
+		  			 (mousebuf[i] & 0x40) >> 3 | /* 4 */
+		  			 (mousebuf[i] & 0x80) >> 3;  /* 5 */
+		  		dx = (mousebuf[i] & 0x10) ?
+		  		      mousebuf[i+1] - 256 : mousebuf[i+1];
+		  		dy = (mousebuf[i] & 0x20) ?
+		  		      -(mousebuf[i+2] - 256) : -mousebuf[i+2];
+				switch (mousebuf[i+3]&0x0F) {
+				    case 0x0E: /* DX = +1 */
+				    case 0x02: /* DX = -1 */
+					break;
+				    case 0x0F: /* DY = +1 (map button 4) */
+					button |= (1<<3);
+					break;
+				    case 0x01: /* DY = -1 (map button 5) */
+					button |= (1<<4);
+					break;
+				}
+				break;
+			case MOUSE_MS:
+				/* Microsoft protocol has 0x40 in high byte */
+				if ( (mousebuf[i] & 0x40) != 0x40 ) {
+					/* Go to next byte */
+					i -= (packetsize-1);
+					continue;
+				}
+				/* Get current mouse state */
+				button = ((mousebuf[i] & 0x20) >> 3) |
+				         ((mousebuf[i] & 0x10) >> 4);
+				dx = (signed char)(((mousebuf[i] & 0x03) << 6) |
+				                   (mousebuf[i + 1] & 0x3F));
+				dy = (signed char)(((mousebuf[i] & 0x0C) << 4) |
+				                    (mousebuf[i + 2] & 0x3F));
+				break;
+			case MOUSE_BM:
+				/* BusMouse protocol has 0xF8 in high byte */
+				if ( (mousebuf[i] & 0xF8) != 0x80 ) {
+					/* Go to next byte */
+					i -= (packetsize-1);
+					continue;
+				}
+				/* Get current mouse state */
+				button = (~mousebuf[i]) & 0x07;
+				dx =  (signed char)mousebuf[i+1];
+				dy = -(signed char)mousebuf[i+2];
+				break;
+			case MOUSE_ELO:
+				/* ELO protocol has ELO_START_BYTE as first byte */
+				if ( mousebuf[i] != ELO_START_BYTE ) {
+					/* Go to next byte */
+					i -= (packetsize-1);
+					continue;
+				}
+
+				/* parse the packet */
+				if(!eloParsePacket(&(mousebuf[i]), &dx, &dy, &button)) {
+					break;
+				}
+				
+				button = (button & 0x01) << 2;
+
+				/* convert to screen coordinates */
+				eloConvertXY(this, &dx, &dy);
+				break;
+
+			case NUM_MOUSE_DRVS:
+				/* Uh oh.. */
+				dx = 0;
+				dy = 0;
+				break;
+		}
+		FB_vgamousecallback(button, relative, dx, dy);
+	}
+	if ( i < nread ) {
+		memcpy(mousebuf, &mousebuf[i], (nread-i));
+		start = (nread-i);
+	} else {
+		start = 0;
+	}
+	return;
+}
+
+/* Handle switching to another VC, returns when our VC is back */
+static void switch_vt(_THIS, unsigned short which)
+{
+	struct vt_stat vtstate;
+	unsigned short current;
+	SDL_Surface *screen;
+	__u16 saved_pal[3*256];
+	Uint32 screen_arealen;
+	Uint8 *screen_contents;
+
+	/* Figure out whether or not we're switching to a new console */
+	if ( (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) ||
+	     (which == vtstate.v_active) ) {
+		return;
+	}
+	current = vtstate.v_active;
+
+	/* Save the contents of the screen, and go to text mode */
+	SDL_mutexP(hw_lock);
+	screen = SDL_VideoSurface;
+	screen_arealen = (screen->h*screen->pitch);
+	screen_contents = (Uint8 *)malloc(screen_arealen);
+	if ( screen_contents ) {
+		memcpy(screen_contents, screen->pixels, screen_arealen);
+	}
+	FB_SavePaletteTo(this, 256, saved_pal);
+	ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
+
+	/* New console, switch to it */
+	if ( ioctl(keyboard_fd, VT_ACTIVATE, which) == 0 ) {
+		/* Wait for our console to be activated again */
+		ioctl(keyboard_fd, VT_WAITACTIVE, which);
+		while ( ioctl(keyboard_fd, VT_WAITACTIVE, current) < 0 ) {
+			if ( (errno != EINTR) && (errno != EAGAIN) ) {
+				/* Unknown VT error - cancel this */
+				break;
+			}
+			SDL_Delay(500);
+		}
+	}
+
+	/* Restore graphics mode and the contents of the screen */
+	ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS);
+	FB_RestorePaletteFrom(this, 256, saved_pal);
+	if ( screen_contents ) {
+		memcpy(screen->pixels, screen_contents, screen_arealen);
+		free(screen_contents);
+	}
+	SDL_mutexV(hw_lock);
+}
+
+static void handle_keyboard(_THIS)
+{
+	unsigned char keybuf[BUFSIZ];
+	int i, nread;
+	int pressed;
+	int scancode;
+	SDL_keysym keysym;
+
+	nread = read(keyboard_fd, keybuf, BUFSIZ);
+	for ( i=0; i<nread; ++i ) {
+		scancode = keybuf[i] & 0x7F;
+		if ( keybuf[i] & 0x80 ) {
+			pressed = SDL_RELEASED;
+		} else {
+			pressed = SDL_PRESSED;
+		}
+		TranslateKey(scancode, &keysym);
+		/* Handle Alt-FN for vt switch */
+		switch (keysym.sym) {
+		    case SDLK_F1:
+		    case SDLK_F2:
+		    case SDLK_F3:
+		    case SDLK_F4:
+		    case SDLK_F5:
+		    case SDLK_F6:
+		    case SDLK_F7:
+		    case SDLK_F8:
+		    case SDLK_F9:
+		    case SDLK_F10:
+		    case SDLK_F11:
+		    case SDLK_F12:
+			if ( SDL_GetModState() & KMOD_ALT ) {
+				switch_vt(this, (keysym.sym-SDLK_F1)+1);
+				break;
+			}
+			/* Fall through to normal processing */
+		    default:
+			posted += SDL_PrivateKeyboard(pressed, &keysym);
+			break;
+		}
+	}
+}
+
+void FB_PumpEvents(_THIS)
+{
+	fd_set fdset;
+	int max_fd;
+	static struct timeval zero;
+
+	do {
+		posted = 0;
+
+		FD_ZERO(&fdset);
+		max_fd = 0;
+		if ( keyboard_fd >= 0 ) {
+			FD_SET(keyboard_fd, &fdset);
+			if ( max_fd < keyboard_fd ) {
+				max_fd = keyboard_fd;
+			}
+		}
+		if ( mouse_fd >= 0 ) {
+			FD_SET(mouse_fd, &fdset);
+			if ( max_fd < mouse_fd ) {
+				max_fd = mouse_fd;
+			}
+		}
+		if ( select(max_fd+1, &fdset, NULL, NULL, &zero) > 0 ) {
+			if ( keyboard_fd >= 0 ) {
+				if ( FD_ISSET(keyboard_fd, &fdset) ) {
+					handle_keyboard(this);
+				}
+			}
+			if ( mouse_fd >= 0 ) {
+				if ( FD_ISSET(mouse_fd, &fdset) ) {
+					handle_mouse(this);
+				}
+			}
+		}
+	} while ( posted );
+}
+
+void FB_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Initialize the Linux key translation table */
+
+	/* First get the ascii keys and others not well handled */
+	for (i=0; i<SDL_TABLESIZE(keymap); ++i) {
+	  switch(i) {
+	  /* These aren't handled by the x86 kernel keymapping (?) */
+	  case SCANCODE_PRINTSCREEN:
+	    keymap[i] = SDLK_PRINT;
+	    break;
+	  case SCANCODE_BREAK:
+	    keymap[i] = SDLK_BREAK;
+	    break;
+	  case SCANCODE_BREAK_ALTERNATIVE:
+	    keymap[i] = SDLK_PAUSE;
+	    break;
+	  case SCANCODE_LEFTSHIFT:
+	    keymap[i] = SDLK_LSHIFT;
+	    break;
+	  case SCANCODE_RIGHTSHIFT:
+	    keymap[i] = SDLK_RSHIFT;
+	    break;
+	  case SCANCODE_LEFTCONTROL:
+	    keymap[i] = SDLK_LCTRL;
+	    break;
+	  case SCANCODE_RIGHTCONTROL:
+	    keymap[i] = SDLK_RCTRL;
+	    break;
+	  case SCANCODE_RIGHTWIN:
+	    keymap[i] = SDLK_RSUPER;
+	    break;
+	  case SCANCODE_LEFTWIN:
+	    keymap[i] = SDLK_LSUPER;
+	    break;
+	  case 127:
+	    keymap[i] = SDLK_MENU;
+	    break;
+	  /* this should take care of all standard ascii keys */
+	  default:
+	    keymap[i] = KVAL(vga_keymap[0][i]);
+	    break;
+          }
+	}
+	for (i=0; i<SDL_TABLESIZE(keymap); ++i) {
+	  switch(keymap_temp[i]) {
+	    case K_F1:  keymap[i] = SDLK_F1;  break;
+	    case K_F2:  keymap[i] = SDLK_F2;  break;
+	    case K_F3:  keymap[i] = SDLK_F3;  break;
+	    case K_F4:  keymap[i] = SDLK_F4;  break;
+	    case K_F5:  keymap[i] = SDLK_F5;  break;
+	    case K_F6:  keymap[i] = SDLK_F6;  break;
+	    case K_F7:  keymap[i] = SDLK_F7;  break;
+	    case K_F8:  keymap[i] = SDLK_F8;  break;
+	    case K_F9:  keymap[i] = SDLK_F9;  break;
+	    case K_F10: keymap[i] = SDLK_F10; break;
+	    case K_F11: keymap[i] = SDLK_F11; break;
+	    case K_F12: keymap[i] = SDLK_F12; break;
+
+	    case K_DOWN:  keymap[i] = SDLK_DOWN;  break;
+	    case K_LEFT:  keymap[i] = SDLK_LEFT;  break;
+	    case K_RIGHT: keymap[i] = SDLK_RIGHT; break;
+	    case K_UP:    keymap[i] = SDLK_UP;    break;
+
+	    case K_P0:     keymap[i] = SDLK_KP0; break;
+	    case K_P1:     keymap[i] = SDLK_KP1; break;
+	    case K_P2:     keymap[i] = SDLK_KP2; break;
+	    case K_P3:     keymap[i] = SDLK_KP3; break;
+	    case K_P4:     keymap[i] = SDLK_KP4; break;
+	    case K_P5:     keymap[i] = SDLK_KP5; break;
+	    case K_P6:     keymap[i] = SDLK_KP6; break;
+	    case K_P7:     keymap[i] = SDLK_KP7; break;
+	    case K_P8:     keymap[i] = SDLK_KP8; break;
+	    case K_P9:     keymap[i] = SDLK_KP9; break;
+	    case K_PPLUS:  keymap[i] = SDLK_KP_PLUS; break;
+	    case K_PMINUS: keymap[i] = SDLK_KP_MINUS; break;
+	    case K_PSTAR:  keymap[i] = SDLK_KP_MULTIPLY; break;
+	    case K_PSLASH: keymap[i] = SDLK_KP_DIVIDE; break;
+	    case K_PENTER: keymap[i] = SDLK_KP_ENTER; break;
+	    case K_PDOT:   keymap[i] = SDLK_KP_PERIOD; break;
+
+	    case K_SHIFT:  if ( keymap[i] != SDLK_RSHIFT )
+	                     keymap[i] = SDLK_LSHIFT;
+	                   break;
+	    case K_SHIFTL: keymap[i] = SDLK_LSHIFT; break;
+	    case K_SHIFTR: keymap[i] = SDLK_RSHIFT; break;
+	    case K_CTRL:  if ( keymap[i] != SDLK_RCTRL )
+	                     keymap[i] = SDLK_LCTRL;
+	                   break;
+	    case K_CTRLL:  keymap[i] = SDLK_LCTRL;  break;
+	    case K_CTRLR:  keymap[i] = SDLK_RCTRL;  break;
+	    case K_ALT:    keymap[i] = SDLK_LALT;   break;
+	    case K_ALTGR:  keymap[i] = SDLK_RALT;   break;
+
+	    case K_INSERT: keymap[i] = SDLK_INSERT;   break;
+	    case K_REMOVE: keymap[i] = SDLK_DELETE;   break;
+	    case K_PGUP:   keymap[i] = SDLK_PAGEUP;   break;
+	    case K_PGDN:   keymap[i] = SDLK_PAGEDOWN; break;
+	    case K_FIND:   keymap[i] = SDLK_HOME;     break;
+	    case K_SELECT: keymap[i] = SDLK_END;      break;
+
+	    case K_NUM:  keymap[i] = SDLK_NUMLOCK;   break;
+	    case K_CAPS: keymap[i] = SDLK_CAPSLOCK;  break;
+
+	    case K_F13:   keymap[i] = SDLK_PRINT;     break;
+	    case K_HOLD:  keymap[i] = SDLK_SCROLLOCK; break;
+	    case K_PAUSE: keymap[i] = SDLK_PAUSE;     break;
+
+	    case 127: keymap[i] = SDLK_BACKSPACE; break;
+	     
+	    default: break;
+	  }
+	}
+}
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->sym = keymap[scancode];
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE ) {
+		int map;
+		SDLMod modstate;
+
+		modstate = SDL_GetModState();
+		map = 0;
+		if ( modstate & KMOD_SHIFT ) {
+			map |= (1<<KG_SHIFT);
+		}
+		if ( modstate & KMOD_CTRL ) {
+			map |= (1<<KG_CTRL);
+		}
+		if ( modstate & KMOD_ALT ) {
+			map |= (1<<KG_ALT);
+		}
+		if ( modstate & KMOD_MODE ) {
+			map |= (1<<KG_ALTGR);
+		}
+		if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) {
+			if ( modstate & KMOD_CAPS ) {
+				map ^= (1<<KG_SHIFT);
+			}
+		}
+		if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) {
+			if ( modstate & KMOD_NUM ) {
+				keysym->unicode=KVAL(vga_keymap[map][scancode]);
+			}
+		} else {
+			keysym->unicode = KVAL(vga_keymap[map][scancode]);
+		}
+	}
+	return(keysym);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_fbvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern int FB_OpenKeyboard(_THIS);
+extern void FB_CloseKeyboard(_THIS);
+extern int FB_OpenMouse(_THIS);
+extern void FB_CloseMouse(_THIS);
+extern int FB_EnterGraphicsMode(_THIS);
+extern int FB_InGraphicsMode(_THIS);
+extern void FB_LeaveGraphicsMode(_THIS);
+
+extern void FB_InitOSKeymap(_THIS);
+extern void FB_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbkeys.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,139 @@
+
+/* Scancodes for the Linux framebuffer console
+   - Taken with thanks from SVGAlib 1.4.0
+*/
+
+#define SCANCODE_ESCAPE			1
+
+#define SCANCODE_1			2
+#define SCANCODE_2			3
+#define SCANCODE_3			4
+#define SCANCODE_4			5
+#define SCANCODE_5			6
+#define SCANCODE_6			7
+#define SCANCODE_7			8
+#define SCANCODE_8			9
+#define SCANCODE_9			10
+#define SCANCODE_0			11
+
+#define SCANCODE_MINUS			12
+#define SCANCODE_EQUAL			13
+
+#define SCANCODE_BACKSPACE		14
+#define SCANCODE_TAB			15
+
+#define SCANCODE_Q			16
+#define SCANCODE_W			17
+#define SCANCODE_E			18
+#define SCANCODE_R			19
+#define SCANCODE_T			20
+#define SCANCODE_Y			21
+#define SCANCODE_U			22
+#define SCANCODE_I			23
+#define SCANCODE_O			24
+#define SCANCODE_P			25
+#define SCANCODE_BRACKET_LEFT		26
+#define SCANCODE_BRACKET_RIGHT		27
+
+#define SCANCODE_ENTER			28
+
+#define SCANCODE_LEFTCONTROL		29
+
+#define SCANCODE_A			30
+#define SCANCODE_S			31
+#define SCANCODE_D			32
+#define SCANCODE_F			33
+#define SCANCODE_G			34
+#define SCANCODE_H			35
+#define SCANCODE_J			36
+#define SCANCODE_K			37
+#define SCANCODE_L			38
+#define SCANCODE_SEMICOLON		39
+#define SCANCODE_APOSTROPHE		40
+#define SCANCODE_GRAVE			41
+
+#define SCANCODE_LEFTSHIFT		42
+#define SCANCODE_BACKSLASH		43
+
+#define SCANCODE_Z			44
+#define SCANCODE_X			45
+#define SCANCODE_C			46
+#define SCANCODE_V			47
+#define SCANCODE_B			48
+#define SCANCODE_N			49
+#define SCANCODE_M			50
+#define SCANCODE_COMMA			51
+#define SCANCODE_PERIOD			52
+#define SCANCODE_SLASH			53
+
+#define SCANCODE_RIGHTSHIFT		54
+#define SCANCODE_KEYPADMULTIPLY		55
+
+#define SCANCODE_LEFTALT		56
+#define SCANCODE_SPACE			57
+#define SCANCODE_CAPSLOCK		58
+
+#define SCANCODE_F1			59
+#define SCANCODE_F2			60
+#define SCANCODE_F3			61
+#define SCANCODE_F4			62
+#define SCANCODE_F5			63
+#define SCANCODE_F6			64
+#define SCANCODE_F7			65
+#define SCANCODE_F8			66
+#define SCANCODE_F9			67
+#define SCANCODE_F10			68
+
+#define SCANCODE_NUMLOCK		69
+#define SCANCODE_SCROLLLOCK		70
+
+#define SCANCODE_KEYPAD7		71
+#define SCANCODE_CURSORUPLEFT		71
+#define SCANCODE_KEYPAD8		72
+#define SCANCODE_CURSORUP		72
+#define SCANCODE_KEYPAD9		73
+#define SCANCODE_CURSORUPRIGHT		73
+#define SCANCODE_KEYPADMINUS		74
+#define SCANCODE_KEYPAD4		75
+#define SCANCODE_CURSORLEFT		75
+#define SCANCODE_KEYPAD5		76
+#define SCANCODE_KEYPAD6		77
+#define SCANCODE_CURSORRIGHT		77
+#define SCANCODE_KEYPADPLUS		78
+#define SCANCODE_KEYPAD1		79
+#define SCANCODE_CURSORDOWNLEFT		79
+#define SCANCODE_KEYPAD2		80
+#define SCANCODE_CURSORDOWN		80
+#define SCANCODE_KEYPAD3		81
+#define SCANCODE_CURSORDOWNRIGHT	81
+#define SCANCODE_KEYPAD0		82
+#define SCANCODE_KEYPADPERIOD		83
+
+#define SCANCODE_LESS			86
+
+#define SCANCODE_F11			87
+#define SCANCODE_F12			88
+
+#define SCANCODE_KEYPADENTER		96
+#define SCANCODE_RIGHTCONTROL		97
+#define SCANCODE_CONTROL		97
+#define SCANCODE_KEYPADDIVIDE		98
+#define SCANCODE_PRINTSCREEN		99
+#define SCANCODE_RIGHTALT		100
+#define SCANCODE_BREAK			101	/* Beware: is 119     */
+#define SCANCODE_BREAK_ALTERNATIVE	119	/* on some keyboards! */
+
+#define SCANCODE_HOME			102
+#define SCANCODE_CURSORBLOCKUP		103	/* Cursor key block */
+#define SCANCODE_PAGEUP			104
+#define SCANCODE_CURSORBLOCKLEFT	105	/* Cursor key block */
+#define SCANCODE_CURSORBLOCKRIGHT	106	/* Cursor key block */
+#define SCANCODE_END			107
+#define SCANCODE_CURSORBLOCKDOWN	108	/* Cursor key block */
+#define SCANCODE_PAGEDOWN		109
+#define SCANCODE_INSERT			110
+#define SCANCODE_REMOVE			111
+
+#define SCANCODE_RIGHTWIN		126
+#define SCANCODE_LEFTWIN		125
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbmatrox.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,278 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_fbmatrox.h"
+#include "matrox_mmio.h"
+
+
+static int LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		mga_waitidle();
+	}
+	return(0);
+}
+static void UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* Wait for vertical retrace - taken from the XFree86 Matrox driver */
+static void WaitVBL(_THIS)
+{
+	int count;
+
+	/* find start of retrace */
+	mga_waitidle();
+	while (  (mga_in8(0x1FDA) & 0x08) )
+		;
+	while ( !(mga_in8(0x1FDA) & 0x08) )
+		; 
+	/* wait until we're past the start */
+	count = mga_in32(0x1E20) + 2;
+	while ( mga_in32(0x1E20) < count )
+		;
+}
+
+/* Sets video mem colorkey and accelerated blit function */
+static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+	return(0);
+}
+
+/* Sets per surface hardware alpha value */
+static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
+{
+	return(0);
+}
+
+static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
+{
+	int dstX, dstY;
+	Uint32 fxbndry;
+	Uint32 ydstlen;
+	Uint32 fillop;
+
+	switch (dst->format->BytesPerPixel) {
+	    case 1:
+		color |= (color<<8);
+	    case 2:
+		color |= (color<<16);
+		break;
+	}
+
+	/* Set up the X/Y base coordinates */
+	dstX = 0;
+	dstY = ((char *)dst->pixels - mapped_mem) / SDL_VideoSurface->pitch;
+
+	/* Adjust for the current rectangle */
+	dstX += rect->x;
+	dstY += rect->y;
+
+	/* Set up the X boundaries */
+	fxbndry = (dstX | ((dstX+rect->w) << 16));
+
+	/* Set up the Y boundaries */
+	ydstlen = (rect->h | (dstY << 16));
+
+#if 0	/* This old way doesn't work on the Matrox G450 */
+	/* Set up for color fill operation */
+	fillop = MGADWG_TRAP | MGADWG_SOLID |
+	         MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO |
+	         MGADWG_BFCOL | MGADWG_BLK;
+
+	/* Execute the operations! */
+	mga_wait(4);
+	mga_out32(MGAREG_FCOL, color);
+	mga_out32(MGAREG_FXBNDRY, fxbndry);
+	mga_out32(MGAREG_YDSTLEN, ydstlen);
+	mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, fillop);
+#else
+	/* Set up for color fill operation */
+	fillop = MGADWG_TRAP | MGADWG_SOLID |
+	         MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO;
+
+	/* Execute the operations! */
+	mga_wait(5);
+	mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE);
+	mga_out32(MGAREG_FCOL, color);
+	mga_out32(MGAREG_FXBNDRY, fxbndry);
+	mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen);
+#endif
+
+	return(0);
+}
+
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	SDL_VideoDevice *this;
+	int bpp;
+	int srcX, srcY;
+	int dstX, dstY;
+	Uint32 sign;
+	Uint32 sstart, sstop;
+	int sskip;
+	Uint32 blitop;
+
+	/* FIXME: For now, only blit to display surface */
+	if ( dst->pitch != SDL_VideoSurface->pitch ) {
+		return(src->map->sw_blit(src, srcrect, dst, dstrect));
+	}
+
+	/* Calculate source and destination base coordinates (in pixels) */
+	this = current_video;
+	srcX= 0;	/* FIXME: Calculate this from memory offset */
+	srcY = ((char *)src->pixels - mapped_mem) / SDL_VideoSurface->pitch;
+	dstX = 0;	/* FIXME: Calculate this from memory offset */
+	dstY = ((char *)dst->pixels - mapped_mem) / SDL_VideoSurface->pitch;
+
+	/* Adjust for the current blit rectangles */
+	srcX += srcrect->x;
+	srcY += srcrect->y;
+	dstX += dstrect->x;
+	dstY += dstrect->y;
+
+	/* Set up the blit direction (sign) flags */
+	sign = 0;
+	if ( srcX < dstX ) {
+		sign |= 1;
+	}
+	if ( srcY < dstY ) {
+		sign |= 4;
+	}
+
+	/* Set up the blit source row start, end, and skip (in pixels) */
+	bpp = src->format->BytesPerPixel;
+	sstop = sstart = ((srcY * SDL_VideoSurface->pitch)/bpp) + srcX;
+	if ( srcX < dstX ) {
+		sstart += (dstrect->w - 1);
+	} else {
+		sstop += (dstrect->w - 1);
+	}
+	sskip = src->pitch/bpp;
+	if ( srcY < dstY ) {
+		sskip = -sskip;
+	}
+
+	/* Set up the blit operation */
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		Uint32 colorkey;
+
+		blitop = MGADWG_BFCOL | MGADWG_BITBLT |
+		         MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16) |
+		         MGADWG_TRANSC;
+
+		colorkey = src->format->colorkey;
+		switch (dst->format->BytesPerPixel) {
+		    case 1:
+			colorkey |= (colorkey<<8);
+		    case 2:
+			colorkey |= (colorkey<<16);
+			break;
+		}
+		mga_wait(2);
+		mga_out32(MGAREG_FCOL, colorkey);
+		mga_out32(MGAREG_BCOL, 0xFFFFFFFF);
+	} else {
+		blitop = MGADWG_BFCOL | MGADWG_BITBLT |
+		         MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16);
+	}
+	mga_wait(7);
+	mga_out32(MGAREG_SGN, sign);
+	mga_out32(MGAREG_AR3, sstart);
+	mga_out32(MGAREG_AR0, sstop);
+	mga_out32(MGAREG_AR5, sskip);
+	mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + dstrect->w-1) << 16)));
+	mga_out32(MGAREG_YDSTLEN, (dstY << 16) | dstrect->h);
+	mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop);
+
+	return(0);
+}
+
+static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+	int accelerated;
+
+	/* Set initial acceleration on */
+	src->flags |= SDL_HWACCEL;
+
+	/* Set the surface attributes */
+	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		if ( ! this->info.blit_hw_A ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		if ( ! this->info.blit_hw_CC ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+
+	/* Check to see if final surface blit is accelerated */
+	accelerated = !!(src->flags & SDL_HWACCEL);
+	if ( accelerated ) {
+		src->map->hw_blit = HWAccelBlit;
+	}
+	return(accelerated);
+}
+
+void FB_MatroxAccel(_THIS, __u32 card)
+{
+	/* We have hardware accelerated surface functions */
+	this->CheckHWBlit = CheckHWBlit;
+	this->LockHWSurface = LockHWSurface;
+	this->UnlockHWSurface = UnlockHWSurface;
+	wait_vbl = WaitVBL;
+
+	/* The Matrox has an accelerated color fill */
+	this->info.blit_fill = 1;
+	this->FillHWRect = FillHWRect;
+
+	/* The Matrox has accelerated normal and colorkey blits. */
+	this->info.blit_hw = 1;
+	/* The Millenium I appears to do the colorkey test a word
+	   at a time, and the transparency is intverted. (?)
+	 */
+	if ( card != FB_ACCEL_MATROX_MGA2064W ) {
+		this->info.blit_hw_CC = 1;
+		this->SetHWColorKey = SetHWColorKey;
+	}
+
+#if 0 /* Not yet implemented? */
+	/* The Matrox G200/G400 has an accelerated alpha blit */
+	if ( (card == FB_ACCEL_MATROX_MGAG200)
+	  || (card == FB_ACCEL_MATROX_MGAG400)
+	) {
+		this->info.blit_hw_A = 1;
+		this->SetHWAlpha = SetHWAlpha;
+	}
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbmatrox.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Matrox hardware acceleration for the SDL framebuffer console driver */
+
+#include "SDL_fbvideo.h"
+
+/* Set up the driver for Matrox acceleration */
+extern void FB_MatroxAccel(_THIS, __u32 card);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbmouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_fbvideo.h"
+#include "SDL_fbmouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	int unused;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbmouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_fbvideo.h"
+
+/* Functions to be exported */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbvideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1417 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Framebuffer console based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <asm/page.h>		/* For definition of PAGE_SIZE */
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_fbvideo.h"
+#include "SDL_fbmouse_c.h"
+#include "SDL_fbevents_c.h"
+#include "SDL_fb3dfx.h"
+#include "SDL_fbmatrox.h"
+
+#if defined(i386) && defined(FB_TYPE_VGA_PLANES)
+#define VGA16_FBCON_SUPPORT
+#ifndef FB_AUX_VGA_PLANES_VGA4
+#define FB_AUX_VGA_PLANES_VGA4	0
+#endif
+static inline void outb (unsigned char value, unsigned short port)
+{
+  __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
+} 
+#endif /* FB_TYPE_VGA_PLANES */
+
+/* A list of video resolutions that we query for (sorted largest to smallest) */
+static SDL_Rect checkres[] = {
+	{  0, 0, 1600, 1200 },		/* 16 bpp: 0x11E, or 286 */
+	{  0, 0, 1408, 1056 },		/* 16 bpp: 0x19A, or 410 */
+	{  0, 0, 1280, 1024 },		/* 16 bpp: 0x11A, or 282 */
+	{  0, 0, 1152,  864 },		/* 16 bpp: 0x192, or 402 */
+	{  0, 0, 1024,  768 },		/* 16 bpp: 0x117, or 279 */
+	{  0, 0,  960,  720 },		/* 16 bpp: 0x18A, or 394 */
+	{  0, 0,  800,  600 },		/* 16 bpp: 0x114, or 276 */
+	{  0, 0,  768,  576 },		/* 16 bpp: 0x182, or 386 */
+	{  0, 0,  640,  480 },		/* 16 bpp: 0x111, or 273 */
+	{  0, 0,  640,  400 },		/*  8 bpp: 0x100, or 256 */
+	{  0, 0,  512,  384 },
+	{  0, 0,  320,  240 },
+	{  0, 0,  320,  200 }
+};
+static struct {
+	int xres;
+	int yres;
+	int pixclock;
+	int left;
+	int right;
+	int upper;
+	int lower;
+	int hslen;
+	int vslen;
+	int sync;
+	int vmode;
+} vesa_timings[] = {
+#ifdef USE_VESA_TIMINGS	/* Only tested on Matrox Millenium I */
+	{  640,  400, 39771,  48, 16, 39,  8,  96, 2, 2, 0 },	/* 70 Hz */
+	{  640,  480, 39683,  48, 16, 33, 10,  96, 2, 0, 0 },	/* 60 Hz */
+	{  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },	/* 60 Hz */
+	{  800,  600, 24038, 144, 24, 28,  8, 112, 6, 0, 0 },	/* 60 Hz */
+	{  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },	/* 60 Hz */
+	{ 1024,  768, 15386, 160, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },	/* 60 Hz */
+	{ 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },	/* 60 Hz */
+	{ 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },	/* 60 Hz */
+#else
+	/* You can generate these timings from your XF86Config file using
+	   the 'modeline2fb' perl script included with the fbset package.
+	   These timings were generated for Matrox Millenium I, 15" monitor.
+	*/
+	{  320,  200, 79440,  16, 16, 20,  4,  48, 1, 0, 2 },	/* 70 Hz */
+	{  320,  240, 63492,  16, 16, 16,  4,  48, 2, 0, 2 },	/* 72 Hz */
+	{  512,  384, 49603,  48, 16, 16,  1,  64, 3, 0, 0 },	/* 78 Hz */
+	{  640,  400, 31746,  96, 32, 41,  1,  64, 3, 2, 0 },	/* 85 Hz */
+	{  640,  480, 31746, 120, 16, 16,  1,  64, 3, 0, 0 },	/* 75 Hz */
+	{  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },	/* 60 Hz */
+	{  800,  600, 20000,  64, 56, 23, 37, 120, 6, 3, 0 },	/* 72 Hz */
+	{  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },	/* 60 Hz */
+	{ 1024,  768, 13333, 144, 24, 29,  3, 136, 6, 0, 0 },	/* 70 Hz */
+	{ 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },	/* 60 Hz */
+	{ 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },	/* 60 Hz */
+	{ 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },	/* 60 Hz */
+#endif
+};
+
+/* Initialization/Query functions */
+static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+#ifdef VGA16_FBCON_SUPPORT
+static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+#endif
+static int FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void FB_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int FB_InitHWSurfaces(_THIS, char *base, int size);
+static void FB_FreeHWSurfaces(_THIS);
+static int FB_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int FB_LockHWSurface(_THIS, SDL_Surface *surface);
+static void FB_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void FB_FreeHWSurface(_THIS, SDL_Surface *surface);
+static void FB_WaitVBL(_THIS);
+static int FB_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+/* Internal palette functions */
+static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
+                                  struct fb_var_screeninfo *vinfo);
+static void FB_RestorePalette(_THIS);
+
+/* FB driver bootstrap functions */
+
+static int FB_Available(void)
+{
+	int console;
+	const char *SDL_fbdev;
+
+	SDL_fbdev = getenv("SDL_FBDEV");
+	if ( SDL_fbdev == NULL ) {
+		SDL_fbdev = "/dev/fb0";
+	}
+	console = open(SDL_fbdev, O_RDWR, 0);
+	if ( console >= 0 ) {
+		close(console);
+	}
+	return(console >= 0);
+}
+
+static void FB_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *FB_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *this;
+
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	wait_vbl = FB_WaitVBL;
+	mouse_fd = -1;
+	keyboard_fd = -1;
+
+	/* Set the function pointers */
+	this->VideoInit = FB_VideoInit;
+	this->ListModes = FB_ListModes;
+	this->SetVideoMode = FB_SetVideoMode;
+	this->SetColors = FB_SetColors;
+	this->UpdateRects = NULL;
+	this->VideoQuit = FB_VideoQuit;
+	this->AllocHWSurface = FB_AllocHWSurface;
+	this->CheckHWBlit = NULL;
+	this->FillHWRect = NULL;
+	this->SetHWColorKey = NULL;
+	this->SetHWAlpha = NULL;
+	this->LockHWSurface = FB_LockHWSurface;
+	this->UnlockHWSurface = FB_UnlockHWSurface;
+	this->FlipHWSurface = FB_FlipHWSurface;
+	this->FreeHWSurface = FB_FreeHWSurface;
+	this->SetCaption = NULL;
+	this->SetIcon = NULL;
+	this->IconifyWindow = NULL;
+	this->GrabInput = NULL;
+	this->GetWMInfo = NULL;
+	this->InitOSKeymap = FB_InitOSKeymap;
+	this->PumpEvents = FB_PumpEvents;
+
+	this->free = FB_DeleteDevice;
+
+	return this;
+}
+
+VideoBootStrap FBCON_bootstrap = {
+	"fbcon", "Linux Framebuffer Console",
+	FB_Available, FB_CreateDevice
+};
+
+static int FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo,
+                        int index, unsigned int *w, unsigned int *h)
+{
+	int mode_okay;
+
+	mode_okay = 0;
+	vinfo->bits_per_pixel = (index+1)*8;
+	vinfo->xres = *w;
+	vinfo->xres_virtual = *w;
+	vinfo->yres = *h;
+	vinfo->yres_virtual = *h;
+	vinfo->activate = FB_ACTIVATE_TEST;
+	if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0 ) {
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", *w, *h, (index+1)*8, vinfo->xres, vinfo->yres, vinfo->bits_per_pixel);
+#endif
+		if ( (((vinfo->bits_per_pixel+7)/8)-1) == index ) {
+			*w = vinfo->xres;
+			*h = vinfo->yres;
+			mode_okay = 1;
+		}
+	}
+	return mode_okay;
+}
+
+static int FB_AddMode(_THIS, int index, unsigned int w, unsigned int h)
+{
+	SDL_Rect *mode;
+	int i;
+	int next_mode;
+
+	/* Check to see if we already have this mode */
+	if ( SDL_nummodes[index] > 0 ) {
+		mode = SDL_modelist[index][SDL_nummodes[index]-1];
+		if ( (mode->w == w) && (mode->h == h) ) {
+#ifdef FBCON_DEBUG
+			fprintf(stderr, "We already have mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+			return(0);
+		}
+	}
+
+	/* Only allow a mode if we have a valid timing for it */
+	next_mode = 0;
+	for ( i=0; i<(sizeof(vesa_timings)/sizeof(vesa_timings[0])); ++i ) {
+		if ( (w == vesa_timings[i].xres) &&
+		     (h == vesa_timings[i].yres) && vesa_timings[i].pixclock ) {
+			next_mode = i;
+			break;
+		}
+	}
+	if ( ! next_mode ) {
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h);
+#endif
+		return(0);
+	}
+
+	/* Set up the new video mode rectangle */
+	mode = (SDL_Rect *)malloc(sizeof *mode);
+	if ( mode == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	mode->x = 0;
+	mode->y = 0;
+	mode->w = w;
+	mode->h = h;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+
+	/* Allocate the new list of modes, and fill in the new mode */
+	next_mode = SDL_nummodes[index];
+	SDL_modelist[index] = (SDL_Rect **)
+	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist[index] == NULL ) {
+		SDL_OutOfMemory();
+		SDL_nummodes[index] = 0;
+		free(mode);
+		return(-1);
+	}
+	SDL_modelist[index][next_mode] = mode;
+	SDL_modelist[index][next_mode+1] = NULL;
+	SDL_nummodes[index]++;
+
+	return(0);
+}
+
+static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+	int i, j;
+	int current_index;
+	unsigned int current_w;
+	unsigned int current_h;
+	const char *SDL_fbdev;
+
+	/* Initialize the library */
+	SDL_fbdev = getenv("SDL_FBDEV");
+	if ( SDL_fbdev == NULL ) {
+		SDL_fbdev = "/dev/fb0";
+	}
+	console_fd = open(SDL_fbdev, O_RDWR, 0);
+	if ( console_fd < 0 ) {
+		SDL_SetError("Unable to open %s", SDL_fbdev);
+		return(-1);
+	}
+
+#ifndef DISABLE_THREADS
+	/* Create the hardware surface lock mutex */
+	hw_lock = SDL_CreateMutex();
+	if ( hw_lock == NULL ) {
+		SDL_SetError("Unable to create lock mutex");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+#endif
+
+	/* Get the type of video hardware */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	switch (finfo.type) {
+		case FB_TYPE_PACKED_PIXELS:
+			/* Supported, no worries.. */
+			break;
+#ifdef VGA16_FBCON_SUPPORT
+		case FB_TYPE_VGA_PLANES:
+			/* VGA16 is supported, but that's it */
+			if ( finfo.type_aux == FB_AUX_VGA_PLANES_VGA4 ) {
+				if ( ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0 ) {
+					SDL_SetError("No I/O port permissions");
+					FB_VideoQuit(this);
+					return(-1);
+				}
+				this->SetVideoMode = FB_SetVGA16Mode;
+				break;
+			}
+			/* Fall through to unsupported case */
+#endif /* VGA16_FBCON_SUPPORT */
+		default:
+			SDL_SetError("Unsupported console hardware");
+			FB_VideoQuit(this);
+			return(-1);
+	}
+	switch (finfo.visual) {
+		case FB_VISUAL_TRUECOLOR:
+		case FB_VISUAL_PSEUDOCOLOR:
+		case FB_VISUAL_STATIC_PSEUDOCOLOR:
+		case FB_VISUAL_DIRECTCOLOR:
+			break;
+		default:
+			SDL_SetError("Unsupported console hardware");
+			FB_VideoQuit(this);
+			return(-1);
+	}
+
+	/* Check if the user wants to disable hardware acceleration */
+	{ const char *fb_accel;
+		fb_accel = getenv("SDL_FBACCEL");
+		if ( fb_accel ) {
+			finfo.accel = atoi(fb_accel);
+		}
+	}
+
+	/* Memory map the device, compensating for buggy PPC mmap() */
+	mapped_offset = (((long)finfo.smem_start) -
+	                (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
+	mapped_memlen = finfo.smem_len+mapped_offset;
+	mapped_mem = mmap(NULL, mapped_memlen,
+	                  PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
+	if ( mapped_mem == (char *)-1 ) {
+		SDL_SetError("Unable to memory map the video hardware");
+		mapped_mem = NULL;
+		FB_VideoQuit(this);
+		return(-1);
+	}
+
+	/* Determine the current screen depth */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console pixel format");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	vformat->BitsPerPixel = vinfo.bits_per_pixel;
+	if ( vformat->BitsPerPixel < 8 ) {
+		/* Assuming VGA16, we handle this via a shadow framebuffer */
+		vformat->BitsPerPixel = 8;
+	}
+	for ( i=0; i<vinfo.red.length; ++i ) {
+		vformat->Rmask <<= 1;
+		vformat->Rmask |= (0x00000001<<vinfo.red.offset);
+	}
+	for ( i=0; i<vinfo.green.length; ++i ) {
+		vformat->Gmask <<= 1;
+		vformat->Gmask |= (0x00000001<<vinfo.green.offset);
+	}
+	for ( i=0; i<vinfo.blue.length; ++i ) {
+		vformat->Bmask <<= 1;
+		vformat->Bmask |= (0x00000001<<vinfo.blue.offset);
+	}
+	saved_vinfo = vinfo;
+
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+
+	/* If the I/O registers are available, memory map them so we
+	   can take advantage of any supported hardware acceleration.
+	 */
+	vinfo.accel_flags = 0;	/* Temporarily reserve registers */
+	ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
+	if ( finfo.accel && finfo.mmio_len ) {
+		mapped_iolen = finfo.mmio_len;
+		mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE,
+		                 MAP_SHARED, console_fd, mapped_memlen);
+		if ( mapped_io == (char *)-1 ) {
+			/* Hmm, failed to memory map I/O registers */
+			mapped_io = NULL;
+		}
+	}
+
+	/* Query for the list of available video modes */
+	current_w = vinfo.xres;
+	current_h = vinfo.yres;
+	current_index = ((vinfo.bits_per_pixel+7)/8)-1;
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		SDL_nummodes[i] = 0;
+		SDL_modelist[i] = NULL;
+		for ( j=0; j<(sizeof(checkres)/sizeof(checkres[0])); ++j ) {
+			unsigned int w, h;
+
+			/* See if we are querying for the current mode */
+			w = checkres[j].w;
+			h = checkres[j].h;
+			if ( i == current_index ) {
+				if ( (current_w > w) || (current_h > h) ) {
+					/* Only check once */
+					FB_AddMode(this, i,current_w,current_h);
+					current_index = -1;
+				}
+			}
+			if ( FB_CheckMode(this, &vinfo, i, &w, &h) ) {
+				FB_AddMode(this, i, w, h);
+			}
+		}
+	}
+
+	/* Fill in our hardware acceleration capabilities */
+	this->info.wm_available = 0;
+	this->info.hw_available = 1;
+	this->info.video_mem = finfo.smem_len/1024;
+	if ( mapped_io ) {
+		switch (finfo.accel) {
+		    case FB_ACCEL_MATROX_MGA2064W:
+		    case FB_ACCEL_MATROX_MGA1064SG:
+		    case FB_ACCEL_MATROX_MGA2164W:
+		    case FB_ACCEL_MATROX_MGA2164W_AGP:
+		    case FB_ACCEL_MATROX_MGAG100:
+		    /*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */
+		    case FB_ACCEL_MATROX_MGAG400:
+#ifdef FBACCEL_DEBUG
+			printf("Matrox hardware accelerator!\n");
+#endif
+			FB_MatroxAccel(this, finfo.accel);
+			break;
+		    case FB_ACCEL_3DFX_BANSHEE:
+#ifdef FBACCEL_DEBUG
+			printf("3DFX hardware accelerator!\n");
+#endif
+			FB_3DfxAccel(this, finfo.accel);
+			break;
+		    default:
+#ifdef FBACCEL_DEBUG
+			printf("Unknown hardware accelerator.\n");
+#endif
+			break;
+		}
+	}
+
+	/* Enable mouse and keyboard support */
+	if ( FB_OpenKeyboard(this) < 0 ) {
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	if ( FB_OpenMouse(this) < 0 ) {
+		const char *sdl_nomouse;
+
+		sdl_nomouse = getenv("SDL_NOMOUSE");
+		if ( ! sdl_nomouse ) {
+			SDL_SetError("Unable to open mouse");
+			FB_VideoQuit(this);
+			return(-1);
+		}
+	}
+
+	/* We're done! */
+	return(0);
+}
+
+static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
+}
+
+/* Various screen update functions available */
+static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+#ifdef VGA16_FBCON_SUPPORT
+static void FB_VGA16Update(_THIS, int numrects, SDL_Rect *rects);
+#endif
+
+#ifdef FBCON_DEBUG
+static void print_vinfo(struct fb_var_screeninfo *vinfo)
+{
+	fprintf(stderr, "Printing vinfo:\n");
+	fprintf(stderr, "\txres: %d\n", vinfo->xres);
+	fprintf(stderr, "\tyres: %d\n", vinfo->yres);
+	fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual);
+	fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual);
+	fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset);
+	fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset);
+	fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel);
+	fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale);
+	fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd);
+	fprintf(stderr, "\tactivate: %d\n", vinfo->activate);
+	fprintf(stderr, "\theight: %d\n", vinfo->height);
+	fprintf(stderr, "\twidth: %d\n", vinfo->width);
+	fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags);
+	fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock);
+	fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin);
+	fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin);
+	fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin);
+	fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin);
+	fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len);
+	fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len);
+	fprintf(stderr, "\tsync: %d\n", vinfo->sync);
+	fprintf(stderr, "\tvmode: %d\n", vinfo->vmode);
+	fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset);
+	fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length, vinfo->green.offset);
+	fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length, vinfo->blue.offset);
+	fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length, vinfo->transp.offset);
+}
+static void print_finfo(struct fb_fix_screeninfo *finfo)
+{
+	fprintf(stderr, "Printing finfo:\n");
+	fprintf(stderr, "\tsmem_start = %p\n", (char *)finfo->smem_start);
+	fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len);
+	fprintf(stderr, "\ttype = %d\n", finfo->type);
+	fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux);
+	fprintf(stderr, "\tvisual = %d\n", finfo->visual);
+	fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep);
+	fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep);
+	fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep);
+	fprintf(stderr, "\tline_length = %d\n", finfo->line_length);
+	fprintf(stderr, "\tmmio_start = %p\n", (char *)finfo->mmio_start);
+	fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len);
+	fprintf(stderr, "\taccel = %d\n", finfo->accel);
+}
+#endif
+
+static int choose_fbmodes_mode(struct fb_var_screeninfo *vinfo)
+{
+	int matched;
+	FILE *fbmodes;
+
+	matched = 0;
+	fbmodes = fopen("/etc/fb.modes", "r");
+	if ( fbmodes ) {
+		/* FIXME: Parse the mode definition file */
+		fclose(fbmodes);
+	}
+	return(matched);
+}
+
+static int choose_vesa_mode(struct fb_var_screeninfo *vinfo)
+{
+	int matched;
+	int i;
+
+	/* Check for VESA timings */
+	matched = 0;
+	for ( i=0; i<(sizeof(vesa_timings)/sizeof(vesa_timings[0])); ++i ) {
+		if ( (vinfo->xres == vesa_timings[i].xres) &&
+		     (vinfo->yres == vesa_timings[i].yres) ) {
+#ifdef FBCON_DEBUG
+			fprintf(stderr, "Using VESA timings for %dx%d\n",
+						vinfo->xres, vinfo->yres);
+#endif
+			if ( vesa_timings[i].pixclock ) {
+				vinfo->pixclock = vesa_timings[i].pixclock;
+			}
+			vinfo->left_margin = vesa_timings[i].left;
+			vinfo->right_margin = vesa_timings[i].right;
+			vinfo->upper_margin = vesa_timings[i].upper;
+			vinfo->lower_margin = vesa_timings[i].lower;
+			vinfo->hsync_len = vesa_timings[i].hslen;
+			vinfo->vsync_len = vesa_timings[i].vslen;
+			vinfo->sync = vesa_timings[i].sync;
+			vinfo->vmode = vesa_timings[i].vmode;
+			matched = 1;
+			break;
+		}
+	}
+	return(matched);
+}
+
+#ifdef VGA16_FBCON_SUPPORT
+static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+
+	/* Set the terminal into graphics mode */
+	if ( FB_EnterGraphicsMode(this) < 0 ) {
+		return(NULL);
+	}
+
+	/* Restore the original palette */
+	FB_RestorePalette(this);
+
+	/* Set the video mode and get the final screen format */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console screen info");
+		return(NULL);
+	}
+	cache_vinfo = vinfo;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual vinfo:\n");
+	print_vinfo(&vinfo);
+#endif
+	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
+		return(NULL);
+	}
+    current->format->palette->ncolors = 16;
+
+	/* Get the fixed information about the console hardware.
+	   This is necessary since finfo.line_length changes.
+	 */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		return(NULL);
+	}
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual finfo:\n");
+	print_finfo(&finfo);
+#endif
+
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+
+	/* Set up the new mode framebuffer */
+	current->flags = SDL_FULLSCREEN;
+	current->w = vinfo.xres;
+	current->h = vinfo.yres;
+	current->pitch = current->w;
+	current->pixels = malloc(current->h*current->pitch);
+
+	/* Set the update rectangle function */
+	this->UpdateRects = FB_VGA16Update;
+
+	/* We're done */
+	return(current);
+}
+#endif /* VGA16_FBCON_SUPPORT */
+
+static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+	int i;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	char *surfaces_mem;
+	int surfaces_len;
+
+	/* Set the terminal into graphics mode */
+	if ( FB_EnterGraphicsMode(this) < 0 ) {
+		return(NULL);
+	}
+
+	/* Restore the original palette */
+	FB_RestorePalette(this);
+
+	/* Set the video mode and get the final screen format */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console screen info");
+		return(NULL);
+	}
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing original vinfo:\n");
+	print_vinfo(&vinfo);
+#endif
+	if ( (vinfo.xres != width) || (vinfo.yres != height) ||
+	     (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF) ) {
+		vinfo.activate = FB_ACTIVATE_NOW;
+		vinfo.accel_flags = 0;
+		vinfo.bits_per_pixel = bpp;
+		vinfo.xres = width;
+		vinfo.xres_virtual = width;
+		vinfo.yres = height;
+		if ( flags & SDL_DOUBLEBUF ) {
+			vinfo.yres_virtual = height*2;
+		} else {
+			vinfo.yres_virtual = height;
+		}
+		vinfo.xoffset = 0;
+		vinfo.yoffset = 0;
+		vinfo.red.length = vinfo.red.offset = 0;
+		vinfo.green.length = vinfo.green.offset = 0;
+		vinfo.blue.length = vinfo.blue.offset = 0;
+		vinfo.transp.length = vinfo.transp.offset = 0;
+		if ( ! choose_fbmodes_mode(&vinfo) ) {
+			choose_vesa_mode(&vinfo);
+		}
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "Printing wanted vinfo:\n");
+		print_vinfo(&vinfo);
+#endif
+		if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
+			vinfo.yres_virtual = height;
+			if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
+				SDL_SetError("Couldn't set console screen info");
+				return(NULL);
+			}
+		}
+	}
+	cache_vinfo = vinfo;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual vinfo:\n");
+	print_vinfo(&vinfo);
+#endif
+	Rmask = 0;
+	for ( i=0; i<vinfo.red.length; ++i ) {
+		Rmask <<= 1;
+		Rmask |= (0x00000001<<vinfo.red.offset);
+	}
+	Gmask = 0;
+	for ( i=0; i<vinfo.green.length; ++i ) {
+		Gmask <<= 1;
+		Gmask |= (0x00000001<<vinfo.green.offset);
+	}
+	Bmask = 0;
+	for ( i=0; i<vinfo.blue.length; ++i ) {
+		Bmask <<= 1;
+		Bmask |= (0x00000001<<vinfo.blue.offset);
+	}
+	if ( ! SDL_ReallocFormat(current, vinfo.bits_per_pixel,
+	                                  Rmask, Gmask, Bmask, 0) ) {
+		return(NULL);
+	}
+
+	/* Get the fixed information about the console hardware.
+	   This is necessary since finfo.line_length changes.
+	 */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		return(NULL);
+	}
+
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+
+	/* Set up the new mode framebuffer */
+	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
+	current->w = vinfo.xres;
+	current->h = vinfo.yres;
+	current->pitch = finfo.line_length;
+	current->pixels = mapped_mem+mapped_offset;
+
+	/* Let the application know we have a hardware palette */
+	switch (finfo.visual) {
+	    case FB_VISUAL_PSEUDOCOLOR:
+		current->flags |= SDL_HWPALETTE;
+		break;
+	    default:
+		break;
+	}
+
+	/* Update for double-buffering, if we can */
+	if ( flags & SDL_DOUBLEBUF ) {
+		if ( vinfo.yres_virtual == (height*2) ) {
+			current->flags |= SDL_DOUBLEBUF;
+			flip_page = 0;
+			flip_address[0] = (char *)current->pixels;
+			flip_address[1] = (char *)current->pixels+
+			                          current->h*current->pitch;
+			FB_FlipHWSurface(this, current);
+		}
+	}
+
+	/* Set up the information for hardware surfaces */
+	surfaces_mem = (char *)current->pixels +
+	                        vinfo.yres_virtual*current->pitch;
+	surfaces_len = (mapped_memlen-(surfaces_mem-mapped_mem));
+	FB_FreeHWSurfaces(this);
+	FB_InitHWSurfaces(this, surfaces_mem, surfaces_len);
+
+	/* Set the update rectangle function */
+	this->UpdateRects = FB_DirectUpdate;
+
+	/* We're done */
+	return(current);
+}
+
+#ifdef FBCON_DEBUG
+void FB_DumpHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket;
+
+	printf("Memory left: %d (%d total)\n", surfaces_memleft, surfaces_memtotal);
+	printf("\n");
+	printf("         Base  Size\n");
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		printf("Bucket:  %p, %d (%s)\n", bucket->base, bucket->size, bucket->used ? "used" : "free");
+		if ( bucket->prev ) {
+			if ( bucket->base != bucket->prev->base+bucket->prev->size ) {
+				printf("Warning, corrupt bucket list! (prev)\n");
+			}
+		} else {
+			if ( bucket != &surfaces ) {
+				printf("Warning, corrupt bucket list! (!prev)\n");
+			}
+		}
+		if ( bucket->next ) {
+			if ( bucket->next->base != bucket->base+bucket->size ) {
+				printf("Warning, corrupt bucket list! (next)\n");
+			}
+		}
+	}
+	printf("\n");
+}
+#endif
+
+static int FB_InitHWSurfaces(_THIS, char *base, int size)
+{
+	surfaces.prev = NULL;
+	surfaces.used = 0;
+	surfaces.base = base;
+	surfaces.size = size;
+	surfaces.next = NULL;
+	surfaces_memtotal = size;
+	surfaces_memleft = size;
+	return(0);
+}
+static void FB_FreeHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	bucket = surfaces.next;
+	while ( bucket ) {
+		freeable = bucket;
+		bucket = bucket->next;
+		free(freeable);
+	}
+	surfaces.next = NULL;
+}
+
+static int FB_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket;
+	int size;
+	int extra;
+
+/* Temporarily, we only allow surfaces the same width as display.
+   Some blitters require the pitch between two hardware surfaces
+   to be the same.  Others have interesting alignment restrictions.
+   Until someone who knows these details looks at the code...
+*/
+if ( surface->pitch > SDL_VideoSurface->pitch ) {
+	SDL_SetError("Surface requested wider than screen");
+	return(-1);
+}
+surface->pitch = SDL_VideoSurface->pitch;
+	size = surface->h * surface->pitch;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Allocating bucket of %d bytes\n", size);
+#endif
+
+	/* Quick check for available mem */
+	if ( size > surfaces_memleft ) {
+		SDL_SetError("Not enough video memory");
+		return(-1);
+	}
+
+	/* Search for an empty bucket big enough */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( ! bucket->used && (size <= bucket->size) ) {
+			break;
+		}
+	}
+	if ( bucket == NULL ) {
+		SDL_SetError("Video memory too fragmented");
+		return(-1);
+	}
+
+	/* Create a new bucket for left-over memory */
+	extra = (bucket->size - size);
+	if ( extra ) {
+		vidmem_bucket *newbucket;
+
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
+#endif
+		newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket));
+		if ( newbucket == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		newbucket->prev = bucket;
+		newbucket->used = 0;
+		newbucket->base = bucket->base+size;
+		newbucket->size = extra;
+		newbucket->next = bucket->next;
+		if ( bucket->next ) {
+			bucket->next->prev = newbucket;
+		}
+		bucket->next = newbucket;
+	}
+
+	/* Set the current bucket values and return it! */
+	bucket->used = 1;
+	bucket->size = size;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
+#endif
+	surfaces_memleft -= size;
+	surface->flags |= SDL_HWSURFACE;
+	surface->pixels = bucket->base;
+	return(0);
+}
+static void FB_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	/* Look for the bucket in the current list */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( bucket->base == (char *)surface->pixels ) {
+			break;
+		}
+	}
+	if ( (bucket == NULL) || ! bucket->used ) {
+		return;
+	}
+
+	/* Add the memory back to the total */
+#ifdef FBCON_DEBUG
+	printf("Freeing bucket of %d bytes\n", bucket->size);
+#endif
+	surfaces_memleft += bucket->size;
+
+	/* Can we merge the space with surrounding buckets? */
+	bucket->used = 0;
+	if ( bucket->next && ! bucket->next->used ) {
+#ifdef FBCON_DEBUG
+	printf("Merging with next bucket, for %d total bytes\n", bucket->size+bucket->next->size);
+#endif
+		freeable = bucket->next;
+		bucket->size += bucket->next->size;
+		bucket->next = bucket->next->next;
+		if ( bucket->next ) {
+			bucket->next->prev = bucket;
+		}
+		free(freeable);
+	}
+	if ( bucket->prev && ! bucket->prev->used ) {
+#ifdef FBCON_DEBUG
+	printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size);
+#endif
+		freeable = bucket;
+		bucket->prev->size += bucket->size;
+		bucket->prev->next = bucket->next;
+		if ( bucket->next ) {
+			bucket->next->prev = bucket->prev;
+		}
+		free(freeable);
+	}
+	surface->pixels = NULL;
+}
+static int FB_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		SDL_mutexP(hw_lock);
+	}
+	return(0);
+}
+static void FB_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == SDL_VideoSurface ) {
+		SDL_mutexV(hw_lock);
+	}
+}
+
+static void FB_WaitVBL(_THIS)
+{
+#ifdef FBIOWAITRETRACE /* Heheh, this didn't make it into the main kernel */
+	ioctl(console_fd, FBIOWAITRETRACE, 0);
+#endif
+	return;
+}
+
+static int FB_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	/* Wait for vertical retrace and then flip display */
+	cache_vinfo.yoffset = flip_page*surface->h;
+	wait_vbl(this);
+	if ( ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0 ) {
+		SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed");
+		return(-1);
+	}
+	flip_page = !flip_page;
+
+	surface->pixels = flip_address[flip_page];
+	return(0);
+}
+
+static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	/* The application is already updating the visible video memory */
+	return;
+}
+
+#ifdef VGA16_FBCON_SUPPORT
+/* Code adapted with thanks from the XFree86 VGA16 driver! :) */
+#define writeGr(index, value) \
+outb(index, 0x3CE);           \
+outb(value, 0x3CF);
+#define writeSeq(index, value) \
+outb(index, 0x3C4);            \
+outb(value, 0x3C5);
+
+static void FB_VGA16Update(_THIS, int numrects, SDL_Rect *rects)
+{
+    SDL_Surface *screen;
+    int width, height, FBPitch, left, i, j, SRCPitch, phase;
+    register Uint32 m;
+    Uint8  s1, s2, s3, s4;
+    Uint32 *src, *srcPtr;
+    Uint8  *dst, *dstPtr;
+
+    screen = this->screen;
+    FBPitch = screen->w >> 3;
+    SRCPitch = screen->pitch >> 2;
+
+    writeGr(0x03, 0x00);
+    writeGr(0x05, 0x00);
+    writeGr(0x01, 0x00);
+    writeGr(0x08, 0xFF);
+
+    while(numrects--) {
+	left = rects->x & ~7;
+        width = (rects->w + 7) >> 3;
+        height = rects->h;
+        src = (Uint32*)screen->pixels + (rects->y * SRCPitch) + (left >> 2); 
+        dst = (Uint8*)mapped_mem + (rects->y * FBPitch) + (left >> 3);
+
+	if((phase = (long)dst & 3L)) {
+	    phase = 4 - phase;
+	    if(phase > width) phase = width;
+	    width -= phase;
+	}
+
+        while(height--) {
+	    writeSeq(0x02, 1 << 0);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		*dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		s1 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[3] & 0x01010101) | ((srcPtr[2] & 0x01010101) << 4);
+ 		s2 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[5] & 0x01010101) | ((srcPtr[4] & 0x01010101) << 4);
+ 		s3 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[7] & 0x01010101) | ((srcPtr[6] & 0x01010101) << 4);
+ 		s4 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		*dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		srcPtr += 2;
+	    }
+
+	    writeSeq(0x02, 1 << 1);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		*dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		s1 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[3] & 0x02020202) | ((srcPtr[2] & 0x02020202) << 4);
+ 		s2 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[5] & 0x02020202) | ((srcPtr[4] & 0x02020202) << 4);
+ 		s3 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[7] & 0x02020202) | ((srcPtr[6] & 0x02020202) << 4);
+ 		s4 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		*dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		srcPtr += 2;
+	    }
+
+	    writeSeq(0x02, 1 << 2);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		*dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		s1 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[3] & 0x04040404) | ((srcPtr[2] & 0x04040404) << 4);
+ 		s2 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[5] & 0x04040404) | ((srcPtr[4] & 0x04040404) << 4);
+ 		s3 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[7] & 0x04040404) | ((srcPtr[6] & 0x04040404) << 4);
+ 		s4 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		*dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		srcPtr += 2;
+	    }
+	    
+	    writeSeq(0x02, 1 << 3);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		*dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		s1 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[3] & 0x08080808) | ((srcPtr[2] & 0x08080808) << 4);
+ 		s2 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[5] & 0x08080808) | ((srcPtr[4] & 0x08080808) << 4);
+ 		s3 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[7] & 0x08080808) | ((srcPtr[6] & 0x08080808) << 4);
+ 		s4 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		*dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		srcPtr += 2;
+	    }
+
+            dst += FBPitch;
+            src += SRCPitch;
+        }
+        rects++;
+    }
+}
+#endif /* VGA16_FBCON_SUPPORT */
+
+void FB_SavePaletteTo(_THIS, int palette_len, __u16 *area)
+{
+	struct fb_cmap cmap;
+
+	cmap.start = 0;
+	cmap.len = palette_len;
+	cmap.red = &area[0*palette_len];
+	cmap.green = &area[1*palette_len];
+	cmap.blue = &area[2*palette_len];
+	cmap.transp = NULL;
+	ioctl(console_fd, FBIOGETCMAP, &cmap);
+}
+
+void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 *area)
+{
+	struct fb_cmap cmap;
+
+	cmap.start = 0;
+	cmap.len = palette_len;
+	cmap.red = &area[0*palette_len];
+	cmap.green = &area[1*palette_len];
+	cmap.blue = &area[2*palette_len];
+	cmap.transp = NULL;
+	ioctl(console_fd, FBIOPUTCMAP, &cmap);
+}
+
+static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
+                                  struct fb_var_screeninfo *vinfo)
+{
+	int i;
+
+	/* Save hardware palette, if needed */
+	if ( finfo->visual == FB_VISUAL_PSEUDOCOLOR ) {
+		saved_cmaplen = 1<<vinfo->bits_per_pixel;
+		saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
+		if ( saved_cmap != NULL ) {
+			FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
+		}
+	}
+
+	/* Added support for FB_VISUAL_DIRECTCOLOR.
+	   With this mode pixel information is passed through the palette...
+	   Neat fading and gamma correction effects can be had by simply
+	   fooling around with the palette instead of changing the pixel
+	   values themselves... Very neat!
+
+	   Adam Meyerowitz 1/19/2000
+	   ameyerow@optonline.com
+	*/
+	if ( finfo->visual == FB_VISUAL_DIRECTCOLOR ) {
+		__u16 new_entries[3*256];
+
+		/* Save the colormap */
+		saved_cmaplen = 256;
+		saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
+		if ( saved_cmap != NULL ) {
+			FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
+		}
+
+		/* Allocate new identity colormap */
+		for ( i=0; i<256; ++i ) {
+	      		new_entries[(0*256)+i] =
+			new_entries[(1*256)+i] =
+			new_entries[(2*256)+i] = (i<<8)|i;
+		}
+		FB_RestorePaletteFrom(this, 256, new_entries);
+	}
+}
+
+static void FB_RestorePalette(_THIS)
+{
+	/* Restore the original palette */
+	if ( saved_cmap ) {
+		FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap);
+		free(saved_cmap);
+		saved_cmap = NULL;
+	}
+}
+
+static int FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+	__u16 r[256];
+	__u16 g[256];
+	__u16 b[256];
+	struct fb_cmap cmap;
+
+	/* Set up the colormap */
+	for (i = 0; i < ncolors; i++) {
+		r[i] = colors[i].r << 8;
+		g[i] = colors[i].g << 8;
+		b[i] = colors[i].b << 8;
+	}
+	cmap.start = firstcolor;
+	cmap.len = ncolors;
+	cmap.red = r;
+	cmap.green = g;
+	cmap.blue = b;
+	cmap.transp = NULL;
+
+	if( (ioctl(console_fd, FBIOPUTCMAP, &cmap) < 0) ||
+	    !(this->screen->flags & SDL_HWPALETTE) ) {
+	        colors = this->screen->format->palette->colors;
+		ncolors = this->screen->format->palette->ncolors;
+		cmap.start = 0;
+		cmap.len = ncolors;
+		memset(r, 0, sizeof(r));
+		memset(g, 0, sizeof(g));
+		memset(b, 0, sizeof(b));
+		if ( ioctl(console_fd, FBIOGETCMAP, &cmap) == 0 ) {
+			for ( i=ncolors-1; i>=0; --i ) {
+				colors[i].r = (r[i]>>8);
+				colors[i].g = (g[i]>>8);
+				colors[i].b = (b[i]>>8);
+			}
+		}
+		return(0);
+	}
+	return(1);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+static void FB_VideoQuit(_THIS)
+{
+	int i, j;
+
+	if ( this->screen ) {
+		/* Clear screen and tell SDL not to free the pixels */
+		if ( this->screen->pixels && FB_InGraphicsMode(this) ) {
+#ifdef __powerpc__	/* SIGBUS when using memset() ?? */
+			Uint8 *rowp = (Uint8 *)this->screen->pixels;
+			int left = this->screen->pitch*this->screen->h;
+			while ( left-- ) { *rowp++ = 0; }
+#else
+			memset(this->screen->pixels,0,this->screen->h*this->screen->pitch);
+#endif
+		}
+		/* This test fails when using the VGA16 shadow memory */
+		if ( ((char *)this->screen->pixels >= mapped_mem) &&
+		     ((char *)this->screen->pixels < (mapped_mem+mapped_memlen)) ) {
+			this->screen->pixels = NULL;
+		}
+	}
+
+	/* Clear the lock mutex */
+	if ( hw_lock ) {
+		SDL_DestroyMutex(hw_lock);
+		hw_lock = NULL;
+	}
+
+	/* Clean up defined video modes */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_modelist[i] != NULL ) {
+			for ( j=0; SDL_modelist[i][j]; ++j ) {
+				free(SDL_modelist[i][j]);
+			}
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+	}
+
+	/* Clean up the memory bucket list */
+	FB_FreeHWSurfaces(this);
+
+	/* Close console and input file descriptors */
+	if ( console_fd > 0 ) {
+		/* Unmap the video framebuffer and I/O registers */
+		if ( mapped_mem ) {
+			munmap(mapped_mem, mapped_memlen);
+			mapped_mem = NULL;
+		}
+		if ( mapped_io ) {
+			munmap(mapped_io, mapped_iolen);
+			mapped_io = NULL;
+		}
+
+		/* Restore the original video mode and palette */
+		if ( FB_InGraphicsMode(this) ) {
+			FB_RestorePalette(this);
+			ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo);
+		}
+
+		/* We're all done with the framebuffer */
+		close(console_fd);
+		console_fd = -1;
+	}
+	FB_CloseMouse(this);
+	FB_CloseKeyboard(this);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/SDL_fbvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,135 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_fbvideo_h
+#define _SDL_fbvideo_h
+
+#include <sys/types.h>
+#include <termios.h>
+#include <linux/fb.h>
+
+#include "SDL_mouse.h"
+#include "SDL_mutex.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+
+/* This is the structure we use to keep track of video memory */
+typedef struct vidmem_bucket {
+	struct vidmem_bucket *prev;
+	unsigned int used;
+	char *base;
+	unsigned int size;
+	struct vidmem_bucket *next;
+} vidmem_bucket;
+
+/* Information about the location of the surface in hardware memory */
+struct private_hwdata {
+	int x;
+	int y;
+};
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+	int console_fd;
+	struct fb_var_screeninfo cache_vinfo;
+	struct fb_var_screeninfo saved_vinfo;
+	int saved_cmaplen;
+	__u16 *saved_cmap;
+
+	int current_vt;
+	int saved_vt;
+	int keyboard_fd;
+	int saved_kbd_mode;
+	struct termios saved_kbd_termios;
+
+	int mouse_fd;
+
+	char *mapped_mem;
+	int mapped_memlen;
+	int mapped_offset;
+	char *mapped_io;
+	long mapped_iolen;
+	int flip_page;
+	char *flip_address[2];
+
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+	int SDL_nummodes[NUM_MODELISTS];
+	SDL_Rect **SDL_modelist[NUM_MODELISTS];
+
+	vidmem_bucket surfaces;
+	int surfaces_memtotal;
+	int surfaces_memleft;
+
+	SDL_mutex *hw_lock;
+
+	void (*wait_vbl)(_THIS);
+};
+/* Old variable names */
+#define console_fd		(this->hidden->console_fd)
+#define current_vt		(this->hidden->current_vt)
+#define saved_vt		(this->hidden->saved_vt)
+#define keyboard_fd		(this->hidden->keyboard_fd)
+#define saved_kbd_mode		(this->hidden->saved_kbd_mode)
+#define saved_kbd_termios	(this->hidden->saved_kbd_termios)
+#define mouse_fd		(this->hidden->mouse_fd)
+#define cache_vinfo		(this->hidden->cache_vinfo)
+#define saved_vinfo		(this->hidden->saved_vinfo)
+#define saved_cmaplen		(this->hidden->saved_cmaplen)
+#define saved_cmap		(this->hidden->saved_cmap)
+#define mapped_mem		(this->hidden->mapped_mem)
+#define mapped_memlen		(this->hidden->mapped_memlen)
+#define mapped_offset		(this->hidden->mapped_offset)
+#define mapped_io		(this->hidden->mapped_io)
+#define mapped_iolen		(this->hidden->mapped_iolen)
+#define flip_page		(this->hidden->flip_page)
+#define flip_address		(this->hidden->flip_address)
+#define SDL_nummodes		(this->hidden->SDL_nummodes)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define surfaces		(this->hidden->surfaces)
+#define surfaces_memtotal	(this->hidden->surfaces_memtotal)
+#define surfaces_memleft	(this->hidden->surfaces_memleft)
+#define hw_lock			(this->hidden->hw_lock)
+#define wait_vbl		(this->hidden->wait_vbl)
+
+/* Accelerator types that are supported by the driver, but are not
+   necessarily in the kernel headers on the system we compile on.
+*/
+#ifndef FB_ACCEL_MATROX_MGAG400
+#define FB_ACCEL_MATROX_MGAG400	26	/* Matrox G400			*/
+#endif
+#ifndef FB_ACCEL_3DFX_BANSHEE
+#define FB_ACCEL_3DFX_BANSHEE	31	/* 3Dfx Banshee			*/
+#endif
+
+/* These functions are defined in SDL_fbvideo.c */
+extern void FB_SavePaletteTo(_THIS, int palette_len, __u16 *area);
+extern void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 *area);
+
+#endif /* _SDL_fbvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/matrox_mmio.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,55 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* MGA register definitions */
+
+#include "matrox_regs.h"
+
+/* MGA control macros */
+
+#define mga_in8(reg)		*(volatile Uint8  *)(mapped_io + (reg))
+#define mga_in32(reg)		*(volatile Uint32 *)(mapped_io + (reg))
+
+#define mga_out8(reg,v)		*(volatile Uint8  *)(mapped_io + (reg)) = v;
+#define mga_out32(reg,v)	*(volatile Uint32 *)(mapped_io + (reg)) = v;
+
+
+/* Wait for fifo space */
+#define mga_wait(space)							\
+{									\
+	while ( mga_in8(MGAREG_FIFOSTATUS) < space )			\
+		;							\
+}
+
+
+/* Wait for idle accelerator */
+#define mga_waitidle()							\
+{									\
+	while ( mga_in32(MGAREG_STATUS) & 0x10000 )			\
+		;							\
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/fbcon/matrox_regs.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,376 @@
+
+/*
+ * MGA Millennium (MGA2064W) functions
+ * MGA Mystique (MGA1064SG) functions
+ *
+ * Copyright 1996 The XFree86 Project, Inc.
+ *
+ * Authors
+ *		Dirk Hohndel
+ *			hohndel@XFree86.Org
+ *		David Dawes
+ *			dawes@XFree86.Org
+ * Contributors:
+ *		Guy DESBIEF, Aix-en-provence, France
+ *			g.desbief@aix.pacwan.net
+ *		MGA1064SG Mystique register file
+ */
+  
+
+#ifndef _MGA_REG_H_
+#define _MGA_REG_H_
+
+#define	MGAREG_DWGCTL		0x1c00
+#define	MGAREG_MACCESS		0x1c04
+/* the following is a mystique only register */
+#define MGAREG_MCTLWTST		0x1c08
+#define	MGAREG_ZORG		0x1c0c
+
+#define	MGAREG_PAT0		0x1c10
+#define	MGAREG_PAT1		0x1c14
+#define	MGAREG_PLNWT		0x1c1c
+
+#define	MGAREG_BCOL		0x1c20
+#define	MGAREG_FCOL		0x1c24
+
+#define	MGAREG_SRC0		0x1c30
+#define	MGAREG_SRC1		0x1c34
+#define	MGAREG_SRC2		0x1c38
+#define	MGAREG_SRC3		0x1c3c
+
+#define	MGAREG_XYSTRT		0x1c40
+#define	MGAREG_XYEND		0x1c44
+
+#define	MGAREG_SHIFT		0x1c50
+/* the following is a mystique only register */
+#define MGAREG_DMAPAD		0x1c54
+#define	MGAREG_SGN		0x1c58
+#define	MGAREG_LEN		0x1c5c
+
+#define	MGAREG_AR0		0x1c60
+#define	MGAREG_AR1		0x1c64
+#define	MGAREG_AR2		0x1c68
+#define	MGAREG_AR3		0x1c6c
+#define	MGAREG_AR4		0x1c70
+#define	MGAREG_AR5		0x1c74
+#define	MGAREG_AR6		0x1c78
+
+#define	MGAREG_CXBNDRY		0x1c80
+#define	MGAREG_FXBNDRY		0x1c84
+#define	MGAREG_YDSTLEN		0x1c88
+#define	MGAREG_PITCH		0x1c8c
+
+#define	MGAREG_YDST		0x1c90
+#define	MGAREG_YDSTORG		0x1c94
+#define	MGAREG_YTOP		0x1c98
+#define	MGAREG_YBOT		0x1c9c
+
+#define	MGAREG_CXLEFT		0x1ca0
+#define	MGAREG_CXRIGHT		0x1ca4
+#define	MGAREG_FXLEFT		0x1ca8
+#define	MGAREG_FXRIGHT		0x1cac
+
+#define	MGAREG_XDST		0x1cb0
+
+#define	MGAREG_DR0		0x1cc0
+#define	MGAREG_DR1		0x1cc4
+#define	MGAREG_DR2		0x1cc8
+#define	MGAREG_DR3		0x1ccc
+
+#define	MGAREG_DR4		0x1cd0
+#define	MGAREG_DR5		0x1cd4
+#define	MGAREG_DR6		0x1cd8
+#define	MGAREG_DR7		0x1cdc
+
+#define	MGAREG_DR8		0x1ce0
+#define	MGAREG_DR9		0x1ce4
+#define	MGAREG_DR10		0x1ce8
+#define	MGAREG_DR11		0x1cec
+
+#define	MGAREG_DR12		0x1cf0
+#define	MGAREG_DR13		0x1cf4
+#define	MGAREG_DR14		0x1cf8
+#define	MGAREG_DR15		0x1cfc
+
+#define MGAREG_SRCORG		0x2cb4
+#define MGAREG_DSTORG		0x2cb8
+
+/* add or or this to one of the previous "power registers" to start
+   the drawing engine */
+
+#define MGAREG_EXEC		0x0100
+
+#define	MGAREG_FIFOSTATUS	0x1e10
+#define	MGAREG_STATUS		0x1e14
+#define	MGAREG_ICLEAR		0x1e18
+#define	MGAREG_IEN		0x1e1c
+
+#define	MGAREG_VCOUNT		0x1e20
+
+#define	MGAREG_Reset		0x1e40
+
+#define	MGAREG_OPMODE		0x1e54
+
+/* OPMODE register additives */
+
+#define MGAOPM_DMA_GENERAL	(0x00 << 2)
+#define MGAOPM_DMA_BLIT		(0x01 << 2)
+#define MGAOPM_DMA_VECTOR	(0x10 << 2)
+
+/* DWGCTL register additives */
+
+/* Lines */
+
+#define MGADWG_LINE_OPEN	0x00
+#define MGADWG_AUTOLINE_OPEN	0x01
+#define MGADWG_LINE_CLOSE	0x02
+#define MGADWG_AUTOLINE_CLOSE	0x03
+
+/* Trapezoids */
+#define MGADWG_TRAP		0x04
+#define MGADWG_TEXTURE_TRAP	0x05
+
+/* BitBlts */
+
+#define MGADWG_BITBLT		0x08
+#define MGADWG_FBITBLT		0x0c
+#define MGADWG_ILOAD		0x09
+#define MGADWG_ILOAD_SCALE	0x0d
+#define MGADWG_ILOAD_FILTER	0x0f
+#define MGADWG_IDUMP		0x0a
+
+/* atype access to WRAM */
+
+#define MGADWG_RPL		( 0x00 << 4 )
+#define MGADWG_RSTR		( 0x01 << 4 )
+#define MGADWG_ZI		( 0x03 << 4 )
+#define MGADWG_BLK 		( 0x04 << 4 )
+#define MGADWG_I		( 0x07 << 4 )
+
+/* specifies whether bit blits are linear or xy */
+#define MGADWG_LINEAR		( 0x01 << 7 )
+
+/* z drawing mode. use MGADWG_NOZCMP for always */
+
+#define MGADWG_NOZCMP		( 0x00 << 8 )
+#define MGADWG_ZE		( 0x02 << 8 ) 
+#define MGADWG_ZNE		( 0x03 << 8 )
+#define MGADWG_ZLT		( 0x04 << 8 )
+#define MGADWG_ZLTE		( 0x05 << 8 )
+#define MGADWG_GT		( 0x06 << 8 )
+#define MGADWG_GTE		( 0x07 << 8 )
+
+/* use this to force colour expansion circuitry to do its stuff */
+
+#define MGADWG_SOLID		( 0x01 << 11 )
+
+/* ar register at zero */
+
+#define MGADWG_ARZERO		( 0x01 << 12 )
+
+#define MGADWG_SGNZERO		( 0x01 << 13 )
+
+#define MGADWG_SHIFTZERO	( 0x01 << 14 )
+
+/* See table on 4-43 for bop ALU operations */
+
+/* See table on 4-44 for translucidity masks */
+
+#define MGADWG_BMONOLEF		( 0x00 << 25 )
+#define MGADWG_BMONOWF		( 0x04 << 25 )
+#define MGADWG_BPLAN		( 0x01 << 25 )
+
+/* note that if bfcol is specified and you're doing a bitblt, it causes
+   a fbitblt to be performed, so check that you obey the fbitblt rules */
+
+#define MGADWG_BFCOL   		( 0x02 << 25 )
+#define MGADWG_BUYUV		( 0x0e << 25 )
+#define MGADWG_BU32BGR		( 0x03 << 25 )
+#define MGADWG_BU32RGB		( 0x07 << 25 )
+#define MGADWG_BU24BGR		( 0x0b << 25 )
+#define MGADWG_BU24RGB		( 0x0f << 25 )
+
+#define MGADWG_REPLACE		0x000C0000	/* From Linux kernel sources */
+#define MGADWG_PATTERN		( 0x01 << 29 )
+#define MGADWG_TRANSC		( 0x01 << 30 )
+#define MGADWG_NOCLIP		( 0x01 << 31 )
+#define MGAREG_MISC_WRITE	0x3c2
+#define MGAREG_MISC_READ	0x3cc
+#define MGAREG_MISC_IOADSEL	(0x1 << 0)
+#define MGAREG_MISC_RAMMAPEN	(0x1 << 1)
+#define MGAREG_MISC_CLK_SEL_VGA25	(0x0 << 2)
+#define MGAREG_MISC_CLK_SEL_VGA28	(0x1 << 2)
+#define MGAREG_MISC_CLK_SEL_MGA_PIX	(0x2 << 2)
+#define MGAREG_MISC_CLK_SEL_MGA_MSK	(0x3 << 2)
+#define MGAREG_MISC_VIDEO_DIS	(0x1 << 4)
+#define MGAREG_MISC_HIGH_PG_SEL	(0x1 << 5)
+ 
+/* MMIO VGA registers */
+#define MGAREG_CRTC_INDEX	0x1fd4
+#define MGAREG_CRTC_DATA	0x1fd5
+#define MGAREG_CRTCEXT_INDEX	0x1fde
+#define MGAREG_CRTCEXT_DATA	0x1fdf
+
+
+/* MGA bits for registers PCI_OPTION_REG */
+#define MGA1064_OPT_SYS_CLK_PCI   		( 0x00 << 0 )
+#define MGA1064_OPT_SYS_CLK_PLL   		( 0x01 << 0 )
+#define MGA1064_OPT_SYS_CLK_EXT   		( 0x02 << 0 )
+#define MGA1064_OPT_SYS_CLK_MSK   		( 0x03 << 0 )
+
+#define MGA1064_OPT_SYS_CLK_DIS   		( 0x01 << 2 )
+#define MGA1064_OPT_G_CLK_DIV_1   		( 0x01 << 3 )
+#define MGA1064_OPT_M_CLK_DIV_1   		( 0x01 << 4 )
+
+#define MGA1064_OPT_SYS_PLL_PDN   		( 0x01 << 5 )
+#define MGA1064_OPT_VGA_ION   		( 0x01 << 8 )
+
+/* MGA registers in PCI config space */
+#define PCI_MGA_INDEX		0x44
+#define PCI_MGA_DATA		0x48
+#define PCI_MGA_OPTION2		0x50
+#define PCI_MGA_OPTION3		0x54
+
+#define RAMDAC_OFFSET		0x3c00
+
+/* TVP3026 direct registers */
+
+#define TVP3026_INDEX		0x00
+#define TVP3026_WADR_PAL	0x00
+#define TVP3026_COL_PAL		0x01
+#define TVP3026_PIX_RD_MSK	0x02
+#define TVP3026_RADR_PAL	0x03
+#define TVP3026_CUR_COL_ADDR	0x04
+#define TVP3026_CUR_COL_DATA	0x05
+#define TVP3026_DATA		0x0a
+#define TVP3026_CUR_RAM		0x0b
+#define TVP3026_CUR_XLOW	0x0c
+#define TVP3026_CUR_XHI		0x0d
+#define TVP3026_CUR_YLOW	0x0e
+#define TVP3026_CUR_YHI		0x0f
+
+/* TVP3026 indirect registers */
+
+#define TVP3026_SILICON_REV	0x01
+#define TVP3026_CURSOR_CTL	0x06
+#define TVP3026_LATCH_CTL	0x0f
+#define TVP3026_TRUE_COLOR_CTL	0x18
+#define TVP3026_MUX_CTL		0x19
+#define TVP3026_CLK_SEL		0x1a
+#define TVP3026_PAL_PAGE	0x1c
+#define TVP3026_GEN_CTL		0x1d
+#define TVP3026_MISC_CTL	0x1e
+#define TVP3026_GEN_IO_CTL	0x2a
+#define TVP3026_GEN_IO_DATA	0x2b
+#define TVP3026_PLL_ADDR	0x2c
+#define TVP3026_PIX_CLK_DATA	0x2d
+#define TVP3026_MEM_CLK_DATA	0x2e
+#define TVP3026_LOAD_CLK_DATA	0x2f
+#define TVP3026_KEY_RED_LOW	0x32
+#define TVP3026_KEY_RED_HI	0x33
+#define TVP3026_KEY_GREEN_LOW	0x34
+#define TVP3026_KEY_GREEN_HI	0x35
+#define TVP3026_KEY_BLUE_LOW	0x36
+#define TVP3026_KEY_BLUE_HI	0x37
+#define TVP3026_KEY_CTL		0x38
+#define TVP3026_MCLK_CTL	0x39
+#define TVP3026_SENSE_TEST	0x3a
+#define TVP3026_TEST_DATA	0x3b
+#define TVP3026_CRC_LSB		0x3c
+#define TVP3026_CRC_MSB		0x3d
+#define TVP3026_CRC_CTL		0x3e
+#define TVP3026_ID		0x3f
+#define TVP3026_RESET		0xff
+
+
+/* MGA1064 DAC Register file */
+/* MGA1064 direct registers */
+
+#define MGA1064_INDEX		0x00
+#define MGA1064_WADR_PAL	0x00
+#define MGA1064_COL_PAL		0x01
+#define MGA1064_PIX_RD_MSK	0x02
+#define MGA1064_RADR_PAL	0x03
+#define MGA1064_DATA		0x0a
+
+#define MGA1064_CUR_XLOW	0x0c
+#define MGA1064_CUR_XHI		0x0d
+#define MGA1064_CUR_YLOW	0x0e
+#define MGA1064_CUR_YHI		0x0f
+
+/* MGA1064 indirect registers */
+#define MGA1064_CURSOR_BASE_ADR_LOW	0x04
+#define MGA1064_CURSOR_BASE_ADR_HI	0x05
+#define MGA1064_CURSOR_CTL	0x06
+#define MGA1064_CURSOR_COL0_RED	0x08
+#define MGA1064_CURSOR_COL0_GREEN	0x09
+#define MGA1064_CURSOR_COL0_BLUE	0x0a
+
+#define MGA1064_CURSOR_COL1_RED	0x0c
+#define MGA1064_CURSOR_COL1_GREEN	0x0d
+#define MGA1064_CURSOR_COL1_BLUE	0x0e
+
+#define MGA1064_CURSOR_COL2_RED	0x010
+#define MGA1064_CURSOR_COL2_GREEN	0x011
+#define MGA1064_CURSOR_COL2_BLUE	0x012
+
+#define MGA1064_VREF_CTL	0x018
+
+#define MGA1064_MUL_CTL		0x19
+#define MGA1064_MUL_CTL_8bits		0x0
+#define MGA1064_MUL_CTL_15bits		0x01
+#define MGA1064_MUL_CTL_16bits		0x02
+#define MGA1064_MUL_CTL_24bits		0x03
+#define MGA1064_MUL_CTL_32bits		0x04
+#define MGA1064_MUL_CTL_2G8V16bits		0x05
+#define MGA1064_MUL_CTL_G16V16bits		0x06
+#define MGA1064_MUL_CTL_32_24bits		0x07
+
+#define MGAGDAC_XVREFCTRL		0x18
+#define MGA1064_PIX_CLK_CTL		0x1a
+#define MGA1064_PIX_CLK_CTL_CLK_DIS   		( 0x01 << 2 )
+#define MGA1064_PIX_CLK_CTL_CLK_POW_DOWN   	( 0x01 << 3 )
+#define MGA1064_PIX_CLK_CTL_SEL_PCI   		( 0x00 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_PLL   		( 0x01 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_EXT   		( 0x02 << 0 )
+#define MGA1064_PIX_CLK_CTL_SEL_MSK   		( 0x03 << 0 )
+
+#define MGA1064_GEN_CTL		0x1d
+#define MGA1064_MISC_CTL	0x1e
+#define MGA1064_MISC_CTL_DAC_POW_DN   		( 0x01 << 0 )
+#define MGA1064_MISC_CTL_VGA   		( 0x01 << 1 )
+#define MGA1064_MISC_CTL_DIS_CON   		( 0x03 << 1 )
+#define MGA1064_MISC_CTL_MAFC   		( 0x02 << 1 )
+#define MGA1064_MISC_CTL_VGA8   		( 0x01 << 3 )
+#define MGA1064_MISC_CTL_DAC_RAM_CS   		( 0x01 << 4 )
+
+#define MGA1064_GEN_IO_CTL	0x2a
+#define MGA1064_GEN_IO_DATA	0x2b
+#define MGA1064_SYS_PLL_M	0x2c
+#define MGA1064_SYS_PLL_N	0x2d
+#define MGA1064_SYS_PLL_P	0x2e
+#define MGA1064_SYS_PLL_STAT	0x2f
+#define MGA1064_ZOOM_CTL	0x38
+#define MGA1064_SENSE_TST	0x3a
+
+#define MGA1064_CRC_LSB		0x3c
+#define MGA1064_CRC_MSB		0x3d
+#define MGA1064_CRC_CTL		0x3e
+#define MGA1064_COL_KEY_MSK_LSB		0x40
+#define MGA1064_COL_KEY_MSK_MSB		0x41
+#define MGA1064_COL_KEY_LSB		0x42
+#define MGA1064_COL_KEY_MSB		0x43
+#define MGA1064_PIX_PLLA_M	0x44
+#define MGA1064_PIX_PLLA_N	0x45
+#define MGA1064_PIX_PLLA_P	0x46
+#define MGA1064_PIX_PLLB_M	0x48
+#define MGA1064_PIX_PLLB_N	0x49
+#define MGA1064_PIX_PLLB_P	0x4a
+#define MGA1064_PIX_PLLC_M	0x4c
+#define MGA1064_PIX_PLLC_N	0x4d
+#define MGA1064_PIX_PLLC_P	0x4e
+
+#define MGA1064_PIX_PLL_STAT	0x4f
+
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+
+## Makefile.am for SDL using the GGI video driver
+
+noinst_LTLIBRARIES = libvideo_ggi.la
+libvideo_ggi_la_SOURCES = $(GGI_SRCS)
+libvideo_ggi_la_LIBADD = -lggi -lgii -lgg
+
+# The SDL GGI video driver sources
+GGI_SRCS = 			\
+	SDL_ggikeys.h		\
+	SDL_ggivideo.h		\
+	SDL_ggievents.c		\
+	SDL_ggimouse.c		\
+	SDL_ggivideo.c		\
+	SDL_ggievents_c.h	\
+       	SDL_ggimouse_c.h	\
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggievents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,271 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting GGI events into SDL events */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+
+#include <ggi/keyboard.h>
+
+#include "SDL_ggikeys.h"
+
+#include "SDL.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_ggivideo.h"
+#include "SDL_ggievents_c.h"
+
+/* The translation tables from a GGI keycode to a SDL keysym */
+static SDLKey keymap[128];
+static SDL_keysym *GGI_TranslateKey(ggi_event *ev, SDL_keysym *keysym);
+
+static int posted = 0;
+
+void GGI_PumpEvents(_THIS)
+{
+	struct timeval *tvp, tv = { 0, 0 };
+	ggi_event ev;
+
+	tvp = &tv;
+	
+/*	ggiFlush(VIS); */
+	
+	while (ggiEventPoll(VIS, emAll, tvp))
+/*	while (ggiEventPoll(VIS, (emKeyboard | emPointer | emCommand), tvp)) */
+	{
+		int queueevent_mouse = 0, queueevent_kbd = 0;
+		static int buttons = 0;
+		static int mouse_x = 0, mouse_y = 0, mouse_z = 0;
+		int x = 0, y = 0, z = 0, rx = 0, ry = 0, rz = 0;
+		uint32 sym;
+		int pressed_mouse, pressed_kbd;
+		SDL_keysym keysym;
+		
+		posted = 0;
+
+		/* FIXME: We do not actually want all events, only
+		 * mouse and keyboard events.  Having to handle all
+                 * events will slow things down.  */
+
+		ggiEventRead(VIS, &ev, emAll);
+/*		ggiEventRead(VIS, &ev, (emKeyboard | emPointer | emCommand)); */
+		
+		switch (ev.any.type)
+		{
+			case evPtrRelative:
+			x = ev.pmove.x;
+			y = ev.pmove.y;
+			z = ev.pmove.wheel;
+			posted += SDL_PrivateMouseMotion(0, 1, x, y);
+			break;
+			case evPtrAbsolute:
+			if (mouse_x != ev.pmove.x || mouse_y != ev.pmove.y || mouse_z != ev.pmove.wheel)
+			{
+				x = ev.pmove.x - mouse_x;
+				y = ev.pmove.y - mouse_y;
+				z = ev.pmove.wheel - mouse_z;
+				mouse_x = ev.pmove.x;
+				mouse_y = ev.pmove.y;
+				mouse_z = ev.pmove.wheel;
+				posted += SDL_PrivateMouseMotion(0, 1, x, y);
+			} 
+			break;
+			case evPtrButtonPress:
+			posted += SDL_PrivateMouseButton(SDL_PRESSED, ev.pbutton.button, 0, 0);
+			break;
+			case evPtrButtonRelease:
+			posted += SDL_PrivateMouseButton(SDL_RELEASED, ev.pbutton.button, 0, 0);
+			break;
+			case evKeyPress:
+			case evKeyRepeat:
+			posted += SDL_PrivateKeyboard(SDL_PRESSED, GGI_TranslateKey(&ev, &keysym));
+			break;
+			case evKeyRelease:
+			posted += SDL_PrivateKeyboard(SDL_RELEASED, GGI_TranslateKey(&ev, &keysym));
+			break;
+			case evCommand:
+			fprintf(stderr, "Command event %x recieved\n", ev.cmd.code);
+			break;
+ 			default:
+			fprintf(stderr, "Unhandled event type %d\n", ev.any.type);
+			break;
+		}
+	}
+
+}
+
+void GGI_InitOSKeymap(_THIS)
+{
+	int i;
+	
+	/* Initialize the GGI key translation table */
+	for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+		keymap[i] = SDLK_UNKNOWN;
+	
+	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+	keymap[SCANCODE_1] = SDLK_1;
+	keymap[SCANCODE_2] = SDLK_2;
+	keymap[SCANCODE_3] = SDLK_3;
+	keymap[SCANCODE_4] = SDLK_4;
+	keymap[SCANCODE_5] = SDLK_5;
+	keymap[SCANCODE_6] = SDLK_6;
+	keymap[SCANCODE_7] = SDLK_7;
+	keymap[SCANCODE_8] = SDLK_8;
+	keymap[SCANCODE_9] = SDLK_9;
+	keymap[SCANCODE_0] = SDLK_0;
+	keymap[SCANCODE_MINUS] = SDLK_MINUS;
+	keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
+	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+	keymap[SCANCODE_TAB] = SDLK_TAB;
+	keymap[SCANCODE_Q] = SDLK_q;
+	keymap[SCANCODE_W] = SDLK_w;
+	keymap[SCANCODE_E] = SDLK_e;
+	keymap[SCANCODE_R] = SDLK_r;
+	keymap[SCANCODE_T] = SDLK_t;
+	keymap[SCANCODE_Y] = SDLK_y;
+	keymap[SCANCODE_U] = SDLK_u;
+	keymap[SCANCODE_I] = SDLK_i;
+	keymap[SCANCODE_O] = SDLK_o;
+	keymap[SCANCODE_P] = SDLK_p;
+	keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
+	keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
+	keymap[SCANCODE_ENTER] = SDLK_RETURN;
+	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+	keymap[SCANCODE_A] = SDLK_a;
+	keymap[SCANCODE_S] = SDLK_s;
+	keymap[SCANCODE_D] = SDLK_d;
+	keymap[SCANCODE_F] = SDLK_f;
+	keymap[SCANCODE_G] = SDLK_g;
+	keymap[SCANCODE_H] = SDLK_h;
+	keymap[SCANCODE_J] = SDLK_j;
+	keymap[SCANCODE_K] = SDLK_k;
+	keymap[SCANCODE_L] = SDLK_l;
+	keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
+	keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
+	keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
+	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+	keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
+	keymap[SCANCODE_Z] = SDLK_z;
+	keymap[SCANCODE_X] = SDLK_x;
+	keymap[SCANCODE_C] = SDLK_c;
+	keymap[SCANCODE_V] = SDLK_v;
+	keymap[SCANCODE_B] = SDLK_b;
+	keymap[SCANCODE_N] = SDLK_n;
+	keymap[SCANCODE_M] = SDLK_m;
+	keymap[SCANCODE_COMMA] = SDLK_COMMA;
+	keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
+	keymap[SCANCODE_SLASH] = SDLK_SLASH;
+	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+	keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
+	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+	keymap[SCANCODE_SPACE] = SDLK_SPACE;
+	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+	keymap[SCANCODE_F1] = SDLK_F1;
+	keymap[SCANCODE_F2] = SDLK_F2;
+	keymap[SCANCODE_F3] = SDLK_F3;
+	keymap[SCANCODE_F4] = SDLK_F4;
+	keymap[SCANCODE_F5] = SDLK_F5;
+	keymap[SCANCODE_F6] = SDLK_F6;
+	keymap[SCANCODE_F7] = SDLK_F7;
+	keymap[SCANCODE_F8] = SDLK_F8;
+	keymap[SCANCODE_F9] = SDLK_F9;
+	keymap[SCANCODE_F10] = SDLK_F10;
+	keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
+	keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
+	keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
+	keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
+	keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
+	keymap[SCANCODE_CURSORUP] = SDLK_KP8;
+	keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
+	keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
+	keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
+	keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
+	keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
+	keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
+	keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
+	keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
+	keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
+	keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
+	keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
+	keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
+	keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
+	keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
+	keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
+	keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
+	keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
+	keymap[SCANCODE_LESS] = SDLK_LESS;
+	keymap[SCANCODE_F11] = SDLK_F11;
+	keymap[SCANCODE_F12] = SDLK_F12;
+	keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
+	keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
+	keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
+	keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
+	keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
+	keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
+	keymap[SCANCODE_BREAK] = SDLK_BREAK;
+	keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
+	keymap[SCANCODE_HOME] = SDLK_HOME;
+	keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
+	keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
+	keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
+	keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
+	keymap[SCANCODE_END] = SDLK_END;
+	keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
+	keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
+	keymap[SCANCODE_INSERT] = SDLK_INSERT;
+	keymap[SCANCODE_REMOVE] = SDLK_DELETE;
+	keymap[119] = SDLK_PAUSE;
+	keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
+	keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
+	keymap[127] = SDLK_MENU;
+}
+
+
+
+static SDL_keysym *GGI_TranslateKey(gii_event *ev, SDL_keysym *keysym)
+{
+	/* Set the keysym information */
+	keysym->scancode = ev->key.button;
+	keysym->sym = keymap[ev->key.button];
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if (SDL_TranslateUNICODE) 
+	{
+		keysym->unicode = GII_UNICODE(ev->key.sym);
+	}
+
+	return keysym;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggievents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ggivideo.h"
+
+/* Functions to be exported */
+extern void GGI_InitOSKeymap(_THIS);
+extern void GGI_PumpEvents(_THIS);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggikeys.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,135 @@
+
+#define SCANCODE_ESCAPE			1
+
+#define SCANCODE_1			2
+#define SCANCODE_2			3
+#define SCANCODE_3			4
+#define SCANCODE_4			5
+#define SCANCODE_5			6
+#define SCANCODE_6			7
+#define SCANCODE_7			8
+#define SCANCODE_8			9
+#define SCANCODE_9			10
+#define SCANCODE_0			11
+
+#define SCANCODE_MINUS			12
+#define SCANCODE_EQUAL			13
+
+#define SCANCODE_BACKSPACE		14
+#define SCANCODE_TAB			15
+
+#define SCANCODE_Q			16
+#define SCANCODE_W			17
+#define SCANCODE_E			18
+#define SCANCODE_R			19
+#define SCANCODE_T			20
+#define SCANCODE_Y			21
+#define SCANCODE_U			22
+#define SCANCODE_I			23
+#define SCANCODE_O			24
+#define SCANCODE_P			25
+#define SCANCODE_BRACKET_LEFT		26
+#define SCANCODE_BRACKET_RIGHT		27
+
+#define SCANCODE_ENTER			28
+
+#define SCANCODE_LEFTCONTROL		29
+
+#define SCANCODE_A			30
+#define SCANCODE_S			31
+#define SCANCODE_D			32
+#define SCANCODE_F			33
+#define SCANCODE_G			34
+#define SCANCODE_H			35
+#define SCANCODE_J			36
+#define SCANCODE_K			37
+#define SCANCODE_L			38
+#define SCANCODE_SEMICOLON		39
+#define SCANCODE_APOSTROPHE		40
+#define SCANCODE_GRAVE			41
+
+#define SCANCODE_LEFTSHIFT		42
+#define SCANCODE_BACKSLASH		43
+
+#define SCANCODE_Z			44
+#define SCANCODE_X			45
+#define SCANCODE_C			46
+#define SCANCODE_V			47
+#define SCANCODE_B			48
+#define SCANCODE_N			49
+#define SCANCODE_M			50
+#define SCANCODE_COMMA			51
+#define SCANCODE_PERIOD			52
+#define SCANCODE_SLASH			53
+
+#define SCANCODE_RIGHTSHIFT		54
+#define SCANCODE_KEYPADMULTIPLY		55
+
+#define SCANCODE_LEFTALT		56
+#define SCANCODE_SPACE			57
+#define SCANCODE_CAPSLOCK		58
+
+#define SCANCODE_F1			59
+#define SCANCODE_F2			60
+#define SCANCODE_F3			61
+#define SCANCODE_F4			62
+#define SCANCODE_F5			63
+#define SCANCODE_F6			64
+#define SCANCODE_F7			65
+#define SCANCODE_F8			66
+#define SCANCODE_F9			67
+#define SCANCODE_F10			68
+
+#define SCANCODE_NUMLOCK		69
+#define SCANCODE_SCROLLLOCK		70
+
+#define SCANCODE_KEYPAD7		71
+#define SCANCODE_CURSORUPLEFT		71
+#define SCANCODE_KEYPAD8		72
+#define SCANCODE_CURSORUP		72
+#define SCANCODE_KEYPAD9		73
+#define SCANCODE_CURSORUPRIGHT		73
+#define SCANCODE_KEYPADMINUS		74
+#define SCANCODE_KEYPAD4		75
+#define SCANCODE_CURSORLEFT		75
+#define SCANCODE_KEYPAD5		76
+#define SCANCODE_KEYPAD6		77
+#define SCANCODE_CURSORRIGHT		77
+#define SCANCODE_KEYPADPLUS		78
+#define SCANCODE_KEYPAD1		79
+#define SCANCODE_CURSORDOWNLEFT		79
+#define SCANCODE_KEYPAD2		80
+#define SCANCODE_CURSORDOWN		80
+#define SCANCODE_KEYPAD3		81
+#define SCANCODE_CURSORDOWNRIGHT	81
+#define SCANCODE_KEYPAD0		82
+#define SCANCODE_KEYPADPERIOD		83
+
+#define SCANCODE_LESS			86
+
+#define SCANCODE_F11			87
+#define SCANCODE_F12			88
+
+#define SCANCODE_KEYPADENTER		96
+#define SCANCODE_RIGHTCONTROL		97
+#define SCANCODE_CONTROL		97
+#define SCANCODE_KEYPADDIVIDE		98
+#define SCANCODE_PRINTSCREEN		99
+#define SCANCODE_RIGHTALT		100
+#define SCANCODE_BREAK			101	/* Beware: is 119     */
+#define SCANCODE_BREAK_ALTERNATIVE	119	/* on some keyboards! */
+
+#define SCANCODE_HOME			102
+#define SCANCODE_CURSORBLOCKUP		90	/* Cursor key block */
+#define SCANCODE_PAGEUP			104
+#define SCANCODE_CURSORBLOCKLEFT	92	/* Cursor key block */
+#define SCANCODE_CURSORBLOCKRIGHT	94	/* Cursor key block */
+#define SCANCODE_END			107
+#define SCANCODE_CURSORBLOCKDOWN	108	/* Cursor key block */
+#define SCANCODE_PAGEDOWN		109
+#define SCANCODE_INSERT			110
+#define SCANCODE_REMOVE			111
+
+#define SCANCODE_RIGHTWIN		126
+#define SCANCODE_LEFTWIN		125
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggimouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_ggimouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	int unused;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggimouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ggivideo.h"
+
+/* Functions to be exported */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggivideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,380 @@
+/*
+	SDL - Simple DirectMedia Layer
+	Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+	This library is free software; you can redistribute it and/or
+	modify it under the terms of the GNU Library General Public
+	License as published by the Free Software Foundation; either
+	version 2 of the License, or (at your option) any later version.
+
+	This library is distributed in the hope that it will be useful,
+	but WITHOUT ANY WARRANTY; without even the implied warranty of
+	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+	Library General Public License for more details.
+
+	You should have received a copy of the GNU Library General Public
+	License along with this library; if not, write to the Free
+	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+	Sam Lantinga
+	slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* GGI-based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+
+#include <ggi/ggi.h>
+#include <ggi/gii.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_ggivideo.h"
+#include "SDL_ggimouse_c.h"
+#include "SDL_ggievents_c.h"
+
+
+struct private_hwdata
+{
+	ggi_visual_t vis;
+};
+
+ggi_visual_t VIS;
+
+/* Initialization/Query functions */
+static int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **GGI_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *GGI_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int GGI_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static void GGI_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int GGI_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int GGI_LockHWSurface(_THIS, SDL_Surface *surface);
+static void GGI_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void GGI_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* GGI driver bootstrap functions */
+
+static int GGI_Available(void)
+{
+	ggi_visual_t *vis;
+	
+	vis = ggiOpen(NULL);
+	if (vis != NULL) 
+	{
+		ggiClose(vis);
+	}
+	return (vis != NULL);
+}
+
+static void GGI_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *GGI_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = GGI_VideoInit;
+	device->ListModes = GGI_ListModes;
+	device->SetVideoMode = GGI_SetVideoMode;
+	device->SetColors = GGI_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = GGI_VideoQuit;
+	device->AllocHWSurface = GGI_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = GGI_LockHWSurface;
+	device->UnlockHWSurface = GGI_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = GGI_FreeHWSurface;
+	device->SetCaption = NULL;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->InitOSKeymap = GGI_InitOSKeymap;
+	device->PumpEvents = GGI_PumpEvents;
+
+	device->free = GGI_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap GGI_bootstrap = {
+	"ggi", "General Graphics Interface (GGI)",
+	GGI_Available, GGI_CreateDevice
+};
+
+
+static SDL_Rect video_mode;
+static SDL_Rect *SDL_modelist[4] = { NULL, NULL, NULL, NULL };
+
+int GGI_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	ggi_mode mode =
+	{
+		1,
+		{ GGI_AUTO, GGI_AUTO },
+		{ GGI_AUTO, GGI_AUTO },
+		{ 0, 0 },
+		GT_AUTO,
+		{ GGI_AUTO, GGI_AUTO }
+	};	
+	struct private_hwdata *priv;
+	ggi_color pal[256], map[256];
+	const ggi_directbuffer *db;
+	int err, num_bufs;
+	ggi_pixel white, black;
+	
+	priv = malloc(sizeof(struct private_hwdata));
+	if (priv == NULL)
+	{
+		SDL_SetError("Unhandled GGI mode type!\n");
+		GGI_VideoQuit(NULL);
+	}
+	
+	if (ggiInit() != 0)
+	{
+		SDL_SetError("Unable to initialize GGI!\n");
+		GGI_VideoQuit(NULL);
+	}
+	
+	VIS = ggiOpen(NULL);
+	if (VIS == NULL)
+	{
+		SDL_SetError("Unable to open default GGI visual!\n");
+		ggiExit();
+		GGI_VideoQuit(NULL);
+	}
+	
+	ggiSetFlags(VIS, GGIFLAG_ASYNC);
+	
+	/* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */
+	ggiCheckMode(VIS, &mode);
+	
+	/* At this point we should have a valid mode - try to set it */
+	err = ggiSetMode(VIS, &mode);
+	
+	/* If we couldn't set _any_ modes, something is very wrong */
+	if (err)
+	{
+		SDL_SetError("Can't set a mode!\n");
+		ggiClose(VIS);
+		ggiExit();
+		GGI_VideoQuit(NULL);
+	}
+
+	/* Set a palette for palletized modes */
+	if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
+	{
+		ggiSetColorfulPalette(VIS);
+		ggiGetPalette(VIS, 0, 1 << vformat->BitsPerPixel, pal);
+	}
+	
+	/* Now we try to get the DirectBuffer info, which determines whether
+	 * SDL can access hardware surfaces directly. */
+	
+	num_bufs = ggiDBGetNumBuffers(VIS);
+
+	if (num_bufs > 0)
+	{
+		db = ggiDBGetBuffer(VIS, 0); /* Only handle one DB for now */
+		
+		vformat->BitsPerPixel = db->buffer.plb.pixelformat->depth;
+		
+		vformat->Rmask = db->buffer.plb.pixelformat->red_mask;
+		vformat->Gmask = db->buffer.plb.pixelformat->green_mask;
+		vformat->Bmask = db->buffer.plb.pixelformat->blue_mask;
+		
+		/* Fill in our hardware acceleration capabilities */
+	
+		this->info.wm_available = 0;
+		this->info.hw_available = 1;
+		this->info.video_mem = db->buffer.plb.stride * mode.virt.y;
+	}
+
+	video_mode.x = 0;
+	video_mode.y = 0;
+	video_mode.w = mode.virt.x;
+	video_mode.h = mode.virt.y;
+	SDL_modelist[((vformat->BitsPerPixel + 7) / 8) - 1] = &video_mode;
+
+	/* We're done! */
+	return(0);
+}
+
+static SDL_Rect **GGI_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	return(&SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
+}
+
+/* Various screen update functions available */
+static void GGI_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *GGI_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
+{
+	ggi_mode mode =
+	{
+		1,
+		{ GGI_AUTO, GGI_AUTO },
+		{ GGI_AUTO, GGI_AUTO },
+		{ 0, 0 },
+		GT_AUTO,
+		{ GGI_AUTO, GGI_AUTO }
+	};
+        const ggi_directbuffer *db;
+	ggi_color pal[256];
+	int err;
+
+	fprintf(stderr, "GGI_SetVideoMode()\n");
+	
+	mode.visible.x = mode.virt.x = width;
+	mode.visible.y = mode.virt.y = height;
+	
+	/* Translate requested SDL bit depth into a GGI mode */	
+	switch (bpp)
+	{
+		case 1:  mode.graphtype = GT_1BIT;  break;
+		case 2:  mode.graphtype = GT_2BIT;  break;
+		case 4:  mode.graphtype = GT_4BIT;  break;
+		case 8:  mode.graphtype = GT_8BIT;  break;
+		case 15: mode.graphtype = GT_15BIT; break;
+		case 16: mode.graphtype = GT_16BIT; break;
+		case 24: mode.graphtype = GT_24BIT; break;
+		case 32: mode.graphtype = GT_32BIT; break;
+		default:
+		SDL_SetError("Unknown SDL bit depth, using GT_AUTO....\n");
+		mode.graphtype = GT_AUTO;
+	}
+	
+	/* Validate mode, autodetecting any GGI_AUTO or GT_AUTO fields */
+	ggiCheckMode(VIS, &mode);
+	
+	/* At this point we should have a valid mode - try to set it */
+	err = ggiSetMode(VIS, &mode);
+
+	/* If we couldn't set _any_ modes, something is very wrong */
+	if (err)
+	{
+		SDL_SetError("Can't set a mode!\n");
+		ggiClose(VIS);
+		ggiExit();
+		GGI_VideoQuit(NULL);
+	}
+	
+	/* Set a palette for palletized modes */
+	if (GT_SCHEME(mode.graphtype) == GT_PALETTE)
+	{
+		ggiSetColorfulPalette(VIS);
+		ggiGetPalette(VIS, 0, 1 << bpp, pal);
+	}
+	
+	db = ggiDBGetBuffer(VIS, 0);
+	
+	/* Set up the new mode framebuffer */
+	current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE);
+	current->w = mode.virt.x;
+	current->h = mode.virt.y;
+	current->pitch = db->buffer.plb.stride;
+	current->pixels = db->read;
+
+	/* Set the blit function */
+	this->UpdateRects = GGI_DirectUpdate;
+
+	/* We're done */
+	return(current);
+}
+
+static int GGI_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void GGI_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+static int GGI_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+static void GGI_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+static void GGI_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	int i;
+	
+/*	ggiFlush(VIS); */
+	
+	for (i = 0; i < numrects; i++)
+	{
+		ggiFlushRegion(VIS, rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+	}
+	return;
+}
+
+int GGI_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+	ggi_color pal[256];
+
+	/* Set up the colormap */
+	for (i = 0; i < ncolors; i++)
+	{
+		pal[i].r = (colors[i].r << 8) | colors[i].r;
+		pal[i].g = (colors[i].g << 8) | colors[i].g;
+		pal[i].b = (colors[i].b << 8) | colors[i].b;
+	}
+	
+	ggiSetPalette(VIS, firstcolor, ncolors, pal);
+	
+	return 1;
+}
+	
+void GGI_VideoQuit(_THIS)
+{
+}
+void GGI_FinalQuit(void) 
+{
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/ggi/SDL_ggivideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,52 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_ggivideo_h
+#define _SDL_ggivideo_h
+
+#include <ggi/ggi.h>
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+#define _THIS SDL_VideoDevice *this
+
+/* Private display data */
+
+struct SDL_PrivateVideoData
+{
+	ggi_visual_t *ggivis;
+};
+
+extern ggi_visual_t VIS; /* FIXME: use the private data struct */
+
+extern int SDL_OpenKeyboard(void);
+extern void SDL_CloseKeyboard(void);
+extern int SDL_OpenMouse(void);
+extern void SDL_CloseMouse(void);
+
+#endif /* _SDL_ggivideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,18 @@
+
+## Makefile.am for SDL using the MacOS toolbox
+
+noinst_LTLIBRARIES = libvideo_maccommon.la
+libvideo_maccommon_la_SOURCES = $(COMMON_SRCS)
+
+# The SDL Mac toolbox driver sources
+COMMON_SRCS = 			\
+	SDL_lowvideo.h		\
+	SDL_macevents.c		\
+	SDL_macevents_c.h	\
+	SDL_macgl.c		\
+	SDL_macgl_c.h		\
+	SDL_mackeys.h		\
+	SDL_macmouse.c		\
+	SDL_macmouse_c.h	\
+	SDL_macwm.c		\
+	SDL_macwm_c.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_lowvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,108 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowvideo_h
+#define _SDL_lowvideo_h
+
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <Quickdraw.h>
+#include <Palettes.h>
+#include <Menus.h>
+#include <DrawSprocket.h>
+#endif
+
+#ifdef HAVE_OPENGL
+#ifdef MACOSX
+#include <OpenGL/gl.h> /* OpenGL.framework */
+#include <AGL/agl.h>   /* AGL.framework */
+#else
+#include <GL/gl.h>
+#include <agl.h>
+#endif /* MACOSX */
+#endif /* HAVE_OPENGL */
+
+#include "SDL_video.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+#if !TARGET_API_MAC_CARBON  /* not available in OS X (or more accurately, Carbon) */
+/* Global QuickDraw data */
+extern QDGlobals *theQD;
+#endif
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+	GDevice **SDL_Display;
+	WindowRef SDL_Window;
+	SDL_Rect **SDL_modelist;
+	CTabHandle SDL_CTab;
+	PaletteHandle SDL_CPal;
+
+#if TARGET_API_MAC_CARBON
+	/* For entering and leaving fullscreen mode */
+	Ptr fullscreen_ctx;
+#endif
+
+	/* The current window document style */
+	int current_style;
+
+	/* Information about the last cursor position */
+	Point last_where;
+
+	/* Information about the last keys down */
+	EventModifiers last_mods;
+	KeyMap last_keys;
+
+	/* A handle to the Apple Menu */
+	MenuRef apple_menu;
+
+	/* Information used by DrawSprocket driver */
+	struct DSpInfo *dspinfo;
+
+#ifdef HAVE_OPENGL
+	AGLContext appleGLContext;
+#endif
+};
+/* Old variable names */
+#define SDL_Display		(this->hidden->SDL_Display)
+#define SDL_Window		(this->hidden->SDL_Window)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define SDL_CTab		(this->hidden->SDL_CTab)
+#define SDL_CPal		(this->hidden->SDL_CPal)
+#define fullscreen_ctx		(this->hidden->fullscreen_ctx)
+#define current_style		(this->hidden->current_style)
+#define last_where		(this->hidden->last_where)
+#define last_mods		(this->hidden->last_mods)
+#define last_keys		(this->hidden->last_keys)
+#define apple_menu		(this->hidden->apple_menu)
+#define glContext		(this->hidden->appleGLContext)
+
+#endif /* _SDL_lowvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,677 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <Script.h>
+#include <LowMem.h>
+#include <Devices.h>
+#include <DiskInit.h>
+#include <ToolUtils.h>
+#endif
+
+#include "SDL_events.h"
+#include "SDL_video.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_sysevents.h"
+#include "SDL_macevents_c.h"
+#include "SDL_mackeys.h"
+#include "SDL_macmouse_c.h"
+
+/* Define this to be able to collapse SDL windows.
+#define USE_APPEARANCE_MANAGER
+ */
+
+/* Macintosh resource constants */
+#define mApple	128			/* Apple menu resource */
+#define iAbout	1			/* About menu item */
+
+/* Functions to handle the About menu */
+static void Mac_DoAppleMenu(_THIS, long item);
+
+/* The translation table from a macintosh key scancode to a SDL keysym */
+static SDLKey MAC_keymap[256];
+static SDL_keysym *TranslateKey(int scancode, int modifiers,
+                                SDL_keysym *keysym, int pressed);
+
+/* Handle activation and deactivation  -- returns whether an event was posted */
+static int Mac_HandleActivate(int activate)
+{
+	if ( activate ) {
+		/* Show the current SDL application cursor */
+		SDL_SetCursor(NULL);
+
+		/* put our mask back case it changed during context switch */
+		SetEventMask(everyEvent - autoKeyMask);
+	} else {
+#if TARGET_API_MAC_CARBON
+		{ Cursor cursor;
+			SetCursor(GetQDGlobalsArrow(&cursor));
+		}
+#else
+		SetCursor(&theQD->arrow);
+#endif
+		if ( ! Mac_cursor_showing ) {
+			ShowCursor();
+			Mac_cursor_showing = 1;
+		}
+	}
+	return(SDL_PrivateAppActive(activate, SDL_APPINPUTFOCUS));
+}
+
+static void myGlobalToLocal(_THIS, Point *pt)
+{
+	if ( SDL_VideoSurface && !(SDL_VideoSurface->flags&SDL_FULLSCREEN) ) {
+		GrafPtr saveport;
+		GetPort(&saveport);
+#if TARGET_API_MAC_CARBON
+		SetPort(GetWindowPort(SDL_Window));
+#else
+		SetPort(SDL_Window);
+#endif
+		GlobalToLocal(pt);
+		SetPort(saveport);
+	}
+}
+
+/* The main MacOS event handler */
+static int Mac_HandleEvents(_THIS, int wait4it)
+{
+	int i;
+	EventRecord event;
+
+#if TARGET_API_MAC_CARBON
+	/* There's no GetOSEvent() in the Carbon API. *sigh* */
+#define cooperative_multitasking 1
+#else
+	int cooperative_multitasking;
+	/* If we're running fullscreen, we can hog the MacOS events,
+	   otherwise we had better play nicely with the other apps.
+	*/
+	if ( this->screen && (this->screen->flags & SDL_FULLSCREEN) ) {
+		cooperative_multitasking = 0;
+	} else {
+		cooperative_multitasking = 1;
+	}
+#endif
+
+	/* If we call WaitNextEvent(), MacOS will check other processes
+	 * and allow them to run, and perform other high-level processing.
+	 */
+	if ( cooperative_multitasking || wait4it ) {
+		UInt32 wait_time;
+
+		/* Are we polling or not? */
+		if ( wait4it ) {
+			wait_time = 2147483647;
+		} else {
+			wait_time = 0;
+		}
+		WaitNextEvent(everyEvent, &event, wait_time, nil);
+	} else {
+#if ! TARGET_API_MAC_CARBON
+		GetOSEvent(everyEvent, &event);
+#endif
+	}
+
+#if TARGET_API_MAC_CARBON
+	/* for some reason, event.where isn't set ? */
+	GetGlobalMouse ( &event.where );
+#endif
+    
+	/* Check for mouse motion */
+	if ( (event.where.h != last_where.h) ||
+	     (event.where.v != last_where.v) ) {
+		Point pt;
+		pt = last_where = event.where;
+		myGlobalToLocal(this, &pt);
+		SDL_PrivateMouseMotion(0, 0, pt.h, pt.v);
+	}
+
+	/* Check the current state of the keyboard */
+	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+		KeyMap keys;
+
+		/* Check for special non-event keys */
+		if ( event.modifiers != last_mods ) {
+			static struct {
+				EventModifiers mask;
+				SDLKey key;
+			} mods[] = {
+				{ alphaLock,		SDLK_CAPSLOCK },
+#if 0 /* These are handled below in the GetKeys() code */
+				{ cmdKey,		SDLK_LMETA },
+				{ shiftKey,		SDLK_LSHIFT },
+				{ rightShiftKey,	SDLK_RSHIFT },
+				{ optionKey,		SDLK_LALT },
+				{ rightOptionKey,	SDLK_RALT },
+				{ controlKey,		SDLK_LCTRL },
+				{ rightControlKey,	SDLK_RCTRL },
+#endif /* 0 */
+				{ 0,			0 }
+			};
+			SDL_keysym keysym;
+			Uint8 mode;
+			EventModifiers mod, mask;
+		
+
+			/* Set up the keyboard event */
+			keysym.scancode = 0;
+			keysym.sym = SDLK_UNKNOWN;
+			keysym.mod = KMOD_NONE;
+			keysym.unicode = 0;
+
+			/* See what has changed, and generate events */
+			mod = event.modifiers;
+			for ( i=0; mods[i].mask; ++i ) {
+				mask = mods[i].mask;
+				if ( (mod&mask) != (last_mods&mask) ) {
+					keysym.sym = mods[i].key;
+					if ( (mod&mask) ||
+					     (mods[i].key == SDLK_CAPSLOCK) ) {
+						mode = SDL_PRESSED;
+					} else {
+						mode = SDL_RELEASED;
+					}
+					SDL_PrivateKeyboard(mode, &keysym);
+				}
+			}
+
+			/* Save state for next time */
+			last_mods = mod;
+		}
+
+		/* Check for normal event keys, but we have to scan the
+		   actual keyboard state because on MacOS X a keydown event
+		   is immediately followed by a keyup event.
+		*/
+		GetKeys(keys);
+		if ( (keys[0] != last_keys[0]) || (keys[1] != last_keys[1]) ||
+		     (keys[2] != last_keys[2]) || (keys[3] != last_keys[3]) ) {
+			SDL_keysym keysym;
+			int old_bit, new_bit;
+
+#ifdef DEBUG_KEYBOARD
+			fprintf(sterr, "New keys: 0x%x 0x%x 0x%x 0x%x\n",
+				new_keys[0], new_keys[1],
+				new_keys[2], new_keys[3]);
+#endif
+			for ( i=0; i<128; ++i ) {
+				old_bit = (((Uint8 *)last_keys)[i/8]>>(i%8)) & 0x01;
+				new_bit = (((Uint8 *)keys)[i/8]>>(i%8)) & 0x01;
+				if ( old_bit != new_bit ) {
+					/* Post the keyboard event */
+#ifdef DEBUG_KEYBOARD
+					fprintf(stderr,"Scancode: 0x%2.2X\n",i);
+#endif
+					SDL_PrivateKeyboard(new_bit,
+				            TranslateKey(i, event.modifiers,
+				                         &keysym, new_bit));
+				}
+			}
+
+			/* Save state for next time */
+			last_keys[0] = keys[0];
+			last_keys[1] = keys[1];
+			last_keys[2] = keys[2];
+			last_keys[3] = keys[3];
+		}
+	}
+
+	/* Handle normal events */
+	switch (event.what) {
+	  case mouseDown: {
+		WindowRef win;
+		short area;
+				
+		area = FindWindow(event.where, &win);
+		/* Support switching between the SIOUX console
+		   and SDL_Window by clicking in the window.
+		 */
+		if ( win && (win != FrontWindow()) ) {
+			SelectWindow(win);
+		} 
+		switch (area) {
+		  case inMenuBar: /* Only the apple menu exists */
+			Mac_DoAppleMenu(this, MenuSelect(event.where));
+			HiliteMenu(0);
+			break;
+		  case inDrag:
+#if TARGET_API_MAC_CARBON
+			DragWindow(win, event.where, NULL);
+#else
+			DragWindow(win, event.where, &theQD->screenBits.bounds);
+#endif
+			break;
+		  case inGoAway:
+			if ( TrackGoAway(win, event.where) ) {
+				SDL_PrivateQuit();
+			}
+			break;
+		  case inContent:
+			myGlobalToLocal(this, &event.where);
+			/* Treat command-click as right mouse button */
+			if ( event.modifiers & optionKey ) {
+			    SDL_PrivateMouseButton(SDL_PRESSED,
+					2,event.where.h,event.where.v);
+			}
+			else if ( event.modifiers & cmdKey ) {
+			    SDL_PrivateMouseButton(SDL_PRESSED,
+					3,event.where.h,event.where.v);
+			} else {
+			    SDL_PrivateMouseButton(SDL_PRESSED,
+					1,event.where.h,event.where.v);
+			}
+			break;
+		  case inGrow: {
+			int newSize;
+
+			/* Don't allow resize if video mode isn't resizable */
+			if ( ! SDL_PublicSurface ||
+			     ! (SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
+				break;
+			}
+#if TARGET_API_MAC_CARBON
+			newSize = GrowWindow(win, event.where, NULL);
+#else
+			newSize = GrowWindow(win, event.where, &theQD->screenBits.bounds);
+#endif
+			if ( newSize ) {
+#if !TARGET_API_MAC_CARBON
+				EraseRect ( &theQD->screenBits.bounds );
+#endif
+				SizeWindow ( win, LoWord (newSize), HiWord (newSize), 1 );
+				SDL_PrivateResize ( LoWord (newSize), HiWord (newSize) );
+			}
+		  	} break;
+		  case inZoomIn:
+		  case inZoomOut:
+			if ( TrackBox (win, event.where, area )) {
+				Rect rect;
+#if !TARGET_API_MAC_CARBON
+				EraseRect ( &theQD->screenBits.bounds );
+#endif
+				ZoomWindow ( win, area, 0);
+				if ( area == inZoomIn ) {
+					GetWindowUserState(SDL_Window, &rect);
+				} else {
+					GetWindowStandardState(SDL_Window, &rect);
+				}
+				SDL_PrivateResize (rect.right-rect.left,
+				                   rect.bottom-rect.top);
+			}
+			break;
+#if TARGET_API_MAC_CARBON
+		  case inCollapseBox:
+			if ( TrackBox (win, event.where, area )) {
+				if ( IsWindowCollapsable(win) ) {
+					CollapseWindow (win, !IsWindowCollapsed(win));
+					// There should be something done like in inGrow case, but...
+				}
+			}
+			break;
+#endif /* TARGET_API_MAC_CARBON */
+		  case inSysWindow:
+#if TARGET_API_MAC_CARBON
+			/* Never happens in Carbon? */
+#else
+			SystemClick(&event, win);
+#endif
+			break;
+		  default:
+			break;
+		}
+	  }
+	  break;
+	  case mouseUp: {
+		myGlobalToLocal(this, &event.where);
+		/* Treat command-click as right mouse button */
+		if ( event.modifiers & cmdKey ) {
+		    SDL_PrivateMouseButton(SDL_RELEASED,
+				3, event.where.h, event.where.v);
+		}
+		else if ( event.modifiers & optionKey ) {
+		    SDL_PrivateMouseButton(SDL_RELEASED,
+				2,event.where.h,event.where.v);
+		} else {
+		    SDL_PrivateMouseButton(SDL_RELEASED,
+				1, event.where.h, event.where.v);
+		}
+	  }
+	  break;
+#if 0 /* Handled above the switch statement */
+	  case keyDown: {
+		SDL_keysym keysym;
+
+		SDL_PrivateKeyboard(SDL_PRESSED,
+			TranslateKey((event.message&keyCodeMask)>>8
+		                     event.modifiers, &keysym, 1));
+	  }
+	  break;
+	  case keyUp: {
+		SDL_keysym keysym;
+
+		SDL_PrivateKeyboard(SDL_RELEASED,
+			TranslateKey((event.message&keyCodeMask)>>8
+		                     event.modifiers, &keysym, 0));
+	  }
+	  break;
+#endif
+	  case updateEvt: {
+		BeginUpdate(SDL_Window);
+		if ( (SDL_VideoSurface->flags & SDL_HWSURFACE) ==
+						SDL_SWSURFACE ) {
+			SDL_UpdateRect(SDL_VideoSurface, 0, 0, 0, 0);
+		}
+		EndUpdate(SDL_Window);
+	  }
+	  /* If this was an update event for the SIOUX console, we return 0
+             in order to stop an endless series of updates being triggered.
+	  */
+	  if ( (WindowRef) event.message != SDL_Window ) {
+		return 0;
+	  }
+	  break;
+	  case activateEvt: {
+		Mac_HandleActivate(!!(event.modifiers & activeFlag));
+	  }
+	  break;
+	  case diskEvt: {
+#if TARGET_API_MAC_CARBON
+		/* What are we supposed to do? */;
+#else
+		if ( ((event.message>>16)&0xFFFF) != noErr ) {
+			Point spot;
+			SetPt(&spot, 0x0070, 0x0050);
+			DIBadMount(spot, event.message);
+		}
+#endif
+	  }
+	  break;
+	  case osEvt: {
+		switch ((event.message>>24) & 0xFF) {
+#if 0 /* Handled above the switch statement */
+		  case mouseMovedMessage: {
+			myGlobalToLocal(this, &event.where);
+			SDL_PrivateMouseMotion(0, 0,
+					event.where.h, event.where.v);
+		  }
+		  break;
+#endif /* 0 */
+		  case suspendResumeMessage: {
+			Mac_HandleActivate(!!(event.message & resumeFlag));
+		  }
+		  break;
+		}
+	  }
+	  break;
+	  default: {
+		;
+	  }
+	  break;
+	}
+	return (event.what != nullEvent);
+}
+
+
+void Mac_PumpEvents(_THIS)
+{
+	/* Process pending MacOS events */
+	while ( Mac_HandleEvents(this, 0) ) {
+		/* Loop and check again */;
+	}
+}
+
+void Mac_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Map the MAC keysyms */
+	for ( i=0; i<SDL_TABLESIZE(MAC_keymap); ++i )
+		MAC_keymap[i] = SDLK_UNKNOWN;
+
+	/* Wierd, these keys are on my iBook under MacOS X */
+	MAC_keymap[MK_IBOOK_ENTER] = SDLK_KP_ENTER;
+	MAC_keymap[MK_IBOOK_RIGHT] = SDLK_RIGHT;
+	MAC_keymap[MK_IBOOK_DOWN] = SDLK_DOWN;
+	MAC_keymap[MK_IBOOK_UP] = SDLK_UP;
+	MAC_keymap[MK_IBOOK_LEFT] = SDLK_LEFT;
+
+	/* Defined MAC_* constants */
+	MAC_keymap[MK_ESCAPE] = SDLK_ESCAPE;
+	MAC_keymap[MK_F1] = SDLK_F1;
+	MAC_keymap[MK_F2] = SDLK_F2;
+	MAC_keymap[MK_F3] = SDLK_F3;
+	MAC_keymap[MK_F4] = SDLK_F4;
+	MAC_keymap[MK_F5] = SDLK_F5;
+	MAC_keymap[MK_F6] = SDLK_F6;
+	MAC_keymap[MK_F7] = SDLK_F7;
+	MAC_keymap[MK_F8] = SDLK_F8;
+	MAC_keymap[MK_F9] = SDLK_F9;
+	MAC_keymap[MK_F10] = SDLK_F10;
+	MAC_keymap[MK_F11] = SDLK_F11;
+	MAC_keymap[MK_F12] = SDLK_F12;
+	MAC_keymap[MK_PRINT] = SDLK_PRINT;
+	MAC_keymap[MK_SCROLLOCK] = SDLK_SCROLLOCK;
+	MAC_keymap[MK_PAUSE] = SDLK_PAUSE;
+	MAC_keymap[MK_POWER] = SDLK_POWER;
+	MAC_keymap[MK_BACKQUOTE] = SDLK_BACKQUOTE;
+	MAC_keymap[MK_1] = SDLK_1;
+	MAC_keymap[MK_2] = SDLK_2;
+	MAC_keymap[MK_3] = SDLK_3;
+	MAC_keymap[MK_4] = SDLK_4;
+	MAC_keymap[MK_5] = SDLK_5;
+	MAC_keymap[MK_6] = SDLK_6;
+	MAC_keymap[MK_7] = SDLK_7;
+	MAC_keymap[MK_8] = SDLK_8;
+	MAC_keymap[MK_9] = SDLK_9;
+	MAC_keymap[MK_0] = SDLK_0;
+	MAC_keymap[MK_MINUS] = SDLK_MINUS;
+	MAC_keymap[MK_EQUALS] = SDLK_EQUALS;
+	MAC_keymap[MK_BACKSPACE] = SDLK_BACKSPACE;
+	MAC_keymap[MK_INSERT] = SDLK_INSERT;
+	MAC_keymap[MK_HOME] = SDLK_HOME;
+	MAC_keymap[MK_PAGEUP] = SDLK_PAGEUP;
+	MAC_keymap[MK_NUMLOCK] = SDLK_NUMLOCK;
+	MAC_keymap[MK_KP_EQUALS] = SDLK_KP_EQUALS;
+	MAC_keymap[MK_KP_DIVIDE] = SDLK_KP_DIVIDE;
+	MAC_keymap[MK_KP_MULTIPLY] = SDLK_KP_MULTIPLY;
+	MAC_keymap[MK_TAB] = SDLK_TAB;
+	MAC_keymap[MK_q] = SDLK_q;
+	MAC_keymap[MK_w] = SDLK_w;
+	MAC_keymap[MK_e] = SDLK_e;
+	MAC_keymap[MK_r] = SDLK_r;
+	MAC_keymap[MK_t] = SDLK_t;
+	MAC_keymap[MK_y] = SDLK_y;
+	MAC_keymap[MK_u] = SDLK_u;
+	MAC_keymap[MK_i] = SDLK_i;
+	MAC_keymap[MK_o] = SDLK_o;
+	MAC_keymap[MK_p] = SDLK_p;
+	MAC_keymap[MK_LEFTBRACKET] = SDLK_LEFTBRACKET;
+	MAC_keymap[MK_RIGHTBRACKET] = SDLK_RIGHTBRACKET;
+	MAC_keymap[MK_BACKSLASH] = SDLK_BACKSLASH;
+	MAC_keymap[MK_DELETE] = SDLK_DELETE;
+	MAC_keymap[MK_END] = SDLK_END;
+	MAC_keymap[MK_PAGEDOWN] = SDLK_PAGEDOWN;
+	MAC_keymap[MK_KP7] = SDLK_KP7;
+	MAC_keymap[MK_KP8] = SDLK_KP8;
+	MAC_keymap[MK_KP9] = SDLK_KP9;
+	MAC_keymap[MK_KP_MINUS] = SDLK_KP_MINUS;
+	MAC_keymap[MK_CAPSLOCK] = SDLK_CAPSLOCK;
+	MAC_keymap[MK_a] = SDLK_a;
+	MAC_keymap[MK_s] = SDLK_s;
+	MAC_keymap[MK_d] = SDLK_d;
+	MAC_keymap[MK_f] = SDLK_f;
+	MAC_keymap[MK_g] = SDLK_g;
+	MAC_keymap[MK_h] = SDLK_h;
+	MAC_keymap[MK_j] = SDLK_j;
+	MAC_keymap[MK_k] = SDLK_k;
+	MAC_keymap[MK_l] = SDLK_l;
+	MAC_keymap[MK_SEMICOLON] = SDLK_SEMICOLON;
+	MAC_keymap[MK_QUOTE] = SDLK_QUOTE;
+	MAC_keymap[MK_RETURN] = SDLK_RETURN;
+	MAC_keymap[MK_KP4] = SDLK_KP4;
+	MAC_keymap[MK_KP5] = SDLK_KP5;
+	MAC_keymap[MK_KP6] = SDLK_KP6;
+	MAC_keymap[MK_KP_PLUS] = SDLK_KP_PLUS;
+	MAC_keymap[MK_LSHIFT] = SDLK_LSHIFT;
+	MAC_keymap[MK_z] = SDLK_z;
+	MAC_keymap[MK_x] = SDLK_x;
+	MAC_keymap[MK_c] = SDLK_c;
+	MAC_keymap[MK_v] = SDLK_v;
+	MAC_keymap[MK_b] = SDLK_b;
+	MAC_keymap[MK_n] = SDLK_n;
+	MAC_keymap[MK_m] = SDLK_m;
+	MAC_keymap[MK_COMMA] = SDLK_COMMA;
+	MAC_keymap[MK_PERIOD] = SDLK_PERIOD;
+	MAC_keymap[MK_SLASH] = SDLK_SLASH;
+#if 0	/* These are the same as the left versions - use left by default */
+	MAC_keymap[MK_RSHIFT] = SDLK_RSHIFT;
+#endif
+	MAC_keymap[MK_UP] = SDLK_UP;
+	MAC_keymap[MK_KP1] = SDLK_KP1;
+	MAC_keymap[MK_KP2] = SDLK_KP2;
+	MAC_keymap[MK_KP3] = SDLK_KP3;
+	MAC_keymap[MK_KP_ENTER] = SDLK_KP_ENTER;
+	MAC_keymap[MK_LCTRL] = SDLK_LCTRL;
+	MAC_keymap[MK_LALT] = SDLK_LALT;
+	MAC_keymap[MK_LMETA] = SDLK_LMETA;
+	MAC_keymap[MK_SPACE] = SDLK_SPACE;
+#if 0	/* These are the same as the left versions - use left by default */
+	MAC_keymap[MK_RMETA] = SDLK_RMETA;
+	MAC_keymap[MK_RALT] = SDLK_RALT;
+	MAC_keymap[MK_RCTRL] = SDLK_RCTRL;
+#endif
+	MAC_keymap[MK_LEFT] = SDLK_LEFT;
+	MAC_keymap[MK_DOWN] = SDLK_DOWN;
+	MAC_keymap[MK_RIGHT] = SDLK_RIGHT;
+	MAC_keymap[MK_KP0] = SDLK_KP0;
+	MAC_keymap[MK_KP_PERIOD] = SDLK_KP_PERIOD;
+}
+
+static SDL_keysym *TranslateKey(int scancode, int modifiers,
+                                SDL_keysym *keysym, int pressed)
+{
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->sym = MAC_keymap[keysym->scancode];
+	keysym->mod = KMOD_NONE;
+	keysym->unicode = 0;
+	if ( pressed && SDL_TranslateUNICODE ) {
+		static unsigned long state = 0;
+		static Ptr keymap = nil;
+		Ptr new_keymap;
+
+		/* Get the current keyboard map resource */
+		new_keymap = (Ptr)GetScriptManagerVariable(smKCHRCache);
+		if ( new_keymap != keymap ) {
+			keymap = new_keymap;
+			state = 0;
+		}
+		keysym->unicode = KeyTranslate(keymap,
+			keysym->scancode|modifiers, &state) & 0xFFFF;
+	}
+	return(keysym);
+}
+
+void Mac_InitEvents(_THIS)
+{
+	/* Create apple menu bar */
+	apple_menu = GetMenu(mApple);
+	if ( apple_menu != nil ) {
+		AppendResMenu(apple_menu, 'DRVR');
+		InsertMenu(apple_menu, 0);
+	}
+	DrawMenuBar();
+
+	/* Get rid of spurious events at startup */
+	FlushEvents(everyEvent, 0);
+	
+	/* Allow every event but keyrepeat */
+	SetEventMask(everyEvent - autoKeyMask);
+}
+
+void Mac_QuitEvents(_THIS)
+{
+	ClearMenuBar();
+	if ( apple_menu != nil ) {
+		ReleaseResource((char **)apple_menu);
+	}
+
+	/* Clean up pending events */
+	FlushEvents(everyEvent, 0);
+}
+
+static void Mac_DoAppleMenu(_THIS, long choice)
+{
+#if !TARGET_API_MAC_CARBON  /* No Apple menu in OS X */
+	short menu, item;
+
+	item = (choice&0xFFFF);
+	choice >>= 16;
+	menu = (choice&0xFFFF);
+	
+	switch (menu) {
+		case mApple: {
+			switch (item) {
+				case iAbout: {
+					/* Run the about box */;
+				}
+				break;
+				default: {
+					Str255 name;
+					
+					GetMenuItemText(apple_menu, item, name);
+					OpenDeskAcc(name);
+				}
+				break;
+			}
+		}
+		break;
+		default: {
+			/* Ignore other menus */;
+		}
+	}
+#endif /* !TARGET_API_MAC_CARBON */
+}
+
+#if !TARGET_API_MAC_CARBON
+/* Since we don't initialize QuickDraw, we need to get a pointer to qd */
+QDGlobals *theQD = NULL;
+
+/* Exported to the macmain code */
+void SDL_InitQuickDraw(struct QDGlobals *the_qd)
+{
+	theQD = the_qd;
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_romvideo.h"
+
+/* Functions exported by SDL_macevents.c for the video subsystem
+*/
+extern void Mac_InitEvents(_THIS);
+extern void Mac_QuitEvents(_THIS);
+
+extern void Mac_InitOSKeymap(_THIS);
+extern void Mac_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macgl.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,149 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* AGL implementation of SDL OpenGL support */
+
+#include "SDL_error.h"
+#include "SDL_lowvideo.h"
+#include "SDL_macgl_c.h"
+
+
+/* krat: adding OpenGL support */
+int Mac_GL_Init(_THIS)
+{
+#ifdef HAVE_OPENGL
+	AGLPixelFormat format;
+   	int i = 0;
+	GLint attributes [ 24 ]; /* 24 is max possible in this setup */
+	GLboolean noerr;
+   
+	attributes[i++] = AGL_RGBA;
+
+	if ( this->gl_config.double_buffer ) {
+		attributes[i++] = AGL_DOUBLEBUFFER;
+	}
+	if ( this->gl_config.depth_size != 0 ) {
+		attributes[i++] = AGL_DEPTH_SIZE;
+		attributes[i++] = this->gl_config.depth_size;
+	}	
+	if ( this->gl_config.red_size   != 0 &&
+	     this->gl_config.blue_size  != 0 &&
+	     this->gl_config.green_size != 0 ) {
+
+		attributes[i++] = AGL_RED_SIZE;
+		attributes[i++] = this->gl_config.red_size;
+		attributes[i++] = AGL_GREEN_SIZE;
+		attributes[i++] = this->gl_config.green_size;
+		attributes[i++] = AGL_BLUE_SIZE;
+		attributes[i++] = this->gl_config.blue_size;
+		attributes[i++] = AGL_ALPHA_SIZE;
+		attributes[i++] = this->gl_config.alpha_size;
+	}
+	if ( this->gl_config.stencil_size != 0 ) {
+		attributes[i++] = AGL_STENCIL_SIZE;
+		attributes[i++] = this->gl_config.stencil_size;
+	}
+	if ( this->gl_config.accum_red_size   != 0 &&
+	     this->gl_config.accum_blue_size  != 0 &&
+	     this->gl_config.accum_green_size != 0 ) {
+		
+		attributes[i++] = AGL_ACCUM_RED_SIZE;
+		attributes[i++] = this->gl_config.accum_red_size;
+		attributes[i++] = AGL_ACCUM_GREEN_SIZE;
+		attributes[i++] = this->gl_config.accum_green_size;
+		attributes[i++] = AGL_ACCUM_BLUE_SIZE;
+		attributes[i++] = this->gl_config.accum_blue_size;
+		attributes[i++] = AGL_ACCUM_ALPHA_SIZE;
+		attributes[i++] = this->gl_config.accum_alpha_size;
+	}
+	attributes[i++] = AGL_ALL_RENDERERS;
+	attributes[i]	= AGL_NONE;
+
+	format = aglChoosePixelFormat(NULL, 0, attributes);
+	if ( format == NULL ) {
+		SDL_SetError("Couldn't match OpenGL desired format");
+		return(-1);
+	}
+
+	glContext = aglCreateContext(format, NULL);
+	if ( glContext == NULL ) {
+		SDL_SetError("Couldn't create OpenGL context");
+		return(-1);
+	}
+	aglDestroyPixelFormat(format);
+
+    #if  TARGET_API_MAC_CARBON
+    noerr = aglSetDrawable(glContext, GetWindowPort(SDL_Window));
+    #else
+	noerr = aglSetDrawable(glContext, (AGLDrawable)SDL_Window);
+    #endif
+    
+	if(!noerr) {
+		SDL_SetError("Unable to bind GL context to window");
+		return(-1);
+	}
+	return(0);
+#else
+	SDL_SetError("OpenGL support not configured");
+	return(-1);
+#endif
+}
+
+void Mac_GL_Quit(_THIS)
+{
+#ifdef HAVE_OPENGL
+	if ( glContext != NULL ) {
+		aglSetCurrentContext(NULL);
+		aglSetDrawable(glContext, NULL);
+		aglDestroyContext(glContext);		
+		glContext = NULL;
+	}
+#endif
+}
+
+#ifdef HAVE_OPENGL
+
+/* Make the current context active */
+int Mac_GL_MakeCurrent(_THIS)
+{
+	int retval;
+
+	retval = 0;
+	if( ! aglSetCurrentContext(glContext) ) {
+		SDL_SetError("Unable to make GL context current");
+		retval = -1;
+	}
+	return(retval);
+}
+
+void Mac_GL_SwapBuffers(_THIS)
+{
+	aglSwapBuffers(glContext);
+}
+
+#endif /* HAVE_OPENGL */
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macgl_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* AGL implementation of SDL OpenGL support */
+
+#ifdef HAVE_OPENGL
+#ifdef MACOSX
+#include <OpenGL/gl.h> /* OpenGL.framework */
+#include <AGL/agl.h>   /* AGL.framework */
+#else
+#include <GL/gl.h>
+#include <agl.h>
+#endif /* MACOSX */
+#endif /* HAVE_OPENGL */
+
+/* OpenGL functions */
+extern int Mac_GL_Init(_THIS);
+extern void Mac_GL_Quit(_THIS);
+#ifdef HAVE_OPENGL
+extern int Mac_GL_MakeCurrent(_THIS);
+extern int Mac_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+extern void Mac_GL_SwapBuffers(_THIS);
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_mackeys.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,145 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* These are the Macintosh key scancode constants -- from Inside Macintosh */
+
+#define MK_ESCAPE		0x35
+#define MK_F1			0x7A
+#define MK_F2			0x78
+#define MK_F3			0x63
+#define MK_F4			0x76
+#define MK_F5			0x60
+#define MK_F6			0x61
+#define MK_F7			0x62
+#define MK_F8			0x64
+#define MK_F9			0x65
+#define MK_F10			0x6D
+#define MK_F11			0x67
+#define MK_F12			0x6F
+#define MK_PRINT		0x69
+#define MK_SCROLLOCK		0x6B
+#define MK_PAUSE		0x71
+#define MK_POWER		0x7F
+#define MK_BACKQUOTE		0x32
+#define MK_1			0x12
+#define MK_2			0x13
+#define MK_3			0x14
+#define MK_4			0x15
+#define MK_5			0x17
+#define MK_6			0x16
+#define MK_7			0x1A
+#define MK_8			0x1C
+#define MK_9			0x19
+#define MK_0			0x1D
+#define MK_MINUS		0x1B
+#define MK_EQUALS		0x18
+#define MK_BACKSPACE		0x33
+#define MK_INSERT		0x72
+#define MK_HOME			0x73
+#define MK_PAGEUP		0x74
+#define MK_NUMLOCK		0x47
+#define MK_KP_EQUALS		0x51
+#define MK_KP_DIVIDE		0x4B
+#define MK_KP_MULTIPLY		0x43
+#define MK_TAB			0x30
+#define MK_q			0x0C
+#define MK_w			0x0D
+#define MK_e			0x0E
+#define MK_r			0x0F
+#define MK_t			0x11
+#define MK_y			0x10
+#define MK_u			0x20
+#define MK_i			0x22
+#define MK_o			0x1F
+#define MK_p			0x23
+#define MK_LEFTBRACKET		0x21
+#define MK_RIGHTBRACKET		0x1E
+#define MK_BACKSLASH		0x2A
+#define MK_DELETE		0x75
+#define MK_END			0x77
+#define MK_PAGEDOWN		0x79
+#define MK_KP7			0x59
+#define MK_KP8			0x5B
+#define MK_KP9			0x5C
+#define MK_KP_MINUS		0x4E
+#define MK_CAPSLOCK		0x39
+#define MK_a			0x00
+#define MK_s			0x01
+#define MK_d			0x02
+#define MK_f			0x03
+#define MK_g			0x05
+#define MK_h			0x04
+#define MK_j			0x26
+#define MK_k			0x28
+#define MK_l			0x25
+#define MK_SEMICOLON		0x29
+#define MK_QUOTE		0x27
+#define MK_RETURN		0x24
+#define MK_KP4			0x56
+#define MK_KP5			0x57
+#define MK_KP6			0x58
+#define MK_KP_PLUS		0x45
+#define MK_LSHIFT		0x38
+#define MK_z			0x06
+#define MK_x			0x07
+#define MK_c			0x08
+#define MK_v			0x09
+#define MK_b			0x0B
+#define MK_n			0x2D
+#define MK_m			0x2E
+#define MK_COMMA		0x2B
+#define MK_PERIOD		0x2F
+#define MK_SLASH		0x2C
+#if 0	/* These are the same as the left versions - use left by default */
+#define MK_RSHIFT		0x38
+#endif
+#define MK_UP			0x7E
+#define MK_KP1			0x53
+#define MK_KP2			0x54
+#define MK_KP3			0x55
+#define MK_KP_ENTER		0x4C
+#define MK_LCTRL		0x3B
+#define MK_LALT			0x3A
+#define MK_LMETA		0x37
+#define MK_SPACE		0x31
+#if 0	/* These are the same as the left versions - use left by default */
+#define MK_RMETA		0x37
+#define MK_RALT			0x3A
+#define MK_RCTRL		0x3B
+#endif
+#define MK_LEFT			0x7B
+#define MK_DOWN			0x7D
+#define MK_RIGHT		0x7C
+#define MK_KP0			0x52
+#define MK_KP_PERIOD		0x41
+
+/* Wierd, these keys are on my iBook under MacOS X */
+#define MK_IBOOK_ENTER		0x34
+#define MK_IBOOK_LEFT		0x3B
+#define MK_IBOOK_RIGHT		0x3C
+#define MK_IBOOK_DOWN		0x3D
+#define MK_IBOOK_UP		0x3E
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macmouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,130 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <Quickdraw.h>
+#endif
+
+/* Routines that are not supported by the Carbon API... */
+#if !TARGET_API_MAC_CARBON
+#include <CursorDevices.h>
+#endif
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_macmouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	Cursor curs;
+};
+
+
+void Mac_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+	free(cursor);
+}
+
+WMcursor *Mac_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+	WMcursor *cursor;
+	int row, bytes;
+		
+	/* Allocate the cursor memory */
+	cursor = (WMcursor *)malloc(sizeof(WMcursor));
+	if ( cursor == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(cursor, 0, sizeof(*cursor));
+		
+	bytes = (w/8);
+	if ( bytes > 2 ) {
+		bytes = 2;
+	}
+	for ( row=0; row<h && (row < 16); ++row ) {
+		memcpy(&cursor->curs.data[row], data, bytes);
+		data += w/8;
+	}
+	for ( row=0; row<h && (row < 16); ++row ) {
+		memcpy(&cursor->curs.mask[row], mask, bytes);
+		mask += w/8;
+	}
+	cursor->curs.hotSpot.h = hot_x;
+	cursor->curs.hotSpot.v = hot_y;
+
+	/* That was easy. :) */
+	return(cursor);
+}
+
+int Mac_cursor_showing = 1;
+
+int Mac_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	if ( cursor == NULL ) {
+		if ( Mac_cursor_showing ) {
+			HideCursor();
+			Mac_cursor_showing = 0;
+		}
+	} else {
+		SetCursor(&cursor->curs);
+		if ( ! Mac_cursor_showing ) {
+			ShowCursor();
+			Mac_cursor_showing = 1;
+		}
+	}
+	return(1);
+}
+
+void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+#if !TARGET_API_MAC_CARBON
+	CursorDevice *cursordevice;
+
+	cursordevice = nil;
+	CursorDeviceNextDevice(&cursordevice);
+	if ( cursordevice != nil ) {
+		WindowPtr saveport;
+		Point where;
+
+		GetPort(&saveport);
+		SetPort(SDL_Window);
+		where.h = x;
+		where.v = y;
+		LocalToGlobal(&where);
+		SetPort(saveport);
+		CursorDeviceMoveTo(cursordevice, where.h, where.v);
+	}
+#endif /* !TARGET_API_MAC_CARBON */
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macmouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,38 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_romvideo.h"
+
+/* Functions to be exported */
+extern void Mac_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *Mac_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int Mac_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void Mac_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+
+/* Data to be exported */
+extern int Mac_cursor_showing;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macwm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <Windows.h>
+#include <Strings.h>
+#endif
+
+#include "SDL_macwm_c.h"
+
+void Mac_SetCaption(_THIS, const char *title, const char *icon)
+{
+	/* Don't convert C to P string in place, because it may be read-only */
+	Str255		ptitle; /* MJS */
+	ptitle[0] = strlen (title);
+	memcpy(ptitle+1, title, ptitle[0]); /* MJS */
+	if (SDL_Window)
+		SetWTitle(SDL_Window, ptitle); /* MJS */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/maccommon/SDL_macwm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,32 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_romvideo.h"
+
+/* Functions to be exported */
+extern void Mac_SetCaption(_THIS, const char *title, const char *icon);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macdsp/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macdsp/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,10 @@
+
+## Makefile.am for SDL using the Mac DrawSprocket video driver
+
+noinst_LTLIBRARIES = libvideo_dsp.la
+libvideo_dsp_la_SOURCES = $(DSP_SRCS)
+
+# The SDL Mac DrawSprocket driver sources
+DSP_SRCS = 			\
+	SDL_dspvideo.c		\
+	SDL_dspvideo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macdsp/SDL_dspvideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1386 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+/*
+ Written by Darrell Walisser <dwaliss1@purdue.edu>
+
+ Implementation notes ----------------------------------------------------------------------
+
+ A bit on GWorlds in VRAM from technote 1182:
+
+ There are two important things to note about GWorld's allocated in
+ VRAM. First, the base address retrieved through GetPixBaseAddr or
+ read directly from the PixMap structure can become invalid anytime
+ memory is allocated in VRAM. This can occur either by explicit
+ allocations, such as calls to NewGWorld, or by implicit ones, such as
+ those associated with the internal texture allocation of OpenGL. The
+ stored pixel images themselves will still be valid but may have been
+ moved in VRAM, thus rendering any stored base addresses invalid.
+ You should never store an image's base address for longer than is
+ necessary and especially never across calls to NewGWorld or
+ texture-creation routines. 
+
+ Secondly, an offscreen pixel image allocated in VRAM can be
+ purged at system task time by the display driver. This means any
+ time your application yields time such by calling WaitNextEvent or
+ SystemTask you can lose your VRAM GWorld contents. While this
+ happens infrequently, usually associated with display resolution or
+ pixel depth changes you must code for this eventuality. This purge
+ can occur whether or not the GWorld is locked or not. A return value
+ of false from LockPixels, a NULL return value from GetPixBaseAddr
+ or NULL in the baseAddr field of the PixMap mean that the pixel
+ image has been purged. To reallocate it you can either call
+ UpdateGWorld or Dispose your current GWorld through
+ DisposeGWorld and reallocate it via NewGWorld. Either way you must
+ then rebuild the pixel image. 
+
+------------------------------------------------------------------------------------
+
+  Currently, I don't account for (1). In my testing, NewGWorld never invalidated
+  other existing GWorlds in VRAM. However, I do have protection for (2).
+  Namely, I am using GetOSEvent() instead of WaitNextEvent() so that there are no
+  context switches (the app hogs the CPU). Eventually a book-keeping system should
+  be coded to take care of (1) and (2).
+  
+------------------------------------------------------------------------------------
+
+  System requirements (* denotes optional):
+  
+  1. DrawSprocket 1.7.3
+  2. *MacOS 9 or later for hardware accelerated blit / fill
+  3. *May also require certain graphics hardware for (2). I trust that all Apple OEM
+     hardware will work. Third party accelerators may work if they have QuickDraw
+     acceleration in the drivers and the drivers have been updated for OS 9. The current
+     Voodoo 3 drivers (1.0b12) do not work.
+  
+  Coding suggestions:
+  
+  1. Use SDL_UpdateRects !
+  
+    If no QuickDraw acceleration is present, double-buffered surfaces will use a back buffer
+    in System memory. I recommend you use SDL_UpdateRects with double-buffered surfaces
+    for best performance on these cards, since the overhead is nearly zero for VRAM back buffer.
+    
+  2. Load most-resident surfaces first.
+  
+    If you fill up VRAM or AGP memory, there is no contingency for purging to make room for the next one.
+    Therefore, you should load the surfaces you plan to use the most frequently first.
+    Sooner or later, I will code LRU replacement to help this.
+  
+  TODO:
+  Some kind of posterized mode for resolutions < 640x480.
+  Window support / fullscreen toggle.
+  Figure out how much VRAM is available. Put in video->info->video_mem.
+  Track VRAM usage.
+  
+  BUGS:
+  I can't create a hardware surface the same size as the screen?! How to fix?
+  
+  
+
+   COMPILE OPTIONS:
+   
+   DSP_TRY_CC_AND_AA - Define if you want to try HWA color-key and alpha blitters
+                       HW color-key blitting gives substantial improvements,
+                       but hw alpha is neck-and-neck with SDL's soft bitter.
+
+   DSP_NO_SYNC_VBL   - Define for HWA double-buffered surfaces: don't sync
+                       pseudo-flip to monitor redraw.
+
+   DSP_NO_SYNC_OPENGL - Define for OpenGL surfaces: don't sync buffer swap. Synching buffer
+                        swap may result in reduced performance, but can eliminate some
+                        tearing artifacts.
+   CHANGELOG:
+   09/17/00 Lots of little tweaks. Build modelist in reverse order so largest contexts
+            list first. Compared various methods with ROM methods and fixed rez switch
+            crashing bug in GL Tron. (Woohoo!)
+*/
+
+#define DSP_TRY_CC_AND_AA
+
+/* #define DSP_NO_SYNC_VBL */
+
+#define DSP_NO_SYNC_OPENGL
+
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+#else
+#include <LowMem.h>
+#include <Gestalt.h>
+#include <Devices.h>
+#include <DiskInit.h>
+#include <QDOffscreen.h>
+#endif
+
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_sysvideo.h"
+#include "SDL_dspvideo.h"
+#include "SDL_macgl_c.h"
+#include "SDL_macwm_c.h"
+#include "SDL_macmouse_c.h"
+#include "SDL_macevents_c.h"
+
+/* Initialization/Query functions */
+static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *DSp_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int DSp_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static int DSp_CreatePalette(_THIS);
+static int DSp_DestroyPalette(_THIS);
+static void DSp_VideoQuit(_THIS);
+
+static int DSp_GetMainDevice (_THIS, GDHandle *device);
+static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat);
+static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect *sdl_rects);
+static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *sdl_rects);
+
+/* Hardware surface functions */
+static int DSp_SetHWAlpha(_THIS, SDL_Surface *surface, UInt8 alpha);
+static int DSp_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
+static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int height);
+static int DSp_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int DSp_LockHWSurface(_THIS, SDL_Surface *surface);
+static void DSp_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void DSp_FreeHWSurface(_THIS, SDL_Surface *surface);
+static int DSp_FlipHWSurface(_THIS, SDL_Surface *surface);
+static int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest);
+static int DSp_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                           SDL_Surface *dst, SDL_Rect *dstrect);
+static int DSp_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color);
+
+#ifdef HAVE_OPENGL
+   static void DSp_GL_SwapBuffers (_THIS);
+#endif
+
+#if ! TARGET_API_MAC_CARBON
+
+    #define GetPortPixRowBytes(x)  ( (*(x->portPixMap))->rowBytes )
+   #define GetGDevPixMap(x) ((**(x)).gdPMap)   
+   #define GetPortPixMap(x) ((*(x)).portPixMap)
+   
+   #define GetPixDepth(y)    ((**(y)).pixelSize)
+   //#define GetPixRowBytes(y) ((**(y)).rowBytes)
+   //#define GetPixBaseAddr(y) ((**(y)).baseAddr)
+   #define GetPixCTab(y)     ((**(y)).pmTable)
+    #define GetPortBitMapForCopyBits(x) (&(((GrafPtr)(x))->portBits))
+   
+#else
+    #define GetPortPixRowBytes(x) (GetPixRowBytes(GetPortPixMap(x)) )
+    #define GetGDevPixMap(x) ((**(x)).gdPMap)
+
+#endif
+
+typedef struct private_hwdata {
+
+  GWorldPtr offscreen;    // offscreen gworld in VRAM or AGP
+  
+  #ifdef DSP_TRY_CC_AND_AA
+    GWorldPtr mask;         // transparent mask
+    RGBColor  alpha;        // alpha color
+    RGBColor  trans;        // transparent color
+  #endif
+  
+} private_hwdata;
+
+typedef private_hwdata private_swdata ; /* have same fields */
+
+/* Macintosh toolbox driver bootstrap functions */
+
+static int DSp_Available(void)
+{
+	/* Check for DrawSprocket */
+	/* This check is only meaningful if you weak-link DrawSprocketLib */  
+	return ((Ptr)DSpStartup != (Ptr)kUnresolvedCFragSymbolAddress);
+}
+
+static void DSp_DeleteDevice(SDL_VideoDevice *device)
+{
+	/* -dw- taking no chances with null pointers */
+	if (device) {
+		
+   	if (device->hidden) {
+   	   
+   	   if (device->hidden->dspinfo)
+	         free(device->hidden->dspinfo);
+   	   
+   	   free(device->hidden);
+   	}
+	   free(device);	
+	}
+}
+
+static SDL_VideoDevice *DSp_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, sizeof (*device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	    if (device->hidden)
+	        memset(device->hidden, 0, sizeof ( *(device->hidden) ) );
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+			
+		if ( device ) {
+			
+			if (device->hidden)
+		        free (device->hidden);			
+			
+			free(device);
+		}
+		
+		return(NULL);
+	}
+	
+	/* Allocate DrawSprocket information */
+	device->hidden->dspinfo = (struct DSpInfo *)malloc(
+					(sizeof *device->hidden->dspinfo));
+	if ( device->hidden->dspinfo == NULL ) {
+		SDL_OutOfMemory();
+		free(device->hidden);
+		free(device);
+		return(0);
+	}
+	memset(device->hidden->dspinfo, 0, (sizeof *device->hidden->dspinfo));
+
+	/* Set the function pointers */
+	device->VideoInit       = DSp_VideoInit;
+	device->ListModes       = DSp_ListModes;
+	device->SetVideoMode    = DSp_SetVideoMode;
+	device->SetColors       = DSp_SetColors;
+	device->UpdateRects     = NULL;
+	device->VideoQuit       = DSp_VideoQuit;
+	device->AllocHWSurface  = DSp_AllocHWSurface;
+	device->CheckHWBlit     = NULL;
+	device->FillHWRect      = NULL;
+	device->SetHWColorKey   = NULL;
+	device->SetHWAlpha      = NULL;
+	device->LockHWSurface   = DSp_LockHWSurface;
+	device->UnlockHWSurface = DSp_UnlockHWSurface;
+	device->FlipHWSurface   = DSp_FlipHWSurface;
+	device->FreeHWSurface   = DSp_FreeHWSurface;
+#ifdef HAVE_OPENGL
+	device->GL_MakeCurrent  = Mac_GL_MakeCurrent;
+	device->GL_SwapBuffers  = DSp_GL_SwapBuffers;
+#endif
+	device->SetCaption = NULL;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->FreeWMCursor    = Mac_FreeWMCursor;
+	device->CreateWMCursor  = Mac_CreateWMCursor;
+	device->ShowWMCursor    = Mac_ShowWMCursor;
+	device->WarpWMCursor    = Mac_WarpWMCursor;
+	device->InitOSKeymap    = Mac_InitOSKeymap;
+	device->PumpEvents      = Mac_PumpEvents;
+	
+	device->GrabInput      = NULL;
+	device->CheckMouseMode = NULL;
+	
+	device->free = DSp_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap DSp_bootstrap = {
+	"DSp", "MacOS DrawSprocket",
+	DSp_Available, DSp_CreateDevice
+};
+
+/* Use DSp/Display Manager to build mode list for given screen */
+static SDL_Rect**  DSp_BuildModeList (const GDHandle gDevice)
+{
+	DSpContextAttributes  attributes;
+	DSpContextReference   context;
+	DisplayIDType         displayID;
+	SDL_Rect temp_list [16];
+	SDL_Rect **mode_list;
+	int width, height, i, j;
+        
+        #if TARGET_API_MAC_OSX		
+	
+        displayID = 0;
+        
+        #else
+        /* Ask Display Manager for integer id of screen device */
+	if ( DMGetDisplayIDByGDevice (gDevice, &displayID, SDL_TRUE) != noErr ) {
+		return NULL;
+	}
+	#endif
+	/* Get the first possible DSp context on this device */
+	if ( DSpGetFirstContext (displayID, &context) != noErr ) {
+		return NULL;
+	}
+	
+	if ( DSpContext_GetAttributes (context, &attributes) != noErr )
+		return NULL;
+			
+	for ( i = 0; i < SDL_TABLESIZE(temp_list); i++ ) {
+		width  = attributes.displayWidth;
+		height = attributes.displayHeight;
+		
+		temp_list [i].x = 0 | attributes.displayBestDepth;
+		temp_list [i].y = 0;
+		temp_list [i].w = width;
+		temp_list [i].h = height;
+	
+		/* DSp will report many different contexts with the same width and height. */
+		/* They will differ in bit depth and refresh rate. */
+		/* We will ignore them until we reach one with a different width/height */
+		/* When there are no more contexts to look at, we will quit building the list*/
+		while ( width == attributes.displayWidth && height == attributes.displayHeight ) {
+		
+			OSStatus err = DSpGetNextContext (context, &context);
+			if (err != noErr)
+				if (err == kDSpContextNotFoundErr)
+					goto done;
+				else
+					return NULL;		
+			
+			if ( DSpContext_GetAttributes (context, &attributes) != noErr )
+				return NULL;
+				
+			temp_list [i].x |= attributes.displayBestDepth;
+		}
+	}
+done:
+	i++;          /* i was not incremented before kicking out of the loop */
+	
+	mode_list = (SDL_Rect**) malloc (sizeof (SDL_Rect*) * (i+1));
+	if (mode_list) {
+	
+	   /* -dw- new stuff: build in reverse order so largest sizes list first */
+		for (j = i-1; j >= 0; j--) {
+			mode_list [j] = (SDL_Rect*) malloc (sizeof (SDL_Rect));	
+			if (mode_list [j])
+				memcpy (mode_list [j], &(temp_list [j]), sizeof (SDL_Rect));
+			else {
+				SDL_OutOfMemory ();
+				return NULL;
+			}
+		}
+		mode_list [i] = NULL;		/* append null to the end */
+	}
+	else {
+		SDL_OutOfMemory ();
+		return NULL;
+	}
+		
+	return mode_list;
+}
+
+static void DSp_IsHWAvailable (_THIS, SDL_PixelFormat *vformat)
+{
+  /* 
+     VRAM GWorlds are only available on OS 9 or later.
+     Even with OS 9, some display drivers won't support it, 
+     so we create a test GWorld and check for errors. 
+  */
+
+  long versionSystem;
+
+  dsp_vram_available = SDL_FALSE;
+  dsp_agp_available  = SDL_FALSE;
+  
+  Gestalt ('sysv', &versionSystem);
+  if (0x00000860 < (versionSystem & 0x0000FFFF)) {
+    
+    GWorldPtr offscreen;
+    OSStatus  err;
+    Rect      bounds;
+    
+    SetRect (&bounds, 0, 0, 320, 240);
+    
+    err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useDistantHdwrMem | noNewDevice);
+    if (err == noErr) {
+      dsp_vram_available = SDL_TRUE;
+      DisposeGWorld (offscreen);
+    }
+	
+    err = NewGWorld (&offscreen, vformat->BitsPerPixel, &bounds, NULL, SDL_Display, useLocalHdwrMem | noNewDevice);
+    if (err == noErr) {
+      DisposeGWorld (offscreen);
+      dsp_agp_available = SDL_TRUE;
+    }
+  }
+}
+
+static int DSp_GetMainDevice (_THIS, GDHandle *device)
+{
+    
+#if TARGET_API_MAC_OSX
+        /* DSpUserSelectContext not available on OS X */
+        *device = GetMainDevice();
+        return 0;
+#else
+        
+	DSpContextAttributes attrib;
+	DSpContextReference  context;
+	DisplayIDType        display_id;
+	GDHandle             main_device;
+	GDHandle             device_list;
+	
+	device_list = GetDeviceList ();
+	main_device = GetMainDevice ();
+	
+	/* Quick check to avoid slower method when only one display exists */
+	if ( (**device_list).gdNextGD == NULL ) {
+	  *device = main_device;
+	  return 0;
+	}
+		
+	memset (&attrib, 0, sizeof (DSpContextAttributes));
+
+	/* These attributes are hopefully supported on all devices...*/
+	attrib.displayWidth         = 640;
+	attrib.displayHeight        = 480;
+	attrib.displayBestDepth     = 8;
+	attrib.backBufferBestDepth  = 8;
+	attrib.displayDepthMask     = kDSpDepthMask_All;
+	attrib.backBufferDepthMask  = kDSpDepthMask_All;
+	attrib.colorNeeds           = kDSpColorNeeds_Require;
+	attrib.pageCount            = 1;
+			 
+	if (noErr != DMGetDisplayIDByGDevice (main_device, &display_id, SDL_FALSE)) {
+		SDL_SetError ("Display Manager couldn't associate GDevice with a Display ID");
+		return (-1);
+	}
+	
+	/* Put up dialog on main display to select which display to use */
+	if (noErr != DSpUserSelectContext (&attrib, display_id, NULL, &context)) {
+		SDL_SetError ("DrawSprocket couldn't create a context");
+		return (-1);
+	}
+         
+	if (noErr != DSpContext_GetDisplayID (context, &display_id)) {
+		SDL_SetError ("DrawSprocket couldn't get display ID");
+		return (-1);
+	}
+  
+	if (noErr != DMGetGDeviceByDisplayID  (display_id, &main_device, SDL_FALSE)) {
+		SDL_SetError ("Display Manager couldn't associate Display ID with GDevice");
+		return (-1);  
+	}
+
+	*device = main_device;
+	return (0);
+#endif
+}
+
+static int DSp_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	
+	NumVersion dsp_version = DSpGetVersion ();
+	
+	if (  (dsp_version.majorRev == 1 && dsp_version.minorAndBugRev < 0x73) ||
+	      (dsp_version.majorRev < 1)  ) {                          
+	    
+	   /* StandardAlert (kAlertStopAlert, "\pError!", 
+	                "\pI need DrawSprocket 1.7.3 or later!\n"
+	                  "You can find a newer version at http://www.apple.com/swupdates.",
+	                   NULL, NULL);
+	    */              
+	    SDL_SetError ("DrawSprocket version is too old. Need 1.7.3 or later.");
+	    return (-1);
+	}
+	
+	if ( DSpStartup () != noErr ) {
+		SDL_SetError ("DrawSprocket couldn't startup");
+		return(-1);
+	}
+	
+	/* Start DSpintosh events */
+	Mac_InitEvents(this);
+
+	/* Get a handle to the main monitor, or choose one on multiple monitor setups */
+	if ( DSp_GetMainDevice(this, &SDL_Display) <  0)
+		return (-1);
+
+	/* Determine pixel format */
+    vformat->BitsPerPixel = GetPixDepth ( (**SDL_Display).gdPMap );
+	dsp_old_depth = vformat->BitsPerPixel;
+		
+	switch (vformat->BitsPerPixel) {
+		case 16:	
+			vformat->Rmask = 0x00007c00;
+			vformat->Gmask = 0x000003e0;
+			vformat->Bmask = 0x0000001f;
+			break;
+		default:
+			break;
+	}
+   
+   if ( DSp_CreatePalette (this) < 0 ) {
+   
+      SDL_SetError ("Could not create palette");
+      return (-1);
+   }
+   
+	/* Get a list of available fullscreen modes */
+	SDL_modelist = DSp_BuildModeList (SDL_Display);
+	if (SDL_modelist == NULL) {
+		SDL_SetError ("DrawSprocket could not build a mode list");
+		return (-1);
+	}
+	
+	/* Check for VRAM and AGP GWorlds for HW Blitting */
+	DSp_IsHWAvailable (this, vformat);
+	
+	this->info.wm_available = 0;
+
+	if (dsp_vram_available || dsp_agp_available) {
+    
+	  this->info.hw_available = SDL_TRUE;
+	  
+	  this->CheckHWBlit  = DSp_CheckHWBlit;
+	  this->info.blit_hw = SDL_TRUE; 
+  
+	  this->FillHWRect     = DSp_FillHWRect;
+	  this->info.blit_fill = SDL_TRUE;
+	  
+	#ifdef DSP_TRY_CC_AND_AA  
+	  this->SetHWColorKey   = DSp_SetHWColorKey;
+	  this->info.blit_hw_CC = SDL_TRUE;
+	  
+	  this->SetHWAlpha      = DSp_SetHWAlpha;
+	  this->info.blit_hw_A  = SDL_TRUE;
+	#endif
+	
+	}  
+    
+	return(0);
+}
+
+static SDL_Rect **DSp_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	static SDL_Rect *dsp_modes[16];
+	int i = 0, j = 0;
+	
+	if ( format->BitsPerPixel == 0 )
+	   return ( (SDL_Rect**) NULL );
+	
+	while (SDL_modelist[i] != NULL) {
+	
+	   if (SDL_modelist[i]->x & format->BitsPerPixel) {
+	      dsp_modes[j] = SDL_modelist[i];
+	      j++;
+	   }
+	   i++;
+	}
+	
+	dsp_modes[j] = NULL;
+
+	return dsp_modes;
+}
+
+/* Various screen update functions available */
+static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+static volatile unsigned int retrace_count = 0; /* -dw- need volatile because it updates asychronously */
+
+#if ! TARGET_API_MAC_OSX
+Boolean DSp_VBLProc ( DSpContextReference context, void *ref_con )
+{
+	retrace_count++;
+	
+	return 1; /* Darrell, is this right? */
+}
+#endif
+
+static void DSp_SetHWError (OSStatus err, int is_agp)
+{
+	char message[1024];
+	const char *fmt, *mem;
+
+	if ( is_agp ) {
+		mem = "AGP Memory";
+	} else {
+		mem = "VRAM";
+	}
+	switch(err) {
+	    case memFullErr:
+		fmt = "Hardware surface possible but not enough %s available";
+		break;
+	    case cDepthErr:
+		fmt = "Hardware surface possible but invalid color depth";
+		break;
+	    default:
+		fmt = "Hardware surface could not be allocated in %s - unknown error";
+		break;
+	}
+	sprintf(message, fmt, mem);
+	SDL_SetError(message);
+}
+
+/* put up a dialog to verify display change */
+static int DSp_ConfirmSwitch () {
+
+  /* resource id's for dialog */
+  const int rDialog = 1002;
+  const int bCancel = 1;
+  const int bOK     = 2;
+  
+  DialogPtr dialog;
+  OSStatus  err;
+  SInt32    response;
+  DialogItemIndex       item = 0;
+  GrafPtr   savePort;
+    
+  GetPort (&savePort);
+  
+  dialog = GetNewDialog (rDialog, NULL, (WindowPtr) -1);
+  if (dialog == NULL)
+	 return (0);
+  
+  SetPort (dialog);
+  
+  SetDialogDefaultItem (dialog, bCancel);
+  SetDialogCancelItem  (dialog, bCancel);
+  
+  SetEventMask (everyEvent);  
+  FlushEvents (everyEvent, 0);
+   
+   /* On MacOS 8.5 or later, we can make the dialog go away after 15 seconds */
+   /* This is good since it's possible user can't even see the dialog! */
+   /* Requires linking to DialogsLib */
+   err = Gestalt(gestaltSystemVersion,&response);
+   if (err == noErr && response >= 0x00000850) {
+   	SetDialogTimeout(dialog, bCancel, 15);
+   }
+
+   do {      
+    
+    ModalDialog ( NULL, &item );  
+
+   } while ( item != bCancel && item != bOK && err != noErr);
+
+  DisposeWindow (dialog);
+  SetPort (savePort);
+  
+  SetEventMask(everyEvent - autoKeyMask);
+  FlushEvents(everyEvent, 0);
+   
+  return (item - 1);
+}
+
+static void DSp_UnsetVideoMode(_THIS, SDL_Surface *current)
+{
+			
+		
+	 if ( current->flags & SDL_OPENGL )  { 
+	   Mac_GL_Quit (this);	   	
+	}
+		
+	if (dsp_context != NULL) {
+		
+		GWorldPtr front;
+		DSpContext_GetFrontBuffer (dsp_context, &front);
+		
+		if (front != dsp_back_buffer)
+		   DisposeGWorld (dsp_back_buffer);
+		
+		if (current->hwdata)
+		   free (current->hwdata);
+		   
+		DSpContext_SetState (dsp_context, kDSpContextState_Inactive );
+		DSpContext_Release  (dsp_context);
+		
+		dsp_context = NULL;
+	}
+    	
+    if (SDL_Window != NULL) {
+        DisposeWindow (SDL_Window);
+        SDL_Window = NULL;
+    }    
+    
+    current->pixels = NULL;
+    current->flags  = 0;
+}
+
+static SDL_Surface *DSp_SetVideoMode(_THIS,
+	SDL_Surface *current, int width, int height, int bpp, Uint32 flags)
+{
+	
+	DisplayIDType        display_id;
+	DSpContextAttributes attrib;
+	Fixed freq;
+	OSStatus err;
+	UInt32 rmask = 0, gmask = 0, bmask = 0;
+		
+	int   page_count;
+	int   double_buf;
+	int   hw_surface;
+	int   use_dsp_back_buffer;
+     
+	DSp_UnsetVideoMode (this, current);
+       
+    if (bpp != dsp_old_depth)
+        DSp_DestroyPalette (this);
+   
+	double_buf = (flags & SDL_DOUBLEBUF) != 0;
+	hw_surface = (flags & SDL_HWSURFACE) != 0;
+	use_dsp_back_buffer = !dsp_vram_available || !hw_surface ;
+	
+	current->flags |= SDL_FULLSCREEN;
+
+rebuild:  
+  
+	if ( double_buf && use_dsp_back_buffer ) {
+		page_count = 2;
+	} else {
+		page_count = 1;
+	}
+
+	memset (&attrib, 0, sizeof (DSpContextAttributes));
+	attrib.displayWidth         = width;
+	attrib.displayHeight        = height;
+	attrib.displayBestDepth     = bpp;
+	attrib.backBufferBestDepth  = bpp;
+	attrib.displayDepthMask     = kDSpDepthMask_All;
+	attrib.backBufferDepthMask  = kDSpDepthMask_All;
+	attrib.colorNeeds           = kDSpColorNeeds_Require;
+	attrib.colorTable           = 0;
+	attrib.pageCount            = page_count;
+        #if TARGET_API_MAC_OSX
+        
+        if ( DSpFindBestContext (&attrib, &dsp_context) != noErr ) {
+            SDL_SetError ("DrawSprocket couldn't find a context");
+            return NULL;
+        }
+        
+        #else
+	if ( noErr != DMGetDisplayIDByGDevice (SDL_Display, &display_id, SDL_FALSE) ) {
+		SDL_SetError ("Display Manager couldn't associate GDevice with display_id");
+		return NULL;
+	}	
+	if ( DSpFindBestContextOnDisplayID (&attrib, &dsp_context, display_id) != noErr ) {
+		SDL_SetError ("DrawSprocket couldn't find a suitable context on given display");
+		return NULL;
+	}
+	
+        #endif		
+	if ( DSpContext_Reserve (dsp_context, &attrib) != noErr ) {
+		SDL_SetError ("DrawSprocket couldn't get the needed resources to build the display");
+		return NULL;
+	}
+	
+	if ( (err = DSpContext_SetState (dsp_context, kDSpContextState_Active)) != noErr ) {
+		
+		if (err == kDSpConfirmSwitchWarning) {     
+		  
+		   if ( ! DSp_ConfirmSwitch () ) {
+		   
+		      DSpContext_Release (dsp_context);
+		      dsp_context = NULL;
+		      SDL_SetError ("User cancelled display switch");
+		      return NULL;
+		   }
+		   else
+		     /* Have to reactivate context. Why? */
+		     DSpContext_SetState (dsp_context, kDSpContextState_Active);
+		      
+	   }
+	   else {
+	      SDL_SetError ("DrawSprocket couldn't activate the context");
+		  return NULL;
+	   }
+	}
+   
+   
+	if (bpp != dsp_old_depth) {
+   	
+   	    DSp_CreatePalette  (this);
+   
+       	/* update format if display depth changed */
+       	if (bpp == 16) {
+       	
+       	   rmask = 0x00007c00;
+       	   gmask = 0x000003e0;
+       	   bmask = 0x0000001f;
+       	}
+       	if ( ! SDL_ReallocFormat (current, bpp, rmask, gmask, bmask, 0 ) ) {
+       		
+       	   SDL_SetError ("Could not reallocate video format.");
+       	   return(NULL);
+       	}
+	}
+	
+	if (!double_buf) {
+		
+		/* single-buffer context */
+		DSpContext_GetFrontBuffer (dsp_context, &dsp_back_buffer);
+			
+		current->hwdata   = (private_hwdata*) malloc (sizeof (private_hwdata));
+		if (current ->hwdata == NULL) {
+			SDL_OutOfMemory ();
+	  		return NULL;		  
+		}
+		current->hwdata->offscreen = dsp_back_buffer;
+	    current->flags   |= SDL_HWSURFACE;
+	    this->UpdateRects = DSp_DirectUpdate;
+	} 
+	else if ( use_dsp_back_buffer ) {
+	
+		DSpContext_GetBackBuffer  (dsp_context, kDSpBufferKind_Normal, &dsp_back_buffer);
+		
+		current->flags   |= SDL_DOUBLEBUF | SDL_SWSURFACE; /* only front buffer is in VRAM */                                     
+	    this->UpdateRects = DSp_DSpUpdate;	
+	} 
+	else if ( DSp_NewHWSurface(this, &dsp_back_buffer, bpp, width-1, height-1) == 0 ) {
+      
+      current->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata));
+      if (current ->hwdata == NULL) {
+      	SDL_OutOfMemory ();
+      	return NULL;		  
+      }
+      
+      memset (current->hwdata, 0, sizeof (private_hwdata));
+      current->hwdata->offscreen = dsp_back_buffer;
+      current->flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; 
+      this->UpdateRects = DSp_DirectUpdate; /* hardware doesn't do update rects, must be page-flipped */	   
+   }  	
+   else {
+
+	   DSpContext_Release (dsp_context);	
+	   use_dsp_back_buffer = SDL_TRUE;
+	   goto  rebuild;
+    }
+	   	
+    current->pitch  = GetPortPixRowBytes(dsp_back_buffer) & 0x3FFF;
+	current->pixels = GetPixBaseAddr(GetPortPixMap(dsp_back_buffer));
+	
+	current->w = width;
+	current->h = height;
+	
+    #if ! TARGET_API_MAC_OSX
+        
+	if (use_dsp_back_buffer) {
+	   
+	   DSpContext_GetMonitorFrequency (dsp_context, &freq);
+	   DSpContext_SetMaxFrameRate     (dsp_context, freq >> 16);
+	}
+	
+    
+	if ( (current->flags & SDL_HWSURFACE) || (current->flags & SDL_OPENGL) )
+		DSpContext_SetVBLProc (dsp_context, DSp_VBLProc, NULL);
+    #endif
+	
+	if (bpp == 8)	
+	   current->flags |= SDL_HWPALETTE;
+	
+	if (flags & SDL_OPENGL) {
+		   
+	   Rect rect;
+	   RGBColor rgb = { 0.0, 0.0, 0.0 };
+	   GrafPtr save_port;
+	   
+	   SetRect (&rect, 0, 0, width, height);
+	   SDL_Window = NewCWindow(nil, &( (**SDL_Display).gdRect), "\p", SDL_TRUE, plainDBox, (WindowPtr)-1, SDL_FALSE, 0);
+		   
+	   if (SDL_Window == NULL) {
+		 
+		   SDL_SetError ("DSp_SetVideoMode : OpenGL window could not be created.");
+		   return NULL;  			   	
+	   }
+	   
+	   /* Set window color to black to avoid white flash*/
+	   GetPort (&save_port);
+	   SetPort (SDL_Window);
+	      RGBForeColor (&rgb);
+	      PaintRect    (&rect);	
+	   SetPort (save_port);
+	   
+	   SetPortWindowPort (SDL_Window);
+	   SelectWindow  (SDL_Window);
+	     
+	   if ( Mac_GL_Init (this) < 0 ) {
+	   
+	      SDL_SetError ("DSp_SetVideoMode : could not create OpenGL context.");
+	      return NULL;
+	   }
+	   	   	   	   
+	   current->flags |= SDL_OPENGL;	
+	}
+	
+	return current; 
+}
+
+#ifdef DSP_TRY_CC_AND_AA
+
+static int DSp_MakeHWMask (_THIS, SDL_Surface *surface)
+{
+    GDHandle save_device;
+    CGrafPtr save_port;
+    GWorldPtr temp;
+    RGBColor black = { 0, 0, 0 };
+    RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
+    Rect     rect;
+    
+    Uint32 depth = GetPixDepth ( GetGDevPixMap (SDL_Display) );
+    
+    SetRect (&rect, 0, 0, surface->w, surface->h);
+    
+    if ( noErr != NewGWorld (&(surface->hwdata->mask), depth, &rect, 0, SDL_Display, 0 ) < 0 ) {
+    
+        SDL_OutOfMemory ();
+        return (-1);
+    }   
+    
+    if ( noErr != NewGWorld (&temp, depth, &rect, 0 , SDL_Display, 0 ) ) {
+    
+        SDL_OutOfMemory ();
+        return (-1);
+    }                         
+
+            
+    GetGWorld (&save_port, &save_device);
+    SetGWorld (surface->hwdata->mask, SDL_Display);
+    
+    RGBForeColor (&white);
+    PaintRect    (&rect);
+                 
+    RGBBackColor (&(surface->hwdata->trans));
+    
+    CopyBits ( GetPortBitMapForCopyBits(surface->hwdata->offscreen),
+                 GetPortBitMapForCopyBits(surface->hwdata->mask),
+    	       &rect, &rect, transparent, NULL );
+        
+    SetGWorld (surface->hwdata->mask, SDL_Display);    
+    SetGWorld (save_port, save_device);     
+    return (0);
+}
+
+static int DSp_SetHWAlpha(_THIS, SDL_Surface *surface, UInt8 alpha)
+{
+    surface->hwdata->alpha.red   = (alpha / 255.0) * 65535;
+    surface->hwdata->alpha.blue  = (alpha / 255.0) * 65535;
+    surface->hwdata->alpha.green = (alpha / 255.0) * 65535;
+
+    surface->flags |= SDL_SRCALPHA;
+
+    if (surface->flags & SDL_SRCCOLORKEY) {
+        return(DSp_MakeHWMask (this, surface));
+    }
+    return(0);
+}
+
+static int DSp_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+    CGrafPtr save_port;
+    GDHandle save_device;
+    
+    GetGWorld (&save_port, &save_device);
+    SetGWorld (surface->hwdata->offscreen, NULL);
+    
+    Index2Color (key, &(surface->hwdata->trans));
+    surface->flags |= SDL_SRCCOLORKEY;    
+    
+    SetGWorld (save_port, save_device);
+    
+    if ( surface->flags & SDL_SRCALPHA ) {
+        return(DSp_MakeHWMask (this, surface));    
+    } 
+    return(0);
+}
+
+#endif /* DSP_TRY_CC_AND_AA */
+
+static int DSp_NewHWSurface(_THIS, CGrafPtr *port, int depth, int width, int height) {
+   
+   OSStatus err;
+   Rect     bounds;
+		
+	SetRect (&bounds, 0, 0, width, height);
+   
+    if (dsp_vram_available) {
+	   /* try VRAM */
+   	  err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useDistantHdwrMem | noNewDevice );
+      if (err != noErr)
+         DSp_SetHWError (err, SDL_FALSE);        
+      else
+         return (0);      
+    }
+    
+    if (dsp_agp_available) {
+      /* try AGP */
+      err = NewGWorld (port, depth, &bounds, 0 , SDL_Display, useLocalHdwrMem | noNewDevice );
+                                            
+      if (err != noErr)
+         DSp_SetHWError (err, SDL_TRUE);
+      else   
+         return (0);     
+     }  
+                  
+   return (-1);  
+}
+
+static int DSp_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	GWorldPtr temp;
+	 	 
+	if ( DSp_NewHWSurface (this, &temp, surface->format->BitsPerPixel, surface->w, surface->h) < 0 )
+	   return (-1);
+			
+	surface->hwdata = (private_hwdata*) malloc (sizeof (private_hwdata));
+	if (surface->hwdata == NULL) {
+		SDL_OutOfMemory ();
+		return -1;
+	}
+	
+	memset (surface->hwdata, 0, sizeof(private_hwdata));
+	surface->hwdata->offscreen = temp;
+	surface->pitch	 = GetPixRowBytes (GetPortPixMap (temp)) & 0x3FFF;
+	surface->pixels  = GetPixBaseAddr (GetPortPixMap (temp));
+	surface->flags	|= SDL_HWSURFACE;
+#ifdef DSP_TRY_CC_AND_AA	
+	surface->flags  |= SDL_HWACCEL;
+#endif	
+	return 0;
+}
+
+static void DSp_FreeHWSurface(_THIS, SDL_Surface *surface)
+{	
+	if (surface->hwdata->offscreen != NULL)
+		DisposeGWorld (surface->hwdata->offscreen);
+	free (surface->hwdata);
+
+    surface->pixels = NULL;
+}
+
+static int DSp_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dest)
+{
+	int accelerated;
+
+	/* Set initial acceleration on */
+	src->flags |= SDL_HWACCEL;
+
+	/* Set the surface attributes */
+	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		if ( ! this->info.blit_hw_A ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		if ( ! this->info.blit_hw_CC ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+
+	/* Check to see if final surface blit is accelerated */
+	accelerated = !!(src->flags & SDL_HWACCEL);
+	if ( accelerated ) {
+		src->map->hw_blit = DSp_HWAccelBlit;
+	}
+	return(accelerated);
+}
+
+static int DSp_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                           SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	CGrafPtr save_port;
+	GDHandle save_device;
+	Rect src_rect, dst_rect;
+    RGBColor black = { 0, 0, 0 };
+    RGBColor white = { 0xFFFF, 0xFFFF, 0xFFFF };
+
+#ifdef DSP_TRY_CC_AND_AA		
+	UInt32 mode;	
+#endif
+	
+	SetRect (&src_rect, srcrect->x, srcrect->y, srcrect->x + srcrect->w, srcrect->y + srcrect->h);
+	SetRect (&dst_rect, dstrect->x, dstrect->y, dstrect->x + dstrect->w, dstrect->y + dstrect->h);
+	
+	GetGWorld (&save_port, &save_device);
+	SetGWorld (dst->hwdata->offscreen, NULL);		
+		
+	RGBForeColor (&black);
+	RGBBackColor (&white);
+		
+#ifdef DSP_TRY_CC_AND_AA
+	
+	if ( (src->flags & SDL_SRCCOLORKEY) &&
+	     (src->flags & SDL_SRCALPHA)  ) {
+	     
+	     OpColor (&(src->hwdata->alpha));	           
+    
+         CopyDeepMask ( GetPortBitMapForCopyBits(src->hwdata->offscreen),
+                        GetPortBitMapForCopyBits(src->hwdata->mask),
+                        GetPortBitMapForCopyBits(dst->hwdata->offscreen),
+	                    &src_rect, &src_rect, &dst_rect,
+	                    blend,
+	                    NULL );                	                    
+	}
+	else {
+    	
+    	if ( src->flags & SDL_SRCCOLORKEY) {		    	    	    
+    	    RGBBackColor (&(src->hwdata->trans) );	    
+    	    mode = transparent;
+    	}
+    	else if (src->flags & SDL_SRCALPHA) {
+    	
+    	    OpColor (&(src->hwdata->alpha));
+    	    mode = blend;
+    	}    	
+    	else {
+    	
+    	    mode = srcCopy;   	    
+    	}            
+    	
+        CopyBits ( GetPortBitMapForCopyBits(src->hwdata->offscreen),
+                   GetPortBitMapForCopyBits(dst->hwdata->offscreen),
+    	           &src_rect, &dst_rect, mode, NULL );
+    }	
+#else
+    
+    CopyBits ( &(((GrafPtr)(src->hwdata->offscreen))->portBits),
+    	           &(((GrafPtr)(dst->hwdata->offscreen))->portBits),
+    	           &src_rect, &dst_rect, srcCopy, NULL );
+
+#endif /* DSP_TRY_CC_AND_AA */           
+	                             
+	SetGWorld (save_port, save_device);
+
+	return(0);
+}
+
+static int DSp_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 color)
+{
+	CGrafPtr save_port;
+	GDHandle save_device;
+	Rect     fill_rect;
+	RGBColor rgb;
+		
+	SetRect (&fill_rect, rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
+	
+	GetGWorld (&save_port, &save_device);
+	SetGWorld (dst->hwdata->offscreen, NULL);
+
+    Index2Color (color, &rgb);
+    
+	RGBForeColor (&rgb);
+	PaintRect (&fill_rect);
+
+	SetGWorld (save_port, save_device);    
+
+	return(0);
+}
+
+static int DSp_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	  if ( (surface->flags & SDL_HWSURFACE) ) {
+		CGrafPtr dsp_front_buffer, save_port;
+		Rect rect;
+		
+		unsigned int old_count;
+		
+		/* pseudo page flipping for VRAM back buffer*/ 
+		DSpContext_GetFrontBuffer (dsp_context, &dsp_front_buffer);
+		SetRect (&rect, 0, 0, surface->w-1, surface->h-1);  	
+  		
+  		GetPort ((GrafPtr *)&save_port);
+  		SetPort ((GrafPtr)dsp_front_buffer);
+  		
+  		/* wait for retrace */
+  		/* I have tried doing the swap in interrupt routine (VBL Proc) to do */
+  		/* it asynchronously, but apparently CopyBits isn't interrupt safe  */		   
+        
+            #if ! TARGET_API_MAC_OSX
+		#ifndef DSP_NO_SYNC_VBL
+    		old_count = retrace_count;
+    		while (old_count == retrace_count)
+    			  ;
+		#endif				  
+            #endif
+  		
+          CopyBits ( GetPortBitMapForCopyBits(dsp_back_buffer),
+                      GetPortBitMapForCopyBits(dsp_front_buffer),
+  			   &rect, &rect, srcCopy, NULL );
+  	
+  		SetPort ((GrafPtr)save_port);
+  		
+	} else {
+		/* not really page flipping at all: DSp just blits the dirty rectangles from DSp_UpdateRects */	    
+		Boolean busy_flag;
+		DSpContext_SwapBuffers (dsp_context, NULL, &busy_flag); /* this  waits for VBL */
+		DSpContext_GetBackBuffer (dsp_context, kDSpBufferKind_Normal, &dsp_back_buffer);
+        surface->pixels =  GetPixBaseAddr( GetPortPixMap(dsp_back_buffer) );
+	}
+	return(0);
+}
+
+static int DSp_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( LockPixels (GetGWorldPixMap (surface->hwdata->offscreen)) )
+		return 0;
+	else
+		return -1;
+}
+
+static void DSp_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	UnlockPixels (GetGWorldPixMap (surface->hwdata->offscreen));
+}
+
+static void DSp_DirectUpdate(_THIS, int numrects, SDL_Rect *sdl_rects)
+{
+	return;
+}
+
+static void DSp_DSpUpdate(_THIS, int numrects, SDL_Rect *sdl_rects)
+{
+#if ! TARGET_API_MAC_OSX /* Unsupported DSp in here */
+	int i;
+	Rect rect;
+	
+	for (i = 0; i < numrects; i++) {
+	
+		rect.top    = sdl_rects[i].y;
+		rect.left   = sdl_rects[i].x;
+		rect.bottom = sdl_rects[i].h + sdl_rects[i].y;
+		rect.right  = sdl_rects[i].w + sdl_rects[i].x;
+		
+		DSpContext_InvalBackBufferRect (dsp_context, &rect);		
+	}
+#endif
+}
+
+static int DSp_CreatePalette(_THIS) {
+
+
+	/* Create our palette */
+	SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8);
+	if ( SDL_CTab == nil ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	(**SDL_CTab).ctSeed = GetCTSeed();
+	(**SDL_CTab).ctFlags = 0;
+	(**SDL_CTab).ctSize = 255;
+	CTabChanged(SDL_CTab);
+	SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0);
+	
+	return 0;
+}
+
+static int DSp_DestroyPalette(_THIS) {
+
+	/* Free palette and restore original one */
+	if ( SDL_CTab != nil ) {
+		DisposeHandle((Handle)SDL_CTab);
+		SDL_CTab = nil;
+	}
+	if ( SDL_CPal != nil ) {
+		DisposePalette(SDL_CPal);
+		SDL_CPal = nil;
+	}
+	RestoreDeviceClut(SDL_Display);
+	
+   return (0);
+}
+
+static int DSp_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	CTabHandle   cTab;
+	
+	int i;
+
+	cTab = SDL_CTab;
+	
+	/* Verify the range of colors */
+	if ( (firstcolor+ncolors) > ((**cTab).ctSize+1) ) {
+		return(0);
+	}
+	
+	/* Set the screen palette and update the display */
+	for(i = 0; i < ncolors; i++) {
+	        int j = firstcolor + i;
+	        (**cTab).ctTable[j].value = j;
+		(**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r;
+		(**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g;
+		(**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b;
+	}
+	
+	SetGDevice(SDL_Display);
+	SetEntries(0, (**cTab).ctSize, (ColorSpec *)&(**cTab).ctTable);
+
+	return(1);
+}
+
+void DSp_VideoQuit(_THIS)
+{
+	int i;
+	
+	/* Free current video mode */
+	DSp_UnsetVideoMode(this, this->screen);
+
+   /* Free Palette and restore original */
+   DSp_DestroyPalette (this);
+
+	/* Free list of video modes */
+	if ( SDL_modelist != NULL ) {
+		for ( i=0; SDL_modelist[i]; i++ ) {
+			free(SDL_modelist[i]);
+		}
+		free(SDL_modelist);
+		SDL_modelist = NULL;
+	}
+	
+	/* Unload DrawSprocket */
+   DSpShutdown ();
+}
+
+#ifdef HAVE_OPENGL
+
+/* swap buffers with v-sync */
+static void DSp_GL_SwapBuffers (_THIS) {
+
+   #ifndef DSP_NO_SYNC_OPENGL
+   
+       unsigned int old_count;
+          
+       old_count = retrace_count;
+       while (old_count == retrace_count)
+          ;
+   #endif
+      
+   aglSwapBuffers (glContext);
+}
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macdsp/SDL_dspvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,58 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dspvideo_h
+#define _SDL_dspvideo_h
+
+#if TARGET_API_MAC_OSX
+#  include <DrawSprocket/DrawSprocket.h> /* Drawsprocket.framework */
+#else
+#include <DrawSprocket.h>
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* DrawSprocket specific information */
+struct DSpInfo {
+	DSpContextReference dsp_context;
+	CGrafPtr            dsp_back_buffer;
+   int                 dsp_old_depth;
+   
+	/* Flags for hw acceleration */
+	int dsp_vram_available;
+	int dsp_agp_available;
+	
+	
+}; 
+/* Old variable names */
+#define dsp_context (this->hidden->dspinfo->dsp_context)
+#define dsp_back_buffer (this->hidden->dspinfo->dsp_back_buffer)
+#define dsp_old_depth   (this->hidden->dspinfo->dsp_old_depth)
+#define dsp_vram_available (this->hidden->dspinfo->dsp_vram_available)
+#define dsp_agp_available (this->hidden->dspinfo->dsp_agp_available)
+
+#endif /* _SDL_dspvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macrom/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macrom/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,10 @@
+
+## Makefile.am for SDL using the Mac toolbox video driver
+
+noinst_LTLIBRARIES = libvideo_macrom.la
+libvideo_macrom_la_SOURCES = $(ROM_SRCS)
+
+# The SDL Mac toolbox driver sources
+ROM_SRCS = 			\
+	SDL_romvideo.c		\
+	SDL_romvideo.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macrom/SDL_romvideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,730 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#if TARGET_API_MAC_CARBON
+#include <Carbon.h>
+/* The fullscreen code requires the QuickTime framework, and the window
+   is still at the back on MacOS X, which is where this code is needed.
+ */
+#if USE_QUICKTIME
+#include <Movies.h>
+#endif
+#else
+#include <LowMem.h>
+#include <Gestalt.h>
+#include <Devices.h>
+#include <DiskInit.h>
+#include <QDOffscreen.h>
+#endif
+
+#include "SDL_video.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_sysvideo.h"
+#include "SDL_romvideo.h"
+#include "SDL_macgl_c.h"
+#include "SDL_macwm_c.h"
+#include "SDL_macmouse_c.h"
+#include "SDL_macevents_c.h"
+
+/* Initialization/Query functions */
+static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int ROM_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static void ROM_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int ROM_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int ROM_LockHWSurface(_THIS, SDL_Surface *surface);
+static void ROM_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void ROM_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
+/* Saved state for the menu bar */
+static RgnHandle	gSaveGrayRgn = nil;
+static short		gSaveMenuBar = 0;
+static Boolean		gSaveCSVis = true;
+
+#if powerc
+/* Mixed mode glue to activate the 68K emulator and twiddle a register */
+#define ONEWORDSTUB(p1) \
+		{ 0x41FA, 0x0010, 0x209F, (p1), 0x41FA, \
+		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
+
+#define TWOWORDSTUB(p1,p2) \
+		{ 0x41FA, 0x0012, 0x209F, (p1), (p2), 0x41FA, \
+		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
+
+#define THREEWORDSTUB(p1,p2,p3) \
+		{ 0x41FA, 0x0014, 0x209F, (p1), (p2), (p3), 0x41FA, \
+		  0x0008, 0x2F10, 0x4E75, 0x0000, 0x0000, 0x0000 }
+
+/* ControlStrip inline glue for PowerPC */
+static pascal Boolean SBIsControlStripVisible(void)
+{
+	static short procData[] = TWOWORDSTUB(0x7000, 0xAAF2);
+	ProcInfoType procInfo = kD0DispatchedPascalStackBased
+				| RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
+            	| DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode);
+            				
+	return((Boolean) CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x00));
+}
+
+static pascal void SBShowHideControlStrip(Boolean showIt)
+{
+	static short procData[] = THREEWORDSTUB(0x303C, 0x0101, 0xAAF2);
+	ProcInfoType procInfo = kD0DispatchedPascalStackBased
+				| DISPATCHED_STACK_ROUTINE_SELECTOR_SIZE(kFourByteCode)
+				| DISPATCHED_STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(Boolean)));
+
+	CallUniversalProc((UniversalProcPtr) procData, procInfo, 0x01, showIt);
+}
+#endif /* powerc */
+#endif /* !TARGET_API_MAC_CARBON */
+
+/* Macintosh toolbox driver bootstrap functions */
+
+static int ROM_Available(void)
+{
+	return(1);
+}
+
+static void ROM_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *ROM_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = ROM_VideoInit;
+	device->ListModes = ROM_ListModes;
+	device->SetVideoMode = ROM_SetVideoMode;
+	device->SetColors = ROM_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = ROM_VideoQuit;
+	device->AllocHWSurface = ROM_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = ROM_LockHWSurface;
+	device->UnlockHWSurface = ROM_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = ROM_FreeHWSurface;
+#ifdef HAVE_OPENGL
+	device->GL_MakeCurrent = Mac_GL_MakeCurrent;
+	device->GL_SwapBuffers = Mac_GL_SwapBuffers;
+#endif
+	device->SetCaption = Mac_SetCaption;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->FreeWMCursor = Mac_FreeWMCursor;
+	device->CreateWMCursor = Mac_CreateWMCursor;
+	device->ShowWMCursor = Mac_ShowWMCursor;
+	device->WarpWMCursor = Mac_WarpWMCursor;
+	device->InitOSKeymap = Mac_InitOSKeymap;
+	device->PumpEvents = Mac_PumpEvents;
+
+	device->free = ROM_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap TOOLBOX_bootstrap = {
+	"toolbox", "MacOS ROM Toolbox",
+	ROM_Available, ROM_CreateDevice
+};
+
+
+static int ROM_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	long info;
+	
+	/* Check out some things about the system */
+	Gestalt(gestaltQuickdrawVersion, &info);
+	if ( info == gestaltOriginalQD ) {
+		SDL_SetError("Color Quickdraw not available");
+		return(-1);
+	}
+
+	/* Start ROMintosh events */
+	Mac_InitEvents(this);
+
+	/* Get a handle to the main monitor */
+	SDL_Display = GetMainDevice();
+
+	/* Determine pixel format */
+	vformat->BitsPerPixel = (**(**SDL_Display).gdPMap).pixelSize;
+	switch (vformat->BitsPerPixel) {
+		case 16:	/* 5-5-5 RGB */
+			vformat->Rmask = 0x00007c00;
+			vformat->Gmask = 0x000003e0;
+			vformat->Bmask = 0x0000001f;
+			break;
+		default:
+			break;
+	}
+
+	/* Create our palette */
+	SDL_CTab = (CTabHandle)NewHandle(sizeof(ColorSpec)*256 + 8);
+	if ( SDL_CTab == nil ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	(**SDL_CTab).ctSeed = GetCTSeed();
+	(**SDL_CTab).ctFlags = 0;
+	(**SDL_CTab).ctSize = 255;
+	CTabChanged(SDL_CTab);
+	SDL_CPal = NewPalette(256, SDL_CTab, pmExplicit+pmTolerant, 0);
+
+	/* Get a list of available fullscreen modes */
+	SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist ) {
+		SDL_modelist[0] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+		if ( SDL_modelist[0] ) {
+			SDL_modelist[0]->x = 0;
+			SDL_modelist[0]->y = 0;
+			SDL_modelist[0]->w = (**SDL_Display).gdRect.right;
+			SDL_modelist[0]->h = (**SDL_Display).gdRect.bottom;
+		}
+		SDL_modelist[1] = NULL;
+	}
+
+	/* Fill in some window manager capabilities */
+	this->info.wm_available = 1;
+
+	/* We're done! */
+	return(0);
+}
+
+static SDL_Rect **ROM_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	if ( this->screen->format->BitsPerPixel == format->BitsPerPixel ) {
+		if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			return(SDL_modelist);
+		} else {
+			return((SDL_Rect **)-1);
+		}
+	} else {
+		return((SDL_Rect **)0);
+	}
+}
+
+static void ROM_HideMenuBar(_THIS)
+{
+#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
+	RgnHandle		drawRgn = nil;
+	RgnHandle		tempRgn = nil;
+	RgnHandle		grayRgn = nil;
+	WindowPtr		window = nil;
+	GDHandle		gd = nil;
+	GrafPtr			savePort;
+	long			response;
+	short			height;
+	EventRecord		theEvent;
+
+	height = GetMBarHeight();
+	
+	if ( height > 0 ) {
+		tempRgn = NewRgn();
+		drawRgn = NewRgn();
+		gSaveGrayRgn = NewRgn();
+		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
+			goto CLEANUP;
+		}
+		grayRgn = GetGrayRgn(); /* No need to check for this */
+	
+		GetPort(&savePort);
+
+		/* Hide the control strip if it's present, and record its 
+		   previous position into the dirty region for redrawing. 
+		   This isn't necessary, but may help catch stray bits. */
+		CopyRgn(grayRgn, tempRgn);
+		if (!Gestalt(gestaltControlStripAttr, &response) && 
+			(response & (1L << gestaltControlStripExists))) {
+			gSaveCSVis = SBIsControlStripVisible();
+			if (gSaveCSVis)
+				SBShowHideControlStrip(false);
+		}
+		DiffRgn(grayRgn, tempRgn, drawRgn);
+
+		/* Save the gray region once the control strip is hidden*/
+		CopyRgn(grayRgn, gSaveGrayRgn);
+
+		/* Change the menu height in lowmem */
+		gSaveMenuBar = height;
+		LMSetMBarHeight(0);
+		
+		/* Walk the monitor rectangles, and combine any pieces that
+		   aren't in GrayRgn: menubar, round corners, fake floaters. */
+		for(gd = GetDeviceList(); gd; gd = GetNextDevice(gd)) 
+			{
+			if (!TestDeviceAttribute(gd, screenDevice)) continue;
+			if (!TestDeviceAttribute(gd, screenActive)) continue;
+
+			RectRgn(tempRgn, &(*gd)->gdRect);	/* Get the whole screen */
+			DiffRgn(tempRgn, grayRgn, tempRgn); /* Subtract out GrayRgn */
+			UnionRgn(tempRgn, drawRgn, drawRgn);/* Combine all the bits */
+			}
+			
+		/* Add the bits into the GrayRgn */
+		UnionRgn(drawRgn, grayRgn, grayRgn);
+
+		/* Modify the vis regions of exposed windows */
+		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
+		PaintBehind(window, drawRgn);
+		CalcVisBehind(window, drawRgn);
+
+		SetPort(savePort);
+		
+		/* Yield time so that floaters can catch up */
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		}
+
+CLEANUP:
+
+	if (tempRgn) DisposeRgn(tempRgn);
+	if (drawRgn) DisposeRgn(drawRgn);
+#endif /* !TARGET_API_MAC_CARBON */
+}
+	
+static void ROM_ShowMenuBar(_THIS)
+{
+#if !TARGET_API_MAC_CARBON /* This seems not to be available? -sts Aug 2000 */
+	RgnHandle		drawRgn = nil;
+	RgnHandle		menuRgn = nil;
+	RgnHandle		tempRgn = nil;
+	RgnHandle		grayRgn = nil;
+	WindowPtr		window = nil;
+	GrafPtr			wMgrPort;
+	GrafPtr			savePort;
+	Rect			menuRect;
+	long			response;
+	short			height;
+	EventRecord		theEvent;
+	RGBColor		saveRGB;
+	RGBColor		blackRGB = { 0, 0, 0 };
+
+	height = GetMBarHeight();
+	
+	if ((height <= 0) && (gSaveMenuBar > 0)) {
+		drawRgn = NewRgn();
+		menuRgn = NewRgn();
+		tempRgn = NewRgn();
+		if ( ! tempRgn || ! drawRgn || ! gSaveGrayRgn ) {
+			goto CLEANUP;
+		}
+		grayRgn = GetGrayRgn(); /* No need to check for this */
+	
+		GetPort(&savePort);
+		GetWMgrPort(&wMgrPort);
+
+		/* Set the height properly */
+		LMSetMBarHeight(gSaveMenuBar);
+
+		/* Restore the old GrayRgn: rounded corners, etc, but not
+		   the menubar -- subtract that out first! */
+		if (gSaveGrayRgn)
+			{
+			menuRect = (*GetMainDevice())->gdRect;
+			menuRect.bottom = menuRect.top + gSaveMenuBar;
+			RectRgn(menuRgn, &menuRect);
+
+			DiffRgn(grayRgn, gSaveGrayRgn, drawRgn); 	/* What do we inval? */
+			DiffRgn(drawRgn, menuRgn, drawRgn);			/* Clip out the menu */
+			
+			/* Now redraw the corners and other bits black */
+			SetPort(wMgrPort);
+			GetClip(tempRgn);
+			SetClip(drawRgn);
+			GetForeColor(&saveRGB);
+			RGBForeColor(&blackRGB);
+			PaintRgn(drawRgn);
+			RGBForeColor(&saveRGB);
+			SetClip(tempRgn);
+			SetPort(savePort);
+			
+			UnionRgn(drawRgn, menuRgn, drawRgn);		/* Put back the menu */
+
+			/* Now actually restore the GrayRgn */
+			CopyRgn(gSaveGrayRgn, grayRgn);
+			DisposeRgn(gSaveGrayRgn);
+			gSaveGrayRgn = nil;
+			}
+
+		/* Modify the vis regions of exposed windows and draw menubar */
+		window = (FrontWindow()) ? FrontWindow() : (WindowPtr) -1L;
+		PaintBehind(window, drawRgn);
+		CalcVisBehind(window, drawRgn);
+		DrawMenuBar();
+
+		SetPort(savePort);
+		gSaveMenuBar = 0;
+
+		/* Now show the control strip if it's present */
+		if (!Gestalt(gestaltControlStripAttr, &response) && 
+				(response & (1L << gestaltControlStripExists)))
+			{
+			if (gSaveCSVis && !SBIsControlStripVisible())
+				SBShowHideControlStrip(true);
+			gSaveCSVis = true;
+			}
+
+		/* Yield time so that floaters can catch up */
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		EventAvail(0, &theEvent);
+		}
+
+CLEANUP:
+
+	if (drawRgn) DisposeRgn(drawRgn);
+	if (menuRgn) DisposeRgn(menuRgn);
+	if (tempRgn) DisposeRgn(tempRgn);
+#endif /* !TARGET_API_MAC_CARBON */
+}
+
+/* Various screen update functions available */
+static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+static void ROM_UnsetVideoMode(_THIS, SDL_Surface *current)
+{
+	/* Free the current window, if any */
+	if ( SDL_Window != nil ) {
+		GWorldPtr memworld;
+		
+		/* Handle OpenGL support */
+		Mac_GL_Quit(this);
+
+		memworld = (GWorldPtr)GetWRefCon(SDL_Window);
+		if ( memworld != nil ) {
+			UnlockPixels(GetGWorldPixMap(memworld));
+			DisposeGWorld(memworld);
+		}
+		if ( (current->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+#if USE_QUICKTIME
+			EndFullScreen(fullscreen_ctx, nil);
+			SDL_Window = nil;
+#else
+			ROM_ShowMenuBar(this);
+#endif
+		}
+	}
+	current->pixels = NULL;
+	current->flags &= ~(SDL_HWSURFACE|SDL_FULLSCREEN);
+}
+
+static SDL_Surface *ROM_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	Rect wrect, orect;
+#if TARGET_API_MAC_CARBON
+	Rect tmprect;
+#endif
+
+	/* Free any previous video mode */
+	ROM_UnsetVideoMode(this, current);
+
+	/* Create the ROM window and SDL video surface */
+	current->flags = 0;		/* Clear flags */
+	current->w = width;
+	current->h = height;
+	SetRect(&wrect, 0, 0, width, height);
+	if ( SDL_Window ) {
+		/* If we recreate the window, don't move it around */
+#if TARGET_API_MAC_CARBON
+		orect = *GetWindowPortBounds(SDL_Window, &tmprect);
+#else
+		orect = SDL_Window->portRect;
+#endif
+		OffsetRect(&wrect, orect.left, orect.top);
+	} else {
+		/* Center the window the first time we show it */
+		OffsetRect(&wrect,
+		(SDL_modelist[0]->w-width)/2, (SDL_modelist[0]->h-height)/2);
+	}
+
+#if MACOSX && !USE_QUICKTIME
+	/* Hum.. fullscreen mode is broken */
+	flags &= ~SDL_FULLSCREEN;
+#endif
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		/* Create the fullscreen window and use screen bits */
+		current->flags |= SDL_HWSURFACE|SDL_FULLSCREEN;
+		if ( SDL_Window ) {
+			DisposeWindow(SDL_Window);
+		}
+#if USE_QUICKTIME
+		BeginFullScreen(&fullscreen_ctx, nil, 0,0, &SDL_Window, nil, 0);
+#else
+		SDL_Window = NewCWindow(nil, &wrect, "\p", true, plainDBox,
+						(WindowPtr)-1, false, 0);
+		ROM_HideMenuBar(this);
+#endif
+		current->pitch = (**(**SDL_Display).gdPMap).rowBytes & 0x3FFF;
+		current->pixels = (**(**SDL_Display).gdPMap).baseAddr;
+		this->UpdateRects = ROM_DirectUpdate;
+	} else {
+		GWorldPtr memworld;
+		PixMapHandle pixmap;
+		int style;
+
+		style = noGrowDocProc;
+		if ( flags & SDL_NOFRAME ) {
+			style = plainDBox;
+			current->flags |= SDL_NOFRAME;
+		} else
+		if ( flags & SDL_RESIZABLE ) {
+			style = zoomDocProc;
+			current->flags |= SDL_RESIZABLE;
+		}
+		if ( SDL_Window && (style == current_style) ) {
+			/* Resize existing window, if necessary */
+			if ( ((orect.right-orect.left) != width) ||
+			     ((orect.bottom-orect.top) != height) ) {
+				SizeWindow(SDL_Window, width, height, false);
+			}
+		} else {
+			/* Recreate the window in the new style */
+			if ( SDL_Window ) {
+				DisposeWindow(SDL_Window);
+			}
+			SDL_Window = NewCWindow(nil, &wrect, "\p", true,
+			                        style, (WindowPtr)-1, true, 0);
+
+			/* Set the window title, if any */
+			{ char *title;
+				SDL_WM_GetCaption(&title, NULL);
+				if ( title ) {
+					Mac_SetCaption(this, title, NULL);
+				}
+			}
+		}
+		current_style = style;
+		SetPalette(SDL_Window, SDL_CPal, false);
+		ActivatePalette(SDL_Window);
+		if ( NewGWorld(&memworld, 0,
+#if TARGET_API_MAC_CARBON
+			       GetWindowPortBounds(SDL_Window, &tmprect),
+#else
+			       &SDL_Window->portRect,
+#endif
+			       SDL_CTab, nil, 0) != noErr ) {
+			SDL_SetError("NewGWorld() failed");
+			return(NULL);
+		}
+		SetWRefCon(SDL_Window, (long)memworld);
+		pixmap = GetGWorldPixMap(memworld);
+		LockPixels(pixmap);
+		current->pitch = (**pixmap).rowBytes & 0x3FFF;
+		current->pixels = GetPixBaseAddr(pixmap);
+		this->UpdateRects = ROM_WindowUpdate;
+	}
+	SetPortWindowPort(SDL_Window);
+	SelectWindow(SDL_Window);
+
+	/* Handle OpenGL support */
+	if ( flags & SDL_OPENGL ) {
+		if ( Mac_GL_Init(this) == 0 ) {
+			current->flags |= SDL_OPENGL;
+		} else {
+			current = NULL;
+		}
+	}
+	
+	if ( (flags & SDL_HWPALETTE) && (flags & SDL_FULLSCREEN) )
+	   current->flags |= SDL_HWPALETTE;
+	   
+	/* We're live! */
+	return(current);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int ROM_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void ROM_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+static int ROM_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+static void ROM_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+static void ROM_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	/* The application is already updating the visible video memory */
+	return;
+}
+
+static void ROM_WindowUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	GWorldPtr memworld;
+	GrafPtr saveport;
+	CGrafPtr thePort;
+	const BitMap *memBits;
+	const BitMap *winBits;
+	int i;
+	Rect update;
+	
+	/* Copy from the offscreen GWorld to the window port */
+	GetPort(&saveport);
+	SetPortWindowPort(SDL_Window);
+	thePort = GetWindowPort(SDL_Window);
+	memworld = (GWorldPtr)GetWRefCon(SDL_Window);
+#if TARGET_API_MAC_CARBON
+	memBits = GetPortBitMapForCopyBits((CGrafPtr) memworld);
+#else
+	memBits = &((GrafPtr)memworld)->portBits;
+#endif
+#if TARGET_API_MAC_CARBON
+	winBits = GetPortBitMapForCopyBits(thePort);
+#else
+	winBits = &SDL_Window->portBits;
+#endif
+	for ( i=0; i<numrects; ++i ) {
+		update.left = rects[i].x;
+		update.right = rects[i].x+rects[i].w;
+		update.top = rects[i].y;
+		update.bottom = rects[i].y+rects[i].h;
+		CopyBits(memBits, winBits,
+			 &update, &update, srcCopy, nil);
+	}
+#if TARGET_API_MAC_CARBON
+	if ( QDIsPortBuffered(thePort) ) {
+		QDFlushPortBuffer(thePort, NULL);
+	}
+#endif
+	SetPort(saveport);
+}
+
+static int ROM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	CTabHandle cTab;
+	int i;
+
+	/* Get the colortable from the either the display or window */
+	if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		cTab = (**(**SDL_Display).gdPMap).pmTable;
+	} else {
+		cTab = SDL_CTab;
+	}
+
+	/* Verify the range of colors */
+	if ( (firstcolor+ncolors) > ((**cTab).ctSize+1) ) {
+		return(0);
+	}
+	
+	/* Set the screen palette and update the display */
+	for ( i=0; i< ncolors; ++i ) {
+	        int j = firstcolor + i;
+		(**cTab).ctTable[j].value = j;
+		(**cTab).ctTable[j].rgb.red = colors[i].r << 8 | colors[i].r;
+		(**cTab).ctTable[j].rgb.green = colors[i].g << 8 | colors[i].g;
+		(**cTab).ctTable[j].rgb.blue = colors[i].b << 8 | colors[i].b;
+	}
+//	if ( (this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) 
+{
+		GDevice **odisplay;
+		odisplay = GetGDevice();
+		SetGDevice(SDL_Display);
+		SetEntries(0, (**cTab).ctSize, (ColorSpec *)&(**cTab).ctTable);
+		SetGDevice(odisplay);
+	}
+	return(1);
+}
+
+void ROM_VideoQuit(_THIS)
+{
+	int i;
+
+	/* Free current video mode */
+	ROM_UnsetVideoMode(this, this->screen);
+	if ( SDL_Window ) {
+		DisposeWindow(SDL_Window);
+		SDL_Window = nil;
+	}
+
+	/* Free palette and restore original one */
+	if ( SDL_CTab != nil ) {
+		DisposeHandle((Handle)SDL_CTab);
+		SDL_CTab = nil;
+	}
+	if ( SDL_CPal != nil ) {
+		DisposePalette(SDL_CPal);
+		SDL_CPal = nil;
+	}
+	RestoreDeviceClut(GetMainDevice());
+
+	/* Free list of video modes */
+	if ( SDL_modelist != NULL ) {
+		for ( i=0; SDL_modelist[i]; ++i ) {
+			free(SDL_modelist[i]);
+		}
+		free(SDL_modelist);
+		SDL_modelist = NULL;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/macrom/SDL_romvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,33 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_romvideo_h
+#define _SDL_romvideo_h
+
+#include "SDL_lowvideo.h"
+
+#endif /* _SDL_romvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,21 @@
+
+## Makefile.am for SDL using the QNX Photon video driver
+
+noinst_LTLIBRARIES = libvideo_photon.la
+libvideo_photon_la_SOURCES = $(PH_SRCS)
+
+# The SDL QNX Photon video driver sources
+PH_SRCS = 			\
+	SDL_ph_events.c		\
+	SDL_ph_events_c.h	\
+	SDL_ph_image.c		\
+	SDL_ph_image_c.h	\
+	SDL_ph_modes.c		\
+	SDL_ph_modes_c.h	\
+	SDL_ph_mouse.c		\
+	SDL_ph_mouse_c.h	\
+	SDL_ph_video.c		\
+	SDL_ph_video.h		\
+	SDL_ph_wm.c		\
+	SDL_phyuv.c		\
+	SDL_phyuv_c.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_events.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,563 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting photon events into SDL events */
+
+#include <Ph.h>
+#include <stdio.h>
+#include <setjmp.h>
+#include <photon/PkKeyDef.h>
+#include <sys/time.h>
+
+#include "SDL.h"
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_ph_video.h"
+#include "SDL_ph_modes_c.h"
+#include "SDL_ph_image_c.h"
+#include "SDL_ph_events_c.h"
+
+
+/* The translation tables from a photon keysym to a SDL keysym */
+static SDLKey ODD_keymap[256];
+static SDLKey MISC_keymap[0xFF + 1];
+SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym);
+
+/* Check to see if this is a repeated key.
+   (idea shamelessly lifted from GII -- thanks guys! :)
+ */
+
+static int ph_KeyRepeat(_THIS, PhKeyEvent_t* keyevent)
+{
+	PhEvent_t* peekevent;
+	PhKeyEvent_t* keyEvent;
+	int repeated;
+
+	repeated = 0;
+	switch (PhEventPeek( peekevent, EVENT_SIZE ))
+	{
+		case Ph_EVENT_MSG: {
+			if(peekevent->type == Ph_EV_KEY)
+			{
+				keyEvent = PhGetData( peekevent );
+				if ( !(Pk_KF_Key_Down & keyEvent->key_flags) &&
+					(keyEvent->key_cap == keyevent->key_cap) &&
+					(peekevent->timestamp == event->timestamp)	
+				) {
+					repeated = 1;
+					 //PhEventNext( peekevent, EVENT_SIZE );  
+				}				
+			}
+		}
+		break;
+
+		case -1: {
+			perror( "PhEventPeek failed" );
+		}
+		break;
+
+		default: /* no events pending */
+	}
+	return(repeated);
+}
+
+/* Note:  The X server buffers and accumulates mouse motion events, so
+   the motion event generated by the warp may not appear exactly as we
+   expect it to.  We work around this (and improve performance) by only
+   warping the pointer when it reaches the edge, and then wait for it.
+*/
+/*
+#define MOUSE_FUDGE_FACTOR	8
+
+static inline int X11_WarpedMotion(_THIS, XEvent *xevent)
+{
+	int w, h, i;
+	int deltax, deltay;
+	int posted;
+
+	w = SDL_VideoSurface->w;
+	h = SDL_VideoSurface->h;
+	deltax = xevent->xmotion.x - mouse_last.x;
+	deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
+#endif
+	mouse_last.x = xevent->xmotion.x;
+	mouse_last.y = xevent->xmotion.y;
+	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+
+	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
+	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
+		/* Get the events that have accumulated */
+/*		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
+			deltax = xevent->xmotion.x - mouse_last.x;
+			deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
+#endif
+			mouse_last.x = xevent->xmotion.x;
+			mouse_last.y = xevent->xmotion.y;
+			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+		}
+		mouse_last.x = w/2;
+		mouse_last.y = h/2;
+		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
+					mouse_last.x, mouse_last.y);
+		for ( i=0; i<10; ++i ) {
+        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
+			if ( (xevent->xmotion.x >
+			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.x <
+			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y >
+			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y <
+			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
+				break;
+			}
+#ifdef DEBUG_XEVENTS
+  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
+#endif
+		}
+#ifdef DEBUG_XEVENTS
+		if ( i == 10 ) {
+			printf("Warning: didn't detect mouse warp motion\n");
+		}
+#endif
+	}
+	return(posted);
+}
+*/
+
+static int ph_DispatchEvent(_THIS)
+{
+	int posted;
+	PhRect_t* rect;
+	PhPointerEvent_t* pointerEvent;
+	PhKeyEvent_t* keyEvent;
+	PhWindowEvent_t* winEvent;
+	int i;
+	SDL_Rect sdlrects[50]; 
+	
+	posted = 0;
+	
+	switch (event->type) {
+		case Ph_EV_BOUNDARY:
+		{
+		
+			if (event->subtype == Ph_EV_PTR_ENTER)
+				posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			else if (event->subtype ==Ph_EV_PTR_LEAVE)
+				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);	
+		}
+		break;
+
+		case Ph_EV_PTR_MOTION_BUTTON:
+		case Ph_EV_PTR_MOTION_NOBUTTON:
+		{
+		
+			if ( SDL_VideoSurface ) {
+				pointerEvent = PhGetData( event );
+				rect = PhGetRects( event );
+				posted = SDL_PrivateMouseMotion(0, 1,
+                		pointerEvent->pos.x - rect[0].ul.x,
+                		pointerEvent->pos.y - rect[0].ul.y);		
+			}
+		}
+		break;
+
+		case Ph_EV_BUT_PRESS:
+		{
+
+			pointerEvent = PhGetData( event );
+			/* TODO: is 'buttons' the right mapping? */
+			posted = SDL_PrivateMouseButton(SDL_PRESSED,
+                        	pointerEvent->buttons, 0, 0);
+		}
+		break;
+
+		case Ph_EV_BUT_RELEASE:
+		{
+			
+			pointerEvent = PhGetData( event );
+			 posted = SDL_PrivateMouseButton(SDL_RELEASED,
+         			pointerEvent->buttons, 0, 0);
+		}
+		break;
+
+		case Ph_EV_WM:
+		{
+
+		
+			winEvent = PhGetData( event );
+			
+			/* losing focus */
+			if ((winEvent->event_f==Ph_WM_FOCUS)&&
+				(winEvent->event_state==Ph_WM_EVSTATE_FOCUSLOST))
+			{
+				posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);	
+
+				/* Queue leaving fullscreen mode */
+				switch_waiting = 0x01;
+				switch_time = SDL_GetTicks() + 200;
+			}
+
+			/* gaining focus */
+			else if ((winEvent->event_f==Ph_WM_FOCUS)&&
+					(winEvent->event_state==Ph_WM_EVSTATE_FOCUS))
+			{
+				posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
+
+				/* Queue entry into fullscreen mode */
+				switch_waiting = 0x01 | SDL_FULLSCREEN;
+				switch_time = SDL_GetTicks() + 1500;
+			}
+
+			/* request to quit */
+			else if (winEvent->event_f==Ph_WM_CLOSE)
+			{
+				posted = SDL_PrivateQuit();
+			}
+		}
+		break;
+		
+		/* window has been resized, moved or removed */
+		case Ph_EV_EXPOSE:
+		{
+
+			if (SDL_VideoSurface)
+			{
+			  
+			  
+					rect = PhGetRects( event );
+
+				//PgSetClipping(1, rect );
+				 for(i=0;i<event->num_rects;i++)
+			   {
+			      sdlrects[i].x = rect[i].ul.x;
+			      sdlrects[i].y = rect[i].ul.y;
+			      sdlrects[i].w = rect[i].lr.x - rect[i].ul.x;
+			      sdlrects[i].h = rect[i].lr.y - rect[i].ul.y;
+			      	
+				}
+			
+					this->UpdateRects(this, event->num_rects, sdlrects);
+
+			}
+		}
+		break;
+
+		case Ph_EV_KEY:
+		{
+	
+			SDL_keysym keysym;
+			
+			posted = 0;
+			
+			keyEvent = PhGetData( event );
+
+			if (Pk_KF_Key_Down & keyEvent->key_flags)
+			{
+				
+				posted = SDL_PrivateKeyboard(SDL_PRESSED,
+                			ph_TranslateKey( keyEvent, &keysym));
+			}
+			else /* must be key release */
+ 			{
+ 				/* Ignore repeated key release events */
+				/*if (! Pk_KF_Key_Repeat & keyEvent->key_flags )*/
+				
+					posted = SDL_PrivateKeyboard(SDL_RELEASED,
+        					ph_TranslateKey( keyEvent, &keysym));
+				/*}*/
+			}
+		}
+		break;
+	}
+	
+		
+	
+	return(posted);
+}
+
+/* perform a blocking read if no events available */
+int ph_Pending(_THIS)
+{
+	
+	/* Flush the display connection and look to see if events are queued */
+
+	PgFlush();
+
+     while( 1 )
+      {   //note this is a non-blocking call
+          switch( PhEventPeek( event, EVENT_SIZE ) )
+           {
+              case Ph_EVENT_MSG:
+                 
+                 return 1;
+                 break;
+              case -1:
+                 perror( "PhEventNext failed" );
+                 break;
+              default:
+             	  
+                return 0;
+       }
+   }
+
+	/* Oh well, nothing is ready .. */
+	return(0);
+}
+
+/*
+SAMPLE EVENT PUMP
+=================
+static void update( int block ){
+
+    int ch,fl;
+    PhKeyEvent_t *key;
+
+    for( ;; ){
+
+        if( block ){
+            do{
+                fl=PhEventNext( event,EVENT_SIZE );
+            }while( fl!=Ph_EVENT_MSG );
+            block=0;
+        }else{
+            do{
+                fl=PhEventPeek( event,EVENT_SIZE );
+                if( !fl ) return;
+            }while( fl!=Ph_EVENT_MSG );
+        }
+
+        switch( event->type ){
+        case Ph_EV_KEY:
+            key=PhGetData( event );
+            ch=key->key_cap;    // & 127;
+            fl=key->key_flags;
+            if( ch<32 || ch>127 ) break;
+            if( fl & Pk_KF_Key_Down ){
+                if( !(fl & Pk_KF_Key_Repeat) ){
+                    if( queput-queget<QUE_SIZE ) keyque[ queput++ & QUE_MASK ]=ch;
+                    keyMatrix[ch]=1;
+                }
+            }else{
+                keyMatrix[ch]=0;
+            }
+            break;
+        default:
+            PtEventHandler( event );
+        }
+    }
+}
+*/
+
+void ph_PumpEvents(_THIS)
+{
+	int pending;
+
+	/* Keep processing pending events */
+	pending = 0;
+	while ( ph_Pending(this) ) {
+		ph_DispatchEvent(this);
+		++pending;
+	}
+	if ( switch_waiting ) {
+		Uint32 now;
+
+		now  = SDL_GetTicks();
+		if ( pending || !SDL_VideoSurface ) {
+			/* Try again later... */
+			if ( switch_waiting & SDL_FULLSCREEN ) {
+				switch_time = now + 1500;
+			} else {
+				switch_time = now + 200;
+			}
+		} else if ( now >= switch_time ) {
+			Uint32 go_fullscreen;
+
+			go_fullscreen = switch_waiting & SDL_FULLSCREEN;
+			switch_waiting = 0;
+			if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) {
+				if ( go_fullscreen ) {
+					ph_EnterFullScreen(this);
+				} else {
+					ph_LeaveFullScreen(this);
+				}
+			}
+			/* Handle focus in/out when grabbed */
+/*
+			if ( go_fullscreen ) {
+				ph_GrabInputNoLock(this, this->input_grab);
+			} else {
+				ph_GrabInputNoLock(this, SDL_GRAB_OFF);
+			}
+*/
+		}
+	}
+}
+
+void ph_InitKeymap(void)
+{
+	int i;
+
+	/* Odd keys used in international keyboards */
+	for ( i=0; i<SDL_TABLESIZE(ODD_keymap); ++i )
+		ODD_keymap[i] = SDLK_UNKNOWN;
+
+	/* Map the miscellaneous keys */
+	for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i )
+		MISC_keymap[i] = SDLK_UNKNOWN;
+
+	MISC_keymap[Pk_BackSpace&0xFF] = SDLK_BACKSPACE;
+	MISC_keymap[Pk_Tab&0xFF] = SDLK_TAB;
+	MISC_keymap[Pk_Clear&0xFF] = SDLK_CLEAR;
+	MISC_keymap[Pk_Return&0xFF] = SDLK_RETURN;
+	MISC_keymap[Pk_Pause&0xFF] = SDLK_PAUSE;
+	MISC_keymap[Pk_Escape&0xFF] = SDLK_ESCAPE;
+	MISC_keymap[Pk_Delete&0xFF] = SDLK_DELETE;
+
+	MISC_keymap[Pk_KP_0&0xFF] = SDLK_KP0;
+	MISC_keymap[Pk_KP_1&0xFF] = SDLK_KP1;
+	MISC_keymap[Pk_KP_2&0xFF] = SDLK_KP2;
+	MISC_keymap[Pk_KP_3&0xFF] = SDLK_KP3;
+	MISC_keymap[Pk_KP_4&0xFF] = SDLK_KP4;
+	MISC_keymap[Pk_KP_5&0xFF] = SDLK_KP5;
+	MISC_keymap[Pk_KP_6&0xFF] = SDLK_KP6;
+	MISC_keymap[Pk_KP_7&0xFF] = SDLK_KP7;
+	MISC_keymap[Pk_KP_8&0xFF] = SDLK_KP8;
+	MISC_keymap[Pk_KP_9&0xFF] = SDLK_KP9;
+
+	MISC_keymap[Pk_KP_Decimal&0xFF] = SDLK_KP_PERIOD;
+	MISC_keymap[Pk_KP_Divide&0xFF] = SDLK_KP_DIVIDE;
+	MISC_keymap[Pk_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY;
+	MISC_keymap[Pk_KP_Subtract&0xFF] = SDLK_KP_MINUS;
+	MISC_keymap[Pk_KP_Add&0xFF] = SDLK_KP_PLUS;
+	MISC_keymap[Pk_KP_Enter&0xFF] = SDLK_KP_ENTER;
+	MISC_keymap[Pk_KP_Equal&0xFF] = SDLK_KP_EQUALS;
+
+	MISC_keymap[Pk_Up&0xFF] = SDLK_UP;
+	MISC_keymap[Pk_Down&0xFF] = SDLK_DOWN;
+	MISC_keymap[Pk_Right&0xFF] = SDLK_RIGHT;
+	MISC_keymap[Pk_Left&0xFF] = SDLK_LEFT;
+	MISC_keymap[Pk_Insert&0xFF] = SDLK_INSERT;
+	MISC_keymap[Pk_Home&0xFF] = SDLK_HOME;
+	MISC_keymap[Pk_End&0xFF] = SDLK_END;
+	MISC_keymap[Pk_Pg_Up&0xFF] = SDLK_PAGEUP;
+	MISC_keymap[Pk_Pg_Down&0xFF] = SDLK_PAGEDOWN;
+
+	MISC_keymap[Pk_F1&0xFF] = SDLK_F1;
+	MISC_keymap[Pk_F2&0xFF] = SDLK_F2;
+	MISC_keymap[Pk_F3&0xFF] = SDLK_F3;
+	MISC_keymap[Pk_F4&0xFF] = SDLK_F4;
+	MISC_keymap[Pk_F5&0xFF] = SDLK_F5;
+	MISC_keymap[Pk_F6&0xFF] = SDLK_F6;
+	MISC_keymap[Pk_F7&0xFF] = SDLK_F7;
+	MISC_keymap[Pk_F8&0xFF] = SDLK_F8;
+	MISC_keymap[Pk_F9&0xFF] = SDLK_F9;
+	MISC_keymap[Pk_F10&0xFF] = SDLK_F10;
+	MISC_keymap[Pk_F11&0xFF] = SDLK_F11;
+	MISC_keymap[Pk_F12&0xFF] = SDLK_F12;
+	MISC_keymap[Pk_F13&0xFF] = SDLK_F13;
+	MISC_keymap[Pk_F14&0xFF] = SDLK_F14;
+	MISC_keymap[Pk_F15&0xFF] = SDLK_F15;
+
+	MISC_keymap[Pk_Num_Lock&0xFF] = SDLK_NUMLOCK;
+	MISC_keymap[Pk_Caps_Lock&0xFF] = SDLK_CAPSLOCK;
+	MISC_keymap[Pk_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
+	MISC_keymap[Pk_Shift_R&0xFF] = SDLK_RSHIFT;
+	MISC_keymap[Pk_Shift_L&0xFF] = SDLK_LSHIFT;
+	MISC_keymap[Pk_Control_R&0xFF] = SDLK_RCTRL;
+	MISC_keymap[Pk_Control_L&0xFF] = SDLK_LCTRL;
+	MISC_keymap[Pk_Alt_R&0xFF] = SDLK_RALT;
+	MISC_keymap[Pk_Alt_L&0xFF] = SDLK_LALT;
+	MISC_keymap[Pk_Meta_R&0xFF] = SDLK_RMETA;
+	MISC_keymap[Pk_Meta_L&0xFF] = SDLK_LMETA;
+	MISC_keymap[Pk_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */
+	MISC_keymap[Pk_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows */
+	MISC_keymap[Pk_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */
+
+	MISC_keymap[Pk_Help&0xFF] = SDLK_HELP;
+	MISC_keymap[Pk_Print&0xFF] = SDLK_PRINT;
+//	MISC_keymap[Pk_Sys_Req] = SDLK_SYSREQ;
+	MISC_keymap[Pk_Break&0xFF] = SDLK_BREAK;
+	MISC_keymap[Pk_Menu&0xFF] = SDLK_MENU;
+	MISC_keymap[Pk_Hyper_R&0xFF] = SDLK_MENU;   /* Windows "Menu" key */
+}
+
+static unsigned long cap;
+
+SDL_keysym *ph_TranslateKey(PhKeyEvent_t *key, SDL_keysym *keysym)
+{
+/*	
+	'sym' is set to the value of the key with modifiers applied to it. 
+	This member is valid only if Pk_KF_Sym_Valid is set in the key_flags.
+	We will assume it is valid.
+*/
+	cap = key->key_cap;
+    switch (cap>>8) {
+            case 0x00:  /* Latin 1 */
+            case 0x01:  /* Latin 2 */
+            case 0x02:  /* Latin 3 */
+            case 0x03:  /* Latin 4 */
+            case 0x04:  /* Katakana */
+            case 0x05:  /* Arabic */
+            case 0x06:  /* Cyrillic */
+            case 0x07:  /* Greek */
+            case 0x08:  /* Technical */
+            case 0x0A:  /* Publishing */
+            case 0x0C:  /* Hebrew */
+            case 0x0D:  /* Thai */
+                keysym->sym = (SDLKey)(cap&0xFF);
+                /* Map capital letter syms to lowercase */
+                if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z'))
+                    keysym->sym += ('a'-'A');
+                break;
+//            case 0xFE:
+//                keysym->sym = ODD_keymap[sym&0xFF];
+//                break;
+            case 0xF0:
+                keysym->sym = MISC_keymap[cap&0xFF];
+                break;
+            default:
+                fprintf(stderr,"Photon: Unknown key_cap, cap = 0x%.4x\n", (unsigned int)cap);
+                break;
+    }	
+	return (keysym);
+}
+
+void ph_InitOSKeymap(_THIS)
+{
+
+	ph_InitKeymap();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_events_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,34 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ph_video.h"
+
+#define EVENT_SIZE sizeof( PhEvent_t ) + 1000
+
+/* Functions to be exported */
+extern void ph_InitOSKeymap(_THIS);
+extern void ph_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_image.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,348 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <Ph.h>
+#include <photon/Pg.h>
+
+#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_ph_image_c.h"
+
+//printf("%s:%s:%d\n", __FILE__, __PRETTY_FUNCTION__, __LINE__ );
+
+/* Various screen update functions available */
+//static void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+//static void ph_DummyUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+int ph_SetupImage(_THIS, SDL_Surface *screen)
+{
+	int type = 0;
+
+	/* Determine image type */
+	switch(screen->format->BitsPerPixel)
+	{
+		case 8:{
+			type = Pg_IMAGE_PALETTE_BYTE;
+		}
+		break;
+		case 15:{
+			type = Pg_IMAGE_DIRECT_555; 
+		}
+		break;
+		case 16:{
+			type = Pg_IMAGE_DIRECT_565; 
+		}
+		break;
+
+		case 24:{
+			type = Pg_IMAGE_DIRECT_888;
+		}
+		break;
+		
+		case 32:{
+			type = Pg_IMAGE_DIRECT_8888;
+		}
+		break;
+		default:{
+		/* should never get here */
+			fprintf(stderr,"error: unsupported bbp = %d\n",
+					screen->format->BitsPerPixel);
+			return -1;
+		}
+		break;
+	}
+
+	//using shared memory for speed (set last param to 1)
+	if ((SDL_Image = PhCreateImage( NULL, screen->w, screen->h, type, NULL, 0, 1 )) 
+		== NULL)
+	{
+		fprintf(stderr,"error: PhCreateImage failed.\n");
+		return -1;
+	}
+
+	screen->pixels = SDL_Image->image;
+	
+	this->UpdateRects = ph_NormalUpdate;
+
+	return 0;
+}
+
+int ph_SetupOCImage(_THIS, SDL_Surface *screen) //Offscreen context
+{
+	int type = 0;
+
+	/* Determine image type */
+	switch(screen->format->BitsPerPixel)
+	{
+		case 8:{
+			type = Pg_IMAGE_PALETTE_BYTE;
+		}
+		break;
+		case 15:{
+			type = Pg_IMAGE_DIRECT_555; 
+		}
+		break;
+		case 16:{
+			type = Pg_IMAGE_DIRECT_565; 
+		}
+		break;
+
+		case 24:{
+			type = Pg_IMAGE_DIRECT_888;
+		}
+		break;
+		
+		case 32:{
+			type = Pg_IMAGE_DIRECT_8888;
+		}
+		break;
+		default:{
+		/* should never get here */
+			fprintf(stderr,"error: unsupported bbp = %d\n",
+					screen->format->BitsPerPixel);
+			return -1;
+		}
+		break;
+	}
+
+		OCImage.FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
+		OCImage.FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
+
+	if(OCImage.direct_context == NULL)
+	  OCImage.direct_context = PdCreateDirectContext();
+
+	  OCImage.offscreen_context = PdCreateOffscreenContext(0,screen->w,screen->h, Pg_OSC_MEM_PAGE_ALIGN);	
+				
+		if (OCImage.offscreen_context == NULL)
+		{
+			printf("PdCreateOffscreenContext  failed\n");
+			return -1;
+		}
+
+		OCImage.Stride = OCImage.offscreen_context->pitch;	
+
+      if (OCImage.flags & SDL_DOUBLEBUF)
+      			printf("hardware flag for doublebuf offscreen context\n");
+
+			
+			OCImage.dc_ptr.ptr8 = (unsigned char *) PdGetOffscreenContextPtr(OCImage.offscreen_context);
+			
+			OCImage.CurrentFrameData = OCImage.FrameData0;
+			OCImage.CurrentFrameData->Y = OCImage.dc_ptr.ptr8;
+			OCImage.CurrentFrameData->U = NULL;
+			OCImage.CurrentFrameData->V = NULL;
+			OCImage.current = 0;
+	
+			if(OCImage.dc_ptr.ptr8 == NULL)
+			{
+ 				printf("PdGetOffscreenContextPtr failed\n");
+ 				return -1;
+			}
+			
+			PhDCSetCurrent(OCImage.offscreen_context);
+
+			screen->pixels = OCImage.CurrentFrameData->Y;
+	
+			this->UpdateRects = ph_OCUpdate;
+
+	return 0;
+}
+
+
+void ph_DestroyImage(_THIS, SDL_Surface *screen)
+{
+
+
+   if(SDL_Image == NULL)
+     return;
+
+	 if (OCImage.offscreen_context != NULL)
+	{
+			
+			PhDCRelease(OCImage.offscreen_context);
+			OCImage.offscreen_context = NULL;
+			free(OCImage.FrameData0);
+			OCImage.FrameData0 = NULL;
+			free(OCImage.FrameData1);
+			OCImage.FrameData1 = NULL;
+	}
+
+	if (SDL_Image->image)
+	{
+		//free(SDL_Image->image);
+		//SDL_Image->image = NULL;
+		PhReleaseImage(SDL_Image);
+		SDL_Image = NULL;
+	}
+
+	if ( screen ) {
+    	screen->pixels = NULL;
+	}
+	
+	SDL_Image = NULL;
+}
+
+int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
+{
+  
+    ph_DestroyImage(this, screen);
+    
+    if(  flags & SDL_HWSURFACE)
+    {
+       OCImage.flags = flags;  //needed for SDL_DOUBLEBUF check
+       return ph_SetupOCImage(this,screen);
+    }
+    else if(flags & SDL_OPENGL) /* No image when using GL */
+    {
+       return 0;
+    } 
+    else
+    {
+        return ph_SetupImage(this, screen);
+    }      
+
+}
+
+int ph_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+
+        return(-1);
+}
+
+void ph_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+
+        return;
+}
+
+int ph_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+
+        return(0);
+}
+
+int ph_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+
+        if ( (surface == SDL_VideoSurface) && blit_queued ) {
+//                XSync(GFX_Display, False);
+				PgFlush();
+                blit_queued = 0;
+        }
+        return(0);
+}
+
+void ph_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+
+        return;
+}
+
+static PhPoint_t ph_pos;
+static PhRect_t ph_rect;
+static int i;
+
+void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+
+    for ( i=0; i<numrects; ++i ) 
+	{
+    	if ( rects[i].w == 0 ) { /* Clipped? */
+                continue;
+        }
+
+		ph_pos.x = rects[i].x;
+		ph_pos.y = rects[i].y;
+		ph_rect.ul.x = rects[i].x;
+		ph_rect.ul.y = rects[i].y;
+		ph_rect.lr.x = rects[i].x + rects[i].w;
+		ph_rect.lr.y = rects[i].y + rects[i].h;
+
+		if (PgDrawPhImageRectmx( &ph_pos, SDL_Image, &ph_rect, 0 ) < 0)
+		{
+			fprintf(stderr,"error: PgDrawPhImageRectmx failed.\n");
+		}
+	}
+    if (PgFlush() < 0)
+	{
+    	fprintf(stderr,"error: PgFlush failed.\n");
+    }
+}
+void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	PhPoint_t zero = {0};
+	PhRect_t src_rect;
+	PhRect_t dest_rect;
+
+	if(OCImage.direct_context == NULL)
+	 {
+	    return;
+	 }   
+	   		
+	  PgSetRegion(PtWidgetRid(window));
+	  PgSetClipping(0,NULL);
+	  PgWaitHWIdle();
+ 		
+
+    for ( i=0; i<numrects; ++i ) 
+	{
+    	if ( rects[i].w == 0 ) { /* Clipped? */
+                continue;
+        }
+
+			src_rect.ul.x=rects[i].x;
+			src_rect.ul.y=rects[i].y;
+			dest_rect.ul.x=rects[i].x;
+			dest_rect.ul.y=rects[i].y;
+			
+			dest_rect.lr.x=src_rect.lr.x= rects[i].x +rects[i].w;
+			dest_rect.lr.y=src_rect.lr.y= rects[i].y +rects[i].h;
+		
+			zero.x = zero.y = 0;
+	   		PgSetTranslation (&zero, 0);
+	       PgSetRegion(PtWidgetRid(window));
+			PgSetClipping(0,NULL);
+ 			PgContextBlitArea(OCImage.offscreen_context, (PhArea_t *)(&src_rect), NULL, (PhArea_t *)(&dest_rect));
+ 			
+	}
+    if (PgFlush() < 0)
+	{
+    	fprintf(stderr,"error: PgFlush failed.\n");
+    }
+    
+ //later used to toggling double buffer   
+    if(OCImage.current == 0)
+	{
+		OCImage.CurrentFrameData = OCImage.FrameData0;
+	}
+	else
+	{
+		OCImage.CurrentFrameData = OCImage.FrameData1;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_image_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ph_video.h"
+
+extern int ph_SetupImage(_THIS, SDL_Surface *screen);
+extern void ph_DestroyImage(_THIS, SDL_Surface *screen);
+extern int ph_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
+
+extern int ph_AllocHWSurface(_THIS, SDL_Surface *surface);
+extern void ph_FreeHWSurface(_THIS, SDL_Surface *surface);
+extern int ph_LockHWSurface(_THIS, SDL_Surface *surface);
+extern void ph_UnlockHWSurface(_THIS, SDL_Surface *surface);
+extern int ph_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+extern void ph_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+extern void ph_OCUpdate(_THIS, int numrects, SDL_Rect *rects);
+extern void ph_DummyUpdate(_THIS, int numrects, SDL_Rect *rects);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_modes.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,488 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+
+#include "SDL_ph_modes_c.h"
+
+static unsigned long key1, key2;
+static PgVideoModeInfo_t mode_info;
+static PgVideoModes_t mode_list;
+  /* The current list of available video modes */
+ SDL_Rect SDL_modelist[127];
+ SDL_Rect *SDLmod_ptr;
+ SDL_Rect **SDLmod_ptrptr ;
+
+static int compare_modes_by_res(const void* mode1, const void* mode2)
+{
+
+	if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
+	{
+	    fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
+        	    *(unsigned short*)mode1);
+    	return 0;
+	}
+	key1 = mode_info.width * mode_info.height;
+
+	if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
+	{
+    	fprintf(stderr,"error: In compare_modes_by_res PgGetVideoModeInfo failed on mode: 0x%x\n",
+	            *(unsigned short*)mode2);
+	    return 0;
+	}
+    key2 = mode_info.width * mode_info.height;
+
+	if (key1 > key2)
+		return 1;
+	else if (key1 == key2)
+		return 0;
+	else
+		return -1;
+}
+
+static int compare_modes_by_bpp(const void* mode1, const void* mode2)
+{
+
+    if (PgGetVideoModeInfo(*(unsigned short*)mode1, &mode_info) < 0)
+    {
+        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
+                *(unsigned short*)mode1);
+        return 0;
+    }
+    key1 = mode_info.bits_per_pixel;
+
+    if (PgGetVideoModeInfo(*(unsigned short*)mode2, &mode_info) < 0)
+    {
+        fprintf(stderr,"error: In compare_modes_by_bpp PgGetVideoModeInfo failed on mode: 0x%x\n",
+                *(unsigned short*)mode2);
+        return 0;
+    }
+    key2 = mode_info.bits_per_pixel;
+
+    if (key1 > key2)
+        return 1;
+    else if (key1 == key2)
+        return 0;
+    else
+        return -1;
+}
+
+int ph_GetVideoModes(_THIS)
+{
+	unsigned short *front;
+	int i, bpp_group_size;
+
+	// TODO: add mode_list member to _THIS
+	if (PgGetVideoModeList( &mode_list ) < 0)
+	{
+		fprintf(stderr,"error: PgGetVideoModeList failed\n");
+		return -1;
+	}
+	
+	// sort list first by bits per pixel (bpp), 
+	// then sort groups with same bpp by resolution.
+	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_bpp);
+	bpp_group_size = 1;
+	front = &mode_list.modes[0];
+	for(i=0;i<mode_list.num_modes-2;i++)
+	{
+		if (compare_modes_by_bpp(&mode_list.modes[i],&mode_list.modes[i+1]))
+		{
+			qsort(front, bpp_group_size, sizeof(unsigned short), compare_modes_by_res);
+			front = &mode_list.modes[i+1];
+			bpp_group_size = 1;
+		}
+		else
+		{
+			bpp_group_size++;
+		}
+	}
+
+	//SDL_modelist = (SDL_Rect **)malloc((mode_list.num_modes+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist ) {
+		for (i=0;i<mode_list.num_modes;i++) {
+        //	SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+	     //   if ( SDL_modelist[i] == NULL ) {
+    	  //      break;
+	     //   }
+		    if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+		    {
+        		fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
+                		mode_list.modes[i]);
+		        return -1;
+    		}
+    	    SDL_modelist[i].x = 0;
+	        SDL_modelist[i].y = 0;
+    	    SDL_modelist[i].w = mode_info.height;
+        	SDL_modelist[i].h = mode_info.width;
+	    }
+    	//SDL_modelist[i] = NULL;
+	}
+	else
+	{
+		fprintf(stderr,"error: malloc failed on SDL_modelist\n");
+		return -1;
+	}
+	
+	return 0;
+}
+
+static SDL_Rect** ph_SupportedVisual( SDL_PixelFormat *format)
+{
+	int i = 0;
+	int j = 0;
+	SDL_Rect Amodelist[127];
+
+
+	if (PgGetVideoModeList( &mode_list ) < 0)
+    {
+        fprintf(stderr,"error: PgGetVideoModeList failed\n");
+        return NULL;
+    }
+
+	mode_info.bits_per_pixel = 0;
+
+	for (i=0; i < mode_list.num_modes; i++) 
+	{
+            if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+            {
+                fprintf(stderr,"error: PgGetVideoModeInfo failed on mode: 0x%x\n",
+                        mode_list.modes[i]);
+                return NULL;
+            }
+            
+            if(mode_info.bits_per_pixel == format->BitsPerPixel)
+            {
+				Amodelist[j].w = mode_info.width;
+				Amodelist[j].h = mode_info.height;
+				Amodelist[j].x = 0;
+				Amodelist[j].y = 0;
+				j++;	
+			}
+	}
+	
+	//reorder biggest for smallest , assume width dominates
+	   for(i=0; i< j ; i++)
+	   {
+	     SDL_modelist[i].w = Amodelist[j - i -1].w;
+	     SDL_modelist[i].h = Amodelist[j - i -1].h;
+	     SDL_modelist[i].x = Amodelist[j - i -1].x;
+	     SDL_modelist[i].y = Amodelist[j - i -1].y;
+	   }
+	
+	SDLmod_ptr = SDL_modelist;
+	SDLmod_ptrptr = &SDLmod_ptr;
+	return SDLmod_ptrptr;
+}
+
+SDL_Rect **ph_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+    return ph_SupportedVisual( format);
+}
+
+void ph_FreeVideoModes(_THIS)
+{
+    int i;
+
+ //   if ( SDL_modelist ) {
+ //       for ( i=0; SDL_modelist[i]; ++i ) {
+ //           free(SDL_modelist[i]);
+ //       }
+ //       free(SDL_modelist);
+ //       SDL_modelist = NULL;
+//    }
+}
+
+static void set_best_resolution(_THIS, int width, int height)
+{
+
+    if ( use_vidmode ) {
+		PgDisplaySettings_t 	settings;
+		PgVideoModeInfo_t		current_mode_info;
+		unsigned short			current_bpp;
+        int i;
+
+		if (PgGetVideoMode( &settings ) < 0)
+		{
+			fprintf(stderr,"error: PgGetVideoMode failed\n");
+			return;
+		}
+		if (PgGetVideoModeInfo( settings.mode, &current_mode_info ) < 0)
+		{
+			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+			return;
+		}
+		current_bpp = current_mode_info.bits_per_pixel;
+
+        if (PgGetVideoModeList(&mode_list) >= 0)
+		{
+			qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
+#ifdef PH_DEBUG
+  			printf("Available modes:\n");
+  			for ( i = 0; i < mode_list.num_modes; ++i ) 
+			{
+				PgGetVideoModeInfo(mode_list.modes[i], &mode_info);
+    			printf("Mode %d: %dx%d\n", i, mode_info.width, mode_info.height);
+  			}
+#endif
+            for ( i = mode_list.num_modes-1; i >= 0 ; --i ) 
+			{
+				if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+				{
+					fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+				}
+                if ( (mode_info.width >= width) &&
+                     (mode_info.height >= height) &&
+					 (mode_info.bits_per_pixel == current_bpp) )
+                    break;
+            }
+			if (i >= 0)
+			{
+                if ( (mode_info.width != current_mode_info.width) ||
+                     (mode_info.height != current_mode_info.height) ) 
+				{
+					settings.mode = mode_list.modes[i];
+					if(PgSetVideoMode( &settings ) < 0)	
+					{
+						fprintf(stderr,"error: PgSetVideoMode failed\n");
+					}
+                }
+            }
+        }
+    }
+}
+
+static void get_real_resolution(_THIS, int* w, int* h)
+{
+
+    if ( use_vidmode ) {
+        PgDisplaySettings_t settings;
+        int unused;
+
+        if (PgGetVideoMode( &settings ) >= 0) {
+			*w = settings.xres;
+			*h = settings.yres;
+            return;
+        }
+    }
+//    *w = DisplayWidth(SDL_Display, SDL_Screen);
+//    *h = DisplayHeight(SDL_Display, SDL_Screen);
+}
+
+int ph_ResizeFullScreen(_THIS)
+{
+
+    if ( currently_fullscreen ) {
+        set_best_resolution(this, current_w, current_h);
+    }
+    return(1);
+}
+
+int get_mode(int width, int height, int bpp)
+/* return the mode associated with width, height and bpp */
+/* if there is no mode then zero is returned */
+{
+	int i;
+
+
+if(width <640)
+   width = 640;
+if(height < 480)
+  height = 480;
+
+
+	if (PgGetVideoModeList( &mode_list ) < 0)
+	{
+	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
+    	return -1;
+	}
+
+	// search list for exact match
+	for (i=0;i<mode_list.num_modes;i++)
+	{
+		if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+		{
+			fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+			return 0;
+		}
+		
+		
+		if ((mode_info.width == width) && 
+			(mode_info.height == height) && 
+			(mode_info.bits_per_pixel == bpp))
+			{
+			return mode_list.modes[i];
+			}
+	}
+	return (i == mode_list.num_modes) ? 0 : mode_list.modes[i];
+}
+
+int get_mode_any_format(int width, int height, int bpp)
+/* return the mode associated with width, height and bpp */
+/* if requested bpp is not found the mode with closest bpp is returned */
+{
+    int i, closest, delta, min_delta;
+
+	if (PgGetVideoModeList( &mode_list ) < 0)
+	{
+	    fprintf(stderr,"error: PgGetVideoModeList failed\n");
+	    return -1;
+	}
+
+	qsort(mode_list.modes, mode_list.num_modes, sizeof(unsigned short), compare_modes_by_res);
+	for(i=0;i<mode_list.num_modes;i++)
+	{
+       if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+       {
+           fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+           return 0;
+       }
+       if ((mode_info.width == width) &&
+           (mode_info.height == height))
+           break;
+	}
+	if (i<mode_list.num_modes)
+	{
+		// get closest bpp
+		closest = i++;
+		if (mode_info.bits_per_pixel == bpp)
+			return mode_list.modes[ closest ];
+
+		min_delta = abs(mode_info.bits_per_pixel - bpp);
+		while(1)
+		{
+			if (PgGetVideoModeInfo(mode_list.modes[i], &mode_info) < 0)
+			{
+			    fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+			    return 0;
+			}
+
+			if ((mode_info.width != width) ||
+				(mode_info.height != height))
+				break;
+			else if (mode_info.bits_per_pixel == bpp)
+			{
+				closest = i;
+				break;
+			}
+			else
+			{
+				delta = abs(mode_info.bits_per_pixel - bpp);
+				if (delta < min_delta)
+				{
+					closest = i;
+					min_delta = delta;
+				}
+				i++;
+			}
+		}
+		return mode_list.modes[ closest ];
+	}
+	else
+		return 0;
+}
+
+void ph_WaitMapped(_THIS);
+void ph_WaitUnmapped(_THIS);
+void ph_QueueEnterFullScreen(_THIS);
+
+int ph_ToggleFullScreen(_THIS, int on)
+{
+
+   if(currently_fullscreen)
+        ph_LeaveFullScreen(this);
+   else
+        ph_EnterFullScreen(this);
+      
+   return 0;     
+
+}
+
+int ph_EnterFullScreen(_THIS)
+{
+	if ( ! currently_fullscreen ) 
+	{
+
+		if (old_video_mode==-1)
+		{
+			PgGetGraphicsHWCaps(&graphics_card_caps);
+			old_video_mode=graphics_card_caps.current_video_mode;
+			old_refresh_rate=graphics_card_caps.current_rrate;
+		}
+
+
+		if(OCImage.direct_context == NULL)
+       	 OCImage.direct_context=(PdDirectContext_t*)PdCreateDirectContext();
+        if( !OCImage.direct_context )
+             fprintf(stderr, "error: Can't create direct context\n" );
+             
+       
+		/* Remove the cursor if in full screen mode */		
+/*
+		region_info.cursor_type = Ph_CURSOR_NONE;
+		region_info.rid=PtWidgetRid(window);
+		PhRegionChange(Ph_REGION_CURSOR,0,&region_info,NULL,NULL);
+*/
+
+	 	PdDirectStart( OCImage.direct_context );
+
+		currently_fullscreen = 1;
+		}
+
+
+		
+	return 1;
+}
+
+int ph_LeaveFullScreen(_THIS )
+{
+   PgDisplaySettings_t mymode_settings;
+       
+	if ( currently_fullscreen )
+	{
+		PdDirectStop(OCImage.direct_context);
+		PdReleaseDirectContext(OCImage.direct_context);
+
+		//Restore old video mode	
+		if (old_video_mode != -1)
+		{
+			mymode_settings.mode= (unsigned short) old_video_mode;
+			mymode_settings.refresh= (unsigned short) old_refresh_rate;
+			mymode_settings.flags = 0;
+			if(PgSetVideoMode(&mymode_settings) < 0)
+			{
+            fprintf(stderr,"error: PgSetVideoMode failed\n");
+        	}
+		}
+	
+		old_video_mode=-1;
+		old_refresh_rate=-1;	
+	
+		// Restore cursor	
+	
+	}
+	return 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_modes_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,47 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+
+#ifndef _PH_MODES_INCLUDED_
+#define _PH_MODES_INCLUDED_
+
+#include "SDL_ph_video.h"
+
+extern int ph_GetVideoModes(_THIS);
+extern SDL_Rect **ph_ListModes(_THIS,SDL_PixelFormat *format, Uint32 flags);
+extern void ph_FreeVideoModes(_THIS);
+extern int ph_ResizeFullScreen(_THIS);
+extern void ph_WaitMapped(_THIS);
+extern void ph_WaitUnmapped(_THIS);
+extern void ph_QueueEnterFullScreen(_THIS);
+extern int ph_EnterFullScreen(_THIS);
+extern int ph_LeaveFullScreen(_THIS);
+extern int get_mode(int width, int height, int bpp);
+extern int get_mode_any_format(int width, int height, int bpp);
+extern int ph_ToggleFullScreen(_THIS, int on);
+
+#endif /* _PH_MODES_INCLUDED_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_mouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,177 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_ph_mouse_c.h"
+
+struct  WMcursor {
+	PhCursorDef_t *ph_cursor ;
+};
+
+
+void ph_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+
+    if ( window != NULL ) {
+		SDL_Lock_EventThread();
+		
+		if (PtSetResource( window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0 ) < 0)
+		{
+			//TODO: output error msg
+		}
+		
+		SDL_Unlock_EventThread();
+	}	
+	//free(cursor->ph_cursor.images);
+	free(cursor);
+}
+
+WMcursor *ph_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+	WMcursor* cursor;
+	int clen, i;
+
+	/* Allocate and initialize the cursor memory */
+	if ((cursor = (WMcursor*)malloc(sizeof(WMcursor))) == NULL)
+	{
+        SDL_OutOfMemory();
+        return(NULL);
+	}
+	memset(cursor,0,sizeof(WMcursor));
+	
+	cursor->ph_cursor = (PhCursorDef_t *) malloc(sizeof(PhCursorDef_t) + 32*4*2);
+	if(cursor->ph_cursor == NULL)
+	   printf("cursor malloc failed\n");
+
+	memset(cursor->ph_cursor,0,(sizeof(PhCursorDef_t) + 32*4*2));
+	   
+	cursor->ph_cursor->hdr.type =Ph_RDATA_CURSOR;   
+	cursor->ph_cursor->size1.x = (short)w;
+	cursor->ph_cursor->size1.y = (short)h;
+	cursor->ph_cursor->offset1.x = (short)hot_x;
+	cursor->ph_cursor->offset1.y = (short)hot_y;
+	cursor->ph_cursor->bytesperline1 = (char)w/8;
+	cursor->ph_cursor->color1 = Pg_WHITE;
+	cursor->ph_cursor->size2.x = (short)w;
+    cursor->ph_cursor->size2.y = (short)h;
+    cursor->ph_cursor->offset2.x = (short)hot_x;
+    cursor->ph_cursor->offset2.y = (short)hot_y;
+    cursor->ph_cursor->bytesperline2 = (char)w/8;
+    cursor->ph_cursor->color2 = Pg_BLACK;
+      
+	clen = (w/8)*h;
+
+	/* Copy the mask and the data to different 
+	   bitmap planes */
+	for ( i=0; i<clen; ++i ) {
+        cursor->ph_cursor->images[i] = data[i];
+        cursor->ph_cursor->images[i+clen] = mask[i];
+    }
+    
+    //#bytes following the hdr struct
+	cursor->ph_cursor->hdr.len =sizeof(PhCursorDef_t) + clen*2 - sizeof(PhRegionDataHdr_t); 
+
+	return (cursor);
+}
+
+
+PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor)
+{
+
+	return(*cursor->ph_cursor);
+}
+
+
+int ph_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	PtArg_t args[3];
+	int nargs = 0;
+	short cursor_is_defined = 0;
+
+
+
+	/* Don't do anything if the display is gone */
+ 	if ( window == NULL ) {
+    	 return(0);
+ 	}
+
+	/* Set the photon cursor cursor, or blank if cursor is NULL */
+	if ( window ) {
+		
+		if ( cursor != NULL ) {
+			PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0 );
+			// Could set next to any PgColor_t value
+			PtSetArg( &args[1], Pt_ARG_CURSOR_COLOR,Ph_CURSOR_DEFAULT_COLOR , 0 );
+			PtSetArg( &args[2], Pt_ARG_BITMAP_CURSOR, cursor->ph_cursor, (cursor->ph_cursor->hdr.len + sizeof(PhRegionDataHdr_t)) );
+			nargs = 3;
+			cursor_is_defined = 1;
+		}
+		else // Ph_CURSOR_NONE
+		{
+			PtSetArg( &args[0], Pt_ARG_CURSOR_TYPE,Ph_CURSOR_NONE, 0);
+			nargs = 1;
+			cursor_is_defined = 1;
+		}
+		if (cursor_is_defined)
+		 {
+    	    SDL_Lock_EventThread();
+			
+			if (PtSetResources( window, nargs, args ) < 0 )
+			{
+			    return(0);
+			}	
+						
+			SDL_Unlock_EventThread();
+		}
+		else
+			return(0);
+	}
+	return(1);
+}
+
+void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+
+	SDL_Lock_EventThread();
+	PhMoveCursorRel( PhInputGroup(NULL), x, y );	
+	SDL_Unlock_EventThread();
+}
+
+
+void ph_CheckMouseMode(_THIS)
+{
+
+	mouse_relative = 1;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_mouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ph_video.h"
+
+/* Functions to be exported */
+extern void ph_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *ph_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern PhCursorDef_t ph_GetWMPhCursor(WMcursor *cursor);
+extern int ph_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void ph_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+extern void ph_CheckMouseMode(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_video.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,496 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_thread.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_endian.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_ph_video.h"
+#include "SDL_ph_modes_c.h"
+#include "SDL_ph_image_c.h"
+#include "SDL_ph_events_c.h"
+#include "SDL_ph_mouse_c.h"
+#include "SDL_phyuv_c.h"
+#include "blank_cursor.h"
+
+static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
+                int width, int height, int bpp, Uint32 flags);
+static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void ph_VideoQuit(_THIS);
+static void ph_DeleteDevice(SDL_VideoDevice *device);
+
+static int ph_Available(void)
+{
+
+        return 1;
+}
+
+static SDL_VideoDevice *ph_CreateDevice(int devindex)
+{
+    SDL_VideoDevice *device;
+
+    /* Initialize all variables that we clean on shutdown */
+    device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+    if ( device ) {
+        memset(device, 0, (sizeof *device));
+        device->hidden = (struct SDL_PrivateVideoData *)
+                malloc((sizeof *device->hidden));
+        device->gl_data = NULL;
+    }
+    if ( (device == NULL) || (device->hidden == NULL) ) {
+        SDL_OutOfMemory();
+        ph_DeleteDevice(device);
+        return(0);
+    }
+    memset(device->hidden, 0, (sizeof *device->hidden));
+
+    /* Set the driver flags */
+    device->handles_any_size = 1; //JB not true for fullscreen
+
+    /* Set the function pointers */
+	device->CreateYUVOverlay = ph_CreateYUVOverlay;
+    device->VideoInit = ph_VideoInit;
+    device->ListModes = ph_ListModes;
+    device->SetVideoMode = ph_SetVideoMode;
+    device->ToggleFullScreen =  ph_ToggleFullScreen;
+    device->UpdateMouse = NULL;	
+    device->SetColors = ph_SetColors;
+    device->UpdateRects =  NULL; //set in ph_ResizeImage
+    device->VideoQuit = ph_VideoQuit;
+    device->AllocHWSurface = ph_AllocHWSurface;
+    device->CheckHWBlit = NULL;
+    device->FillHWRect = NULL;
+    device->SetHWColorKey = NULL;
+    device->SetHWAlpha = NULL;
+    device->LockHWSurface = ph_LockHWSurface;
+    device->UnlockHWSurface = ph_UnlockHWSurface;
+    device->FlipHWSurface = ph_FlipHWSurface;
+    device->FreeHWSurface = ph_FreeHWSurface;
+    device->SetCaption = NULL;
+    device->SetIcon = NULL;
+    device->IconifyWindow = NULL;
+    device->GrabInput = NULL;
+    device->GetWMInfo = NULL;
+    device->FreeWMCursor = ph_FreeWMCursor;
+    device->CreateWMCursor = ph_CreateWMCursor;
+    device->ShowWMCursor = ph_ShowWMCursor;
+    device->WarpWMCursor = ph_WarpWMCursor;
+    device->CheckMouseMode = ph_CheckMouseMode;
+    device->InitOSKeymap = ph_InitOSKeymap;
+    device->PumpEvents = ph_PumpEvents;
+
+    device->free = ph_DeleteDevice;
+
+    return device;
+}
+
+VideoBootStrap X11_bootstrap = {
+        "photon", "QNX Photon video output",
+	ph_Available, ph_CreateDevice
+};
+
+static void ph_DeleteDevice(SDL_VideoDevice *device)
+{
+
+    if ( device ) {
+        if ( device->hidden ) {
+            free(device->hidden);
+            device->hidden = NULL;
+        }
+        if ( device->gl_data ) {
+            free(device->gl_data);
+            device->gl_data = NULL;
+        }
+        free(device);
+        device = NULL;
+    }
+}
+
+static int ph_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	PtArg_t arg[1];
+    PhDim_t dim;
+	PgColor_t ph_palette[_Pg_MAX_PALETTE];
+	int i;
+	unsigned long *tempptr;
+	int rtnval;
+	PgDisplaySettings_t mysettings;
+	PgVideoModeInfo_t my_mode_info;
+	
+     if( NULL == ( event = malloc( EVENT_SIZE ) ) )
+          exit( EXIT_FAILURE );
+
+	/* Create a widget 'window' to capture events */
+    dim.w=0; //JB test320;
+    dim.h=0; //JB test240;
+    //We need to return BytesPerPixel as it in used by CreateRGBsurface
+	
+    PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
+    
+/*    
+    PtSetArg(&arg[1], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, Pt_RESIZE_XY_AS_REQUIRED);
+    PtSetArg(&arg[2], Pt_ARG_WINDOW_STATE, Pt_TRUE, Ph_WM_STATE_ISFRONT |
+                        Ph_WM_STATE_ISMAX |
+                        Ph_WM_STATE_ISFOCUS);
+
+    PtSetArg(&arg[3], Pt_ARG_WINDOW_RENDER_FLAGS,Pt_FALSE,~0);
+    PtSetArg(&arg[4], Pt_ARG_WINDOW_MANAGED_FLAGS,Pt_TRUE,
+                        Ph_WM_FFRONT |
+                        Ph_WM_CLOSE |
+                        Ph_WM_TOFRONT |
+                        Ph_WM_CONSWITCH);
+*/    
+    
+    
+	window=PtAppInit(NULL, NULL, NULL, 1, arg);
+
+  	if(window == NULL)
+  	{
+  		printf("PtAppInit failed\n");
+        PtExit(EXIT_FAILURE);
+  	}
+
+    //PgSetDrawBufferSize(16 *1024);
+   	PgSetRegion(PtWidgetRid(window));
+    PgSetClipping(0,NULL);
+    PtRealizeWidget(window);
+
+
+    /* Get the available video modes */
+//    if(ph_GetVideoModes(this) < 0)
+//        return -1;
+
+	/* Create the blank cursor */
+	SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
+                (int)BLANK_CWIDTH, (int)BLANK_CHEIGHT,
+                   (int)BLANK_CHOTX, (int)BLANK_CHOTY);
+
+	if(SDL_BlankCursor == NULL)
+	  printf("could not create blank cursor\n");
+     /* Get the video mode */
+         if (PgGetVideoMode( &mysettings ) < 0)
+            {
+                fprintf(stderr,"ph_VideoInit:  PgGetVideoMode failed\n");
+      			//QNX6/Patch A always fails return code even though call succeeds. fixed Patch B
+            }
+        
+         if (PgGetVideoModeInfo(mysettings.mode, &my_mode_info) < 0)
+            {
+                fprintf(stderr,"ph_VideoInit:  PgGetVideoModeInfo failed\n");
+            }
+       //We need to return BytesPerPixel as it in used by CreateRGBsurface
+       vformat->BitsPerPixel = my_mode_info.bits_per_pixel;
+       vformat->BytesPerPixel = vformat->BitsPerPixel/8;
+ 
+       //return a palette if we are in 256 color mode           
+		if(vformat->BitsPerPixel == 8)
+		{
+			vformat->palette = malloc(sizeof(SDL_Palette));
+			memset(vformat->palette, 0, sizeof(SDL_Palette));
+			vformat->palette->ncolors = 256;
+			vformat->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
+			
+			//fill the palette
+			rtnval = PgGetPalette(ph_palette);
+			if(rtnval < 0)
+			   printf("ph_VideoInit:  PgGetPalette failed\n");
+			   
+       	tempptr = (unsigned long *)vformat->palette->colors;
+
+			for(i=0;i<256; i++)
+			{
+  				*tempptr = (((unsigned long)ph_palette[i]) << 8);
+  				tempptr++;
+
+			}		
+		
+		}
+
+
+	currently_fullscreen = 0;
+    return 0;
+}
+
+static SDL_Surface *ph_SetVideoMode(_THIS, SDL_Surface *current,
+                int width, int height, int bpp, Uint32 flags)
+{
+    PhRegion_t region_info;
+    PgDisplaySettings_t settings;
+	PgVideoModeInfo_t mode_info;
+    int mode, actual_width, actual_height;
+	PtArg_t arg[5];
+	PhDim_t dim;	
+		int rtnval;
+	SDL_Rect ** mymodelist;
+	SDL_PixelFormat myformat;
+	PgColor_t ph_palette[_Pg_MAX_PALETTE];
+	int i;
+	unsigned long *tempptr;
+
+	actual_width = width;
+	actual_height = height;
+
+
+    /* Lock the event thread, in multi-threading environments */
+    SDL_Lock_EventThread();
+
+
+     /* Initialize the window */
+    if (flags & SDL_FULLSCREEN) //Direct Context , assume SDL_HWSURFACE also set
+    {
+
+/*  
+	if (old_video_mode==-1)
+	{
+		PgGetGraphicsHWCaps(&graphics_card_caps);
+		old_video_mode=graphics_card_caps.current_video_mode;
+		old_refresh_rate=graphics_card_caps.current_rrate;
+	}
+*/    	
+    	  	
+    	  	  	
+    	  	  	  	  	
+        /* Get the video mode and set it */
+        if (bpp == 0)
+        {
+            if (PgGetVideoMode( &settings ) < 0)
+            {
+                fprintf(stderr,"error: PgGetVideoMode failed\n");
+            }
+            if (PgGetVideoModeInfo(settings.mode, &mode_info) < 0)
+            {
+                fprintf(stderr,"error: PgGetVideoModeInfo failed\n");
+            }
+            bpp = mode_info.bits_per_pixel;
+        }
+        if (flags & SDL_ANYFORMAT)
+        {
+            if ((mode = get_mode_any_format(width, height, bpp)) == 0)
+            {
+                fprintf(stderr,"error: get_mode_any_format failed\n");
+                exit(1);
+            }
+        }
+        else
+        {
+            if ((mode = get_mode(width, height, bpp)) == 0)
+            {
+                 	fprintf(stderr,"error: get_mode failed\n");
+                	exit(1);
+            }
+               
+           
+        }
+        settings.mode = mode;
+        settings.refresh = 0;
+        settings.flags  = 0;       
+             
+        
+        if (PgSetVideoMode( &settings ) < 0)
+        {
+            fprintf(stderr,"error: PgSetVideoMode failed\n");
+        }
+
+		/* Get the true height and width */
+		
+      current->flags = (flags|(~SDL_RESIZABLE)); //no resize for Direct Context
+
+		 /* Begin direct mode */
+		 ph_EnterFullScreen(this);
+
+       
+
+    } //end fullscreen flag
+    else if (flags & SDL_HWSURFACE)  /* Use offscreen memory iff SDL_HWSURFACE flag is set */
+    {
+      // Hardware surface is Offsceen Context.  ph_ResizeImage handles the switch
+      current->flags = (flags|(~SDL_RESIZABLE)); //no stretch blit in offscreen context
+    }
+    else // must be SDL_SWSURFACE
+    {
+     current->flags = (flags|SDL_RESIZABLE); //yes we can resize as this is a software surface
+     }
+
+
+	//If we are setting video to use the palette make sure we have allocated memory for it
+	if(bpp == 8)
+	{
+		current->format->palette = malloc(sizeof(SDL_Palette));
+		memset(current->format->palette, 0, sizeof(SDL_Palette));
+		current->format->palette->ncolors = 256;
+		current->format->palette->colors = (SDL_Color *)malloc(256 *sizeof(SDL_Color));
+		//fill the palette
+		rtnval = PgGetPalette(ph_palette);
+
+       tempptr = (unsigned long *)current->format->palette->colors;
+
+		for(i=0;i<256; i++)
+		{
+  			*tempptr = (((unsigned long)ph_palette[i]) << 8);
+  			tempptr++;
+
+		}
+	}
+
+
+	//Current window dimensions
+	PtGetResource( window, Pt_ARG_DIM, &dim, 0 );
+	
+	//If we need to resize the window
+	if((dim.w != width)||(dim.h != height))
+	{
+	    dim.w=width;
+    	dim.h=height; 
+    	PtSetArg(&arg[0], Pt_ARG_DIM, &dim,0);
+		PtSetResources( window, 1, arg ); 	
+       current->w = width;
+       current->h = height;
+       current->format->BitsPerPixel = bpp;
+		current->format->BytesPerPixel = bpp/8;
+       current->pitch = SDL_CalculatePitch(current);
+       //Must call at least once it setup image planes 
+       ph_ResizeImage(this, current, flags);
+    }
+
+
+    SDL_Unlock_EventThread();
+
+    /* We're done! */
+    return(current);
+}
+
+static void ph_VideoQuit(_THIS)
+{
+		
+	if(SDL_Image != NULL)
+	{
+	  	    ph_DestroyImage(this, SDL_VideoSurface); 
+	
+	}
+
+	if (currently_fullscreen)
+	{
+		PdDirectStop( directContext );
+		PdReleaseDirectContext( directContext );
+		directContext=0;	
+		currently_fullscreen = 0;
+	}
+	
+}
+
+
+static int ph_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	PgColor_t *in, *out;
+	int i, j;
+	int alloct_all = 1;
+
+    	colors = this->screen->format->palette->colors;
+
+	in = alloca( ncolors*sizeof(PgColor_t)  );
+	if ( in == NULL  ) {
+		return 0;
+	}
+	memset(in,0,ncolors*sizeof(PgColor_t));
+
+    out = alloca( ncolors*sizeof(PgColor_t)  );
+    if ( out == NULL  ) {
+		return 0;
+    }
+	
+	for (i=0,j=firstcolor;i<ncolors;i++,j++)
+	{
+		in[i] |= colors[j].r<<16 ;
+		in[i] |= colors[j].g<<8 ;
+		in[i] |= colors[j].b ; 
+	}
+
+	if ( (this->screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) 
+	{
+		if( PgSetPalette( in, 0, 0, ncolors, Pg_PALSET_HARD, 0) < 0 )
+		{
+			fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_HARD)  failed\n");
+			return 0;
+		}  
+	}
+	else 
+	{
+		if ( PgColorMatch(ncolors, in, out) < 0 )
+        {
+            fprintf(stderr,"error: PgColorMatch failed\n");
+            return 0;
+        }
+		for (i=0;i<ncolors;i++)
+		{
+			if (memcmp(&in[i],&out[i],sizeof(PgColor_t)))
+			{
+				alloct_all = 0;
+				break;
+			}
+		}
+        if( PgSetPalette( out, 0, 0, ncolors, Pg_PALSET_SOFT, 0) < 0 )
+        {
+            fprintf(stderr,"error: PgSetPalette(..,Pg_PALSET_SOFT) failed\n");
+            return 0;
+        }
+	}
+	return alloct_all;
+}
+
+static int ph_ResizeWindow(_THIS,
+            SDL_Surface *screen, int w, int h, Uint32 flags)
+{
+	PhWindowEvent_t winevent;
+
+	memset( &winevent, 0, sizeof(winevent) ); 
+	winevent.event_f = Ph_WM_RESIZE;
+	winevent.size.w = w;
+	winevent.size.h = h;
+	winevent.rid = PtWidgetRid( window );
+	if (PtForwardWindowEvent( &winevent ) < 0)
+	{
+		fprintf(stderr,"error: PtForwardWindowEvent failed.\n");
+	}
+	current_w = w;
+	current_h = h;
+    return(0);
+}
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_video.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,172 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+/*
+static PhEvent_t *event;
+static PtAppContext_t app;
+static PtWidget_t *window;
+static PgVideoModes_t modelist;
+static PdOffscreenContext_t *Buff[2];
+static PdDirectContext_t *directContext;
+static PhRect_t screenRect,windowRect;
+static PgColor_t currRGB;
+static PhPoint_t zeroPoint;
+static char keyque[ QUE_SIZE ],keyMatrix[256];
+static int queput,queget;
+static int modeSet;
+static PgHWCaps_t hwCaps;
+static PgDisplaySettings_t mode_settings;
+static int rshift1,rshift2,gshift1,gshift2,bshift1,bshift2;
+static int backPitch;
+static unsigned RBitMask,GBitMask,BBitMask;
+static unsigned TranslatedFillColor;
+*/
+
+#ifndef _SDL_ph_video_h
+#define _SDL_ph_video_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+#include "Ph.h"
+#include "Pt.h"
+#include <photon/Pg.h>
+#include <photon/PdDirect.h>
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+typedef union vidptr{
+  uint8_t  *volatile ptr8;
+  uint16_t *volatile ptr16;
+  uint32_t *volatile ptr32;
+ } VidPtr_t;
+
+typedef struct {
+	unsigned char *Y;
+	unsigned char *V;
+	unsigned char *U;
+}FRAMEDATA;
+
+#define EVENT_SIZE    sizeof( PhEvent_t ) + 1000
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+    int local_ph;		/* Flag: true if local display */
+    PtAppContext_t app;
+    PgDisplaySettings_t mode_settings;	
+    PtWidget_t *window;    /* used to handle input events */
+	PhImage_t *image;	 /* used to display image */
+
+ 	struct {
+       PdDirectContext_t *direct_context;
+		PdOffscreenContext_t *offscreen_context;
+		VidPtr_t    dc_ptr;
+		FRAMEDATA *CurrentFrameData;
+		FRAMEDATA *FrameData0;
+		FRAMEDATA *FrameData1;
+		int current;
+		long Stride;
+		long flags;
+	} ocimage;
+
+    PhDrawContext_t *ScreenDC; //=NULL;
+	signed short old_video_mode; //=-1;
+	signed short old_refresh_rate; //=-1;
+	PgHWCaps_t graphics_card_caps;
+	
+	PdDirectContext_t *directContext;
+	PdOffscreenContext_t *Buff[2];
+	struct _Ph_ctrl* ctrl_channel;
+	
+	PhGC_t *Pt_GC, *Pg_GC; /* Graphic contexts to switch between Pt and Pg APIs */
+
+    /* The variables used for displaying graphics */
+
+    /* The current width and height of the fullscreen mode */
+    int current_w;
+    int current_h;
+
+    /* Support for internal mouse warping */
+    struct {
+        int x;
+        int y;
+    } mouse_last;
+    struct {
+        int numerator;
+        int denominator;
+        int threshold;
+    } mouse_accel;
+    int mouse_relative;
+	WMcursor* BlankCursor;
+
+  
+
+    int depth;			/* current visual depth (not bpp) */
+
+    int use_vidmode;
+    int currently_fullscreen;
+
+    /* Automatic mode switching support (entering/leaving fullscreen) */
+    Uint32 switch_waiting;
+    Uint32 switch_time;
+
+    /* Prevent too many XSync() calls */
+    int blit_queued;
+
+    short *iconcolors;		/* List of colors used by the icon */
+	PhEvent_t* event;
+};
+
+#define local_ph 		(this->hidden->local_ph)
+#define app				(this->hidden->app)
+#define mode_settings	(this->hidden->mode_settings)
+#define window			(this->hidden->window)
+#define directContext	(this->hidden->directContext)
+#define Buff			(this->hidden->Buff)
+#define ctrl_channel 	(this->hidden->ctrl_channel)
+#define SDL_Image		(this->hidden->image)
+#define OCImage		(this->hidden->ocimage)
+#define old_video_mode		(this->hidden->old_video_mode)
+#define old_refresh_rate		(this->hidden->old_refresh_rate)
+#define graphics_card_caps		(this->hidden->graphics_card_caps)
+#define Pt_GC			(this->hidden->Pt_GC)
+#define Pg_GC			(this->hidden->Pg_GC)
+
+/* Old variable names */
+#define swap_pixels		(this->hidden->swap_pixels)
+#define current_w		(this->hidden->current_w)
+#define current_h		(this->hidden->current_h)
+#define mouse_last		(this->hidden->mouse_last)
+#define mouse_accel		(this->hidden->mouse_accel)
+#define mouse_relative		(this->hidden->mouse_relative)
+#define saved_mode		(this->hidden->saved_mode)
+#define saved_view		(this->hidden->saved_view)
+#define use_vidmode		(this->hidden->use_vidmode)
+#define currently_fullscreen	(this->hidden->currently_fullscreen)
+#define switch_waiting		(this->hidden->switch_waiting)
+#define switch_time		(this->hidden->switch_time)
+#define blit_queued		(this->hidden->blit_queued)
+#define SDL_iconcolorIs		(this->hidden->iconcolors)
+#define event				(this->hidden->event)
+#define SDL_BlankCursor     (this->hidden->BlankCursor)
+
+#endif /* _SDL_x11video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_wm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,363 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <Ph.h>
+#include "SDL_version.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_video.h"
+#include "SDL_syswm.h"
+#include "SDL_events_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_ph_modes_c.h"
+#include "SDL_ph_wm_c.h"
+
+/* This is necessary for working properly with Enlightenment, etc. */
+#define USE_ICON_WINDOW
+
+void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
+{
+
+#if 0 /*big*/
+	int ncolors;
+	PhImage_t *image;
+	PgColor_t* palette;
+
+	image = PhCreateImage( image,
+                          	icon->w,
+                          	icon->h,
+                          	Pg_IMAGE_DIRECT_888,
+                          	NULL, 0, 0 );
+
+/* ---------------------------------------- */
+	SDL_Surface *sicon;
+//	XWMHints *wmhints;
+//	XImage *icon_image;
+//	Pixmap icon_pixmap;
+//	Pixmap mask_pixmap;
+//	GC GC;
+//	XGCValues GCvalues;
+	int i, b, dbpp;
+	SDL_Rect bounds;
+	Uint8 *LSBmask, *color_tried;
+	Visual *dvis;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	/* The icon must use the default visual, depth and colormap of the
+	   screen, so it might need a conversion */
+// ?	dbpp = DefaultDepth(SDL_Display, SDL_Screen);
+	switch(dbpp) {
+	case 15:
+	    dbpp = 16; break;
+	case 24:
+	    dbpp = 32; break;
+	}
+	dvis = DefaultVisual(SDL_Display, SDL_Screen);
+
+	/* The Visual struct is supposed to be opaque but we cheat a little */
+	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
+				     dbpp,
+				     dvis->red_mask, dvis->green_mask,
+				     dvis->blue_mask, 0);
+
+	if ( sicon == NULL ) {
+		goto done;
+	}
+	/* If we already have allocated colours from the default colormap,
+	   copy them */
+	if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap
+	   && this->screen->format->palette && sicon->format->palette) {
+	    memcpy(sicon->format->palette->colors,
+		   this->screen->format->palette->colors,
+		   this->screen->format->palette->ncolors * sizeof(SDL_Color));
+	}
+
+	bounds.x = 0;
+	bounds.y = 0;
+	bounds.w = icon->w;
+	bounds.h = icon->h;
+	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 )
+		goto done;
+
+	/* Lock down the colors used in the colormap */
+	color_tried = NULL;
+	if ( sicon->format->BitsPerPixel == 8 ) {
+		SDL_Palette *palette;
+		Uint8 *p;
+		XColor wanted;
+
+		palette = sicon->format->palette;
+		color_tried = malloc(palette->ncolors);
+		if ( color_tried == NULL ) {
+			goto done;
+		}
+		if ( SDL_iconcolors != NULL ) {
+			free(SDL_iconcolors);
+		}
+		SDL_iconcolors = malloc(palette->ncolors
+					* sizeof(*SDL_iconcolors));
+		if ( SDL_iconcolors == NULL ) {
+			free(color_tried);
+			goto done;
+		}
+		memset(color_tried, 0, palette->ncolors);
+		memset(SDL_iconcolors, 0,
+		       palette->ncolors * sizeof(*SDL_iconcolors));
+
+		p = (Uint8 *)sicon->pixels; 
+		for ( i = sicon->w*sicon->h; i > 0; --i, ++p ) {
+			if ( ! color_tried[*p] ) {
+				wanted.pixel = *p;
+				wanted.red   = (palette->colors[*p].r<<8);
+				wanted.green = (palette->colors[*p].g<<8);
+				wanted.blue  = (palette->colors[*p].b<<8);
+				wanted.flags = (DoRed|DoGreen|DoBlue);
+				if (XAllocColor(SDL_Display,
+						SDL_DisplayColormap, &wanted)) {
+					++SDL_iconcolors[wanted.pixel];
+				}
+				color_tried[*p] = 1;
+			}
+		}
+	}
+	if ( color_tried != NULL ) {
+		free(color_tried);
+	}
+
+	/* Translate mask data to LSB order and set the icon mask */
+	i = (sicon->w/8)*sicon->h;
+	LSBmask = (Uint8 *)malloc(i);
+	if ( LSBmask == NULL ) {
+		goto done;
+	}
+	memset(LSBmask, 0, i);
+	while ( --i >= 0 ) {
+		for ( b=0; b<8; ++b )
+			LSBmask[i] |= (((mask[i]>>b)&0x01)<<(7-b));
+	}
+	mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
+					LSBmask, sicon->w, sicon->h, 1L, 0L, 1);
+
+	/* Transfer the image to an X11 pixmap */
+	icon_image = XCreateImage(SDL_Display,
+			DefaultVisual(SDL_Display, SDL_Screen),
+			DefaultDepth(SDL_Display, SDL_Screen),
+			ZPixmap, 0, (char *)sicon->pixels, sicon->w, sicon->h,
+			((sicon->format)->BytesPerPixel == 3) ? 32 :
+				(sicon->format)->BytesPerPixel*8, 0);
+	icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
+			DefaultDepth(SDL_Display, SDL_Screen));
+	GC = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
+	XPutImage(SDL_Display, icon_pixmap, GC, icon_image,
+					0, 0, 0, 0, sicon->w, sicon->h);
+	XFreeGC(SDL_Display, GC);
+	XDestroyImage(icon_image);
+	free(LSBmask);
+	sicon->pixels = NULL;
+
+#ifdef USE_ICON_WINDOW
+	/* Create an icon window and set the pixmap as its background */
+	icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
+					0, 0, sicon->w, sicon->h, 0,
+					CopyFromParent, CopyFromParent);
+	XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap);
+	XClearWindow(SDL_Display, icon_window);
+#endif
+
+	/* Set the window icon to the icon pixmap (and icon window) */
+	wmhints = XAllocWMHints();
+	wmhints->flags = (IconPixmapHint | IconMaskHint);
+	wmhints->icon_pixmap = icon_pixmap;
+	wmhints->icon_mask = mask_pixmap;
+#ifdef USE_ICON_WINDOW
+	wmhints->flags |= IconWindowHint;
+	wmhints->icon_window = icon_window;
+#endif
+	XSetWMHints(SDL_Display, WMwindow, wmhints);
+	XFree(wmhints);
+	XSync(SDL_Display, False);
+
+  done:
+	SDL_Unlock_EventThread();
+	if ( sicon != NULL ) {
+		SDL_FreeSurface(sicon);
+	}
+	
+#endif /*big*/
+	return;
+}
+
+void ph_SetCaption(_THIS, const char *title, const char *icon)
+{
+
+#if 0
+	XTextProperty titleprop, iconprop;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	if ( title != NULL ) {
+		XStringListToTextProperty((char **)&title, 1, &titleprop);
+		XSetWMName(SDL_Display, WMwindow, &titleprop);
+		XFree(titleprop.value);
+	}
+	if ( icon != NULL ) {
+		XStringListToTextProperty((char **)&icon, 1, &iconprop);
+		XSetWMIconName(SDL_Display, WMwindow, &iconprop);
+		XFree(iconprop.value);
+	}
+	XSync(SDL_Display, False);
+
+	SDL_Unlock_EventThread();
+#endif
+}
+
+/* Iconify the window */
+int ph_IconifyWindow(_THIS)
+{
+	int result;
+	
+#if 0
+	SDL_Lock_EventThread();
+	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+#endif
+	return(result);
+}
+
+SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode)
+{
+#if 0 /*big*/
+	int numtries, result;
+
+	if ( this->screen == NULL ) {
+		return(SDL_GRAB_OFF);
+	}
+	if ( ! SDL_Window ) {
+		return(mode);	/* Will be set later on mode switch */
+	}
+	if ( mode == SDL_GRAB_OFF ) {
+		XUngrabPointer(SDL_Display, CurrentTime);
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Rebind the mouse to the fullscreen window */
+			for ( numtries = 0; numtries < 10; ++numtries ) {
+				result = XGrabPointer(SDL_Display, FSwindow,
+						True, 0,
+						GrabModeAsync, GrabModeAsync,
+						FSwindow, None, CurrentTime);
+				if ( result == AlreadyGrabbed ) {
+					break;
+				}
+				SDL_Delay(100);
+			}
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XUngrabKeyboard(SDL_Display, CurrentTime);
+	} else {
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Unbind the mouse from the fullscreen window */
+			XUngrabPointer(SDL_Display, CurrentTime);
+		}
+		/* Try to grab the mouse */
+		for ( numtries = 0; numtries < 10; ++numtries ) {
+			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
+						GrabModeAsync, GrabModeAsync,
+						SDL_Window, None, CurrentTime);
+			if ( result != AlreadyGrabbed ) {
+				break;
+			}
+			SDL_Delay(100);
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XGrabKeyboard(SDL_Display, WMwindow, True,
+			GrabModeAsync, GrabModeAsync, CurrentTime);
+	}
+	XSync(SDL_Display, False);
+
+
+#endif /*big*/
+	return(mode);
+}
+
+SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode)
+{
+#if 0
+	SDL_Lock_EventThread();
+	mode = X11_GrabInputNoLock(this, mode);
+	SDL_Unlock_EventThread();
+#endif
+	return(mode);
+}
+
+/* If 'info' is the right version, this function fills it and returns 1.
+   Otherwise, in case of a version mismatch, it returns -1.
+*/
+static void lock_display(void)
+{
+	SDL_Lock_EventThread();
+}
+static void unlock_display(void)
+{
+#if 0
+	/* Make sure any X11 transactions are completed */
+	SDL_VideoDevice *this = current_video;
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+#endif
+}
+int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info)
+{
+#if 0
+	if ( info->version.major <= SDL_MAJOR_VERSION ) {
+		info->subsystem = SDL_SYSWM_X11;
+		info->info.x11.display = SDL_Display;
+		info->info.x11.window = SDL_Window;
+		if ( SDL_VERSIONNUM(info->version.major,
+		                    info->version.minor,
+		                    info->version.patch) >= 1002 ) {
+			info->info.x11.fswindow = FSwindow;
+			info->info.x11.wmwindow = WMwindow;
+		}
+		info->info.x11.lock_func = lock_display;
+		info->info.x11.unlock_func = unlock_display;
+		return(1);
+	} else {
+		SDL_SetError("Application not compiled with SDL %d.%d\n",
+					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+		return(-1);
+	}
+#endif
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_ph_wm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_ph_video.h"
+
+/* Functions to be exported */
+extern void ph_SetCaption(_THIS, const char *title, const char *icon);
+extern void ph_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
+extern int ph_IconifyWindow(_THIS);
+extern SDL_GrabMode ph_GrabInputNoLock(_THIS, SDL_GrabMode mode);
+extern SDL_GrabMode ph_GrabInput(_THIS, SDL_GrabMode mode);
+extern int ph_GetWMInfo(_THIS, SDL_SysWMinfo *info);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_phyuv.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,659 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the QNX Realtime Platform version for SDL YUV video overlays */
+
+#include <stdlib.h>
+#include <string.h>
+//#include <ncurses.h> //only for bool
+#ifndef bool
+#define bool char
+#define TRUE 1
+#define FALSE 0
+#endif
+#include <errno.h>
+
+#include <Ph.h>
+#include <Pt.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_phyuv_c.h"
+#include "SDL_yuvfuncs.h"
+
+#if 0  //just for reference
+/* YUV data formats			FourCC		   Layout		H sample (YUV)	V sample (YUV)	BPP */
+#define Pg_VIDEO_FORMAT_IYU1		0x31555949	/* U2Y2Y2V2Y2Y2		144		111		12  */
+#define Pg_VIDEO_FORMAT_IYU2		0x32555949	/* U4Y4V4U4Y4V4		111		111		24  */
+#define Pg_VIDEO_FORMAT_UYVY		0x59565955	/* U8Y8V8Y8		122		111		16  */
+#define Pg_VIDEO_FORMAT_YUY2		0x32595559	/* Y8U8Y8V8		122		111		16  */
+#define Pg_VIDEO_FORMAT_YVYU		0x55595659	/* Y8V8Y8U8		122		111		16  */
+#define Pg_VIDEO_FORMAT_V422		0x56343232	/* V8Y8U8Y8		122		111		16  */
+#define Pg_VIDEO_FORMAT_CLJR		0x524a4c43	/* V6U6Y5Y5Y5Y5		133		111		8   */
+#define Pg_VIDEO_FORMAT_YVU9		0x39555659	/* Planar YVU		144		144		9   */
+#define Pg_VIDEO_FORMAT_YV12		0x32315659	/* Planar YUV		122		122		12  */
+
+/* There seems to be no FourCC that matches this */
+#define Pg_VIDEO_FORMAT_YUV420		0x00000100	/* Planar YUV		122		111		16  */
+
+/* These formats are the same as YV12, except the U and V planes do not have to contiguously follow the Y plane */
+/* but they're all the same to us, since we always have 3 plane pointers */
+#define Pg_VIDEO_FORMAT_CLPL	Pg_VIDEO_FORMAT_YV12	/* Cirrus Logic Planar format */
+#define Pg_VIDEO_FORMAT_VBPL	Pg_VIDEO_FORMAT_YV12	/* VooDoo Banshee planar format */
+
+#define SDL_YV12_OVERLAY	0x32315659	/* Planar mode: Y + V + U */
+#define SDL_IYUV_OVERLAY	0x56555949	/* Planar mode: Y + U + V */
+#define SDL_YUY2_OVERLAY	0x32595559	/* Packed mode: Y0+U0+Y1+V0 */
+#define SDL_UYVY_OVERLAY	0x59565955	/* Packed mode: U0+Y0+V0+Y1 */
+#define SDL_YVYU_OVERLAY	0x55595659	/* Packed mode: Y0+V0+Y1+U0 */
+
+#endif 
+
+
+#define OVERLAY_STATE_UNINIT  0
+#define OVERLAY_STATE_ACTIVE 1
+
+/* The functions used to manipulate software video overlays */
+static struct private_yuvhwfuncs ph_yuvfuncs = {
+	ph_LockYUVOverlay,
+	ph_UnlockYUVOverlay,
+	ph_DisplayYUVOverlay,
+	ph_FreeYUVOverlay
+};
+
+
+typedef struct {
+  int id;
+  int width, height;
+  int data_size;              /* bytes */
+  int num_planes;
+  int *pitches;               /* bytes */
+  int *offsets;               /* bytes */
+  char *data;
+  void *obdata;     
+} XvImage;
+
+
+struct private_yuvhwdata {
+	XvImage *image;	
+	FRAMEDATA *CurrentFrameData;
+	FRAMEDATA *FrameData0;
+	FRAMEDATA *FrameData1;
+	PgScalerProps_t	props;
+	PgScalerCaps_t		caps;
+	PgVideoChannel_t *channel;
+	SDL_Rect CurrentWindow;
+	long format;
+	int screen_width;
+	int screen_height ;
+	int screen_bpp ;    //2
+	bool planar;
+	bool scaler_on ;
+	int current;
+	long YStride;
+	long VStride;
+	long UStride;
+	long chromakey;
+	unsigned long State;
+	long flags;
+};
+
+extern PgVideoChannel_t * PgCreateVideoChannel(unsigned type, unsigned flags);
+extern int PgGetScalerCapabilities( PgVideoChannel_t *channel, int format_index, PgScalerCaps_t *vcaps );
+extern int PgConfigScalerChannel(PgVideoChannel_t *channel, PgScalerProps_t *props);
+extern void PgDestroyVideoChannel(PgVideoChannel_t *channel);
+extern PgColor_t PgGetOverlayChromaColor(void);
+
+void
+grab_ptrs2(PgVideoChannel_t *channel, FRAMEDATA *Frame0, FRAMEDATA *Frame1 )
+{
+
+	/* Buffers have moved; re-obtain the pointers */
+	Frame0->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane1);
+	Frame1->Y = (unsigned char *)PdGetOffscreenContextPtr(channel->yplane2);
+	Frame0->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane1);
+	Frame1->U = (unsigned char *)PdGetOffscreenContextPtr(channel->uplane2);
+	Frame0->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane1);
+	Frame1->V = (unsigned char *)PdGetOffscreenContextPtr(channel->vplane2);
+
+}
+
+SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
+{
+	SDL_Overlay *overlay;
+	struct private_yuvhwdata *hwdata;
+	int xv_port;
+	int rtncode;
+//	PhRect_t rect;
+//	PhSysInfo_t info;
+//	PhRegion_t region;
+//	short x, y;
+	PtArg_t argt;
+	int i =0;
+//	bool bCont = TRUE;
+	int Priority[20];
+	int Type[20];
+	int entries, select, highest;
+
+	PhDCSetCurrent(0);  //Need to set draw context to window esp. if we we in Offscreeen mode
+
+	/* Create the overlay structure */
+	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
+	if ( overlay == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(overlay, 0, (sizeof *overlay));
+
+	/* Fill in the basic members */
+	overlay->format = format;
+	overlay->w = width;
+	overlay->h = height;
+	
+	/* Set up the YUV surface function structure */
+	overlay->hwfuncs = &ph_yuvfuncs;
+
+	/* Create the pixel data and lookup tables */
+	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
+	overlay->hwdata = hwdata;
+	if ( hwdata == NULL ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	
+		if (overlay->hwdata->channel == NULL)
+	{
+	
+  
+		if ((overlay->hwdata->channel = PgCreateVideoChannel(Pg_VIDEO_CHANNEL_SCALER,0)) == NULL) 
+		{
+			SDL_SetError("Create channel failed:%s\n", strerror( errno ));
+			free(overlay->hwdata);
+			free(overlay);
+			return(NULL);
+		}
+#if 0
+		overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps);
+		PgGetScalerCapabilities(overlay->hwdata->channel, 0, &(overlay->hwdata->caps));
+		if (overlay->hwdata->caps.flags & Pg_SCALER_CAP_DOUBLE_BUFFER)
+			overlay->hwdata->props.flags |= Pg_SCALER_PROP_DOUBLE_BUFFER;
+#endif	
+	}
+
+overlay->hwdata->CurrentWindow.x = 0;
+overlay->hwdata->CurrentWindow.y = 0;
+overlay->hwdata->CurrentWindow.w = 320;
+overlay->hwdata->CurrentWindow.h = 240;
+
+
+
+overlay->hwdata->State = OVERLAY_STATE_UNINIT;
+
+overlay->hwdata->screen_bpp = 2;
+overlay->hwdata->scaler_on = FALSE;
+
+overlay->hwdata->screen_width = 1024;
+overlay->hwdata->screen_height  = 768;
+
+overlay->hwdata->FrameData0 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
+overlay->hwdata->FrameData1 = (FRAMEDATA *) malloc((size_t)(sizeof( FRAMEDATA)));
+
+overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
+
+
+//Note you really don't need to do this for SDL as you are given a format, but this is a good example
+
+xv_port = -1;
+i=0;
+	
+while(PgGetScalerCapabilities(overlay->hwdata->channel, i++, &(overlay->hwdata->caps)) == 0) 
+{
+
+		if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YV12) //in SDL
+		{
+			
+			Priority[i-1] = 0;
+			Type[i-1] = Pg_VIDEO_FORMAT_YV12;
+			if(format == Pg_VIDEO_FORMAT_YV12)
+			{
+				overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YV12;
+				xv_port = 1; //supported
+				Priority[i-1] = 100; //force selected
+			}
+			
+		}
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YVU9) //in SDL
+		{
+			
+			Priority[i-1] = 0;
+			Type[i-1] = Pg_VIDEO_FORMAT_YVU9;			
+			if(format == Pg_VIDEO_FORMAT_YVU9)
+			{
+				overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YVU9;
+				xv_port = 1; //supported
+				Priority[i-1] = 100; //force selected
+			}
+			
+		}
+#if 0 //this part of SDL is YUV specific
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_RGB555)
+		{
+			
+			Priority[i-1] = 3;
+			Type[i-1] = Pg_VIDEO_FORMAT_RGB555;			
+		}
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_RGB565)
+		{
+			
+			Priority[i-1] =  2;
+			Type[i-1] = Pg_VIDEO_FORMAT_RGB565;			
+		}
+		else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_RGB8888)
+		{
+			
+			Priority[i-1] = 1;
+			Type[i-1] = Pg_VIDEO_FORMAT_RGB8888;			
+		}
+#endif
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_IYU1)
+		{
+			
+			Priority[i-1] = 0;
+			Type[i-1] = Pg_VIDEO_FORMAT_IYU1;
+			
+		}
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_IYU2)
+		{
+			
+			Priority[i-1] = 0;
+			Type[i-1] = Pg_VIDEO_FORMAT_IYU2;			
+		}
+
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_UYVY) //in SDL
+		{
+			
+			Priority[i-1] = 7;
+			Type[i-1] = Pg_VIDEO_FORMAT_UYVY;
+			if(format == Pg_VIDEO_FORMAT_UYVY)
+			{
+				overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_UYVY;
+				xv_port = 1; //supported
+				Priority[i-1] = 100; //force selected
+			}
+			
+		}
+		else if(overlay->hwdata->caps.format == Pg_VIDEO_FORMAT_YUY2) //in SDL
+		{
+			
+			Priority[i-1] = 8;
+			Type[i-1] = Pg_VIDEO_FORMAT_YUY2;			
+			if(format == Pg_VIDEO_FORMAT_YUY2)
+			{
+				overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YUY2;
+				xv_port = 1; //supported
+				Priority[i-1] = 100; //force selected
+			}
+			
+		}
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_YVYU) //in SDL
+		{
+			
+			Priority[i-1] = 4;
+			Type[i-1] = Pg_VIDEO_FORMAT_YVYU;	
+			
+			if(format == Pg_VIDEO_FORMAT_YVYU)
+			{
+				overlay->hwdata->props.format =  Pg_VIDEO_FORMAT_YVYU;
+				xv_port = 1; //supported
+				Priority[i-1] = 100; //force selected
+				
+			}
+		
+		}
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_V422)
+		{
+			
+			Priority[i-1] = 5;
+			Type[i-1] = Pg_VIDEO_FORMAT_V422;			
+		}		
+		else if(overlay->hwdata->caps.format  == Pg_VIDEO_FORMAT_CLJR)
+		{
+			
+			Priority[i-1] = 6;
+			Type[i-1] = Pg_VIDEO_FORMAT_CLJR;		
+		}	
+		else
+		{
+		
+		Priority[i-1] = 0;
+		}
+			
+overlay->hwdata->caps.size = sizeof(overlay->hwdata->caps);
+}
+
+	if ( xv_port == -1 )
+	{
+		SDL_SetError("No available video ports for requested format");
+		return(NULL);
+	}
+ 
+//Pick the highest priority format
+entries = i -2;
+highest = Priority[0]; //make first entry top at begining
+select = 0;
+
+for (i = 1; i < entries; i++)
+{
+
+
+   if(Priority[i] > highest)
+   {
+      highest = Priority[i];
+      select  = i;
+   }
+} 
+
+ 
+ 
+ overlay->hwdata->caps.size = sizeof (overlay->hwdata->caps	);
+PgGetScalerCapabilities(overlay->hwdata->channel, select, &(overlay->hwdata->caps));
+overlay->hwdata->props.format = overlay->hwdata->caps.format ;
+
+    overlay->hwdata->format = overlay->hwdata->props.format;  //to make easier for apps to use
+
+
+	overlay->hwdata->props.size = sizeof (overlay->hwdata->props);
+    overlay->hwdata->props.src_dim.w = width;   
+    overlay->hwdata->props.src_dim.h = height;   
+	
+	overlay->hwdata->chromakey = PgGetOverlayChromaColor();
+
+	// Set chromakey in video widget so we can see overlay data
+	/* I don't know where the container widget is!!!, I guess it is in hidden->window*/
+	
+	PtEnter(0);
+	PtSetArg( &argt, Pt_ARG_FILL_COLOR, overlay->hwdata->chromakey, 0 );
+	PtSetResources( window, 1, &argt ); 
+	PtLeave(0);
+
+
+	fflush( stderr );
+
+	overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
+	overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
+	//Next line MIGHT have x and y reversed!!!!!!!!!!!!
+	overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
+	overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
+		
+
+
+	overlay->hwdata->props.flags =
+	    ~Pg_SCALER_PROP_SCALER_ENABLE | Pg_SCALER_PROP_DOUBLE_BUFFER ;
+
+	if (overlay->hwdata->chromakey) {
+		overlay->hwdata->props.flags |= Pg_SCALER_PROP_CHROMA_ENABLE;
+		overlay->hwdata->props.color_key = overlay->hwdata->chromakey;
+		overlay->hwdata->props.color_key_mask = 0xffffff;
+	} 
+	else
+	{
+		overlay->hwdata->props.flags &= ~Pg_SCALER_PROP_CHROMA_ENABLE;
+	}
+
+
+	overlay->hwdata->scaler_on = FALSE;
+
+
+
+ rtncode =    PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));	
+	switch(rtncode)
+	{
+	case -1:
+		SDL_SetError("PgConfigScalerChannel failed\n");
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+   		break;
+	case 1:
+		grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
+		break;
+	case 0:
+	default:
+   		break;
+	}
+
+
+	grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
+
+if(overlay->hwdata->channel->yplane1 != NULL)			
+	overlay->hwdata->YStride = overlay->hwdata->channel->yplane1->pitch;
+if(overlay->hwdata->channel->uplane1 != NULL)			
+	overlay->hwdata->UStride = overlay->hwdata->channel->uplane1->pitch;
+if(overlay->hwdata->channel->vplane1 != NULL)			
+	overlay->hwdata->VStride = overlay->hwdata->channel->vplane1->pitch;
+
+
+	overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
+
+
+
+	if (overlay->hwdata->current == -1)
+	{
+		SDL_SetError("PgNextFrame failed, bailing out\n");
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+        
+        //set current frame for double buffering
+	if(overlay->hwdata->current == 0)
+	{
+		overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
+	}
+	else
+	{
+		overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
+	}
+    
+	overlay->hwdata->State = OVERLAY_STATE_ACTIVE;
+
+
+	/* We're all done.. */
+	return(overlay);
+}
+
+int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+//int rtncode;
+
+if(overlay == NULL)
+   return 0;
+
+//set current frame for double buffering
+	if(overlay->hwdata->current == 0)
+	{
+		overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData0;
+	}
+	else
+	{
+		overlay->hwdata->CurrentFrameData = overlay->hwdata->FrameData1;
+	}
+
+	//Lock gets the pointer and passes it to the app. The app writes all yuv data into overlay->pixels
+//Note this is defined as Uint8 **pixels;				/* Read-write */	
+	overlay->pixels = &overlay->hwdata->CurrentFrameData->Y; 
+	overlay->pitches  = &overlay->hwdata->YStride;
+		
+	return(0);
+}
+
+void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+int rtncode;
+
+if(overlay == NULL)
+   return ;
+
+		if(overlay->hwdata->scaler_on == FALSE) 
+		{
+			
+		
+		overlay->hwdata->props.flags |= Pg_SCALER_PROP_SCALER_ENABLE;
+        rtncode =PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
+        	switch(rtncode)
+			{
+				case -1:
+					SDL_SetError("PgConfigScalerChannel failed\n");
+					SDL_FreeYUVOverlay(overlay);
+   					break;
+				case 1:
+					grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
+					overlay->hwdata->scaler_on = TRUE;
+					break;
+				case 0:
+					default:
+					overlay->hwdata->scaler_on = TRUE;
+   					break;
+			}
+//This would be the best place to draw chromakey but we do not have a SDL_Surface in the args
+//This means we might see a chromakey flicker at startup
+		}
+		overlay->hwdata->current = PgNextVideoFrame(overlay->hwdata->channel);
+
+
+	if (overlay->hwdata->current == -1) {
+		SDL_SetError("PgNextVideoFrame failed\n");
+		SDL_FreeYUVOverlay(overlay);	
+		return;	
+	}
+
+	overlay->pixels = NULL;
+}
+
+int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
+{
+int rtncode;
+
+if(overlay == NULL)
+   return 0;
+
+
+	/*SDL_Rect CurrentWindow*/
+//If CurrentWindow has change, move the viewport
+if((overlay->hwdata->CurrentWindow.x != dstrect->x) ||
+  (overlay->hwdata->CurrentWindow.y != dstrect->y) ||
+  (overlay->hwdata->CurrentWindow.w != dstrect->w) ||
+  (overlay->hwdata->CurrentWindow.h != dstrect->h))
+{
+		if(overlay->hwdata->State == OVERLAY_STATE_UNINIT)
+		return -1;
+
+	overlay->hwdata->CurrentWindow.x = dstrect->x;
+  	overlay->hwdata->CurrentWindow.y = dstrect->y;
+  	overlay->hwdata->CurrentWindow.w = dstrect->w;
+  	overlay->hwdata->CurrentWindow.h = dstrect->h;
+
+	overlay->hwdata->props.viewport.ul.x = overlay->hwdata->CurrentWindow.x;
+	overlay->hwdata->props.viewport.ul.y = overlay->hwdata->CurrentWindow.y;
+	//Next line MIGHT have x and y reversed!!!!!!!!!!!!
+	overlay->hwdata->props.viewport.lr.x = overlay->hwdata->CurrentWindow.x +overlay->hwdata->CurrentWindow.w;
+	overlay->hwdata->props.viewport.lr.y = overlay->hwdata->CurrentWindow.y + overlay->hwdata->CurrentWindow.h;
+
+	
+     rtncode = PgConfigScalerChannel(overlay->hwdata->channel, &(overlay->hwdata->props));
+
+	switch(rtncode)
+	{
+	case -1:
+		SDL_SetError("PgConfigScalerChannel failed\n");
+		SDL_FreeYUVOverlay(overlay);
+		return(0);
+   		break;
+	case 1:
+		grab_ptrs2(overlay->hwdata->channel, overlay->hwdata->FrameData0, overlay->hwdata->FrameData1);
+		break;
+	case 0:
+	default:
+   		break;
+	}
+}
+
+
+//JB the X11 file did this. We do this in SDL_unlock, we need to confirm that lock and unlock are called for each frame!
+//	XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
+//	              hwdata->image, 0, 0, overlay->w, overlay->h,
+//	              dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);	           
+/*  This is what this call is
+int XvShmPutImage (
+   Display *dpy,
+   XvPortID port,
+   Drawable d,
+   GC gc,
+   XvImage *image,
+   int src_x,
+   int src_y,
+   unsigned int src_w,
+   unsigned int src_h,
+   int dest_x, 
+   int dest_y,
+   unsigned int dest_w,
+   unsigned int dest_h,
+   Bool send_event
+)
+*/
+
+	return(0);
+}
+
+void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	//struct private_yuvhwdata *hwdata;
+
+	if(overlay == NULL)
+		return;
+	
+	if(overlay->hwdata == NULL)
+		return;
+	
+	overlay->hwdata->State = OVERLAY_STATE_UNINIT;
+
+	if( overlay->hwdata->channel == NULL )
+	{
+		return;
+	}	
+
+	PgDestroyVideoChannel(overlay->hwdata->channel);
+
+	overlay->hwdata->channel = NULL;
+	overlay->hwdata->CurrentFrameData = NULL;  
+	
+	free(overlay->hwdata->FrameData0);
+	free(overlay->hwdata->FrameData1);
+	overlay->hwdata->FrameData0 = NULL;
+	overlay->hwdata->FrameData1 = NULL;
+	free(overlay->hwdata);
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/photon/SDL_phyuv_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the XFree86 Xv extension implementation of YUV video overlays */
+
+#include "SDL_video.h"
+#include "SDL_ph_video.h"
+
+extern SDL_Overlay *ph_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
+
+extern int ph_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern void ph_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern int ph_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
+
+extern void ph_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the SVGAlib video driver
+
+noinst_LTLIBRARIES = libvideo_svga.la
+libvideo_svga_la_SOURCES = $(SVGA_SRCS)
+
+# The SDL SVGAlib video driver sources
+SVGA_SRCS = 			\
+	SDL_svgavideo.h		\
+	SDL_svgaevents.c	\
+	SDL_svgaevents_c.h	\
+	SDL_svgamouse.c		\
+	SDL_svgamouse_c.h	\
+	SDL_svgavideo.c
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgaevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,419 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting X11 events into SDL events */
+
+#include <stdio.h>
+
+#include <vga.h>
+#include <vgamouse.h>
+#include <vgakeyboard.h>
+#if defined(linux)
+#include <linux/kd.h>
+#include <linux/keyboard.h>
+#elif defined(__FreeBSD__)
+#include <sys/kbio.h>
+#else
+#error You must choose your operating system here
+#endif
+
+#include "SDL.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_svgavideo.h"
+#include "SDL_svgaevents_c.h"
+
+/* The translation tables from a console scancode to a SDL keysym */
+#if defined(linux)
+#define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
+static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
+#elif defined(__FreeBSD__)
+/* FIXME: Free the keymap when we shut down the video mode */
+static keymap_t *vga_keymap = NULL;
+#else
+#error You must choose your operating system here
+#endif
+static SDLKey keymap[128];
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+/* Ugh, we have to duplicate the kernel's keysym mapping code...
+   Oh, it's not so bad. :-)
+
+   FIXME: Add keyboard LED handling code
+ */
+#if defined(linux)
+int SVGA_initkeymaps(int fd)
+{
+	struct kbentry entry;
+	int map, i;
+
+	/* Load all the keysym mappings */
+	for ( map=0; map<NUM_VGAKEYMAPS; ++map ) {
+		memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16));
+		for ( i=0; i<NR_KEYS; ++i ) {
+			entry.kb_table = map;
+			entry.kb_index = i;
+			if ( ioctl(fd, KDGKBENT, &entry) == 0 ) {
+				/* The "Enter" key is a special case */
+				if ( entry.kb_value == K_ENTER ) {
+					entry.kb_value = K(KT_ASCII,13);
+				}
+				/* Handle numpad specially as well */
+				if ( KTYP(entry.kb_value) == KT_PAD ) {
+				    switch ( entry.kb_value ) {
+					case K_P0:
+					case K_P1:
+					case K_P2:
+					case K_P3:
+					case K_P4:
+					case K_P5:
+					case K_P6:
+					case K_P7:
+					case K_P8:
+					case K_P9:
+					    vga_keymap[map][i]=entry.kb_value;
+					    vga_keymap[map][i]+= '0';
+					    break;
+                                        case K_PPLUS:
+					    vga_keymap[map][i]=K(KT_ASCII,'+');
+					    break;
+                                        case K_PMINUS:
+					    vga_keymap[map][i]=K(KT_ASCII,'-');
+					    break;
+                                        case K_PSTAR:
+					    vga_keymap[map][i]=K(KT_ASCII,'*');
+					    break;
+                                        case K_PSLASH:
+					    vga_keymap[map][i]=K(KT_ASCII,'/');
+					    break;
+                                        case K_PENTER:
+					    vga_keymap[map][i]=K(KT_ASCII,'\r');
+					    break;
+                                        case K_PCOMMA:
+					    vga_keymap[map][i]=K(KT_ASCII,',');
+					    break;
+                                        case K_PDOT:
+					    vga_keymap[map][i]=K(KT_ASCII,'.');
+					    break;
+					default:
+					    break;
+				    }
+				}
+				/* Do the normal key translation */
+				if ( (KTYP(entry.kb_value) == KT_LATIN) ||
+				     (KTYP(entry.kb_value) == KT_ASCII) ||
+				     (KTYP(entry.kb_value) == KT_LETTER) ) {
+					vga_keymap[map][i] = entry.kb_value;
+				}
+			}
+		}
+	}
+	return(0);
+}
+#elif defined(__FreeBSD__)
+int SVGA_initkeymaps(int fd)
+{
+	vga_keymap = malloc(sizeof(keymap_t));
+	if ( ! vga_keymap ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	if (ioctl(fd, GIO_KEYMAP, vga_keymap) == -1) {
+		free(vga_keymap);
+		vga_keymap = NULL;
+		SDL_SetError("Unable to get keyboard map");
+		return(-1);
+	}
+	return(0);
+}
+#else
+#error You must choose your operating system here
+#endif
+
+int posted = 0;
+
+void SVGA_mousecallback(int button, int dx, int dy,
+                          int u1,int u2,int u3, int u4)
+{
+	if ( dx || dy ) {
+		posted += SDL_PrivateMouseMotion(0, 1, dx, dy);
+	}
+	if ( button & MOUSE_LEFTBUTTON ) {
+		if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) {
+			posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
+		}
+	} else {
+		if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(1)) ) {
+			posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
+		}
+	}
+	if ( button & MOUSE_MIDDLEBUTTON ) {
+		if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) {
+			posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0);
+		}
+	} else {
+		if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(2)) ) {
+			posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0);
+		}
+	}
+	if ( button & MOUSE_RIGHTBUTTON ) {
+		if ( !(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) {
+			posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
+		}
+	} else {
+		if ( (SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(3)) ) {
+			posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
+		}
+	}
+}
+
+void SVGA_keyboardcallback(int scancode, int pressed)
+{
+	SDL_keysym keysym;
+
+	if ( pressed ) {
+		posted += SDL_PrivateKeyboard(SDL_PRESSED,
+			    TranslateKey(scancode, &keysym));
+	} else {
+		posted += SDL_PrivateKeyboard(SDL_RELEASED,
+			    TranslateKey(scancode, &keysym));
+	}
+}
+
+void SVGA_PumpEvents(_THIS)
+{
+	do {
+		posted = 0;
+		mouse_update();
+		keyboard_update();
+	} while ( posted );
+}
+
+void SVGA_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Initialize the BeOS key translation table */
+	for ( i=0; i<SDL_TABLESIZE(keymap); ++i )
+		keymap[i] = SDLK_UNKNOWN;
+
+	keymap[SCANCODE_ESCAPE] = SDLK_ESCAPE;
+	keymap[SCANCODE_1] = SDLK_1;
+	keymap[SCANCODE_2] = SDLK_2;
+	keymap[SCANCODE_3] = SDLK_3;
+	keymap[SCANCODE_4] = SDLK_4;
+	keymap[SCANCODE_5] = SDLK_5;
+	keymap[SCANCODE_6] = SDLK_6;
+	keymap[SCANCODE_7] = SDLK_7;
+	keymap[SCANCODE_8] = SDLK_8;
+	keymap[SCANCODE_9] = SDLK_9;
+	keymap[SCANCODE_0] = SDLK_0;
+	keymap[SCANCODE_MINUS] = SDLK_MINUS;
+	keymap[SCANCODE_EQUAL] = SDLK_EQUALS;
+	keymap[SCANCODE_BACKSPACE] = SDLK_BACKSPACE;
+	keymap[SCANCODE_TAB] = SDLK_TAB;
+	keymap[SCANCODE_Q] = SDLK_q;
+	keymap[SCANCODE_W] = SDLK_w;
+	keymap[SCANCODE_E] = SDLK_e;
+	keymap[SCANCODE_R] = SDLK_r;
+	keymap[SCANCODE_T] = SDLK_t;
+	keymap[SCANCODE_Y] = SDLK_y;
+	keymap[SCANCODE_U] = SDLK_u;
+	keymap[SCANCODE_I] = SDLK_i;
+	keymap[SCANCODE_O] = SDLK_o;
+	keymap[SCANCODE_P] = SDLK_p;
+	keymap[SCANCODE_BRACKET_LEFT] = SDLK_LEFTBRACKET;
+	keymap[SCANCODE_BRACKET_RIGHT] = SDLK_RIGHTBRACKET;
+	keymap[SCANCODE_ENTER] = SDLK_RETURN;
+	keymap[SCANCODE_LEFTCONTROL] = SDLK_LCTRL;
+	keymap[SCANCODE_A] = SDLK_a;
+	keymap[SCANCODE_S] = SDLK_s;
+	keymap[SCANCODE_D] = SDLK_d;
+	keymap[SCANCODE_F] = SDLK_f;
+	keymap[SCANCODE_G] = SDLK_g;
+	keymap[SCANCODE_H] = SDLK_h;
+	keymap[SCANCODE_J] = SDLK_j;
+	keymap[SCANCODE_K] = SDLK_k;
+	keymap[SCANCODE_L] = SDLK_l;
+	keymap[SCANCODE_SEMICOLON] = SDLK_SEMICOLON;
+	keymap[SCANCODE_APOSTROPHE] = SDLK_QUOTE;
+	keymap[SCANCODE_GRAVE] = SDLK_BACKQUOTE;
+	keymap[SCANCODE_LEFTSHIFT] = SDLK_LSHIFT;
+	keymap[SCANCODE_BACKSLASH] = SDLK_BACKSLASH;
+	keymap[SCANCODE_Z] = SDLK_z;
+	keymap[SCANCODE_X] = SDLK_x;
+	keymap[SCANCODE_C] = SDLK_c;
+	keymap[SCANCODE_V] = SDLK_v;
+	keymap[SCANCODE_B] = SDLK_b;
+	keymap[SCANCODE_N] = SDLK_n;
+	keymap[SCANCODE_M] = SDLK_m;
+	keymap[SCANCODE_COMMA] = SDLK_COMMA;
+	keymap[SCANCODE_PERIOD] = SDLK_PERIOD;
+	keymap[SCANCODE_SLASH] = SDLK_SLASH;
+	keymap[SCANCODE_RIGHTSHIFT] = SDLK_RSHIFT;
+	keymap[SCANCODE_KEYPADMULTIPLY] = SDLK_KP_MULTIPLY;
+	keymap[SCANCODE_LEFTALT] = SDLK_LALT;
+	keymap[SCANCODE_SPACE] = SDLK_SPACE;
+	keymap[SCANCODE_CAPSLOCK] = SDLK_CAPSLOCK;
+	keymap[SCANCODE_F1] = SDLK_F1;
+	keymap[SCANCODE_F2] = SDLK_F2;
+	keymap[SCANCODE_F3] = SDLK_F3;
+	keymap[SCANCODE_F4] = SDLK_F4;
+	keymap[SCANCODE_F5] = SDLK_F5;
+	keymap[SCANCODE_F6] = SDLK_F6;
+	keymap[SCANCODE_F7] = SDLK_F7;
+	keymap[SCANCODE_F8] = SDLK_F8;
+	keymap[SCANCODE_F9] = SDLK_F9;
+	keymap[SCANCODE_F10] = SDLK_F10;
+	keymap[SCANCODE_NUMLOCK] = SDLK_NUMLOCK;
+	keymap[SCANCODE_SCROLLLOCK] = SDLK_SCROLLOCK;
+	keymap[SCANCODE_KEYPAD7] = SDLK_KP7;
+	keymap[SCANCODE_CURSORUPLEFT] = SDLK_KP7;
+	keymap[SCANCODE_KEYPAD8] = SDLK_KP8;
+	keymap[SCANCODE_CURSORUP] = SDLK_KP8;
+	keymap[SCANCODE_KEYPAD9] = SDLK_KP9;
+	keymap[SCANCODE_CURSORUPRIGHT] = SDLK_KP9;
+	keymap[SCANCODE_KEYPADMINUS] = SDLK_KP_MINUS;
+	keymap[SCANCODE_KEYPAD4] = SDLK_KP4;
+	keymap[SCANCODE_CURSORLEFT] = SDLK_KP4;
+	keymap[SCANCODE_KEYPAD5] = SDLK_KP5;
+	keymap[SCANCODE_KEYPAD6] = SDLK_KP6;
+	keymap[SCANCODE_CURSORRIGHT] = SDLK_KP6;
+	keymap[SCANCODE_KEYPADPLUS] = SDLK_KP_PLUS;
+	keymap[SCANCODE_KEYPAD1] = SDLK_KP1;
+	keymap[SCANCODE_CURSORDOWNLEFT] = SDLK_KP1;
+	keymap[SCANCODE_KEYPAD2] = SDLK_KP2;
+	keymap[SCANCODE_CURSORDOWN] = SDLK_KP2;
+	keymap[SCANCODE_KEYPAD3] = SDLK_KP3;
+	keymap[SCANCODE_CURSORDOWNRIGHT] = SDLK_KP3;
+	keymap[SCANCODE_KEYPAD0] = SDLK_KP0;
+	keymap[SCANCODE_KEYPADPERIOD] = SDLK_KP_PERIOD;
+	keymap[SCANCODE_LESS] = SDLK_LESS;
+	keymap[SCANCODE_F11] = SDLK_F11;
+	keymap[SCANCODE_F12] = SDLK_F12;
+	keymap[SCANCODE_KEYPADENTER] = SDLK_KP_ENTER;
+	keymap[SCANCODE_RIGHTCONTROL] = SDLK_RCTRL;
+	keymap[SCANCODE_CONTROL] = SDLK_RCTRL;
+	keymap[SCANCODE_KEYPADDIVIDE] = SDLK_KP_DIVIDE;
+	keymap[SCANCODE_PRINTSCREEN] = SDLK_PRINT;
+	keymap[SCANCODE_RIGHTALT] = SDLK_RALT;
+	keymap[SCANCODE_BREAK] = SDLK_BREAK;
+	keymap[SCANCODE_BREAK_ALTERNATIVE] = SDLK_UNKNOWN;
+	keymap[SCANCODE_HOME] = SDLK_HOME;
+	keymap[SCANCODE_CURSORBLOCKUP] = SDLK_UP;
+	keymap[SCANCODE_PAGEUP] = SDLK_PAGEUP;
+	keymap[SCANCODE_CURSORBLOCKLEFT] = SDLK_LEFT;
+	keymap[SCANCODE_CURSORBLOCKRIGHT] = SDLK_RIGHT;
+	keymap[SCANCODE_END] = SDLK_END;
+	keymap[SCANCODE_CURSORBLOCKDOWN] = SDLK_DOWN;
+	keymap[SCANCODE_PAGEDOWN] = SDLK_PAGEDOWN;
+	keymap[SCANCODE_INSERT] = SDLK_INSERT;
+	keymap[SCANCODE_REMOVE] = SDLK_DELETE;
+	keymap[119] = SDLK_PAUSE;
+	keymap[SCANCODE_RIGHTWIN] = SDLK_RSUPER;
+	keymap[SCANCODE_LEFTWIN] = SDLK_LSUPER;
+	keymap[127] = SDLK_MENU;
+}
+
+#if defined(linux)
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->sym = keymap[scancode];
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE ) {
+		int map;
+		SDLMod modstate;
+
+		modstate = SDL_GetModState();
+		map = 0;
+		if ( modstate & KMOD_SHIFT ) {
+			map |= (1<<KG_SHIFT);
+		}
+		if ( modstate & KMOD_CTRL ) {
+			map |= (1<<KG_CTRL);
+		}
+		if ( modstate & KMOD_ALT ) {
+			map |= (1<<KG_ALT);
+		}
+		if ( modstate & KMOD_MODE ) {
+			map |= (1<<KG_ALTGR);
+		}
+		if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) {
+			if ( modstate & KMOD_CAPS ) {
+				map ^= (1<<KG_SHIFT);
+			}
+		}
+		if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) {
+			if ( modstate & KMOD_NUM ) {
+				keysym->unicode=KVAL(vga_keymap[map][scancode]);
+			}
+		} else {
+			keysym->unicode = KVAL(vga_keymap[map][scancode]);
+		}
+	}
+	return(keysym);
+}
+#elif defined(__FreeBSD__)
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+	/* Set the keysym information */
+	keysym->scancode = scancode;
+	keysym->sym = keymap[scancode];
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE && vga_keymap ) {
+		int map;
+		SDLMod modstate;
+
+		modstate = SDL_GetModState();
+		map = 0;
+		if ( modstate & KMOD_SHIFT ) {
+			map += 1;
+		}
+		if ( modstate & KMOD_CTRL ) {
+			map += 2;
+		}
+		if ( modstate & KMOD_ALT ) {
+			map += 4;
+		}
+		if ( !(vga_keymap->key[scancode].spcl & (0x80 >> map)) ) {
+			keysym->unicode = vga_keymap->key[scancode].map[map];
+		}
+
+	}
+	return(keysym);
+}
+#else
+#error You must choose your operating system here
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgaevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_svgavideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern int SVGA_initkeymaps(int fd);
+extern void SVGA_mousecallback(int button, int dx, int dy,
+                                 int u1,int u2,int u3, int u4);
+extern void SVGA_keyboardcallback(int scancode, int pressed);
+
+extern void SVGA_InitOSKeymap(_THIS);
+extern void SVGA_PumpEvents(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgamouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_svgavideo.h"
+#include "SDL_svgamouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	int unused;
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgamouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_svgavideo.h"
+
+/* Functions to be exported */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgavideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,471 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* SVGAlib based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <sys/stat.h>
+
+#if defined(linux)
+#include <linux/vt.h>
+#elif defined(__FreeBSD__)
+#include <sys/consio.h>
+#else
+#error You must choose your operating system here
+#endif
+#include <vga.h>
+#include <vgamouse.h>
+#include <vgakeyboard.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_svgavideo.h"
+#include "SDL_svgaevents_c.h"
+#include "SDL_svgamouse_c.h"
+
+
+/* Initialization/Query functions */
+static int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int SVGA_SetColors(_THIS, int firstcolor, int ncolors,
+			  SDL_Color *colors);
+static void SVGA_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int SVGA_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface);
+static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface);
+static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void SVGA_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* SVGAlib driver bootstrap functions */
+
+static int SVGA_Available(void)
+{
+	/* Check to see if we are root and stdin is a virtual console */
+	int console;
+
+	console = STDIN_FILENO;
+	if ( console >= 0 ) {
+		struct stat sb;
+		struct vt_mode dummy;
+
+		if ( (fstat(console, &sb) < 0) ||
+		     (ioctl(console, VT_GETMODE, &dummy) < 0) ) {
+			console = -1;
+		}
+	}
+	return((geteuid() == 0) && (console >= 0));
+}
+
+static void SVGA_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *SVGA_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( device ) {
+			free(device);
+		}
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+
+	/* Set the function pointers */
+	device->VideoInit = SVGA_VideoInit;
+	device->ListModes = SVGA_ListModes;
+	device->SetVideoMode = SVGA_SetVideoMode;
+	device->SetColors = SVGA_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = SVGA_VideoQuit;
+	device->AllocHWSurface = SVGA_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = SVGA_LockHWSurface;
+	device->UnlockHWSurface = SVGA_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = SVGA_FreeHWSurface;
+	device->SetCaption = NULL;
+	device->SetIcon = NULL;
+	device->IconifyWindow = NULL;
+	device->GrabInput = NULL;
+	device->GetWMInfo = NULL;
+	device->InitOSKeymap = SVGA_InitOSKeymap;
+	device->PumpEvents = SVGA_PumpEvents;
+
+	device->free = SVGA_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap SVGALIB_bootstrap = {
+	"svgalib", "SVGAlib",
+	SVGA_Available, SVGA_CreateDevice
+};
+
+static int SVGA_AddMode(_THIS, int mode, int actually_add, int force)
+{
+	vga_modeinfo *modeinfo;
+
+	modeinfo = vga_getmodeinfo(mode);
+	if ( force || ( modeinfo->flags & CAPABLE_LINEAR ) ) {
+		int i, j;
+
+		i = modeinfo->bytesperpixel-1;
+		if ( actually_add ) {
+			SDL_Rect saved_rect[2];
+			int      saved_mode[2];
+			int b;
+
+			/* Add the mode, sorted largest to smallest */
+			b = 0;
+			j = 0;
+			while ( (SDL_modelist[i][j]->w > modeinfo->width) ||
+			        (SDL_modelist[i][j]->h > modeinfo->height) ) {
+				++j;
+			}
+			/* Skip modes that are already in our list */
+			if ( (SDL_modelist[i][j]->w == modeinfo->width) &&
+			     (SDL_modelist[i][j]->h == modeinfo->height) ) {
+				return(0);
+			}
+			/* Insert the new mode */
+			saved_rect[b] = *SDL_modelist[i][j];
+			saved_mode[b] = SDL_vgamode[i][j];
+			SDL_modelist[i][j]->w = modeinfo->width;
+			SDL_modelist[i][j]->h = modeinfo->height;
+			SDL_vgamode[i][j] = mode;
+			/* Everybody scoot down! */
+			if ( saved_rect[b].w && saved_rect[b].h ) {
+			    for ( ++j; SDL_modelist[i][j]->w; ++j ) {
+				saved_rect[!b] = *SDL_modelist[i][j];
+				saved_mode[!b] = SDL_vgamode[i][j];
+				*SDL_modelist[i][j] = saved_rect[b];
+				SDL_vgamode[i][j] = saved_mode[b];
+				b = !b;
+			    }
+			    *SDL_modelist[i][j] = saved_rect[b];
+			    SDL_vgamode[i][j] = saved_mode[b];
+			}
+		} else {
+			++SDL_nummodes[i];
+		}
+	}
+	return( force || ( modeinfo->flags & CAPABLE_LINEAR ) );
+}
+
+static void SVGA_UpdateVideoInfo(_THIS)
+{
+	vga_modeinfo *modeinfo;
+
+	this->info.wm_available = 0;
+	this->info.hw_available = 1;
+	modeinfo = vga_getmodeinfo(vga_getcurrentmode());
+	this->info.video_mem = (modeinfo->maxpixels/1024);
+	if ( modeinfo->bytesperpixel > 0 ) {
+		this->info.video_mem *= modeinfo->bytesperpixel;
+	}
+	/* FIXME: Add hardware accelerated blit information */
+#if 0
+printf("Hardware accelerated blit: %savailable\n", modeinfo->haveblit ? "" : "not ");
+#endif
+}
+
+int SVGA_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	int keyboard;
+	int i, j;
+	int mode, total_modes;
+
+	/* Initialize all variables that we clean on shutdown */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		SDL_nummodes[i] = 0;
+		SDL_modelist[i] = NULL;
+		SDL_vgamode[i] = NULL;
+	}
+
+	/* Initialize the library */
+	vga_disabledriverreport();
+	if ( vga_init() < 0 ) {
+		SDL_SetError("Unable to initialize SVGAlib");
+		return(-1);
+	}
+	vga_setmode(TEXT);
+
+	/* Enable mouse and keyboard support */
+	vga_setmousesupport(1);
+	keyboard = keyboard_init_return_fd();
+	if ( keyboard < 0 ) {
+		SDL_SetError("Unable to initialize keyboard");
+		return(-1);
+	}
+	if ( SVGA_initkeymaps(keyboard) < 0 ) {
+		return(-1);
+	}
+	keyboard_seteventhandler(SVGA_keyboardcallback);
+
+	/* Determine the screen depth (use default 8-bit depth) */
+	vformat->BitsPerPixel = 8;
+
+	/* Enumerate the available fullscreen modes */
+	total_modes = 0;
+	for ( mode=vga_lastmodenumber(); mode; --mode ) {
+		if ( vga_hasmode(mode) ) {
+			if ( SVGA_AddMode(this, mode, 0, 0) ) {
+				++total_modes;
+			}
+		}
+	}
+	if ( SVGA_AddMode(this, G320x200x256, 0, 1) ) ++total_modes;
+	if ( total_modes == 0 ) {
+		SDL_SetError("No linear video modes available");
+		return(-1);
+	}
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		SDL_vgamode[i] = (int *)malloc(SDL_nummodes[i]*sizeof(int));
+		if ( SDL_vgamode[i] == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		SDL_modelist[i] = (SDL_Rect **)
+				malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
+		if ( SDL_modelist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		for ( j=0; j<SDL_nummodes[i]; ++j ) {
+			SDL_modelist[i][j]=(SDL_Rect *)malloc(sizeof(SDL_Rect));
+			if ( SDL_modelist[i][j] == NULL ) {
+				SDL_OutOfMemory();
+				return(-1);
+			}
+			memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect));
+		}
+		SDL_modelist[i][j] = NULL;
+	}
+	for ( mode=vga_lastmodenumber(); mode; --mode ) {
+		if ( vga_hasmode(mode) ) {
+			SVGA_AddMode(this, mode, 1, 0);
+		}
+	}
+	SVGA_AddMode(this, G320x200x256, 1, 1);
+
+	/* Free extra (duplicated) modes */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		j = 0;
+		while ( SDL_modelist[i][j] && SDL_modelist[i][j]->w ) {
+			j++;
+		}
+		while ( SDL_modelist[i][j] ) {
+			free(SDL_modelist[i][j]);
+			SDL_modelist[i][j] = NULL;
+			j++;
+		}
+	}
+
+	/* Fill in our hardware acceleration capabilities */
+	SVGA_UpdateVideoInfo(this);
+
+	/* We're done! */
+	return(0);
+}
+
+SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
+}
+
+/* Various screen update functions available */
+static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	int mode;
+	int vgamode;
+	vga_modeinfo *modeinfo;
+
+	/* Try to set the requested linear video mode */
+	bpp = (bpp+7)/8-1;
+	for ( mode=0; SDL_modelist[bpp][mode]; ++mode ) {
+		if ( (SDL_modelist[bpp][mode]->w == width) &&
+		     (SDL_modelist[bpp][mode]->h == height) ) {
+			break;
+		}
+	}
+	if ( SDL_modelist[bpp][mode] == NULL ) {
+		SDL_SetError("Couldn't find requested mode in list");
+		return(NULL);
+	}
+	vga_setmode(SDL_vgamode[bpp][mode]);
+	vga_setpage(0);
+
+	vgamode=SDL_vgamode[bpp][mode];
+	if ((vga_setlinearaddressing()<0) && (vgamode!=G320x200x256)) {
+		SDL_SetError("Unable to set linear addressing");
+		return(NULL);
+	}
+	modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]);
+
+	/* Update hardware acceleration info */
+	SVGA_UpdateVideoInfo(this);
+
+	/* Allocate the new pixel format for the screen */
+	bpp = (bpp+1)*8;
+	if ( (bpp == 16) && (modeinfo->colors == 32768) ) {
+		bpp = 15;
+	}
+	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
+		return(NULL);
+	}
+
+	/* Set up the new mode framebuffer */
+	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
+	current->w = width;
+	current->h = height;
+	current->pitch = modeinfo->linewidth;
+	current->pixels = vga_getgraphmem();
+
+	/* Set the blit function */
+	this->UpdateRects = SVGA_DirectUpdate;
+
+	/* Set up the mouse handler again (buggy SVGAlib 1.40) */
+	mouse_seteventhandler(SVGA_mousecallback);
+
+	/* We're done */
+	return(current);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+static int SVGA_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void SVGA_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* We need to wait for vertical retrace on page flipped displays */
+static int SVGA_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		vga_waitretrace();
+	}
+	return(0);
+}
+static void SVGA_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+/* FIXME: How is this done with SVGAlib? */
+static int SVGA_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+
+static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	return;
+}
+
+/* FIXME: Can this be used under SVGAlib? */
+static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	return;
+}
+
+int SVGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+        int i;
+
+	for(i = 0; i < ncolors; i++) {
+	        vga_setpalette(firstcolor + i,
+			       colors[i].r>>2,
+			       colors[i].g>>2,
+			       colors[i].b>>2);
+	}
+	return(1);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+void SVGA_VideoQuit(_THIS)
+{
+	int i, j;
+
+	/* Reset the console video mode */
+	if ( this->screen && (this->screen->w && this->screen->h) ) {
+		vga_setmode(TEXT);
+	}
+	keyboard_close();
+
+	/* Free video mode lists */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_modelist[i] != NULL ) {
+			for ( j=0; SDL_modelist[i][j]; ++j )
+				free(SDL_modelist[i][j]);
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+		if ( SDL_vgamode[i] != NULL ) {
+			free(SDL_vgamode[i]);
+			SDL_vgamode[i] = NULL;
+		}
+	}
+	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
+		/* Direct screen access, no memory buffer */
+		this->screen->pixels = NULL;
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/svga/SDL_svgavideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,49 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_svgavideo_h
+#define _SDL_svgavideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+	int SDL_nummodes[NUM_MODELISTS];
+	SDL_Rect **SDL_modelist[NUM_MODELISTS];
+	int *SDL_vgamode[NUM_MODELISTS];
+};
+/* Old variable names */
+#define SDL_nummodes		(this->hidden->SDL_nummodes)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define SDL_vgamode		(this->hidden->SDL_vgamode)
+
+#endif /* _SDL_svgavideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,17 @@
+
+## Makefile.am for common files used by the SDL Win32 video drivers
+
+noinst_LTLIBRARIES = libvideo_wincommon.la
+libvideo_wincommon_la_SOURCES = $(WINCOMMON_SRCS)
+
+# The SDL Win32 video driver common sources
+WINCOMMON_SRCS =		\
+	SDL_lowvideo.h		\
+	SDL_sysevents.c		\
+	SDL_sysmouse.c		\
+	SDL_sysmouse_c.h	\
+	SDL_syswm.c		\
+	SDL_syswm_c.h		\
+	SDL_wingl.c		\
+	SDL_wingl_c.h		\
+	wmmsg.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_lowvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,84 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_lowvideo_h
+#define _SDL_lowvideo_h
+
+#include <windows.h>
+
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+#define DIRECTX_FULLSCREEN() 						\
+(									\
+	((SDL_VideoSurface->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) && \
+	((SDL_VideoSurface->flags & SDL_OPENGL    ) != SDL_OPENGL    ) && \
+	(strcmp(this->name, "directx") == 0)				\
+)
+
+/* The main window -- and a function to set it for the audio */
+extern const char *SDL_Appname;
+extern HINSTANCE SDL_Instance;
+extern HWND SDL_Window;
+extern const char *SDL_windowid;
+
+/* Variables and functions exported to other parts of the native video
+   subsystem (SDL_sysevents.c)
+*/
+/* Called by windows message loop when system palette is available */
+extern void (*WIN_RealizePalette)(_THIS);
+
+/* Called by windows message loop when the system palette changes */
+extern void (*WIN_PaletteChanged)(_THIS, HWND window);
+
+/* Called by windows message loop when losing or gaining gamma focus */
+extern void (*WIN_SwapGamma)(_THIS);
+
+/* Called by windows message loop when a portion of the screen needs update */
+extern void (*WIN_WinPAINT)(_THIS, HDC hdc);
+
+/* Called by windows message loop when the message isn't handled */
+extern LONG (*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+
+/* The window cursor (from SDL_sysmouse.c) */
+extern HCURSOR SDL_hcursor;
+
+/* The bounds of the window in screen coordinates */
+extern RECT SDL_bounds;
+
+/* Flag -- SDL is performing a resize, rather than the user */
+extern int SDL_resizing;
+
+/* Flag -- the mouse is in relative motion mode */
+extern int mouse_relative;
+
+/* This is really from SDL_dx5audio.c */
+extern void DX5_SoundFocus(HWND window);
+
+#endif /* SDL_lowvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_sysevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,547 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <windows.h>
+
+#include "SDL_getenv.h"
+#include "SDL_events.h"
+#include "SDL_video.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_sysvideo.h"
+#include "SDL_lowvideo.h"
+#include "SDL_syswm_c.h"
+#include "SDL_main.h"
+
+#ifdef WMMSG_DEBUG
+#include "wmmsg.h"
+#endif
+
+#ifdef _WIN32_WCE
+#define NO_GETKEYBOARDSTATE
+#endif
+
+/* The window we use for everything... */
+const char *SDL_Appname = NULL;
+HINSTANCE SDL_Instance = NULL;
+HWND SDL_Window = NULL;
+RECT SDL_bounds = {0, 0, 0, 0};
+int SDL_resizing = 0;
+int mouse_relative = 0;
+int posted = 0;
+
+
+/* Functions called by the message processing function */
+LONG
+(*HandleMessage)(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)=NULL;
+void (*WIN_RealizePalette)(_THIS);
+void (*WIN_PaletteChanged)(_THIS, HWND window);
+void (*WIN_SwapGamma)(_THIS);
+void (*WIN_WinPAINT)(_THIS, HDC hdc);
+
+#ifdef WM_MOUSELEAVE
+/* 
+   Special code to handle mouse leave events - this sucks...
+   http://support.microsoft.com/support/kb/articles/q183/1/07.asp
+
+   TrackMouseEvent() is only available on Win98 and WinNT.
+   _TrackMouseEvent() is available on Win95, but isn't yet in the mingw32
+   development environment, and only works on systems that have had IE 3.0
+   or newer installed on them (which is not the case with the base Win95).
+   Therefore, we implement our own version of _TrackMouseEvent() which
+   uses our own implementation if TrackMouseEvent() is not available.
+*/
+static BOOL (WINAPI *_TrackMouseEvent)(TRACKMOUSEEVENT *ptme) = NULL;
+
+static VOID CALLBACK
+TrackMouseTimerProc(HWND hWnd, UINT uMsg, UINT idEvent, DWORD dwTime)
+{
+	RECT rect;
+	POINT pt;
+
+	GetClientRect(hWnd, &rect);
+	MapWindowPoints(hWnd, NULL, (LPPOINT)&rect, 2);
+	GetCursorPos(&pt);
+	if ( !PtInRect(&rect, pt) || (WindowFromPoint(pt) != hWnd) ) {
+		if ( !KillTimer(hWnd, idEvent) ) {
+			/* Error killing the timer! */
+		}
+		PostMessage(hWnd, WM_MOUSELEAVE, 0, 0);
+	}
+}
+static BOOL WINAPI WIN_TrackMouseEvent(TRACKMOUSEEVENT *ptme)
+{
+	if ( ptme->dwFlags == TME_LEAVE ) {
+		return SetTimer(ptme->hwndTrack, ptme->dwFlags, 100,
+		                (TIMERPROC)TrackMouseTimerProc);
+	}
+	return FALSE;
+}
+#endif /* WM_MOUSELEAVE */
+
+/* Function to retrieve the current keyboard modifiers */
+static void WIN_GetKeyboardState(void)
+{
+#ifndef NO_GETKEYBOARDSTATE
+	SDLMod state;
+	BYTE keyboard[256];
+
+	state = KMOD_NONE;
+	if ( GetKeyboardState(keyboard) ) {
+		if ( keyboard[VK_LSHIFT] & 0x80) {
+			state |= KMOD_LSHIFT;
+		}
+		if ( keyboard[VK_RSHIFT] & 0x80) {
+			state |= KMOD_RSHIFT;
+		}
+		if ( keyboard[VK_LCONTROL] & 0x80) {
+			state |= KMOD_LCTRL;
+		}
+		if ( keyboard[VK_RCONTROL] & 0x80) {
+			state |= KMOD_RCTRL;
+		}
+		if ( keyboard[VK_LMENU] & 0x80) {
+			state |= KMOD_LALT;
+		}
+		if ( keyboard[VK_RMENU] & 0x80) {
+			state |= KMOD_RALT;
+		}
+		if ( keyboard[VK_NUMLOCK] & 0x80) {
+			state |= KMOD_NUM;
+		}
+		if ( keyboard[VK_CAPITAL] & 0x80) {
+			state |= KMOD_CAPS;
+		}
+	}
+	SDL_SetModState(state);
+#endif /* !NO_GETKEYBOARDSTATE */
+}
+
+/* The main Win32 event handler */
+static LONG CALLBACK WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	SDL_VideoDevice *this = current_video;
+	static int mouse_pressed = 0;
+	static int in_window = 0;
+#ifdef WMMSG_DEBUG
+	fprintf(stderr, "Received windows message:  ");
+	if ( msg > MAX_WMMSG ) {
+		fprintf(stderr, "%d", msg);
+	} else {
+		fprintf(stderr, "%s", wmtab[msg]);
+	}
+	fprintf(stderr, " -- 0x%X, 0x%X\n", wParam, lParam);
+#endif
+	switch (msg) {
+
+		case WM_ACTIVATE: {
+			SDL_VideoDevice *this = current_video;
+			BOOL minimized;
+			Uint8 appstate;
+
+			minimized = HIWORD(wParam);
+			if ( !minimized && (LOWORD(wParam) != WA_INACTIVE) ) {
+				/* Gain the following states */
+				appstate = SDL_APPACTIVE|SDL_APPINPUTFOCUS;
+				if ( this->input_grab != SDL_GRAB_OFF ) {
+					WIN_GrabInput(this, SDL_GRAB_ON);
+				}
+				if ( !(SDL_GetAppState()&SDL_APPINPUTFOCUS) ) {
+					WIN_SwapGamma(this);
+				}
+				posted = SDL_PrivateAppActive(1, appstate);
+				WIN_GetKeyboardState();
+			} else {
+				/* Lose the following states */
+				appstate = SDL_APPINPUTFOCUS;
+				if ( minimized ) {
+					appstate |= SDL_APPACTIVE;
+				}
+				if ( this->input_grab != SDL_GRAB_OFF ) {
+					WIN_GrabInput(this, SDL_GRAB_OFF);
+				}
+				if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+					WIN_SwapGamma(this);
+				}
+				posted = SDL_PrivateAppActive(0, appstate);
+			}
+			return(0);
+		}
+		break;
+
+		case WM_MOUSEMOVE: {
+			
+			/* Mouse is handled by DirectInput when fullscreen */
+			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
+				Sint16 x, y;
+
+				/* mouse has entered the window */
+				if ( ! in_window ) {
+#ifdef WM_MOUSELEAVE
+					TRACKMOUSEEVENT tme;
+
+					tme.cbSize = sizeof(tme);
+					tme.dwFlags = TME_LEAVE;
+					tme.hwndTrack = SDL_Window;
+					_TrackMouseEvent(&tme);
+#endif /* WM_MOUSELEAVE */
+					in_window = TRUE;
+
+					posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+				}
+
+				/* mouse has moved within the window */
+				x = LOWORD(lParam);
+				y = HIWORD(lParam);
+				if ( mouse_relative ) {
+					POINT center;
+					center.x = (SDL_VideoSurface->w/2);
+					center.y = (SDL_VideoSurface->h/2);
+					x -= (Sint16)center.x;
+					y -= (Sint16)center.y;
+					if ( x || y ) {
+						ClientToScreen(SDL_Window, &center);
+						SetCursorPos(center.x, center.y);
+						posted = SDL_PrivateMouseMotion(0, 1, x, y);
+					}
+				} else {
+					posted = SDL_PrivateMouseMotion(0, 0, x, y);
+				}
+			}
+		}
+		return(0);
+
+#ifdef WM_MOUSELEAVE
+		case WM_MOUSELEAVE: {
+
+			/* Mouse is handled by DirectInput when fullscreen */
+			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
+				/* mouse has left the window */
+				/* or */
+				/* Elvis has left the building! */
+				in_window = FALSE;
+				posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+			}
+		}
+		return(0);
+#endif /* WM_MOUSELEAVE */
+
+		case WM_LBUTTONDOWN:
+		case WM_LBUTTONUP:
+		case WM_MBUTTONDOWN:
+		case WM_MBUTTONUP:
+		case WM_RBUTTONDOWN:
+		case WM_RBUTTONUP: {
+			/* Mouse is handled by DirectInput when fullscreen */
+			if ( SDL_VideoSurface && ! DIRECTX_FULLSCREEN() ) {
+				Sint16 x, y;
+				Uint8 button, state;
+
+				/* Figure out which button to use */
+				switch (msg) {
+					case WM_LBUTTONDOWN:
+						button = 1;
+						state = SDL_PRESSED;
+						break;
+					case WM_LBUTTONUP:
+						button = 1;
+						state = SDL_RELEASED;
+						break;
+					case WM_MBUTTONDOWN:
+						button = 2;
+						state = SDL_PRESSED;
+						break;
+					case WM_MBUTTONUP:
+						button = 2;
+						state = SDL_RELEASED;
+						break;
+					case WM_RBUTTONDOWN:
+						button = 3;
+						state = SDL_PRESSED;
+						break;
+					case WM_RBUTTONUP:
+						button = 3;
+						state = SDL_RELEASED;
+						break;
+					default:
+						/* Eh? Unknown button? */
+						return(0);
+				}
+				if ( state == SDL_PRESSED ) {
+					/* Grab mouse so we get up events */
+					if ( ++mouse_pressed > 0 ) {
+						SetCapture(hwnd);
+					}
+				} else {
+					/* Release mouse after all up events */
+					if ( --mouse_pressed <= 0 ) {
+						ReleaseCapture();
+						mouse_pressed = 0;
+					}
+				}
+				if ( mouse_relative ) {
+				/*	RJR: March 28, 2000
+					report internal mouse position if in relative mode */
+					x = 0; y = 0;
+				} else {
+					x = (Sint16)LOWORD(lParam);
+					y = (Sint16)HIWORD(lParam);
+				}
+				posted = SDL_PrivateMouseButton(
+							state, button, x, y);
+			}
+		}
+		return(0);
+
+#ifdef WM_GETMINMAXINFO
+		/* This message is sent as a way for us to "check" the values
+		 * of a position change.  If we don't like it, we can adjust
+		 * the values before they are changed.
+		 */
+		case WM_GETMINMAXINFO: {
+			MINMAXINFO *info;
+			RECT        size;
+			int x, y;
+			int width;
+			int height;
+
+			/* We don't want to clobber an internal resize */
+			if ( SDL_resizing )
+				return(0);
+
+			/* We allow resizing with the SDL_RESIZABLE flag */
+			if ( SDL_PublicSurface &&
+				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
+				return(0);
+			}
+
+			/* Get the current position of our window */
+			GetWindowRect(SDL_Window, &size);
+			x = size.left;
+			y = size.top;
+
+			/* Calculate current width and height of our window */
+			size.top = 0;
+			size.left = 0;
+			if ( SDL_PublicSurface != NULL ) {
+				size.bottom = SDL_PublicSurface->h;
+				size.right = SDL_PublicSurface->w;
+			} else {
+				size.bottom = 0;
+				size.right = 0;
+			}
+			AdjustWindowRect(&size, GetWindowLong(hwnd, GWL_STYLE),
+									FALSE);
+			width = size.right - size.left;
+			height = size.bottom - size.top;
+
+			/* Fix our size to the current size */
+			info = (MINMAXINFO *)lParam;
+			info->ptMaxSize.x = width;
+			info->ptMaxSize.y = height;
+			info->ptMaxPosition.x = x;
+			info->ptMaxPosition.y = y;
+			info->ptMinTrackSize.x = width;
+			info->ptMinTrackSize.y = height;
+			info->ptMaxTrackSize.x = width;
+			info->ptMaxTrackSize.y = height;
+		}
+		return(0);
+#endif /* WM_GETMINMAXINFO */
+
+		case WM_MOVE: {
+			SDL_VideoDevice *this = current_video;
+
+			GetClientRect(SDL_Window, &SDL_bounds);
+			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds);
+			ClientToScreen(SDL_Window, (LPPOINT)&SDL_bounds+1);
+			if ( this->input_grab != SDL_GRAB_OFF ) {
+				ClipCursor(&SDL_bounds);
+			}
+		}
+		break;
+	
+		case WM_SIZE: {
+			if ( SDL_PublicSurface &&
+				(SDL_PublicSurface->flags & SDL_RESIZABLE) ) {
+				SDL_PrivateResize(LOWORD(lParam), HIWORD(lParam));
+			}
+			return(0);
+		}
+		break;
+
+		/* We need to set the cursor */
+		case WM_SETCURSOR: {
+			Uint16 hittest;
+
+			hittest = LOWORD(lParam);
+			if ( hittest == HTCLIENT ) {
+				SetCursor(SDL_hcursor);
+				return(TRUE);
+			}
+		}
+		break;
+
+		/* We are about to get palette focus! */
+		case WM_QUERYNEWPALETTE: {
+			WIN_RealizePalette(current_video);
+			return(TRUE);
+		}
+		break;
+
+		/* Another application changed the palette */
+		case WM_PALETTECHANGED: {
+			WIN_PaletteChanged(current_video, (HWND)wParam);
+		}
+		break;
+
+		/* We were occluded, refresh our display */
+		case WM_PAINT: {
+			HDC hdc;
+			PAINTSTRUCT ps;
+
+			hdc = BeginPaint(SDL_Window, &ps);
+			if ( current_video->screen &&
+			     !(current_video->screen->flags & SDL_OPENGL) ) {
+				WIN_WinPAINT(current_video, hdc);
+			}
+			EndPaint(SDL_Window, &ps);
+		}
+		return(0);
+
+		case WM_ERASEBKGND: {
+			/* Just do nothing */ ;
+		}
+		return(1);
+
+		case WM_CLOSE: {
+			if ( (posted = SDL_PrivateQuit()) )
+				PostQuitMessage(0);
+		}
+		return(0);
+
+		case WM_DESTROY: {
+			PostQuitMessage(0);
+		}
+		return(0);
+
+		default: {
+			/* Special handling by the video driver */
+			if (HandleMessage) {
+				return(HandleMessage(current_video,
+			                     hwnd, msg, wParam, lParam));
+			}
+		}
+		break;
+	}
+	return(DefWindowProc(hwnd, msg, wParam, lParam));
+}
+
+/* This allows the SDL_WINDOWID hack */
+const char *SDL_windowid = NULL;
+
+/* Register the class for this application -- exported for winmain.c */
+int SDL_RegisterApp(char *name, Uint32 style, void *hInst)
+{
+	static int initialized = 0;
+	WNDCLASS class;
+#ifdef WM_MOUSELEAVE
+	HMODULE handle;
+#endif
+
+	/* Only do this once... */
+	if ( initialized ) {
+		return(0);
+	}
+
+	/* This function needs to be passed the correct process handle
+	   by the application.  The following call just returns a handle
+	   to the SDL DLL, which is useless for our purposes and causes
+	   DirectInput to fail to initialize.
+	 */
+	if ( ! hInst ) {
+		hInst = GetModuleHandle(NULL);
+	}
+
+	/* Register the application class */
+	class.hCursor		= NULL;
+#ifdef _WIN32_WCE
+    {
+	/* WinCE uses the UNICODE version */
+	int nLen = strlen(name);
+	LPWSTR lpszW = alloca((nLen+1)*2);
+	MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen);
+	class.hIcon		= LoadImage(hInst, lpszW, IMAGE_ICON,
+	                                    0, 0, LR_DEFAULTCOLOR);
+	class.lpszMenuName	= lpszW;
+	class.lpszClassName	= lpszW;
+    }
+#else
+	class.hIcon		= LoadImage(hInst, name, IMAGE_ICON,
+	                                    0, 0, LR_DEFAULTCOLOR);
+	class.lpszMenuName	= "(none)";
+	class.lpszClassName	= name;
+#endif /* _WIN32_WCE */
+	class.hbrBackground	= NULL;
+	class.hInstance		= hInst ? hInst : GetModuleHandle(0);
+	class.style		= style;
+#ifdef HAVE_OPENGL
+	class.style		|= CS_OWNDC;
+#endif
+	class.lpfnWndProc	= WinMessage;
+	class.cbWndExtra	= 0;
+	class.cbClsExtra	= 0;
+	if ( ! RegisterClass(&class) ) {
+		SDL_SetError("Couldn't register application class");
+		return(-1);
+	}
+	SDL_Appname = name;
+	SDL_Instance = hInst;
+
+#ifdef WM_MOUSELEAVE
+	/* Get the version of TrackMouseEvent() we use */
+	_TrackMouseEvent = NULL;
+	handle = GetModuleHandle("USER32.DLL");
+	if ( handle ) {
+		_TrackMouseEvent = (BOOL (WINAPI *)(TRACKMOUSEEVENT *))GetProcAddress(handle, "TrackMouseEvent");
+	}
+	if ( _TrackMouseEvent == NULL ) {
+		_TrackMouseEvent = WIN_TrackMouseEvent;
+	}
+#endif /* WM_MOUSELEAVE */
+
+	/* Check for SDL_WINDOWID hack */
+	SDL_windowid = getenv("SDL_WINDOWID");
+
+	initialized = 1;
+	return(0);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_sysmouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,263 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <windows.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_sysmouse_c.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_lowvideo.h"
+
+#ifdef _WIN32_WCE
+#define USE_STATIC_CURSOR
+#endif
+
+HCURSOR	SDL_hcursor = NULL;		/* Exported for SDL_eventloop.c */
+
+/* The implementation dependent data for the window manager cursor */
+/* For some reason when creating a windows cursor, the ands and xors memory
+   is not copied, so we need to keep track of it and free it when we are done
+   with the cursor.  If we free the memory prematurely, the app crashes. :-}
+*/
+struct WMcursor {
+	HCURSOR curs;
+#ifndef USE_STATIC_CURSOR
+	Uint8 *ands;
+	Uint8 *xors;
+#endif
+};
+
+/* Convert bits to padded bytes */
+#define PAD_BITS(bits)	((bits+7)/8)
+
+#ifdef CURSOR_DEBUG
+static void PrintBITMAP(FILE *out, char *bits, int w, int h)
+{
+	int i;
+	unsigned char ch;
+
+	while ( h-- > 0 ) {
+		for ( i=0; i<w; ++i ) {
+			if ( (i%8) == 0 )
+				ch = *bits++;
+			if ( ch&0x80 )
+				fprintf(out, "X");
+			else
+				fprintf(out, " ");
+			ch <<= 1;
+		}
+		fprintf(out, "\n");
+	}
+}
+#endif
+
+#ifndef USE_STATIC_CURSOR
+/* Local functions to convert the SDL cursor mask into Windows format */
+static void memnot(Uint8 *dst, Uint8 *src, int len)
+{
+	while ( len-- > 0 )
+		*dst++ = ~*src++;
+}
+static void memxor(Uint8 *dst, Uint8 *src1, Uint8 *src2, int len)
+{
+	while ( len-- > 0 )
+		*dst++ = (*src1++)^(*src2++);
+}
+#endif /* !USE_STATIC_CURSOR */
+
+void WIN_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+#ifndef USE_STATIC_CURSOR
+	if ( cursor->curs != NULL )
+		DestroyCursor(cursor->curs);
+	if ( cursor->ands != NULL )
+		free(cursor->ands);
+	if ( cursor->xors != NULL )
+		free(cursor->xors);
+#endif /* !USE_STATIC_CURSOR */
+	free(cursor);
+}
+
+WMcursor *WIN_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+#ifdef USE_STATIC_CURSOR
+	WMcursor *cursor;
+
+	/* Allocate the cursor */
+	cursor = (WMcursor *)malloc(sizeof(*cursor));
+	if ( cursor ) {
+		cursor->curs = LoadCursor(NULL, IDC_ARROW);
+	}
+	return(cursor);
+#else
+	WMcursor *cursor;
+	int allowed_x;
+	int allowed_y;
+	int run, pad, i;
+	Uint8 *aptr, *xptr;
+
+	/* Check to make sure the cursor size is okay */
+	allowed_x = GetSystemMetrics(SM_CXCURSOR);
+	allowed_y = GetSystemMetrics(SM_CYCURSOR);
+	if ( (w > allowed_x) || (h > allowed_y) ) {
+		SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
+							allowed_x, allowed_y);
+		return(NULL);
+	}
+
+	/* Allocate the cursor */
+	cursor = (WMcursor *)malloc(sizeof(*cursor));
+	if ( cursor == NULL ) {
+		SDL_SetError("Out of memory");
+		return(NULL);
+	}
+	cursor->curs = NULL;
+	cursor->ands = NULL;
+	cursor->xors = NULL;
+
+	/* Pad out to the normal cursor size */
+	run = PAD_BITS(w);
+	pad = PAD_BITS(allowed_x)-run;
+	aptr = cursor->ands = (Uint8 *)malloc((run+pad)*allowed_y);
+	xptr = cursor->xors = (Uint8 *)malloc((run+pad)*allowed_y);
+	if ( (aptr == NULL) || (xptr == NULL) ) {
+		WIN_FreeWMCursor(NULL, cursor);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	for ( i=0; i<h; ++i ) {
+		memxor(xptr, data, mask, run);
+		xptr += run;
+		data += run;
+		memnot(aptr, mask, run);
+		mask += run;
+		aptr += run;
+		memset(xptr,  0, pad);
+		xptr += pad;
+		memset(aptr, ~0, pad);
+		aptr += pad;
+	}
+	pad += run;
+	for ( ; i<allowed_y; ++i ) {
+		memset(xptr,  0, pad);
+		xptr += pad;
+		memset(aptr, ~0, pad);
+		aptr += pad;
+	}
+
+	/* Create the cursor */
+	cursor->curs = CreateCursor(
+			(HINSTANCE)GetWindowLong(SDL_Window, GWL_HINSTANCE),
+					hot_x, hot_y, allowed_x, allowed_y, 
+						cursor->ands, cursor->xors);
+	if ( cursor->curs == NULL ) {
+		WIN_FreeWMCursor(NULL, cursor);
+		SDL_SetError("Windows couldn't create the requested cursor");
+		return(NULL);
+	}
+	return(cursor);
+#endif /* USE_STATIC_CURSOR */
+}
+
+int WIN_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	POINT mouse_pos;
+
+	/* The fullscreen cursor must be done in software with DirectInput */
+	if ( !this->screen || DIRECTX_FULLSCREEN() ) {
+		return(0);
+	}
+
+	/* Set the window cursor to our cursor, if applicable */
+	if ( cursor != NULL ) {
+		SDL_hcursor = cursor->curs;
+	} else {
+		SDL_hcursor = NULL;
+	}
+	GetCursorPos(&mouse_pos);
+	if ( PtInRect(&SDL_bounds, mouse_pos) ) {
+		SetCursor(SDL_hcursor);
+	}
+	return(1);
+}
+
+void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+	POINT pt;
+
+	if ( DIRECTX_FULLSCREEN() ) {
+		x += (this->screen->offset % this->screen->pitch) /
+		      this->screen->format->BytesPerPixel;
+		y += (this->screen->offset / this->screen->pitch);
+		SDL_PrivateMouseMotion(0, 0, x, y);
+	} else if ( mouse_relative) {
+		/*	RJR: March 28, 2000
+			leave physical cursor at center of screen if
+			mouse hidden and grabbed */
+		SDL_PrivateMouseMotion(0, 0, x, y);
+	} else {
+		pt.x = x;
+		pt.y = y;
+		ClientToScreen(SDL_Window, &pt);
+		SetCursorPos(pt.x, pt.y);
+	}
+}
+
+/* Update the current mouse state and position */
+void WIN_UpdateMouse(_THIS)
+{
+	RECT rect;
+	POINT pt;
+
+	if ( ! DIRECTX_FULLSCREEN() ) {
+		GetClientRect(SDL_Window, &rect);
+		GetCursorPos(&pt);
+		MapWindowPoints(NULL, SDL_Window, &pt, 1);
+		if (PtInRect(&rect, pt) && (WindowFromPoint(pt) == SDL_Window)){
+			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			SDL_PrivateMouseMotion(0,0, (Sint16)pt.x, (Sint16)pt.y);
+		} else {
+			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+		}
+	}
+}
+
+/* Check to see if we need to enter or leave mouse relative mode */
+void WIN_CheckMouseMode(_THIS)
+{
+        /* If the mouse is hidden and input is grabbed, we use relative mode */
+        if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
+             (this->input_grab != SDL_GRAB_OFF) ) {
+                mouse_relative = 1;
+        } else {
+                mouse_relative = 0;
+        }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_sysmouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Functions to be exported */
+extern void WIN_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *WIN_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int WIN_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void WIN_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+extern void WIN_UpdateMouse(_THIS);
+extern void WIN_CheckMouseMode(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_syswm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,276 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$"
+#endif
+
+#include <stdio.h>
+#include <malloc.h>
+#include <windows.h>
+
+#include "SDL_version.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_syswm.h"
+#include "SDL_syswm_c.h"
+#include "SDL_pixels_c.h"
+
+#ifdef _WIN32_WCE
+#define DISABLE_ICON_SUPPORT
+#endif
+
+/*	RJR: March 28, 2000
+	we need "SDL_cursor_c.h" for mods to WIN_GrabInput */
+#include "SDL_cursor_c.h"
+
+/* The screen icon -- needs to be freed on SDL_VideoQuit() */
+HICON   screen_icn = NULL;
+
+/* Win32 icon mask semantics are different from those of SDL:
+     SDL applies the mask to the icon and copies result to desktop.
+     Win32 applies the mask to the desktop and XORs the icon on.
+   This means that the SDL mask needs to be applied to the icon and
+   then inverted and passed to Win32.
+*/
+void WIN_SetWMIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
+{
+#ifdef DISABLE_ICON_SUPPORT
+	return;
+#else
+	SDL_Palette *pal_256;
+	SDL_Surface *icon_256;
+	Uint8 *pdata, *pwin32;
+	Uint8 *mdata, *mwin32, m = 0;
+	int icon_len;
+	int icon_plen;
+	int icon_mlen;
+	int icon_pitch;
+	int mask_pitch;
+	SDL_Rect bounds;
+	int i, skip;
+	int row, col;
+	struct /* quasi-BMP format */ Win32Icon {
+		Uint32 biSize;
+		Sint32 biWidth;
+		Sint32 biHeight;
+		Uint16 biPlanes;
+		Uint16 biBitCount;
+		Uint32 biCompression;
+		Uint32 biSizeImage;
+		Sint32 biXPelsPerMeter;
+		Sint32 biYPelsPerMeter;
+		Uint32 biClrUsed;
+		Uint32 biClrImportant;
+		struct /* RGBQUAD -- note it's BGR ordered */ {
+			Uint8 rgbBlue;
+			Uint8 rgbGreen;
+			Uint8 rgbRed;
+			Uint8 rgbReserved;
+		} biColors[256];
+		/* Pixels:
+		Uint8 pixels[]
+		*/
+		/* Mask:
+		Uint8 mask[]
+		*/
+	} *icon_win32;
+	
+	/* Allocate the win32 bmp icon and set everything to zero */
+	icon_pitch = ((icon->w+3)&~3);
+	mask_pitch = ((icon->w+7)/8);
+	icon_plen = icon->h*icon_pitch;
+	icon_mlen = icon->h*mask_pitch;
+	icon_len = sizeof(*icon_win32)+icon_plen+icon_mlen;
+	icon_win32 = (struct Win32Icon *)alloca(icon_len);
+	if ( icon_win32 == NULL ) {
+		return;
+	}
+	memset(icon_win32, 0, icon_len);
+
+	/* Set the basic BMP parameters */
+	icon_win32->biSize = sizeof(*icon_win32)-sizeof(icon_win32->biColors);
+	icon_win32->biWidth = icon->w;
+	icon_win32->biHeight = icon->h*2;
+	icon_win32->biPlanes = 1;
+	icon_win32->biBitCount = 8;
+	icon_win32->biSizeImage = icon_plen+icon_mlen;
+
+	/* Allocate a standard 256 color icon surface */
+	icon_256 = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
+					 icon_win32->biBitCount, 0, 0, 0, 0);
+	if ( icon_256 == NULL ) {
+		return;
+	}
+	pal_256 = icon_256->format->palette;
+	if (icon->format->palette && 
+		(icon->format->BitsPerPixel == icon_256->format->BitsPerPixel)){
+		Uint8 black;
+		memcpy(pal_256->colors, icon->format->palette->colors,
+					pal_256->ncolors*sizeof(SDL_Color));
+		/* Make sure that 0 is black! */
+		black = SDL_FindColor(pal_256, 0x00, 0x00, 0x00);
+		pal_256->colors[black] = pal_256->colors[0];
+		pal_256->colors[0].r = 0x00;
+		pal_256->colors[0].g = 0x00;
+		pal_256->colors[0].b = 0x00;
+	} else {
+		SDL_DitherColors(pal_256->colors,
+					icon_256->format->BitsPerPixel);
+	}
+
+	/* Now copy color data to the icon BMP */
+	for ( i=0; i<(1<<icon_win32->biBitCount); ++i ) {
+		icon_win32->biColors[i].rgbRed = pal_256->colors[i].r;
+		icon_win32->biColors[i].rgbGreen = pal_256->colors[i].g;
+		icon_win32->biColors[i].rgbBlue = pal_256->colors[i].b;
+	}
+
+	/* Convert icon to a standard surface format.  This may not always
+	   be necessary, as Windows supports a variety of BMP formats, but
+	   it greatly simplifies our code.
+	*/ 
+        bounds.x = 0;
+        bounds.y = 0;
+        bounds.w = icon->w;
+        bounds.h = icon->h;
+        if ( SDL_LowerBlit(icon, &bounds, icon_256, &bounds) < 0 ) {
+		SDL_FreeSurface(icon_256);
+                return;
+	}
+
+	/* Copy pixels upside-down to icon BMP, masked with the icon mask */
+	if ( SDL_MUSTLOCK(icon_256) || (icon_256->pitch != icon_pitch) ) {
+		SDL_FreeSurface(icon_256);
+		SDL_SetError("Warning: Unexpected icon_256 characteristics");
+		return;
+	}
+	pdata = (Uint8 *)icon_256->pixels;
+	mdata = mask;
+	pwin32 = (Uint8 *)icon_win32+sizeof(*icon_win32)+icon_plen-icon_pitch;
+	skip = icon_pitch - icon->w;
+	for ( row=0; row<icon->h; ++row ) {
+		for ( col=0; col<icon->w; ++col ) {
+			if ( (col%8) == 0 ) {
+				m = *mdata++;
+			}
+			if ( (m&0x80) != 0x00 ) {
+				*pwin32 = *pdata;
+			}
+			m <<= 1;
+			++pdata;
+			++pwin32;
+		}
+		pdata  += skip;
+		pwin32 += skip;
+		pwin32 -= 2*icon_pitch;
+	}
+	SDL_FreeSurface(icon_256);
+
+	/* Copy mask inverted and upside-down to icon BMP */
+	mdata = mask;
+	mwin32 = (Uint8 *)icon_win32
+			+sizeof(*icon_win32)+icon_plen+icon_mlen-mask_pitch;
+	for ( row=0; row<icon->h; ++row ) {
+		for ( col=0; col<mask_pitch; ++col ) {
+			*mwin32++ = ~*mdata++;
+		}
+		mwin32 -= 2*mask_pitch;
+	}
+
+	/* Finally, create the icon handle and set the window icon */
+	screen_icn = CreateIconFromResourceEx((Uint8 *)icon_win32, icon_len,
+			TRUE, 0x00030000, icon->w, icon->h, LR_DEFAULTCOLOR);
+	if ( screen_icn == NULL ) {
+		SDL_SetError("Couldn't create Win32 icon handle");
+	} else {
+		SetClassLong(SDL_Window, GCL_HICON, (LONG)screen_icn);
+	}
+#endif /* DISABLE_ICON_SUPPORT */
+}
+
+void WIN_SetWMCaption(_THIS, const char *title, const char *icon)
+{
+#ifdef _WIN32_WCE
+	/* WinCE uses the UNICODE version */
+	int nLen = strlen(title);
+	LPWSTR lpszW = alloca((nLen+1)*2);
+	MultiByteToWideChar(CP_ACP, 0, title, -1, lpszW, nLen);
+	SetWindowText(SDL_Window, lpszW);
+#else
+	SetWindowText(SDL_Window, title);
+#endif
+}
+
+int WIN_IconifyWindow(_THIS)
+{
+	ShowWindow(SDL_Window, SW_MINIMIZE);
+	return(1);
+}
+
+SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode)
+{
+	if ( mode == SDL_GRAB_OFF ) {
+		ClipCursor(NULL);
+		if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
+		/*	RJR: March 28, 2000
+			must be leaving relative mode, move mouse from
+			center of window to where it belongs ... */
+			POINT pt;
+			int x, y;
+			SDL_GetMouseState(&x,&y);
+			pt.x = x;
+			pt.y = y;
+			ClientToScreen(SDL_Window, &pt);
+			SetCursorPos(pt.x,pt.y);
+		}
+	} else {
+		ClipCursor(&SDL_bounds);
+		if ( !(SDL_cursorstate & CURSOR_VISIBLE) ) {
+		/*	RJR: March 28, 2000
+			must be entering relative mode, get ready by
+			moving mouse to	center of window ... */
+			POINT pt;
+			pt.x = (SDL_VideoSurface->w/2);
+			pt.y = (SDL_VideoSurface->h/2);
+			ClientToScreen(SDL_Window, &pt);
+			SetCursorPos(pt.x, pt.y);
+		}
+	}
+	return(mode);
+}
+
+/* If 'info' is the right version, this function fills it and returns 1.
+   Otherwise, in case of a version mismatch, it returns -1.
+*/
+int WIN_GetWMInfo(_THIS, SDL_SysWMinfo *info)
+{
+	if ( info->version.major <= SDL_MAJOR_VERSION ) {
+		info->window = SDL_Window;
+		return(1);
+	} else {
+		SDL_SetError("Application not compiled with SDL %d.%d\n",
+					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+		return(-1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_syswm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Data that needs to be freed at SDL_SYS_VideoQuit() */
+extern HICON screen_icn;
+
+/* Functions to be exported */
+extern void WIN_SetWMIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
+extern void WIN_SetWMCaption(_THIS, const char *title, const char *icon);
+extern int WIN_IconifyWindow(_THIS);
+extern SDL_GrabMode WIN_GrabInput(_THIS, SDL_GrabMode mode);
+extern int WIN_GetWMInfo(_THIS, SDL_SysWMinfo *info);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_wingl.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,287 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* WGL implementation of SDL OpenGL support */
+
+#include <windows.h>
+
+#include "SDL_error.h"
+#include "SDL_lowvideo.h"
+#include "SDL_wingl_c.h"
+
+#ifdef HAVE_OPENGL
+#define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL"
+#endif
+
+
+int WIN_GL_SetupWindow(_THIS)
+{
+	int retval;
+#ifdef HAVE_OPENGL
+	int pixel_format;
+
+	/* load the gl driver from a default path */
+	if ( ! this->gl_config.driver_loaded ) {
+		/* no driver has been loaded, use default (ourselves) */
+		if ( WIN_GL_LoadLibrary(this, NULL) < 0 ) {
+			return(-1);
+		}
+	}
+
+	/* Get the window device context for our OpenGL drawing */
+	GL_hdc = GetDC(SDL_Window);
+	if ( GL_hdc == NULL ) {
+		SDL_SetError("Unable to get DC for SDL_Window");
+		return(-1);
+	}
+
+	/* Set up the pixel format descriptor with our needed format */
+	memset(&GL_pfd, 0, sizeof(GL_pfd));
+	GL_pfd.nSize = sizeof(GL_pfd);
+	GL_pfd.nVersion = 1;
+	GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL);
+	if ( this->gl_config.double_buffer ) {
+		GL_pfd.dwFlags |= PFD_DOUBLEBUFFER;
+	}
+	GL_pfd.iPixelType = PFD_TYPE_RGBA;
+	GL_pfd.cColorBits = this->gl_config.buffer_size;
+	GL_pfd.cRedBits = this->gl_config.red_size;
+	GL_pfd.cGreenBits = this->gl_config.green_size;
+	GL_pfd.cBlueBits = this->gl_config.blue_size;
+	GL_pfd.cAlphaBits = this->gl_config.alpha_size;
+	GL_pfd.cAccumRedBits = this->gl_config.accum_red_size;
+	GL_pfd.cAccumGreenBits = this->gl_config.accum_green_size;
+	GL_pfd.cAccumBlueBits = this->gl_config.accum_blue_size;
+	GL_pfd.cAccumAlphaBits = this->gl_config.accum_alpha_size;
+	GL_pfd.cAccumBits =
+		(GL_pfd.cAccumRedBits + GL_pfd.cAccumGreenBits +
+		 GL_pfd.cAccumBlueBits + GL_pfd.cAccumAlphaBits);
+	GL_pfd.cDepthBits = this->gl_config.depth_size;
+	GL_pfd.cStencilBits = this->gl_config.stencil_size;
+
+	/* Choose and set the closest available pixel format */
+	pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd);
+	if ( !pixel_format ) {
+		SDL_SetError("No matching GL pixel format available");
+		return(-1);
+	}
+	if( !SetPixelFormat(GL_hdc, pixel_format, &GL_pfd) ) {
+		SDL_SetError("Unable to set HDC pixel format");
+		return(-1);
+	}
+	DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd);
+
+	GL_hrc = this->gl_data->wglCreateContext(GL_hdc);
+	if( GL_hrc == NULL ) {
+		SDL_SetError("Unable to create GL context");
+		return(-1);
+	}
+	gl_active = 1;
+#else
+	SDL_SetError("WIN driver not configured with OpenGL");
+#endif
+	if ( gl_active ) {
+		retval = 0;
+	} else {
+		retval = -1;
+	}
+	return(retval);
+}
+
+void WIN_GL_ShutDown(_THIS)
+{
+#ifdef HAVE_OPENGL
+	/* Clean up OpenGL */
+	if ( GL_hrc ) {
+		this->gl_data->wglMakeCurrent(NULL, NULL);
+		this->gl_data->wglDeleteContext(GL_hrc);
+		GL_hrc = NULL;
+	}
+	if ( GL_hdc ) {
+		ReleaseDC(SDL_Window, GL_hdc);
+		GL_hdc = NULL;
+	}
+	gl_active = 0;
+
+	WIN_GL_UnloadLibrary(this);
+#endif /* HAVE_OPENGL */
+}
+
+#ifdef HAVE_OPENGL
+
+/* Make the current context active */
+int WIN_GL_MakeCurrent(_THIS)
+{
+	int retval;
+
+	retval = 0;
+	if ( ! this->gl_data->wglMakeCurrent(GL_hdc, GL_hrc) ) {
+		SDL_SetError("Unable to make GL context current");
+		retval = -1;
+	}
+	return(retval);
+}
+
+/* Get attribute data from glX. */
+int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
+{
+	int retval;
+
+	retval = 0;
+	switch( attrib ) {
+	    case SDL_GL_RED_SIZE:
+		*value = GL_pfd.cRedBits;
+		break;
+	    case SDL_GL_GREEN_SIZE:
+		*value = GL_pfd.cGreenBits;
+		break;
+	    case SDL_GL_BLUE_SIZE:
+		*value = GL_pfd.cBlueBits;
+		break;
+	    case SDL_GL_ALPHA_SIZE:
+		*value = GL_pfd.cAlphaBits;
+		break;
+	    case SDL_GL_DOUBLEBUFFER:
+		if ( GL_pfd.dwFlags & PFD_DOUBLEBUFFER ) {
+			*value = 1;
+		} else {
+			*value = 0;
+		}
+		break;
+	    case SDL_GL_BUFFER_SIZE:
+		*value = GL_pfd.cColorBits;
+		break;
+	    case SDL_GL_DEPTH_SIZE:
+		*value = GL_pfd.cDepthBits;
+		break;
+	    case SDL_GL_STENCIL_SIZE:
+		*value = GL_pfd.cStencilBits;
+		break;
+	    case SDL_GL_ACCUM_RED_SIZE:
+		*value = GL_pfd.cAccumRedBits;
+		break;
+	    case SDL_GL_ACCUM_GREEN_SIZE:
+		*value = GL_pfd.cAccumGreenBits;
+		break;
+	    case SDL_GL_ACCUM_BLUE_SIZE:
+		*value = GL_pfd.cAccumBlueBits;
+		break;
+	    case SDL_GL_ACCUM_ALPHA_SIZE:
+		*value = GL_pfd.cAccumAlphaBits;
+		break;
+	    default:
+		retval = -1;
+		break;
+	}
+	return retval;
+}
+
+void WIN_GL_SwapBuffers(_THIS)
+{
+	SwapBuffers(GL_hdc);
+}
+
+#endif /* HAVE_OPENGL */
+
+#ifdef HAVE_OPENGL
+
+void WIN_GL_UnloadLibrary(_THIS)
+{
+	if ( this->gl_config.driver_loaded ) {
+		FreeLibrary((HMODULE)this->gl_config.dll_handle);
+
+		this->gl_data->wglGetProcAddress = NULL;
+		this->gl_data->wglCreateContext = NULL;
+		this->gl_data->wglDeleteContext = NULL;
+		this->gl_data->wglMakeCurrent = NULL;
+
+		this->gl_config.dll_handle = NULL;
+		this->gl_config.driver_loaded = 0;
+	}
+}
+
+/* Passing a NULL path means load pointers from the application */
+int WIN_GL_LoadLibrary(_THIS, const char* path) 
+{
+	HMODULE handle;
+
+ 	if ( gl_active ) {
+ 		SDL_SetError("OpenGL context already created");
+ 		return -1;
+ 	}
+
+	if ( path == NULL ) {
+		path = DEFAULT_GL_DRIVER_PATH;
+	}
+	handle = LoadLibrary(path);
+	if ( handle == NULL ) {
+		SDL_SetError("Could not load OpenGL library");
+		return -1;
+	}
+
+	/* Unload the old driver and reset the pointers */
+	WIN_GL_UnloadLibrary(this);
+
+	/* Load new function pointers */
+	this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *))
+		GetProcAddress(handle, "wglGetProcAddress");
+	this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC))
+		GetProcAddress(handle, "wglCreateContext");
+	this->gl_data->wglDeleteContext = (BOOL (WINAPI *)(HGLRC))
+		GetProcAddress(handle, "wglDeleteContext");
+	this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC))
+		GetProcAddress(handle, "wglMakeCurrent");
+
+	if ( (this->gl_data->wglGetProcAddress == NULL) ||
+	     (this->gl_data->wglCreateContext == NULL) ||
+	     (this->gl_data->wglDeleteContext == NULL) ||
+	     (this->gl_data->wglMakeCurrent == NULL) ) {
+		SDL_SetError("Could not retrieve OpenGL functions");
+		FreeLibrary(handle);
+		return -1;
+	}
+
+	this->gl_config.dll_handle = handle;
+	strcpy(this->gl_config.driver_path, path);
+	this->gl_config.driver_loaded = 1;
+	return 0;
+}
+
+void *WIN_GL_GetProcAddress(_THIS, const char* proc)
+{
+	void *func;
+
+	/* This is to pick up extensions */
+	func = this->gl_data->wglGetProcAddress(proc);
+	if ( ! func ) {
+		/* This is probably a normal GL function */
+		func = GetProcAddress(this->gl_config.dll_handle, proc);
+	}
+	return func;
+}
+
+#endif /* HAVE_OPENGL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/SDL_wingl_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,69 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* WGL implementation of SDL OpenGL support */
+
+#include "SDL_sysvideo.h"
+
+
+struct SDL_PrivateGLData {
+    int gl_active; /* to stop switching drivers while we have a valid context */
+
+#ifdef HAVE_OPENGL
+    PIXELFORMATDESCRIPTOR GL_pfd;
+    HDC GL_hdc;
+    HGLRC GL_hrc;
+
+    void * (WINAPI *wglGetProcAddress)(const char *proc);
+
+    HGLRC (WINAPI *wglCreateContext)(HDC hdc);
+
+    BOOL (WINAPI *wglDeleteContext)(HGLRC hglrc);
+
+    BOOL (WINAPI *wglMakeCurrent)(HDC hdc, HGLRC hglrc);
+
+#endif /* HAVE_OPENGL */
+};
+
+/* Old variable names */
+#define gl_active	(this->gl_data->gl_active)
+#define GL_pfd		(this->gl_data->GL_pfd)
+#define GL_hdc		(this->gl_data->GL_hdc)
+#define GL_hrc		(this->gl_data->GL_hrc)
+
+/* OpenGL functions */
+extern int WIN_GL_SetupWindow(_THIS);
+extern void WIN_GL_ShutDown(_THIS);
+#ifdef HAVE_OPENGL
+extern int WIN_GL_MakeCurrent(_THIS);
+extern int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+extern void WIN_GL_SwapBuffers(_THIS);
+extern void WIN_GL_UnloadLibrary(_THIS);
+extern int WIN_GL_LoadLibrary(_THIS, const char* path);
+extern void *WIN_GL_GetProcAddress(_THIS, const char* proc);
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/wincommon/wmmsg.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1030 @@
+
+#define MAX_WMMSG	(sizeof(wmtab)/sizeof(wmtab[0]))
+
+char *wmtab[] = {
+	"WM_NULL",
+	"WM_CREATE",
+	"WM_DESTROY",
+	"WM_MOVE",
+	"UNKNOWN (4)",
+	"WM_SIZE",
+	"WM_ACTIVATE",
+	"WM_SETFOCUS",
+	"WM_KILLFOCUS",
+	"UNKNOWN (9)",
+	"WM_ENABLE",
+	"WM_SETREDRAW",
+	"WM_SETTEXT",
+	"WM_GETTEXT",
+	"WM_GETTEXTLENGTH",
+	"WM_PAINT",
+	"WM_CLOSE",
+	"WM_QUERYENDSESSION",
+	"WM_QUIT",
+	"WM_QUERYOPEN",
+	"WM_ERASEBKGND",
+	"WM_SYSCOLORCHANGE",
+	"WM_ENDSESSION",
+	"UNKNOWN (23)",
+	"WM_SHOWWINDOW",
+	"UNKNOWN (25)",
+	"WM_SETTINGCHANGE",
+	"WM_DEVMODECHANGE",
+	"WM_ACTIVATEAPP",
+	"WM_FONTCHANGE",
+	"WM_TIMECHANGE",
+	"WM_CANCELMODE",
+	"WM_SETCURSOR",
+	"WM_MOUSEACTIVATE",
+	"WM_CHILDACTIVATE",
+	"WM_QUEUESYNC",
+	"WM_GETMINMAXINFO",
+	"UNKNOWN (37)",
+	"WM_PAINTICON",
+	"WM_ICONERASEBKGND",
+	"WM_NEXTDLGCTL",
+	"UNKNOWN (41)",
+	"WM_SPOOLERSTATUS",
+	"WM_DRAWITEM",
+	"WM_MEASUREITEM",
+	"WM_DELETEITEM",
+	"WM_VKEYTOITEM",
+	"WM_CHARTOITEM",
+	"WM_SETFONT",
+	"WM_GETFONT",
+	"WM_SETHOTKEY",
+	"WM_GETHOTKEY",
+	"UNKNOWN (52)",
+	"UNKNOWN (53)",
+	"UNKNOWN (54)",
+	"WM_QUERYDRAGICON",
+	"UNKNOWN (56)",
+	"WM_COMPAREITEM",
+	"UNKNOWN (58)",
+	"UNKNOWN (59)",
+	"UNKNOWN (60)",
+	"WM_GETOBJECT",
+	"UNKNOWN (62)",
+	"UNKNOWN (63)",
+	"UNKNOWN (64)",
+	"WM_COMPACTING",
+	"UNKNOWN (66)",
+	"UNKNOWN (67)",
+	"WM_COMMNOTIFY",
+	"UNKNOWN (69)",
+	"WM_WINDOWPOSCHANGING",
+	"WM_WINDOWPOSCHANGED",
+	"WM_POWER",
+	"UNKNOWN (73)",
+	"WM_COPYDATA",
+	"WM_CANCELJOURNAL",
+	"UNKNOWN (76)",
+	"UNKNOWN (77)",
+	"WM_NOTIFY",
+	"UNKNOWN (79)",
+	"WM_INPUTLANGCHANGEREQUEST",
+	"WM_INPUTLANGCHANGE",
+	"WM_TCARD",
+	"WM_HELP",
+	"WM_USERCHANGED",
+	"WM_NOTIFYFORMAT",
+	"UNKNOWN (86)",
+	"UNKNOWN (87)",
+	"UNKNOWN (88)",
+	"UNKNOWN (89)",
+	"UNKNOWN (90)",
+	"UNKNOWN (91)",
+	"UNKNOWN (92)",
+	"UNKNOWN (93)",
+	"UNKNOWN (94)",
+	"UNKNOWN (95)",
+	"UNKNOWN (96)",
+	"UNKNOWN (97)",
+	"UNKNOWN (98)",
+	"UNKNOWN (99)",
+	"UNKNOWN (100)",
+	"UNKNOWN (101)",
+	"UNKNOWN (102)",
+	"UNKNOWN (103)",
+	"UNKNOWN (104)",
+	"UNKNOWN (105)",
+	"UNKNOWN (106)",
+	"UNKNOWN (107)",
+	"UNKNOWN (108)",
+	"UNKNOWN (109)",
+	"UNKNOWN (110)",
+	"UNKNOWN (111)",
+	"UNKNOWN (112)",
+	"UNKNOWN (113)",
+	"UNKNOWN (114)",
+	"UNKNOWN (115)",
+	"UNKNOWN (116)",
+	"UNKNOWN (117)",
+	"UNKNOWN (118)",
+	"UNKNOWN (119)",
+	"UNKNOWN (120)",
+	"UNKNOWN (121)",
+	"UNKNOWN (122)",
+	"WM_CONTEXTMENU",
+	"WM_STYLECHANGING",
+	"WM_STYLECHANGED",
+	"WM_DISPLAYCHANGE",
+	"WM_GETICON",
+	"WM_SETICON",
+	"WM_NCCREATE",
+	"WM_NCDESTROY",
+	"WM_NCCALCSIZE",
+	"WM_NCHITTEST",
+	"WM_NCPAINT",
+	"WM_NCACTIVATE",
+	"WM_GETDLGCODE",
+	"WM_SYNCPAINT",
+	"UNKNOWN (137)",
+	"UNKNOWN (138)",
+	"UNKNOWN (139)",
+	"UNKNOWN (140)",
+	"UNKNOWN (141)",
+	"UNKNOWN (142)",
+	"UNKNOWN (143)",
+	"UNKNOWN (144)",
+	"UNKNOWN (145)",
+	"UNKNOWN (146)",
+	"UNKNOWN (147)",
+	"UNKNOWN (148)",
+	"UNKNOWN (149)",
+	"UNKNOWN (150)",
+	"UNKNOWN (151)",
+	"UNKNOWN (152)",
+	"UNKNOWN (153)",
+	"UNKNOWN (154)",
+	"UNKNOWN (155)",
+	"UNKNOWN (156)",
+	"UNKNOWN (157)",
+	"UNKNOWN (158)",
+	"UNKNOWN (159)",
+	"WM_NCMOUSEMOVE",
+	"WM_NCLBUTTONDOWN",
+	"WM_NCLBUTTONUP",
+	"WM_NCLBUTTONDBLCLK",
+	"WM_NCRBUTTONDOWN",
+	"WM_NCRBUTTONUP",
+	"WM_NCRBUTTONDBLCLK",
+	"WM_NCMBUTTONDOWN",
+	"WM_NCMBUTTONUP",
+	"WM_NCMBUTTONDBLCLK",
+	"UNKNOWN (170)",
+	"UNKNOWN (171)",
+	"UNKNOWN (172)",
+	"UNKNOWN (173)",
+	"UNKNOWN (174)",
+	"UNKNOWN (175)",
+	"UNKNOWN (176)",
+	"UNKNOWN (177)",
+	"UNKNOWN (178)",
+	"UNKNOWN (179)",
+	"UNKNOWN (180)",
+	"UNKNOWN (181)",
+	"UNKNOWN (182)",
+	"UNKNOWN (183)",
+	"UNKNOWN (184)",
+	"UNKNOWN (185)",
+	"UNKNOWN (186)",
+	"UNKNOWN (187)",
+	"UNKNOWN (188)",
+	"UNKNOWN (189)",
+	"UNKNOWN (190)",
+	"UNKNOWN (191)",
+	"UNKNOWN (192)",
+	"UNKNOWN (193)",
+	"UNKNOWN (194)",
+	"UNKNOWN (195)",
+	"UNKNOWN (196)",
+	"UNKNOWN (197)",
+	"UNKNOWN (198)",
+	"UNKNOWN (199)",
+	"UNKNOWN (200)",
+	"UNKNOWN (201)",
+	"UNKNOWN (202)",
+	"UNKNOWN (203)",
+	"UNKNOWN (204)",
+	"UNKNOWN (205)",
+	"UNKNOWN (206)",
+	"UNKNOWN (207)",
+	"UNKNOWN (208)",
+	"UNKNOWN (209)",
+	"UNKNOWN (210)",
+	"UNKNOWN (211)",
+	"UNKNOWN (212)",
+	"UNKNOWN (213)",
+	"UNKNOWN (214)",
+	"UNKNOWN (215)",
+	"UNKNOWN (216)",
+	"UNKNOWN (217)",
+	"UNKNOWN (218)",
+	"UNKNOWN (219)",
+	"UNKNOWN (220)",
+	"UNKNOWN (221)",
+	"UNKNOWN (222)",
+	"UNKNOWN (223)",
+	"UNKNOWN (224)",
+	"UNKNOWN (225)",
+	"UNKNOWN (226)",
+	"UNKNOWN (227)",
+	"UNKNOWN (228)",
+	"UNKNOWN (229)",
+	"UNKNOWN (230)",
+	"UNKNOWN (231)",
+	"UNKNOWN (232)",
+	"UNKNOWN (233)",
+	"UNKNOWN (234)",
+	"UNKNOWN (235)",
+	"UNKNOWN (236)",
+	"UNKNOWN (237)",
+	"UNKNOWN (238)",
+	"UNKNOWN (239)",
+	"UNKNOWN (240)",
+	"UNKNOWN (241)",
+	"UNKNOWN (242)",
+	"UNKNOWN (243)",
+	"UNKNOWN (244)",
+	"UNKNOWN (245)",
+	"UNKNOWN (246)",
+	"UNKNOWN (247)",
+	"UNKNOWN (248)",
+	"UNKNOWN (249)",
+	"UNKNOWN (250)",
+	"UNKNOWN (251)",
+	"UNKNOWN (252)",
+	"UNKNOWN (253)",
+	"UNKNOWN (254)",
+	"UNKNOWN (255)",
+	"WM_KEYDOWN",
+	"WM_KEYUP",
+	"WM_CHAR",
+	"WM_DEADCHAR",
+	"WM_SYSKEYDOWN",
+	"WM_SYSKEYUP",
+	"WM_SYSCHAR",
+	"WM_SYSDEADCHAR",
+	"WM_KEYLAST",
+	"UNKNOWN (265)",
+	"UNKNOWN (266)",
+	"UNKNOWN (267)",
+	"UNKNOWN (268)",
+	"UNKNOWN (269)",
+	"UNKNOWN (270)",
+	"UNKNOWN (271)",
+	"WM_INITDIALOG",
+	"WM_COMMAND",
+	"WM_SYSCOMMAND",
+	"WM_TIMER",
+	"WM_HSCROLL",
+	"WM_VSCROLL",
+	"WM_INITMENU",
+	"WM_INITMENUPOPUP",
+	"UNKNOWN (280)",
+	"UNKNOWN (281)",
+	"UNKNOWN (282)",
+	"UNKNOWN (283)",
+	"UNKNOWN (284)",
+	"UNKNOWN (285)",
+	"UNKNOWN (286)",
+	"WM_MENUSELECT",
+	"WM_MENUCHAR",
+	"WM_ENTERIDLE",
+	"WM_MENURBUTTONUP",
+	"WM_MENUDRAG",
+	"WM_MENUGETOBJECT",
+	"WM_UNINITMENUPOPUP",
+	"WM_MENUCOMMAND",
+	"UNKNOWN (295)",
+	"UNKNOWN (296)",
+	"UNKNOWN (297)",
+	"UNKNOWN (298)",
+	"UNKNOWN (299)",
+	"UNKNOWN (300)",
+	"UNKNOWN (301)",
+	"UNKNOWN (302)",
+	"UNKNOWN (303)",
+	"UNKNOWN (304)",
+	"UNKNOWN (305)",
+	"WM_CTLCOLORMSGBOX",
+	"WM_CTLCOLOREDIT",
+	"WM_CTLCOLORLISTBOX",
+	"WM_CTLCOLORBTN",
+	"WM_CTLCOLORDLG",
+	"WM_CTLCOLORSCROLLBAR",
+	"WM_CTLCOLORSTATIC",
+	"UNKNOWN (313)",
+	"UNKNOWN (314)",
+	"UNKNOWN (315)",
+	"UNKNOWN (316)",
+	"UNKNOWN (317)",
+	"UNKNOWN (318)",
+	"UNKNOWN (319)",
+	"UNKNOWN (320)",
+	"UNKNOWN (321)",
+	"UNKNOWN (322)",
+	"UNKNOWN (323)",
+	"UNKNOWN (324)",
+	"UNKNOWN (325)",
+	"UNKNOWN (326)",
+	"UNKNOWN (327)",
+	"UNKNOWN (328)",
+	"UNKNOWN (329)",
+	"UNKNOWN (330)",
+	"UNKNOWN (331)",
+	"UNKNOWN (332)",
+	"UNKNOWN (333)",
+	"UNKNOWN (334)",
+	"UNKNOWN (335)",
+	"UNKNOWN (336)",
+	"UNKNOWN (337)",
+	"UNKNOWN (338)",
+	"UNKNOWN (339)",
+	"UNKNOWN (340)",
+	"UNKNOWN (341)",
+	"UNKNOWN (342)",
+	"UNKNOWN (343)",
+	"UNKNOWN (344)",
+	"UNKNOWN (345)",
+	"UNKNOWN (346)",
+	"UNKNOWN (347)",
+	"UNKNOWN (348)",
+	"UNKNOWN (349)",
+	"UNKNOWN (350)",
+	"UNKNOWN (351)",
+	"UNKNOWN (352)",
+	"UNKNOWN (353)",
+	"UNKNOWN (354)",
+	"UNKNOWN (355)",
+	"UNKNOWN (356)",
+	"UNKNOWN (357)",
+	"UNKNOWN (358)",
+	"UNKNOWN (359)",
+	"UNKNOWN (360)",
+	"UNKNOWN (361)",
+	"UNKNOWN (362)",
+	"UNKNOWN (363)",
+	"UNKNOWN (364)",
+	"UNKNOWN (365)",
+	"UNKNOWN (366)",
+	"UNKNOWN (367)",
+	"UNKNOWN (368)",
+	"UNKNOWN (369)",
+	"UNKNOWN (370)",
+	"UNKNOWN (371)",
+	"UNKNOWN (372)",
+	"UNKNOWN (373)",
+	"UNKNOWN (374)",
+	"UNKNOWN (375)",
+	"UNKNOWN (376)",
+	"UNKNOWN (377)",
+	"UNKNOWN (378)",
+	"UNKNOWN (379)",
+	"UNKNOWN (380)",
+	"UNKNOWN (381)",
+	"UNKNOWN (382)",
+	"UNKNOWN (383)",
+	"UNKNOWN (384)",
+	"UNKNOWN (385)",
+	"UNKNOWN (386)",
+	"UNKNOWN (387)",
+	"UNKNOWN (388)",
+	"UNKNOWN (389)",
+	"UNKNOWN (390)",
+	"UNKNOWN (391)",
+	"UNKNOWN (392)",
+	"UNKNOWN (393)",
+	"UNKNOWN (394)",
+	"UNKNOWN (395)",
+	"UNKNOWN (396)",
+	"UNKNOWN (397)",
+	"UNKNOWN (398)",
+	"UNKNOWN (399)",
+	"UNKNOWN (400)",
+	"UNKNOWN (401)",
+	"UNKNOWN (402)",
+	"UNKNOWN (403)",
+	"UNKNOWN (404)",
+	"UNKNOWN (405)",
+	"UNKNOWN (406)",
+	"UNKNOWN (407)",
+	"UNKNOWN (408)",
+	"UNKNOWN (409)",
+	"UNKNOWN (410)",
+	"UNKNOWN (411)",
+	"UNKNOWN (412)",
+	"UNKNOWN (413)",
+	"UNKNOWN (414)",
+	"UNKNOWN (415)",
+	"UNKNOWN (416)",
+	"UNKNOWN (417)",
+	"UNKNOWN (418)",
+	"UNKNOWN (419)",
+	"UNKNOWN (420)",
+	"UNKNOWN (421)",
+	"UNKNOWN (422)",
+	"UNKNOWN (423)",
+	"UNKNOWN (424)",
+	"UNKNOWN (425)",
+	"UNKNOWN (426)",
+	"UNKNOWN (427)",
+	"UNKNOWN (428)",
+	"UNKNOWN (429)",
+	"UNKNOWN (430)",
+	"UNKNOWN (431)",
+	"UNKNOWN (432)",
+	"UNKNOWN (433)",
+	"UNKNOWN (434)",
+	"UNKNOWN (435)",
+	"UNKNOWN (436)",
+	"UNKNOWN (437)",
+	"UNKNOWN (438)",
+	"UNKNOWN (439)",
+	"UNKNOWN (440)",
+	"UNKNOWN (441)",
+	"UNKNOWN (442)",
+	"UNKNOWN (443)",
+	"UNKNOWN (444)",
+	"UNKNOWN (445)",
+	"UNKNOWN (446)",
+	"UNKNOWN (447)",
+	"UNKNOWN (448)",
+	"UNKNOWN (449)",
+	"UNKNOWN (450)",
+	"UNKNOWN (451)",
+	"UNKNOWN (452)",
+	"UNKNOWN (453)",
+	"UNKNOWN (454)",
+	"UNKNOWN (455)",
+	"UNKNOWN (456)",
+	"UNKNOWN (457)",
+	"UNKNOWN (458)",
+	"UNKNOWN (459)",
+	"UNKNOWN (460)",
+	"UNKNOWN (461)",
+	"UNKNOWN (462)",
+	"UNKNOWN (463)",
+	"UNKNOWN (464)",
+	"UNKNOWN (465)",
+	"UNKNOWN (466)",
+	"UNKNOWN (467)",
+	"UNKNOWN (468)",
+	"UNKNOWN (469)",
+	"UNKNOWN (470)",
+	"UNKNOWN (471)",
+	"UNKNOWN (472)",
+	"UNKNOWN (473)",
+	"UNKNOWN (474)",
+	"UNKNOWN (475)",
+	"UNKNOWN (476)",
+	"UNKNOWN (477)",
+	"UNKNOWN (478)",
+	"UNKNOWN (479)",
+	"UNKNOWN (480)",
+	"UNKNOWN (481)",
+	"UNKNOWN (482)",
+	"UNKNOWN (483)",
+	"UNKNOWN (484)",
+	"UNKNOWN (485)",
+	"UNKNOWN (486)",
+	"UNKNOWN (487)",
+	"UNKNOWN (488)",
+	"UNKNOWN (489)",
+	"UNKNOWN (490)",
+	"UNKNOWN (491)",
+	"UNKNOWN (492)",
+	"UNKNOWN (493)",
+	"UNKNOWN (494)",
+	"UNKNOWN (495)",
+	"UNKNOWN (496)",
+	"UNKNOWN (497)",
+	"UNKNOWN (498)",
+	"UNKNOWN (499)",
+	"UNKNOWN (500)",
+	"UNKNOWN (501)",
+	"UNKNOWN (502)",
+	"UNKNOWN (503)",
+	"UNKNOWN (504)",
+	"UNKNOWN (505)",
+	"UNKNOWN (506)",
+	"UNKNOWN (507)",
+	"UNKNOWN (508)",
+	"UNKNOWN (509)",
+	"UNKNOWN (510)",
+	"UNKNOWN (511)",
+	"WM_MOUSEMOVE",
+	"WM_LBUTTONDOWN",
+	"WM_LBUTTONUP",
+	"WM_LBUTTONDBLCLK",
+	"WM_RBUTTONDOWN",
+	"WM_RBUTTONUP",
+	"WM_RBUTTONDBLCLK",
+	"WM_MBUTTONDOWN",
+	"WM_MBUTTONUP",
+	"WM_MOUSELAST",
+	"WM_MOUSELAST",
+	"UNKNOWN (523)",
+	"UNKNOWN (524)",
+	"UNKNOWN (525)",
+	"UNKNOWN (526)",
+	"UNKNOWN (527)",
+	"WM_PARENTNOTIFY",
+	"WM_ENTERMENULOOP",
+	"WM_EXITMENULOOP",
+	"WM_NEXTMENU",
+	"WM_SIZING",
+	"WM_CAPTURECHANGED",
+	"WM_MOVING",
+	"UNKNOWN (535)",
+	"WM_POWERBROADCAST",
+	"WM_DEVICECHANGE",
+	"UNKNOWN (538)",
+	"UNKNOWN (539)",
+	"UNKNOWN (540)",
+	"UNKNOWN (541)",
+	"UNKNOWN (542)",
+	"UNKNOWN (543)",
+	"WM_MDICREATE",
+	"WM_MDIDESTROY",
+	"WM_MDIACTIVATE",
+	"WM_MDIRESTORE",
+	"WM_MDINEXT",
+	"WM_MDIMAXIMIZE",
+	"WM_MDITILE",
+	"WM_MDICASCADE",
+	"WM_MDIICONARRANGE",
+	"WM_MDIGETACTIVE",
+	"UNKNOWN (554)",
+	"UNKNOWN (555)",
+	"UNKNOWN (556)",
+	"UNKNOWN (557)",
+	"UNKNOWN (558)",
+	"UNKNOWN (559)",
+	"WM_MDISETMENU",
+	"WM_ENTERSIZEMOVE",
+	"WM_EXITSIZEMOVE",
+	"WM_DROPFILES",
+	"WM_MDIREFRESHMENU",
+	"UNKNOWN (565)",
+	"UNKNOWN (566)",
+	"UNKNOWN (567)",
+	"UNKNOWN (568)",
+	"UNKNOWN (569)",
+	"UNKNOWN (570)",
+	"UNKNOWN (571)",
+	"UNKNOWN (572)",
+	"UNKNOWN (573)",
+	"UNKNOWN (574)",
+	"UNKNOWN (575)",
+	"UNKNOWN (576)",
+	"UNKNOWN (577)",
+	"UNKNOWN (578)",
+	"UNKNOWN (579)",
+	"UNKNOWN (580)",
+	"UNKNOWN (581)",
+	"UNKNOWN (582)",
+	"UNKNOWN (583)",
+	"UNKNOWN (584)",
+	"UNKNOWN (585)",
+	"UNKNOWN (586)",
+	"UNKNOWN (587)",
+	"UNKNOWN (588)",
+	"UNKNOWN (589)",
+	"UNKNOWN (590)",
+	"UNKNOWN (591)",
+	"UNKNOWN (592)",
+	"UNKNOWN (593)",
+	"UNKNOWN (594)",
+	"UNKNOWN (595)",
+	"UNKNOWN (596)",
+	"UNKNOWN (597)",
+	"UNKNOWN (598)",
+	"UNKNOWN (599)",
+	"UNKNOWN (600)",
+	"UNKNOWN (601)",
+	"UNKNOWN (602)",
+	"UNKNOWN (603)",
+	"UNKNOWN (604)",
+	"UNKNOWN (605)",
+	"UNKNOWN (606)",
+	"UNKNOWN (607)",
+	"UNKNOWN (608)",
+	"UNKNOWN (609)",
+	"UNKNOWN (610)",
+	"UNKNOWN (611)",
+	"UNKNOWN (612)",
+	"UNKNOWN (613)",
+	"UNKNOWN (614)",
+	"UNKNOWN (615)",
+	"UNKNOWN (616)",
+	"UNKNOWN (617)",
+	"UNKNOWN (618)",
+	"UNKNOWN (619)",
+	"UNKNOWN (620)",
+	"UNKNOWN (621)",
+	"UNKNOWN (622)",
+	"UNKNOWN (623)",
+	"UNKNOWN (624)",
+	"UNKNOWN (625)",
+	"UNKNOWN (626)",
+	"UNKNOWN (627)",
+	"UNKNOWN (628)",
+	"UNKNOWN (629)",
+	"UNKNOWN (630)",
+	"UNKNOWN (631)",
+	"UNKNOWN (632)",
+	"UNKNOWN (633)",
+	"UNKNOWN (634)",
+	"UNKNOWN (635)",
+	"UNKNOWN (636)",
+	"UNKNOWN (637)",
+	"UNKNOWN (638)",
+	"UNKNOWN (639)",
+	"UNKNOWN (640)",
+	"UNKNOWN (641)",
+	"UNKNOWN (642)",
+	"UNKNOWN (643)",
+	"UNKNOWN (644)",
+	"UNKNOWN (645)",
+	"UNKNOWN (646)",
+	"UNKNOWN (647)",
+	"UNKNOWN (648)",
+	"UNKNOWN (649)",
+	"UNKNOWN (650)",
+	"UNKNOWN (651)",
+	"UNKNOWN (652)",
+	"UNKNOWN (653)",
+	"UNKNOWN (654)",
+	"UNKNOWN (655)",
+	"UNKNOWN (656)",
+	"UNKNOWN (657)",
+	"UNKNOWN (658)",
+	"UNKNOWN (659)",
+	"UNKNOWN (660)",
+	"UNKNOWN (661)",
+	"UNKNOWN (662)",
+	"UNKNOWN (663)",
+	"UNKNOWN (664)",
+	"UNKNOWN (665)",
+	"UNKNOWN (666)",
+	"UNKNOWN (667)",
+	"UNKNOWN (668)",
+	"UNKNOWN (669)",
+	"UNKNOWN (670)",
+	"UNKNOWN (671)",
+	"UNKNOWN (672)",
+	"WM_MOUSEHOVER",
+	"UNKNOWN (674)",
+	"WM_MOUSELEAVE",
+	"UNKNOWN (676)",
+	"UNKNOWN (677)",
+	"UNKNOWN (678)",
+	"UNKNOWN (679)",
+	"UNKNOWN (680)",
+	"UNKNOWN (681)",
+	"UNKNOWN (682)",
+	"UNKNOWN (683)",
+	"UNKNOWN (684)",
+	"UNKNOWN (685)",
+	"UNKNOWN (686)",
+	"UNKNOWN (687)",
+	"UNKNOWN (688)",
+	"UNKNOWN (689)",
+	"UNKNOWN (690)",
+	"UNKNOWN (691)",
+	"UNKNOWN (692)",
+	"UNKNOWN (693)",
+	"UNKNOWN (694)",
+	"UNKNOWN (695)",
+	"UNKNOWN (696)",
+	"UNKNOWN (697)",
+	"UNKNOWN (698)",
+	"UNKNOWN (699)",
+	"UNKNOWN (700)",
+	"UNKNOWN (701)",
+	"UNKNOWN (702)",
+	"UNKNOWN (703)",
+	"UNKNOWN (704)",
+	"UNKNOWN (705)",
+	"UNKNOWN (706)",
+	"UNKNOWN (707)",
+	"UNKNOWN (708)",
+	"UNKNOWN (709)",
+	"UNKNOWN (710)",
+	"UNKNOWN (711)",
+	"UNKNOWN (712)",
+	"UNKNOWN (713)",
+	"UNKNOWN (714)",
+	"UNKNOWN (715)",
+	"UNKNOWN (716)",
+	"UNKNOWN (717)",
+	"UNKNOWN (718)",
+	"UNKNOWN (719)",
+	"UNKNOWN (720)",
+	"UNKNOWN (721)",
+	"UNKNOWN (722)",
+	"UNKNOWN (723)",
+	"UNKNOWN (724)",
+	"UNKNOWN (725)",
+	"UNKNOWN (726)",
+	"UNKNOWN (727)",
+	"UNKNOWN (728)",
+	"UNKNOWN (729)",
+	"UNKNOWN (730)",
+	"UNKNOWN (731)",
+	"UNKNOWN (732)",
+	"UNKNOWN (733)",
+	"UNKNOWN (734)",
+	"UNKNOWN (735)",
+	"UNKNOWN (736)",
+	"UNKNOWN (737)",
+	"UNKNOWN (738)",
+	"UNKNOWN (739)",
+	"UNKNOWN (740)",
+	"UNKNOWN (741)",
+	"UNKNOWN (742)",
+	"UNKNOWN (743)",
+	"UNKNOWN (744)",
+	"UNKNOWN (745)",
+	"UNKNOWN (746)",
+	"UNKNOWN (747)",
+	"UNKNOWN (748)",
+	"UNKNOWN (749)",
+	"UNKNOWN (750)",
+	"UNKNOWN (751)",
+	"UNKNOWN (752)",
+	"UNKNOWN (753)",
+	"UNKNOWN (754)",
+	"UNKNOWN (755)",
+	"UNKNOWN (756)",
+	"UNKNOWN (757)",
+	"UNKNOWN (758)",
+	"UNKNOWN (759)",
+	"UNKNOWN (760)",
+	"UNKNOWN (761)",
+	"UNKNOWN (762)",
+	"UNKNOWN (763)",
+	"UNKNOWN (764)",
+	"UNKNOWN (765)",
+	"UNKNOWN (766)",
+	"UNKNOWN (767)",
+	"WM_CUT",
+	"WM_COPY",
+	"WM_PASTE",
+	"WM_CLEAR",
+	"WM_UNDO",
+	"WM_RENDERFORMAT",
+	"WM_RENDERALLFORMATS",
+	"WM_DESTROYCLIPBOARD",
+	"WM_DRAWCLIPBOARD",
+	"WM_PAINTCLIPBOARD",
+	"WM_VSCROLLCLIPBOARD",
+	"WM_SIZECLIPBOARD",
+	"WM_ASKCBFORMATNAME",
+	"WM_CHANGECBCHAIN",
+	"WM_HSCROLLCLIPBOARD",
+	"WM_QUERYNEWPALETTE",
+	"WM_PALETTEISCHANGING",
+	"WM_PALETTECHANGED",
+	"WM_HOTKEY",
+	"UNKNOWN (787)",
+	"UNKNOWN (788)",
+	"UNKNOWN (789)",
+	"UNKNOWN (790)",
+	"WM_PRINT",
+	"WM_PRINTCLIENT",
+	"UNKNOWN (793)",
+	"UNKNOWN (794)",
+	"UNKNOWN (795)",
+	"UNKNOWN (796)",
+	"UNKNOWN (797)",
+	"UNKNOWN (798)",
+	"UNKNOWN (799)",
+	"UNKNOWN (800)",
+	"UNKNOWN (801)",
+	"UNKNOWN (802)",
+	"UNKNOWN (803)",
+	"UNKNOWN (804)",
+	"UNKNOWN (805)",
+	"UNKNOWN (806)",
+	"UNKNOWN (807)",
+	"UNKNOWN (808)",
+	"UNKNOWN (809)",
+	"UNKNOWN (810)",
+	"UNKNOWN (811)",
+	"UNKNOWN (812)",
+	"UNKNOWN (813)",
+	"UNKNOWN (814)",
+	"UNKNOWN (815)",
+	"UNKNOWN (816)",
+	"UNKNOWN (817)",
+	"UNKNOWN (818)",
+	"UNKNOWN (819)",
+	"UNKNOWN (820)",
+	"UNKNOWN (821)",
+	"UNKNOWN (822)",
+	"UNKNOWN (823)",
+	"UNKNOWN (824)",
+	"UNKNOWN (825)",
+	"UNKNOWN (826)",
+	"UNKNOWN (827)",
+	"UNKNOWN (828)",
+	"UNKNOWN (829)",
+	"UNKNOWN (830)",
+	"UNKNOWN (831)",
+	"UNKNOWN (832)",
+	"UNKNOWN (833)",
+	"UNKNOWN (834)",
+	"UNKNOWN (835)",
+	"UNKNOWN (836)",
+	"UNKNOWN (837)",
+	"UNKNOWN (838)",
+	"UNKNOWN (839)",
+	"UNKNOWN (840)",
+	"UNKNOWN (841)",
+	"UNKNOWN (842)",
+	"UNKNOWN (843)",
+	"UNKNOWN (844)",
+	"UNKNOWN (845)",
+	"UNKNOWN (846)",
+	"UNKNOWN (847)",
+	"UNKNOWN (848)",
+	"UNKNOWN (849)",
+	"UNKNOWN (850)",
+	"UNKNOWN (851)",
+	"UNKNOWN (852)",
+	"UNKNOWN (853)",
+	"UNKNOWN (854)",
+	"UNKNOWN (855)",
+	"WM_HANDHELDFIRST",
+	"UNKNOWN (857)",
+	"UNKNOWN (858)",
+	"UNKNOWN (859)",
+	"UNKNOWN (860)",
+	"UNKNOWN (861)",
+	"UNKNOWN (862)",
+	"WM_HANDHELDLAST",
+	"WM_AFXFIRST",
+	"UNKNOWN (865)",
+	"UNKNOWN (866)",
+	"UNKNOWN (867)",
+	"UNKNOWN (868)",
+	"UNKNOWN (869)",
+	"UNKNOWN (870)",
+	"UNKNOWN (871)",
+	"UNKNOWN (872)",
+	"UNKNOWN (873)",
+	"UNKNOWN (874)",
+	"UNKNOWN (875)",
+	"UNKNOWN (876)",
+	"UNKNOWN (877)",
+	"UNKNOWN (878)",
+	"UNKNOWN (879)",
+	"UNKNOWN (880)",
+	"UNKNOWN (881)",
+	"UNKNOWN (882)",
+	"UNKNOWN (883)",
+	"UNKNOWN (884)",
+	"UNKNOWN (885)",
+	"UNKNOWN (886)",
+	"UNKNOWN (887)",
+	"UNKNOWN (888)",
+	"UNKNOWN (889)",
+	"UNKNOWN (890)",
+	"UNKNOWN (891)",
+	"UNKNOWN (892)",
+	"UNKNOWN (893)",
+	"UNKNOWN (894)",
+	"WM_AFXLAST",
+	"WM_PENWINFIRST",
+	"UNKNOWN (897)",
+	"UNKNOWN (898)",
+	"UNKNOWN (899)",
+	"UNKNOWN (900)",
+	"UNKNOWN (901)",
+	"UNKNOWN (902)",
+	"UNKNOWN (903)",
+	"UNKNOWN (904)",
+	"UNKNOWN (905)",
+	"UNKNOWN (906)",
+	"UNKNOWN (907)",
+	"UNKNOWN (908)",
+	"UNKNOWN (909)",
+	"UNKNOWN (910)",
+	"WM_PENWINLAST",
+	"UNKNOWN (912)",
+	"UNKNOWN (913)",
+	"UNKNOWN (914)",
+	"UNKNOWN (915)",
+	"UNKNOWN (916)",
+	"UNKNOWN (917)",
+	"UNKNOWN (918)",
+	"UNKNOWN (919)",
+	"UNKNOWN (920)",
+	"UNKNOWN (921)",
+	"UNKNOWN (922)",
+	"UNKNOWN (923)",
+	"UNKNOWN (924)",
+	"UNKNOWN (925)",
+	"UNKNOWN (926)",
+	"UNKNOWN (927)",
+	"UNKNOWN (928)",
+	"UNKNOWN (929)",
+	"UNKNOWN (930)",
+	"UNKNOWN (931)",
+	"UNKNOWN (932)",
+	"UNKNOWN (933)",
+	"UNKNOWN (934)",
+	"UNKNOWN (935)",
+	"UNKNOWN (936)",
+	"UNKNOWN (937)",
+	"UNKNOWN (938)",
+	"UNKNOWN (939)",
+	"UNKNOWN (940)",
+	"UNKNOWN (941)",
+	"UNKNOWN (942)",
+	"UNKNOWN (943)",
+	"UNKNOWN (944)",
+	"UNKNOWN (945)",
+	"UNKNOWN (946)",
+	"UNKNOWN (947)",
+	"UNKNOWN (948)",
+	"UNKNOWN (949)",
+	"UNKNOWN (950)",
+	"UNKNOWN (951)",
+	"UNKNOWN (952)",
+	"UNKNOWN (953)",
+	"UNKNOWN (954)",
+	"UNKNOWN (955)",
+	"UNKNOWN (956)",
+	"UNKNOWN (957)",
+	"UNKNOWN (958)",
+	"UNKNOWN (959)",
+	"UNKNOWN (960)",
+	"UNKNOWN (961)",
+	"UNKNOWN (962)",
+	"UNKNOWN (963)",
+	"UNKNOWN (964)",
+	"UNKNOWN (965)",
+	"UNKNOWN (966)",
+	"UNKNOWN (967)",
+	"UNKNOWN (968)",
+	"UNKNOWN (969)",
+	"UNKNOWN (970)",
+	"UNKNOWN (971)",
+	"UNKNOWN (972)",
+	"UNKNOWN (973)",
+	"UNKNOWN (974)",
+	"UNKNOWN (975)",
+	"UNKNOWN (976)",
+	"UNKNOWN (977)",
+	"UNKNOWN (978)",
+	"UNKNOWN (979)",
+	"UNKNOWN (980)",
+	"UNKNOWN (981)",
+	"UNKNOWN (982)",
+	"UNKNOWN (983)",
+	"UNKNOWN (984)",
+	"UNKNOWN (985)",
+	"UNKNOWN (986)",
+	"UNKNOWN (987)",
+	"UNKNOWN (988)",
+	"UNKNOWN (989)",
+	"UNKNOWN (990)",
+	"UNKNOWN (991)",
+	"UNKNOWN (992)",
+	"UNKNOWN (993)",
+	"UNKNOWN (994)",
+	"UNKNOWN (995)",
+	"UNKNOWN (996)",
+	"UNKNOWN (997)",
+	"UNKNOWN (998)",
+	"UNKNOWN (999)",
+	"UNKNOWN (1000)",
+	"UNKNOWN (1001)",
+	"UNKNOWN (1002)",
+	"UNKNOWN (1003)",
+	"UNKNOWN (1004)",
+	"UNKNOWN (1005)",
+	"UNKNOWN (1006)",
+	"UNKNOWN (1007)",
+	"UNKNOWN (1008)",
+	"UNKNOWN (1009)",
+	"UNKNOWN (1010)",
+	"UNKNOWN (1011)",
+	"UNKNOWN (1012)",
+	"UNKNOWN (1013)",
+	"UNKNOWN (1014)",
+	"UNKNOWN (1015)",
+	"UNKNOWN (1016)",
+	"UNKNOWN (1017)",
+	"UNKNOWN (1018)",
+	"UNKNOWN (1019)",
+	"UNKNOWN (1020)",
+	"UNKNOWN (1021)",
+	"UNKNOWN (1022)",
+	"UNKNOWN (1023)",
+	"WM_USER"
+};
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,13 @@
+
+## Makefile.am for SDL using the Win32 DIB video driver
+
+noinst_LTLIBRARIES = libvideo_windib.la
+libvideo_windib_la_SOURCES = $(WINDIB_SRCS)
+
+# The SDL Win32 DIB video driver sources
+WINDIB_SRCS = 			\
+	SDL_dibevents.c		\
+	SDL_dibevents_c.h	\
+	SDL_dibvideo.c		\
+	SDL_dibvideo.h		\
+	SDL_vkeys.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/SDL_dibevents.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,343 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <windows.h>
+
+#include "SDL_events.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_lowvideo.h"
+#include "SDL_dibvideo.h"
+#include "SDL_vkeys.h"
+
+#ifndef WM_APP
+#define WM_APP	0x8000
+#endif
+
+#ifdef _WIN32_WCE
+#define NO_GETKEYBOARDSTATE
+#endif
+
+/* The translation table from a Microsoft VK keysym to a SDL keysym */
+static SDLKey VK_keymap[SDLK_LAST];
+static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed);
+
+/* Masks for processing the windows KEYDOWN and KEYUP messages */
+#define REPEATED_KEYMASK	(1<<30)
+#define EXTENDED_KEYMASK	(1<<24)
+
+/* The main Win32 event handler */
+LONG
+ DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	extern int posted;
+
+	switch (msg) {
+		case WM_SYSKEYDOWN:
+		case WM_KEYDOWN: {
+			SDL_keysym keysym;
+
+			/* Ignore repeated keys */
+			if ( lParam&REPEATED_KEYMASK ) {
+				return(0);
+			}
+			switch (wParam) {
+				case VK_CONTROL:
+					if ( lParam&EXTENDED_KEYMASK )
+						wParam = VK_RCONTROL;
+					else
+						wParam = VK_LCONTROL;
+					break;
+				case VK_SHIFT:
+					/* EXTENDED trick doesn't work here */
+					wParam = VK_LSHIFT;
+					break;
+				case VK_MENU:
+					if ( lParam&EXTENDED_KEYMASK )
+						wParam = VK_RMENU;
+					else
+						wParam = VK_LMENU;
+					break;
+			}
+			posted = SDL_PrivateKeyboard(SDL_PRESSED,
+				TranslateKey(wParam,HIWORD(lParam),&keysym,1));
+		}
+		return(0);
+
+		case WM_SYSKEYUP:
+		case WM_KEYUP: {
+			SDL_keysym keysym;
+
+			switch (wParam) {
+				case VK_CONTROL:
+					if ( lParam&EXTENDED_KEYMASK )
+						wParam = VK_RCONTROL;
+					else
+						wParam = VK_LCONTROL;
+					break;
+				case VK_SHIFT:
+					/* EXTENDED trick doesn't work here */
+					wParam = VK_LSHIFT;
+					break;
+				case VK_MENU:
+					if ( lParam&EXTENDED_KEYMASK )
+						wParam = VK_RMENU;
+					else
+						wParam = VK_LMENU;
+					break;
+			}
+			posted = SDL_PrivateKeyboard(SDL_RELEASED,
+				TranslateKey(wParam,HIWORD(lParam),&keysym,0));
+		}
+		return(0);
+
+		default: {
+			/* Only post the event if we're watching for it */
+			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+			        SDL_SysWMmsg wmmsg;
+
+				SDL_VERSION(&wmmsg.version);
+				wmmsg.hwnd = hwnd;
+				wmmsg.msg = msg;
+				wmmsg.wParam = wParam;
+				wmmsg.lParam = lParam;
+				posted = SDL_PrivateSysWMEvent(&wmmsg);
+			}
+		}
+		break;
+	}
+	return(DefWindowProc(hwnd, msg, wParam, lParam));
+}
+
+void DIB_PumpEvents(_THIS)
+{
+	MSG msg;
+
+	while ( PeekMessage(&msg, NULL, 0, (WM_APP-1), PM_NOREMOVE) ) {
+		if ( GetMessage(&msg, NULL, 0, (WM_APP-1)) > 0 ) {
+			DispatchMessage(&msg);
+		}
+	}
+}
+
+void DIB_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Map the VK keysyms */
+	for ( i=0; i<SDL_TABLESIZE(VK_keymap); ++i )
+		VK_keymap[i] = SDLK_UNKNOWN;
+
+	VK_keymap[VK_BACK] = SDLK_BACKSPACE;
+	VK_keymap[VK_TAB] = SDLK_TAB;
+	VK_keymap[VK_CLEAR] = SDLK_CLEAR;
+	VK_keymap[VK_RETURN] = SDLK_RETURN;
+	VK_keymap[VK_PAUSE] = SDLK_PAUSE;
+	VK_keymap[VK_ESCAPE] = SDLK_ESCAPE;
+	VK_keymap[VK_SPACE] = SDLK_SPACE;
+	VK_keymap[VK_APOSTROPHE] = SDLK_QUOTE;
+	VK_keymap[VK_COMMA] = SDLK_COMMA;
+	VK_keymap[VK_MINUS] = SDLK_MINUS;
+	VK_keymap[VK_PERIOD] = SDLK_PERIOD;
+	VK_keymap[VK_SLASH] = SDLK_SLASH;
+	VK_keymap[VK_0] = SDLK_0;
+	VK_keymap[VK_1] = SDLK_1;
+	VK_keymap[VK_2] = SDLK_2;
+	VK_keymap[VK_3] = SDLK_3;
+	VK_keymap[VK_4] = SDLK_4;
+	VK_keymap[VK_5] = SDLK_5;
+	VK_keymap[VK_6] = SDLK_6;
+	VK_keymap[VK_7] = SDLK_7;
+	VK_keymap[VK_8] = SDLK_8;
+	VK_keymap[VK_9] = SDLK_9;
+	VK_keymap[VK_SEMICOLON] = SDLK_SEMICOLON;
+	VK_keymap[VK_EQUALS] = SDLK_EQUALS;
+	VK_keymap[VK_LBRACKET] = SDLK_LEFTBRACKET;
+	VK_keymap[VK_BACKSLASH] = SDLK_BACKSLASH;
+	VK_keymap[VK_RBRACKET] = SDLK_RIGHTBRACKET;
+	VK_keymap[VK_GRAVE] = SDLK_BACKQUOTE;
+	VK_keymap[VK_A] = SDLK_a;
+	VK_keymap[VK_B] = SDLK_b;
+	VK_keymap[VK_C] = SDLK_c;
+	VK_keymap[VK_D] = SDLK_d;
+	VK_keymap[VK_E] = SDLK_e;
+	VK_keymap[VK_F] = SDLK_f;
+	VK_keymap[VK_G] = SDLK_g;
+	VK_keymap[VK_H] = SDLK_h;
+	VK_keymap[VK_I] = SDLK_i;
+	VK_keymap[VK_J] = SDLK_j;
+	VK_keymap[VK_K] = SDLK_k;
+	VK_keymap[VK_L] = SDLK_l;
+	VK_keymap[VK_M] = SDLK_m;
+	VK_keymap[VK_N] = SDLK_n;
+	VK_keymap[VK_O] = SDLK_o;
+	VK_keymap[VK_P] = SDLK_p;
+	VK_keymap[VK_Q] = SDLK_q;
+	VK_keymap[VK_R] = SDLK_r;
+	VK_keymap[VK_S] = SDLK_s;
+	VK_keymap[VK_T] = SDLK_t;
+	VK_keymap[VK_U] = SDLK_u;
+	VK_keymap[VK_V] = SDLK_v;
+	VK_keymap[VK_W] = SDLK_w;
+	VK_keymap[VK_X] = SDLK_x;
+	VK_keymap[VK_Y] = SDLK_y;
+	VK_keymap[VK_Z] = SDLK_z;
+	VK_keymap[VK_DELETE] = SDLK_DELETE;
+
+	VK_keymap[VK_NUMPAD0] = SDLK_KP0;
+	VK_keymap[VK_NUMPAD1] = SDLK_KP1;
+	VK_keymap[VK_NUMPAD2] = SDLK_KP2;
+	VK_keymap[VK_NUMPAD3] = SDLK_KP3;
+	VK_keymap[VK_NUMPAD4] = SDLK_KP4;
+	VK_keymap[VK_NUMPAD5] = SDLK_KP5;
+	VK_keymap[VK_NUMPAD6] = SDLK_KP6;
+	VK_keymap[VK_NUMPAD7] = SDLK_KP7;
+	VK_keymap[VK_NUMPAD8] = SDLK_KP8;
+	VK_keymap[VK_NUMPAD9] = SDLK_KP9;
+	VK_keymap[VK_DECIMAL] = SDLK_KP_PERIOD;
+	VK_keymap[VK_DIVIDE] = SDLK_KP_DIVIDE;
+	VK_keymap[VK_MULTIPLY] = SDLK_KP_MULTIPLY;
+	VK_keymap[VK_SUBTRACT] = SDLK_KP_MINUS;
+	VK_keymap[VK_ADD] = SDLK_KP_PLUS;
+
+	VK_keymap[VK_UP] = SDLK_UP;
+	VK_keymap[VK_DOWN] = SDLK_DOWN;
+	VK_keymap[VK_RIGHT] = SDLK_RIGHT;
+	VK_keymap[VK_LEFT] = SDLK_LEFT;
+	VK_keymap[VK_INSERT] = SDLK_INSERT;
+	VK_keymap[VK_HOME] = SDLK_HOME;
+	VK_keymap[VK_END] = SDLK_END;
+	VK_keymap[VK_PRIOR] = SDLK_PAGEUP;
+	VK_keymap[VK_NEXT] = SDLK_PAGEDOWN;
+
+	VK_keymap[VK_F1] = SDLK_F1;
+	VK_keymap[VK_F2] = SDLK_F2;
+	VK_keymap[VK_F3] = SDLK_F3;
+	VK_keymap[VK_F4] = SDLK_F4;
+	VK_keymap[VK_F5] = SDLK_F5;
+	VK_keymap[VK_F6] = SDLK_F6;
+	VK_keymap[VK_F7] = SDLK_F7;
+	VK_keymap[VK_F8] = SDLK_F8;
+	VK_keymap[VK_F9] = SDLK_F9;
+	VK_keymap[VK_F10] = SDLK_F10;
+	VK_keymap[VK_F11] = SDLK_F11;
+	VK_keymap[VK_F12] = SDLK_F12;
+	VK_keymap[VK_F13] = SDLK_F13;
+	VK_keymap[VK_F14] = SDLK_F14;
+	VK_keymap[VK_F15] = SDLK_F15;
+
+	VK_keymap[VK_NUMLOCK] = SDLK_NUMLOCK;
+	VK_keymap[VK_CAPITAL] = SDLK_CAPSLOCK;
+	VK_keymap[VK_SCROLL] = SDLK_SCROLLOCK;
+	VK_keymap[VK_RSHIFT] = SDLK_RSHIFT;
+	VK_keymap[VK_LSHIFT] = SDLK_LSHIFT;
+	VK_keymap[VK_RCONTROL] = SDLK_RCTRL;
+	VK_keymap[VK_LCONTROL] = SDLK_LCTRL;
+	VK_keymap[VK_RMENU] = SDLK_RALT;
+	VK_keymap[VK_LMENU] = SDLK_LALT;
+	VK_keymap[VK_RWIN] = SDLK_RSUPER;
+	VK_keymap[VK_LWIN] = SDLK_LSUPER;
+
+	VK_keymap[VK_HELP] = SDLK_HELP;
+#ifdef VK_PRINT
+	VK_keymap[VK_PRINT] = SDLK_PRINT;
+#endif
+	VK_keymap[VK_SNAPSHOT] = SDLK_PRINT;
+	VK_keymap[VK_CANCEL] = SDLK_BREAK;
+	VK_keymap[VK_APPS] = SDLK_MENU;
+}
+
+static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, int pressed)
+{
+	/* Set the keysym information */
+	keysym->scancode = (unsigned char) scancode;
+	keysym->sym = VK_keymap[vkey];
+	keysym->mod = KMOD_NONE;
+	keysym->unicode = 0;
+	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
+#ifdef NO_GETKEYBOARDSTATE
+		/* Uh oh, better hope the vkey is close enough.. */
+		keysym->unicode = vkey;
+#else
+		BYTE keystate[256];
+		BYTE chars[2];
+
+		GetKeyboardState(keystate);
+		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
+			keysym->unicode = chars[0];
+		}
+#endif /* NO_GETKEYBOARDSTATE */
+	}
+	return(keysym);
+}
+
+int DIB_CreateWindow(_THIS)
+{
+#ifdef _WIN32_WCE
+	/* WinCE uses the UNICODE version */
+	int nLen = strlen(SDL_Appname);
+	LPWSTR lpszW = alloca((nLen+1)*2);
+	MultiByteToWideChar(CP_ACP, 0, SDL_Appname, -1, lpszW, nLen);
+
+	SDL_RegisterApp("SDL_app", 0, 0);
+	SDL_Window = CreateWindow(lpszW, lpszW,
+                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
+                                 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
+	if ( SDL_Window == NULL ) {
+		SDL_SetError("Couldn't create window");
+		return(-1);
+	}
+	ShowWindow(SDL_Window, SW_HIDE);
+#else
+	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
+	if ( SDL_windowid ) {
+		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
+	} else {
+		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
+                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
+                                 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
+		if ( SDL_Window == NULL ) {
+			SDL_SetError("Couldn't create window");
+			return(-1);
+		}
+		ShowWindow(SDL_Window, SW_HIDE);
+	}
+#endif /* _WIN32_WCE */
+
+	return(0);
+}
+
+void DIB_DestroyWindow(_THIS)
+{
+	if ( SDL_windowid == NULL ) {
+		DestroyWindow(SDL_Window);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/SDL_dibevents_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Variables and functions exported by SDL_dibevents.c to other parts 
+   of the native video subsystem (SDL_dibvideo.c)
+*/
+extern LONG
+ DIB_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+extern int DIB_CreateWindow(_THIS);
+extern void DIB_DestroyWindow(_THIS);
+
+extern void DIB_PumpEvents(_THIS);
+extern void DIB_InitOSKeymap(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/SDL_dibvideo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,925 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <windows.h>
+
+/* Not yet in the mingw32 cross-compile headers */
+#ifndef CDS_FULLSCREEN
+#define CDS_FULLSCREEN	4
+#endif
+
+#include "SDL.h"
+#include "SDL_mutex.h"
+#include "SDL_syswm.h"
+#include "SDL_sysvideo.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_dibvideo.h"
+#include "SDL_syswm_c.h"
+#include "SDL_sysmouse_c.h"
+#include "SDL_dibevents_c.h"
+#include "SDL_wingl_c.h"
+
+#ifdef _WIN32_WCE
+#define NO_GETDIBITS
+#define NO_CHANGEDISPLAYSETTINGS
+#define NO_GAMMA_SUPPORT
+#endif
+
+/* Initialization/Query functions */
+static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int DIB_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static void DIB_CheckGamma(_THIS);
+static void DIB_SwapGamma(_THIS);
+static void DIB_QuitGamma(_THIS);
+#ifndef NO_GAMMA_SUPPORT
+static int DIB_SetGammaRamp(_THIS, Uint16 *ramp);
+static int DIB_GetGammaRamp(_THIS, Uint16 *ramp);
+#endif
+static void DIB_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int DIB_LockHWSurface(_THIS, SDL_Surface *surface);
+static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+/* Windows message handling functions */
+static void DIB_RealizePalette(_THIS);
+static void DIB_PaletteChanged(_THIS, HWND window);
+static void DIB_WinPAINT(_THIS, HDC hdc);
+
+/* helper fn */
+static int DIB_SussScreenDepth();
+
+/* DIB driver bootstrap functions */
+
+static int DIB_Available(void)
+{
+	return(1);
+}
+
+static void DIB_DeleteDevice(SDL_VideoDevice *device)
+{
+	if ( device ) {
+		if ( device->hidden ) {
+			free(device->hidden);
+		}
+		if ( device->gl_data ) {
+			free(device->gl_data);
+		}
+		free(device);
+	}
+}
+
+static SDL_VideoDevice *DIB_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+		device->gl_data = (struct SDL_PrivateGLData *)
+				malloc((sizeof *device->gl_data));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ||
+		                 (device->gl_data == NULL) ) {
+		SDL_OutOfMemory();
+		DIB_DeleteDevice(device);
+		return(NULL);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+	memset(device->gl_data, 0, (sizeof *device->gl_data));
+
+	/* Set the function pointers */
+	device->VideoInit = DIB_VideoInit;
+	device->ListModes = DIB_ListModes;
+	device->SetVideoMode = DIB_SetVideoMode;
+	device->UpdateMouse = WIN_UpdateMouse;
+	device->SetColors = DIB_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = DIB_VideoQuit;
+	device->AllocHWSurface = DIB_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = DIB_LockHWSurface;
+	device->UnlockHWSurface = DIB_UnlockHWSurface;
+	device->FlipHWSurface = NULL;
+	device->FreeHWSurface = DIB_FreeHWSurface;
+#ifndef NO_GAMMA_SUPPORT
+	device->SetGammaRamp = DIB_SetGammaRamp;
+	device->GetGammaRamp = DIB_GetGammaRamp;
+#endif
+#ifdef HAVE_OPENGL
+        device->GL_LoadLibrary = WIN_GL_LoadLibrary;
+        device->GL_GetProcAddress = WIN_GL_GetProcAddress;
+        device->GL_GetAttribute = WIN_GL_GetAttribute;
+        device->GL_MakeCurrent = WIN_GL_MakeCurrent;
+        device->GL_SwapBuffers = WIN_GL_SwapBuffers;
+#endif
+	device->SetCaption = WIN_SetWMCaption;
+	device->SetIcon = WIN_SetWMIcon;
+	device->IconifyWindow = WIN_IconifyWindow;
+	device->GrabInput = WIN_GrabInput;
+	device->GetWMInfo = WIN_GetWMInfo;
+	device->FreeWMCursor = WIN_FreeWMCursor;
+	device->CreateWMCursor = WIN_CreateWMCursor;
+	device->ShowWMCursor = WIN_ShowWMCursor;
+	device->WarpWMCursor = WIN_WarpWMCursor;
+	device->CheckMouseMode = WIN_CheckMouseMode;
+	device->InitOSKeymap = DIB_InitOSKeymap;
+	device->PumpEvents = DIB_PumpEvents;
+
+	/* Set up the windows message handling functions */
+	WIN_RealizePalette = DIB_RealizePalette;
+	WIN_PaletteChanged = DIB_PaletteChanged;
+	WIN_SwapGamma = DIB_SwapGamma;
+	WIN_WinPAINT = DIB_WinPAINT;
+	HandleMessage = DIB_HandleMessage;
+
+	device->free = DIB_DeleteDevice;
+
+	/* We're finally ready */
+	return device;
+}
+
+VideoBootStrap WINDIB_bootstrap = {
+	"windib", "Win95/98/NT/2000 GDI",
+	DIB_Available, DIB_CreateDevice
+};
+
+#ifndef NO_CHANGEDISPLAYSETTINGS
+
+static int cmpmodes(const void *va, const void *vb)
+{
+    SDL_Rect *a = *(SDL_Rect **)va;
+    SDL_Rect *b = *(SDL_Rect **)vb;
+    if(a->w > b->w)
+        return -1;
+    return b->h - a->h;
+}
+
+static int DIB_AddMode(_THIS, int bpp, int w, int h)
+{
+	SDL_Rect *mode;
+	int i, index;
+	int next_mode;
+
+	/* Check to see if we already have this mode */
+	if ( bpp < 8 ) {  /* Not supported */
+		return(0);
+	}
+	index = ((bpp+7)/8)-1;
+	for ( i=0; i<SDL_nummodes[index]; ++i ) {
+		mode = SDL_modelist[index][i];
+		if ( (mode->w == w) && (mode->h == h) ) {
+			return(0);
+		}
+	}
+
+	/* Set up the new video mode rectangle */
+	mode = (SDL_Rect *)malloc(sizeof *mode);
+	if ( mode == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	mode->x = 0;
+	mode->y = 0;
+	mode->w = w;
+	mode->h = h;
+
+	/* Allocate the new list of modes, and fill in the new mode */
+	next_mode = SDL_nummodes[index];
+	SDL_modelist[index] = (SDL_Rect **)
+	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist[index] == NULL ) {
+		SDL_OutOfMemory();
+		SDL_nummodes[index] = 0;
+		free(mode);
+		return(-1);
+	}
+	SDL_modelist[index][next_mode] = mode;
+	SDL_modelist[index][next_mode+1] = NULL;
+	SDL_nummodes[index]++;
+
+	return(0);
+}
+
+#endif /* !NO_CHANGEDISPLAYSETTINGS */
+
+static HPALETTE DIB_CreatePalette(int bpp)
+{
+/*	RJR: March 28, 2000
+	moved palette creation here from "DIB_VideoInit" */
+
+	HPALETTE handle = NULL;
+	
+	if ( bpp <= 8 )
+	{
+		LOGPALETTE *palette;
+		HDC hdc;
+		int ncolors;
+		int i;
+
+		ncolors = 1;
+		for ( i=0; i<bpp; ++i ) {
+			ncolors *= 2;
+		}
+		palette = (LOGPALETTE *)malloc(sizeof(*palette)+
+					ncolors*sizeof(PALETTEENTRY));
+		palette->palVersion = 0x300;
+		palette->palNumEntries = ncolors;
+		hdc = GetDC(SDL_Window);
+		GetSystemPaletteEntries(hdc, 0, ncolors, palette->palPalEntry);
+		ReleaseDC(SDL_Window, hdc);
+		handle = CreatePalette(palette);
+		free(palette);
+	}
+	
+	return handle;
+}
+
+int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+#ifndef NO_CHANGEDISPLAYSETTINGS
+	int i;
+	DEVMODE settings;
+#endif
+
+	/* Create the window */
+	if ( DIB_CreateWindow(this) < 0 ) {
+		return(-1);
+	}
+	DX5_SoundFocus(SDL_Window);
+
+	/* Determine the screen depth */
+	vformat->BitsPerPixel = DIB_SussScreenDepth();
+	switch (vformat->BitsPerPixel) {
+		case 15:
+			vformat->Rmask = 0x00007c00;
+			vformat->Gmask = 0x000003e0;
+			vformat->Bmask = 0x0000001f;
+			vformat->BitsPerPixel = 16;
+			break;
+		case 16:
+			vformat->Rmask = 0x0000f800;
+			vformat->Gmask = 0x000007e0;
+			vformat->Bmask = 0x0000001f;
+			break;
+		case 24:
+		case 32:
+			/* GDI defined as 8-8-8 */
+			vformat->Rmask = 0x00ff0000;
+			vformat->Gmask = 0x0000ff00;
+			vformat->Bmask = 0x000000ff;
+			break;
+		default:
+			break;
+	}
+
+	/* See if gamma is supported on this screen */
+	DIB_CheckGamma(this);
+
+#ifndef NO_CHANGEDISPLAYSETTINGS
+	/* Query for the list of available video modes */
+	for ( i=0; EnumDisplaySettings(NULL, i, &settings); ++i ) {
+		DIB_AddMode(this, settings.dmBitsPerPel,
+			settings.dmPelsWidth, settings.dmPelsHeight);
+	}
+	/* Sort the mode lists */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_nummodes[i] > 0 ) {
+			qsort(SDL_modelist[i], SDL_nummodes[i], sizeof *SDL_modelist[i], cmpmodes);
+		}
+	}
+#endif /* !NO_CHANGEDISPLAYSETTINGS */
+
+	/* Grab an identity palette if we are in a palettized mode */
+	if ( vformat->BitsPerPixel <= 8 ) {
+	/*	RJR: March 28, 2000
+		moved palette creation to "DIB_CreatePalette" */
+		screen_pal = DIB_CreatePalette(vformat->BitsPerPixel);
+	}
+
+	/* Fill in some window manager capabilities */
+	this->info.wm_available = 1;
+
+	/* We're done! */
+	return(0);
+}
+
+/* We support any format at any dimension */
+SDL_Rect **DIB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+#ifdef NO_CHANGEDISPLAYSETTINGS
+	return((SDL_Rect **)-1);
+#else
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
+	} else {
+		return((SDL_Rect **)-1);
+	}
+#endif
+}
+
+
+/*
+  Helper fn to work out which screen depth windows is currently using.
+  15 bit mode is considered 555 format, 16 bit is 565.
+  returns 0 for unknown mode.
+  (Derived from code in sept 1999 Windows Developer Journal
+  http://www.wdj.com/code/archive.html)
+*/
+static int DIB_SussScreenDepth()
+{
+#ifdef NO_GETDIBITS
+	int depth;
+	HDC hdc;
+
+	hdc = GetDC(SDL_Window);
+	depth = GetDeviceCaps(hdc, PLANES) * GetDeviceCaps(hdc, BITSPIXEL);
+	ReleaseDC(SDL_Window, hdc);
+	if ( depth == 16 ) {
+		depth = 15;	/* GDI defined as RGB 555 */
+	}
+	return(depth);
+#else
+    int dib_size;
+    LPBITMAPINFOHEADER dib_hdr;
+    HDC hdc;
+    HBITMAP hbm;
+
+    /* Allocate enough space for a DIB header plus palette (for
+     * 8-bit modes) or bitfields (for 16- and 32-bit modes)
+     */
+    dib_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD);
+    dib_hdr = (LPBITMAPINFOHEADER) malloc(dib_size);
+    memset(dib_hdr, 0, dib_size);
+    dib_hdr->biSize = sizeof(BITMAPINFOHEADER);
+    
+    /* Get a device-dependent bitmap that's compatible with the
+       screen.
+     */
+    hdc = GetDC(NULL);
+    hbm = CreateCompatibleBitmap( hdc, 1, 1 );
+
+    /* Convert the DDB to a DIB.  We need to call GetDIBits twice:
+     * the first call just fills in the BITMAPINFOHEADER; the 
+     * second fills in the bitfields or palette.
+     */
+    GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
+    GetDIBits(hdc, hbm, 0, 1, NULL, (LPBITMAPINFO) dib_hdr, DIB_RGB_COLORS);
+    DeleteObject(hbm);
+    ReleaseDC(NULL, hdc);
+
+    switch( dib_hdr->biBitCount )
+    {
+    case 8:     return 8;
+    case 24:    return 24;
+    case 32:    return 32;
+    case 16:
+        if( dib_hdr->biCompression == BI_BITFIELDS ) {
+            /* check the red mask */
+            switch( ((DWORD*)((char*)dib_hdr + dib_hdr->biSize))[0] ) {
+                case 0xf800: return 16;    /* 565 */
+                case 0x7c00: return 15;    /* 555 */
+            }
+        }
+    }
+    return 0;    /* poo. */
+#endif /* NO_GETDIBITS */
+}
+
+
+/* Various screen update functions available */
+static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	SDL_Surface *video;
+	Uint32 prev_flags;
+	DWORD style;
+	const DWORD directstyle =
+			(WS_POPUP);
+	const DWORD windowstyle = 
+			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
+	const DWORD resizestyle =
+			(WS_THICKFRAME|WS_MAXIMIZEBOX);
+	int binfo_size;
+	BITMAPINFO *binfo;
+	HDC hdc;
+	RECT bounds;
+	int x, y;
+	BOOL was_visible;
+	Uint32 Rmask, Gmask, Bmask;
+
+	/* See whether or not we should center the window */
+	was_visible = IsWindowVisible(SDL_Window);
+
+	/* Clean up any GL context that may be hanging around */
+	if ( current->flags & SDL_OPENGL ) {
+		WIN_GL_ShutDown(this);
+	}
+
+	/* Recalculate the bitmasks if necessary */
+	if ( bpp == current->format->BitsPerPixel ) {
+		video = current;
+	} else {
+		switch (bpp) {
+			case 15:
+			case 16:
+				if ( DIB_SussScreenDepth() == 15 ) {
+					/* 5-5-5 */
+					Rmask = 0x00007c00;
+					Gmask = 0x000003e0;
+					Bmask = 0x0000001f;
+				} else {
+					/* 5-6-5 */
+					Rmask = 0x0000f800;
+					Gmask = 0x000007e0;
+					Bmask = 0x0000001f;
+				}
+				break;
+			case 24:
+			case 32:
+				/* GDI defined as 8-8-8 */
+				Rmask = 0x00ff0000;
+				Gmask = 0x0000ff00;
+				Bmask = 0x000000ff;
+				break;
+			default:
+				Rmask = 0x00000000;
+				Gmask = 0x00000000;
+				Bmask = 0x00000000;
+				break;
+		}
+		video = SDL_CreateRGBSurface(SDL_SWSURFACE,
+					0, 0, bpp, Rmask, Gmask, Bmask, 0);
+		if ( video == NULL ) {
+			SDL_OutOfMemory();
+			return(NULL);
+		}
+	}
+
+	/* Fill in part of the video surface */
+	prev_flags = video->flags;
+	video->flags = 0;	/* Clear flags */
+	video->w = width;
+	video->h = height;
+	video->pitch = SDL_CalculatePitch(video);
+
+#ifndef NO_CHANGEDISPLAYSETTINGS
+	/* Set fullscreen mode if appropriate */
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		DEVMODE settings;
+
+		memset(&settings, 0, sizeof(DEVMODE));
+		settings.dmSize = sizeof(DEVMODE);
+		settings.dmBitsPerPel = video->format->BitsPerPixel;
+		settings.dmPelsWidth = width;
+		settings.dmPelsHeight = height;
+		settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
+		if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
+			video->flags |= SDL_FULLSCREEN;
+			if ( screen_pal != NULL ) {
+			/*	RJR: March 28, 2000
+				delete identity palette if switching from a palettized mode */
+				DeleteObject(screen_pal);
+				screen_pal = NULL;
+			}
+			if ( bpp <= 8 )
+			{
+			/*	RJR: March 28, 2000
+				create identity palette switching to a palettized mode */
+				screen_pal = DIB_CreatePalette(bpp);
+			}
+		}
+	}
+#endif /* !NO_CHANGEDISPLAYSETTINGS */
+
+	style = GetWindowLong(SDL_Window, GWL_STYLE);
+	style &= ~(resizestyle|WS_MAXIMIZE);
+	if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		style &= ~windowstyle;
+		style |= directstyle;
+	} else {
+#ifndef NO_CHANGEDISPLAYSETTINGS
+		if ( (prev_flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			ChangeDisplaySettings(NULL, 0);
+		}
+#endif
+		if ( flags & SDL_NOFRAME ) {
+			style &= ~windowstyle;
+			style |= directstyle;
+			video->flags |= SDL_NOFRAME;
+		} else {
+			style &= ~directstyle;
+			style |= windowstyle;
+			if ( flags & SDL_RESIZABLE ) {
+				style |= resizestyle;
+				video->flags |= SDL_RESIZABLE;
+			}
+		}
+		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
+	}
+	SetWindowLong(SDL_Window, GWL_STYLE, style);
+
+	/* Delete the old bitmap if necessary */
+	if ( screen_bmp != NULL ) {
+		DeleteObject(screen_bmp);
+	}
+	if ( ! (flags & SDL_OPENGL) ) {
+		BOOL is16bitmode = (video->format->BytesPerPixel == 2);
+
+		/* Suss out the bitmap info header */
+		binfo_size = sizeof(*binfo);
+		if( is16bitmode ) {
+			/* 16bit modes, palette area used for rgb bitmasks */
+			binfo_size += 3*sizeof(DWORD);
+		} else if ( video->format->palette ) {
+			binfo_size += video->format->palette->ncolors *
+							sizeof(RGBQUAD);
+		}
+		binfo = (BITMAPINFO *)malloc(binfo_size);
+		if ( ! binfo ) {
+			if ( video != current ) {
+				SDL_FreeSurface(video);
+			}
+			SDL_OutOfMemory();
+			return(NULL);
+		}
+
+		binfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
+		binfo->bmiHeader.biWidth = video->w;
+		binfo->bmiHeader.biHeight = -video->h;	/* -ve for topdown bitmap */
+		binfo->bmiHeader.biPlanes = 1;
+		binfo->bmiHeader.biSizeImage = video->h * video->pitch;
+		binfo->bmiHeader.biXPelsPerMeter = 0;
+		binfo->bmiHeader.biYPelsPerMeter = 0;
+		binfo->bmiHeader.biClrUsed = 0;
+		binfo->bmiHeader.biClrImportant = 0;
+		binfo->bmiHeader.biBitCount = video->format->BitsPerPixel;
+
+		if ( is16bitmode ) {
+			/* BI_BITFIELDS tells CreateDIBSection about the rgb masks in the palette */
+			binfo->bmiHeader.biCompression = BI_BITFIELDS;
+			((Uint32*)binfo->bmiColors)[0] = video->format->Rmask;
+			((Uint32*)binfo->bmiColors)[1] = video->format->Gmask;
+			((Uint32*)binfo->bmiColors)[2] = video->format->Bmask;
+		} else {
+			binfo->bmiHeader.biCompression = BI_RGB;	/* BI_BITFIELDS for 565 vs 555 */
+			if ( video->format->palette ) {
+				memset(binfo->bmiColors, 0,
+					video->format->palette->ncolors*sizeof(RGBQUAD));
+			}
+		}
+
+		/* Create the offscreen bitmap buffer */
+		hdc = GetDC(SDL_Window);
+		screen_bmp = CreateDIBSection(hdc, binfo, DIB_RGB_COLORS,
+					(void **)(&video->pixels), NULL, 0);
+		ReleaseDC(SDL_Window, hdc);
+		free(binfo);
+		if ( screen_bmp == NULL ) {
+			if ( video != current ) {
+				SDL_FreeSurface(video);
+			}
+			SDL_SetError("Couldn't create DIB section");
+			return(NULL);
+		}
+		this->UpdateRects = DIB_NormalUpdate;
+
+		/* Set video surface flags */
+		if ( bpp <= 8 ) {
+			/* BitBlt() maps colors for us */
+			video->flags |= SDL_HWPALETTE;
+		}
+	}
+
+	/* Resize the window */
+	if ( SDL_windowid == NULL ) {
+		UINT swp_flags;
+
+		SDL_resizing = 1;
+		bounds.left = 0;
+		bounds.top = 0;
+		bounds.right = video->w;
+		bounds.bottom = video->h;
+		AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
+		width = bounds.right-bounds.left;
+		height = bounds.bottom-bounds.top;
+		x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
+		y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
+		if ( y < 0 ) { /* Cover up title bar for more client area */
+			y -= GetSystemMetrics(SM_CYCAPTION)/2;
+		}
+		swp_flags = (SWP_NOCOPYBITS | SWP_NOZORDER | SWP_SHOWWINDOW);
+		if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
+			swp_flags |= SWP_NOMOVE;
+		}
+		SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags);
+		SDL_resizing = 0;
+		SetForegroundWindow(SDL_Window);
+	}
+
+	/* Set up for OpenGL */
+	if ( flags & SDL_OPENGL ) {
+		if ( WIN_GL_SetupWindow(this) < 0 ) {
+			return(NULL);
+		}
+		video->flags |= SDL_OPENGL;
+	}
+	/* We're live! */
+	return(video);
+}
+
+/* We don't actually allow hardware surfaces in the DIB driver */
+static int DIB_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+static void DIB_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+static int DIB_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+static void DIB_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+static void DIB_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	HDC hdc, mdc;
+	int i;
+
+	hdc = GetDC(SDL_Window);
+	if ( screen_pal ) {
+		SelectPalette(hdc, screen_pal, FALSE);
+	}
+	mdc = CreateCompatibleDC(hdc);
+	SelectObject(mdc, screen_bmp);
+	for ( i=0; i<numrects; ++i ) {
+		BitBlt(hdc, rects[i].x, rects[i].y, rects[i].w, rects[i].h,
+					mdc, rects[i].x, rects[i].y, SRCCOPY);
+	}
+	DeleteDC(mdc);
+	ReleaseDC(SDL_Window, hdc);
+}
+
+int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	RGBQUAD *pal;
+	int i;
+	HDC hdc, mdc;
+
+	/* Update the display palette */
+	hdc = GetDC(SDL_Window);
+	if ( screen_pal ) {
+		PALETTEENTRY *entries;
+
+		entries = (PALETTEENTRY *)alloca(ncolors*sizeof(PALETTEENTRY));
+		for ( i=0; i<ncolors; ++i ) {
+			entries[i].peRed   = colors[i].r;
+			entries[i].peGreen = colors[i].g;
+			entries[i].peBlue  = colors[i].b;
+			entries[i].peFlags = PC_NOCOLLAPSE;
+		}
+		SetPaletteEntries(screen_pal, firstcolor, ncolors, entries);
+		SelectPalette(hdc, screen_pal, FALSE);
+		RealizePalette(hdc);
+	}
+
+	/* Copy palette colors into DIB palette */
+	pal = (RGBQUAD *)alloca(ncolors*sizeof(RGBQUAD));
+	for ( i=0; i<ncolors; ++i ) {
+		pal[i].rgbRed = colors[i].r;
+		pal[i].rgbGreen = colors[i].g;
+		pal[i].rgbBlue = colors[i].b;
+		pal[i].rgbReserved = 0;
+	}
+
+	/* Set the DIB palette and update the display */
+	mdc = CreateCompatibleDC(hdc);
+	SelectObject(mdc, screen_bmp);
+	SetDIBColorTable(mdc, firstcolor, ncolors, pal);
+	BitBlt(hdc, 0, 0, this->screen->w, this->screen->h,
+	       mdc, 0, 0, SRCCOPY);
+	DeleteDC(mdc);
+	ReleaseDC(SDL_Window, hdc);
+	return(1);
+}
+
+static void DIB_CheckGamma(_THIS)
+{
+#ifndef NO_GAMMA_SUPPORT
+	HDC hdc;
+	WORD ramp[3*256];
+
+	/* If we fail to get gamma, disable gamma control */
+	hdc = GetDC(SDL_Window);
+	if ( ! GetDeviceGammaRamp(hdc, ramp) ) {
+		this->GetGammaRamp = NULL;
+		this->SetGammaRamp = NULL;
+	}
+	ReleaseDC(SDL_Window, hdc);
+#endif /* !NO_GAMMA_SUPPORT */
+}
+static void DIB_SwapGamma(_THIS)
+{
+#ifndef NO_GAMMA_SUPPORT
+	HDC hdc;
+
+	if ( gamma_saved ) {
+		hdc = GetDC(SDL_Window);
+		if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+			/* About to leave active state, restore gamma */
+			SetDeviceGammaRamp(hdc, gamma_saved);
+		} else {
+			/* About to enter active state, set game gamma */
+			GetDeviceGammaRamp(hdc, gamma_saved);
+			SetDeviceGammaRamp(hdc, this->gamma);
+		}
+		ReleaseDC(SDL_Window, hdc);
+	}
+#endif /* !NO_GAMMA_SUPPORT */
+}
+static void DIB_QuitGamma(_THIS)
+{
+#ifndef NO_GAMMA_SUPPORT
+	if ( gamma_saved ) {
+		/* Restore the original gamma if necessary */
+		if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+			HDC hdc;
+
+			hdc = GetDC(SDL_Window);
+			SetDeviceGammaRamp(hdc, gamma_saved);
+			ReleaseDC(SDL_Window, hdc);
+		}
+
+		/* Free the saved gamma memory */
+		free(gamma_saved);
+		gamma_saved = 0;
+	}
+#endif /* !NO_GAMMA_SUPPORT */
+}
+
+#ifndef NO_GAMMA_SUPPORT
+
+static int DIB_SetGammaRamp(_THIS, Uint16 *ramp)
+{
+	HDC hdc;
+	BOOL succeeded;
+
+	/* Set the ramp for the display */
+	if ( ! gamma_saved ) {
+		gamma_saved = (WORD *)malloc(3*256*sizeof(*gamma_saved));
+		if ( ! gamma_saved ) {
+			SDL_OutOfMemory();
+			return -1;
+		}
+		hdc = GetDC(SDL_Window);
+		GetDeviceGammaRamp(hdc, gamma_saved);
+		ReleaseDC(SDL_Window, hdc);
+	}
+	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+		hdc = GetDC(SDL_Window);
+		succeeded = SetDeviceGammaRamp(hdc, ramp);
+		ReleaseDC(SDL_Window, hdc);
+	} else {
+		succeeded = TRUE;
+	}
+	return succeeded ? 0 : -1;
+}
+
+static int DIB_GetGammaRamp(_THIS, Uint16 *ramp)
+{
+	HDC hdc;
+	BOOL succeeded;
+
+	/* Get the ramp from the display */
+	hdc = GetDC(SDL_Window);
+	succeeded = GetDeviceGammaRamp(hdc, ramp);
+	ReleaseDC(SDL_Window, hdc);
+	return succeeded ? 0 : -1;
+}
+
+#endif /* !NO_GAMMA_SUPPORT */
+
+void DIB_VideoQuit(_THIS)
+{
+	/* Destroy the window and everything associated with it */
+	if ( SDL_Window ) {
+		/* Delete the screen bitmap (also frees screen->pixels) */
+		if ( this->screen ) {
+#ifndef NO_CHANGEDISPLAYSETTINGS
+			if ( this->screen->flags & SDL_FULLSCREEN ) {
+				ChangeDisplaySettings(NULL, 0);
+			}
+#endif
+			if ( this->screen->flags & SDL_OPENGL ) {
+				WIN_GL_ShutDown(this);
+			}
+			this->screen->pixels = NULL;
+		}
+		if ( screen_bmp ) {
+			DeleteObject(screen_bmp);
+			screen_bmp = NULL;
+		}
+		if ( screen_icn ) {
+			DestroyIcon(screen_icn);
+			screen_icn = NULL;
+		}
+		DIB_QuitGamma(this);
+		DIB_DestroyWindow(this);
+
+		SDL_Window = NULL;
+	}
+}
+
+/* Exported for the windows message loop only */
+static void DIB_FocusPalette(_THIS, int foreground)
+{
+	if ( screen_pal != NULL ) {
+		HDC hdc;
+
+		hdc = GetDC(SDL_Window);
+		SelectPalette(hdc, screen_pal, FALSE);
+		if ( RealizePalette(hdc) )
+			InvalidateRect(SDL_Window, NULL, FALSE);
+		ReleaseDC(SDL_Window, hdc);
+	}
+}
+static void DIB_RealizePalette(_THIS)
+{
+	DIB_FocusPalette(this, 1);
+}
+static void DIB_PaletteChanged(_THIS, HWND window)
+{
+	if ( window != SDL_Window ) {
+		DIB_FocusPalette(this, 0);
+	}
+}
+
+/* Exported for the windows message loop only */
+static void DIB_WinPAINT(_THIS, HDC hdc)
+{
+	HDC mdc;
+
+	if ( screen_pal ) {
+		SelectPalette(hdc, screen_pal, FALSE);
+	}
+	mdc = CreateCompatibleDC(hdc);
+	SelectObject(mdc, screen_bmp);
+	BitBlt(hdc, 0, 0, SDL_VideoSurface->w, SDL_VideoSurface->h,
+							mdc, 0, 0, SRCCOPY);
+	DeleteDC(mdc);
+}
+
+/* Stub in case DirectX isn't available */
+#ifndef ENABLE_DIRECTX
+void DX5_SoundFocus(HWND hwnd)
+{
+	return;
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/SDL_dibvideo.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,51 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dibvideo_h
+#define _SDL_dibvideo_h
+
+#include <windows.h>
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+    HBITMAP screen_bmp;
+    HPALETTE screen_pal;
+
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+    int SDL_nummodes[NUM_MODELISTS];
+    SDL_Rect **SDL_modelist[NUM_MODELISTS];
+
+    WORD *gamma_saved;
+};
+/* Old variable names */
+#define screen_bmp		(this->hidden->screen_bmp)
+#define screen_pal		(this->hidden->screen_pal)
+#define SDL_nummodes		(this->hidden->SDL_nummodes)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define gamma_saved		(this->hidden->gamma_saved)
+
+#endif /* _SDL_dibvideo_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windib/SDL_vkeys.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,78 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef VK_0
+#define VK_0	'0'
+#define VK_1	'1'
+#define VK_2	'2'
+#define VK_3	'3'
+#define VK_4	'4'
+#define VK_5	'5'
+#define VK_6	'6'
+#define VK_7	'7'
+#define VK_8	'8'
+#define VK_9	'9'
+#define VK_A	'A'
+#define VK_B	'B'
+#define VK_C	'C'
+#define VK_D	'D'
+#define VK_E	'E'
+#define VK_F	'F'
+#define VK_G	'G'
+#define VK_H	'H'
+#define VK_I	'I'
+#define VK_J	'J'
+#define VK_K	'K'
+#define VK_L	'L'
+#define VK_M	'M'
+#define VK_N	'N'
+#define VK_O	'O'
+#define VK_P	'P'
+#define VK_Q	'Q'
+#define VK_R	'R'
+#define VK_S	'S'
+#define VK_T	'T'
+#define VK_U	'U'
+#define VK_V	'V'
+#define VK_W	'W'
+#define VK_X	'X'
+#define VK_Y	'Y'
+#define VK_Z	'Z'
+#endif /* VK_0 */
+
+/* These keys haven't been defined, but were experimentally determined */
+#define VK_SEMICOLON	0xBA
+#define VK_EQUALS		0xBB
+#define VK_COMMA		0xBC
+#define VK_MINUS		0xBD
+#define VK_PERIOD		0xBE
+#define VK_SLASH		0xBF
+#define VK_GRAVE		0xC0
+#define VK_LBRACKET		0xDB
+#define VK_BACKSLASH	0xDC
+#define VK_RBRACKET		0xDD
+#define VK_APOSTROPHE	0xDE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the DirectX video driver
+
+noinst_LTLIBRARIES = libvideo_windx5.la
+libvideo_windx5_la_SOURCES = $(DIRECTX_SRCS)
+
+# The SDL DirectX video driver sources
+DIRECTX_SRCS = 			\
+	SDL_dx5events.c		\
+	SDL_dx5events_c.h	\
+	SDL_dx5video.c		\
+	SDL_dx5video.h		\
+	SDL_dx5yuv.c		\
+	SDL_dx5yuv_c.h		\
+	directx.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5events.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,780 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* CAUTION!!!!  If you modify this file, check ../windib/SDL_sysevents.c */
+
+#include "directx.h"
+
+#include <stdio.h>
+#include "SDL_events.h"
+#include "SDL_video.h"
+#include "SDL_error.h"
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_events_c.h"
+#include "SDL_lowvideo.h"
+#include "SDL_dx5video.h"
+
+#ifndef WM_APP
+#define WM_APP	0x8000
+#endif
+
+/* The keyboard and mouse device input */
+#define MAX_INPUTS	16		/* Maximum of 16-1 input devices */
+#define INPUT_QSIZE	32		/* Buffer up to 32 input messages */
+
+static LPDIRECTINPUT dinput = NULL;
+static LPDIRECTINPUTDEVICE2 SDL_DIdev[MAX_INPUTS];
+static HANDLE               SDL_DIevt[MAX_INPUTS];
+static void (*SDL_DIfun[MAX_INPUTS])(const int, DIDEVICEOBJECTDATA *);
+static int SDL_DIndev = 0;
+static int mouse_lost;
+static int mouse_pressed;
+
+/* The translation table from a DirectInput scancode to an SDL keysym */
+static SDLKey DIK_keymap[256];
+static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed);
+
+/* Convert a DirectInput return code to a text message */
+static void SetDIerror(char *function, int code)
+{
+	static char *error;
+	static char  errbuf[BUFSIZ];
+
+	errbuf[0] = 0;
+	switch (code) {
+                case DIERR_GENERIC:
+                        error = "Undefined error!";
+                        break;
+		case DIERR_OLDDIRECTINPUTVERSION:
+			error = "Your version of DirectInput needs upgrading";
+			break;
+		case DIERR_INVALIDPARAM:
+                        error = "Invalid parameters";
+                        break;
+                case DIERR_OUTOFMEMORY:
+                        error = "Out of memory";
+                        break;
+		case DIERR_DEVICENOTREG:
+			error = "Device not registered";
+			break;
+		case DIERR_NOINTERFACE:
+			error = "Interface not supported";
+			break;
+		case DIERR_NOTINITIALIZED:
+			error = "Device not initialized";
+			break;
+		default:
+			sprintf(errbuf, "%s: Unknown DirectInput error: 0x%x",
+								function, code);
+			break;
+	}
+	if ( ! errbuf[0] ) {
+		sprintf(errbuf, "%s: %s", function, error);
+	}
+	SDL_SetError("%s", errbuf);
+	return;
+}
+
+/* Initialize DirectInput
+   Note:  If NONEXCLUSIVE access is requested for the devices, normal 
+          windows input messages will continue to be generated for that
+          input device, in addition to DirectInput messages.
+ */
+static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *events);
+static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *events);
+struct {
+	char *name;
+	REFGUID guid;
+	LPCDIDATAFORMAT format;
+	DWORD win_level;
+	DWORD raw_level;
+	void (*fun)(const int numevents, DIDEVICEOBJECTDATA *events);
+} inputs[] = {
+	{ "keyboard",
+		&GUID_SysKeyboard, &c_dfDIKeyboard,
+		(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE),
+		(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE), handle_keyboard },
+	{ "mouse",
+		&GUID_SysMouse, &c_dfDIMouse,
+		(DISCL_FOREGROUND|DISCL_NONEXCLUSIVE),
+		(DISCL_FOREGROUND|DISCL_EXCLUSIVE), handle_mouse },
+	{ NULL, NULL, NULL, 0, 0, NULL }
+};
+	
+static int DX5_DInputInit(_THIS)
+{
+	int         i;
+	LPDIRECTINPUTDEVICE device;
+	HRESULT     result;
+	DIPROPDWORD dipdw;
+
+	/* Create the DirectInput object */
+	result = DInputCreate(SDL_Instance, DIRECTINPUT_VERSION,
+							&dinput, NULL);
+	if ( result != DI_OK ) {
+		SetDIerror("DirectInputCreate", result);
+		return(-1);
+	}
+
+	/* Create all of our registered input devices */
+	SDL_DIndev = 0;
+	for ( i=0; inputs[i].name; ++i ) {
+		/* Create the DirectInput device */
+		result = IDirectInput_CreateDevice(dinput, inputs[i].guid,
+								&device, NULL);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInput::CreateDevice", result);
+			return(-1);
+		}
+		result = IDirectInputDevice_QueryInterface(device,
+			&IID_IDirectInputDevice2, (LPVOID *)&SDL_DIdev[i]);
+		IDirectInputDevice_Release(device);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInputDevice::QueryInterface", result);
+			return(-1);
+		}
+		result = IDirectInputDevice2_SetCooperativeLevel(SDL_DIdev[i],
+					SDL_Window, inputs[i].win_level);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInputDevice::SetCooperativeLevel",
+									result);
+			return(-1);
+		}
+		result = IDirectInputDevice2_SetDataFormat(SDL_DIdev[i],
+							inputs[i].format);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInputDevice::SetDataFormat", result);
+			return(-1);
+		}
+
+		/* Set buffered input -- we aren't polling */
+		memset(&dipdw, 0, sizeof(dipdw));
+		dipdw.diph.dwSize = sizeof(dipdw);
+		dipdw.diph.dwHeaderSize = sizeof(dipdw.diph);
+		dipdw.diph.dwObj = 0;
+		dipdw.diph.dwHow = DIPH_DEVICE;
+		dipdw.dwData = INPUT_QSIZE;
+		result = IDirectInputDevice2_SetProperty(SDL_DIdev[i],
+						DIPROP_BUFFERSIZE, &dipdw.diph);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInputDevice::SetProperty", result);
+			return(-1);
+		}
+
+		/* Create an event to be signaled when input is ready */
+		SDL_DIevt[i] = CreateEvent(NULL, FALSE, FALSE, NULL);
+		if ( SDL_DIevt[i] == NULL ) {
+			SDL_SetError("Couldn't create DirectInput event");
+			return(-1);
+		}
+		result = IDirectInputDevice2_SetEventNotification(SDL_DIdev[i],
+								SDL_DIevt[i]);
+		if ( result != DI_OK ) {
+			SetDIerror("DirectInputDevice::SetEventNotification",
+									result);
+			return(-1);
+		}
+		SDL_DIfun[i] = inputs[i].fun;
+
+		/* Acquire the device for input */
+		IDirectInputDevice2_Acquire(SDL_DIdev[i]);
+
+		/* Increment the number of devices we have */
+		++SDL_DIndev;
+	}
+	mouse_pressed = 0;
+
+	/* DirectInput is ready! */
+	return(0);
+}
+
+/* Change cooperative level based on whether or not we are fullscreen */
+void DX5_DInputReset(_THIS, int fullscreen)
+{
+	DWORD level;
+	int i;
+	HRESULT result;
+
+	for ( i=0; i<MAX_INPUTS; ++i ) {
+		if ( SDL_DIdev[i] != NULL ) {
+			if ( fullscreen ) {
+				level = inputs[i].raw_level;
+			} else {
+				level = inputs[i].win_level;
+			}
+			IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
+			result = IDirectInputDevice2_SetCooperativeLevel(
+					SDL_DIdev[i], SDL_Window, level);
+			IDirectInputDevice2_Acquire(SDL_DIdev[i]);
+			if ( result != DI_OK ) {
+				SetDIerror(
+			"DirectInputDevice::SetCooperativeLevel", result);
+			}
+		}
+	}
+	mouse_lost = 1;
+}
+
+/* Clean up DirectInput */
+static void DX5_DInputQuit(_THIS)
+{
+	int i;
+
+	if ( dinput != NULL ) {
+		/* Close and release all DirectInput devices */
+		for ( i=0; i<MAX_INPUTS; ++i ) {
+			if ( SDL_DIdev[i] != NULL ) {
+				IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
+				IDirectInputDevice2_SetEventNotification(
+							SDL_DIdev[i], NULL);
+				if ( SDL_DIevt[i] != NULL ) {
+					CloseHandle(SDL_DIevt[i]);
+					SDL_DIevt[i] = NULL;
+				}
+				IDirectInputDevice2_Release(SDL_DIdev[i]);
+				SDL_DIdev[i] = NULL;
+			}
+		}
+		/* Release DirectInput */
+		IDirectInput_Release(dinput);
+		dinput = NULL;
+	}
+}
+
+/* Flag to tell SDL whether or not we queued an event */
+static int posted = 0;
+
+/* Input event handler functions */
+static void handle_keyboard(const int numevents, DIDEVICEOBJECTDATA *keybuf)
+{
+	int i;
+	SDL_keysym keysym;
+
+	/* Translate keyboard messages */
+	for ( i=0; i<numevents; ++i ) {
+		if ( keybuf[i].dwData & 0x80 ) {
+			posted = SDL_PrivateKeyboard(SDL_PRESSED,
+				    TranslateKey(keybuf[i].dwOfs, &keysym, 1));
+		} else {
+			posted = SDL_PrivateKeyboard(SDL_RELEASED,
+				    TranslateKey(keybuf[i].dwOfs, &keysym, 0));
+		}
+	}
+}
+static void handle_mouse(const int numevents, DIDEVICEOBJECTDATA *ptrbuf)
+{
+	int i;
+	Sint16 xrel, yrel;
+	Uint8 state;
+	Uint8 button;
+
+	/* If we are in windowed mode, Windows is taking care of the mouse */
+	if ( ! (SDL_PublicSurface->flags & SDL_FULLSCREEN) ) {
+		return;
+	}
+
+	/* If the mouse was lost, regain some sense of mouse state */
+	if ( mouse_lost ) {
+		POINT mouse_pos;
+		Uint8 old_state;
+		Uint8 new_state;
+
+		/* Set ourselves up with the current cursor position */
+		GetCursorPos(&mouse_pos);
+		ScreenToClient(SDL_Window, &mouse_pos);
+		posted = SDL_PrivateMouseMotion(0, 0,
+				(Sint16)mouse_pos.x, (Sint16)mouse_pos.y);
+
+		/* Check for mouse button changes */
+		old_state = SDL_GetMouseState(NULL, NULL);
+		new_state = 0;
+		{ /* Get the new DirectInput button state for the mouse */
+			DIMOUSESTATE distate;
+			HRESULT result;
+
+			result=IDirectInputDevice2_GetDeviceState(SDL_DIdev[1],
+						sizeof(distate), &distate);
+			if ( result != DI_OK ) {
+				/* Try again next time */
+				SetDIerror(
+				"IDirectInputDevice2::GetDeviceState", result);
+				return;
+			}
+			for ( i=3; i>=0; --i ) {
+				if ( (distate.rgbButtons[i]&0x80) == 0x80 ) {
+					new_state |= 0x01;
+				}
+				new_state <<= 1;
+			}
+		}
+		for ( i=0; i<8; ++i ) {
+			if ( (old_state&0x01) != (new_state&0x01) ) {
+				button = (Uint8)(i+1);
+				/* Button #2 on two button mice is button 3
+				   (the middle button is button 2)
+				 */
+				if ( button == 2 ) {
+					button = 3;
+				} else
+				if ( button == 3 ) {
+					button = 2;
+				}
+				if ( new_state & 0x01 ) {
+					/* Grab mouse so we get mouse-up */
+					if ( ++mouse_pressed > 0 ) {
+						SetCapture(SDL_Window);
+					}
+					state = SDL_PRESSED;
+				} else {
+					/* Release mouse after all mouse-ups */
+					if ( --mouse_pressed <= 0 ) {
+						ReleaseCapture();
+						mouse_pressed = 0;
+					}
+					state = SDL_RELEASED;
+				}
+				posted = SDL_PrivateMouseButton(state, button,
+									0, 0);
+			}
+			old_state >>= 1;
+			new_state >>= 1;
+		}
+		mouse_lost = 0;
+		return;
+	}
+
+	/* Translate mouse messages */
+	xrel = 0;
+	yrel = 0;
+	for ( i=0; i<(int)numevents; ++i ) {
+		switch (ptrbuf[i].dwOfs) {
+			case DIMOFS_X:
+				xrel += (Sint16)ptrbuf[i].dwData;
+				break;
+			case DIMOFS_Y:
+				yrel += (Sint16)ptrbuf[i].dwData;
+				break;
+			case DIMOFS_BUTTON0:
+			case DIMOFS_BUTTON1:
+			case DIMOFS_BUTTON2:
+			case DIMOFS_BUTTON3:
+				if ( xrel || yrel ) {
+					posted = SDL_PrivateMouseMotion(
+							0, 1, xrel, yrel);
+					xrel = 0;
+					yrel = 0;
+				}
+				button = (Uint8)(ptrbuf[i].dwOfs-DIMOFS_BUTTON0)+1;
+				/* Button #2 on two button mice is button 3
+				   (the middle button is button 2)
+				 */
+				if ( button == 2 ) {
+					button = 3;
+				} else
+				if ( button == 3 ) {
+					button = 2;
+				}
+				if ( ptrbuf[i].dwData & 0x80 ) {
+					/* Grab mouse so we get mouse-up */
+					if ( ++mouse_pressed > 0 ) {
+						SetCapture(SDL_Window);
+					}
+					state = SDL_PRESSED;
+				} else {
+					/* Release mouse after all mouse-ups */
+					if ( --mouse_pressed <= 0 ) {
+						ReleaseCapture();
+						mouse_pressed = 0;
+					}
+					state = SDL_RELEASED;
+				}
+				posted = SDL_PrivateMouseButton(state, button,
+									0, 0);
+				break;
+		}
+	}
+	if ( xrel || yrel ) {
+		posted = SDL_PrivateMouseMotion( 0, 1, xrel, yrel);
+	}
+}
+
+/* The main Win32 event handler */
+LONG
+ DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+	switch (msg) {
+		case WM_ACTIVATEAPP: {
+			int i, active;
+
+			active = (wParam && (GetForegroundWindow() == hwnd));
+			if ( active ) {
+				for ( i=0; SDL_DIdev[i]; ++i ) {
+					IDirectInputDevice2_Acquire(
+								SDL_DIdev[i]);
+				}
+			} else {
+				for ( i=0; SDL_DIdev[i]; ++i ) {
+					IDirectInputDevice2_Unacquire(
+								SDL_DIdev[i]);
+				}
+				mouse_lost = 1;
+			}
+		}
+		break;
+
+		case WM_DISPLAYCHANGE: {
+			WORD BitsPerPixel;
+			WORD SizeX, SizeY;
+
+			/* Ack!  The display changed size and/or depth! */
+			SizeX = LOWORD(lParam);
+			SizeY = HIWORD(lParam);
+			BitsPerPixel = wParam;
+			/* We cause this message when we go fullscreen */
+		}
+		break;
+
+		/* The keyboard is handled via DirectInput */
+		case WM_SYSKEYUP:
+		case WM_SYSKEYDOWN:
+		case WM_KEYUP:
+		case WM_KEYDOWN: {
+			/* Ignore windows keyboard messages */;
+		}
+		return(0);
+
+		/* Don't allow screen savers or monitor power downs.
+		   This is because they quietly clear DirectX surfaces.
+		   It would be better to allow the application to
+		   decide whether or not to blow these off, but the
+		   semantics of SDL_PrivateSysWMEvent() don't allow
+		   the application that choice.
+		 */
+		case WM_SYSCOMMAND: {
+			if ((wParam&0xFFF0)==SC_SCREENSAVE || 
+			    (wParam&0xFFF0)==SC_MONITORPOWER)
+				return(0);
+		}
+		goto custom_processing;
+		break;
+
+		default: {
+		custom_processing:
+			/* Only post the event if we're watching for it */
+			if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+			        SDL_SysWMmsg wmmsg;
+
+				SDL_VERSION(&wmmsg.version);
+				wmmsg.hwnd = hwnd;
+				wmmsg.msg = msg;
+				wmmsg.wParam = wParam;
+				wmmsg.lParam = lParam;
+				posted = SDL_PrivateSysWMEvent(&wmmsg);
+			}
+		}
+		break;
+	}
+	return(DefWindowProc(hwnd, msg, wParam, lParam));
+}
+
+/* This function checks the windows message queue and DirectInput and returns
+   1 if there was input, 0 if there was no input, or -1 if the application has
+   posted a quit message.
+*/
+static int DX5_CheckInput(_THIS, int timeout)
+{
+	MSG msg;
+	int      i;
+	HRESULT  result;
+	DWORD    event;
+
+	/* Check the normal windows queue (highest preference) */
+	posted = 0;
+	while ( ! posted &&
+	        PeekMessage(&msg, NULL, 0, (WM_APP-1), PM_NOREMOVE) ) {
+		if ( GetMessage(&msg, NULL, 0, (WM_APP-1)) > 0 ) {
+			DispatchMessage(&msg);
+		} else {
+			return(-1);
+		}
+	}
+	if ( posted ) {
+		return(1);
+	}
+
+	/* Pump the DirectInput flow */
+	if ( SDL_GetAppState() & SDL_APPINPUTFOCUS ) {
+		for ( i=0; i<SDL_DIndev; ++i ) {
+			result = IDirectInputDevice2_Poll(SDL_DIdev[i]);
+			if ( (result == DIERR_INPUTLOST) ||
+					(result == DIERR_NOTACQUIRED) ) {
+				if ( strcmp(inputs[i].name, "mouse") == 0 ) {
+					mouse_lost = 1;
+				}
+				IDirectInputDevice2_Acquire(SDL_DIdev[i]);
+				IDirectInputDevice2_Poll(SDL_DIdev[i]);
+			}
+		}
+	}
+
+	/* Wait for messages and input events */
+	event = MsgWaitForMultipleObjects(SDL_DIndev, SDL_DIevt, FALSE,
+							timeout, QS_ALLEVENTS);
+	if ((event >= WAIT_OBJECT_0) && (event < (WAIT_OBJECT_0+SDL_DIndev))) {
+		DWORD numevents;
+		DIDEVICEOBJECTDATA evtbuf[INPUT_QSIZE];
+
+		event -= WAIT_OBJECT_0;
+		numevents = INPUT_QSIZE;
+		result = IDirectInputDevice2_GetDeviceData(
+				SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA),
+							evtbuf, &numevents, 0);
+		if ( (result == DIERR_INPUTLOST) ||
+					(result == DIERR_NOTACQUIRED) ) {
+			if ( strcmp(inputs[event].name, "mouse") == 0 ) {
+				mouse_lost = 1;
+			}
+			IDirectInputDevice2_Acquire(SDL_DIdev[event]);
+			result = IDirectInputDevice2_GetDeviceData(
+				SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA),
+							evtbuf, &numevents, 0);
+		}
+		/* Handle the events */
+		if ( result == DI_OK ) {
+			/* Note: This can post multiple events to event queue
+			 */
+			(*SDL_DIfun[event])((int)numevents, evtbuf);
+			return(1);
+		}
+	}
+	if ( event != WAIT_TIMEOUT ) {
+		/* Maybe there was a windows message? */
+		if ( PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) ) {
+			if ( GetMessage(&msg, NULL, 0, 0) > 0 ) {
+				DispatchMessage(&msg);
+			} else {
+				return(-1);
+			}
+			return(1);
+		}
+	}
+	return(0);
+}
+
+void DX5_PumpEvents(_THIS)
+{
+	/* Wait for messages and DirectInput */
+	while ( DX5_CheckInput(this, 0) > 0 ) {
+		/* Loop and check again */;
+	}
+}
+
+void DX5_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Map the DIK scancodes to SDL keysyms */
+	for ( i=0; i<SDL_TABLESIZE(DIK_keymap); ++i )
+		DIK_keymap[i] = 0;
+
+	/* Defined DIK_* constants */
+	DIK_keymap[DIK_ESCAPE] = SDLK_ESCAPE;
+	DIK_keymap[DIK_1] = SDLK_1;
+	DIK_keymap[DIK_2] = SDLK_2;
+	DIK_keymap[DIK_3] = SDLK_3;
+	DIK_keymap[DIK_4] = SDLK_4;
+	DIK_keymap[DIK_5] = SDLK_5;
+	DIK_keymap[DIK_6] = SDLK_6;
+	DIK_keymap[DIK_7] = SDLK_7;
+	DIK_keymap[DIK_8] = SDLK_8;
+	DIK_keymap[DIK_9] = SDLK_9;
+	DIK_keymap[DIK_0] = SDLK_0;
+	DIK_keymap[DIK_MINUS] = SDLK_MINUS;
+	DIK_keymap[DIK_EQUALS] = SDLK_EQUALS;
+	DIK_keymap[DIK_BACK] = SDLK_BACKSPACE;
+	DIK_keymap[DIK_TAB] = SDLK_TAB;
+	DIK_keymap[DIK_Q] = SDLK_q;
+	DIK_keymap[DIK_W] = SDLK_w;
+	DIK_keymap[DIK_E] = SDLK_e;
+	DIK_keymap[DIK_R] = SDLK_r;
+	DIK_keymap[DIK_T] = SDLK_t;
+	DIK_keymap[DIK_Y] = SDLK_y;
+	DIK_keymap[DIK_U] = SDLK_u;
+	DIK_keymap[DIK_I] = SDLK_i;
+	DIK_keymap[DIK_O] = SDLK_o;
+	DIK_keymap[DIK_P] = SDLK_p;
+	DIK_keymap[DIK_LBRACKET] = SDLK_LEFTBRACKET;
+	DIK_keymap[DIK_RBRACKET] = SDLK_RIGHTBRACKET;
+	DIK_keymap[DIK_RETURN] = SDLK_RETURN;
+	DIK_keymap[DIK_LCONTROL] = SDLK_LCTRL;
+	DIK_keymap[DIK_A] = SDLK_a;
+	DIK_keymap[DIK_S] = SDLK_s;
+	DIK_keymap[DIK_D] = SDLK_d;
+	DIK_keymap[DIK_F] = SDLK_f;
+	DIK_keymap[DIK_G] = SDLK_g;
+	DIK_keymap[DIK_H] = SDLK_h;
+	DIK_keymap[DIK_J] = SDLK_j;
+	DIK_keymap[DIK_K] = SDLK_k;
+	DIK_keymap[DIK_L] = SDLK_l;
+	DIK_keymap[DIK_SEMICOLON] = SDLK_SEMICOLON;
+	DIK_keymap[DIK_APOSTROPHE] = SDLK_QUOTE;
+	DIK_keymap[DIK_GRAVE] = SDLK_BACKQUOTE;
+	DIK_keymap[DIK_LSHIFT] = SDLK_LSHIFT;
+	DIK_keymap[DIK_BACKSLASH] = SDLK_BACKSLASH;
+	DIK_keymap[DIK_Z] = SDLK_z;
+	DIK_keymap[DIK_X] = SDLK_x;
+	DIK_keymap[DIK_C] = SDLK_c;
+	DIK_keymap[DIK_V] = SDLK_v;
+	DIK_keymap[DIK_B] = SDLK_b;
+	DIK_keymap[DIK_N] = SDLK_n;
+	DIK_keymap[DIK_M] = SDLK_m;
+	DIK_keymap[DIK_COMMA] = SDLK_COMMA;
+	DIK_keymap[DIK_PERIOD] = SDLK_PERIOD;
+	DIK_keymap[DIK_SLASH] = SDLK_SLASH;
+	DIK_keymap[DIK_RSHIFT] = SDLK_RSHIFT;
+	DIK_keymap[DIK_MULTIPLY] = SDLK_KP_MULTIPLY;
+	DIK_keymap[DIK_LMENU] = SDLK_LALT;
+	DIK_keymap[DIK_SPACE] = SDLK_SPACE;
+	DIK_keymap[DIK_CAPITAL] = SDLK_CAPSLOCK;
+	DIK_keymap[DIK_F1] = SDLK_F1;
+	DIK_keymap[DIK_F2] = SDLK_F2;
+	DIK_keymap[DIK_F3] = SDLK_F3;
+	DIK_keymap[DIK_F4] = SDLK_F4;
+	DIK_keymap[DIK_F5] = SDLK_F5;
+	DIK_keymap[DIK_F6] = SDLK_F6;
+	DIK_keymap[DIK_F7] = SDLK_F7;
+	DIK_keymap[DIK_F8] = SDLK_F8;
+	DIK_keymap[DIK_F9] = SDLK_F9;
+	DIK_keymap[DIK_F10] = SDLK_F10;
+	DIK_keymap[DIK_NUMLOCK] = SDLK_NUMLOCK;
+	DIK_keymap[DIK_SCROLL] = SDLK_SCROLLOCK;
+	DIK_keymap[DIK_NUMPAD7] = SDLK_KP7;
+	DIK_keymap[DIK_NUMPAD8] = SDLK_KP8;
+	DIK_keymap[DIK_NUMPAD9] = SDLK_KP9;
+	DIK_keymap[DIK_SUBTRACT] = SDLK_KP_MINUS;
+	DIK_keymap[DIK_NUMPAD4] = SDLK_KP4;
+	DIK_keymap[DIK_NUMPAD5] = SDLK_KP5;
+	DIK_keymap[DIK_NUMPAD6] = SDLK_KP6;
+	DIK_keymap[DIK_ADD] = SDLK_KP_PLUS;
+	DIK_keymap[DIK_NUMPAD1] = SDLK_KP1;
+	DIK_keymap[DIK_NUMPAD2] = SDLK_KP2;
+	DIK_keymap[DIK_NUMPAD3] = SDLK_KP3;
+	DIK_keymap[DIK_NUMPAD0] = SDLK_KP0;
+	DIK_keymap[DIK_DECIMAL] = SDLK_KP_PERIOD;
+	DIK_keymap[DIK_F11] = SDLK_F11;
+	DIK_keymap[DIK_F12] = SDLK_F12;
+
+	DIK_keymap[DIK_F13] = SDLK_F13;
+	DIK_keymap[DIK_F14] = SDLK_F14;
+	DIK_keymap[DIK_F15] = SDLK_F15;
+
+	DIK_keymap[DIK_NUMPADEQUALS] = SDLK_KP_EQUALS;
+	DIK_keymap[DIK_NUMPADENTER] = SDLK_KP_ENTER;
+	DIK_keymap[DIK_RCONTROL] = SDLK_RCTRL;
+	DIK_keymap[DIK_DIVIDE] = SDLK_KP_DIVIDE;
+	DIK_keymap[DIK_SYSRQ] = SDLK_SYSREQ;
+	DIK_keymap[DIK_RMENU] = SDLK_RALT;
+	DIK_keymap[DIK_HOME] = SDLK_HOME;
+	DIK_keymap[DIK_UP] = SDLK_UP;
+	DIK_keymap[DIK_PRIOR] = SDLK_PAGEUP;
+	DIK_keymap[DIK_LEFT] = SDLK_LEFT;
+	DIK_keymap[DIK_RIGHT] = SDLK_RIGHT;
+	DIK_keymap[DIK_END] = SDLK_END;
+	DIK_keymap[DIK_DOWN] = SDLK_DOWN;
+	DIK_keymap[DIK_NEXT] = SDLK_PAGEDOWN;
+	DIK_keymap[DIK_INSERT] = SDLK_INSERT;
+	DIK_keymap[DIK_DELETE] = SDLK_DELETE;
+	DIK_keymap[DIK_LWIN] = SDLK_LMETA;
+	DIK_keymap[DIK_RWIN] = SDLK_RMETA;
+	DIK_keymap[DIK_APPS] = SDLK_MENU;
+}
+
+static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed)
+{
+	/* Set the keysym information */
+	keysym->scancode = (unsigned char)scancode;
+	keysym->sym = DIK_keymap[scancode];
+	keysym->mod = KMOD_NONE;
+	keysym->unicode = 0;
+	if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */
+		UINT vkey;
+		BYTE keystate[256];
+		BYTE chars[2];
+
+		vkey = MapVirtualKey(scancode, 1);
+		GetKeyboardState(keystate);
+		if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) {
+			keysym->unicode = chars[0];
+		}
+	}
+	return(keysym);
+}
+
+int DX5_CreateWindow(_THIS)
+{
+	int i;
+
+	/* Clear out DirectInput variables in case we fail */
+	for ( i=0; i<MAX_INPUTS; ++i ) {
+		SDL_DIdev[i] = NULL;
+		SDL_DIevt[i] = NULL;
+		SDL_DIfun[i] = NULL;
+	}
+
+	/* Create the SDL window */
+	SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0);
+	if ( SDL_windowid ) {
+		SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0);
+	} else {
+		SDL_Window = CreateWindow(SDL_Appname, SDL_Appname,
+                        (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX),
+                                 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL);
+		if ( SDL_Window == NULL ) {
+			SDL_SetError("Couldn't create window");
+			return(-1);
+		}
+		ShowWindow(SDL_Window, SW_HIDE);
+	}
+
+	/* Initialize DirectInput */
+	if ( DX5_DInputInit(this) < 0 ) {
+		return(-1);
+	}
+
+	/* Ready to roll */
+	return(0);
+}
+
+void DX5_DestroyWindow(_THIS)
+{
+	/* Close down DirectInput */
+	DX5_DInputQuit(this);
+
+	/* Destroy our window */
+	DestroyWindow(SDL_Window);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5events_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_lowvideo.h"
+
+/* Variables and functions exported by SDL_dx5events.c to other parts 
+   of the native video subsystem (SDL_dx5video.c)
+*/
+extern LONG
+ DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
+extern int DX5_CreateWindow(_THIS);
+extern void DX5_DestroyWindow(_THIS);
+
+extern void DX5_PumpEvents(_THIS);
+extern void DX5_InitOSKeymap(_THIS);
+extern void DX5_DInputReset(_THIS, int fullscreen);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5video.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,2323 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+#include <windows.h>
+#include "directx.h"
+
+/* Not yet in the mingw32 cross-compile headers */
+#ifndef CDS_FULLSCREEN
+#define CDS_FULLSCREEN	4
+#endif
+
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_events.h"
+#include "SDL_syswm.h"
+#include "SDL_sysvideo.h"
+#include "SDL_RLEaccel_c.h"
+#include "SDL_blit.h"
+#include "SDL_pixels_c.h"
+#include "SDL_dx5video.h"
+#include "SDL_syswm_c.h"
+#include "SDL_sysmouse_c.h"
+#include "SDL_dx5events_c.h"
+#include "SDL_dx5yuv_c.h"
+#include "SDL_wingl_c.h"
+
+/* Function called to create a GL video mode - use the GDI driver, not DirectX */
+extern SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags);
+
+/* DirectX function pointers for video and events */
+HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
+HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
+
+/* This is the rect EnumModes2 uses */
+struct DX5EnumRect {
+	SDL_Rect r;
+	struct DX5EnumRect* next;
+};
+static struct DX5EnumRect *enumlists[NUM_MODELISTS];
+
+/*
+ * Experimentally determined values for c_cfDI* constants used in DirectX 5.0
+ */
+
+/* Keyboard */
+
+static DIOBJECTDATAFORMAT KBD_fmt[] = {
+	{ &GUID_Key, 0, 0x8000000C, 0x00000000 },
+	{ &GUID_Key, 1, 0x8000010C, 0x00000000 },
+	{ &GUID_Key, 2, 0x8000020C, 0x00000000 },
+	{ &GUID_Key, 3, 0x8000030C, 0x00000000 },
+	{ &GUID_Key, 4, 0x8000040C, 0x00000000 },
+	{ &GUID_Key, 5, 0x8000050C, 0x00000000 },
+	{ &GUID_Key, 6, 0x8000060C, 0x00000000 },
+	{ &GUID_Key, 7, 0x8000070C, 0x00000000 },
+	{ &GUID_Key, 8, 0x8000080C, 0x00000000 },
+	{ &GUID_Key, 9, 0x8000090C, 0x00000000 },
+	{ &GUID_Key, 10, 0x80000A0C, 0x00000000 },
+	{ &GUID_Key, 11, 0x80000B0C, 0x00000000 },
+	{ &GUID_Key, 12, 0x80000C0C, 0x00000000 },
+	{ &GUID_Key, 13, 0x80000D0C, 0x00000000 },
+	{ &GUID_Key, 14, 0x80000E0C, 0x00000000 },
+	{ &GUID_Key, 15, 0x80000F0C, 0x00000000 },
+	{ &GUID_Key, 16, 0x8000100C, 0x00000000 },
+	{ &GUID_Key, 17, 0x8000110C, 0x00000000 },
+	{ &GUID_Key, 18, 0x8000120C, 0x00000000 },
+	{ &GUID_Key, 19, 0x8000130C, 0x00000000 },
+	{ &GUID_Key, 20, 0x8000140C, 0x00000000 },
+	{ &GUID_Key, 21, 0x8000150C, 0x00000000 },
+	{ &GUID_Key, 22, 0x8000160C, 0x00000000 },
+	{ &GUID_Key, 23, 0x8000170C, 0x00000000 },
+	{ &GUID_Key, 24, 0x8000180C, 0x00000000 },
+	{ &GUID_Key, 25, 0x8000190C, 0x00000000 },
+	{ &GUID_Key, 26, 0x80001A0C, 0x00000000 },
+	{ &GUID_Key, 27, 0x80001B0C, 0x00000000 },
+	{ &GUID_Key, 28, 0x80001C0C, 0x00000000 },
+	{ &GUID_Key, 29, 0x80001D0C, 0x00000000 },
+	{ &GUID_Key, 30, 0x80001E0C, 0x00000000 },
+	{ &GUID_Key, 31, 0x80001F0C, 0x00000000 },
+	{ &GUID_Key, 32, 0x8000200C, 0x00000000 },
+	{ &GUID_Key, 33, 0x8000210C, 0x00000000 },
+	{ &GUID_Key, 34, 0x8000220C, 0x00000000 },
+	{ &GUID_Key, 35, 0x8000230C, 0x00000000 },
+	{ &GUID_Key, 36, 0x8000240C, 0x00000000 },
+	{ &GUID_Key, 37, 0x8000250C, 0x00000000 },
+	{ &GUID_Key, 38, 0x8000260C, 0x00000000 },
+	{ &GUID_Key, 39, 0x8000270C, 0x00000000 },
+	{ &GUID_Key, 40, 0x8000280C, 0x00000000 },
+	{ &GUID_Key, 41, 0x8000290C, 0x00000000 },
+	{ &GUID_Key, 42, 0x80002A0C, 0x00000000 },
+	{ &GUID_Key, 43, 0x80002B0C, 0x00000000 },
+	{ &GUID_Key, 44, 0x80002C0C, 0x00000000 },
+	{ &GUID_Key, 45, 0x80002D0C, 0x00000000 },
+	{ &GUID_Key, 46, 0x80002E0C, 0x00000000 },
+	{ &GUID_Key, 47, 0x80002F0C, 0x00000000 },
+	{ &GUID_Key, 48, 0x8000300C, 0x00000000 },
+	{ &GUID_Key, 49, 0x8000310C, 0x00000000 },
+	{ &GUID_Key, 50, 0x8000320C, 0x00000000 },
+	{ &GUID_Key, 51, 0x8000330C, 0x00000000 },
+	{ &GUID_Key, 52, 0x8000340C, 0x00000000 },
+	{ &GUID_Key, 53, 0x8000350C, 0x00000000 },
+	{ &GUID_Key, 54, 0x8000360C, 0x00000000 },
+	{ &GUID_Key, 55, 0x8000370C, 0x00000000 },
+	{ &GUID_Key, 56, 0x8000380C, 0x00000000 },
+	{ &GUID_Key, 57, 0x8000390C, 0x00000000 },
+	{ &GUID_Key, 58, 0x80003A0C, 0x00000000 },
+	{ &GUID_Key, 59, 0x80003B0C, 0x00000000 },
+	{ &GUID_Key, 60, 0x80003C0C, 0x00000000 },
+	{ &GUID_Key, 61, 0x80003D0C, 0x00000000 },
+	{ &GUID_Key, 62, 0x80003E0C, 0x00000000 },
+	{ &GUID_Key, 63, 0x80003F0C, 0x00000000 },
+	{ &GUID_Key, 64, 0x8000400C, 0x00000000 },
+	{ &GUID_Key, 65, 0x8000410C, 0x00000000 },
+	{ &GUID_Key, 66, 0x8000420C, 0x00000000 },
+	{ &GUID_Key, 67, 0x8000430C, 0x00000000 },
+	{ &GUID_Key, 68, 0x8000440C, 0x00000000 },
+	{ &GUID_Key, 69, 0x8000450C, 0x00000000 },
+	{ &GUID_Key, 70, 0x8000460C, 0x00000000 },
+	{ &GUID_Key, 71, 0x8000470C, 0x00000000 },
+	{ &GUID_Key, 72, 0x8000480C, 0x00000000 },
+	{ &GUID_Key, 73, 0x8000490C, 0x00000000 },
+	{ &GUID_Key, 74, 0x80004A0C, 0x00000000 },
+	{ &GUID_Key, 75, 0x80004B0C, 0x00000000 },
+	{ &GUID_Key, 76, 0x80004C0C, 0x00000000 },
+	{ &GUID_Key, 77, 0x80004D0C, 0x00000000 },
+	{ &GUID_Key, 78, 0x80004E0C, 0x00000000 },
+	{ &GUID_Key, 79, 0x80004F0C, 0x00000000 },
+	{ &GUID_Key, 80, 0x8000500C, 0x00000000 },
+	{ &GUID_Key, 81, 0x8000510C, 0x00000000 },
+	{ &GUID_Key, 82, 0x8000520C, 0x00000000 },
+	{ &GUID_Key, 83, 0x8000530C, 0x00000000 },
+	{ &GUID_Key, 84, 0x8000540C, 0x00000000 },
+	{ &GUID_Key, 85, 0x8000550C, 0x00000000 },
+	{ &GUID_Key, 86, 0x8000560C, 0x00000000 },
+	{ &GUID_Key, 87, 0x8000570C, 0x00000000 },
+	{ &GUID_Key, 88, 0x8000580C, 0x00000000 },
+	{ &GUID_Key, 89, 0x8000590C, 0x00000000 },
+	{ &GUID_Key, 90, 0x80005A0C, 0x00000000 },
+	{ &GUID_Key, 91, 0x80005B0C, 0x00000000 },
+	{ &GUID_Key, 92, 0x80005C0C, 0x00000000 },
+	{ &GUID_Key, 93, 0x80005D0C, 0x00000000 },
+	{ &GUID_Key, 94, 0x80005E0C, 0x00000000 },
+	{ &GUID_Key, 95, 0x80005F0C, 0x00000000 },
+	{ &GUID_Key, 96, 0x8000600C, 0x00000000 },
+	{ &GUID_Key, 97, 0x8000610C, 0x00000000 },
+	{ &GUID_Key, 98, 0x8000620C, 0x00000000 },
+	{ &GUID_Key, 99, 0x8000630C, 0x00000000 },
+	{ &GUID_Key, 100, 0x8000640C, 0x00000000 },
+	{ &GUID_Key, 101, 0x8000650C, 0x00000000 },
+	{ &GUID_Key, 102, 0x8000660C, 0x00000000 },
+	{ &GUID_Key, 103, 0x8000670C, 0x00000000 },
+	{ &GUID_Key, 104, 0x8000680C, 0x00000000 },
+	{ &GUID_Key, 105, 0x8000690C, 0x00000000 },
+	{ &GUID_Key, 106, 0x80006A0C, 0x00000000 },
+	{ &GUID_Key, 107, 0x80006B0C, 0x00000000 },
+	{ &GUID_Key, 108, 0x80006C0C, 0x00000000 },
+	{ &GUID_Key, 109, 0x80006D0C, 0x00000000 },
+	{ &GUID_Key, 110, 0x80006E0C, 0x00000000 },
+	{ &GUID_Key, 111, 0x80006F0C, 0x00000000 },
+	{ &GUID_Key, 112, 0x8000700C, 0x00000000 },
+	{ &GUID_Key, 113, 0x8000710C, 0x00000000 },
+	{ &GUID_Key, 114, 0x8000720C, 0x00000000 },
+	{ &GUID_Key, 115, 0x8000730C, 0x00000000 },
+	{ &GUID_Key, 116, 0x8000740C, 0x00000000 },
+	{ &GUID_Key, 117, 0x8000750C, 0x00000000 },
+	{ &GUID_Key, 118, 0x8000760C, 0x00000000 },
+	{ &GUID_Key, 119, 0x8000770C, 0x00000000 },
+	{ &GUID_Key, 120, 0x8000780C, 0x00000000 },
+	{ &GUID_Key, 121, 0x8000790C, 0x00000000 },
+	{ &GUID_Key, 122, 0x80007A0C, 0x00000000 },
+	{ &GUID_Key, 123, 0x80007B0C, 0x00000000 },
+	{ &GUID_Key, 124, 0x80007C0C, 0x00000000 },
+	{ &GUID_Key, 125, 0x80007D0C, 0x00000000 },
+	{ &GUID_Key, 126, 0x80007E0C, 0x00000000 },
+	{ &GUID_Key, 127, 0x80007F0C, 0x00000000 },
+	{ &GUID_Key, 128, 0x8000800C, 0x00000000 },
+	{ &GUID_Key, 129, 0x8000810C, 0x00000000 },
+	{ &GUID_Key, 130, 0x8000820C, 0x00000000 },
+	{ &GUID_Key, 131, 0x8000830C, 0x00000000 },
+	{ &GUID_Key, 132, 0x8000840C, 0x00000000 },
+	{ &GUID_Key, 133, 0x8000850C, 0x00000000 },
+	{ &GUID_Key, 134, 0x8000860C, 0x00000000 },
+	{ &GUID_Key, 135, 0x8000870C, 0x00000000 },
+	{ &GUID_Key, 136, 0x8000880C, 0x00000000 },
+	{ &GUID_Key, 137, 0x8000890C, 0x00000000 },
+	{ &GUID_Key, 138, 0x80008A0C, 0x00000000 },
+	{ &GUID_Key, 139, 0x80008B0C, 0x00000000 },
+	{ &GUID_Key, 140, 0x80008C0C, 0x00000000 },
+	{ &GUID_Key, 141, 0x80008D0C, 0x00000000 },
+	{ &GUID_Key, 142, 0x80008E0C, 0x00000000 },
+	{ &GUID_Key, 143, 0x80008F0C, 0x00000000 },
+	{ &GUID_Key, 144, 0x8000900C, 0x00000000 },
+	{ &GUID_Key, 145, 0x8000910C, 0x00000000 },
+	{ &GUID_Key, 146, 0x8000920C, 0x00000000 },
+	{ &GUID_Key, 147, 0x8000930C, 0x00000000 },
+	{ &GUID_Key, 148, 0x8000940C, 0x00000000 },
+	{ &GUID_Key, 149, 0x8000950C, 0x00000000 },
+	{ &GUID_Key, 150, 0x8000960C, 0x00000000 },
+	{ &GUID_Key, 151, 0x8000970C, 0x00000000 },
+	{ &GUID_Key, 152, 0x8000980C, 0x00000000 },
+	{ &GUID_Key, 153, 0x8000990C, 0x00000000 },
+	{ &GUID_Key, 154, 0x80009A0C, 0x00000000 },
+	{ &GUID_Key, 155, 0x80009B0C, 0x00000000 },
+	{ &GUID_Key, 156, 0x80009C0C, 0x00000000 },
+	{ &GUID_Key, 157, 0x80009D0C, 0x00000000 },
+	{ &GUID_Key, 158, 0x80009E0C, 0x00000000 },
+	{ &GUID_Key, 159, 0x80009F0C, 0x00000000 },
+	{ &GUID_Key, 160, 0x8000A00C, 0x00000000 },
+	{ &GUID_Key, 161, 0x8000A10C, 0x00000000 },
+	{ &GUID_Key, 162, 0x8000A20C, 0x00000000 },
+	{ &GUID_Key, 163, 0x8000A30C, 0x00000000 },
+	{ &GUID_Key, 164, 0x8000A40C, 0x00000000 },
+	{ &GUID_Key, 165, 0x8000A50C, 0x00000000 },
+	{ &GUID_Key, 166, 0x8000A60C, 0x00000000 },
+	{ &GUID_Key, 167, 0x8000A70C, 0x00000000 },
+	{ &GUID_Key, 168, 0x8000A80C, 0x00000000 },
+	{ &GUID_Key, 169, 0x8000A90C, 0x00000000 },
+	{ &GUID_Key, 170, 0x8000AA0C, 0x00000000 },
+	{ &GUID_Key, 171, 0x8000AB0C, 0x00000000 },
+	{ &GUID_Key, 172, 0x8000AC0C, 0x00000000 },
+	{ &GUID_Key, 173, 0x8000AD0C, 0x00000000 },
+	{ &GUID_Key, 174, 0x8000AE0C, 0x00000000 },
+	{ &GUID_Key, 175, 0x8000AF0C, 0x00000000 },
+	{ &GUID_Key, 176, 0x8000B00C, 0x00000000 },
+	{ &GUID_Key, 177, 0x8000B10C, 0x00000000 },
+	{ &GUID_Key, 178, 0x8000B20C, 0x00000000 },
+	{ &GUID_Key, 179, 0x8000B30C, 0x00000000 },
+	{ &GUID_Key, 180, 0x8000B40C, 0x00000000 },
+	{ &GUID_Key, 181, 0x8000B50C, 0x00000000 },
+	{ &GUID_Key, 182, 0x8000B60C, 0x00000000 },
+	{ &GUID_Key, 183, 0x8000B70C, 0x00000000 },
+	{ &GUID_Key, 184, 0x8000B80C, 0x00000000 },
+	{ &GUID_Key, 185, 0x8000B90C, 0x00000000 },
+	{ &GUID_Key, 186, 0x8000BA0C, 0x00000000 },
+	{ &GUID_Key, 187, 0x8000BB0C, 0x00000000 },
+	{ &GUID_Key, 188, 0x8000BC0C, 0x00000000 },
+	{ &GUID_Key, 189, 0x8000BD0C, 0x00000000 },
+	{ &GUID_Key, 190, 0x8000BE0C, 0x00000000 },
+	{ &GUID_Key, 191, 0x8000BF0C, 0x00000000 },
+	{ &GUID_Key, 192, 0x8000C00C, 0x00000000 },
+	{ &GUID_Key, 193, 0x8000C10C, 0x00000000 },
+	{ &GUID_Key, 194, 0x8000C20C, 0x00000000 },
+	{ &GUID_Key, 195, 0x8000C30C, 0x00000000 },
+	{ &GUID_Key, 196, 0x8000C40C, 0x00000000 },
+	{ &GUID_Key, 197, 0x8000C50C, 0x00000000 },
+	{ &GUID_Key, 198, 0x8000C60C, 0x00000000 },
+	{ &GUID_Key, 199, 0x8000C70C, 0x00000000 },
+	{ &GUID_Key, 200, 0x8000C80C, 0x00000000 },
+	{ &GUID_Key, 201, 0x8000C90C, 0x00000000 },
+	{ &GUID_Key, 202, 0x8000CA0C, 0x00000000 },
+	{ &GUID_Key, 203, 0x8000CB0C, 0x00000000 },
+	{ &GUID_Key, 204, 0x8000CC0C, 0x00000000 },
+	{ &GUID_Key, 205, 0x8000CD0C, 0x00000000 },
+	{ &GUID_Key, 206, 0x8000CE0C, 0x00000000 },
+	{ &GUID_Key, 207, 0x8000CF0C, 0x00000000 },
+	{ &GUID_Key, 208, 0x8000D00C, 0x00000000 },
+	{ &GUID_Key, 209, 0x8000D10C, 0x00000000 },
+	{ &GUID_Key, 210, 0x8000D20C, 0x00000000 },
+	{ &GUID_Key, 211, 0x8000D30C, 0x00000000 },
+	{ &GUID_Key, 212, 0x8000D40C, 0x00000000 },
+	{ &GUID_Key, 213, 0x8000D50C, 0x00000000 },
+	{ &GUID_Key, 214, 0x8000D60C, 0x00000000 },
+	{ &GUID_Key, 215, 0x8000D70C, 0x00000000 },
+	{ &GUID_Key, 216, 0x8000D80C, 0x00000000 },
+	{ &GUID_Key, 217, 0x8000D90C, 0x00000000 },
+	{ &GUID_Key, 218, 0x8000DA0C, 0x00000000 },
+	{ &GUID_Key, 219, 0x8000DB0C, 0x00000000 },
+	{ &GUID_Key, 220, 0x8000DC0C, 0x00000000 },
+	{ &GUID_Key, 221, 0x8000DD0C, 0x00000000 },
+	{ &GUID_Key, 222, 0x8000DE0C, 0x00000000 },
+	{ &GUID_Key, 223, 0x8000DF0C, 0x00000000 },
+	{ &GUID_Key, 224, 0x8000E00C, 0x00000000 },
+	{ &GUID_Key, 225, 0x8000E10C, 0x00000000 },
+	{ &GUID_Key, 226, 0x8000E20C, 0x00000000 },
+	{ &GUID_Key, 227, 0x8000E30C, 0x00000000 },
+	{ &GUID_Key, 228, 0x8000E40C, 0x00000000 },
+	{ &GUID_Key, 229, 0x8000E50C, 0x00000000 },
+	{ &GUID_Key, 230, 0x8000E60C, 0x00000000 },
+	{ &GUID_Key, 231, 0x8000E70C, 0x00000000 },
+	{ &GUID_Key, 232, 0x8000E80C, 0x00000000 },
+	{ &GUID_Key, 233, 0x8000E90C, 0x00000000 },
+	{ &GUID_Key, 234, 0x8000EA0C, 0x00000000 },
+	{ &GUID_Key, 235, 0x8000EB0C, 0x00000000 },
+	{ &GUID_Key, 236, 0x8000EC0C, 0x00000000 },
+	{ &GUID_Key, 237, 0x8000ED0C, 0x00000000 },
+	{ &GUID_Key, 238, 0x8000EE0C, 0x00000000 },
+	{ &GUID_Key, 239, 0x8000EF0C, 0x00000000 },
+	{ &GUID_Key, 240, 0x8000F00C, 0x00000000 },
+	{ &GUID_Key, 241, 0x8000F10C, 0x00000000 },
+	{ &GUID_Key, 242, 0x8000F20C, 0x00000000 },
+	{ &GUID_Key, 243, 0x8000F30C, 0x00000000 },
+	{ &GUID_Key, 244, 0x8000F40C, 0x00000000 },
+	{ &GUID_Key, 245, 0x8000F50C, 0x00000000 },
+	{ &GUID_Key, 246, 0x8000F60C, 0x00000000 },
+	{ &GUID_Key, 247, 0x8000F70C, 0x00000000 },
+	{ &GUID_Key, 248, 0x8000F80C, 0x00000000 },
+	{ &GUID_Key, 249, 0x8000F90C, 0x00000000 },
+	{ &GUID_Key, 250, 0x8000FA0C, 0x00000000 },
+	{ &GUID_Key, 251, 0x8000FB0C, 0x00000000 },
+	{ &GUID_Key, 252, 0x8000FC0C, 0x00000000 },
+	{ &GUID_Key, 253, 0x8000FD0C, 0x00000000 },
+	{ &GUID_Key, 254, 0x8000FE0C, 0x00000000 },
+	{ &GUID_Key, 255, 0x8000FF0C, 0x00000000 },
+};
+
+const DIDATAFORMAT c_dfDIKeyboard = { 24, 16, 0x00000002, 256, 256, KBD_fmt };
+
+
+/* Mouse */
+
+static DIOBJECTDATAFORMAT PTR_fmt[] = {
+	{ &GUID_XAxis, 0, 0x00FFFF03, 0x00000000 },
+	{ &GUID_YAxis, 4, 0x00FFFF03, 0x00000000 },
+	{ &GUID_ZAxis, 8, 0x80FFFF03, 0x00000000 },
+	{ NULL, 12, 0x00FFFF0C, 0x00000000 },
+	{ NULL, 13, 0x00FFFF0C, 0x00000000 },
+	{ NULL, 14, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 15, 0x80FFFF0C, 0x00000000 },
+};
+
+const DIDATAFORMAT c_dfDIMouse = { 24, 16, 0x00000002, 16, 7, PTR_fmt };
+
+
+/* Joystick */
+
+static DIOBJECTDATAFORMAT JOY_fmt[] = {
+	{ &GUID_XAxis, 0, 0x80FFFF03, 0x00000100 },
+	{ &GUID_YAxis, 4, 0x80FFFF03, 0x00000100 },
+	{ &GUID_ZAxis, 8, 0x80FFFF03, 0x00000100 },
+	{ &GUID_RxAxis, 12, 0x80FFFF03, 0x00000100 },
+	{ &GUID_RyAxis, 16, 0x80FFFF03, 0x00000100 },
+	{ &GUID_RzAxis, 20, 0x80FFFF03, 0x00000100 },
+	{ &GUID_Slider, 24, 0x80FFFF03, 0x00000100 },
+	{ &GUID_Slider, 28, 0x80FFFF03, 0x00000100 },
+	{ &GUID_POV, 32, 0x80FFFF10, 0x00000000 },
+	{ &GUID_POV, 36, 0x80FFFF10, 0x00000000 },
+	{ &GUID_POV, 40, 0x80FFFF10, 0x00000000 },
+	{ &GUID_POV, 44, 0x80FFFF10, 0x00000000 },
+	{ NULL, 48, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 49, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 50, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 51, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 52, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 53, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 54, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 55, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 56, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 57, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 58, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 59, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 60, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 61, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 62, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 63, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 64, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 65, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 66, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 67, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 68, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 69, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 70, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 71, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 72, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 73, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 74, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 75, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 76, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 77, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 78, 0x80FFFF0C, 0x00000000 },
+	{ NULL, 79, 0x80FFFF0C, 0x00000000 },
+};
+
+const DIDATAFORMAT c_dfDIJoystick = { 24, 16, 0x00000001, 80, 44, JOY_fmt };
+
+
+/* Initialization/Query functions */
+static int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int DX5_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static void DX5_SwapGamma(_THIS);
+#ifdef IID_IDirectDrawGammaControl
+static int DX5_SetGammaRamp(_THIS, Uint16 *ramp);
+static int DX5_GetGammaRamp(_THIS, Uint16 *ramp);
+#endif
+static void DX5_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
+static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color);
+static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key);
+static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha);
+static int DX5_LockHWSurface(_THIS, SDL_Surface *surface);
+static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface);
+static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface);
+
+static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, 
+				LPDIRECTDRAWSURFACE3 requested, Uint32 flag);
+
+/* Windows message handling functions */
+static void DX5_RealizePalette(_THIS);
+static void DX5_PaletteChanged(_THIS, HWND window);
+static void DX5_WinPAINT(_THIS, HDC hdc);
+
+/* DX5 driver bootstrap functions */
+
+static int DX5_Available(void)
+{
+	HINSTANCE DInputDLL;
+	HINSTANCE DDrawDLL;
+	int dinput_ok;
+	int ddraw_ok;
+
+	/* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */
+	dinput_ok = 0;
+	DInputDLL = LoadLibrary("DINPUT.DLL");
+	if ( DInputDLL != NULL ) {
+		dinput_ok = 1;
+	  	FreeLibrary(DInputDLL);
+	}
+	ddraw_ok = 0;
+	DDrawDLL = LoadLibrary("DDRAW.DLL");
+	if ( DDrawDLL != NULL ) {
+	  HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *);
+	  LPDIRECTDRAW DDraw;
+
+	  /* Try to create a valid DirectDraw object */
+	  DDrawCreate = (void *)GetProcAddress(DDrawDLL, "DirectDrawCreate");
+	  if ( (DDrawCreate != NULL)
+			&& !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) {
+	    if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw,
+							NULL, DDSCL_NORMAL)) ) {
+	      DDSURFACEDESC desc;
+	      LPDIRECTDRAWSURFACE  DDrawSurf;
+	      LPDIRECTDRAWSURFACE3 DDrawSurf3;
+
+	      /* Try to create a DirectDrawSurface3 object */
+	      memset(&desc, 0, sizeof(desc));
+	      desc.dwSize = sizeof(desc);
+	      desc.dwFlags = DDSD_CAPS;
+	      desc.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY;
+	      if ( !FAILED(IDirectDraw_CreateSurface(DDraw, &desc,
+							&DDrawSurf, NULL)) ) {
+	        if ( !FAILED(IDirectDrawSurface_QueryInterface(DDrawSurf,
+			&IID_IDirectDrawSurface3, (LPVOID *)&DDrawSurf3)) ) {
+	          /* Yay! */
+		  ddraw_ok = 1;
+
+	          /* Clean up.. */
+	          IDirectDrawSurface3_Release(DDrawSurf3);
+	        }
+	        IDirectDrawSurface_Release(DDrawSurf);
+	      }
+	    }
+	    IDirectDraw_Release(DDraw);
+	  }
+	  FreeLibrary(DDrawDLL);
+	}
+	return(dinput_ok && ddraw_ok);
+}
+
+/* Functions for loading the DirectX functions dynamically */
+static HINSTANCE DDrawDLL = NULL;
+static HINSTANCE DInputDLL = NULL;
+
+static void DX5_Unload(void)
+{
+	if ( DDrawDLL != NULL ) {
+		FreeLibrary(DDrawDLL);
+		DDrawCreate = NULL;
+		DDrawDLL = NULL;
+	}
+	if ( DInputDLL != NULL ) {
+		FreeLibrary(DInputDLL);
+		DInputCreate = NULL;
+		DInputDLL = NULL;
+	}
+}
+static int DX5_Load(void)
+{
+	int status;
+
+	DX5_Unload();
+	DDrawDLL = LoadLibrary("DDRAW.DLL");
+	if ( DDrawDLL != NULL ) {
+		DDrawCreate = (void *)GetProcAddress(DDrawDLL,
+					"DirectDrawCreate");
+	}
+	DInputDLL = LoadLibrary("DINPUT.DLL");
+	if ( DInputDLL != NULL ) {
+		DInputCreate = (void *)GetProcAddress(DInputDLL,
+					"DirectInputCreateA");
+	}
+	if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) {
+		status = 0;
+	} else {
+		DX5_Unload();
+		status = -1;
+	}
+	return status;
+}
+
+static void DX5_DeleteDevice(SDL_VideoDevice *this)
+{
+	/* Free DirectDraw object */
+	if ( ddraw2 != NULL ) {
+		IDirectDraw2_Release(ddraw2);
+	}
+	DX5_Unload();
+	if ( this ) {
+		if ( this->hidden ) {
+			free(this->hidden);
+		}
+		if ( this->gl_data ) {
+			free(this->gl_data);
+		}
+		free(this);
+	}
+}
+
+static SDL_VideoDevice *DX5_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Load DirectX */
+	if ( DX5_Load() < 0 ) {
+		return(NULL);
+	}
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+		device->gl_data = (struct SDL_PrivateGLData *)
+				malloc((sizeof *device->gl_data));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ||
+		                 (device->gl_data == NULL) ) {
+		SDL_OutOfMemory();
+		DX5_DeleteDevice(device);
+		return(NULL);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+	memset(device->gl_data, 0, (sizeof *device->gl_data));
+
+	/* Set the function pointers */
+	device->VideoInit = DX5_VideoInit;
+	device->ListModes = DX5_ListModes;
+	device->SetVideoMode = DX5_SetVideoMode;
+	device->UpdateMouse = WIN_UpdateMouse;
+	device->CreateYUVOverlay = DX5_CreateYUVOverlay;
+	device->SetColors = DX5_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = DX5_VideoQuit;
+	device->AllocHWSurface = DX5_AllocHWSurface;
+	device->CheckHWBlit = DX5_CheckHWBlit;
+	device->FillHWRect = DX5_FillHWRect;
+	device->SetHWColorKey = DX5_SetHWColorKey;
+	device->SetHWAlpha = DX5_SetHWAlpha;
+	device->LockHWSurface = DX5_LockHWSurface;
+	device->UnlockHWSurface = DX5_UnlockHWSurface;
+	device->FlipHWSurface = DX5_FlipHWSurface;
+	device->FreeHWSurface = DX5_FreeHWSurface;
+#ifdef IID_IDirectDrawGammaControl
+	device->SetGammaRamp = DX5_SetGammaRamp;
+	device->GetGammaRamp = DX5_GetGammaRamp;
+#endif
+#ifdef HAVE_OPENGL
+        device->GL_LoadLibrary = WIN_GL_LoadLibrary;
+        device->GL_GetProcAddress = WIN_GL_GetProcAddress;
+        device->GL_GetAttribute = WIN_GL_GetAttribute;
+        device->GL_MakeCurrent = WIN_GL_MakeCurrent;
+        device->GL_SwapBuffers = WIN_GL_SwapBuffers;
+#endif
+	device->SetCaption = WIN_SetWMCaption;
+	device->SetIcon = WIN_SetWMIcon;
+	device->IconifyWindow = WIN_IconifyWindow;
+	device->GrabInput = WIN_GrabInput;
+	device->GetWMInfo = WIN_GetWMInfo;
+	device->FreeWMCursor = WIN_FreeWMCursor;
+	device->CreateWMCursor = WIN_CreateWMCursor;
+	device->ShowWMCursor = WIN_ShowWMCursor;
+	device->WarpWMCursor = WIN_WarpWMCursor;
+	device->CheckMouseMode = WIN_CheckMouseMode;
+	device->InitOSKeymap = DX5_InitOSKeymap;
+	device->PumpEvents = DX5_PumpEvents;
+
+	/* Set up the windows message handling functions */
+	WIN_RealizePalette = DX5_RealizePalette;
+	WIN_PaletteChanged = DX5_PaletteChanged;
+	WIN_SwapGamma = DX5_SwapGamma;
+	WIN_WinPAINT = DX5_WinPAINT;
+	HandleMessage = DX5_HandleMessage;
+
+	device->free = DX5_DeleteDevice;
+
+	/* We're finally ready */
+	return device;
+}
+
+VideoBootStrap DIRECTX_bootstrap = {
+	"directx", "Win95/98/2000 DirectX",
+	DX5_Available, DX5_CreateDevice
+};
+
+static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata)
+{
+	SDL_VideoDevice *this = (SDL_VideoDevice *)udata;
+	struct DX5EnumRect *enumrect;
+#if defined(NONAMELESSUNION)
+	int bpp = desc->ddpfPixelFormat.u1.dwRGBBitCount;
+#else
+	int bpp = desc->ddpfPixelFormat.dwRGBBitCount;
+#endif
+
+	switch (bpp)  {
+		case 8:
+		case 16:
+		case 24:
+		case 32:
+			bpp /= 8; --bpp;
+			++SDL_nummodes[bpp];
+			enumrect = (struct DX5EnumRect*)malloc(sizeof(struct DX5EnumRect));
+			if ( !enumrect ) {
+				SDL_OutOfMemory();
+				return(DDENUMRET_CANCEL);
+			}
+			enumrect->r.x = 0;
+			enumrect->r.y = 0;
+			enumrect->r.w = (Uint16)desc->dwWidth;
+			enumrect->r.h = (Uint16)desc->dwHeight;
+			enumrect->next = enumlists[bpp];
+			enumlists[bpp] = enumrect;
+			break;
+	}
+
+
+	return(DDENUMRET_OK);
+}
+
+void SetDDerror(const char *function, int code)
+{
+	static char *error;
+	static char  errbuf[BUFSIZ];
+
+	errbuf[0] = 0;
+	switch (code) {
+		case DDERR_GENERIC:
+			error = "Undefined error!";
+			break;
+		case DDERR_EXCEPTION:
+			error = "Exception encountered";
+			break;
+		case DDERR_INVALIDOBJECT:
+			error = "Invalid object";
+			break;
+		case DDERR_INVALIDPARAMS:
+			error = "Invalid parameters";
+			break;
+		case DDERR_NOTFOUND:
+			error = "Object not found";
+			break;
+		case DDERR_INVALIDRECT:
+			error = "Invalid rectangle";
+			break;
+		case DDERR_INVALIDCAPS:
+			error = "Invalid caps member";
+			break;
+		case DDERR_INVALIDPIXELFORMAT:
+			error = "Invalid pixel format";
+			break;
+		case DDERR_OUTOFMEMORY:
+			error = "Out of memory";
+			break;
+		case DDERR_OUTOFVIDEOMEMORY:
+			error = "Out of video memory";
+			break;
+		case DDERR_SURFACEBUSY:
+			error = "Surface busy";
+			break;
+		case DDERR_SURFACELOST:
+			error = "Surface was lost";
+			break;
+		case DDERR_WASSTILLDRAWING:
+			error = "DirectDraw is still drawing";
+			break;
+		case DDERR_INVALIDSURFACETYPE:
+			error = "Invalid surface type";
+			break;
+		case DDERR_NOEXCLUSIVEMODE:
+			error = "Not in exclusive access mode";
+			break;
+		case DDERR_NOPALETTEATTACHED:
+			error = "No palette attached";
+			break;
+		case DDERR_NOPALETTEHW:
+			error = "No palette hardware";
+			break;
+		case DDERR_NOT8BITCOLOR:
+			error = "Not 8-bit color";
+			break;
+		case DDERR_EXCLUSIVEMODEALREADYSET:
+			error = "Exclusive mode was already set";
+			break;
+		case DDERR_HWNDALREADYSET:
+			error = "Window handle already set";
+			break;
+		case DDERR_HWNDSUBCLASSED:
+			error = "Window handle is subclassed";
+			break;
+		case DDERR_NOBLTHW:
+			error = "No blit hardware";
+			break;
+		case DDERR_IMPLICITLYCREATED:
+			error = "Surface was implicitly created";
+			break;
+		case DDERR_INCOMPATIBLEPRIMARY:
+			error = "Incompatible primary surface";
+			break;
+		case DDERR_NOCOOPERATIVELEVELSET:
+			error = "No cooperative level set";
+			break;
+		case DDERR_NODIRECTDRAWHW:
+			error = "No DirectDraw hardware";
+			break;
+		case DDERR_NOEMULATION:
+			error = "No emulation available";
+			break;
+		case DDERR_NOFLIPHW:
+			error = "No flip hardware";
+			break;
+		case DDERR_NOTFLIPPABLE:
+			error = "Surface not flippable";
+			break;
+		case DDERR_PRIMARYSURFACEALREADYEXISTS:
+			error = "Primary surface already exists";
+			break;
+		case DDERR_UNSUPPORTEDMODE:
+			error = "Unsupported mode";
+			break;
+		case DDERR_WRONGMODE:
+			error = "Surface created in different mode";
+			break;
+		case DDERR_UNSUPPORTED:
+			error = "Operation not supported";
+			break;
+		case E_NOINTERFACE:
+			error = "Interface not present";
+			break;
+		default:
+			sprintf(errbuf, "%s: Unknown DirectDraw error: 0x%x",
+								function, code);
+			break;
+	}
+	if ( ! errbuf[0] ) {
+		sprintf(errbuf, "%s: %s", function, error);
+	}
+	SDL_SetError("%s", errbuf);
+	return;
+}
+
+
+static int DX5_UpdateVideoInfo(_THIS)
+{
+	/* This needs to be DDCAPS_DX5 for the DirectDraw2 interface */
+#if DIRECTDRAW_VERSION <= 0x300
+#error Your version of DirectX must be greater than or equal to 5.0
+#endif
+#ifndef IID_IDirectDrawGammaControl
+	/*if gamma is undefined then we really have directx <= 0x500*/
+	DDCAPS DDCaps;
+#else
+	DDCAPS_DX5 DDCaps;
+#endif
+	HRESULT result;
+
+	/* Fill in our hardware acceleration capabilities */
+	memset(&DDCaps, 0, sizeof(DDCaps));
+	DDCaps.dwSize = sizeof(DDCaps);
+	result = IDirectDraw2_GetCaps(ddraw2, (DDCAPS *)&DDCaps, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw2::GetCaps", result);
+		return(-1);
+	}
+	this->info.hw_available = 1;
+	if ( (DDCaps.dwCaps & DDCAPS_BLT) == DDCAPS_BLT ) {
+		this->info.blit_hw = 1;
+	}
+	if ( ((DDCaps.dwCaps & DDCAPS_COLORKEY) == DDCAPS_COLORKEY) &&
+	     ((DDCaps.dwCKeyCaps & DDCKEYCAPS_SRCBLT) == DDCKEYCAPS_SRCBLT) ) {
+		this->info.blit_hw_CC = 1;
+	}
+	if ( (DDCaps.dwCaps & DDCAPS_ALPHA) == DDCAPS_ALPHA ) {
+		/* This is only for alpha channel, and DirectX 6
+		   doesn't support 2D alpha blits yet, so set it 0
+		 */
+		this->info.blit_hw_A = 0;
+	}
+	if ( (DDCaps.dwCaps & DDCAPS_CANBLTSYSMEM) == DDCAPS_CANBLTSYSMEM ) {
+		this->info.blit_sw = 1;
+		/* This isn't necessarily true, but the HEL will cover us */
+		this->info.blit_sw_CC = this->info.blit_hw_CC;
+		this->info.blit_sw_A = this->info.blit_hw_A;
+	}
+	if ( (DDCaps.dwCaps & DDCAPS_BLTCOLORFILL) == DDCAPS_BLTCOLORFILL ) {
+		this->info.blit_fill = 1;
+	}
+
+	/* Find out how much video memory is available */
+	{ DDSCAPS ddsCaps;
+	  DWORD total_mem;
+		ddsCaps.dwCaps = DDSCAPS_VIDEOMEMORY;
+		result = IDirectDraw2_GetAvailableVidMem(ddraw2,
+						&ddsCaps, &total_mem, NULL);
+		if ( result != DD_OK ) {
+			total_mem = DDCaps.dwVidMemTotal; 
+		}
+		this->info.video_mem = total_mem/1024;
+	}
+	return(0);
+}
+
+int DX5_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	HRESULT result;
+	LPDIRECTDRAW ddraw;
+	int i, j;
+	HDC hdc;
+
+	/* Intialize everything */
+	ddraw2 = NULL;
+	SDL_primary = NULL;
+	SDL_clipper = NULL;
+	SDL_palette = NULL;
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		SDL_nummodes[i] = 0;
+		SDL_modelist[i] = NULL;
+		SDL_modeindex[i] = 0;
+	}
+	colorchange_expected = 0;
+
+	/* Create the window */
+	if ( DX5_CreateWindow(this) < 0 ) {
+		return(-1);
+	}
+	DX5_SoundFocus(SDL_Window);
+
+	/* Create the DirectDraw object */
+	result = DDrawCreate(NULL, &ddraw, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawCreate", result);
+		return(-1);
+	}
+	result = IDirectDraw_QueryInterface(ddraw, &IID_IDirectDraw2,
+							(LPVOID *)&ddraw2);
+	IDirectDraw_Release(ddraw);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw::QueryInterface", result);
+		return(-1);
+	}
+
+	/* Determine the screen depth */
+	hdc = GetDC(SDL_Window);
+	vformat->BitsPerPixel = GetDeviceCaps(hdc,PLANES) *
+					GetDeviceCaps(hdc,BITSPIXEL);
+	ReleaseDC(SDL_Window, hdc);
+
+	/* Enumerate the available fullscreen modes */
+	for ( i=0; i<NUM_MODELISTS; ++i )
+		enumlists[i] = NULL;
+
+	result = IDirectDraw2_EnumDisplayModes(ddraw2,0,NULL,this,EnumModes2);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw2::EnumDisplayModes", result);
+		return(-1);
+	}
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		struct DX5EnumRect *rect;
+		SDL_modelist[i] = (SDL_Rect **)
+				malloc((SDL_nummodes[i]+1)*sizeof(SDL_Rect *));
+		if ( SDL_modelist[i] == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		for ( j = 0, rect = enumlists[i]; rect; ++j, rect = rect->next ) {
+			SDL_modelist[i][j]=(SDL_Rect *)rect;
+		}
+		SDL_modelist[i][j] = NULL;
+	}
+	
+	/* Fill in some window manager capabilities */
+	this->info.wm_available = 1;
+
+	/* Fill in the video hardware capabilities */
+	DX5_UpdateVideoInfo(this);
+
+	return(0);
+}
+
+SDL_Rect **DX5_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	int bpp;
+
+	bpp = format->BitsPerPixel;
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		/* FIXME:  No support for 1 bpp or 4 bpp formats */
+		switch (bpp) {  /* Does windows support other BPP? */
+			case 8:
+			case 16:
+			case 24:
+			case 32:
+				bpp = (bpp/8)-1;
+				if ( SDL_nummodes[bpp] > 0 )
+					return(SDL_modelist[bpp]);
+				/* Fall through */
+			default:
+				return((SDL_Rect **)0);
+		}
+	} else {
+		if ( this->screen->format->BitsPerPixel == bpp ) {
+			return((SDL_Rect **)-1);
+		} else {
+			return((SDL_Rect **)0);
+		}
+	}
+}
+
+/* Various screen update functions available */
+static void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	SDL_Surface *video;
+	HRESULT result;
+	DWORD sharemode;
+	DWORD style;
+	const DWORD directstyle =
+			(WS_POPUP);
+	const DWORD windowstyle = 
+			(WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX);
+	const DWORD resizestyle =
+			(WS_THICKFRAME|WS_MAXIMIZEBOX);
+	DDSURFACEDESC ddsd;
+	LPDIRECTDRAWSURFACE  dd_surface1;
+	LPDIRECTDRAWSURFACE3 dd_surface3;
+	BOOL was_visible;
+
+#ifdef DDRAW_DEBUG
+ fprintf(stderr, "Setting %dx%dx%d video mode\n", width, height, bpp);
+#endif
+	/* See whether or not we should center the window */
+	was_visible = IsWindowVisible(SDL_Window);
+
+	/* Clean up any previous DirectDraw surfaces */
+	if ( current->hwdata ) {
+		this->FreeHWSurface(this, current);
+		current->hwdata = NULL;
+	}
+	if ( SDL_primary != NULL ) {
+		IDirectDrawSurface3_Release(SDL_primary);
+		SDL_primary = NULL;
+	}
+
+	/* Unset any previous OpenGL fullscreen mode */
+	if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
+	                       (SDL_OPENGL|SDL_FULLSCREEN) ) {
+		ChangeDisplaySettings(NULL, 0);
+	}
+
+	/* Clean up any GL context that may be hanging around */
+	if ( current->flags & SDL_OPENGL ) {
+		WIN_GL_ShutDown(this);
+	}
+
+	/* If we are setting a GL mode, use GDI, not DirectX (yuck) */
+	if ( flags & SDL_OPENGL ) {
+		RECT bounds;
+		int x, y;
+		Uint32 Rmask, Gmask, Bmask;
+
+		/* Recalculate the bitmasks if necessary */
+		if ( bpp == current->format->BitsPerPixel ) {
+			video = current;
+		} else {
+			switch (bpp) {
+			    case 15:
+			    case 16:
+				if ( 0 /*DIB_SussScreenDepth() == 15*/ ) {
+					/* 5-5-5 */
+					Rmask = 0x00007c00;
+					Gmask = 0x000003e0;
+					Bmask = 0x0000001f;
+				} else {
+					/* 5-6-5 */
+					Rmask = 0x0000f800;
+					Gmask = 0x000007e0;
+					Bmask = 0x0000001f;
+				}
+				break;
+			    case 24:
+			    case 32:
+				/* GDI defined as 8-8-8 */
+				Rmask = 0x00ff0000;
+				Gmask = 0x0000ff00;
+				Bmask = 0x000000ff;
+				break;
+			    default:
+				Rmask = 0x00000000;
+				Gmask = 0x00000000;
+				Bmask = 0x00000000;
+				break;
+			}
+			video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0, bpp,
+			                             Rmask, Gmask, Bmask, 0);
+			if ( video == NULL ) {
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+		}
+
+		/* Fill in part of the video surface */
+		video->flags = 0;	/* Clear flags */
+		video->w = width;
+		video->h = height;
+		video->pitch = SDL_CalculatePitch(video);
+
+		/* Set fullscreen mode if appropriate.
+		   Ugh, since our list of valid video modes comes from
+		   the DirectX driver, we may not actually be able to
+		   change to the desired resolution here.
+		   FIXME: Should we do a closest match?
+		 */
+		if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			DEVMODE settings;
+
+			memset(&settings, 0, sizeof(DEVMODE));
+			settings.dmSize = sizeof(DEVMODE);
+			settings.dmBitsPerPel = video->format->BitsPerPixel;
+			settings.dmPelsWidth = width;
+			settings.dmPelsHeight = height;
+			settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT | DM_BITSPERPEL;
+			if ( ChangeDisplaySettings(&settings, CDS_FULLSCREEN) == DISP_CHANGE_SUCCESSFUL ) {
+				video->flags |= SDL_FULLSCREEN;
+			}
+		}
+
+		style = GetWindowLong(SDL_Window, GWL_STYLE);
+		style &= ~(resizestyle|WS_MAXIMIZE);
+		if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			style &= ~windowstyle;
+			style |= directstyle;
+		} else {
+			if ( flags & SDL_NOFRAME ) {
+				style &= ~windowstyle;
+				style |= directstyle;
+				video->flags |= SDL_NOFRAME;
+			} else {
+				style &= ~directstyle;
+				style |= windowstyle;
+				if ( flags & SDL_RESIZABLE ) {
+					style |= resizestyle;
+					video->flags |= SDL_RESIZABLE;
+				}
+			}
+			if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
+		}
+		SetWindowLong(SDL_Window, GWL_STYLE, style);
+
+		/* Resize the window (copied from SDL WinDIB driver) */
+		if ( SDL_windowid == NULL ) {
+			UINT swp_flags;
+
+			SDL_resizing = 1;
+			bounds.left = 0;
+			bounds.top = 0;
+			bounds.right = video->w;
+			bounds.bottom = video->h;
+			AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE);
+			width = bounds.right-bounds.left;
+			height = bounds.bottom-bounds.top;
+			x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
+			y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
+			if ( y < 0 ) { /* Cover up title bar for more client area */
+				y -= GetSystemMetrics(SM_CYCAPTION)/2;
+			}
+			swp_flags = (SWP_NOCOPYBITS | SWP_NOZORDER | SWP_SHOWWINDOW);
+			if ( was_visible && !(flags & SDL_FULLSCREEN) ) {
+				swp_flags |= SWP_NOMOVE;
+			}
+			SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags);
+			SDL_resizing = 0;
+			SetForegroundWindow(SDL_Window);
+		}
+
+		/* Set up for OpenGL */
+		if ( WIN_GL_SetupWindow(this) < 0 ) {
+			return(NULL);
+		}
+		video->flags |= SDL_OPENGL;
+		return(video);
+	}
+
+	/* Set the appropriate window style */
+	style = GetWindowLong(SDL_Window, GWL_STYLE);
+	style &= ~(resizestyle|WS_MAXIMIZE);
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		style &= ~windowstyle;
+		style |= directstyle;
+	} else {
+		if ( flags & SDL_NOFRAME ) {
+			style &= ~windowstyle;
+			style |= directstyle;
+		} else {
+			style &= ~directstyle;
+			style |= windowstyle;
+			if ( flags & SDL_RESIZABLE ) {
+				style |= resizestyle;
+			}
+		}
+		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
+	}
+	SetWindowLong(SDL_Window, GWL_STYLE, style);
+
+	/* Set DirectDraw sharing mode.. exclusive when fullscreen */
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		sharemode = DDSCL_FULLSCREEN|DDSCL_EXCLUSIVE|DDSCL_ALLOWREBOOT;
+	} else {
+		sharemode = DDSCL_NORMAL;
+	}
+	result = IDirectDraw2_SetCooperativeLevel(ddraw2,SDL_Window,sharemode);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw2::SetCooperativeLevel", result);
+		return(NULL);
+	}
+
+	/* Set the display mode, if we are in fullscreen mode */
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		/* Cover up desktop during mode change */
+		SDL_resizing = 1;
+		SetWindowPos(SDL_Window, NULL, 0, 0, 
+			GetSystemMetrics(SM_CXSCREEN),
+			GetSystemMetrics(SM_CYSCREEN),
+			(SWP_NOCOPYBITS | SWP_NOZORDER));
+		SDL_resizing = 0;
+		ShowWindow(SDL_Window, SW_SHOW);
+		while ( GetForegroundWindow() != SDL_Window ) {
+			SetForegroundWindow(SDL_Window);
+			SDL_Delay(100);
+		}
+		result = IDirectDraw2_SetDisplayMode(ddraw2, width, height,
+								bpp, 0, 0);
+		if ( result != DD_OK ) {
+			/* We couldn't set fullscreen mode, try window */
+			return(DX5_SetVideoMode(this, current,
+				width, height, bpp, flags & ~SDL_FULLSCREEN)); 
+		}
+		DX5_DInputReset(this, 1);
+	} else {
+		DX5_DInputReset(this, 0);
+	}
+	DX5_UpdateVideoInfo(this);
+
+	/* Create a primary DirectDraw surface */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	ddsd.dwFlags = DDSD_CAPS;
+	ddsd.ddsCaps.dwCaps = (DDSCAPS_PRIMARYSURFACE|DDSCAPS_VIDEOMEMORY);
+	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
+		/* There's no windowed double-buffering */
+		flags &= ~SDL_DOUBLEBUF;
+	}
+	if ( (flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT;
+		ddsd.ddsCaps.dwCaps |= (DDSCAPS_COMPLEX|DDSCAPS_FLIP);
+		ddsd.dwBackBufferCount = 1;
+	}
+	result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); 
+	if ( (result != DD_OK) && ((flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) ) {
+		ddsd.dwFlags &= ~DDSD_BACKBUFFERCOUNT;
+		ddsd.ddsCaps.dwCaps &= ~(DDSCAPS_COMPLEX|DDSCAPS_FLIP);
+		ddsd.dwBackBufferCount = 0;
+		result = IDirectDraw2_CreateSurface(ddraw2,
+						&ddsd, &dd_surface1, NULL); 
+	}
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw2::CreateSurface(PRIMARY)", result);
+		return(NULL);
+	}
+	result = IDirectDrawSurface_QueryInterface(dd_surface1,
+			&IID_IDirectDrawSurface3, (LPVOID *)&SDL_primary);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface::QueryInterface", result);
+		return(NULL);
+	}
+	result = IDirectDrawSurface_Release(dd_surface1);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface::Release", result);
+		return(NULL);
+	}
+
+	/* Get the format of the primary DirectDraw surface */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	ddsd.dwFlags = DDSD_PIXELFORMAT|DDSD_CAPS;
+	result = IDirectDrawSurface3_GetSurfaceDesc(SDL_primary, &ddsd);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface::Release", result);
+		return(NULL);
+	}
+	if ( ! (ddsd.ddpfPixelFormat.dwFlags&DDPF_RGB) ) {
+		SDL_SetError("Primary DDRAW surface is not RGB format");
+		return(NULL);
+	}
+
+	/* Free old palette and create a new one if we're in 8-bit mode */
+	if ( SDL_palette != NULL ) {
+		IDirectDrawPalette_Release(SDL_palette);
+		SDL_palette = NULL;
+	}
+#if defined(NONAMELESSUNION)
+	if ( ddsd.ddpfPixelFormat.u1.dwRGBBitCount == 8 ) {
+#else
+	if ( ddsd.ddpfPixelFormat.dwRGBBitCount == 8 ) {
+#endif
+		int i;
+
+		if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			/* We have access to the entire palette */
+			for ( i=0; i<256; ++i ) {
+				SDL_colors[i].peFlags =
+						(PC_NOCOLLAPSE|PC_RESERVED);
+				SDL_colors[i].peRed = 0;
+				SDL_colors[i].peGreen = 0;
+				SDL_colors[i].peBlue = 0;
+			}
+		} else {
+			/* First 10 colors are reserved by Windows */
+			for ( i=0; i<10; ++i ) {
+				SDL_colors[i].peFlags = PC_EXPLICIT;
+				SDL_colors[i].peRed = i;
+				SDL_colors[i].peGreen = 0;
+				SDL_colors[i].peBlue = 0;
+			}
+			for ( i=10; i<(10+236); ++i ) {
+				SDL_colors[i].peFlags = PC_NOCOLLAPSE;
+				SDL_colors[i].peRed = 0;
+				SDL_colors[i].peGreen = 0;
+				SDL_colors[i].peBlue = 0;
+			}
+			/* Last 10 colors are reserved by Windows */
+			for ( i=246; i<256; ++i ) {
+				SDL_colors[i].peFlags = PC_EXPLICIT;
+				SDL_colors[i].peRed = i;
+				SDL_colors[i].peGreen = 0;
+				SDL_colors[i].peBlue = 0;
+			}
+		}
+		result = IDirectDraw2_CreatePalette(ddraw2,
+		     			(DDPCAPS_8BIT|DDPCAPS_ALLOW256),
+						SDL_colors, &SDL_palette, NULL);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDraw2::CreatePalette", result);
+			return(NULL);
+		}
+		result = IDirectDrawSurface3_SetPalette(SDL_primary,
+								SDL_palette);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDrawSurface3::SetPalette", result);
+			return(NULL);
+		}
+	}
+
+	/* Create our video surface using the same pixel format */
+	video = current;
+	if ( (width != video->w) || (height != video->h)
+			|| (video->format->BitsPerPixel != 
+#if defined(NONAMELESSUNION)
+				ddsd.ddpfPixelFormat.u1.dwRGBBitCount) ) {
+#else
+				ddsd.ddpfPixelFormat.dwRGBBitCount) ) {
+#endif
+		SDL_FreeSurface(video);
+		video = SDL_CreateRGBSurface(SDL_SWSURFACE, 0, 0,
+#if defined(NONAMELESSUNION)
+				ddsd.ddpfPixelFormat.u1.dwRGBBitCount,
+					ddsd.ddpfPixelFormat.u2.dwRBitMask,
+					ddsd.ddpfPixelFormat.u3.dwGBitMask,
+					ddsd.ddpfPixelFormat.u4.dwBBitMask,
+#else
+				ddsd.ddpfPixelFormat.dwRGBBitCount,
+					ddsd.ddpfPixelFormat.dwRBitMask,
+					ddsd.ddpfPixelFormat.dwGBitMask,
+					ddsd.ddpfPixelFormat.dwBBitMask,
+#endif
+								0);
+		if ( video == NULL ) {
+			SDL_OutOfMemory();
+			return(NULL);
+		}
+		video->w = width;
+		video->h = height;
+		video->pitch = 0;
+	}
+	video->flags = 0;	/* Clear flags */
+
+	/* If not fullscreen, locking is possible, but it doesn't do what 
+	   the caller really expects -- if the locked surface is written to,
+	   the appropriate portion of the entire screen is modified, not 
+	   the application window, as we would like.
+	   Note that it is still possible to write directly to display
+	   memory, but the application must respect the clip list of
+	   the surface.  There might be some odd timing interactions
+	   involving clip list updates and background refreshing as
+	   Windows moves other windows across our window.
+	   We currently don't support this, even though it might be a
+	   good idea since BeOS has an implementation of BDirectWindow
+	   that does the same thing.  This would be most useful for
+	   applications that do complete screen updates every frame.
+	    -- Fixme?
+	*/
+	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
+		/* Necessary if we're going from fullscreen to window */
+		if ( video->pixels == NULL ) {
+			video->pitch = (width*video->format->BytesPerPixel);
+			/* Pitch needs to be QWORD (8-byte) aligned */
+			video->pitch = (video->pitch + 7) & ~7;
+			video->pixels = (void *)malloc(video->h*video->pitch);
+			if ( video->pixels == NULL ) {
+				if ( video != current ) {
+					SDL_FreeSurface(video);
+				}
+				SDL_OutOfMemory();
+				return(NULL);
+			}
+		}
+		dd_surface3 = NULL;
+		video->flags |= SDL_SWSURFACE;
+		if ( (flags & SDL_RESIZABLE) && !(flags & SDL_NOFRAME) ) {
+			video->flags |= SDL_RESIZABLE;
+		}
+		if ( flags & SDL_NOFRAME ) {
+			video->flags |= SDL_NOFRAME;
+		}
+	} else {
+		/* Necessary if we're going from window to fullscreen */
+		if ( video->pixels != NULL ) {
+			free(video->pixels);
+			video->pixels = NULL;
+		}
+		dd_surface3 = SDL_primary;
+		video->flags |= SDL_HWSURFACE;
+	}
+
+	/* See if the primary surface has double-buffering enabled */
+	if ( (ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP) == DDSCAPS_FLIP ) {
+		video->flags |= SDL_DOUBLEBUF;
+	}
+
+	/* Allocate the SDL surface associated with the primary surface */
+	if ( DX5_AllocDDSurface(this, video, dd_surface3,
+	                        video->flags&SDL_HWSURFACE) < 0 ) {
+		if ( video != current ) {
+			SDL_FreeSurface(video);
+		}
+		return(NULL);
+	}
+
+	/* Use the appropriate blitting function */
+	if ( (flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+		video->flags |= SDL_FULLSCREEN;
+		if ( video->format->palette != NULL ) {
+			video->flags |= SDL_HWPALETTE;
+		}
+		this->UpdateRects = DX5_DirectUpdate;
+	} else {
+		this->UpdateRects = DX5_WindowUpdate;
+	}
+
+	/* Make our window the proper size, set the clipper, then show it */
+	if ( (flags & SDL_FULLSCREEN) != SDL_FULLSCREEN ) {
+		RECT bounds;
+		int  x, y;
+		UINT swp_flags;
+
+		/* Create and set a clipper on our primary surface */
+		if ( SDL_clipper == NULL ) {
+			result = IDirectDraw2_CreateClipper(ddraw2,
+							0, &SDL_clipper, NULL);
+			if ( result != DD_OK ) {
+				if ( video != current ) {
+					SDL_FreeSurface(video);
+				}
+				SetDDerror("DirectDraw2::CreateClipper",result);
+				return(NULL);
+			}
+		}
+		result = IDirectDrawClipper_SetHWnd(SDL_clipper, 0, SDL_Window);
+		if ( result != DD_OK ) {
+			if ( video != current ) {
+				SDL_FreeSurface(video);
+			}
+			SetDDerror("DirectDrawClipper::SetHWnd", result);
+			return(NULL);
+		}
+		result = IDirectDrawSurface3_SetClipper(SDL_primary,
+								SDL_clipper);
+		if ( result != DD_OK ) {
+			if ( video != current ) {
+				SDL_FreeSurface(video);
+			}
+			SetDDerror("DirectDrawSurface3::SetClipper", result);
+			return(NULL);
+		}
+
+		/* Set the size of the window, centering and adjusting */
+		SDL_resizing = 1;
+		bounds.left = 0;
+		bounds.top = 0;
+		bounds.right = video->w;
+		bounds.bottom = video->h;
+		AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE),
+									FALSE);
+		width = bounds.right-bounds.left;
+		height = bounds.bottom-bounds.top;
+		x = (GetSystemMetrics(SM_CXSCREEN)-width)/2;
+		y = (GetSystemMetrics(SM_CYSCREEN)-height)/2;
+		if ( y < 0 ) { /* Cover up title bar for more client area */
+			y -= GetSystemMetrics(SM_CYCAPTION)/2;
+		}
+		swp_flags = (SWP_NOCOPYBITS | SWP_NOZORDER);
+		if ( was_visible ) {
+			swp_flags |= SWP_NOMOVE;
+		}
+		SetWindowPos(SDL_Window, NULL, x, y, width, height, swp_flags);
+		SDL_resizing = 0;
+	}
+	ShowWindow(SDL_Window, SW_SHOW);
+	SetForegroundWindow(SDL_Window);
+
+	/* We're live! */
+	return(video);
+}
+
+struct private_hwdata {
+	LPDIRECTDRAWSURFACE3 dd_surface;
+	LPDIRECTDRAWSURFACE3 dd_writebuf;
+};
+
+static int DX5_AllocDDSurface(_THIS, SDL_Surface *surface, 
+				LPDIRECTDRAWSURFACE3 requested, Uint32 flag)
+{
+	LPDIRECTDRAWSURFACE  dd_surface1;
+	LPDIRECTDRAWSURFACE3 dd_surface3;
+	DDSURFACEDESC ddsd;
+	HRESULT result;
+
+	/* Clear the hardware flag, in case we fail */
+	surface->flags &= ~flag;
+
+	/* Allocate the hardware acceleration data */
+	surface->hwdata = (struct private_hwdata *)
+					malloc(sizeof(*surface->hwdata));
+	if ( surface->hwdata == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	dd_surface3 = NULL;
+
+	/* Set up the surface description */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|
+					DDSD_PITCH|DDSD_PIXELFORMAT);
+	ddsd.dwWidth = surface->w;
+	ddsd.dwHeight= surface->h;
+#if defined(NONAMELESSUNION)
+	ddsd.u1.lPitch = surface->pitch;
+#else
+	ddsd.lPitch = surface->pitch;
+#endif
+	if ( (flag & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		ddsd.ddsCaps.dwCaps =
+				(DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY);
+	} else {
+		ddsd.ddsCaps.dwCaps =
+				(DDSCAPS_OFFSCREENPLAIN|DDSCAPS_SYSTEMMEMORY);
+	}
+	ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
+	ddsd.ddpfPixelFormat.dwFlags = DDPF_RGB;
+	if ( surface->format->palette ) {
+		ddsd.ddpfPixelFormat.dwFlags |= DDPF_PALETTEINDEXED8;
+	}
+#if defined(NONAMELESSUNION)
+	ddsd.ddpfPixelFormat.u1.dwRGBBitCount = surface->format->BitsPerPixel;
+	ddsd.ddpfPixelFormat.u2.dwRBitMask = surface->format->Rmask;
+	ddsd.ddpfPixelFormat.u3.dwGBitMask = surface->format->Gmask;
+	ddsd.ddpfPixelFormat.u4.dwBBitMask = surface->format->Bmask;
+#else
+	ddsd.ddpfPixelFormat.dwRGBBitCount = surface->format->BitsPerPixel;
+	ddsd.ddpfPixelFormat.dwRBitMask = surface->format->Rmask;
+	ddsd.ddpfPixelFormat.dwGBitMask = surface->format->Gmask;
+	ddsd.ddpfPixelFormat.dwBBitMask = surface->format->Bmask;
+#endif
+
+	/* Create the DirectDraw video surface */
+	if ( requested != NULL ) {
+		dd_surface3 = requested;
+	} else {
+		result = IDirectDraw2_CreateSurface(ddraw2,
+						&ddsd, &dd_surface1, NULL); 
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDraw2::CreateSurface", result);
+			goto error_end;
+		}
+		result = IDirectDrawSurface_QueryInterface(dd_surface1,
+			&IID_IDirectDrawSurface3, (LPVOID *)&dd_surface3);
+		IDirectDrawSurface_Release(dd_surface1);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDrawSurface::QueryInterface", result);
+			goto error_end;
+		}
+	}
+
+	if ( (flag & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		/* Check to see whether the surface actually ended up
+		   in video memory, and fail if not.  We expect the
+		   surfaces we create here to actually be in hardware!
+		*/
+		result = IDirectDrawSurface3_GetCaps(dd_surface3,&ddsd.ddsCaps);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDrawSurface3::GetCaps", result);
+			goto error_end;
+		}
+		if ( (ddsd.ddsCaps.dwCaps&DDSCAPS_VIDEOMEMORY) !=
+							DDSCAPS_VIDEOMEMORY ) {
+			SDL_SetError("No room in video memory");
+			goto error_end;
+		}
+	} else {
+		/* Try to hook our surface memory */
+		ddsd.dwFlags = DDSD_LPSURFACE;
+		ddsd.lpSurface = surface->pixels;
+		result = IDirectDrawSurface3_SetSurfaceDesc(dd_surface3,
+								&ddsd, 0);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDraw2::SetSurfaceDesc", result);
+			goto error_end;
+		}
+	
+	}
+
+	/* Make sure the surface format was set properly */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	result = IDirectDrawSurface3_Lock(dd_surface3, NULL,
+					&ddsd, DDLOCK_NOSYSLOCK, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Lock", result);
+		goto error_end;
+	}
+	IDirectDrawSurface3_Unlock(dd_surface3, NULL);
+
+	if ( (flag & SDL_HWSURFACE) == SDL_SWSURFACE ) {
+		if ( ddsd.lpSurface != surface->pixels ) {
+			SDL_SetError("DDraw didn't use SDL surface memory");
+			goto error_end;
+		}
+		if (
+#if defined(NONAMELESSUNION)
+			ddsd.u1.lPitch
+#else
+			ddsd.lPitch
+#endif
+				 != (LONG)surface->pitch ) {
+			SDL_SetError("DDraw created surface with wrong pitch");
+			goto error_end;
+		}
+	} else {
+#if defined(NONAMELESSUNION)
+		surface->pitch = (Uint16)ddsd.u1.lPitch;
+#else
+		surface->pitch = (Uint16)ddsd.lPitch;
+#endif
+	}
+#if defined(NONAMELESSUNION)
+	if ( (ddsd.ddpfPixelFormat.u1.dwRGBBitCount != 
+					surface->format->BitsPerPixel) ||
+	     (ddsd.ddpfPixelFormat.u2.dwRBitMask != surface->format->Rmask) ||
+	     (ddsd.ddpfPixelFormat.u3.dwGBitMask != surface->format->Gmask) ||
+	     (ddsd.ddpfPixelFormat.u4.dwBBitMask != surface->format->Bmask) ){
+#else
+	if ( (ddsd.ddpfPixelFormat.dwRGBBitCount != 
+					surface->format->BitsPerPixel) ||
+	     (ddsd.ddpfPixelFormat.dwRBitMask != surface->format->Rmask) ||
+	     (ddsd.ddpfPixelFormat.dwGBitMask != surface->format->Gmask) ||
+	     (ddsd.ddpfPixelFormat.dwBBitMask != surface->format->Bmask) ){
+#endif
+		SDL_SetError("DDraw didn't use SDL surface description");
+		goto error_end;
+	}
+	if ( (ddsd.dwWidth != (DWORD)surface->w) ||
+		(ddsd.dwHeight != (DWORD)surface->h) ) {
+		SDL_SetError("DDraw created surface with wrong size");
+		goto error_end;
+	}
+
+	/* Set the surface private data */
+	surface->flags |= flag;
+	surface->hwdata->dd_surface = dd_surface3;
+	if ( (surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		LPDIRECTDRAWSURFACE3 dd_writebuf;
+
+		ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
+		result = IDirectDrawSurface3_GetAttachedSurface(dd_surface3,
+						&ddsd.ddsCaps, &dd_writebuf);
+		if ( result != DD_OK ) {
+			SetDDerror("DirectDrawSurface3::GetAttachedSurface",
+								result);
+		} else {
+			dd_surface3 = dd_writebuf;
+		}
+	}
+	surface->hwdata->dd_writebuf = dd_surface3;
+
+	/* We're ready to go! */
+	return(0);
+
+	/* Okay, so goto's are cheesy, but there are so many possible
+	   errors in this function, and the cleanup is the same in 
+	   every single case.  Is there a better way, other than deeply
+	   nesting the code?
+	*/
+error_end:
+	if ( (dd_surface3 != NULL) && (dd_surface3 != requested) ) {
+		IDirectDrawSurface_Release(dd_surface3);
+	}
+	free(surface->hwdata);
+	surface->hwdata = NULL;
+	return(-1);
+}
+
+static int DX5_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	/* DDraw limitation -- you need to set cooperative level first */
+	if ( SDL_primary == NULL ) {
+		SDL_SetError("You must set a non-GL video mode first");
+		return(-1);
+	}
+	return(DX5_AllocDDSurface(this, surface, NULL, SDL_HWSURFACE));
+}
+
+void PrintSurface(char *title, LPDIRECTDRAWSURFACE3 surface, Uint32 flags)
+{
+	DDSURFACEDESC ddsd;
+
+	/* Lock and load! */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	if ( IDirectDrawSurface3_Lock(surface, NULL, &ddsd,
+			(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL) != DD_OK ) {
+		return;
+	}
+	IDirectDrawSurface3_Unlock(surface, NULL);
+	
+	fprintf(stderr, "%s:\n", title);
+	fprintf(stderr, "\tSize: %dx%d in %s at %ld bpp (pitch = %ld)\n",
+		ddsd.dwWidth, ddsd.dwHeight,
+		(flags & SDL_HWSURFACE) ? "hardware" : "software",
+#if defined(NONAMELESSUNION)
+		ddsd.ddpfPixelFormat.u1.dwRGBBitCount, ddsd.u1.lPitch);
+#else
+		ddsd.ddpfPixelFormat.dwRGBBitCount, ddsd.lPitch);
+#endif
+	fprintf(stderr, "\tR = 0x%X, G = 0x%X, B = 0x%X\n", 
+#if defined(NONAMELESSUNION)
+	     		ddsd.ddpfPixelFormat.u2.dwRBitMask,
+	     		ddsd.ddpfPixelFormat.u3.dwGBitMask,
+	     		ddsd.ddpfPixelFormat.u4.dwBBitMask);
+#else
+	     		ddsd.ddpfPixelFormat.dwRBitMask,
+	     		ddsd.ddpfPixelFormat.dwGBitMask,
+	     		ddsd.ddpfPixelFormat.dwBBitMask);
+#endif
+}
+
+static int DX5_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+					SDL_Surface *dst, SDL_Rect *dstrect)
+{
+	LPDIRECTDRAWSURFACE3 src_surface;
+	LPDIRECTDRAWSURFACE3 dst_surface;
+	DWORD flags;
+	RECT rect;
+	HRESULT result;
+
+	/* Set it up.. the desination must have a DDRAW surface */
+	src_surface = src->hwdata->dd_writebuf;
+	dst_surface = dst->hwdata->dd_writebuf;
+	rect.top    = srcrect->y;
+	rect.bottom = srcrect->y+srcrect->h;
+	rect.left   = srcrect->x;
+	rect.right  = srcrect->x+srcrect->w;
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY )
+		flags = DDBLTFAST_SRCCOLORKEY;
+	else
+		flags = DDBLTFAST_NOCOLORKEY;
+	/* FIXME:  We can remove this flag for _really_ fast blit queuing,
+	           but it will affect the return values of locks and flips.
+	 */
+	flags |= DDBLTFAST_WAIT;
+
+	/* Do the blit! */
+	result = IDirectDrawSurface3_BltFast(dst_surface,
+			dstrect->x, dstrect->y, src_surface, &rect, flags);
+	if ( result != DD_OK ) {
+		if ( result == DDERR_SURFACELOST ) {
+			result = IDirectDrawSurface3_Restore(src_surface);
+			result = IDirectDrawSurface3_Restore(dst_surface);
+			/* The surfaces need to be reloaded with artwork */
+			SDL_SetError("Blit surfaces were lost, reload them");
+			return(-2);
+		}
+		SetDDerror("IDirectDrawSurface3::BltFast", result);
+#ifdef DDRAW_DEBUG
+ fprintf(stderr, "Original dest rect: %dx%d at %d,%d\n", dstrect->w, dstrect->h, dstrect->x, dstrect->y);
+ fprintf(stderr, "HW accelerated %sblit to from 0x%p to 0x%p at (%d,%d)\n",
+		(src->flags & SDL_SRCCOLORKEY) ? "colorkey " : "", src, dst,
+					dstrect->x, dstrect->y);
+  PrintSurface("SRC", src_surface, src->flags);
+  PrintSurface("DST", dst_surface, dst->flags);
+ fprintf(stderr, "Source rectangle: (%d,%d) - (%d,%d)\n",
+		rect.left, rect.top, rect.right, rect.bottom);
+#endif
+		/* Unexpected error, fall back to software blit */
+		return(src->map->sw_blit(src, srcrect, dst, dstrect));
+	}
+	return(0);
+}
+
+static int DX5_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+	int accelerated;
+
+	/* We need to have a DDraw surface for HW blits */
+	if ( (src->flags & SDL_HWSURFACE) == SDL_SWSURFACE ) {
+		/* Allocate a DDraw surface for the blit */
+		if ( src->hwdata == NULL ) {
+			DX5_AllocDDSurface(this, src, NULL, SDL_SWSURFACE);
+		}
+	}
+	if ( src->hwdata == NULL ) {
+		return(0);
+	}
+
+	/* Set initial acceleration on */
+	src->flags |= SDL_HWACCEL;
+
+	/* Set the surface attributes */
+	if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+		if ( DX5_SetHWColorKey(this, src, src->format->colorkey) < 0 ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+	if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+		if ( DX5_SetHWAlpha(this, src, src->format->alpha) < 0 ) {
+			src->flags &= ~SDL_HWACCEL;
+		}
+	}
+
+	/* Check to see if final surface blit is accelerated */
+	accelerated = !!(src->flags & SDL_HWACCEL);
+	if ( accelerated ) {
+#ifdef DDRAW_DEBUG
+  fprintf(stderr, "Setting accelerated blit on 0x%p\n", src);
+#endif
+		src->map->hw_blit = DX5_HWAccelBlit;
+	}
+	return(accelerated);
+}
+
+static int DX5_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color)
+{
+	LPDIRECTDRAWSURFACE3 dst_surface;
+	RECT area;
+	DDBLTFX bltfx;
+	HRESULT result;
+
+#ifdef DDRAW_DEBUG
+ fprintf(stderr, "HW accelerated fill at (%d,%d)\n", dstrect->x, dstrect->y);
+#endif
+	dst_surface = dst->hwdata->dd_writebuf;
+	area.top = dstrect->y;
+	area.bottom = dstrect->y+dstrect->h;
+	area.left = dstrect->x;
+	area.right = dstrect->x+dstrect->w;
+	bltfx.dwSize = sizeof(bltfx);
+#if defined(NONAMELESSUNION)
+	bltfx.u5.dwFillColor = color;
+#else
+	bltfx.dwFillColor = color;
+#endif
+	result = IDirectDrawSurface3_Blt(dst_surface,
+			&area, NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &bltfx);
+	if ( result == DDERR_SURFACELOST ) {
+		IDirectDrawSurface3_Restore(dst_surface);
+		result = IDirectDrawSurface3_Blt(dst_surface,
+			&area, NULL, NULL, DDBLT_COLORFILL|DDBLT_WAIT, &bltfx);
+	}
+	if ( result != DD_OK ) {
+		SetDDerror("IDirectDrawSurface3::Blt", result);
+		return(-1);
+	}
+	return(0);
+}
+
+static int DX5_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+	DDCOLORKEY colorkey;
+	HRESULT result;
+
+	/* Set the surface colorkey */
+	colorkey.dwColorSpaceLowValue = key;
+	colorkey.dwColorSpaceHighValue = key;
+	result = IDirectDrawSurface3_SetColorKey(
+			surface->hwdata->dd_surface, DDCKEY_SRCBLT, &colorkey);
+	if ( result != DD_OK ) {
+		SetDDerror("IDirectDrawSurface3::SetColorKey", result);
+		return(-1);
+	}
+	return(0);
+}
+static int DX5_SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 alpha)
+{
+	return(-1);
+}
+
+static int DX5_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	HRESULT result;
+	LPDIRECTDRAWSURFACE3 dd_surface;
+	DDSURFACEDESC ddsd;
+
+	/* Lock and load! */
+	dd_surface = surface->hwdata->dd_writebuf;
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd,
+					(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
+	if ( result == DDERR_SURFACELOST ) {
+		result = IDirectDrawSurface3_Restore(
+						surface->hwdata->dd_surface);
+		result = IDirectDrawSurface3_Lock(dd_surface, NULL, &ddsd, 
+					(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
+	}
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Lock", result);
+		return(-1);
+	}
+	/* Pitch might have changed -- recalculate pitch and offset */
+#if defined(NONAMELESSUNION)
+	if ( surface->pitch != ddsd.u1.lPitch ) {
+		surface->pitch = ddsd.u1.lPitch;
+#else
+	if ( surface->pitch != ddsd.lPitch ) {
+		surface->pitch = (Uint16)ddsd.lPitch;
+#endif
+		surface->offset =
+			((ddsd.dwHeight-surface->h)/2)*surface->pitch +
+			((ddsd.dwWidth-surface->w)/2)*
+					surface->format->BytesPerPixel;
+	}
+	surface->pixels = ddsd.lpSurface;
+	return(0);
+}
+
+static void DX5_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	IDirectDrawSurface3_Unlock(surface->hwdata->dd_writebuf, NULL);
+	surface->pixels = NULL;
+}
+
+static int DX5_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	HRESULT result;
+	LPDIRECTDRAWSURFACE3 dd_surface;
+
+	dd_surface = surface->hwdata->dd_surface;
+	result = IDirectDrawSurface3_Flip(dd_surface, NULL, DDFLIP_WAIT);
+	if ( result == DDERR_SURFACELOST ) {
+		result = IDirectDrawSurface3_Restore(
+						surface->hwdata->dd_surface);
+		result = IDirectDrawSurface3_Flip(dd_surface,NULL,DDFLIP_WAIT);
+	}
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Flip", result);
+		return(-1);
+	}
+	return(0);
+}
+
+static void DX5_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface->hwdata ) {
+		if ( surface->hwdata->dd_surface != SDL_primary ) {
+			IDirectDrawSurface3_Release(surface->hwdata->dd_surface);
+		}
+		free(surface->hwdata);
+		surface->hwdata = NULL;
+	}
+}
+
+void DX5_WindowUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	HRESULT result;
+	int i;
+	RECT src, dst;
+
+	for ( i=0; i<numrects; ++i ) {
+		src.top = rects[i].y;
+		src.bottom = rects[i].y+rects[i].h;
+		src.left = rects[i].x;
+		src.right = rects[i].x+rects[i].w;
+		dst.top = SDL_bounds.top+src.top;
+		dst.left = SDL_bounds.left+src.left;
+		dst.bottom = SDL_bounds.top+src.bottom;
+		dst.right = SDL_bounds.left+src.right;
+		result = IDirectDrawSurface3_Blt(SDL_primary, &dst, 
+					this->screen->hwdata->dd_surface, &src,
+							DDBLT_WAIT, NULL);
+		/* Doh!  Check for lost surface and restore it */
+		if ( result == DDERR_SURFACELOST ) {
+			IDirectDrawSurface3_Restore(SDL_primary);
+			IDirectDrawSurface3_Blt(SDL_primary, &dst, 
+					this->screen->hwdata->dd_surface, &src,
+							DDBLT_WAIT, NULL);
+		}
+	}
+}
+
+void DX5_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+}
+
+/* Compress a full palette into the limited number of colors given to us
+   by windows.
+
+   The "best" way to do this is to sort the colors by diversity and place
+   the most diverse colors into the limited palette.  Unfortunately this
+   results in widely varying colors being displayed in the interval during
+   which the windows palette has been set, and the mapping of the shadow
+   surface to the new palette.  This is especially noticeable during fades.
+
+   To deal with this problem, we can copy a predetermined portion of the
+   full palette, and use that as the limited palette.  This allows colors
+   to fade smoothly as the remapping is very similar on each palette change.
+   Unfortunately, this breaks applications which partition the palette into
+   distinct and widely varying areas, expecting all colors to be available.
+
+   I'm making them both available, chosen at compile time.
+   If you want the chunk-o-palette algorithm, define SIMPLE_COMPRESSION,
+   otherwise the sort-by-diversity algorithm will be used.
+*/
+#define SIMPLE_COMPRESSION
+#define CS_CS_DIST(A, B) ({						\
+	int r = (A.r - B.r);						\
+	int g = (A.g - B.g);						\
+	int b = (A.b - B.b);						\
+	(r*r + g*g + b*b);						\
+})
+static void DX5_CompressPalette(_THIS, SDL_Color *colors, int ncolors, int maxcolors)
+{
+#ifdef SIMPLE_COMPRESSION
+	int i, j;
+#else
+	static SDL_Color zero = { 0, 0, 0, 0 };
+	int i, j;
+	int max, dist;
+	int prev, next;
+	int *pool;
+	int *seen, *order;
+#endif
+
+	/* Does this happen? */
+	if ( maxcolors > ncolors ) {
+		maxcolors = ncolors;
+	}
+
+#ifdef SIMPLE_COMPRESSION
+	/* Just copy the first "maxcolors" colors */
+	for ( j=10, i=0; i<maxcolors; ++i, ++j ) {
+		SDL_colors[j].peRed = colors[i].r;
+		SDL_colors[j].peGreen = colors[i].g;
+		SDL_colors[j].peBlue = colors[i].b;
+	}
+#else
+	/* Allocate memory for the arrays we use */
+	pool = (int *)alloca(2*ncolors*sizeof(int));
+	if ( pool == NULL ) {
+		/* No worries, just return */;
+		return;
+	}
+	seen = pool;
+	memset(seen, 0, ncolors*sizeof(int));
+	order = pool+ncolors;
+
+	/* Start with the brightest color */
+	max = 0;
+	for ( i=0; i<ncolors; ++i ) {
+		dist = CS_CS_DIST(zero, colors[i]);
+		if ( dist >= max ) {
+			max = dist;
+			next = i;
+		}
+	}
+	j = 0;
+	order[j++] = next;
+	seen[next] = 1;
+	prev = next;
+
+	/* Keep going through all the colors */
+	while ( j < maxcolors ) {
+		max = 0;
+		for ( i=0; i<ncolors; ++i ) {
+			if ( seen[i] ) {
+				continue;
+			}
+			dist = CS_CS_DIST(colors[i], colors[prev]);
+			if ( dist >= max ) {
+				max = dist;
+				next = i;
+			}
+		}
+		order[j++] = next;
+		seen[next] = 1;
+		prev = next;
+	}
+
+	/* Compress the colors to the palette */
+	for ( j=10, i=0; i<maxcolors; ++i, ++j ) {
+		SDL_colors[j].peRed = colors[order[i]].r;
+		SDL_colors[j].peGreen = colors[order[i]].g;
+		SDL_colors[j].peBlue = colors[order[i]].b;
+	}
+#endif /* SIMPLE_COMPRESSION */
+}
+
+/* Set the system colormap in both fullscreen and windowed modes */
+int DX5_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+	int alloct_all;
+
+	/* Copy palette colors into display palette */
+	alloct_all = 0;
+	if ( SDL_palette != NULL ) {
+		if ( (this->screen->flags&SDL_FULLSCREEN) == SDL_FULLSCREEN ) {
+			/* We can set all entries explicitly */
+			for ( i=0; i< ncolors; ++i ) {
+			        int j = firstcolor + i;
+				SDL_colors[j].peRed = colors[i].r;
+				SDL_colors[j].peGreen = colors[i].g;
+				SDL_colors[j].peBlue = colors[i].b;
+			}
+			IDirectDrawPalette_SetEntries(SDL_palette, 0,
+				firstcolor, ncolors, &SDL_colors[firstcolor]);
+			alloct_all = 1;
+		} else {
+			/* Grab the 236 most diverse colors in the palette */
+			DX5_CompressPalette(this, colors, ncolors, 236);
+			/* This sends an WM_PALETTECHANGED message to us */
+			colorchange_expected = 1;
+			IDirectDrawPalette_SetEntries(SDL_palette, 0,
+							0, 256, SDL_colors);
+		}
+	}
+	return(alloct_all);
+}
+
+static void DX5_SwapGamma(_THIS)
+{
+	return;
+}
+
+/* Gamma code is only available on DirectX 7 and newer */
+#ifdef IID_IDirectDrawGammaControl
+
+static int DX5_SetGammaRamp(_THIS, Uint16 *ramp)
+{
+	LPDIRECTDRAWGAMMACONTROL gamma;
+	DDGAMMARAMP gamma_ramp;
+	HRESULT result;
+
+	/* Check for a video mode! */
+	if ( ! SDL_primary ) {
+		SDL_SetError("A video mode must be set for gamma correction");
+		return(-1);
+	}
+
+	/* Get the gamma control object */
+	result = IDirectDrawSurface3_QueryInterface(SDL_primary,
+			&IID_IDirectDrawGammaControl, (LPVOID *)&gamma);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result);
+		return(-1);
+	}
+
+	/* Set up the gamma ramp */
+	memcpy(gamma_ramp.red, &ramp[0*256], 256*sizeof(*ramp));
+	memcpy(gamma_ramp.green, &ramp[1*256], 256*sizeof(*ramp));
+	memcpy(gamma_ramp.blue, &ramp[2*256], 256*sizeof(*ramp));
+	result = IDirectDrawGammaControl_SetGammaRamp(gamma, 0, &gamma_ramp);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawGammaControl::SetGammaRamp()", result);
+	}
+
+	/* Release the interface and return */
+	IDirectDrawGammaControl_Release(gamma);
+	return (result == DD_OK) ? 0 : -1;
+}
+
+static int DX5_GetGammaRamp(_THIS, Uint16 *ramp)
+{
+	LPDIRECTDRAWGAMMACONTROL gamma;
+	DDGAMMARAMP gamma_ramp;
+	HRESULT result;
+
+	/* Check for a video mode! */
+	if ( ! SDL_primary ) {
+		SDL_SetError("A video mode must be set for gamma correction");
+		return(-1);
+	}
+
+	/* Get the gamma control object */
+	result = IDirectDrawSurface3_QueryInterface(SDL_primary,
+			&IID_IDirectDrawGammaControl, (LPVOID *)&gamma);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::QueryInterface(GAMMA)", result);
+		return(-1);
+	}
+
+	/* Set up the gamma ramp */
+	result = IDirectDrawGammaControl_GetGammaRamp(gamma, 0, &gamma_ramp);
+	if ( result == DD_OK ) {
+		memcpy(&ramp[0*256], gamma_ramp.red, 256*sizeof(*ramp));
+		memcpy(&ramp[1*256], gamma_ramp.green, 256*sizeof(*ramp));
+		memcpy(&ramp[2*256], gamma_ramp.blue, 256*sizeof(*ramp));
+	} else {
+		SetDDerror("DirectDrawGammaControl::GetGammaRamp()", result);
+	}
+
+	/* Release the interface and return */
+	IDirectDrawGammaControl_Release(gamma);
+	return (result == DD_OK) ? 0 : -1;
+}
+
+#endif /* IID_IDirectDrawGammaControl */
+
+void DX5_VideoQuit(_THIS)
+{
+	int i, j;
+
+	/* If we're fullscreen GL, we need to reset the display */
+	if ( this->screen != NULL ) {
+		if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) ==
+		                            (SDL_OPENGL|SDL_FULLSCREEN) ) {
+			ChangeDisplaySettings(NULL, 0);
+		}
+		if ( this->screen->flags & SDL_OPENGL ) {
+			WIN_GL_ShutDown(this);
+		}
+	}
+
+	/* Free any palettes we used */
+	if ( SDL_palette != NULL ) {
+		IDirectDrawPalette_Release(SDL_palette);
+		SDL_palette = NULL;
+	}
+
+	/* Allow the primary surface to be freed */
+	if ( SDL_primary != NULL ) {
+		SDL_primary = NULL;
+	}
+
+	/* Free video mode lists */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_modelist[i] != NULL ) {
+			for ( j=0; SDL_modelist[i][j]; ++j )
+				free(SDL_modelist[i][j]);
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+	}
+
+	/* Free the window */
+	if ( SDL_Window ) {
+		DX5_DestroyWindow(this);
+	}
+
+	/* Free our window icon */
+	if ( screen_icn ) {
+		DestroyIcon(screen_icn);
+		screen_icn = NULL;
+	}
+}
+
+/* Exported for the windows message loop only */
+void DX5_RealizePalette(_THIS)
+{
+	if ( SDL_palette ) {
+		IDirectDrawSurface3_SetPalette(SDL_primary, SDL_palette);
+	}
+}
+static void DX5_Recolor8Bit(_THIS, SDL_Surface *surface, Uint8 *mapping)
+{
+	int row, col;
+	Uint8 *pixels;
+
+	if ( surface->w && surface->h ) {
+		if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+			if ( this->LockHWSurface(this, surface) < 0 ) {
+				return;
+			}
+		}
+		for ( row=0; row<surface->h; ++row ) {
+			pixels = (Uint8 *)surface->pixels+row*surface->pitch;
+			for ( col=0; col<surface->w; ++col, ++pixels ) {
+				*pixels = mapping[*pixels];
+			}
+		}
+		if ( (surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+			this->UnlockHWSurface(this, surface);
+		}
+		SDL_UpdateRect(surface, 0, 0, 0, 0);
+	}
+}
+void DX5_PaletteChanged(_THIS, HWND window)
+{
+	SDL_Palette *palette;
+	SDL_Color *saved = NULL;
+	HDC hdc;
+	int i;
+	PALETTEENTRY *entries;
+
+	/* This is true when the window is closing */
+	if ( (SDL_primary == NULL) || (SDL_VideoSurface == NULL) )
+		return;
+
+	/* We need to get the colors as they were set */
+	palette = this->physpal;
+	if(!palette)
+	        palette = SDL_VideoSurface->format->palette;
+	if ( palette == NULL ) { /* Sometimes we don't have a palette */
+		return;
+	}
+	entries = (PALETTEENTRY *)alloca(palette->ncolors*sizeof(*entries));
+	hdc = GetDC(window);
+	GetSystemPaletteEntries(hdc, 0, palette->ncolors, entries);
+	ReleaseDC(window, hdc);
+	if ( ! colorchange_expected ) {
+		saved = (SDL_Color *)alloca(palette->ncolors*sizeof(SDL_Color));
+		memcpy(saved, palette->colors, 
+					palette->ncolors*sizeof(SDL_Color));
+	}
+	for ( i=0; i<palette->ncolors; ++i ) {
+		palette->colors[i].r = entries[i].peRed;
+		palette->colors[i].g = entries[i].peGreen;
+		palette->colors[i].b = entries[i].peBlue;
+	}
+	if ( ! colorchange_expected ) {
+		Uint8 mapping[256];
+
+		memset(mapping, 0, sizeof(mapping));
+		for ( i=0; i<palette->ncolors; ++i ) {
+			mapping[i] = SDL_FindColor(palette,
+					saved[i].r, saved[i].g, saved[i].b);
+		}
+		DX5_Recolor8Bit(this, SDL_VideoSurface, mapping);
+	}
+	colorchange_expected = 0;
+
+	/* Notify all mapped surfaces of the change */
+	SDL_FormatChanged(SDL_VideoSurface);
+}
+
+/* Exported for the windows message loop only */
+void DX5_WinPAINT(_THIS, HDC hdc)
+{
+	SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5video.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,65 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_dx5video_h
+#define _SDL_dx5video_h
+
+#include "directx.h"
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+    LPDIRECTDRAW2 ddraw2;
+    LPDIRECTDRAWSURFACE3 SDL_primary;
+    LPDIRECTDRAWCLIPPER SDL_clipper;
+    LPDIRECTDRAWPALETTE SDL_palette;
+    PALETTEENTRY SDL_colors[256];
+    int colorchange_expected;
+
+#define NUM_MODELISTS	4		/* 8, 16, 24, and 32 bits-per-pixel */
+    int SDL_nummodes[NUM_MODELISTS];
+    SDL_Rect **SDL_modelist[NUM_MODELISTS];
+    int SDL_modeindex[NUM_MODELISTS];
+};
+/* Old variable names */
+#define ddraw2			(this->hidden->ddraw2)
+#define SDL_primary		(this->hidden->SDL_primary)
+#define SDL_clipper		(this->hidden->SDL_clipper)
+#define SDL_palette		(this->hidden->SDL_palette)
+#define SDL_colors		(this->hidden->SDL_colors)
+#define colorchange_expected	(this->hidden->colorchange_expected)
+#define SDL_nummodes		(this->hidden->SDL_nummodes)
+#define SDL_modelist		(this->hidden->SDL_modelist)
+#define SDL_modeindex		(this->hidden->SDL_modeindex)
+
+/* DirectX function pointers for video and events */
+extern HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter );
+extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter);
+
+/* DirectDraw error reporting function */
+extern void SetDDerror(const char *function, int code);
+
+#endif /* _SDL_dx5video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5yuv.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,302 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the DirectDraw implementation of YUV video overlays */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_dx5yuv_c.h"
+#include "SDL_yuvfuncs.h"
+
+#define USE_DIRECTX_OVERLAY
+
+/* The functions used to manipulate software video overlays */
+static struct private_yuvhwfuncs dx5_yuvfuncs = {
+	DX5_LockYUVOverlay,
+	DX5_UnlockYUVOverlay,
+	DX5_DisplayYUVOverlay,
+	DX5_FreeYUVOverlay
+};
+
+struct private_yuvhwdata {
+	LPDIRECTDRAWSURFACE3 surface;
+
+	/* These are just so we don't have to allocate them separately */
+	Uint16 pitches[3];
+	Uint8 *planes[3];
+};
+
+
+static LPDIRECTDRAWSURFACE3 CreateYUVSurface(_THIS,
+                                         int width, int height, Uint32 format)
+{
+	HRESULT result;
+	LPDIRECTDRAWSURFACE  dd_surface1;
+	LPDIRECTDRAWSURFACE3 dd_surface3;
+	DDSURFACEDESC ddsd;
+
+	/* Set up the surface description */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	ddsd.dwFlags = (DDSD_WIDTH|DDSD_HEIGHT|DDSD_CAPS|DDSD_PIXELFORMAT);
+	ddsd.dwWidth = width;
+	ddsd.dwHeight= height;
+#ifdef USE_DIRECTX_OVERLAY
+	ddsd.ddsCaps.dwCaps = (DDSCAPS_OVERLAY|DDSCAPS_VIDEOMEMORY);
+#else
+	ddsd.ddsCaps.dwCaps = (DDSCAPS_OFFSCREENPLAIN|DDSCAPS_VIDEOMEMORY);
+#endif
+	ddsd.ddpfPixelFormat.dwSize = sizeof(ddsd.ddpfPixelFormat);
+	ddsd.ddpfPixelFormat.dwFlags = DDPF_FOURCC;
+	ddsd.ddpfPixelFormat.dwFourCC = format;
+
+	/* Create the DirectDraw video surface */
+	result = IDirectDraw2_CreateSurface(ddraw2, &ddsd, &dd_surface1, NULL); 
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDraw2::CreateSurface", result);
+		return(NULL);
+	}
+	result = IDirectDrawSurface_QueryInterface(dd_surface1,
+			&IID_IDirectDrawSurface3, (LPVOID *)&dd_surface3);
+	IDirectDrawSurface_Release(dd_surface1);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface::QueryInterface", result);
+		return(NULL);
+	}
+
+	/* Make sure the surface format was set properly */
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	result = IDirectDrawSurface3_Lock(dd_surface3, NULL,
+					  &ddsd, DDLOCK_NOSYSLOCK, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Lock", result);
+		IDirectDrawSurface_Release(dd_surface3);
+		return(NULL);
+	}
+	IDirectDrawSurface3_Unlock(dd_surface3, NULL);
+
+	if ( !(ddsd.ddpfPixelFormat.dwFlags & DDPF_FOURCC) ||
+	      (ddsd.ddpfPixelFormat.dwFourCC != format) ) {
+		SDL_SetError("DDraw didn't use requested FourCC format");
+		IDirectDrawSurface_Release(dd_surface3);
+		return(NULL);
+	}
+
+	/* We're ready to go! */
+	return(dd_surface3);
+}
+
+#ifdef DEBUG_YUV
+static char *PrintFOURCC(Uint32 code)
+{
+	static char buf[5];
+
+	buf[3] = code >> 24;
+	buf[2] = (code >> 16) & 0xFF;
+	buf[1] = (code >> 8) & 0xFF;
+	buf[0] = (code & 0xFF);
+	return(buf);
+}
+#endif
+
+SDL_Overlay *DX5_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
+{
+	SDL_Overlay *overlay;
+	struct private_yuvhwdata *hwdata;
+
+#ifdef DEBUG_YUV
+	DWORD numcodes;
+	DWORD *codes;
+
+	printf("FOURCC format requested: 0x%x\n", PrintFOURCC(format));
+	IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, NULL);
+	if ( numcodes ) {
+		DWORD i;
+		codes = malloc(numcodes*sizeof(*codes));
+		if ( codes ) {
+			IDirectDraw2_GetFourCCCodes(ddraw2, &numcodes, codes);
+			for ( i=0; i<numcodes; ++i ) {
+				fprintf(stderr, "Code %d: 0x%x\n", i, PrintFOURCC(codes[i]));
+			}
+			free(codes);
+		}
+	} else {
+		fprintf(stderr, "No FOURCC codes supported\n");
+	}
+#endif
+
+	/* Create the overlay structure */
+	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
+	if ( overlay == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(overlay, 0, (sizeof *overlay));
+
+	/* Fill in the basic members */
+	overlay->format = format;
+	overlay->w = width;
+	overlay->h = height;
+
+	/* Set up the YUV surface function structure */
+	overlay->hwfuncs = &dx5_yuvfuncs;
+
+	/* Create the pixel data and lookup tables */
+	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
+	overlay->hwdata = hwdata;
+	if ( hwdata == NULL ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	hwdata->surface = CreateYUVSurface(this, width, height, format);
+	if ( hwdata->surface == NULL ) {
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	overlay->hw_overlay = 1;
+
+	/* Set up the plane pointers */
+	overlay->pitches = hwdata->pitches;
+	overlay->pixels = hwdata->planes;
+	switch (format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+		overlay->planes = 3;
+	    default:
+		overlay->planes = 1;
+		break;
+	}
+
+	/* We're all done.. */
+	return(overlay);
+}
+
+int DX5_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	HRESULT result;
+	LPDIRECTDRAWSURFACE3 surface;
+	DDSURFACEDESC ddsd;
+
+	surface = overlay->hwdata->surface;
+	memset(&ddsd, 0, sizeof(ddsd));
+	ddsd.dwSize = sizeof(ddsd);
+	result = IDirectDrawSurface3_Lock(surface, NULL,
+					  &ddsd, DDLOCK_NOSYSLOCK, NULL);
+	if ( result == DDERR_SURFACELOST ) {
+		result = IDirectDrawSurface3_Restore(surface);
+		result = IDirectDrawSurface3_Lock(surface, NULL, &ddsd, 
+					(DDLOCK_NOSYSLOCK|DDLOCK_WAIT), NULL);
+	}
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Lock", result);
+		return(-1);
+	}
+
+	/* Find the pitch and offset values for the overlay */
+#if defined(NONAMELESSUNION)
+	overlay->pitches[0] = (Uint16)ddsd.u1.lPitch;
+#else
+	overlay->pitches[0] = (Uint16)ddsd.lPitch;
+#endif
+	overlay->pixels[0] = (Uint8 *)ddsd.lpSurface;
+	switch (overlay->format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+		/* Add the two extra planes */
+		overlay->pitches[1] = overlay->pitches[0] / 2;
+		overlay->pitches[2] = overlay->pitches[0] / 2;
+	        overlay->pixels[1] = overlay->pixels[0] +
+		                     overlay->pitches[0] * overlay->h;
+	        overlay->pixels[2] = overlay->pixels[1] +
+		                     overlay->pitches[1] * overlay->h / 2;
+	        break;
+	    default:
+		/* Only one plane, no worries */
+		break;
+	}
+	return(0);
+}
+
+void DX5_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	LPDIRECTDRAWSURFACE3 surface;
+
+	surface = overlay->hwdata->surface;
+	IDirectDrawSurface3_Unlock(surface, NULL);
+}
+
+int DX5_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
+{
+	HRESULT result;
+	LPDIRECTDRAWSURFACE3 surface;
+	RECT src, dst;
+
+	surface = overlay->hwdata->surface;
+	src.top = 0;
+	src.bottom = overlay->h;
+	src.left = 0;
+	src.right = overlay->w;
+	dst.top = SDL_bounds.top+dstrect->y;
+	dst.left = SDL_bounds.left+dstrect->x;
+	dst.bottom = dst.top+dstrect->h;
+	dst.right = dst.left+dstrect->w;
+#ifdef USE_DIRECTX_OVERLAY
+	result = IDirectDrawSurface3_UpdateOverlay(surface, &src,
+				SDL_primary, &dst, DDOVER_SHOW, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::UpdateOverlay", result);
+		return(-1);
+	}
+#else
+	result = IDirectDrawSurface3_Blt(SDL_primary, &dst, surface, &src,
+							DDBLT_WAIT, NULL);
+	if ( result != DD_OK ) {
+		SetDDerror("DirectDrawSurface3::Blt", result);
+		return(-1);
+	}
+#endif
+	return(0);
+}
+
+void DX5_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	struct private_yuvhwdata *hwdata;
+
+	hwdata = overlay->hwdata;
+	if ( hwdata ) {
+		if ( hwdata->surface ) {
+			IDirectDrawSurface_Release(hwdata->surface);
+		}
+		free(hwdata);
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/SDL_dx5yuv_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the DirectDraw implementation of YUV video overlays */
+
+#include "SDL_video.h"
+#include "SDL_lowvideo.h"
+#include "SDL_dx5video.h"
+
+extern SDL_Overlay *DX5_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
+
+extern int DX5_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern void DX5_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern int DX5_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
+
+extern void DX5_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/windx5/directx.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,83 @@
+
+#ifndef _directx_h_
+#define _directx_h
+
+/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
+
+#include <windows.h>
+#include <mmsystem.h>
+#ifndef WIN32
+#define WIN32
+#endif
+#undef  WINNT
+
+/* Far pointers don't exist in 32-bit code */
+#ifndef FAR
+#define FAR
+#endif
+
+/* Error codes not yet included in Win32 API header files */
+#ifndef MAKE_HRESULT
+#define MAKE_HRESULT(sev,fac,code) \
+	((HRESULT)(((unsigned long)(sev)<<31) | ((unsigned long)(fac)<<16) | ((unsigned long)(code))))
+#endif
+
+#ifndef S_OK
+#define S_OK		(HRESULT)0x00000000L
+#endif
+
+#ifndef SUCCEEDED
+#define SUCCEEDED(x)	((HRESULT)(x) >= 0)
+#endif
+#ifndef FAILED
+#define FAILED(x)	((HRESULT)(x)<0)
+#endif
+
+#ifndef E_FAIL
+#define E_FAIL		(HRESULT)0x80000008L
+#endif
+#ifndef E_NOINTERFACE
+#define E_NOINTERFACE	(HRESULT)0x80004002L
+#endif
+#ifndef E_OUTOFMEMORY
+#define E_OUTOFMEMORY	(HRESULT)0x8007000EL
+#endif
+#ifndef E_INVALIDARG
+#define E_INVALIDARG	(HRESULT)0x80070057L
+#endif
+#ifndef E_NOTIMPL
+#define E_NOTIMPL	(HRESULT)0x80004001L
+#endif
+#ifndef REGDB_E_CLASSNOTREG
+#define REGDB_E_CLASSNOTREG	(HRESULT)0x80040154L
+#endif
+
+/* Severity codes */
+#ifndef SEVERITY_ERROR
+#define SEVERITY_ERROR	1
+#endif
+
+/* Error facility codes */
+#ifndef FACILITY_WIN32
+#define FACILITY_WIN32	7
+#endif
+
+#ifndef FIELD_OFFSET
+#define FIELD_OFFSET(type, field)    ((LONG)&(((type *)0)->field))
+#endif
+
+/* DirectX headers (if it isn't included, I haven't tested it yet)
+ */
+/* We need these defines to mark what version of DirectX API we use */
+#define DIRECTDRAW_VERSION  0x0700
+#define DIRECTSOUND_VERSION 0x0500
+#define DIRECTINPUT_VERSION 0x0500
+
+#ifdef __GNUC__
+#define NONAMELESSUNION
+#endif
+#include <ddraw.h>
+#include <dsound.h>
+#include <dinput.h>
+
+#endif /* _directx_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,6 @@
+Makefile.in
+Makefile
+.libs
+*.o
+*.lo
+*.la
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,28 @@
+
+## Makefile.am for SDL using the X11 video driver
+
+noinst_LTLIBRARIES = libvideo_x11.la
+libvideo_x11_la_SOURCES = $(X11_SRCS)
+
+# The SDL X11 video driver sources
+X11_SRCS = 			\
+	SDL_x11dga.c		\
+	SDL_x11dga_c.h		\
+	SDL_x11events.c		\
+	SDL_x11events_c.h	\
+	SDL_x11gamma.c		\
+	SDL_x11gamma_c.h	\
+	SDL_x11gl.c		\
+	SDL_x11gl_c.h		\
+	SDL_x11image.c		\
+	SDL_x11image_c.h	\
+	SDL_x11modes.c		\
+	SDL_x11modes_c.h	\
+	SDL_x11mouse.c		\
+	SDL_x11mouse_c.h	\
+	SDL_x11video.c		\
+	SDL_x11video.h		\
+	SDL_x11wm.c		\
+	SDL_x11wm_c.h		\
+	SDL_x11yuv.c		\
+	SDL_x11yuv_c.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11dga.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,96 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is currently only used to enable DGA mouse.
+   The new fullscreen code makes it very difficult to handle DGA dynamically.
+   There will be a completely separate DGA driver that is fullscreen-only.
+*/
+
+#include <stdlib.h>		/* For getenv() */
+#include "SDL_video.h"
+#include "SDL_cursor_c.h"
+#include "SDL_x11dga_c.h"
+
+/* Global for the error handler */
+int dga_event, dga_error = -1;
+
+void X11_EnableDGAMouse(_THIS)
+{
+#ifdef XFREE86_DGAMOUSE
+    int dga_major, dga_minor;
+    int use_dgamouse;
+    const char *env_use_dgamouse;
+
+    /* Check configuration to see if we should use DGA mouse */
+#ifdef DEFAULT_DGAMOUSE
+    use_dgamouse = 1;
+#else
+    use_dgamouse = 0;
+#endif
+    env_use_dgamouse = getenv("SDL_VIDEO_X11_DGAMOUSE");
+    if ( env_use_dgamouse ) {
+        use_dgamouse = atoi(env_use_dgamouse);
+    }
+    /* Check for buggy X servers */
+    if ( use_dgamouse && BUGGY_XFREE86(==, 4000) ) {
+        use_dgamouse = 0;
+    }
+    /* Only use DGA mouse if the cursor is not showing (in relative mode) */
+    if ( use_dgamouse && local_X11 && !(using_dga & DGA_MOUSE) &&
+         XF86DGAQueryExtension(SDL_Display, &dga_event, &dga_error) &&
+         XF86DGAQueryVersion(SDL_Display, &dga_major, &dga_minor) ) {
+	if ( XF86DGADirectVideo(SDL_Display, SDL_Screen, XF86DGADirectMouse) ) {
+            using_dga |= DGA_MOUSE;
+        }
+    }
+#endif /* XFREE86_DGAMOUSE */
+}
+
+/* Argh.  Glide resets DGA mouse mode when it makes the context current! */
+void X11_CheckDGAMouse(_THIS)
+{
+#ifdef XFREE86_DGAMOUSE
+    int flags;
+
+    if ( using_dga & DGA_MOUSE ) {
+        XF86DGAQueryDirectVideo(SDL_Display, SDL_Screen, &flags);
+        if ( ! (flags & XF86DGADirectMouse) ) {
+                XF86DGADirectVideo(SDL_Display,SDL_Screen,XF86DGADirectMouse);
+        }
+    }
+#endif
+}
+
+void X11_DisableDGAMouse(_THIS)
+{
+#ifdef XFREE86_DGAMOUSE
+    if ( using_dga & DGA_MOUSE ) {
+	XF86DGADirectVideo(SDL_Display, SDL_Screen, 0);
+        using_dga &= ~DGA_MOUSE;
+    }
+#endif /* XFREE86_DGAMOUSE */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11dga_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_x11video.h"
+
+/* Different DGA access states */
+#define DGA_GRAPHICS	0x01
+#define DGA_KEYBOARD	0x02
+#define DGA_MOUSE	0x04
+
+extern void X11_EnableDGAMouse(_THIS);
+extern void X11_CheckDGAMouse(_THIS);
+extern void X11_DisableDGAMouse(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11events.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,880 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Handle the event stream, converting X11 events into SDL events */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <setjmp.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#ifdef __SVR4
+#include <X11/Sunkeysym.h>
+#endif
+#include <sys/time.h>
+
+#include "SDL.h"
+#include "SDL_syswm.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_x11video.h"
+#include "SDL_x11dga_c.h"
+#include "SDL_x11modes_c.h"
+#include "SDL_x11image_c.h"
+#include "SDL_x11gamma_c.h"
+#include "SDL_x11wm_c.h"
+#include "SDL_x11mouse_c.h"
+#include "SDL_x11events_c.h"
+
+
+/* The translation tables from an X11 keysym to a SDL keysym */
+static SDLKey ODD_keymap[256];
+static SDLKey MISC_keymap[256];
+SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
+			     SDL_keysym *keysym);
+
+/* Check to see if this is a repeated key.
+   (idea shamelessly lifted from GII -- thanks guys! :)
+ */
+static int X11_KeyRepeat(Display *display, XEvent *event)
+{
+	XEvent peekevent;
+	int repeated;
+
+	repeated = 0;
+	if ( XPending(display) ) {
+		XPeekEvent(display, &peekevent);
+		if ( (peekevent.type == KeyPress) &&
+		     (peekevent.xkey.keycode == event->xkey.keycode) &&
+		     (peekevent.xkey.time == event->xkey.time) ) {
+			repeated = 1;
+			XNextEvent(display, &peekevent);
+		}
+	}
+	return(repeated);
+}
+
+/* Note:  The X server buffers and accumulates mouse motion events, so
+   the motion event generated by the warp may not appear exactly as we
+   expect it to.  We work around this (and improve performance) by only
+   warping the pointer when it reaches the edge, and then wait for it.
+*/
+#define MOUSE_FUDGE_FACTOR	8
+
+static __inline__ int X11_WarpedMotion(_THIS, XEvent *xevent)
+{
+	int w, h, i;
+	int deltax, deltay;
+	int posted;
+
+	w = SDL_VideoSurface->w;
+	h = SDL_VideoSurface->h;
+	deltax = xevent->xmotion.x - mouse_last.x;
+	deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Warped mouse motion: %d,%d\n", deltax, deltay);
+#endif
+	mouse_last.x = xevent->xmotion.x;
+	mouse_last.y = xevent->xmotion.y;
+	posted = SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+
+	if ( (xevent->xmotion.x < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.x > (w-MOUSE_FUDGE_FACTOR)) ||
+	     (xevent->xmotion.y < MOUSE_FUDGE_FACTOR) ||
+	     (xevent->xmotion.y > (h-MOUSE_FUDGE_FACTOR)) ) {
+		/* Get the events that have accumulated */
+		while ( XCheckTypedEvent(SDL_Display, MotionNotify, xevent) ) {
+			deltax = xevent->xmotion.x - mouse_last.x;
+			deltay = xevent->xmotion.y - mouse_last.y;
+#ifdef DEBUG_MOTION
+  printf("Extra mouse motion: %d,%d\n", deltax, deltay);
+#endif
+			mouse_last.x = xevent->xmotion.x;
+			mouse_last.y = xevent->xmotion.y;
+			posted += SDL_PrivateMouseMotion(0, 1, deltax, deltay);
+		}
+		mouse_last.x = w/2;
+		mouse_last.y = h/2;
+		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0,
+					mouse_last.x, mouse_last.y);
+		for ( i=0; i<10; ++i ) {
+        		XMaskEvent(SDL_Display, PointerMotionMask, xevent);
+			if ( (xevent->xmotion.x >
+			          (mouse_last.x-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.x <
+			          (mouse_last.x+MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y >
+			          (mouse_last.y-MOUSE_FUDGE_FACTOR)) &&
+			     (xevent->xmotion.y <
+			          (mouse_last.y+MOUSE_FUDGE_FACTOR)) ) {
+				break;
+			}
+#ifdef DEBUG_XEVENTS
+  printf("Lost mouse motion: %d,%d\n", xevent->xmotion.x, xevent->xmotion.y);
+#endif
+		}
+#ifdef DEBUG_XEVENTS
+		if ( i == 10 ) {
+			printf("Warning: didn't detect mouse warp motion\n");
+		}
+#endif
+	}
+	return(posted);
+}
+
+static int X11_DispatchEvent(_THIS)
+{
+	int posted;
+	XEvent xevent;
+
+	XNextEvent(SDL_Display, &xevent);
+
+	posted = 0;
+	switch (xevent.type) {
+
+	    /* Gaining mouse coverage? */
+	    case EnterNotify: {
+#ifdef DEBUG_XEVENTS
+printf("EnterNotify!\n");
+if ( xevent.xcrossing.mode == NotifyGrab )
+printf("Mode: NotifyGrab\n");
+if ( xevent.xcrossing.mode == NotifyUngrab )
+printf("Mode: NotifyUngrab\n");
+#endif
+		if ( (xevent.xcrossing.mode != NotifyGrab) &&
+		     (xevent.xcrossing.mode != NotifyUngrab) ) {
+			posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+		}
+	    }
+	    break;
+
+	    /* Losing mouse coverage? */
+	    case LeaveNotify: {
+#ifdef DEBUG_XEVENTS
+printf("LeaveNotify!\n");
+if ( xevent.xcrossing.mode == NotifyGrab )
+printf("Mode: NotifyGrab\n");
+if ( xevent.xcrossing.mode == NotifyUngrab )
+printf("Mode: NotifyUngrab\n");
+#endif
+		if ( (xevent.xcrossing.mode != NotifyGrab) &&
+		     (xevent.xcrossing.mode != NotifyUngrab) ) {
+			posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+		}
+	    }
+	    break;
+
+	    /* Gaining input focus? */
+	    case FocusIn: {
+#ifdef DEBUG_XEVENTS
+printf("FocusIn!\n");
+#endif
+		posted = SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
+
+		/* Queue entry into fullscreen mode */
+		switch_waiting = 0x01 | SDL_FULLSCREEN;
+		switch_time = SDL_GetTicks() + 1500;
+	    }
+	    break;
+
+	    /* Losing input focus? */
+	    case FocusOut: {
+#ifdef DEBUG_XEVENTS
+printf("FocusOut!\n");
+#endif
+		posted = SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
+
+		/* Queue leaving fullscreen mode */
+		switch_waiting = 0x01;
+		switch_time = SDL_GetTicks() + 200;
+	    }
+	    break;
+
+	    /* Generated upon EnterWindow and FocusIn */
+	    case KeymapNotify: {
+		X11_SetKeyboardState(SDL_Display, xevent.xkeymap.key_vector);
+	    }
+	    break;
+
+	    /* Mouse motion? */
+	    case MotionNotify: {
+		if ( SDL_VideoSurface ) {
+			if ( mouse_relative ) {
+				if ( using_dga & DGA_MOUSE ) {
+#ifdef DEBUG_MOTION
+  printf("DGA motion: %d,%d\n", xevent.xmotion.x_root, xevent.xmotion.y_root);
+#endif
+					posted = SDL_PrivateMouseMotion(0, 1,
+							xevent.xmotion.x_root,
+							xevent.xmotion.y_root);
+				} else {
+					posted = X11_WarpedMotion(this,&xevent);
+				}
+			} else {
+				posted = SDL_PrivateMouseMotion(0, 0,
+						xevent.xmotion.x,
+						xevent.xmotion.y);
+			}
+		}
+	    }
+	    break;
+
+	    /* Mouse button press? */
+	    case ButtonPress: {
+		posted = SDL_PrivateMouseButton(SDL_PRESSED, 
+					xevent.xbutton.button, 0, 0);
+	    }
+	    break;
+
+	    /* Mouse button release? */
+	    case ButtonRelease: {
+		posted = SDL_PrivateMouseButton(SDL_RELEASED, 
+					xevent.xbutton.button, 0, 0);
+	    }
+	    break;
+
+	    /* Key press? */
+	    case KeyPress: {
+		SDL_keysym keysym;
+		posted = SDL_PrivateKeyboard(SDL_PRESSED,
+				X11_TranslateKey(SDL_Display, &xevent.xkey,
+						 xevent.xkey.keycode,
+						 &keysym));
+	    }
+	    break;
+
+	    /* Key release? */
+	    case KeyRelease: {
+		SDL_keysym keysym;
+
+		/* Check to see if this is a repeated key */
+		if ( ! X11_KeyRepeat(SDL_Display, &xevent) ) {
+			posted = SDL_PrivateKeyboard(SDL_RELEASED, 
+				X11_TranslateKey(SDL_Display, &xevent.xkey,
+						 xevent.xkey.keycode,
+						 &keysym));
+		}
+	    }
+	    break;
+
+	    /* Have we been iconified? */
+	    case UnmapNotify: {
+#ifdef DEBUG_XEVENTS
+printf("UnmapNotify!\n");
+#endif
+		/* If we're active, make ourselves inactive */
+		if ( SDL_GetAppState() & SDL_APPACTIVE ) {
+			/* Swap out the gamma before we go inactive */
+			X11_SwapVidModeGamma(this);
+
+			/* Send an internal deactivate event */
+			posted = SDL_PrivateAppActive(0,
+					SDL_APPACTIVE|SDL_APPINPUTFOCUS);
+		}
+	    }
+	    break;
+
+	    /* Have we been restored? */
+	    case MapNotify: {
+#ifdef DEBUG_XEVENTS
+printf("MapNotify!\n");
+#endif
+		/* If we're not active, make ourselves active */
+		if ( !(SDL_GetAppState() & SDL_APPACTIVE) ) {
+			/* Send an internal activate event */
+			posted = SDL_PrivateAppActive(1, SDL_APPACTIVE);
+
+			/* Now that we're active, swap the gamma back */
+			X11_SwapVidModeGamma(this);
+		}
+
+		if ( SDL_VideoSurface &&
+		     (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) {
+#ifdef GRAB_FULLSCREEN
+			X11_EnterFullScreen(this);
+#else
+			/* Queue entry into fullscreen mode */
+			switch_waiting = 0x01 | SDL_FULLSCREEN;
+			switch_time = SDL_GetTicks() + 1500;
+#endif
+		} else {
+			X11_GrabInputNoLock(this, this->input_grab);
+		}
+		if ( SDL_VideoSurface ) {
+			X11_RefreshDisplay(this);
+		}
+	    }
+	    break;
+
+	    /* Have we been resized or moved? */
+	    case ConfigureNotify: {
+#ifdef DEBUG_XEVENTS
+printf("ConfigureNotify! (resize: %dx%d)\n", xevent.xconfigure.width, xevent.xconfigure.height);
+#endif
+		if ( SDL_VideoSurface ) {
+		    if ((xevent.xconfigure.width != SDL_VideoSurface->w) ||
+		        (xevent.xconfigure.height != SDL_VideoSurface->h)) {
+			/* FIXME: Find a better fix for the bug with KDE 1.2 */
+			if ( ! ((xevent.xconfigure.width == 32) &&
+			        (xevent.xconfigure.height == 32)) ) {
+				SDL_PrivateResize(xevent.xconfigure.width,
+				                  xevent.xconfigure.height);
+			}
+		    } else {
+			/* OpenGL windows need to know about the change */
+			if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
+				SDL_PrivateExpose();
+			}
+		    }
+		}
+	    }
+	    break;
+
+	    /* Have we been requested to quit (or another client message?) */
+	    case ClientMessage: {
+		if ( (xevent.xclient.format == 32) &&
+		     (xevent.xclient.data.l[0] == WM_DELETE_WINDOW) )
+		{
+			posted = SDL_PrivateQuit();
+		} else
+		if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+			SDL_SysWMmsg wmmsg;
+
+			SDL_VERSION(&wmmsg.version);
+			wmmsg.subsystem = SDL_SYSWM_X11;
+			wmmsg.event.xevent = xevent;
+			posted = SDL_PrivateSysWMEvent(&wmmsg);
+		}
+	    }
+	    break;
+
+	    /* Do we need to refresh ourselves? */
+	    case Expose: {
+#ifdef DEBUG_XEVENTS
+printf("Expose (count = %d)\n", xevent.xexpose.count);
+#endif
+		if ( SDL_VideoSurface && (xevent.xexpose.count == 0) ) {
+			if ( SDL_VideoSurface->flags & SDL_OPENGL ) {
+				SDL_PrivateExpose();
+			} else {
+				X11_RefreshDisplay(this);
+			}
+		}
+	    }
+	    break;
+
+	    default: {
+#ifdef DEBUG_XEVENTS
+printf("Unhandled event %d\n", xevent.type);
+#endif
+		/* Only post the event if we're watching for it */
+		if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) {
+			SDL_SysWMmsg wmmsg;
+
+			SDL_VERSION(&wmmsg.version);
+			wmmsg.subsystem = SDL_SYSWM_X11;
+			wmmsg.event.xevent = xevent;
+			posted = SDL_PrivateSysWMEvent(&wmmsg);
+		}
+	    }
+	    break;
+	}
+	return(posted);
+}
+
+/* Ack!  XPending() actually performs a blocking read if no events available */
+int X11_Pending(Display *display)
+{
+	/* Flush the display connection and look to see if events are queued */
+	XFlush(display);
+	if ( XEventsQueued(display, QueuedAlready) ) {
+		return(1);
+	}
+
+	/* More drastic measures are required -- see if X is ready to talk */
+	{
+		static struct timeval zero_time;	/* static == 0 */
+		int x11_fd;
+		fd_set fdset;
+
+		x11_fd = ConnectionNumber(display);
+		FD_ZERO(&fdset);
+		FD_SET(x11_fd, &fdset);
+		if ( select(x11_fd+1, &fdset, NULL, NULL, &zero_time) == 1 ) {
+			return(XPending(display));
+		}
+	}
+
+	/* Oh well, nothing is ready .. */
+	return(0);
+}
+
+void X11_PumpEvents(_THIS)
+{
+	int pending;
+
+	/* Keep processing pending events */
+	pending = 0;
+	while ( X11_Pending(SDL_Display) ) {
+		X11_DispatchEvent(this);
+		++pending;
+	}
+	if ( switch_waiting ) {
+		Uint32 now;
+
+		now  = SDL_GetTicks();
+		if ( pending || !SDL_VideoSurface ) {
+			/* Try again later... */
+			if ( switch_waiting & SDL_FULLSCREEN ) {
+				switch_time = now + 1500;
+			} else {
+				switch_time = now + 200;
+			}
+		} else if ( now >= switch_time ) {
+			Uint32 go_fullscreen;
+
+			go_fullscreen = switch_waiting & SDL_FULLSCREEN;
+			switch_waiting = 0;
+			if ( SDL_VideoSurface->flags & SDL_FULLSCREEN ) {
+				if ( go_fullscreen ) {
+					X11_EnterFullScreen(this);
+				} else {
+					X11_LeaveFullScreen(this);
+				}
+			}
+			/* Handle focus in/out when grabbed */
+			if ( go_fullscreen ) {
+				X11_GrabInputNoLock(this, this->input_grab);
+			} else {
+				X11_GrabInputNoLock(this, SDL_GRAB_OFF);
+			}
+			X11_CheckMouseModeNoLock(this);
+		}
+	}
+}
+
+void X11_InitKeymap(void)
+{
+	int i;
+
+	/* Odd keys used in international keyboards */
+	for ( i=0; i<SDL_TABLESIZE(ODD_keymap); ++i )
+		ODD_keymap[i] = SDLK_UNKNOWN;
+
+#ifdef XK_dead_circumflex
+	/* These X keysyms have 0xFE as the high byte */
+	ODD_keymap[XK_dead_circumflex&0xFF] = SDLK_CARET;
+#endif
+
+	/* Map the miscellaneous keys */
+	for ( i=0; i<SDL_TABLESIZE(MISC_keymap); ++i )
+		MISC_keymap[i] = SDLK_UNKNOWN;
+
+	/* These X keysyms have 0xFF as the high byte */
+	MISC_keymap[XK_BackSpace&0xFF] = SDLK_BACKSPACE;
+	MISC_keymap[XK_Tab&0xFF] = SDLK_TAB;
+	MISC_keymap[XK_Clear&0xFF] = SDLK_CLEAR;
+	MISC_keymap[XK_Return&0xFF] = SDLK_RETURN;
+	MISC_keymap[XK_Pause&0xFF] = SDLK_PAUSE;
+	MISC_keymap[XK_Escape&0xFF] = SDLK_ESCAPE;
+	MISC_keymap[XK_Delete&0xFF] = SDLK_DELETE;
+
+	MISC_keymap[XK_KP_0&0xFF] = SDLK_KP0;		/* Keypad 0-9 */
+	MISC_keymap[XK_KP_1&0xFF] = SDLK_KP1;
+	MISC_keymap[XK_KP_2&0xFF] = SDLK_KP2;
+	MISC_keymap[XK_KP_3&0xFF] = SDLK_KP3;
+	MISC_keymap[XK_KP_4&0xFF] = SDLK_KP4;
+	MISC_keymap[XK_KP_5&0xFF] = SDLK_KP5;
+	MISC_keymap[XK_KP_6&0xFF] = SDLK_KP6;
+	MISC_keymap[XK_KP_7&0xFF] = SDLK_KP7;
+	MISC_keymap[XK_KP_8&0xFF] = SDLK_KP8;
+	MISC_keymap[XK_KP_9&0xFF] = SDLK_KP9;
+	MISC_keymap[XK_KP_Insert&0xFF] = SDLK_KP0;
+	MISC_keymap[XK_KP_End&0xFF] = SDLK_KP1;	
+	MISC_keymap[XK_KP_Down&0xFF] = SDLK_KP2;
+	MISC_keymap[XK_KP_Page_Down&0xFF] = SDLK_KP3;
+	MISC_keymap[XK_KP_Left&0xFF] = SDLK_KP4;
+	MISC_keymap[XK_KP_Begin&0xFF] = SDLK_KP5;
+	MISC_keymap[XK_KP_Right&0xFF] = SDLK_KP6;
+	MISC_keymap[XK_KP_Home&0xFF] = SDLK_KP7;
+	MISC_keymap[XK_KP_Up&0xFF] = SDLK_KP8;
+	MISC_keymap[XK_KP_Page_Up&0xFF] = SDLK_KP9;
+	MISC_keymap[XK_KP_Delete&0xFF] = SDLK_KP_PERIOD;
+	MISC_keymap[XK_KP_Decimal&0xFF] = SDLK_KP_PERIOD;
+	MISC_keymap[XK_KP_Divide&0xFF] = SDLK_KP_DIVIDE;
+	MISC_keymap[XK_KP_Multiply&0xFF] = SDLK_KP_MULTIPLY;
+	MISC_keymap[XK_KP_Subtract&0xFF] = SDLK_KP_MINUS;
+	MISC_keymap[XK_KP_Add&0xFF] = SDLK_KP_PLUS;
+	MISC_keymap[XK_KP_Enter&0xFF] = SDLK_KP_ENTER;
+	MISC_keymap[XK_KP_Equal&0xFF] = SDLK_KP_EQUALS;
+
+	MISC_keymap[XK_Up&0xFF] = SDLK_UP;
+	MISC_keymap[XK_Down&0xFF] = SDLK_DOWN;
+	MISC_keymap[XK_Right&0xFF] = SDLK_RIGHT;
+	MISC_keymap[XK_Left&0xFF] = SDLK_LEFT;
+	MISC_keymap[XK_Insert&0xFF] = SDLK_INSERT;
+	MISC_keymap[XK_Home&0xFF] = SDLK_HOME;
+	MISC_keymap[XK_End&0xFF] = SDLK_END;
+	MISC_keymap[XK_Page_Up&0xFF] = SDLK_PAGEUP;
+	MISC_keymap[XK_Page_Down&0xFF] = SDLK_PAGEDOWN;
+
+	MISC_keymap[XK_F1&0xFF] = SDLK_F1;
+	MISC_keymap[XK_F2&0xFF] = SDLK_F2;
+	MISC_keymap[XK_F3&0xFF] = SDLK_F3;
+	MISC_keymap[XK_F4&0xFF] = SDLK_F4;
+	MISC_keymap[XK_F5&0xFF] = SDLK_F5;
+	MISC_keymap[XK_F6&0xFF] = SDLK_F6;
+	MISC_keymap[XK_F7&0xFF] = SDLK_F7;
+	MISC_keymap[XK_F8&0xFF] = SDLK_F8;
+	MISC_keymap[XK_F9&0xFF] = SDLK_F9;
+	MISC_keymap[XK_F10&0xFF] = SDLK_F10;
+	MISC_keymap[XK_F11&0xFF] = SDLK_F11;
+	MISC_keymap[XK_F12&0xFF] = SDLK_F12;
+	MISC_keymap[XK_F13&0xFF] = SDLK_F13;
+	MISC_keymap[XK_F14&0xFF] = SDLK_F14;
+	MISC_keymap[XK_F15&0xFF] = SDLK_F15;
+
+	MISC_keymap[XK_Num_Lock&0xFF] = SDLK_NUMLOCK;
+	MISC_keymap[XK_Caps_Lock&0xFF] = SDLK_CAPSLOCK;
+	MISC_keymap[XK_Scroll_Lock&0xFF] = SDLK_SCROLLOCK;
+	MISC_keymap[XK_Shift_R&0xFF] = SDLK_RSHIFT;
+	MISC_keymap[XK_Shift_L&0xFF] = SDLK_LSHIFT;
+	MISC_keymap[XK_Control_R&0xFF] = SDLK_RCTRL;
+	MISC_keymap[XK_Control_L&0xFF] = SDLK_LCTRL;
+	MISC_keymap[XK_Alt_R&0xFF] = SDLK_RALT;
+	MISC_keymap[XK_Alt_L&0xFF] = SDLK_LALT;
+	MISC_keymap[XK_Meta_R&0xFF] = SDLK_RMETA;
+	MISC_keymap[XK_Meta_L&0xFF] = SDLK_LMETA;
+	MISC_keymap[XK_Super_L&0xFF] = SDLK_LSUPER; /* Left "Windows" */
+	MISC_keymap[XK_Super_R&0xFF] = SDLK_RSUPER; /* Right "Windows */
+	MISC_keymap[XK_Mode_switch&0xFF] = SDLK_MODE; /* "Alt Gr" key */
+	MISC_keymap[XK_Multi_key&0xFF] = SDLK_COMPOSE; /* Multi-key compose */
+
+	MISC_keymap[XK_Help&0xFF] = SDLK_HELP;
+	MISC_keymap[XK_Print&0xFF] = SDLK_PRINT;
+	MISC_keymap[XK_Sys_Req&0xFF] = SDLK_SYSREQ;
+	MISC_keymap[XK_Break&0xFF] = SDLK_BREAK;
+	MISC_keymap[XK_Menu&0xFF] = SDLK_MENU;
+	MISC_keymap[XK_Hyper_R&0xFF] = SDLK_MENU;   /* Windows "Menu" key */
+}
+
+SDL_keysym *X11_TranslateKey(Display *display, XKeyEvent *xkey, KeyCode kc,
+			     SDL_keysym *keysym)
+{
+	KeySym xsym;
+
+	/* Get the raw keyboard scancode */
+	keysym->scancode = kc;
+	xsym = XKeycodeToKeysym(display, kc, 0);
+#ifdef DEBUG_KEYS
+	fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, kc);
+#endif
+	/* Get the translated SDL virtual keysym */
+	keysym->sym = SDLK_UNKNOWN;
+	if ( xsym ) {
+		switch (xsym>>8) {
+			case 0x1005FF:
+#ifdef SunXK_F36
+				if ( xsym == SunXK_F36 )
+					keysym->sym = SDLK_F11;
+#endif
+#ifdef SunXK_F37
+				if ( xsym == SunXK_F37 )
+					keysym->sym = SDLK_F12;
+#endif
+				break;
+			case 0x00:	/* Latin 1 */
+			case 0x01:	/* Latin 2 */
+			case 0x02:	/* Latin 3 */
+			case 0x03:	/* Latin 4 */
+			case 0x04:	/* Katakana */
+			case 0x05:	/* Arabic */
+			case 0x06:	/* Cyrillic */
+			case 0x07:	/* Greek */
+			case 0x08:	/* Technical */
+			case 0x0A:	/* Publishing */
+			case 0x0C:	/* Hebrew */
+			case 0x0D:	/* Thai */
+				keysym->sym = (SDLKey)(xsym&0xFF);
+				/* Map capital letter syms to lowercase */
+				if ((keysym->sym >= 'A')&&(keysym->sym <= 'Z'))
+					keysym->sym += ('a'-'A');
+				break;
+			case 0xFE:
+				keysym->sym = ODD_keymap[xsym&0xFF];
+				break;
+			case 0xFF:
+				keysym->sym = MISC_keymap[xsym&0xFF];
+				break;
+			default:
+				fprintf(stderr,
+					"X11: Unknown xsym, sym = 0x%04x\n",
+					(unsigned int)xsym);
+				break;
+		}
+	} else {
+		/* X11 doesn't know how to translate the key! */
+		switch (kc) {
+			/* Caution:
+			   These keycodes are from the Microsoft Keyboard
+			 */
+			case 115:
+				keysym->sym = SDLK_LSUPER;
+				break;
+			case 116:
+				keysym->sym = SDLK_RSUPER;
+				break;
+			case 117:
+				keysym->sym = SDLK_MENU;
+				break;
+			default:
+				/*
+				 * no point in an error message; happens for
+				 * several keys when we get a keymap notify
+				 */
+				break;
+		}
+	}
+	keysym->mod = KMOD_NONE;
+
+	/* If UNICODE is on, get the UNICODE value for the key */
+	keysym->unicode = 0;
+	if ( SDL_TranslateUNICODE && xkey ) {
+		static XComposeStatus state;
+		/* Until we handle the IM protocol, use XLookupString() */
+		unsigned char keybuf[32];
+
+#define BROKEN_XFREE86_INTERNATIONAL_KBD
+/* This appears to be a magical flag that is used with AltGr on
+   international keyboards to signal alternate key translations.
+   The flag doesn't show up when in fullscreen mode (?)
+   FIXME:  Check to see if this code is safe for other servers.
+*/
+#ifdef BROKEN_XFREE86_INTERNATIONAL_KBD
+		/* Work around what appears to be a bug in XFree86 */
+		if ( SDL_GetModState() & KMOD_MODE ) {
+			xkey->state |= (1<<13);
+		}
+#endif
+		/* Look up the translated value for the key event */
+		if ( XLookupString(xkey, (char *)keybuf, sizeof(keybuf),
+							NULL, &state) ) {
+			/*
+			 * FIXME,: XLookupString() may yield more than one
+			 * character, so we need a mechanism to allow for
+			 * this (perhaps generate null keypress events with
+			 * a unicode value)
+			 */
+			keysym->unicode = keybuf[0];
+		}
+	}
+	return(keysym);
+}
+
+/* X11 modifier masks for various keys */
+static unsigned meta_l_mask, meta_r_mask, alt_l_mask, alt_r_mask;
+static unsigned num_mask, mode_switch_mask;
+
+static void get_modifier_masks(Display *display)
+{
+	static unsigned got_masks;
+	int i, j;
+	XModifierKeymap *xmods;
+	unsigned n;
+
+	if(got_masks)
+		return;
+
+	xmods = XGetModifierMapping(display);
+	n = xmods->max_keypermod;
+	for(i = 3; i < 8; i++) {
+		for(j = 0; j < n; j++) {
+			KeyCode kc = xmods->modifiermap[i * n + j];
+			KeySym ks = XKeycodeToKeysym(display, kc, 0);
+			unsigned mask = 1 << i;
+			switch(ks) {
+			case XK_Num_Lock:
+				num_mask = mask; break;
+			case XK_Alt_L:
+				alt_l_mask = mask; break;
+			case XK_Alt_R:
+				alt_r_mask = mask; break;
+			case XK_Meta_L:
+				meta_l_mask = mask; break;
+			case XK_Meta_R:
+				meta_r_mask = mask; break;
+			case XK_Mode_switch:
+				mode_switch_mask = mask; break;
+			}
+		}
+	}
+	XFreeModifiermap(xmods);
+	got_masks = 1;
+}
+
+
+/*
+ * This function is semi-official; it is not officially exported and should
+ * not be considered part of the SDL API, but may be used by client code
+ * that *really* needs it (including legacy code).
+ * It is slow, though, and should be avoided if possible.
+ *
+ * Note that it isn't completely accurate either; in particular, multi-key
+ * sequences (dead accents, compose key sequences) will not work since the
+ * state has been irrevocably lost.
+ */
+Uint16 X11_KeyToUnicode(SDLKey keysym, SDLMod modifiers)
+{
+	struct SDL_VideoDevice *this = current_video;
+	char keybuf[32];
+	int i;
+	KeySym xsym = 0;
+	XKeyEvent xkey;
+	Uint16 unicode;
+
+	if ( !this || !SDL_Display ) {
+		return 0;
+	}
+
+	memset(&xkey, 0, sizeof(xkey));
+	xkey.display = SDL_Display;
+
+	xsym = keysym;		/* last resort if not found */
+	for (i = 0; i < 256; ++i) {
+		if ( MISC_keymap[i] == keysym ) {
+			xsym = 0xFF00 | i;
+			break;
+		} else if ( ODD_keymap[i] == keysym ) {
+			xsym = 0xFE00 | i;
+			break;
+		}
+	}
+
+	xkey.keycode = XKeysymToKeycode(xkey.display, xsym);
+
+	get_modifier_masks(SDL_Display);
+	if(modifiers & KMOD_SHIFT)
+		xkey.state |= ShiftMask;
+	if(modifiers & KMOD_CAPS)
+		xkey.state |= LockMask;
+	if(modifiers & KMOD_CTRL)
+		xkey.state |= ControlMask;
+	if(modifiers & KMOD_MODE)
+		xkey.state |= mode_switch_mask;
+	if(modifiers & KMOD_LALT)
+		xkey.state |= alt_l_mask;
+	if(modifiers & KMOD_RALT)
+		xkey.state |= alt_r_mask;
+	if(modifiers & KMOD_LMETA)
+		xkey.state |= meta_l_mask;
+	if(modifiers & KMOD_RMETA)
+		xkey.state |= meta_r_mask;
+	if(modifiers & KMOD_NUM)
+		xkey.state |= num_mask;
+
+	unicode = 0;
+	if ( XLookupString(&xkey, keybuf, sizeof(keybuf), NULL, NULL) )
+		unicode = (unsigned char)keybuf[0];
+	return(unicode);
+}
+
+/*
+ * Called when focus is regained, to read the keyboard state and generate
+ * synthetic keypress/release events.
+ * key_vec is a bit vector of keycodes (256 bits)
+ */
+void X11_SetKeyboardState(Display *display, const char *key_vec)
+{
+	char keys_return[32];
+	int i, gen_event;
+	KeyCode xcode[SDLK_LAST];
+	Uint8 new_kstate[SDLK_LAST];
+	Uint8 *kstate = SDL_GetKeyState(NULL);
+
+	/* The first time the window is mapped, we initialize key state */
+	if ( ! key_vec ) {
+		key_vec = keys_return;
+		XQueryKeymap(display, keys_return);
+		gen_event = 0;
+	} else {
+		gen_event = 1;
+	}
+
+	/* Zero the new state and generate it */
+	memset(new_kstate, 0, sizeof(new_kstate));
+	/*
+	 * An obvious optimisation is to check entire longwords at a time in
+	 * both loops, but we can't be sure the arrays are aligned so it's not
+	 * worth the extra complexity
+	 */
+	for(i = 0; i < 32; i++) {
+		int j;
+		if(!key_vec[i])
+			continue;
+		for(j = 0; j < 8; j++) {
+			if(key_vec[i] & (1 << j)) {
+				SDL_keysym sk;
+				KeyCode kc = i << 3 | j;
+				X11_TranslateKey(display, NULL, kc, &sk);
+				new_kstate[sk.sym] = 1;
+				xcode[sk.sym] = kc;
+			}
+		}
+	}
+	for(i = SDLK_FIRST+1; i < SDLK_LAST; i++) {
+		int st;
+		SDL_keysym sk;
+
+		if(kstate[i] == new_kstate[i])
+			continue;
+		/*
+		 * Send a fake keyboard event correcting the difference between
+		 * SDL's keyboard state and the actual. Note that there is no
+		 * way to find out the scancode for key releases, but since all
+		 * keys are released when focus is lost only keypresses should
+		 * be sent here
+		 */
+		st = new_kstate[i] ? SDL_PRESSED : SDL_RELEASED;
+		memset(&sk, 0, sizeof(sk));
+		sk.sym = i;
+		sk.scancode = xcode[i];		/* only valid for key press */
+		if ( gen_event ) {
+			SDL_PrivateKeyboard(st, &sk);
+		} else {
+			kstate[i] = new_kstate[i];
+		}
+	}
+}
+
+void X11_InitOSKeymap(_THIS)
+{
+	X11_InitKeymap();
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11events_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,34 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_x11video.h"
+
+/* Functions to be exported */
+extern void X11_InitOSKeymap(_THIS);
+extern void X11_PumpEvents(_THIS);
+extern void X11_SetKeyboardState(Display *display, const char *key_vec);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11gamma.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,147 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_x11video.h"
+
+/* From the X server sources... */
+#define MAX_GAMMA 10.0
+#define MIN_GAMMA (1.0/MAX_GAMMA)
+
+static int X11_SetGammaNoLock(_THIS, float red, float green, float blue)
+{
+#ifdef XFREE86_VMGAMMA
+    if (use_vidmode) {
+        XF86VidModeGamma gamma;
+        Bool succeeded;
+
+	/* Clamp the gamma values */
+	if ( red < MIN_GAMMA ) {
+		gamma.red = MIN_GAMMA;
+	} else
+	if ( red > MAX_GAMMA ) {
+		gamma.red = MAX_GAMMA;
+	} else {
+        	gamma.red = red;
+	}
+	if ( green < MIN_GAMMA ) {
+		gamma.green = MIN_GAMMA;
+	} else
+	if ( green > MAX_GAMMA ) {
+		gamma.green = MAX_GAMMA;
+	} else {
+        	gamma.green = green;
+	}
+	if ( blue < MIN_GAMMA ) {
+		gamma.blue = MIN_GAMMA;
+	} else
+	if ( blue > MAX_GAMMA ) {
+		gamma.blue = MAX_GAMMA;
+	} else {
+        	gamma.blue = blue;
+	}
+        if ( SDL_GetAppState() & SDL_APPACTIVE ) {
+            succeeded = XVidMode(SetGamma, (SDL_Display, SDL_Screen, &gamma));
+            XSync(SDL_Display, False);
+        } else {
+            gamma_saved[0] = gamma.red;
+            gamma_saved[1] = gamma.green;
+            gamma_saved[2] = gamma.blue;
+            succeeded = True;
+        }
+        if ( succeeded ) {
+            ++gamma_changed;
+        }
+        return succeeded ? 0 : -1;
+    }
+#endif
+    SDL_SetError("Gamma correction not supported");
+    return -1;
+}
+int X11_SetVidModeGamma(_THIS, float red, float green, float blue)
+{
+    int result;
+
+    SDL_Lock_EventThread();
+    result = X11_SetGammaNoLock(this, red, green, blue);
+    SDL_Unlock_EventThread();
+
+    return(result);
+}
+
+static int X11_GetGammaNoLock(_THIS, float *red, float *green, float *blue)
+{
+#ifdef XFREE86_VMGAMMA
+    if (use_vidmode) {
+        XF86VidModeGamma gamma;
+        if (XVidMode(GetGamma, (SDL_Display, SDL_Screen, &gamma))) {
+            *red   = gamma.red;
+            *green = gamma.green;
+            *blue  = gamma.blue;
+            return 0;
+        }
+        return -1;
+    }
+#endif
+    SDL_SetError("Gamma correction not supported");
+    return -1;
+}
+int X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue)
+{
+    int result;
+
+    SDL_Lock_EventThread();
+    result = X11_GetGammaNoLock(this, red, green, blue);
+    SDL_Unlock_EventThread();
+
+    return(result);
+}
+
+void X11_SaveVidModeGamma(_THIS)
+{
+    /* Try to save the current gamma, otherwise disable gamma control */
+    if ( X11_GetGammaNoLock(this,
+              &gamma_saved[0], &gamma_saved[1], &gamma_saved[2]) < 0 ) {
+        this->SetGamma = 0;
+        this->GetGamma = 0;
+    }
+    gamma_changed = 0;
+}
+void X11_SwapVidModeGamma(_THIS)
+{
+    float new_gamma[3];
+
+    if ( gamma_changed ) {
+        new_gamma[0] = gamma_saved[0];
+        new_gamma[1] = gamma_saved[1];
+        new_gamma[2] = gamma_saved[2];
+        X11_GetGammaNoLock(this, &gamma_saved[0], &gamma_saved[1], &gamma_saved[2]);
+        X11_SetGammaNoLock(this, new_gamma[0], new_gamma[1], new_gamma[2]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11gamma_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,36 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_x11gamma_h
+#define _SDL_x11gamma_h
+
+extern int X11_SetVidModeGamma(_THIS, float red, float green, float blue);
+extern int X11_GetVidModeGamma(_THIS, float *red, float *green, float *blue);
+extern void X11_SaveVidModeGamma(_THIS);
+extern void X11_SwapVidModeGamma(_THIS);
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11gl.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,413 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>	/* For getenv() prototype */
+#include <string.h>
+
+#include "SDL_events_c.h"
+#include "SDL_error.h"
+#include "SDL_x11video.h"
+#include "SDL_x11dga_c.h"
+#include "SDL_x11gl_c.h"
+
+#define DEFAULT_OPENGL	"libGL.so.1"
+
+/* return the preferred visual to use for openGL graphics */
+XVisualInfo *X11_GL_GetVisual(_THIS)
+{
+#ifdef HAVE_OPENGL
+	/* 64 seems nice. */
+	int attribs[64];
+	int i;
+
+	/* load the gl driver from a default path */
+	if ( ! this->gl_config.driver_loaded ) {
+	        /* no driver has been loaded, use default (ourselves) */
+	        if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
+		        return NULL;
+		}
+	}
+
+	/* See if we already have a window which we must use */
+	if ( SDL_windowid ) {
+		XWindowAttributes a;
+		XVisualInfo vi_in;
+		int out_count;
+
+		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
+		vi_in.screen = SDL_Screen;
+		vi_in.visualid = XVisualIDFromVisual(a.visual);
+		glx_visualinfo = XGetVisualInfo(SDL_Display,
+	                     VisualScreenMask|VisualIDMask, &vi_in, &out_count);
+		return glx_visualinfo;
+	}
+
+        /* Setup our GLX attributes according to the gl_config. */
+        i = 0;
+        attribs[i++] = GLX_RGBA;
+	attribs[i++] = GLX_RED_SIZE;
+	attribs[i++] = this->gl_config.red_size;
+	attribs[i++] = GLX_GREEN_SIZE;
+	attribs[i++] = this->gl_config.green_size;
+	attribs[i++] = GLX_BLUE_SIZE;
+	attribs[i++] = this->gl_config.blue_size;
+
+	if( this->gl_config.alpha_size ) {
+		attribs[i++] = GLX_ALPHA_SIZE;
+		attribs[i++] = this->gl_config.alpha_size;
+	}
+
+	if( this->gl_config.buffer_size ) {
+                attribs[i++] = GLX_BUFFER_SIZE;
+	        attribs[i++] = this->gl_config.buffer_size;
+	}
+
+	if( this->gl_config.double_buffer ) {
+		attribs[i++] = GLX_DOUBLEBUFFER;
+	}
+
+	attribs[i++] = GLX_DEPTH_SIZE;
+	attribs[i++] = this->gl_config.depth_size;
+
+	if( this->gl_config.stencil_size ) {
+		attribs[i++] = GLX_STENCIL_SIZE;
+		attribs[i++] = this->gl_config.stencil_size;
+	}
+
+	if( this->gl_config.accum_red_size ) {
+	        attribs[i++] = GLX_ACCUM_RED_SIZE;
+		attribs[i++] = this->gl_config.accum_red_size;
+	}
+
+	if( this->gl_config.accum_green_size ) {
+	        attribs[i++] = GLX_ACCUM_GREEN_SIZE;
+		attribs[i++] = this->gl_config.accum_green_size;
+	}
+
+	if( this->gl_config.accum_blue_size ) {
+	        attribs[i++] = GLX_ACCUM_BLUE_SIZE;
+		attribs[i++] = this->gl_config.accum_blue_size;
+	}
+
+	if( this->gl_config.accum_alpha_size ) {
+	        attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
+		attribs[i++] = this->gl_config.accum_alpha_size;
+	}
+
+#ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
+	attribs[i++] = GLX_X_VISUAL_TYPE;
+	attribs[i++] = GLX_DIRECT_COLOR;
+#endif
+	attribs[i++] = None;
+
+ 	glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, 
+						  SDL_Screen, attribs);
+#ifdef GLX_DIRECT_COLOR
+	if( !glx_visualinfo ) { /* No DirectColor visual?  Try again.. */
+		attribs[i-3] = None;
+ 		glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, 
+						  SDL_Screen, attribs);
+	}
+#endif
+	if( !glx_visualinfo ) {
+		SDL_SetError( "Couldn't find matching GLX visual");
+		return NULL;
+	}
+	return glx_visualinfo;
+#else
+	SDL_SetError("X11 driver not configured with OpenGL");
+	return NULL;
+#endif
+}
+
+int X11_GL_CreateWindow(_THIS, int w, int h)
+{
+	int retval;
+#ifdef HAVE_OPENGL
+	XSetWindowAttributes attributes;
+	unsigned long mask;
+	unsigned long black;
+
+	black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
+						 	SDL_Screen))
+	       	? BlackPixel(SDL_Display, SDL_Screen) : 0;
+	attributes.background_pixel = black;
+	attributes.border_pixel = black;
+	attributes.colormap = SDL_XColorMap;
+	mask = CWBackPixel | CWBorderPixel | CWColormap;
+
+	SDL_Window = XCreateWindow(SDL_Display, WMwindow,
+			0, 0, w, h, 0, glx_visualinfo->depth,
+			InputOutput, glx_visualinfo->visual,
+			mask, &attributes);
+	if ( !SDL_Window ) {
+		SDL_SetError("Could not create window");
+		return -1;
+	}
+	retval = 0;
+#else
+	SDL_SetError("X11 driver not configured with OpenGL");
+	retval = -1;
+#endif
+	return(retval);
+}
+
+int X11_GL_CreateContext(_THIS)
+{
+	int retval;
+#ifdef HAVE_OPENGL
+	/* We do this to create a clean separation between X and GLX errors. */
+	XSync( SDL_Display, False );
+	glx_context = this->gl_data->glXCreateContext(GFX_Display, 
+				     glx_visualinfo, NULL, True);
+	XSync( GFX_Display, False );
+
+	if (glx_context == NULL) {
+		SDL_SetError("Could not create GL context");
+		return -1;
+	}
+
+	gl_active = 1;
+#else
+	SDL_SetError("X11 driver not configured with OpenGL");
+#endif
+	if ( gl_active ) {
+		retval = 0;
+	} else {
+		retval = -1;
+	}
+	return(retval);
+}
+
+void X11_GL_Shutdown(_THIS)
+{
+#ifdef HAVE_OPENGL
+	/* Clean up OpenGL */
+	if( glx_context ) {
+		this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
+
+		if (glx_context != NULL)
+			this->gl_data->glXDestroyContext(GFX_Display, glx_context);
+
+		if( this->gl_data->glXReleaseBuffersMESA ) {
+		    this->gl_data->glXReleaseBuffersMESA(GFX_Display,SDL_Window);
+		}
+		glx_context = NULL;
+	}
+	gl_active = 0;
+#endif /* HAVE_OPENGL */
+}
+
+#ifdef HAVE_OPENGL
+
+/* Make the current context active */
+int X11_GL_MakeCurrent(_THIS)
+{
+	int retval;
+
+	retval = 0;
+	if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
+	                                     SDL_Window, glx_context) ) {
+		SDL_SetError("Unable to make GL context current");
+		retval = -1;
+	}
+	XSync( GFX_Display, False );
+
+	/* More Voodoo X server workarounds... Grr... */
+	SDL_Lock_EventThread();
+	X11_CheckDGAMouse(this);
+	SDL_Unlock_EventThread();
+
+	return(retval);
+}
+
+/* Get attribute data from glX. */
+int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
+{
+	int retval;
+	int glx_attrib = None;
+
+	switch( attrib ) {
+	    case SDL_GL_RED_SIZE:
+		glx_attrib = GLX_RED_SIZE;
+		break;
+	    case SDL_GL_GREEN_SIZE:
+		glx_attrib = GLX_GREEN_SIZE;
+		break;
+	    case SDL_GL_BLUE_SIZE:
+		glx_attrib = GLX_BLUE_SIZE;
+		break;
+	    case SDL_GL_ALPHA_SIZE:
+		glx_attrib = GLX_ALPHA_SIZE;
+		break;
+	    case SDL_GL_DOUBLEBUFFER:
+		glx_attrib = GLX_DOUBLEBUFFER;
+		break;
+	    case SDL_GL_BUFFER_SIZE:
+		glx_attrib = GLX_BUFFER_SIZE;
+		break;
+	    case SDL_GL_DEPTH_SIZE:
+		glx_attrib = GLX_DEPTH_SIZE;
+		break;
+	    case SDL_GL_STENCIL_SIZE:
+		glx_attrib = GLX_STENCIL_SIZE;
+		break;
+	    case SDL_GL_ACCUM_RED_SIZE:
+		glx_attrib = GLX_ACCUM_RED_SIZE;
+		break;
+	    case SDL_GL_ACCUM_GREEN_SIZE:
+		glx_attrib = GLX_ACCUM_GREEN_SIZE;
+		break;
+	    case SDL_GL_ACCUM_BLUE_SIZE:
+		glx_attrib = GLX_ACCUM_BLUE_SIZE;
+		break;
+	    case SDL_GL_ACCUM_ALPHA_SIZE:
+		glx_attrib = GLX_ACCUM_ALPHA_SIZE;
+		break;
+	    default:
+		return(-1);
+	}
+
+	retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
+
+	return retval;
+}
+
+void X11_GL_SwapBuffers(_THIS)
+{
+	this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
+}
+
+#endif /* HAVE_OPENGL */
+
+void X11_GL_UnloadLibrary(_THIS)
+{
+#ifdef HAVE_OPENGL
+	if ( this->gl_config.driver_loaded ) {
+		dlclose(this->gl_config.dll_handle);
+
+		this->gl_data->glXGetProcAddress = NULL;
+		this->gl_data->glXChooseVisual = NULL;
+		this->gl_data->glXCreateContext = NULL;
+		this->gl_data->glXDestroyContext = NULL;
+		this->gl_data->glXMakeCurrent = NULL;
+		this->gl_data->glXSwapBuffers = NULL;
+
+		this->gl_config.dll_handle = NULL;
+		this->gl_config.driver_loaded = 0;
+	}
+#endif
+}
+
+#ifdef HAVE_OPENGL
+
+/* Passing a NULL path means load pointers from the application */
+int X11_GL_LoadLibrary(_THIS, const char* path) 
+{
+	void* handle;
+	int dlopen_flags;
+
+ 	if ( gl_active ) {
+ 		SDL_SetError("OpenGL context already created");
+ 		return -1;
+ 	}
+
+#ifdef RTLD_GLOBAL
+	dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
+#else
+	dlopen_flags = RTLD_LAZY;
+#endif
+	handle = dlopen(path, dlopen_flags);
+	/* Catch the case where the application isn't linked with GL */
+	if ( (dlsym(handle, "glXChooseVisual") == NULL) && (path == NULL) ) {
+		dlclose(handle);
+		path = getenv("SDL_VIDEO_GL_DRIVER");
+		if ( path == NULL ) {
+			path = DEFAULT_OPENGL;
+		}
+		handle = dlopen(path, dlopen_flags);
+	}
+	if ( handle == NULL ) {
+		SDL_SetError("Could not load OpenGL library");
+		return -1;
+	}
+
+	/* Unload the old driver and reset the pointers */
+	X11_GL_UnloadLibrary(this);
+
+	/* Load new function pointers */
+	this->gl_data->glXGetProcAddress = dlsym(handle, "glXGetProcAddressARB");
+	this->gl_data->glXChooseVisual = dlsym(handle, "glXChooseVisual");
+	this->gl_data->glXCreateContext = dlsym(handle, "glXCreateContext");
+	this->gl_data->glXDestroyContext = dlsym(handle, "glXDestroyContext");
+	this->gl_data->glXMakeCurrent = dlsym(handle, "glXMakeCurrent");
+	this->gl_data->glXSwapBuffers = dlsym(handle, "glXSwapBuffers");
+	this->gl_data->glXGetConfig = dlsym(handle, "glXGetConfig");
+	/* We don't compare below for this in case we're not using Mesa. */
+	this->gl_data->glXReleaseBuffersMESA = dlsym( handle, "glXReleaseBuffersMESA" );
+
+	if ( (this->gl_data->glXChooseVisual == NULL) || 
+	     (this->gl_data->glXCreateContext == NULL) ||
+	     (this->gl_data->glXDestroyContext == NULL) ||
+	     (this->gl_data->glXMakeCurrent == NULL) ||
+	     (this->gl_data->glXSwapBuffers == NULL) ||
+	     (this->gl_data->glXGetConfig == NULL) ) {
+		SDL_SetError("Could not retrieve OpenGL functions");
+		return -1;
+	}
+
+	this->gl_config.dll_handle = handle;
+	this->gl_config.driver_loaded = 1;
+	if ( path ) {
+		strncpy(this->gl_config.driver_path, path,
+			sizeof(this->gl_config.driver_path)-1);
+	} else {
+		strcpy(this->gl_config.driver_path, "");
+	}
+	return 0;
+}
+
+void *X11_GL_GetProcAddress(_THIS, const char* proc)
+{
+	void* handle;
+	
+	handle = this->gl_config.dll_handle;
+#if 0 /* This doesn't work correctly yet */
+	if ( this->gl_data->glXGetProcAddress ) {
+        void *func, *func2;
+		func = this->gl_data->glXGetProcAddress(proc);
+        func2 = dlsym(handle, proc);
+        if ( func != func2 ) {
+fprintf(stderr, "glXGetProcAddress returned %p and dlsym returned %p for %s\n", func, func2, proc);
+        }
+        return this->gl_data->glXGetProcAddress(proc);
+	}
+#endif
+	return dlsym(handle, proc);
+}
+
+#endif /* HAVE_OPENGL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11gl_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,98 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifdef HAVE_OPENGL
+#include <GL/glx.h>
+#include <dlfcn.h>
+#endif
+#include "SDL_sysvideo.h"
+
+struct SDL_PrivateGLData {
+    int gl_active; /* to stop switching drivers while we have a valid context */
+
+#ifdef HAVE_OPENGL
+    GLXContext glx_context;	/* Current GL context */
+    XVisualInfo* glx_visualinfo; /* XVisualInfo* returned by glXChooseVisual */
+
+    void * (*glXGetProcAddress)(const GLubyte *procName);
+
+    XVisualInfo* (*glXChooseVisual)
+		( Display*		dpy,
+		  int			screen,
+		  int*		attribList );
+
+    GLXContext (*glXCreateContext)
+		( Display*		dpy,
+		  XVisualInfo*	vis,
+		  GLXContext		shareList,
+		  Bool		direct );
+
+    void (*glXDestroyContext)
+		( Display* 		dpy,
+		  GLXContext		ctx );
+
+    Bool (*glXMakeCurrent)
+		( Display*		dpy,
+		  GLXDrawable		drawable,
+		  GLXContext		ctx );
+
+    void (*glXSwapBuffers)
+		( Display*		dpy,
+		  GLXDrawable		drawable );
+
+    int (*glXGetConfig)
+	 ( Display* dpy,
+	   XVisualInfo* visual_info,
+	   int attrib,
+	   int* value );
+
+    void (*glXReleaseBuffersMESA)
+	 ( Display* dpy,
+	   GLXDrawable drawable );
+
+#endif /* HAVE_OPENGL */
+};
+
+/* Old variable names */
+#define gl_active		(this->gl_data->gl_active)
+#define glx_context		(this->gl_data->glx_context)
+#define glx_visualinfo		(this->gl_data->glx_visualinfo)
+
+/* OpenGL functions */
+extern XVisualInfo *X11_GL_GetVisual(_THIS);
+extern int X11_GL_CreateWindow(_THIS, int w, int h);
+extern int X11_GL_CreateContext(_THIS);
+extern void X11_GL_Shutdown(_THIS);
+#ifdef HAVE_OPENGL
+extern int X11_GL_MakeCurrent(_THIS);
+extern int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
+extern void X11_GL_SwapBuffers(_THIS);
+extern int X11_GL_LoadLibrary(_THIS, const char* path);
+extern void *X11_GL_GetProcAddress(_THIS, const char* proc);
+#endif
+extern void X11_GL_UnloadLibrary(_THIS);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11image.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,456 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+
+#include "SDL_error.h"
+#include "SDL_endian.h"
+#include "SDL_x11image_c.h"
+
+#if defined(__USLC__)
+#ifdef HAVE_KSTAT
+#undef HAVE_KSTAT
+#endif
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_KSTAT
+#include <kstat.h>
+#endif
+
+#ifndef NO_SHARED_MEMORY
+
+/* Shared memory information */
+extern int XShmQueryExtension(Display *dpy);	/* Not in X11 headers */
+
+/* Shared memory error handler routine */
+static int shm_error;
+static int (*X_handler)(Display *, XErrorEvent *) = NULL;
+static int shm_errhandler(Display *d, XErrorEvent *e)
+{
+        if ( e->error_code == BadAccess ) {
+        	++shm_error;
+        	return(0);
+        } else
+		return(X_handler(d,e));
+}
+#endif /* ! NO_SHARED_MEMORY */
+
+/* Various screen update functions available */
+static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects);
+static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects);
+
+int X11_SetupImage(_THIS, SDL_Surface *screen)
+{
+#ifdef NO_SHARED_MEMORY
+	screen->pixels = malloc(screen->h*screen->pitch);
+#else
+	/* Allocate shared memory if possible */
+	if ( use_mitshm ) {
+		shminfo.shmid = shmget(IPC_PRIVATE, screen->h*screen->pitch,
+								IPC_CREAT|0777);
+		if ( shminfo.shmid >= 0 ) {
+			shminfo.shmaddr = (char *)shmat(shminfo.shmid, 0, 0);
+			shminfo.readOnly = False;
+			if ( shminfo.shmaddr != (char *)-1 ) {
+				shm_error = False;
+				X_handler = XSetErrorHandler(shm_errhandler);
+				XShmAttach(SDL_Display, &shminfo);
+				XSync(SDL_Display, True);
+				XSetErrorHandler(X_handler);
+				if ( shm_error == True )
+					shmdt(shminfo.shmaddr);
+			} else {
+				shm_error = True;
+			}
+			shmctl(shminfo.shmid, IPC_RMID, NULL);
+		} else {
+			shm_error = True;
+		}
+		if ( shm_error == True )
+			use_mitshm = 0;
+	}
+	if ( use_mitshm ) {
+		screen->pixels = shminfo.shmaddr;
+	} else {
+		screen->pixels = malloc(screen->h*screen->pitch);
+	}
+#endif /* NO_SHARED_MEMORY */
+	if ( screen->pixels == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+
+#ifdef NO_SHARED_MEMORY
+	{
+ 	        int bpp = screen->format->BytesPerPixel;
+		SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
+					  this->hidden->depth, ZPixmap, 0,
+					  (char *)screen->pixels, 
+					  screen->w, screen->h,
+					  (bpp == 3) ? 32 : bpp * 8,
+					  0);
+	}
+#else
+	if ( use_mitshm ) {
+		SDL_Ximage = XShmCreateImage(SDL_Display, SDL_Visual,
+					     this->hidden->depth, ZPixmap,
+					     shminfo.shmaddr, &shminfo, 
+					     screen->w, screen->h);
+	} else {
+ 	        int bpp = screen->format->BytesPerPixel;
+		SDL_Ximage = XCreateImage(SDL_Display, SDL_Visual,
+					  this->hidden->depth, ZPixmap, 0,
+					  (char *)screen->pixels, 
+					  screen->w, screen->h,
+					  (bpp == 3) ? 32 : bpp * 8,
+					  0);
+	}
+#endif /* NO_SHARED_MEMORY */
+	if ( SDL_Ximage == NULL ) {
+		SDL_SetError("Couldn't create XImage");
+#ifndef NO_SHARED_MEMORY
+		if ( use_mitshm ) {
+			XShmDetach(SDL_Display, &shminfo);
+			XSync(SDL_Display, False);
+			shmdt(shminfo.shmaddr);
+			screen->pixels = NULL;
+		}
+#endif /* ! NO_SHARED_MEMORY */
+		return(-1);
+	}
+	screen->pitch = SDL_Ximage->bytes_per_line;
+
+	/* Determine what blit function to use */
+#ifdef NO_SHARED_MEMORY
+	this->UpdateRects = X11_NormalUpdate;
+#else
+	if ( use_mitshm ) {
+		this->UpdateRects = X11_MITSHMUpdate;
+	} else {
+		this->UpdateRects = X11_NormalUpdate;
+	}
+#endif
+	return(0);
+}
+
+void X11_DestroyImage(_THIS, SDL_Surface *screen)
+{
+	if ( SDL_Ximage ) {
+		XDestroyImage(SDL_Ximage);
+#ifndef NO_SHARED_MEMORY
+		if ( use_mitshm ) {
+			XShmDetach(SDL_Display, &shminfo);
+			XSync(SDL_Display, False);
+			shmdt(shminfo.shmaddr);
+		}
+#endif /* ! NO_SHARED_MEMORY */
+		SDL_Ximage = NULL;
+	}
+	if ( screen ) {
+		screen->pixels = NULL;
+	}
+}
+
+/* This is a hack to see whether this system has more than 1 CPU */
+static int num_CPU(void)
+{
+       static int num_cpus = 0;
+
+       if(!num_cpus) {
+#ifdef linux
+           char line[BUFSIZ];
+           FILE *pstat = fopen("/proc/stat", "r");
+           if ( pstat ) {
+               while ( fgets(line, sizeof(line), pstat) ) {
+                   if (memcmp(line, "cpu", 3) == 0 && line[3] != ' ') {
+                       ++num_cpus;
+                   }
+               }
+               fclose(pstat);
+           }
+#elif defined(HAVE_KSTAT)
+           kstat_ctl_t *kc = kstat_open();
+           kstat_t *ks;
+           kstat_named_t *kn;
+           if(kc) {
+               if((ks = kstat_lookup(kc, "unix", -1, "system_misc"))
+                  && kstat_read(kc, ks, NULL) != -1
+                  && (kn = kstat_data_lookup(ks, "ncpus")))
+#ifdef KSTAT_DATA_UINT32
+                   num_cpus = kn->value.ui32;
+#else
+                   num_cpus = kn->value.ul; /* needed in solaris <2.6 */
+#endif
+               kstat_close(kc);
+           }
+#elif defined(__USLC__)
+           num_cpus = (int)sysconf(_SC_NPROCESSORS_CONF);
+#endif
+           if ( num_cpus <= 0 ) {
+               num_cpus = 1;
+           }
+       }
+       return num_cpus;
+}
+
+int X11_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)
+{
+	int retval;
+
+	X11_DestroyImage(this, screen);
+        if ( flags & SDL_OPENGL ) {  /* No image when using GL */
+        	retval = 0;
+        } else {
+		retval = X11_SetupImage(this, screen);
+		/* We support asynchronous blitting on the display */
+		if ( flags & SDL_ASYNCBLIT ) {
+			/* This is actually slower on single-CPU systems,
+			   probably because of CPU contention between the
+			   X server and the application.
+			   Note: Is this still true with XFree86 4.0?
+			*/
+			if ( num_CPU() > 1 ) {
+				screen->flags |= SDL_ASYNCBLIT;
+			}
+		}
+	}
+	return(retval);
+}
+
+/* We don't actually allow hardware surfaces other than the main one */
+int X11_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(-1);
+}
+void X11_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+int X11_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( (surface == SDL_VideoSurface) && blit_queued ) {
+		XSync(GFX_Display, False);
+		blit_queued = 0;
+	}
+	return(0);
+}
+void X11_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	return;
+}
+
+int X11_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	return(0);
+}
+
+/* Byte-swap the pixels in the display image */
+static void X11_SwapAllPixels(SDL_Surface *screen)
+{
+	int x, y;
+
+	switch (screen->format->BytesPerPixel) {
+	    case 2: {
+		Uint16 *spot;
+		for ( y=0; y<screen->h; ++y ) {
+			spot = (Uint16 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch);
+			for ( x=0; x<screen->w; ++x, ++spot ) {
+				*spot = SDL_Swap16(*spot);
+			}
+		}
+	    }
+	    break;
+
+	    case 4: {
+		Uint32 *spot;
+		for ( y=0; y<screen->h; ++y ) {
+			spot = (Uint32 *) ((Uint8 *)screen->pixels +
+						y * screen->pitch);
+			for ( x=0; x<screen->w; ++x, ++spot ) {
+				*spot = SDL_Swap32(*spot);
+			}
+		}
+	    }
+	    break;
+
+	    default:
+		/* should never get here */
+		break;
+	}
+}
+static void X11_SwapPixels(SDL_Surface *screen, SDL_Rect *rect)
+{
+	int x, minx, maxx;
+	int y, miny, maxy;
+
+	switch (screen->format->BytesPerPixel) {
+	    case 2: {
+		Uint16 *spot;
+		minx = rect->x;
+		maxx = rect->x + rect->w;
+		miny = rect->y;
+		maxy = rect->y + rect->h;
+		for ( y=miny; y<maxy; ++y ) {
+		    spot = (Uint16 *) ((Uint8 *)screen->pixels +
+				       y * screen->pitch + minx * 2);
+		    for ( x=minx; x<maxx; ++x, ++spot ) {
+			*spot = SDL_Swap16(*spot);
+		    }
+		}
+	    }
+	    break;
+
+	    case 4: {
+		Uint32 *spot;
+		minx = rect->x;
+		maxx = rect->x + rect->w;
+		miny = rect->y;
+		maxy = rect->y + rect->h;
+		for ( y=miny; y<maxy; ++y ) {
+		    spot = (Uint32 *) ((Uint8 *)screen->pixels +
+				       y * screen->pitch + minx * 4);
+		    for ( x=minx; x<maxx; ++x, ++spot ) {
+			*spot = SDL_Swap32(*spot);
+		    }
+		}
+	    }
+	    break;
+
+	    default:
+		/* should never get here */
+		break;
+	}
+}
+
+static void X11_NormalUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	int i;
+
+	/* Check for endian-swapped X server, swap if necessary (VERY slow!) */
+	if ( swap_pixels &&
+	     ((this->screen->format->BytesPerPixel%2) == 0) ) {
+		for ( i=0; i<numrects; ++i ) {
+			if ( ! rects[i].w ) { /* Clipped? */
+				continue;
+			}
+		        X11_SwapPixels(this->screen, rects + i);
+			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				rects[i].x, rects[i].y,
+				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+			X11_SwapPixels(this->screen, rects + i);
+		}
+	} else {
+		for ( i=0; i<numrects; ++i ) {
+			if ( ! rects[i].w ) { /* Clipped? */
+				continue;
+			}
+			XPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				rects[i].x, rects[i].y,
+				rects[i].x, rects[i].y, rects[i].w, rects[i].h);
+		}
+	}
+	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
+		XFlush(GFX_Display);
+		++blit_queued;
+	} else {
+		XSync(GFX_Display, False);
+	}
+}
+
+static void X11_MITSHMUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+#ifndef NO_SHARED_MEMORY
+	int i;
+
+	for ( i=0; i<numrects; ++i ) {
+		if ( ! rects[i].w ) { /* Clipped? */
+			continue;
+		}
+		XShmPutImage(GFX_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				rects[i].x, rects[i].y,
+				rects[i].x, rects[i].y, rects[i].w, rects[i].h,
+									False);
+	}
+	if ( SDL_VideoSurface->flags & SDL_ASYNCBLIT ) {
+		XFlush(GFX_Display);
+		++blit_queued;
+	} else {
+		XSync(GFX_Display, False);
+	}
+#endif /* ! NO_SHARED_MEMORY */
+}
+
+/* There's a problem with the automatic refreshing of the display.
+   Even though the XVideo code uses the GFX_Display to update the
+   video memory, it appears that updating the window asynchronously
+   from a different thread will cause "blackouts" of the window.
+   This is a sort of a hacked workaround for the problem.
+*/
+static int enable_autorefresh = 1;
+
+void X11_DisableAutoRefresh(_THIS)
+{
+	--enable_autorefresh;
+}
+
+void X11_EnableAutoRefresh(_THIS)
+{
+	++enable_autorefresh;
+}
+
+void X11_RefreshDisplay(_THIS)
+{
+	/* Don't refresh a display that doesn't have an image (like GL) */
+	if ( ! SDL_Ximage || (enable_autorefresh <= 0) ) {
+		return;
+	}
+#ifndef NO_SHARED_MEMORY
+	if ( this->UpdateRects == X11_MITSHMUpdate ) {
+		XShmPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				0, 0, 0, 0, this->screen->w, this->screen->h,
+				False);
+	} else {
+#else
+	{
+#endif /* ! NO_SHARED_MEMORY */
+		/* Check for endian-swapped X server, swap if necessary */
+		if ( swap_pixels &&
+		     ((this->screen->format->BytesPerPixel%2) == 0) ) {
+			X11_SwapAllPixels(this->screen);
+			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				0, 0, 0, 0, this->screen->w, this->screen->h);
+			X11_SwapAllPixels(this->screen);
+		} else {
+			XPutImage(SDL_Display, SDL_Window, SDL_GC, SDL_Ximage,
+				0, 0, 0, 0, this->screen->w, this->screen->h);
+		}
+	}
+	XSync(SDL_Display, False);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11image_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_x11video.h"
+
+extern int X11_SetupImage(_THIS, SDL_Surface *screen);
+extern void X11_DestroyImage(_THIS, SDL_Surface *screen);
+extern int X11_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags);
+
+extern int X11_AllocHWSurface(_THIS, SDL_Surface *surface);
+extern void X11_FreeHWSurface(_THIS, SDL_Surface *surface);
+extern int X11_LockHWSurface(_THIS, SDL_Surface *surface);
+extern void X11_UnlockHWSurface(_THIS, SDL_Surface *surface);
+extern int X11_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+extern void X11_DisableAutoRefresh(_THIS);
+extern void X11_EnableAutoRefresh(_THIS);
+extern void X11_RefreshDisplay(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11modes.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,534 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Utilities for getting and setting the X display mode */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL_timer.h"
+#include "SDL_error.h"
+#include "SDL_events.h"
+#include "SDL_events_c.h"
+#include "SDL_x11video.h"
+#include "SDL_x11wm_c.h"
+#include "SDL_x11modes_c.h"
+
+
+#ifdef XFREE86_VM
+Bool XVidMode(GetModeInfo, (Display *dpy, int scr, XF86VidModeModeInfo *info))
+{
+    XF86VidModeModeLine *l = (XF86VidModeModeLine*)((char*)info + sizeof info->dotclock);
+    return XVidMode(GetModeLine, (dpy, scr, &info->dotclock, l));
+}
+#endif /* XFREE86_VM */
+
+#ifdef XFREE86_VM
+static void save_mode(_THIS)
+{
+    memset(&saved_mode, 0, sizeof(saved_mode));
+    XVidMode(GetModeInfo, (SDL_Display,SDL_Screen,&saved_mode));
+    XVidMode(GetViewPort, (SDL_Display,SDL_Screen,&saved_view.x,&saved_view.y));
+}
+#endif
+
+#ifdef XFREE86_VM
+static void restore_mode(_THIS)
+{
+    XF86VidModeModeLine mode;
+    int unused;
+
+    if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) {
+        if ( (saved_mode.hdisplay != mode.hdisplay) ||
+             (saved_mode.vdisplay != mode.vdisplay) ) {
+            XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, &saved_mode));
+        }
+    }
+    if ( (saved_view.x != 0) || (saved_view.y != 0) ) {
+        XVidMode(SetViewPort, (SDL_Display, SDL_Screen, saved_view.x, saved_view.y));
+    }
+}
+#endif
+
+#ifdef XFREE86_VM
+static int cmpmodes(const void *va, const void *vb)
+{
+    XF86VidModeModeInfo *a = *(XF86VidModeModeInfo**)va;
+    XF86VidModeModeInfo *b = *(XF86VidModeModeInfo**)vb;
+    if(a->hdisplay > b->hdisplay)
+        return -1;
+    return b->vdisplay - a->vdisplay;
+}
+#endif
+
+static void set_best_resolution(_THIS, int width, int height)
+{
+#ifdef XFREE86_VM
+    if ( use_vidmode ) {
+        XF86VidModeModeLine mode;
+        XF86VidModeModeInfo **modes;
+        int i;
+        int nmodes;
+
+        if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &i, &mode)) &&
+             XVidMode(GetAllModeLines, (SDL_Display,SDL_Screen,&nmodes,&modes))){
+            qsort(modes, nmodes, sizeof *modes, cmpmodes);
+#ifdef XFREE86_DEBUG
+  printf("Available modes:\n");
+  for ( i = 0; i < nmodes; ++i ) {
+    printf("Mode %d: %dx%d\n", i, modes[i]->hdisplay, modes[i]->vdisplay);
+  }
+#endif
+            for ( i = nmodes-1; i > 0 ; --i ) {
+                if ( (modes[i]->hdisplay >= width) &&
+                     (modes[i]->vdisplay >= height) )
+                    break;
+            }
+            if ( (modes[i]->hdisplay != mode.hdisplay) ||
+                 (modes[i]->vdisplay != mode.vdisplay) ) {
+                XVidMode(SwitchToMode, (SDL_Display, SDL_Screen, modes[i]));
+            }
+            XFree(modes);
+        }
+    }
+#endif /* XFREE86_VM */
+}
+
+static void get_real_resolution(_THIS, int* w, int* h)
+{
+#ifdef XFREE86_VM
+    if ( use_vidmode ) {
+        XF86VidModeModeLine mode;
+        int unused;
+
+        if ( XVidMode(GetModeLine, (SDL_Display, SDL_Screen, &unused, &mode)) ) {
+            *w = mode.hdisplay;
+            *h = mode.vdisplay;
+            return;
+        }
+    }
+#endif
+    *w = DisplayWidth(SDL_Display, SDL_Screen);
+    *h = DisplayHeight(SDL_Display, SDL_Screen);
+}
+
+/* Called after mapping a window - waits until the window is mapped */
+void X11_WaitMapped(_THIS, Window win)
+{
+    XEvent event;
+    do {
+        XMaskEvent(SDL_Display, StructureNotifyMask, &event);
+    } while ( (event.type != MapNotify) || (event.xmap.event != win) );
+}
+
+/* Called after unmapping a window - waits until the window is unmapped */
+void X11_WaitUnmapped(_THIS, Window win)
+{
+    XEvent event;
+    do {
+        XMaskEvent(SDL_Display, StructureNotifyMask, &event);
+    } while ( (event.type != UnmapNotify) || (event.xunmap.event != win) );
+}
+
+static void move_cursor_to(_THIS, int x, int y)
+{
+    XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y);
+}
+
+static int add_visual(_THIS, int depth, int class)
+{
+    XVisualInfo vi;
+    if(XMatchVisualInfo(SDL_Display, SDL_Screen, depth, class, &vi)) {
+	int n = this->hidden->nvisuals;
+	this->hidden->visuals[n].depth = vi.depth;
+	this->hidden->visuals[n].visual = vi.visual;
+	this->hidden->nvisuals++;
+    }
+    return(this->hidden->nvisuals);
+}
+static int add_visual_byid(_THIS, const char *visual_id)
+{
+    XVisualInfo *vi, template;
+    int nvis;
+
+    if ( visual_id ) {
+        memset(&template, 0, (sizeof template));
+        template.visualid = strtol(visual_id, NULL, 0);
+        vi = XGetVisualInfo(SDL_Display, VisualIDMask, &template, &nvis);
+        if ( vi ) {
+	    int n = this->hidden->nvisuals;
+	    this->hidden->visuals[n].depth = vi->depth;
+	    this->hidden->visuals[n].visual = vi->visual;
+	    this->hidden->nvisuals++;
+            XFree(vi);
+        }
+    }
+    return(this->hidden->nvisuals);
+}
+
+/* Global for the error handler */
+int vm_event, vm_error = -1;
+
+int X11_GetVideoModes(_THIS)
+{
+#ifdef XFREE86_VM
+    int buggy_X11;
+    int vm_major, vm_minor;
+    int nmodes;
+    XF86VidModeModeInfo **modes;
+#endif
+    int i;
+
+    vm_error = -1;
+    use_vidmode = 0;
+#ifdef XFREE86_VM
+    /* Metro-X 4.3.0 and earlier has a broken implementation of
+       XF86VidModeGetAllModeLines() - it hangs the client.
+     */
+    buggy_X11 = 0;
+    if ( strcmp(ServerVendor(SDL_Display), "Metro Link Incorporated") == 0 ) {
+        FILE *metro_fp;
+
+        metro_fp = fopen("/usr/X11R6/lib/X11/Metro/.version", "r");
+        if ( metro_fp != NULL ) {
+            int major, minor, patch, version;
+            major = 0; minor = 0; patch = 0;
+            fscanf(metro_fp, "%d.%d.%d", &major, &minor, &patch);
+            version = major*100+minor*10+patch;
+            if ( version < 431 ) {
+                buggy_X11 = 1;
+            }
+            fclose(metro_fp);
+        }
+    }
+#if defined(__alpha__) || defined(__powerpc__)
+    /* The alpha and PPC XFree86 servers are also buggy */
+    buggy_X11 = 1;
+#endif
+    /* Enumerate the available fullscreen modes */
+    if ( ! buggy_X11 ) {
+        if ( XVidMode(QueryExtension, (SDL_Display, &vm_event, &vm_error)) &&
+              XVidMode(QueryVersion, (SDL_Display, &vm_major, &vm_minor)) ) {
+#ifdef BROKEN_XFREE86_4001
+#ifdef X_XF86VidModeGetDotClocks  /* Compiled under XFree86 4.0 */
+                /* Earlier X servers hang when doing vidmode */
+		if ( vm_major < 2 ) {
+#ifdef DEBUG_XF86
+  printf("Compiled under XFree86 4.0, server is XFree86 3.X\n");
+#endif
+                    buggy_X11 = 1;
+                }
+#else
+		/* XFree86 3.X code works with XFree86 4.0 servers */;
+#endif /* XFree86 4.0 */
+#endif /* XFree86 4.02 and newer are fixed wrt backwards compatibility */
+        } else {
+            buggy_X11 = 1;
+        }
+    }
+    if ( ! buggy_X11 &&
+         XVidMode(GetAllModeLines, (SDL_Display, SDL_Screen,&nmodes,&modes)) ) {
+
+        qsort(modes, nmodes, sizeof *modes, cmpmodes);
+        SDL_modelist = (SDL_Rect **)malloc((nmodes+1)*sizeof(SDL_Rect *));
+        if ( SDL_modelist ) {
+            for ( i=0; i<nmodes; ++i ) {
+                SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+                if ( SDL_modelist[i] == NULL ) {
+                    break;
+                }
+                SDL_modelist[i]->x = 0;
+                SDL_modelist[i]->y = 0;
+                SDL_modelist[i]->w = modes[i]->hdisplay;
+                SDL_modelist[i]->h = modes[i]->vdisplay;
+            }
+            SDL_modelist[i] = NULL;
+        }
+        XFree(modes);
+
+        use_vidmode = 1;
+        save_mode(this);
+    }
+#endif /* XFREE86_VM */
+
+    {
+	static int depth_list[] = { 32, 24, 16, 15, 8 };
+	int j, np;
+	int use_directcolor = 1;
+	XPixmapFormatValues *pf;
+
+	/* Search for the visuals in deepest-first order, so that the first
+	   will be the richest one */
+	if ( getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {
+		use_directcolor = 0;
+	}
+	this->hidden->nvisuals = 0;
+	if ( ! add_visual_byid(this, getenv("SDL_VIDEO_X11_VISUALID")) ) {
+		for ( i=0; i<SDL_TABLESIZE(depth_list); ++i ) {
+			if ( depth_list[i] > 8 ) {
+				if ( use_directcolor ) {
+					add_visual(this, depth_list[i], DirectColor);
+				}
+				add_visual(this, depth_list[i], TrueColor);
+			} else {
+				add_visual(this, depth_list[i], PseudoColor);
+				add_visual(this, depth_list[i], StaticColor);
+			}
+		}
+	}
+	if ( this->hidden->nvisuals == 0 ) {
+	    SDL_SetError("Found no sufficiently capable X11 visuals");
+	    return -1;
+	}
+	    
+	/* look up the pixel quantum for each depth */
+	pf = XListPixmapFormats(SDL_Display, &np);
+	for(i = 0; i < this->hidden->nvisuals; i++) {
+	    int d = this->hidden->visuals[i].depth;
+	    for(j = 0; j < np; j++)
+		if(pf[j].depth == d)
+		    break;
+	    this->hidden->visuals[i].bpp = j < np ? pf[j].bits_per_pixel : d;
+	}
+
+	XFree(pf);
+    }
+
+    if ( SDL_modelist == NULL ) {
+        SDL_modelist = (SDL_Rect **)malloc((1+1)*sizeof(SDL_Rect *));
+        i = 0;
+        if ( SDL_modelist ) {
+            SDL_modelist[i] = (SDL_Rect *)malloc(sizeof(SDL_Rect));
+            if ( SDL_modelist[i] ) {
+                SDL_modelist[i]->x = 0;
+                SDL_modelist[i]->y = 0;
+                SDL_modelist[i]->w = DisplayWidth(SDL_Display, SDL_Screen);
+                SDL_modelist[i]->h = DisplayHeight(SDL_Display, SDL_Screen);
+                ++i;
+            }
+            SDL_modelist[i] = NULL;
+        }
+    }
+
+#ifdef DEBUG_XF86
+    if ( use_vidmode ) {
+        fprintf(stderr, "XFree86 VidMode is enabled\n");
+    }
+    if ( SDL_modelist ) {
+        fprintf(stderr, "X11 video mode list:\n");
+        for ( i=0; SDL_modelist[i]; ++i ) {
+            fprintf(stderr, "\t%dx%d\n",
+                SDL_modelist[i]->w, SDL_modelist[i]->h);
+        }
+    }
+#endif /* DEBUG_XF86 */
+    return 0;
+}
+
+int X11_SupportedVisual(_THIS, SDL_PixelFormat *format)
+{
+    int i;
+    for(i = 0; i < this->hidden->nvisuals; i++)
+	if(this->hidden->visuals[i].bpp == format->BitsPerPixel)
+	    return 1;
+    return 0;
+}
+
+SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+    if ( X11_SupportedVisual(this, format) ) {
+        if ( flags & SDL_FULLSCREEN ) {
+            return(SDL_modelist);
+        } else {
+            return((SDL_Rect **)-1);
+        }
+    } else {
+        return((SDL_Rect **)0);
+    }
+}
+
+void X11_FreeVideoModes(_THIS)
+{
+    int i;
+
+    if ( SDL_modelist ) {
+        for ( i=0; SDL_modelist[i]; ++i ) {
+            free(SDL_modelist[i]);
+        }
+        free(SDL_modelist);
+        SDL_modelist = NULL;
+    }
+}
+
+int X11_ResizeFullScreen(_THIS)
+{
+    int x, y;
+    int real_w, real_h;
+
+    if ( currently_fullscreen ) {
+        /* Switch resolution and cover it with the FSwindow */
+        move_cursor_to(this, 0, 0);
+        set_best_resolution(this, current_w, current_h);
+        move_cursor_to(this, 0, 0);
+        get_real_resolution(this, &real_w, &real_h);
+        XResizeWindow(SDL_Display, FSwindow, real_w, real_h);
+        move_cursor_to(this, real_w/2, real_h/2);
+
+        /* Center and reparent the drawing window */
+        x = (real_w - current_w)/2;
+        y = (real_h - current_h)/2;
+        XReparentWindow(SDL_Display, SDL_Window, FSwindow, x, y);
+        /* FIXME: move the mouse to the old relative location */
+        XSync(SDL_Display, True);   /* Flush spurious mode change events */
+    }
+    return(1);
+}
+
+void X11_QueueEnterFullScreen(_THIS)
+{
+    switch_waiting = 0x01 | SDL_FULLSCREEN;
+    switch_time = SDL_GetTicks() + 1500;
+#if 0 /* This causes a BadMatch error if the window is iconified (not needed) */
+    XSetInputFocus(SDL_Display, WMwindow, RevertToNone, CurrentTime);
+#endif
+}
+
+int X11_EnterFullScreen(_THIS)
+{
+    int okay;
+#if 0
+    Window tmpwin, *windows;
+    int i, nwindows;
+#endif
+
+    okay = 1;
+    if ( ! currently_fullscreen ) {
+        int real_w, real_h;
+
+        /* Map the fullscreen window to blank the screen */
+        get_real_resolution(this, &real_w, &real_h);
+        XResizeWindow(SDL_Display, FSwindow, real_w, real_h);
+        XMapRaised(SDL_Display, FSwindow);
+        X11_WaitMapped(this, FSwindow);
+
+#if 0 /* This seems to break WindowMaker in focus-follows-mouse mode */
+        /* Make sure we got to the top of the window stack */
+        if ( XQueryTree(SDL_Display, SDL_Root, &tmpwin, &tmpwin,
+                                &windows, &nwindows) && windows ) {
+            /* If not, try to put us there - if fail... oh well */
+            if ( windows[nwindows-1] != FSwindow ) {
+                tmpwin = windows[nwindows-1];
+                for ( i=0; i<nwindows; ++i ) {
+                    if ( windows[i] == FSwindow ) {
+                        memcpy(&windows[i], &windows[i+1],
+                               (nwindows-i-1)*sizeof(windows[i]));
+                        break;
+                    }
+                }
+                windows[nwindows-1] = FSwindow;
+                XRestackWindows(SDL_Display, windows, nwindows);
+                XSync(SDL_Display, False);
+            }
+            XFree(windows);
+        }
+#else
+	XRaiseWindow(SDL_Display, FSwindow);
+#endif
+
+        /* Grab the mouse on the fullscreen window
+           The event handling will know when we become active, and then
+           enter fullscreen mode if we can't grab the mouse this time.
+         */
+#ifdef GRAB_FULLSCREEN
+        if ( (XGrabPointer(SDL_Display, FSwindow, True, 0,
+                          GrabModeAsync, GrabModeAsync,
+                          FSwindow, None, CurrentTime) != GrabSuccess) ||
+             (XGrabKeyboard(SDL_Display, WMwindow, True,
+                          GrabModeAsync, GrabModeAsync, CurrentTime) != 0) ) {
+#else
+        if ( XGrabPointer(SDL_Display, FSwindow, True, 0,
+                          GrabModeAsync, GrabModeAsync,
+                          FSwindow, None, CurrentTime) != GrabSuccess ) {
+#endif
+            /* We lost the grab, so try again later */
+            XUnmapWindow(SDL_Display, FSwindow);
+            X11_WaitUnmapped(this, FSwindow);
+            X11_QueueEnterFullScreen(this);
+            return(0);
+        }
+#ifdef GRAB_FULLSCREEN
+	SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
+#endif
+
+#ifdef XFREE86_VM
+        /* Save the current video mode */
+        if ( use_vidmode ) {
+            XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, True));
+        }
+#endif
+        currently_fullscreen = 1;
+
+        /* Set the new resolution */
+        okay = X11_ResizeFullScreen(this);
+        if ( ! okay ) {
+            X11_LeaveFullScreen(this);
+        }
+	/* Set the colormap */
+	if ( SDL_XColorMap ) {
+		XInstallColormap(SDL_Display, SDL_XColorMap);
+	}
+    }
+    X11_GrabInputNoLock(this, this->input_grab | SDL_GRAB_FULLSCREEN);
+    return(okay);
+}
+
+int X11_LeaveFullScreen(_THIS)
+{
+    if ( currently_fullscreen ) {
+        XReparentWindow(SDL_Display, SDL_Window, WMwindow, 0, 0);
+#ifdef XFREE86_VM
+        if ( use_vidmode ) {
+            restore_mode(this);
+            XVidMode(LockModeSwitch, (SDL_Display, SDL_Screen, False));
+        }
+#endif
+        XUnmapWindow(SDL_Display, FSwindow);
+        X11_WaitUnmapped(this, FSwindow);
+#ifdef GRAB_FULLSCREEN
+        XUngrabKeyboard(SDL_Display, CurrentTime);
+#endif
+        XSync(SDL_Display, True);   /* Flush spurious mode change events */
+        currently_fullscreen = 0;
+    }
+    /* If we get popped out of fullscreen mode for some reason, input_grab
+       will still have the SDL_GRAB_FULLSCREEN flag set, since this is only
+       temporary.  In this case, release the grab unless the input has been
+       explicitly grabbed.
+     */
+    X11_GrabInputNoLock(this, this->input_grab & ~SDL_GRAB_FULLSCREEN);
+    return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11modes_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,47 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* Utilities for getting and setting the X display mode */
+
+#include "SDL_x11video.h"
+
+/* Define this if you want to grab the keyboard in fullscreen mode.
+   If you do not define this, SDL will return from SDL_SetVideoMode()
+   immediately, but will not actually go fullscreen until the window
+   manager is idle.
+*/
+#define GRAB_FULLSCREEN
+
+extern int X11_GetVideoModes(_THIS);
+extern SDL_Rect **X11_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+extern void X11_FreeVideoModes(_THIS);
+extern int X11_ResizeFullScreen(_THIS);
+extern void X11_WaitMapped(_THIS, Window win);
+extern void X11_WaitUnmapped(_THIS, Window win);
+extern void X11_QueueEnterFullScreen(_THIS);
+extern int X11_EnterFullScreen(_THIS);
+extern int X11_LeaveFullScreen(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11mouse.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,273 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+#include "SDL_cursor_c.h"
+#include "SDL_x11dga_c.h"
+#include "SDL_x11mouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+	Cursor x_cursor;
+};
+
+
+void X11_FreeWMCursor(_THIS, WMcursor *cursor)
+{
+	if ( SDL_Display != NULL ) {
+		SDL_Lock_EventThread();
+		XFreeCursor(SDL_Display, cursor->x_cursor);
+		XSync(SDL_Display, False);
+		SDL_Unlock_EventThread();
+	}
+	free(cursor);
+}
+
+WMcursor *X11_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y)
+{
+	WMcursor *cursor;
+	XGCValues GCvalues;
+	GC        GCcursor;
+	XImage *data_image, *mask_image;
+	Pixmap  data_pixmap, mask_pixmap;
+	int       clen, i;
+	char     *x_data, *x_mask;
+	static XColor black = {  0,  0,  0,  0 };
+	static XColor white = { 0xffff, 0xffff, 0xffff, 0xffff };
+
+	/* Allocate the cursor memory */
+	cursor = (WMcursor *)malloc(sizeof(WMcursor));
+	if ( cursor == NULL ) {
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+
+	/* Mix the mask and the data */
+	clen = (w/8)*h;
+	x_data = (char *)malloc(clen);
+	if ( x_data == NULL ) {
+		free(cursor);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	x_mask = (char *)malloc(clen);
+	if ( x_mask == NULL ) {
+		free(cursor);
+		free(x_data);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	for ( i=0; i<clen; ++i ) {
+		/* The mask is OR'd with the data to turn inverted color
+		   pixels black since inverted color cursors aren't supported
+		   under X11.
+		 */
+		x_mask[i] = data[i] | mask[i];
+		x_data[i] = data[i];
+	}
+
+	/* Prevent the event thread from running while we use the X server */
+	SDL_Lock_EventThread();
+
+	/* Create the data image */
+	data_image = XCreateImage(SDL_Display, 
+			DefaultVisual(SDL_Display, SDL_Screen),
+					1, XYBitmap, 0, x_data, w, h, 8, w/8);
+	data_image->byte_order = MSBFirst;
+	data_image->bitmap_bit_order = MSBFirst;
+	data_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
+
+	/* Create the data mask */
+	mask_image = XCreateImage(SDL_Display, 
+			DefaultVisual(SDL_Display, SDL_Screen),
+					1, XYBitmap, 0, x_mask, w, h, 8, w/8);
+	mask_image->byte_order = MSBFirst;
+	mask_image->bitmap_bit_order = MSBFirst;
+	mask_pixmap = XCreatePixmap(SDL_Display, SDL_Root, w, h, 1);
+
+	/* Create the graphics context */
+	GCvalues.function = GXcopy;
+	GCvalues.foreground = ~0;
+	GCvalues.background =  0;
+	GCvalues.plane_mask = AllPlanes;
+	GCcursor = XCreateGC(SDL_Display, data_pixmap,
+			(GCFunction|GCForeground|GCBackground|GCPlaneMask),
+								&GCvalues);
+
+	/* Blit the images to the pixmaps */
+	XPutImage(SDL_Display, data_pixmap, GCcursor, data_image,
+							0, 0, 0, 0, w, h);
+	XPutImage(SDL_Display, mask_pixmap, GCcursor, mask_image,
+							0, 0, 0, 0, w, h);
+	XFreeGC(SDL_Display, GCcursor);
+	/* These free the x_data and x_mask memory pointers */
+	XDestroyImage(data_image);
+	XDestroyImage(mask_image);
+
+	/* Create the cursor */
+	cursor->x_cursor = XCreatePixmapCursor(SDL_Display, data_pixmap,
+				mask_pixmap, &black, &white, hot_x, hot_y);
+
+	/* Release the event thread */
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+
+	return(cursor);
+}
+
+int X11_ShowWMCursor(_THIS, WMcursor *cursor)
+{
+	/* Don't do anything if the display is gone */
+	if ( SDL_Display == NULL ) {
+		return(0);
+	}
+
+	/* Set the X11 cursor cursor, or blank if cursor is NULL */
+	if ( SDL_Window ) {
+		SDL_Lock_EventThread();
+		if ( cursor == NULL ) {
+			if ( SDL_BlankCursor != NULL ) {
+				XDefineCursor(SDL_Display, SDL_Window,
+					SDL_BlankCursor->x_cursor);
+			}
+		} else {
+			XDefineCursor(SDL_Display, SDL_Window, cursor->x_cursor);
+		}
+		XSync(SDL_Display, False);
+		SDL_Unlock_EventThread();
+	}
+	return(1);
+}
+
+void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+	if ( using_dga & DGA_MOUSE ) {
+		x += (this->screen->offset % this->screen->pitch) /
+		      this->screen->format->BytesPerPixel;
+		y += (this->screen->offset / this->screen->pitch);
+		SDL_PrivateMouseMotion(0, 0, x, y);
+	} else {
+		SDL_Lock_EventThread();
+		XWarpPointer(SDL_Display, None, SDL_Window, 0, 0, 0, 0, x, y);
+		XSync(SDL_Display, False);
+		SDL_Unlock_EventThread();
+	}
+}
+
+/* Sets the mouse acceleration from a string of the form:
+	2/1/0
+   The first number is the numerator, followed by the acceleration
+   denumenator and threshold.
+*/
+static void SetMouseAccel(_THIS, const char *accel_param)
+{
+	int i;
+	int accel_value[3];
+	char *mouse_param, *mouse_param_buf, *pin;
+
+	mouse_param_buf = (char *)malloc(strlen(accel_param)+1);
+	if ( ! mouse_param_buf ) {
+		return;
+	}
+	strcpy(mouse_param_buf, accel_param);
+	mouse_param = mouse_param_buf;
+
+	for ( i=0; (i < 3) && mouse_param; ++i ) {
+		pin = strchr(mouse_param, '/');
+		if ( pin ) {
+			*pin = '\0';
+		}
+		accel_value[i] = atoi(mouse_param);
+		if ( pin ) {
+			mouse_param = pin+1;
+		} else {
+			mouse_param = NULL;
+		}
+	}
+	if ( mouse_param_buf ) {
+		XChangePointerControl(SDL_Display, True, True,
+			accel_value[0], accel_value[1], accel_value[2]);
+		free(mouse_param_buf);
+	}
+}
+
+/* Check to see if we need to enter or leave mouse relative mode */
+void X11_CheckMouseModeNoLock(_THIS)
+{
+	/* If the mouse is hidden and input is grabbed, we use relative mode */
+	if ( !(SDL_cursorstate & CURSOR_VISIBLE) &&
+	     (this->input_grab != SDL_GRAB_OFF) &&
+             (SDL_GetAppState() & SDL_APPACTIVE) ) {
+		if ( ! mouse_relative ) {
+			X11_EnableDGAMouse(this);
+			if ( ! (using_dga & DGA_MOUSE) ) {
+				char *xmouse_accel;
+
+				SDL_GetMouseState(&mouse_last.x, &mouse_last.y);
+				/* Use as raw mouse mickeys as possible */
+				XGetPointerControl(SDL_Display,
+						&mouse_accel.numerator, 
+						&mouse_accel.denominator,
+						&mouse_accel.threshold);
+				xmouse_accel=getenv("SDL_VIDEO_X11_MOUSEACCEL");
+				if ( xmouse_accel ) {
+					SetMouseAccel(this, xmouse_accel);
+				}
+			}
+			mouse_relative = 1;
+		}
+	} else {
+		if ( mouse_relative ) {
+			if ( using_dga & DGA_MOUSE ) {
+				X11_DisableDGAMouse(this);
+			} else {
+				XChangePointerControl(SDL_Display, True, True,
+						mouse_accel.numerator, 
+						mouse_accel.denominator,
+						mouse_accel.threshold);
+			}
+			mouse_relative = 0;
+		}
+	}
+}
+void X11_CheckMouseMode(_THIS)
+{
+	SDL_Lock_EventThread();
+	X11_CheckMouseModeNoLock(this);
+	SDL_Unlock_EventThread();
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11mouse_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_x11video.h"
+
+/* Functions to be exported */
+extern void X11_FreeWMCursor(_THIS, WMcursor *cursor);
+extern WMcursor *X11_CreateWMCursor(_THIS,
+		Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y);
+extern int X11_ShowWMCursor(_THIS, WMcursor *cursor);
+extern void X11_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+extern void X11_CheckMouseModeNoLock(_THIS);
+extern void X11_CheckMouseMode(_THIS);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11video.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1269 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* X11 based SDL video driver implementation.
+   Note:  This implementation does not currently need X11 thread locking,
+          since the event thread uses a separate X connection and any
+          additional locking necessary is handled internally.  However,
+          if full locking is neccessary, take a look at XInitThreads().
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/ioctl.h>
+#ifdef MTRR_SUPPORT
+#include <asm/mtrr.h>
+#include <sys/fcntl.h>
+#endif
+
+#ifdef HAVE_ALLOCA_H
+#include <alloca.h>
+#endif
+
+#ifdef HAVE_ALLOCA
+#define ALLOCA(n) ((void*)alloca(n))
+#define FREEA(p)
+#else
+#define ALLOCA(n) malloc(n)
+#define FREEA(p) free(p)
+#endif
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_thread.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_endian.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_x11video.h"
+#include "SDL_x11wm_c.h"
+#include "SDL_x11mouse_c.h"
+#include "SDL_x11events_c.h"
+#include "SDL_x11modes_c.h"
+#include "SDL_x11image_c.h"
+#include "SDL_x11yuv_c.h"
+#include "SDL_x11gl_c.h"
+#include "SDL_x11gamma_c.h"
+#include "blank_cursor.h"
+
+/* Initialization/Query functions */
+static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+static int X11_ToggleFullScreen(_THIS, int on);
+static void X11_UpdateMouse(_THIS);
+static int X11_SetColors(_THIS, int firstcolor, int ncolors,
+			 SDL_Color *colors);
+static int X11_SetGammaRamp(_THIS, Uint16 *ramp);
+static void X11_VideoQuit(_THIS);
+
+/* X11 driver bootstrap functions */
+
+static int X11_Available(void)
+{
+	Display *display;
+
+	display = XOpenDisplay(NULL);
+	if ( display != NULL ) {
+		XCloseDisplay(display);
+	}
+	return(display != NULL);
+}
+
+static void X11_DeleteDevice(SDL_VideoDevice *device)
+{
+	if ( device ) {
+		if ( device->hidden ) {
+			free(device->hidden);
+		}
+		if ( device->gl_data ) {
+			free(device->gl_data);
+		}
+		free(device);
+	}
+}
+
+static SDL_VideoDevice *X11_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *device;
+
+	/* Initialize all variables that we clean on shutdown */
+	device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( device ) {
+		memset(device, 0, (sizeof *device));
+		device->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *device->hidden));
+		device->gl_data = (struct SDL_PrivateGLData *)
+				malloc((sizeof *device->gl_data));
+	}
+	if ( (device == NULL) || (device->hidden == NULL) ||
+	                         (device->gl_data == NULL) ) {
+		SDL_OutOfMemory();
+		X11_DeleteDevice(device);
+		return(0);
+	}
+	memset(device->hidden, 0, (sizeof *device->hidden));
+	memset(device->gl_data, 0, (sizeof *device->gl_data));
+
+	/* Set the driver flags */
+	device->handles_any_size = 1;
+
+	/* Set the function pointers */
+	device->VideoInit = X11_VideoInit;
+	device->ListModes = X11_ListModes;
+	device->SetVideoMode = X11_SetVideoMode;
+	device->ToggleFullScreen = X11_ToggleFullScreen;
+	device->UpdateMouse = X11_UpdateMouse;
+#ifdef XFREE86_XV
+	device->CreateYUVOverlay = X11_CreateYUVOverlay;
+#endif
+	device->SetColors = X11_SetColors;
+	device->UpdateRects = NULL;
+	device->VideoQuit = X11_VideoQuit;
+	device->AllocHWSurface = X11_AllocHWSurface;
+	device->CheckHWBlit = NULL;
+	device->FillHWRect = NULL;
+	device->SetHWColorKey = NULL;
+	device->SetHWAlpha = NULL;
+	device->LockHWSurface = X11_LockHWSurface;
+	device->UnlockHWSurface = X11_UnlockHWSurface;
+	device->FlipHWSurface = X11_FlipHWSurface;
+	device->FreeHWSurface = X11_FreeHWSurface;
+	device->SetGamma = X11_SetVidModeGamma;
+	device->GetGamma = X11_GetVidModeGamma;
+	device->SetGammaRamp = X11_SetGammaRamp;
+	device->GetGammaRamp = NULL;
+#ifdef HAVE_OPENGL
+	device->GL_LoadLibrary = X11_GL_LoadLibrary;
+	device->GL_GetProcAddress = X11_GL_GetProcAddress;
+	device->GL_GetAttribute = X11_GL_GetAttribute;
+	device->GL_MakeCurrent = X11_GL_MakeCurrent;
+	device->GL_SwapBuffers = X11_GL_SwapBuffers;
+#endif
+	device->SetCaption = X11_SetCaption;
+	device->SetIcon = X11_SetIcon;
+	device->IconifyWindow = X11_IconifyWindow;
+	device->GrabInput = X11_GrabInput;
+	device->GetWMInfo = X11_GetWMInfo;
+	device->FreeWMCursor = X11_FreeWMCursor;
+	device->CreateWMCursor = X11_CreateWMCursor;
+	device->ShowWMCursor = X11_ShowWMCursor;
+	device->WarpWMCursor = X11_WarpWMCursor;
+	device->CheckMouseMode = X11_CheckMouseMode;
+	device->InitOSKeymap = X11_InitOSKeymap;
+	device->PumpEvents = X11_PumpEvents;
+
+	device->free = X11_DeleteDevice;
+
+	return device;
+}
+
+VideoBootStrap X11_bootstrap = {
+	"x11", "X Window System",
+	X11_Available, X11_CreateDevice
+};
+
+/* Shared memory information */
+extern int XShmQueryExtension(Display *dpy);	/* Not in X11 headers */
+
+/* Normal X11 error handler routine */
+static int (*X_handler)(Display *, XErrorEvent *) = NULL;
+static int x_errhandler(Display *d, XErrorEvent *e)
+{
+#ifdef XFREE86_VM
+	extern int vm_error;
+#endif
+#ifdef XFREE86_DGAMOUSE
+	extern int dga_error;
+#endif
+
+#ifdef XFREE86_VM
+	/* VidMode errors are non-fatal. :) */
+	/* Are the errors offset by one from the error base?
+	   e.g. the error base is 143, the code is 148, and the
+	        actual error is XF86VidModeExtensionDisabled (4) ?
+	 */
+        if ( (vm_error >= 0) &&
+	     (((e->error_code == BadRequest)&&(e->request_code == vm_error)) ||
+	      ((e->error_code > vm_error) &&
+	       (e->error_code <= (vm_error+XF86VidModeNumberErrors)))) ) {
+#ifdef XFREE86_DEBUG
+{ char errmsg[1024];
+  XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
+printf("VidMode error: %s\n", errmsg);
+}
+#endif
+        	return(0);
+        }
+#endif /* XFREE86_VM */
+
+#ifdef XFREE86_DGAMOUSE
+	/* DGA errors can be non-fatal. :) */
+        if ( (dga_error >= 0) &&
+	     ((e->error_code > dga_error) &&
+	      (e->error_code <= (dga_error+XF86DGANumberErrors))) ) {
+#ifdef XFREE86_DEBUG
+{ char errmsg[1024];
+  XGetErrorText(d, e->error_code, errmsg, sizeof(errmsg));
+printf("DGA error: %s\n", errmsg);
+}
+#endif
+        	return(0);
+        }
+#endif /* XFREE86_DGAMOUSE */
+
+	return(X_handler(d,e));
+}
+
+/* X11 I/O error handler routine */
+static int (*XIO_handler)(Display *) = NULL;
+static int xio_errhandler(Display *d)
+{
+	/* Ack!  Lost X11 connection! */
+
+	/* We will crash if we try to clean up our display */
+	if ( current_video->hidden->Ximage ) {
+		SDL_VideoSurface->pixels = NULL;
+	}
+	current_video->hidden->X11_Display = NULL;
+
+	/* Continue with the standard X11 error handler */
+	return(XIO_handler(d));
+}
+
+/* Create auxiliary (toplevel) windows with the current visual */
+static void create_aux_windows(_THIS)
+{
+    XSetWindowAttributes xattr;
+    XWMHints *hints;
+    XTextProperty titleprop, iconprop;
+    int def_vis = (SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen));
+
+    /* Don't create any extra windows if we are being managed */
+    if ( SDL_windowid ) {
+	FSwindow = 0;
+	WMwindow = strtol(SDL_windowid, NULL, 0);
+        return;
+    }
+
+    if(FSwindow)
+	XDestroyWindow(SDL_Display, FSwindow);
+
+    xattr.override_redirect = True;
+    xattr.background_pixel = def_vis ? BlackPixel(SDL_Display, SDL_Screen) : 0;
+    xattr.border_pixel = 0;
+    xattr.colormap = SDL_XColorMap;
+
+    FSwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
+			     this->hidden->depth, InputOutput, SDL_Visual,
+			     CWOverrideRedirect | CWBackPixel | CWBorderPixel
+			     | CWColormap,
+			     &xattr);
+
+    XSelectInput(SDL_Display, FSwindow, StructureNotifyMask);
+
+    /* Tell KDE to keep the fullscreen window on top */
+    {
+	XEvent ev;
+	long mask;
+
+	memset(&ev, 0, sizeof(ev));
+	ev.xclient.type = ClientMessage;
+	ev.xclient.window = SDL_Root;
+	ev.xclient.message_type = XInternAtom(SDL_Display,
+					      "KWM_KEEP_ON_TOP", False);
+	ev.xclient.format = 32;
+	ev.xclient.data.l[0] = FSwindow;
+	ev.xclient.data.l[1] = CurrentTime;
+	mask = SubstructureRedirectMask;
+	XSendEvent(SDL_Display, SDL_Root, False, mask, &ev);
+    }
+
+    hints = NULL;
+    titleprop.value = iconprop.value = NULL;
+    if(WMwindow) {
+	/* All window attributes must survive the recreation */
+	hints = XGetWMHints(SDL_Display, WMwindow);
+	XGetWMName(SDL_Display, WMwindow, &titleprop);
+	XGetWMIconName(SDL_Display, WMwindow, &iconprop);
+	XDestroyWindow(SDL_Display, WMwindow);
+    }
+
+    /* Create the window for windowed management */
+    /* (reusing the xattr structure above) */
+    WMwindow = XCreateWindow(SDL_Display, SDL_Root, 0, 0, 32, 32, 0,
+			     this->hidden->depth, InputOutput, SDL_Visual,
+			     CWBackPixel | CWBorderPixel | CWColormap,
+			     &xattr);
+
+    /* Set the input hints so we get keyboard input */
+    if(!hints) {
+	hints = XAllocWMHints();
+	hints->input = True;
+	hints->flags = InputHint;
+    }
+    XSetWMHints(SDL_Display, WMwindow, hints);
+    XFree(hints);
+    if(titleprop.value) {
+	XSetWMName(SDL_Display, WMwindow, &titleprop);
+	XFree(titleprop.value);
+    }
+    if(iconprop.value) {
+	XSetWMIconName(SDL_Display, WMwindow, &iconprop);
+	XFree(iconprop.value);
+    }
+
+    XSelectInput(SDL_Display, WMwindow,
+		 FocusChangeMask | KeyPressMask | KeyReleaseMask
+		 | PropertyChangeMask | StructureNotifyMask | KeymapStateMask);
+
+    /* Set the class hints so we can get an icon (AfterStep) */
+    {
+	XClassHint *classhints;
+	classhints = XAllocClassHint();
+	if(classhints != NULL) {
+	    classhints->res_name = "SDL_App";
+	    classhints->res_class = "SDL_App";
+	    XSetClassHint(SDL_Display, WMwindow, classhints);
+	    XFree(classhints);
+	}
+    }
+
+    /* Allow the window to be deleted by the window manager */
+    WM_DELETE_WINDOW = XInternAtom(SDL_Display, "WM_DELETE_WINDOW", False);
+    XSetWMProtocols(SDL_Display, WMwindow, &WM_DELETE_WINDOW, 1);
+}
+
+static int X11_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	char *display;
+	int i;
+
+	/* Open the X11 display */
+	display = NULL;		/* Get it from DISPLAY environment variable */
+
+	if ( (strncmp(XDisplayName(display), ":", 1) == 0) ||
+	     (strncmp(XDisplayName(display), "unix:", 5) == 0) ) {
+		local_X11 = 1;
+	} else {
+		local_X11 = 0;
+	}
+	SDL_Display = XOpenDisplay(display);
+	if ( SDL_Display == NULL ) {
+		SDL_SetError("Couldn't open X11 display");
+		return(-1);
+	}
+#ifdef X11_DEBUG
+	XSynchronize(SDL_Display, True);
+#endif
+
+	/* Create an alternate X display for graphics updates -- allows us
+	   to do graphics updates in a separate thread from event handling.
+	   Thread-safe X11 doesn't seem to exist.
+	 */
+	GFX_Display = XOpenDisplay(display);
+	if ( GFX_Display == NULL ) {
+		SDL_SetError("Couldn't open X11 display");
+		return(-1);
+	}
+
+	/* Set the normal X error handler */
+	X_handler = XSetErrorHandler(x_errhandler);
+
+	/* Set the error handler if we lose the X display */
+	XIO_handler = XSetIOErrorHandler(xio_errhandler);
+
+	/* use default screen (from $DISPLAY) */
+	SDL_Screen = DefaultScreen(SDL_Display);
+
+#ifndef NO_SHARED_MEMORY
+	/* Check for MIT shared memory extension */
+	use_mitshm = 0;
+	if ( local_X11 ) {
+		use_mitshm = XShmQueryExtension(SDL_Display);
+	}
+#endif /* NO_SHARED_MEMORY */
+
+	/* See whether or not we need to swap pixels */
+	swap_pixels = 0;
+	if ( SDL_BYTEORDER == SDL_LIL_ENDIAN ) {
+		if ( XImageByteOrder(SDL_Display) == MSBFirst ) {
+			swap_pixels = 1;
+		}
+	} else {
+		if ( XImageByteOrder(SDL_Display) == LSBFirst ) {
+			swap_pixels = 1;
+		}
+	}
+
+	/* Get the available video modes */
+	if(X11_GetVideoModes(this) < 0)
+	    return -1;
+
+	/* Determine the default screen depth:
+	   Use the default visual (or at least one with the same depth) */
+	SDL_DisplayColormap = DefaultColormap(SDL_Display, SDL_Screen);
+	for(i = 0; i < this->hidden->nvisuals; i++)
+	    if(this->hidden->visuals[i].depth == DefaultDepth(SDL_Display,
+							      SDL_Screen))
+		break;
+	if(i == this->hidden->nvisuals) {
+	    /* default visual was useless, take the deepest one instead */
+	    i = 0;
+	}
+	SDL_Visual = this->hidden->visuals[i].visual;
+	if ( SDL_Visual == DefaultVisual(SDL_Display, SDL_Screen) ) {
+	    SDL_XColorMap = SDL_DisplayColormap;
+	} else {
+	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
+					    SDL_Visual, AllocNone);
+	}
+	this->hidden->depth = this->hidden->visuals[i].depth;
+	vformat->BitsPerPixel = this->hidden->visuals[i].bpp;
+	if ( vformat->BitsPerPixel > 8 ) {
+		vformat->Rmask = SDL_Visual->red_mask;
+	  	vformat->Gmask = SDL_Visual->green_mask;
+	  	vformat->Bmask = SDL_Visual->blue_mask;
+	}
+	X11_SaveVidModeGamma(this);
+
+	/* See if we have been passed a window to use */
+	SDL_windowid = getenv("SDL_WINDOWID");
+
+	/* Create the fullscreen and managed windows */
+	create_aux_windows(this);
+
+	/* Create the blank cursor */
+	SDL_BlankCursor = this->CreateWMCursor(this, blank_cdata, blank_cmask,
+					BLANK_CWIDTH, BLANK_CHEIGHT,
+						BLANK_CHOTX, BLANK_CHOTY);
+
+	/* Fill in some window manager capabilities */
+	this->info.wm_available = 1;
+
+	/* We're done! */
+	XFlush(SDL_Display);
+	return(0);
+}
+
+static void X11_DestroyWindow(_THIS, SDL_Surface *screen)
+{
+	/* Clean up OpenGL */
+	if ( screen ) {
+		screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT);
+	}
+	X11_GL_Shutdown(this);
+
+	if ( ! SDL_windowid ) {
+		/* Hide the managed window */
+		if ( WMwindow ) {
+			XUnmapWindow(SDL_Display, WMwindow);
+		}
+		if ( screen && (screen->flags & SDL_FULLSCREEN) ) {
+			screen->flags &= ~SDL_FULLSCREEN;
+			X11_LeaveFullScreen(this);
+		}
+
+		/* Destroy the output window */
+		if ( SDL_Window ) {
+			XDestroyWindow(SDL_Display, SDL_Window);
+		}
+
+		/* Free the colormap entries */
+		if ( SDL_XPixels ) {
+			int numcolors;
+			unsigned long pixel;
+
+			numcolors = SDL_Visual->map_entries;
+			for ( pixel=0; pixel<numcolors; ++pixel ) {
+				while ( SDL_XPixels[pixel] > 0 ) {
+					XFreeColors(GFX_Display,
+						SDL_DisplayColormap,&pixel,1,0);
+					--SDL_XPixels[pixel];
+				}
+			}
+			free(SDL_XPixels);
+			SDL_XPixels = NULL;
+		} 
+
+		/* Free the graphics context */
+		if ( SDL_GC ) {
+			XFreeGC(SDL_Display, SDL_GC);
+			SDL_GC = 0;
+		}
+	}
+}
+
+static void X11_SetSizeHints(_THIS, int w, int h, Uint32 flags)
+{
+	XSizeHints *hints;
+
+	hints = XAllocSizeHints();
+	if ( hints ) {
+		if ( flags & SDL_RESIZABLE ) {
+			hints->min_width = 32;
+			hints->min_height = 32;
+			hints->max_height = 4096;
+			hints->max_width = 4096;
+		} else {
+			hints->min_width = hints->max_width = w;
+			hints->min_height = hints->max_height = h;
+		}
+		hints->flags = PMaxSize | PMinSize;
+		if ( flags & SDL_FULLSCREEN ) {
+			hints->x = 0;
+			hints->y = 0;
+			hints->flags |= USPosition;
+		} else
+		/* Center it, if desired */
+		if ( getenv("SDL_VIDEO_CENTERED") ) {
+			int display_w, display_h;
+
+			display_w = DisplayWidth(SDL_Display, SDL_Screen);
+			display_h = DisplayHeight(SDL_Display, SDL_Screen);
+			hints->x = (display_w - w)/2;
+			hints->y = (display_h - h)/2;
+			hints->flags |= USPosition;
+			XMoveWindow(SDL_Display, WMwindow, hints->x, hints->y);
+
+			/* Flush the resize event so we don't catch it later */
+			XSync(SDL_Display, True);
+		}
+		XSetWMNormalHints(SDL_Display, WMwindow, hints);
+		XFree(hints);
+	}
+
+	/* Respect the window caption style */
+	if ( flags & SDL_NOFRAME ) {
+		SDL_bool set;
+		Atom WM_HINTS;
+
+		/* We haven't modified the window manager hints yet */
+		set = SDL_FALSE;
+
+		/* First try to set MWM hints */
+		WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
+		if ( WM_HINTS != None ) {
+			/* Hints used by Motif compliant window managers */
+			struct {
+				unsigned long flags;
+				unsigned long functions;
+				unsigned long decorations;
+				long input_mode;
+				unsigned long status;
+			} MWMHints = { (1L << 1), 0, 0, 0, 0 };
+
+			XChangeProperty(SDL_Display, WMwindow,
+			                WM_HINTS, WM_HINTS, 32,
+			                PropModeReplace,
+					(unsigned char *)&MWMHints,
+					sizeof(MWMHints)/sizeof(long));
+			set = SDL_TRUE;
+		}
+		/* Now try to set KWM hints */
+		WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
+		if ( WM_HINTS != None ) {
+			long KWMHints = 0;
+
+			XChangeProperty(SDL_Display, WMwindow,
+			                WM_HINTS, WM_HINTS, 32,
+			                PropModeReplace,
+					(unsigned char *)&KWMHints,
+					sizeof(KWMHints)/sizeof(long));
+			set = SDL_TRUE;
+		}
+		/* Now try to set GNOME hints */
+		WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True);
+		if ( WM_HINTS != None ) {
+			long GNOMEHints = 0;
+
+			XChangeProperty(SDL_Display, WMwindow,
+			                WM_HINTS, WM_HINTS, 32,
+			                PropModeReplace,
+					(unsigned char *)&GNOMEHints,
+					sizeof(GNOMEHints)/sizeof(long));
+			set = SDL_TRUE;
+		}
+		/* Finally set the transient hints if necessary */
+		if ( ! set ) {
+			XSetTransientForHint(SDL_Display, WMwindow, SDL_Root);
+		}
+	} else {
+		SDL_bool set;
+		Atom WM_HINTS;
+
+		/* We haven't modified the window manager hints yet */
+		set = SDL_FALSE;
+
+		/* First try to unset MWM hints */
+		WM_HINTS = XInternAtom(SDL_Display, "_MOTIF_WM_HINTS", True);
+		if ( WM_HINTS != None ) {
+			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
+			set = SDL_TRUE;
+		}
+		/* Now try to unset KWM hints */
+		WM_HINTS = XInternAtom(SDL_Display, "KWM_WIN_DECORATION", True);
+		if ( WM_HINTS != None ) {
+			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
+			set = SDL_TRUE;
+		}
+		/* Now try to unset GNOME hints */
+		WM_HINTS = XInternAtom(SDL_Display, "_WIN_HINTS", True);
+		if ( WM_HINTS != None ) {
+			XDeleteProperty(SDL_Display, WMwindow, WM_HINTS);
+			set = SDL_TRUE;
+		}
+		/* Finally unset the transient hints if necessary */
+		if ( ! set ) {
+			/* NOTE: Does this work? */
+			XSetTransientForHint(SDL_Display, WMwindow, None);
+		}
+	}
+}
+
+static int X11_CreateWindow(_THIS, SDL_Surface *screen,
+			    int w, int h, int bpp, Uint32 flags)
+{
+	int i, depth;
+	Visual *vis;
+	int vis_change;
+
+	/* If a window is already present, destroy it and start fresh */
+	if ( SDL_Window ) {
+		X11_DestroyWindow(this, screen);
+	}
+
+	/* See if we have been given a window id */
+	if ( SDL_windowid ) {
+		SDL_Window = strtol(SDL_windowid, NULL, 0);
+	} else {
+		SDL_Window = 0;
+	}
+
+	/* find out which visual we are going to use */
+	if ( flags & SDL_OPENGL ) {
+		XVisualInfo *vi;
+
+		vi = X11_GL_GetVisual(this);
+		if( !vi ) {
+			return -1;
+		}
+		vis = vi->visual;
+		depth = vi->depth;
+	} else if ( SDL_windowid ) {
+		XWindowAttributes a;
+
+		XGetWindowAttributes(SDL_Display, SDL_Window, &a);
+		vis = a.visual;
+		depth = a.depth;
+	} else {
+		for ( i = 0; i < this->hidden->nvisuals; i++ ) {
+			if ( this->hidden->visuals[i].bpp == bpp )
+				break;
+		}
+		if ( i == this->hidden->nvisuals ) {
+			SDL_SetError("No matching visual for requested depth");
+			return -1;	/* should never happen */
+		}
+		vis = this->hidden->visuals[i].visual;
+		depth = this->hidden->visuals[i].depth;
+	}
+#ifdef X11_DEBUG
+        printf("Choosing %s visual at %d bpp - %d colormap entries\n", vis->class == PseudoColor ? "PseudoColor" : (vis->class == TrueColor ? "TrueColor" : (vis->class == DirectColor ? "DirectColor" : "Unknown")), depth, vis->map_entries);
+#endif
+	vis_change = (vis != SDL_Visual);
+	SDL_Visual = vis;
+	this->hidden->depth = depth;
+
+	/* Allocate the new pixel format for this video mode */
+	if ( ! SDL_ReallocFormat(screen, bpp,
+			vis->red_mask, vis->green_mask, vis->blue_mask, 0) )
+		return -1;
+
+	/* Create the appropriate colormap */
+	if ( SDL_XColorMap != SDL_DisplayColormap ) {
+		XFreeColormap(SDL_Display, SDL_XColorMap);
+	}
+	if ( SDL_Visual->class == PseudoColor ) {
+	    int ncolors;
+
+	    /* Allocate the pixel flags */
+	    ncolors = SDL_Visual->map_entries;
+	    SDL_XPixels = malloc(ncolors * sizeof(int));
+	    if(SDL_XPixels == NULL) {
+		SDL_OutOfMemory();
+		return -1;
+	    }
+	    memset(SDL_XPixels, 0, ncolors * sizeof(*SDL_XPixels));
+
+	    /* always allocate a private colormap on non-default visuals */
+	    if ( SDL_Visual != DefaultVisual(SDL_Display, SDL_Screen) ) {
+		flags |= SDL_HWPALETTE;
+	    }
+	    if ( flags & SDL_HWPALETTE ) {
+		screen->flags |= SDL_HWPALETTE;
+		SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
+		                                SDL_Visual, AllocAll);
+	    } else {
+		SDL_XColorMap = SDL_DisplayColormap;
+	    }
+	} else if ( SDL_Visual->class == DirectColor ) {
+
+	    /* Create a colormap which we can manipulate for gamma */
+	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
+		                            SDL_Visual, AllocAll);
+            XSync(SDL_Display, False);
+
+	    /* Initialize the colormap to the identity mapping */
+	    SDL_GetGammaRamp(0, 0, 0);
+	    this->screen = screen;
+	    X11_SetGammaRamp(this, this->gamma);
+	    this->screen = NULL;
+	} else {
+	    /* Create a read-only colormap for our window */
+	    SDL_XColorMap = XCreateColormap(SDL_Display, SDL_Root,
+	                                    SDL_Visual, AllocNone);
+	}
+
+	/* Recreate the auxiliary windows, if needed (required for GL) */
+	if ( vis_change )
+	    create_aux_windows(this);
+
+	if(screen->flags & SDL_HWPALETTE) {
+	    /* Since the full-screen window might have got a nonzero background
+	       colour (0 is white on some displays), we should reset the
+	       background to 0 here since that is what the user expects
+	       with a private colormap */
+	    XSetWindowBackground(SDL_Display, FSwindow, 0);
+	    XClearWindow(SDL_Display, FSwindow);
+	}
+
+	/* resize the (possibly new) window manager window */
+	if( !SDL_windowid ) {
+	        X11_SetSizeHints(this, w, h, flags);
+		current_w = w;
+		current_h = h;
+		XResizeWindow(SDL_Display, WMwindow, w, h);
+	}
+
+	/* Create (or use) the X11 display window */
+	if ( !SDL_windowid ) {
+		if ( flags & SDL_OPENGL ) {
+			if ( X11_GL_CreateWindow(this, w, h) < 0 ) {
+				return(-1);
+			}
+		} else {
+			XSetWindowAttributes swa;
+
+			swa.background_pixel = 0;
+			swa.border_pixel = 0;
+			swa.colormap = SDL_XColorMap;
+			SDL_Window = XCreateWindow(SDL_Display, WMwindow,
+		                           	0, 0, w, h, 0, depth,
+		                           	InputOutput, SDL_Visual,
+		                           	CWBackPixel | CWBorderPixel
+		                           	| CWColormap, &swa);
+		}
+		/* Only manage our input if we own the window */
+		XSelectInput(SDL_Display, SDL_Window,
+					( EnterWindowMask | LeaveWindowMask
+					| ButtonPressMask | ButtonReleaseMask
+					| PointerMotionMask | ExposureMask ));
+	}
+
+	/* Create the graphics context here, once we have a window */
+	if ( flags & SDL_OPENGL ) {
+		if ( X11_GL_CreateContext(this) < 0 ) {
+			return(-1);
+		} else {
+			screen->flags |= SDL_OPENGL;
+		}
+	} else {
+		XGCValues gcv;
+
+		gcv.graphics_exposures = False;
+		SDL_GC = XCreateGC(SDL_Display, SDL_Window,
+		                   GCGraphicsExposures, &gcv);
+		if ( ! SDL_GC ) {
+			SDL_SetError("Couldn't create graphics context");
+			return(-1);
+		}
+	}
+
+	/* Set our colormaps when not setting a GL mode */
+	if ( ! (flags & SDL_OPENGL) ) {
+		XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap);
+		if( !SDL_windowid ) {
+		    XSetWindowColormap(SDL_Display, FSwindow, SDL_XColorMap);
+		    XSetWindowColormap(SDL_Display, WMwindow, SDL_XColorMap);
+		}
+	}
+
+#if 0 /* This is an experiment - are the graphics faster now? - nope. */
+	if ( getenv("SDL_VIDEO_X11_BACKINGSTORE") )
+#endif
+	/* Cache the window in the server, when possible */
+	{
+		Screen *xscreen;
+		XSetWindowAttributes a;
+
+		xscreen = ScreenOfDisplay(SDL_Display, SDL_Screen);
+		a.backing_store = DoesBackingStore(xscreen);
+		if ( a.backing_store != NotUseful ) {
+			XChangeWindowAttributes(SDL_Display, SDL_Window,
+			                        CWBackingStore, &a);
+		}
+	}
+
+	/* Update the internal keyboard state */
+	X11_SetKeyboardState(SDL_Display, NULL);
+
+	/* Map them both and go fullscreen, if requested */
+	if ( ! SDL_windowid ) {
+		XMapWindow(SDL_Display, SDL_Window);
+		XMapWindow(SDL_Display, WMwindow);
+		if ( flags & SDL_FULLSCREEN ) {
+			screen->flags |= SDL_FULLSCREEN;
+			X11_WaitMapped(this, WMwindow);
+#ifdef GRAB_FULLSCREEN
+			X11_EnterFullScreen(this);
+#else
+			X11_QueueEnterFullScreen(this);
+#endif
+		} else {
+			screen->flags &= ~SDL_FULLSCREEN;
+		}
+	}
+	return(0);
+}
+
+static int X11_ResizeWindow(_THIS,
+			SDL_Surface *screen, int w, int h, Uint32 flags)
+{
+	if ( ! SDL_windowid ) {
+		/* Resize the window manager window */
+		X11_SetSizeHints(this, w, h, flags);
+		current_w = w;
+		current_h = h;
+		XResizeWindow(SDL_Display, WMwindow, w, h);
+
+		/* Resize the fullscreen and display windows */
+		if ( flags & SDL_FULLSCREEN ) {
+			if ( screen->flags & SDL_FULLSCREEN ) {
+				X11_ResizeFullScreen(this);
+			} else {
+				screen->flags |= SDL_FULLSCREEN;
+#ifdef GRAB_FULLSCREEN
+				X11_EnterFullScreen(this);
+#else
+				X11_QueueEnterFullScreen(this);
+#endif
+			}
+		} else {
+			if ( screen->flags & SDL_FULLSCREEN ) {
+				screen->flags &= ~SDL_FULLSCREEN;
+				X11_LeaveFullScreen(this);
+			}
+		}
+		XResizeWindow(SDL_Display, SDL_Window, w, h);
+	}
+	return(0);
+}
+
+SDL_Surface *X11_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	Uint32 saved_flags;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	/* Check the combination of flags we were passed */
+	if ( flags & SDL_FULLSCREEN ) {
+		/* Clear fullscreen flag if not supported */
+		if ( SDL_windowid ) {
+			flags &= ~SDL_FULLSCREEN;
+		}
+	}
+
+	/* Flush any delayed updates */
+	XSync(GFX_Display, False);
+
+	/* Set up the X11 window */
+	saved_flags = current->flags;
+	if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL)
+	    && bpp == current->format->BitsPerPixel) {
+		if (X11_ResizeWindow(this, current, width, height, flags) < 0) {
+			current = NULL;
+			goto done;
+		}
+	} else {
+		if (X11_CreateWindow(this,current,width,height,bpp,flags) < 0) {
+			current = NULL;
+			goto done;
+		}
+	}
+
+	/* Set up the new mode framebuffer */
+	if ( ((current->w != width) || (current->h != height)) ||
+             ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) {
+		current->w = width;
+		current->h = height;
+		current->pitch = SDL_CalculatePitch(current);
+		X11_ResizeImage(this, current, flags);
+	}
+	current->flags |= (flags&(SDL_RESIZABLE|SDL_NOFRAME));
+
+  done:
+	/* Release the event thread */
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+
+	/* We're done! */
+	return(current);
+}
+
+static int X11_ToggleFullScreen(_THIS, int on)
+{
+	Uint32 event_thread;
+
+	/* Don't switch if we don't own the window */
+	if ( SDL_windowid ) {
+		return(0);
+	}
+
+	/* Don't lock if we are the event thread */
+	event_thread = SDL_EventThreadID();
+	if ( event_thread && (SDL_ThreadID() == event_thread) ) {
+		event_thread = 0;
+	}
+	if ( event_thread ) {
+		SDL_Lock_EventThread();
+	}
+	if ( on ) {
+#ifdef GRAB_FULLSCREEN
+		this->screen->flags |= SDL_FULLSCREEN;
+		X11_EnterFullScreen(this);
+#else
+		X11_QueueEnterFullScreen(this);
+#endif
+	} else {
+		this->screen->flags &= ~SDL_FULLSCREEN;
+		X11_LeaveFullScreen(this);
+	}
+	X11_RefreshDisplay(this);
+	if ( event_thread ) {
+		SDL_Unlock_EventThread();
+	}
+	SDL_ResetKeyboard();
+	return(1);
+}
+
+/* Update the current mouse state and position */
+static void X11_UpdateMouse(_THIS)
+{
+	Window u1; int u2;
+	Window current_win;
+	int x, y;
+	unsigned int mask;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+	if ( XQueryPointer(SDL_Display, SDL_Window, &u1, &current_win,
+	                   &u2, &u2, &x, &y, &mask) ) {
+		if ( (x >= 0) && (x < SDL_VideoSurface->w) &&
+		     (y >= 0) && (y < SDL_VideoSurface->h) ) {
+			SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
+			SDL_PrivateMouseMotion(0, 0, x, y);
+		} else {
+			SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
+		}
+	}
+	SDL_Unlock_EventThread();
+}
+
+/* simple colour distance metric. Supposed to be better than a plain
+   Euclidian distance anyway. */
+#define COLOUR_FACTOR 3
+#define LIGHT_FACTOR 1
+#define COLOUR_DIST(r1, g1, b1, r2, g2, b2)				\
+	(COLOUR_FACTOR * (abs(r1 - r2) + abs(g1 - g2) + abs(b1 - b2))	\
+	 + LIGHT_FACTOR * abs(r1 + g1 + b1 - (r2 + g2 + b2)))
+
+static void allocate_nearest(_THIS, SDL_Color *colors,
+			     SDL_Color *want, int nwant)
+{
+	/*
+	 * There is no way to know which ones to choose from, so we retrieve
+	 * the entire colormap and try the nearest possible, until we find one
+	 * that is shared.
+	 */
+	XColor all[256];
+	int i;
+	for(i = 0; i < 256; i++)
+		all[i].pixel = i;
+	/* 
+	 * XQueryColors sets the flags in the XColor struct, so we use
+	 * that to keep track of which colours are available
+	 */
+	XQueryColors(GFX_Display, SDL_XColorMap, all, 256);
+
+	for(i = 0; i < nwant; i++) {
+		XColor *c;
+		int j;
+		int best = 0;
+		int mindist = 0x7fffffff;
+		int ri = want[i].r;
+		int gi = want[i].g;
+		int bi = want[i].b;
+		for(j = 0; j < 256; j++) {
+			int rj, gj, bj, d2;
+			if(!all[j].flags)
+				continue;	/* unavailable colour cell */
+			rj = all[j].red >> 8;
+			gj = all[j].green >> 8;
+			bj = all[j].blue >> 8;
+			d2 = COLOUR_DIST(ri, gi, bi, rj, gj, bj);
+			if(d2 < mindist) {
+				mindist = d2;
+				best = j;
+			}
+		}
+		if(SDL_XPixels[best])
+			continue; /* already allocated, waste no more time */
+		c = all + best;
+		if(XAllocColor(GFX_Display, SDL_XColorMap, c)) {
+			/* got it */
+			colors[best].r = c->red >> 8;
+			colors[best].g = c->green >> 8;
+			colors[best].b = c->blue >> 8;
+			++SDL_XPixels[best];
+		} else {
+			/* 
+			 * The colour couldn't be allocated, probably being
+			 * owned as a r/w cell by another client. Flag it as
+			 * unavailable and try again. The termination of the
+			 * loop is guaranteed since at least black and white
+			 * are always there.
+			 */
+			c->flags = 0;
+			i--;
+		}
+	}
+}
+
+int X11_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int nrej = 0;
+
+	/* Check to make sure we have a colormap allocated */
+	if ( SDL_XPixels == NULL ) {
+		return(0);
+	}
+	if ( (this->screen->flags & SDL_HWPALETTE) == SDL_HWPALETTE ) {
+	        /* private writable colormap: just set the colours we need */
+	        XColor  *xcmap;
+		int i;
+	        xcmap = ALLOCA(ncolors*sizeof(*xcmap));
+		if(xcmap == NULL)
+		        return 0;
+		for ( i=0; i<ncolors; ++i ) {
+			xcmap[i].pixel = i + firstcolor;
+			xcmap[i].red   = (colors[i].r<<8)|colors[i].r;
+			xcmap[i].green = (colors[i].g<<8)|colors[i].g;
+			xcmap[i].blue  = (colors[i].b<<8)|colors[i].b;
+			xcmap[i].flags = (DoRed|DoGreen|DoBlue);
+		}
+		XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
+		XSync(GFX_Display, False);
+		FREEA(xcmap);
+	} else {
+	        /*
+		 * Shared colormap: We only allocate read-only cells, which
+		 * increases the likelyhood of colour sharing with other
+		 * clients. The pixel values will almost certainly be
+		 * different from the requested ones, so the user has to
+		 * walk the colormap and see which index got what colour.
+		 *
+		 * We can work directly with the logical palette since it
+		 * has already been set when we get here.
+		 */
+		SDL_Color *want, *reject;
+	        unsigned long *freelist;
+		int i;
+		int nfree = 0;
+		int nc = this->screen->format->palette->ncolors;
+	        colors = this->screen->format->palette->colors;
+		freelist = ALLOCA(nc * sizeof(*freelist));
+		/* make sure multiple allocations of the same cell are freed */
+	        for(i = 0; i < ncolors; i++) {
+		        int pixel = firstcolor + i;
+		        while(SDL_XPixels[pixel]) {
+			        freelist[nfree++] = pixel;
+				--SDL_XPixels[pixel];
+			}
+		}
+		XFreeColors(GFX_Display, SDL_XColorMap, freelist, nfree, 0);
+		FREEA(freelist);
+
+		want = ALLOCA(ncolors * sizeof(SDL_Color));
+		reject = ALLOCA(ncolors * sizeof(SDL_Color));
+		memcpy(want, colors + firstcolor, ncolors * sizeof(SDL_Color));
+		/* make sure the user isn't fooled by her own wishes
+		   (black is safe, always available in the default colormap) */
+		memset(colors + firstcolor, 0, ncolors * sizeof(SDL_Color));
+
+		/* now try to allocate the colours */
+		for(i = 0; i < ncolors; i++) {
+		        XColor col;
+			col.red = want[i].r << 8;
+			col.green = want[i].g << 8;
+			col.blue = want[i].b << 8;
+			col.flags = DoRed | DoGreen | DoBlue;
+			if(XAllocColor(GFX_Display, SDL_XColorMap, &col)) {
+			        /* We got the colour, or at least the nearest
+				   the hardware could get. */
+			        colors[col.pixel].r = col.red >> 8;
+				colors[col.pixel].g = col.green >> 8;
+				colors[col.pixel].b = col.blue >> 8;
+				++SDL_XPixels[col.pixel];
+			} else {
+				/*
+				 * no more free cells, add it to the list
+				 * of rejected colours
+				 */
+				reject[nrej++] = want[i];
+			}
+		}
+		if(nrej)
+			allocate_nearest(this, colors, reject, nrej);
+		FREEA(reject);
+		FREEA(want);
+	}
+	return nrej == 0;
+}
+
+int X11_SetGammaRamp(_THIS, Uint16 *ramp)
+{
+	int i, ncolors;
+	XColor xcmap[256];
+
+	/* See if actually setting the gamma is supported */
+	if ( SDL_Visual->class != DirectColor ) {
+	    SDL_SetError("Gamma correction not supported on this visual");
+	    return(-1);
+	}
+
+	/* Calculate the appropriate palette for the given gamma ramp */
+	ncolors = SDL_Visual->map_entries;
+	for ( i=0; i<ncolors; ++i ) {
+		Uint8 c = (256 * i / ncolors);
+		xcmap[i].pixel = SDL_MapRGB(this->screen->format, c, c, c);
+		xcmap[i].red   = ramp[0*256+c];
+		xcmap[i].green = ramp[1*256+c];
+		xcmap[i].blue  = ramp[2*256+c];
+		xcmap[i].flags = (DoRed|DoGreen|DoBlue);
+	}
+	XStoreColors(GFX_Display, SDL_XColorMap, xcmap, ncolors);
+	XSync(GFX_Display, False);
+	return(0);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+void X11_VideoQuit(_THIS)
+{
+	/* Shutdown everything that's still up */
+	/* The event thread should be done, so we can touch SDL_Display */
+	if ( SDL_Display != NULL ) {
+		/* Flush any delayed updates */
+		XSync(GFX_Display, False);
+
+		/* Start shutting down the windows */
+		X11_DestroyImage(this, this->screen);
+		X11_DestroyWindow(this, this->screen);
+		X11_FreeVideoModes(this);
+		if ( SDL_XColorMap != SDL_DisplayColormap ) {
+			XFreeColormap(SDL_Display, SDL_XColorMap);
+		}
+		if ( SDL_iconcolors ) {
+			unsigned long pixel;
+			int numcolors =
+				((this->screen->format)->palette)->ncolors;
+			for ( pixel=0; pixel<numcolors; ++pixel ) {
+				while ( SDL_iconcolors[pixel] > 0 ) {
+					XFreeColors(SDL_Display,
+						SDL_DisplayColormap,&pixel,1,0);
+					--SDL_iconcolors[pixel];
+				}
+			}
+			free(SDL_iconcolors);
+			SDL_iconcolors = NULL;
+		} 
+		/* Restore gamma settings if they've changed */
+		if ( SDL_GetAppState() & SDL_APPACTIVE ) {
+			X11_SwapVidModeGamma(this);
+		}
+
+		/* Free that blank cursor */
+		if ( SDL_BlankCursor != NULL ) {
+			this->FreeWMCursor(this, SDL_BlankCursor);
+			SDL_BlankCursor = NULL;
+		}
+
+		/* Close the X11 graphics connection */
+		if ( GFX_Display != NULL ) {
+			XCloseDisplay(GFX_Display);
+			GFX_Display = NULL;
+		}
+
+		/* Close the X11 display connection */
+		XCloseDisplay(SDL_Display);
+		SDL_Display = NULL;
+
+		/* Reset the X11 error handlers */
+		if ( XIO_handler ) {
+			XSetIOErrorHandler(XIO_handler);
+		}
+		if ( X_handler ) {
+			XSetErrorHandler(X_handler);
+		}
+
+		/* Unload GL library after X11 shuts down */
+		X11_GL_UnloadLibrary(this);
+	}
+	if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) {
+		/* Direct screen access, no memory buffer */
+		this->screen->pixels = NULL;
+	}
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11video.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,190 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#ifndef _SDL_x11video_h
+#define _SDL_x11video_h
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#ifndef NO_SHARED_MEMORY
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#endif
+#ifdef XFREE86_DGAMOUSE
+#include <X11/extensions/xf86dga.h>
+#endif
+#ifdef XFREE86_VM
+#include <X11/extensions/xf86vmode.h>
+#ifdef XFREE86_VM_DYNAMIC_HACK
+#define XVidMode(func, args)	XF40VidMode##func args
+#else
+#define XVidMode(func, args)	XF86VidMode##func args
+#endif
+#endif /* XFREE86_VM */
+#include <string.h>
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+
+/* Hidden "this" pointer for the video functions */
+#define _THIS	SDL_VideoDevice *this
+
+/* Private display data */
+struct SDL_PrivateVideoData {
+    int local_X11;		/* Flag: true if local display */
+    Display *X11_Display;	/* Used for events and window management */
+    Display *GFX_Display;	/* Used for graphics and colormap stuff */
+    Visual *SDL_Visual;		/* The visual used by our window */
+    Window WMwindow;		/* Input window, managed by window manager */
+    Window FSwindow;		/* Fullscreen window, completely unmanaged */
+    Window SDL_Window;		/* Shared by both displays (no X security?) */
+    Atom WM_DELETE_WINDOW;	/* "close-window" protocol atom */
+    WMcursor *BlankCursor;	/* The invisible cursor */
+
+    char *SDL_windowid;		/* Flag: true if we have been passed a window */
+
+    /* Direct Graphics Access extension information */
+    int using_dga;
+
+#ifndef NO_SHARED_MEMORY
+    /* MIT shared memory extension information */
+    int use_mitshm;
+    XShmSegmentInfo shminfo;
+#endif
+
+    /* The variables used for displaying graphics */
+    XImage *Ximage;		/* The X image for our window */
+    GC	gc;			/* The graphic context for drawing */
+    int swap_pixels;		/* Flag: true if display is swapped endian */
+
+    /* The current width and height of the fullscreen mode */
+    int current_w;
+    int current_h;
+
+    /* Support for internal mouse warping */
+    struct {
+        int x;
+        int y;
+    } mouse_last;
+    struct {
+        int numerator;
+        int denominator;
+        int threshold;
+    } mouse_accel;
+    int mouse_relative;
+
+    /* The current list of available video modes */
+    SDL_Rect **modelist;
+
+    /* available visuals of interest to us, sorted deepest first */
+    struct {
+	Visual *visual;
+	int depth;		/* number of significant bits/pixel */
+	int bpp;		/* pixel quantum in bits */
+    } visuals[2*5];		/* at most 2 entries for 8, 15, 16, 24, 32 */
+    int nvisuals;
+
+    Visual *vis;		/* current visual in use */
+    int depth;			/* current visual depth (not bpp) */
+
+    /* Variables used by the X11 video mode code */
+#ifdef XFREE86_VM
+    XF86VidModeModeInfo saved_mode;
+    struct {
+        int x, y;
+    } saved_view;
+#endif
+    int use_vidmode;
+    int currently_fullscreen;
+
+    /* Automatic mode switching support (entering/leaving fullscreen) */
+    Uint32 switch_waiting;
+    Uint32 switch_time;
+
+    /* Prevent too many XSync() calls */
+    int blit_queued;
+
+    /* Colormap handling */
+    Colormap DisplayColormap;	/* The default display colormap */
+    Colormap XColorMap;		/* The current window colormap */
+    int *XPixels;		/* pixels value allocation counts */
+    float gamma_saved[3];	/* Saved gamma values for VidMode gamma */
+    int gamma_changed;		/* flag: has VidMode gamma been modified? */
+
+    short *iconcolors;		/* List of colors used by the icon */
+};
+
+/* Old variable names */
+#define local_X11		(this->hidden->local_X11)
+#define SDL_Display		(this->hidden->X11_Display)
+#define GFX_Display		(this->hidden->GFX_Display)
+#define SDL_Screen		DefaultScreen(this->hidden->X11_Display)
+
+#define SDL_Visual		(this->hidden->vis)
+
+#define SDL_Root		RootWindow(SDL_Display, SDL_Screen)
+#define WMwindow		(this->hidden->WMwindow)
+#define FSwindow		(this->hidden->FSwindow)
+#define SDL_Window		(this->hidden->SDL_Window)
+#define WM_DELETE_WINDOW	(this->hidden->WM_DELETE_WINDOW)
+#define SDL_BlankCursor		(this->hidden->BlankCursor)
+#define SDL_windowid		(this->hidden->SDL_windowid)
+#define using_dga		(this->hidden->using_dga)
+#define use_mitshm		(this->hidden->use_mitshm)
+#define shminfo			(this->hidden->shminfo)
+#define SDL_Ximage		(this->hidden->Ximage)
+#define SDL_GC			(this->hidden->gc)
+#define swap_pixels		(this->hidden->swap_pixels)
+#define current_w		(this->hidden->current_w)
+#define current_h		(this->hidden->current_h)
+#define mouse_last		(this->hidden->mouse_last)
+#define mouse_accel		(this->hidden->mouse_accel)
+#define mouse_relative		(this->hidden->mouse_relative)
+#define SDL_modelist		(this->hidden->modelist)
+#define saved_mode		(this->hidden->saved_mode)
+#define saved_view		(this->hidden->saved_view)
+#define use_vidmode		(this->hidden->use_vidmode)
+#define currently_fullscreen	(this->hidden->currently_fullscreen)
+#define switch_waiting		(this->hidden->switch_waiting)
+#define switch_time		(this->hidden->switch_time)
+#define blit_queued		(this->hidden->blit_queued)
+#define SDL_DisplayColormap	(this->hidden->DisplayColormap)
+#define SDL_PrivateColormap	(this->hidden->PrivateColormap)
+#define SDL_XColorMap		(this->hidden->XColorMap)
+#define SDL_XPixels		(this->hidden->XPixels)
+#define gamma_saved		(this->hidden->gamma_saved)
+#define gamma_changed		(this->hidden->gamma_changed)
+#define SDL_iconcolors		(this->hidden->iconcolors)
+
+/* Some versions of XFree86 have bugs - detect if this is one of them */
+#define BUGGY_XFREE86(condition, buggy_version) \
+((strcmp(ServerVendor(SDL_Display), "The XFree86 Project, Inc") == 0) && \
+ (VendorRelease(SDL_Display) condition buggy_version))
+
+#endif /* _SDL_x11video_h */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11wm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,344 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include "SDL_version.h"
+#include "SDL_error.h"
+#include "SDL_timer.h"
+#include "SDL_video.h"
+#include "SDL_syswm.h"
+#include "SDL_events_c.h"
+#include "SDL_pixels_c.h"
+#include "SDL_x11modes_c.h"
+#include "SDL_x11wm_c.h"
+
+/* This is necessary for working properly with Enlightenment, etc. */
+#define USE_ICON_WINDOW
+
+void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask)
+{
+	SDL_Surface *sicon;
+	XWMHints *wmhints;
+	XImage *icon_image;
+	Pixmap icon_pixmap;
+	Pixmap mask_pixmap;
+#ifdef USE_ICON_WINDOW
+	Window icon_window;
+#endif
+	GC GC;
+	XGCValues GCvalues;
+	int i, b, dbpp;
+	SDL_Rect bounds;
+	Uint8 *LSBmask, *color_tried;
+	Visual *dvis;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	/* The icon must use the default visual, depth and colormap of the
+	   screen, so it might need a conversion */
+	dbpp = DefaultDepth(SDL_Display, SDL_Screen);
+	switch(dbpp) {
+	case 15:
+	    dbpp = 16; break;
+	case 24:
+	    dbpp = 32; break;
+	}
+	dvis = DefaultVisual(SDL_Display, SDL_Screen);
+
+	/* The Visual struct is supposed to be opaque but we cheat a little */
+	sicon = SDL_CreateRGBSurface(SDL_SWSURFACE, icon->w, icon->h,
+				     dbpp,
+				     dvis->red_mask, dvis->green_mask,
+				     dvis->blue_mask, 0);
+
+	if ( sicon == NULL ) {
+		goto done;
+	}
+	/* If we already have allocated colours from the default colormap,
+	   copy them */
+	if(SDL_Visual == dvis && SDL_XColorMap == SDL_DisplayColormap
+	   && this->screen->format->palette && sicon->format->palette) {
+	    memcpy(sicon->format->palette->colors,
+		   this->screen->format->palette->colors,
+		   this->screen->format->palette->ncolors * sizeof(SDL_Color));
+	}
+
+	bounds.x = 0;
+	bounds.y = 0;
+	bounds.w = icon->w;
+	bounds.h = icon->h;
+	if ( SDL_LowerBlit(icon, &bounds, sicon, &bounds) < 0 )
+		goto done;
+
+	/* Lock down the colors used in the colormap */
+	color_tried = NULL;
+	if ( sicon->format->BitsPerPixel == 8 ) {
+		SDL_Palette *palette;
+		Uint8 *p;
+		XColor wanted;
+
+		palette = sicon->format->palette;
+		color_tried = malloc(palette->ncolors);
+		if ( color_tried == NULL ) {
+			goto done;
+		}
+		if ( SDL_iconcolors != NULL ) {
+			free(SDL_iconcolors);
+		}
+		SDL_iconcolors = malloc(palette->ncolors
+					* sizeof(*SDL_iconcolors));
+		if ( SDL_iconcolors == NULL ) {
+			free(color_tried);
+			goto done;
+		}
+		memset(color_tried, 0, palette->ncolors);
+		memset(SDL_iconcolors, 0,
+		       palette->ncolors * sizeof(*SDL_iconcolors));
+
+		p = (Uint8 *)sicon->pixels; 
+		for ( i = sicon->w*sicon->h; i > 0; --i, ++p ) {
+			if ( ! color_tried[*p] ) {
+				wanted.pixel = *p;
+				wanted.red   = (palette->colors[*p].r<<8);
+				wanted.green = (palette->colors[*p].g<<8);
+				wanted.blue  = (palette->colors[*p].b<<8);
+				wanted.flags = (DoRed|DoGreen|DoBlue);
+				if (XAllocColor(SDL_Display,
+						SDL_DisplayColormap, &wanted)) {
+					++SDL_iconcolors[wanted.pixel];
+				}
+				color_tried[*p] = 1;
+			}
+		}
+	}
+	if ( color_tried != NULL ) {
+		free(color_tried);
+	}
+
+	/* Translate mask data to LSB order and set the icon mask */
+	i = (sicon->w/8)*sicon->h;
+	LSBmask = (Uint8 *)malloc(i);
+	if ( LSBmask == NULL ) {
+		goto done;
+	}
+	memset(LSBmask, 0, i);
+	while ( --i >= 0 ) {
+		for ( b=0; b<8; ++b )
+			LSBmask[i] |= (((mask[i]>>b)&0x01)<<(7-b));
+	}
+	mask_pixmap = XCreatePixmapFromBitmapData(SDL_Display, WMwindow,
+		          (char *)LSBmask, sicon->w, sicon->h, 1L, 0L, 1);
+
+	/* Transfer the image to an X11 pixmap */
+	icon_image = XCreateImage(SDL_Display,
+			DefaultVisual(SDL_Display, SDL_Screen),
+			DefaultDepth(SDL_Display, SDL_Screen),
+			ZPixmap, 0, (char *)sicon->pixels, sicon->w, sicon->h,
+			((sicon->format)->BytesPerPixel == 3) ? 32 :
+				(sicon->format)->BytesPerPixel*8, 0);
+	icon_pixmap = XCreatePixmap(SDL_Display, SDL_Root, sicon->w, sicon->h,
+			DefaultDepth(SDL_Display, SDL_Screen));
+	GC = XCreateGC(SDL_Display, icon_pixmap, 0, &GCvalues);
+	XPutImage(SDL_Display, icon_pixmap, GC, icon_image,
+					0, 0, 0, 0, sicon->w, sicon->h);
+	XFreeGC(SDL_Display, GC);
+	XDestroyImage(icon_image);
+	free(LSBmask);
+	sicon->pixels = NULL;
+
+#ifdef USE_ICON_WINDOW
+	/* Create an icon window and set the pixmap as its background */
+	icon_window = XCreateSimpleWindow(SDL_Display, SDL_Root,
+					0, 0, sicon->w, sicon->h, 0,
+					CopyFromParent, CopyFromParent);
+	XSetWindowBackgroundPixmap(SDL_Display, icon_window, icon_pixmap);
+	XClearWindow(SDL_Display, icon_window);
+#endif
+
+	/* Set the window icon to the icon pixmap (and icon window) */
+	wmhints = XAllocWMHints();
+	wmhints->flags = (IconPixmapHint | IconMaskHint);
+	wmhints->icon_pixmap = icon_pixmap;
+	wmhints->icon_mask = mask_pixmap;
+#ifdef USE_ICON_WINDOW
+	wmhints->flags |= IconWindowHint;
+	wmhints->icon_window = icon_window;
+#endif
+	XSetWMHints(SDL_Display, WMwindow, wmhints);
+	XFree(wmhints);
+	XSync(SDL_Display, False);
+
+  done:
+	SDL_Unlock_EventThread();
+	if ( sicon != NULL ) {
+		SDL_FreeSurface(sicon);
+	}
+	return;
+}
+
+void X11_SetCaption(_THIS, const char *title, const char *icon)
+{
+	XTextProperty titleprop, iconprop;
+
+	/* Lock the event thread, in multi-threading environments */
+	SDL_Lock_EventThread();
+
+	if ( title != NULL ) {
+		XStringListToTextProperty((char **)&title, 1, &titleprop);
+		XSetWMName(SDL_Display, WMwindow, &titleprop);
+		XFree(titleprop.value);
+	}
+	if ( icon != NULL ) {
+		XStringListToTextProperty((char **)&icon, 1, &iconprop);
+		XSetWMIconName(SDL_Display, WMwindow, &iconprop);
+		XFree(iconprop.value);
+	}
+	XSync(SDL_Display, False);
+
+	SDL_Unlock_EventThread();
+}
+
+/* Iconify the window */
+int X11_IconifyWindow(_THIS)
+{
+	int result;
+
+	SDL_Lock_EventThread();
+	result = XIconifyWindow(SDL_Display, WMwindow, SDL_Screen);
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+	return(result);
+}
+
+SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode)
+{
+	int numtries, result;
+
+	if ( this->screen == NULL ) {
+		return(SDL_GRAB_OFF);
+	}
+	if ( ! SDL_Window ) {
+		return(mode);	/* Will be set later on mode switch */
+	}
+	if ( mode == SDL_GRAB_OFF ) {
+		XUngrabPointer(SDL_Display, CurrentTime);
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Rebind the mouse to the fullscreen window */
+			for ( numtries = 0; numtries < 10; ++numtries ) {
+				result = XGrabPointer(SDL_Display, FSwindow,
+						True, 0,
+						GrabModeAsync, GrabModeAsync,
+						FSwindow, None, CurrentTime);
+				if ( result == AlreadyGrabbed ) {
+					break;
+				}
+				SDL_Delay(100);
+			}
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XUngrabKeyboard(SDL_Display, CurrentTime);
+	} else {
+		if ( this->screen->flags & SDL_FULLSCREEN ) {
+			/* Unbind the mouse from the fullscreen window */
+			XUngrabPointer(SDL_Display, CurrentTime);
+		}
+		/* Try to grab the mouse */
+		for ( numtries = 0; numtries < 10; ++numtries ) {
+			result = XGrabPointer(SDL_Display, SDL_Window, True, 0,
+						GrabModeAsync, GrabModeAsync,
+						SDL_Window, None, CurrentTime);
+			if ( result != AlreadyGrabbed ) {
+				break;
+			}
+			SDL_Delay(100);
+		}
+#ifdef GRAB_FULLSCREEN
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+#endif
+		XGrabKeyboard(SDL_Display, WMwindow, True,
+			GrabModeAsync, GrabModeAsync, CurrentTime);
+
+		/* Raise the window if we grab the mouse */
+		if ( !(this->screen->flags & SDL_FULLSCREEN) )
+			XRaiseWindow(SDL_Display, WMwindow);
+	}
+	XSync(SDL_Display, False);
+
+	return(mode);
+}
+
+SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode)
+{
+	SDL_Lock_EventThread();
+	mode = X11_GrabInputNoLock(this, mode);
+	SDL_Unlock_EventThread();
+
+	return(mode);
+}
+
+/* If 'info' is the right version, this function fills it and returns 1.
+   Otherwise, in case of a version mismatch, it returns -1.
+*/
+static void lock_display(void)
+{
+	SDL_Lock_EventThread();
+}
+static void unlock_display(void)
+{
+	/* Make sure any X11 transactions are completed */
+	SDL_VideoDevice *this = current_video;
+	XSync(SDL_Display, False);
+	SDL_Unlock_EventThread();
+}
+int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info)
+{
+	if ( info->version.major <= SDL_MAJOR_VERSION ) {
+		info->subsystem = SDL_SYSWM_X11;
+		info->info.x11.display = SDL_Display;
+		info->info.x11.window = SDL_Window;
+		if ( SDL_VERSIONNUM(info->version.major,
+		                    info->version.minor,
+		                    info->version.patch) >= 1002 ) {
+			info->info.x11.fswindow = FSwindow;
+			info->info.x11.wmwindow = WMwindow;
+		}
+		info->info.x11.lock_func = lock_display;
+		info->info.x11.unlock_func = unlock_display;
+		return(1);
+	} else {
+		SDL_SetError("Application not compiled with SDL %d.%d\n",
+					SDL_MAJOR_VERSION, SDL_MINOR_VERSION);
+		return(-1);
+	}
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11wm_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,37 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+#include "SDL_x11video.h"
+
+/* Functions to be exported */
+extern void X11_SetCaption(_THIS, const char *title, const char *icon);
+extern void X11_SetIcon(_THIS, SDL_Surface *icon, Uint8 *mask);
+extern int X11_IconifyWindow(_THIS);
+extern SDL_GrabMode X11_GrabInputNoLock(_THIS, SDL_GrabMode mode);
+extern SDL_GrabMode X11_GrabInput(_THIS, SDL_GrabMode mode);
+extern int X11_GetWMInfo(_THIS, SDL_SysWMinfo *info);
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11yuv.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,280 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the XFree86 Xv extension implementation of YUV video overlays */
+
+#ifdef XFREE86_XV
+
+#include <stdlib.h>
+#include <string.h>
+#include <X11/Xlib.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <X11/extensions/XShm.h>
+#include <X11/extensions/Xvlib.h>
+
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_x11yuv_c.h"
+#include "SDL_yuvfuncs.h"
+
+#define XFREE86_REFRESH_HACK
+#ifdef XFREE86_REFRESH_HACK
+#include "SDL_x11image_c.h"
+#endif
+
+/* Workaround when pitch != width */
+#define PITCH_WORKAROUND
+
+/* The functions used to manipulate software video overlays */
+static struct private_yuvhwfuncs x11_yuvfuncs = {
+	X11_LockYUVOverlay,
+	X11_UnlockYUVOverlay,
+	X11_DisplayYUVOverlay,
+	X11_FreeYUVOverlay
+};
+
+struct private_yuvhwdata {
+	int port;
+	XShmSegmentInfo yuvshm;
+	XvImage *image;
+};
+
+
+SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display)
+{
+	SDL_Overlay *overlay;
+	struct private_yuvhwdata *hwdata;
+	int xv_port;
+	int i, j, k;
+	int adaptors;
+	XvAdaptorInfo *ainfo;
+	XShmSegmentInfo *yuvshm;
+
+	/* Look for the XVideo extension with a valid port for this format */
+	xv_port = -1;
+	if ( (Success == XvQueryExtension(GFX_Display, &j, &j, &j, &j, &j)) &&
+	     (Success == XvQueryAdaptors(GFX_Display,
+	                                 RootWindow(GFX_Display, SDL_Screen),
+	                                 &adaptors, &ainfo)) ) {
+		for ( i=0; (i < adaptors) && (xv_port == -1); ++i ) {
+			/* Check to see if the visual can be used */
+			if ( BUGGY_XFREE86(<=, 4001) ) {
+				int visual_ok = 0;
+				for ( j=0; j<ainfo[i].num_formats; ++j ) {
+					if ( ainfo[i].formats[j].visual_id ==
+							SDL_Visual->visualid ) {
+						visual_ok = 1;
+						break;
+					}
+				}
+				if ( ! visual_ok ) {
+					continue;
+				}
+			}
+			if ( (ainfo[i].type & XvInputMask) &&
+			     (ainfo[i].type & XvImageMask) ) {
+				int num_formats;
+				XvImageFormatValues *formats;
+				formats = XvListImageFormats(GFX_Display,
+				              ainfo[i].base_id, &num_formats);
+				for ( j=0; (j < num_formats) && (xv_port == -1); ++j ) {
+					if ( (Uint32)formats[j].id == format ) {
+						for ( k=0; k < ainfo[i].num_ports; ++k ) {
+							if ( Success == XvGrabPort(GFX_Display, ainfo[i].base_id+k, CurrentTime) ) {
+								xv_port = ainfo[i].base_id+k;
+								break;
+							}
+						}
+					}
+				}
+			}
+		}
+	}
+	if ( xv_port == -1 ) {
+		SDL_SetError("No available video ports for requested format");
+		return(NULL);
+	}
+
+	/* Create the overlay structure */
+	overlay = (SDL_Overlay *)malloc(sizeof *overlay);
+	if ( overlay == NULL ) {
+		XvUngrabPort(GFX_Display, xv_port, CurrentTime);
+		SDL_OutOfMemory();
+		return(NULL);
+	}
+	memset(overlay, 0, (sizeof *overlay));
+
+	/* Fill in the basic members */
+	overlay->format = format;
+	overlay->w = width;
+	overlay->h = height;
+
+	/* Set up the YUV surface function structure */
+	overlay->hwfuncs = &x11_yuvfuncs;
+	overlay->hw_overlay = 1;
+
+	/* Create the pixel data and lookup tables */
+	hwdata = (struct private_yuvhwdata *)malloc(sizeof *hwdata);
+	overlay->hwdata = hwdata;
+	if ( hwdata == NULL ) {
+		XvUngrabPort(GFX_Display, xv_port, CurrentTime);
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	yuvshm = &hwdata->yuvshm;
+	memset(yuvshm, 0, sizeof(*yuvshm));
+	hwdata->port = xv_port;
+	hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format,
+	                                 0, width, height, yuvshm);
+
+#ifdef PITCH_WORKAROUND
+	if ( hwdata->image != NULL && hwdata->image->pitches[0] != width )
+	{
+	  /* Ajust overlay width according to pitch */ 
+	  switch (format) {
+	    case SDL_YV12_OVERLAY:
+	    case SDL_IYUV_OVERLAY:
+	        width = hwdata->image->pitches[0];
+		break;
+	    case SDL_YUY2_OVERLAY:
+	    case SDL_UYVY_OVERLAY:
+	    case SDL_YVYU_OVERLAY:
+	        width = hwdata->image->pitches[0] / 2;
+		break;
+	    default:
+		/* We should never get here (caught above) */
+		return(NULL);
+	  }
+	  
+	  XFree(hwdata->image);
+	  hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format,
+					   0, width, height, yuvshm);
+	}
+#endif
+
+	if ( hwdata->image == NULL ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	yuvshm->shmid = shmget(IPC_PRIVATE, hwdata->image->data_size,
+	                       IPC_CREAT | 0777);
+	if ( yuvshm->shmid < 0 ) {
+		SDL_SetError("Unable to get %d bytes shared memory",
+		             hwdata->image->data_size);
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	yuvshm->shmaddr  = (char *) shmat(yuvshm->shmid, 0, 0);
+	yuvshm->readOnly = False;
+	hwdata->image->data = yuvshm->shmaddr;
+
+	XShmAttach(GFX_Display, yuvshm);
+	XSync(GFX_Display, False);
+	shmctl(yuvshm->shmid, IPC_RMID, 0);
+
+	/* Find the pitch and offset values for the overlay */
+	overlay->planes = hwdata->image->num_planes;
+	overlay->pitches = (Uint16 *)malloc(overlay->planes * sizeof(Uint16));
+	overlay->pixels = (Uint8 **)malloc(overlay->planes * sizeof(Uint8 *));
+	if ( !overlay->pitches || !overlay->pixels ) {
+		SDL_OutOfMemory();
+		SDL_FreeYUVOverlay(overlay);
+		return(NULL);
+	}
+	for ( i=0; i<overlay->planes; ++i ) {
+		overlay->pitches[i] = hwdata->image->pitches[i];
+		overlay->pixels[i] = (Uint8 *)hwdata->image->data +
+		                              hwdata->image->offsets[i];
+	}
+
+#ifdef XFREE86_REFRESH_HACK
+	/* Work around an XFree86 X server bug (?)
+	   We can't perform normal updates in windows that have video
+	   being output to them.  See SDL_x11image.c for more details.
+	 */
+	X11_DisableAutoRefresh(this);
+#endif
+
+	/* We're all done.. */
+	return(overlay);
+}
+
+int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	return(0);
+}
+
+void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	return;
+}
+
+int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect)
+{
+	struct private_yuvhwdata *hwdata;
+
+	hwdata = overlay->hwdata;
+	XvShmPutImage(GFX_Display, hwdata->port, SDL_Window, SDL_GC,
+	              hwdata->image, 0, 0, overlay->w, overlay->h,
+	              dstrect->x, dstrect->y, dstrect->w, dstrect->h, False);
+	XSync(GFX_Display, False);
+	return(0);
+}
+
+void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay)
+{
+	struct private_yuvhwdata *hwdata;
+
+	hwdata = overlay->hwdata;
+	if ( hwdata ) {
+		XvUngrabPort(GFX_Display, hwdata->port, CurrentTime);
+		if ( hwdata->yuvshm.shmaddr ) {
+			XShmDetach(GFX_Display, &hwdata->yuvshm);
+			shmdt(hwdata->yuvshm.shmaddr);
+		}
+		if ( hwdata->image ) {
+			XFree(hwdata->image);
+		}
+		free(hwdata);
+	}
+	if ( overlay->pitches ) {
+		free(overlay->pitches);
+		overlay->pitches = NULL;
+	}
+	if ( overlay->pixels ) {
+		free(overlay->pixels);
+		overlay->pixels = NULL;
+	}
+#ifdef XFREE86_REFRESH_HACK
+	X11_EnableAutoRefresh(this);
+#endif
+}
+
+#endif /* XFREE86_XV */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/video/x11/SDL_x11yuv_c.h	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,45 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997, 1998, 1999, 2000, 2001  Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Library General Public
+    License as published by the Free Software Foundation; either
+    version 2 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Library General Public License for more details.
+
+    You should have received a copy of the GNU Library General Public
+    License along with this library; if not, write to the Free
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+    Sam Lantinga
+    slouken@devolution.com
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id$";
+#endif
+
+/* This is the XFree86 Xv extension implementation of YUV video overlays */
+
+#include "SDL_video.h"
+#include "SDL_x11video.h"
+
+#ifdef XFREE86_XV
+
+extern SDL_Overlay *X11_CreateYUVOverlay(_THIS, int width, int height, Uint32 format, SDL_Surface *display);
+
+extern int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+extern int X11_DisplayYUVOverlay(_THIS, SDL_Overlay *overlay, SDL_Rect *dstrect);
+
+extern void X11_FreeYUVOverlay(_THIS, SDL_Overlay *overlay);
+
+#endif /* XFREE86_XV */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/strip_fPIC.sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,15 @@
+#!/bin/sh
+#
+# libtool assumes that the compiler can handle the -fPIC flag
+# This isn't always true (for example, nasm can't handle it)
+command=""
+while [ $1 ]; do
+    if [ "$1" != "-fPIC" ]; then
+        if [ "$1" != "-DPIC" ]; then
+            command="$command $1"
+        fi
+    fi
+    shift
+done
+echo $command
+exec $command
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/.cvsignore	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1 @@
+Makefile.in configure aclocal.m4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/.gdbinit	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,3 @@
+handle SIGUSR1 pass noprint
+handle SIGUSR2 pass noprint
+break main
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/COPYING	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,8 @@
+
+The test programs in this directory tree are for demonstrating and
+testing the functionality of the SDL library, and are placed in the
+public domain.
+
+October 28, 1997
+--
+	Sam Lantinga				(slouken@devolution.com)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/Makefile.am	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,16 @@
+AUTOMAKE_OPTIONS = no-dependencies
+
+noinst_PROGRAMS = \
+	testver testtypes testhread testlock testerror testsem testtimer \
+	loopwave testcdrom testkeys testvidinfo checkkeys testwin graywin \
+	testsprite testbitmap testalpha testgamma testpalette testwm \
+	threadwin testgl testjoystick
+
+testalpha_SOURCES = testalpha.c
+testalpha_LDADD = @MATHLIB@
+testgamma_SOURCES = testgamma.c
+testgamma_LDADD = @MATHLIB@
+testpalette_SOURCES = testpalette.c
+testpalette_LDADD = @MATHLIB@
+testgl_SOURCES = testgl.c
+testgl_LDADD = @GL_LIBS@ @MATHLIB@
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/README	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,25 @@
+
+These are test programs for the SDL library:
+
+	testver		Check the version and dynamic loading and endianness
+	testtypes	Check to see if the data types are the correct size
+	testhread	Hacked up test of multi-threading
+	testlock	Hacked up test of multi-threading and locking
+	testerror	Tests multi-threaded error handling
+	testsem		Tests SDL's semaphore implementation
+	testtimer	Test the timer facilities
+	loopwave	Audio test -- loop playing a WAV file
+	testcdrom	Sample audio CD control program
+	testkeys	List the available keyboard keys
+	testvidinfo	Show the pixel format of the display
+	checkkeys	Watch the key events to check the keyboard
+	testwin		Display a BMP image at various depths
+	graywin		Display a gray gradient and center mouse on spacebar
+	testsprite	Example of fast sprite movement on the screen
+	testbitmap	Test displaying 1-bit bitmaps
+	testalpha	Display an alpha faded icon -- paint with mouse
+	testwm		Test window manager -- title, icon, events
+	threadwin	Test multi-threaded event handling
+	testgl		A very simple example of using OpenGL with SDL
+	testjoystick	List joysticks and watch joystick events
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/acinclude.m4	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,168 @@
+# Configure paths for SDL
+# Sam Lantinga 9/21/99
+# stolen from Manish Singh
+# stolen back from Frank Belew
+# stolen from Manish Singh
+# Shamelessly stolen from Owen Taylor
+
+dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
+dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
+dnl
+AC_DEFUN(AM_PATH_SDL,
+[dnl 
+dnl Get the cflags and libraries from the sdl-config script
+dnl
+AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
+            sdl_prefix="$withval", sdl_prefix="")
+AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
+            sdl_exec_prefix="$withval", sdl_exec_prefix="")
+AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
+		    , enable_sdltest=yes)
+
+  if test x$sdl_exec_prefix != x ; then
+     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
+     if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
+     fi
+  fi
+  if test x$sdl_prefix != x ; then
+     sdl_args="$sdl_args --prefix=$sdl_prefix"
+     if test x${SDL_CONFIG+set} != xset ; then
+        SDL_CONFIG=$sdl_prefix/bin/sdl-config
+     fi
+  fi
+
+  AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
+  min_sdl_version=ifelse([$1], ,0.11.0,$1)
+  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
+  no_sdl=""
+  if test "$SDL_CONFIG" = "no" ; then
+    no_sdl=yes
+  else
+    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
+    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
+
+    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
+    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
+    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
+           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
+    if test "x$enable_sdltest" = "xyes" ; then
+      ac_save_CFLAGS="$CFLAGS"
+      ac_save_LIBS="$LIBS"
+      CFLAGS="$CFLAGS $SDL_CFLAGS"
+      LIBS="$LIBS $SDL_LIBS"
+dnl
+dnl Now check if the installed SDL is sufficiently new. (Also sanity
+dnl checks the results of sdl-config to some extent
+dnl
+      rm -f conf.sdltest
+      AC_TRY_RUN([
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "SDL.h"
+
+char*
+my_strdup (char *str)
+{
+  char *new_str;
+  
+  if (str)
+    {
+      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
+      strcpy (new_str, str);
+    }
+  else
+    new_str = NULL;
+  
+  return new_str;
+}
+
+int main (int argc, char *argv[])
+{
+  int major, minor, micro;
+  char *tmp_version;
+
+  /* This hangs on some systems (?)
+  system ("touch conf.sdltest");
+  */
+  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
+
+  /* HP/UX 9 (%@#!) writes to sscanf strings */
+  tmp_version = my_strdup("$min_sdl_version");
+  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
+     printf("%s, bad version string\n", "$min_sdl_version");
+     exit(1);
+   }
+
+   if (($sdl_major_version > major) ||
+      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
+      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
+    {
+      return 0;
+    }
+  else
+    {
+      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
+      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
+      printf("*** best to upgrade to the required version.\n");
+      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
+      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
+      printf("*** config.cache before re-running configure\n");
+      return 1;
+    }
+}
+
+],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
+       CFLAGS="$ac_save_CFLAGS"
+       LIBS="$ac_save_LIBS"
+     fi
+  fi
+  if test "x$no_sdl" = x ; then
+     AC_MSG_RESULT(yes)
+     ifelse([$2], , :, [$2])     
+  else
+     AC_MSG_RESULT(no)
+     if test "$SDL_CONFIG" = "no" ; then
+       echo "*** The sdl-config script installed by SDL could not be found"
+       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
+       echo "*** your path, or set the SDL_CONFIG environment variable to the"
+       echo "*** full path to sdl-config."
+     else
+       if test -f conf.sdltest ; then
+        :
+       else
+          echo "*** Could not run SDL test program, checking why..."
+          CFLAGS="$CFLAGS $SDL_CFLAGS"
+          LIBS="$LIBS $SDL_LIBS"
+          AC_TRY_LINK([
+#include <stdio.h>
+#include "SDL.h"
+],      [ return 0; ],
+        [ echo "*** The test program compiled, but did not run. This usually means"
+          echo "*** that the run-time linker is not finding SDL or finding the wrong"
+          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
+          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
+          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
+          echo "*** is required on your system"
+	  echo "***"
+          echo "*** If you have an old version installed, it is best to remove it, although"
+          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
+        [ echo "*** The test program failed to compile or link. See the file config.log for the"
+          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
+          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
+          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
+          CFLAGS="$ac_save_CFLAGS"
+          LIBS="$ac_save_LIBS"
+       fi
+     fi
+     SDL_CFLAGS=""
+     SDL_LIBS=""
+     ifelse([$3], , :, [$3])
+  fi
+  AC_SUBST(SDL_CFLAGS)
+  AC_SUBST(SDL_LIBS)
+  rm -f conf.sdltest
+])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/autogen.sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,9 @@
+#!/bin/sh
+#
+aclocal
+automake --foreign
+autoconf
+
+# Run configure for this platform
+#./configure $*
+echo "Now you are ready to run ./configure"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/checkkeys.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,124 @@
+
+/* Simple program:  Loop, watching keystrokes
+   Note that you need to call SDL_PollEvent() or SDL_WaitEvent() to 
+   pump the event loop and catch keystrokes.
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+static void print_modifiers(void)
+{
+	int mod;
+	printf(" modifiers:");
+	mod = SDL_GetModState();
+	if(!mod) {
+		printf(" (none)");
+		return;
+	}
+	if(mod & KMOD_LSHIFT)
+		printf(" LSHIFT");
+	if(mod & KMOD_RSHIFT)
+		printf(" RSHIFT");
+	if(mod & KMOD_LCTRL)
+		printf(" LCTRL");
+	if(mod & KMOD_RCTRL)
+		printf(" RCTRL");
+	if(mod & KMOD_LALT)
+		printf(" LALT");
+	if(mod & KMOD_RALT)
+		printf(" RALT");
+	if(mod & KMOD_LMETA)
+		printf(" LMETA");
+	if(mod & KMOD_RMETA)
+		printf(" RMETA");
+	if(mod & KMOD_NUM)
+		printf(" NUM");
+	if(mod & KMOD_CAPS)
+		printf(" CAPS");
+	if(mod & KMOD_MODE)
+		printf(" MODE");
+}
+
+static void PrintKey(SDL_keysym *sym, int pressed)
+{
+	/* Print the keycode, name and state */
+	if ( sym->sym ) {
+		printf("Key %s:  %d-%s ", pressed ?  "pressed" : "released",
+					sym->sym, SDL_GetKeyName(sym->sym));
+	} else {
+		printf("Unknown Key (scancode = %d) %s ", sym->scancode,
+					pressed ?  "pressed" : "released");
+	}
+
+	/* Print the translated character, if one exists */
+	if ( sym->unicode ) {
+		/* Is it a control-character? */
+		if ( sym->unicode < ' ' ) {
+			printf(" (^%c)", sym->unicode+'@');
+		} else {
+#ifdef UNICODE
+			printf(" (%c)", sym->unicode);
+#else
+			/* This is a Latin-1 program, so only show 8-bits */
+			if ( !(sym->unicode & 0xFF00) )
+				printf(" (%c)", sym->unicode);
+#endif
+		}
+	}
+	print_modifiers();
+	printf("\n");
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Event event;
+	int done;
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Set 640x480 video mode */
+	if ( SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE) == NULL ) {
+		fprintf(stderr, "Couldn't set 640x480 video mode: %s\n",
+							SDL_GetError());
+		exit(2);
+	}
+
+	/* Enable UNICODE translation for keyboard input */
+	SDL_EnableUNICODE(1);
+
+	/* Enable auto repeat for keyboard input */
+	SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,
+	                    SDL_DEFAULT_REPEAT_INTERVAL);
+
+	/* Watch keystrokes */
+	done = 0;
+	while ( !done ) {
+		/* Check for events */
+		SDL_WaitEvent(&event);
+		switch (event.type) {
+			case SDL_KEYDOWN:
+				PrintKey(&event.key.keysym, 1);
+				break;
+			case SDL_KEYUP:
+				PrintKey(&event.key.keysym, 0);
+				break;
+			case SDL_MOUSEBUTTONDOWN:
+				/* Any button press quits the app... */
+			case SDL_QUIT:
+				done = 1;
+				break;
+			default:
+				break;
+		}
+	}
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/config.guess	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1289 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+
+version='2000-09-05'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Written by Per Bothner <bothner@cygnus.com>.
+# Please send patches to <config-patches@gnu.org>.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit system type (host/target name).
+#
+# Only a few systems have been added to this list; please add others
+# (but try to keep the structure clean).
+#
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of this system.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+# Use $HOST_CC if defined. $CC may point to a cross-compiler
+if test x"$CC_FOR_BUILD" = x; then
+  if test x"$HOST_CC" != x; then
+    CC_FOR_BUILD="$HOST_CC"
+  else
+    if test x"$CC" != x; then
+      CC_FOR_BUILD="$CC"
+    else
+      CC_FOR_BUILD=cc
+    fi
+  fi
+fi
+
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 8/24/94.)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+	PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+dummy=dummy-$$
+trap 'rm -f $dummy.c $dummy.o $dummy; exit 1' 1 2 15
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+	# Netbsd (nbsd) targets should (where applicable) match one or
+	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+	# switched to ELF, *-*-netbsd* would select the old
+	# object file format.  This provides both forward
+	# compatibility and a consistent mechanism for selecting the
+	# object file format.
+	# Determine the machine/vendor (is the vendor relevant).
+	case "${UNAME_MACHINE}" in
+	    amiga) machine=m68k-unknown ;;
+	    arm32) machine=arm-unknown ;;
+	    atari*) machine=m68k-atari ;;
+	    sun3*) machine=m68k-sun ;;
+	    mac68k) machine=m68k-apple ;;
+	    macppc) machine=powerpc-apple ;;
+	    hp3[0-9][05]) machine=m68k-hp ;;
+	    ibmrt|romp-ibm) machine=romp-ibm ;;
+	    *) machine=${UNAME_MACHINE}-unknown ;;
+	esac
+	# The Operating System including object format.
+	if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+		| grep __ELF__ >/dev/null
+	then
+	    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+	    # Return netbsd for either.  FIX?
+	    os=netbsd
+	else
+	    os=netbsdelf
+	fi
+	# The OS release
+	release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+	# contains redundant information, the shorter form:
+	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+	echo "${machine}-${os}${release}"
+	exit 0 ;;
+    alpha:OSF1:*:*)
+	if test $UNAME_RELEASE = "V4.0"; then
+		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+	fi
+	# A Vn.n version is a released version.
+	# A Tn.n version is a released field test version.
+	# A Xn.n version is an unreleased experimental baselevel.
+	# 1.2 uses "1.2" for uname -r.
+	cat <<EOF >$dummy.s
+	.data
+\$Lformat:
+	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+	.text
+	.globl main
+	.align 4
+	.ent main
+main:
+	.frame \$30,16,\$26,0
+	ldgp \$29,0(\$27)
+	.prologue 1
+	.long 0x47e03d80 # implver \$0
+	lda \$2,-1
+	.long 0x47e20c21 # amask \$2,\$1
+	lda \$16,\$Lformat
+	mov \$0,\$17
+	not \$1,\$18
+	jsr \$26,printf
+	ldgp \$29,0(\$26)
+	mov 0,\$16
+	jsr \$26,exit
+	.end main
+EOF
+	$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+	if test "$?" = 0 ; then
+		case `./$dummy` in
+			0-0)
+				UNAME_MACHINE="alpha"
+				;;
+			1-0)
+				UNAME_MACHINE="alphaev5"
+				;;
+			1-1)
+				UNAME_MACHINE="alphaev56"
+				;;
+			1-101)
+				UNAME_MACHINE="alphapca56"
+				;;
+			2-303)
+				UNAME_MACHINE="alphaev6"
+				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
+		esac
+	fi
+	rm -f $dummy.s $dummy
+	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+	exit 0 ;;
+    Alpha\ *:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# Should we change UNAME_MACHINE based on the output of uname instead
+	# of the specific Alpha model?
+	echo alpha-pc-interix
+	exit 0 ;;
+    21064:Windows_NT:50:3)
+	echo alpha-dec-winnt3.5
+	exit 0 ;;
+    Amiga*:UNIX_System_V:4.0:*)
+	echo m68k-unknown-sysv4
+	exit 0;;
+    amiga:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+	echo ${UNAME_MACHINE}-unknown-amigaos
+	exit 0 ;;
+    arc64:OpenBSD:*:*)
+	echo mips64el-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    arc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    hkmips:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    pmax:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    sgi:OpenBSD:*:*)
+	echo mips-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    wgrisc:OpenBSD:*:*)
+	echo mipsel-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    *:OS/390:*:*)
+	echo i370-ibm-openedition
+	exit 0 ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+	echo arm-acorn-riscix${UNAME_RELEASE}
+	exit 0;;
+    SR2?01:HI-UX/MPP:*:*)
+	echo hppa1.1-hitachi-hiuxmpp
+	exit 0;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+	if test "`(/bin/universe) 2>/dev/null`" = att ; then
+		echo pyramid-pyramid-sysv3
+	else
+		echo pyramid-pyramid-bsd
+	fi
+	exit 0 ;;
+    NILE*:*:*:dcosx)
+	echo pyramid-pyramid-svr4
+	exit 0 ;;
+    sun4H:SunOS:5.*:*)
+	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    i86pc:SunOS:5.*:*)
+	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:6*:*)
+	# According to config.sub, this is the proper way to canonicalize
+	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+	# it's likely to be more like Solaris than SunOS4.
+	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    sun4*:SunOS:*:*)
+	case "`/usr/bin/arch -k`" in
+	    Series*|S4*)
+		UNAME_RELEASE=`uname -v`
+		;;
+	esac
+	# Japanese Language versions have a version number like `4.1.3-JL'.
+	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+	exit 0 ;;
+    sun3*:SunOS:*:*)
+	echo m68k-sun-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    sun*:*:4.2BSD:*)
+	UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+	case "`/bin/arch`" in
+	    sun3)
+		echo m68k-sun-sunos${UNAME_RELEASE}
+		;;
+	    sun4)
+		echo sparc-sun-sunos${UNAME_RELEASE}
+		;;
+	esac
+	exit 0 ;;
+    aushp:SunOS:*:*)
+	echo sparc-auspex-sunos${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+	echo m68k-atari-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+	exit 0 ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit 0 ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit 0 ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit 0 ;;
+    sun3*:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mac68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme68k:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    mvme88k:OpenBSD:*:*)
+	echo m88k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    powerpc:machten:*:*)
+	echo powerpc-apple-machten${UNAME_RELEASE}
+	exit 0 ;;
+    RISC*:Mach:*:*)
+	echo mips-dec-mach_bsd4.3
+	exit 0 ;;
+    RISC*:ULTRIX:*:*)
+	echo mips-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    VAX*:ULTRIX*:*:*)
+	echo vax-dec-ultrix${UNAME_RELEASE}
+	exit 0 ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+	echo clipper-intergraph-clix${UNAME_RELEASE}
+	exit 0 ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+	sed 's/^	//' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+	#if defined (host_mips) && defined (MIPSEB)
+	#if defined (SYSTYPE_SYSV)
+	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_SVR4)
+	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+	#endif
+	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+	#endif
+	#endif
+	  exit (-1);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy \
+	  && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
+	  && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo mips-mips-riscos${UNAME_RELEASE}
+	exit 0 ;;
+    Night_Hawk:Power_UNIX:*:*)
+	echo powerpc-harris-powerunix
+	exit 0 ;;
+    m88k:CX/UX:7*:*)
+	echo m88k-harris-cxux7
+	exit 0 ;;
+    m88k:*:4*:R4*)
+	echo m88k-motorola-sysv4
+	exit 0 ;;
+    m88k:*:3*:R3*)
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+	then
+	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+	       [ ${TARGET_BINARY_INTERFACE}x = x ]
+	    then
+		echo m88k-dg-dgux${UNAME_RELEASE}
+	    else
+		echo m88k-dg-dguxbcs${UNAME_RELEASE}
+	    fi
+	else
+	    echo i586-dg-dgux${UNAME_RELEASE}
+	fi
+ 	exit 0 ;;
+    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
+	echo m88k-dolphin-sysv3
+	exit 0 ;;
+    M88*:*:R3*:*)
+	# Delta 88k system running SVR3
+	echo m88k-motorola-sysv3
+	exit 0 ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+	echo m88k-tektronix-sysv3
+	exit 0 ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+	echo m68k-tektronix-bsd
+	exit 0 ;;
+    *:IRIX*:*:*)
+	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+	exit 0 ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
+	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
+    i?86:AIX:*:*)
+	echo i386-ibm-aix
+	exit 0 ;;
+    *:AIX:2:3)
+	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+		sed 's/^		//' << EOF >$dummy.c
+		#include <sys/systemcfg.h>
+
+		main()
+			{
+			if (!__power_pc())
+				exit(1);
+			puts("powerpc-ibm-aix3.2.5");
+			exit(0);
+			}
+EOF
+		$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+		rm -f $dummy.c $dummy
+		echo rs6000-ibm-aix3.2.5
+	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+		echo rs6000-ibm-aix3.2.4
+	else
+		echo rs6000-ibm-aix3.2
+	fi
+	exit 0 ;;
+    *:AIX:*:4)
+	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
+	if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
+		IBM_ARCH=rs6000
+	else
+		IBM_ARCH=powerpc
+	fi
+	if [ -x /usr/bin/oslevel ] ; then
+		IBM_REV=`/usr/bin/oslevel`
+	else
+		IBM_REV=4.${UNAME_RELEASE}
+	fi
+	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+	exit 0 ;;
+    *:AIX:*:*)
+	echo rs6000-ibm-aix
+	exit 0 ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+	echo romp-ibm-bsd4.4
+	exit 0 ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+	exit 0 ;;                           # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+	echo rs6000-bull-bosx
+	exit 0 ;;
+    DPX/2?00:B.O.S.:*:*)
+	echo m68k-bull-sysv3
+	exit 0 ;;
+    9000/[34]??:4.3bsd:1.*:*)
+	echo m68k-hp-bsd
+	exit 0 ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+	echo m68k-hp-bsd4.4
+	exit 0 ;;
+    9000/[34678]??:HP-UX:*:*)
+	case "${UNAME_MACHINE}" in
+	    9000/31? )            HP_ARCH=m68000 ;;
+	    9000/[34]?? )         HP_ARCH=m68k ;;
+	    9000/[678][0-9][0-9])
+              sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+              	{
+              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+              	case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+              	    switch (bits)
+              		{
+              		case 64: puts ("hppa2.0w"); break;
+              		case 32: puts ("hppa2.0n"); break;
+              		default: puts ("hppa2.0"); break;
+              		} break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+              	    puts ("hppa2.0"); break;
+              #endif
+              	default: puts ("hppa1.0"); break;
+              	}
+                  exit (0);
+              }
+EOF
+	(CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
+	rm -f $dummy.c $dummy
+	esac
+	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+	exit 0 ;;
+    3050*:HI-UX:*:*)
+	sed 's/^	//' << EOF >$dummy.c
+	#include <unistd.h>
+	int
+	main ()
+	{
+	  long cpu = sysconf (_SC_CPU_VERSION);
+	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+	     results, however.  */
+	  if (CPU_IS_PA_RISC (cpu))
+	    {
+	      switch (cpu)
+		{
+		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+		  default: puts ("hppa-hitachi-hiuxwe2"); break;
+		}
+	    }
+	  else if (CPU_IS_HP_MC68K (cpu))
+	    puts ("m68k-hitachi-hiuxwe2");
+	  else puts ("unknown-hitachi-hiuxwe2");
+	  exit (0);
+	}
+EOF
+	$CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
+	rm -f $dummy.c $dummy
+	echo unknown-hitachi-hiuxwe2
+	exit 0 ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+	echo hppa1.1-hp-bsd
+	exit 0 ;;
+    9000/8??:4.3bsd:*:*)
+	echo hppa1.0-hp-bsd
+	exit 0 ;;
+    *9??*:MPE/iX:*:*)
+	echo hppa1.0-hp-mpeix
+	exit 0 ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+	echo hppa1.1-hp-osf
+	exit 0 ;;
+    hp8??:OSF1:*:*)
+	echo hppa1.0-hp-osf
+	exit 0 ;;
+    i?86:OSF1:*:*)
+	if [ -x /usr/sbin/sysversion ] ; then
+	    echo ${UNAME_MACHINE}-unknown-osf1mk
+	else
+	    echo ${UNAME_MACHINE}-unknown-osf1
+	fi
+	exit 0 ;;
+    parisc*:Lites*:*:*)
+	echo hppa1.1-hp-lites
+	exit 0 ;;
+    hppa*:OpenBSD:*:*)
+	echo hppa-unknown-openbsd
+	exit 0 ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+	echo c1-convex-bsd
+        exit 0 ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+        exit 0 ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+	echo c34-convex-bsd
+        exit 0 ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+	echo c38-convex-bsd
+        exit 0 ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+	echo c4-convex-bsd
+        exit 0 ;;
+    CRAY*X-MP:*:*:*)
+	echo xmp-cray-unicos
+        exit 0 ;;
+    CRAY*Y-MP:*:*:*)
+	echo ymp-cray-unicos${UNAME_RELEASE}
+	exit 0 ;;
+    CRAY*[A-Z]90:*:*:*)
+	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
+	exit 0 ;;
+    CRAY*TS:*:*:*)
+	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*T3E:*:*:*)
+	echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY*SV1:*:*:*)
+	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+	exit 0 ;;
+    CRAY-2:*:*:*)
+	echo cray2-cray-unicos
+        exit 0 ;;
+    F300:UNIX_System_V:*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit 0 ;;
+    F301:UNIX_System_V:*:*)
+       echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
+       exit 0 ;;
+    hp300:OpenBSD:*:*)
+	echo m68k-unknown-openbsd${UNAME_RELEASE}
+	exit 0 ;;
+    i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    sparc*:BSD/OS:*:*)
+	echo sparc-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:BSD/OS:*:*)
+	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+	exit 0 ;;
+    *:FreeBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+	exit 0 ;;
+    *:OpenBSD:*:*)
+	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+	exit 0 ;;
+    i*:CYGWIN*:*)
+	echo ${UNAME_MACHINE}-pc-cygwin
+	exit 0 ;;
+    i*:MINGW*:*)
+	echo ${UNAME_MACHINE}-pc-mingw32
+	exit 0 ;;
+    i*:PW*:*)
+	echo ${UNAME_MACHINE}-pc-pw32
+	exit 0 ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+	# How do we know it's Interix rather than the generic POSIX subsystem?
+	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+	# UNAME_MACHINE based on the output of uname instead of i386?
+	echo i386-pc-interix
+	exit 0 ;;
+    i*:UWIN*:*)
+	echo ${UNAME_MACHINE}-pc-uwin
+	exit 0 ;;
+    p*:CYGWIN*:*)
+	echo powerpcle-unknown-cygwin
+	exit 0 ;;
+    prep*:SunOS:5.*:*)
+	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+	exit 0 ;;
+    *:GNU:*:*)
+	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+	exit 0 ;;
+    i*86:Minix:*:*)
+	echo ${UNAME_MACHINE}-pc-minix
+	exit 0 ;;
+    *:Linux:*:*)
+
+	# The BFD linker knows what the default object file format is, so
+	# first see if it will tell us. cd to the root directory to prevent
+	# problems with other programs or directories called `ld' in the path.
+	ld_help_string=`cd /; ld --help 2>&1`
+	ld_supported_emulations=`echo $ld_help_string \
+			 | sed -ne '/supported emulations:/!d
+				    s/[ 	][ 	]*/ /g
+				    s/.*supported emulations: *//
+				    s/ .*//
+				    p'`
+        case "$ld_supported_emulations" in
+	  *ia64)
+		echo "${UNAME_MACHINE}-unknown-linux"
+		exit 0
+		;;
+	  i?86linux)
+		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+		exit 0
+		;;
+	  elf_i?86)
+		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+		;;
+	  i?86coff)
+		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+		exit 0
+		;;
+	  sparclinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  armlinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32arm*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
+		exit 0
+		;;
+	  armelf_linux*)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	  m68klinux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
+		exit 0
+		;;
+	  elf32ppc | elf32ppclinux)
+		# Determine Lib Version
+		cat >$dummy.c <<EOF
+#include <features.h>
+#if defined(__GLIBC__)
+extern char __libc_version[];
+extern char __libc_release[];
+#endif
+main(argc, argv)
+     int argc;
+     char *argv[];
+{
+#if defined(__GLIBC__)
+  printf("%s %s\n", __libc_version, __libc_release);
+#else
+  printf("unkown\n");
+#endif
+  return 0;
+}
+EOF
+		LIBC=""
+		$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
+		if test "$?" = 0 ; then
+			./$dummy | grep 1\.99 > /dev/null
+			if test "$?" = 0 ; then
+				LIBC="libc1"
+			fi
+		fi
+		rm -f $dummy.c $dummy
+		echo powerpc-unknown-linux-gnu${LIBC}
+		exit 0
+		;;
+	  shelf_linux)
+		echo "${UNAME_MACHINE}-unknown-linux-gnu"
+		exit 0
+		;;
+	esac
+
+	if test "${UNAME_MACHINE}" = "alpha" ; then
+		cat <<EOF >$dummy.s
+			.data
+		\$Lformat:
+			.byte 37,100,45,37,120,10,0	# "%d-%x\n"
+
+			.text
+			.globl main
+			.align 4
+			.ent main
+		main:
+			.frame \$30,16,\$26,0
+			ldgp \$29,0(\$27)
+			.prologue 1
+			.long 0x47e03d80 # implver \$0
+			lda \$2,-1
+			.long 0x47e20c21 # amask \$2,\$1
+			lda \$16,\$Lformat
+			mov \$0,\$17
+			not \$1,\$18
+			jsr \$26,printf
+			ldgp \$29,0(\$26)
+			mov 0,\$16
+			jsr \$26,exit
+			.end main
+EOF
+		LIBC=""
+		$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+		if test "$?" = 0 ; then
+			case `./$dummy` in
+			0-0)
+				UNAME_MACHINE="alpha"
+				;;
+			1-0)
+				UNAME_MACHINE="alphaev5"
+				;;
+			1-1)
+				UNAME_MACHINE="alphaev56"
+				;;
+			1-101)
+				UNAME_MACHINE="alphapca56"
+				;;
+			2-303)
+				UNAME_MACHINE="alphaev6"
+				;;
+			2-307)
+				UNAME_MACHINE="alphaev67"
+				;;
+			esac
+
+			objdump --private-headers $dummy | \
+			  grep ld.so.1 > /dev/null
+			if test "$?" = 0 ; then
+				LIBC="libc1"
+			fi
+		fi
+		rm -f $dummy.s $dummy
+		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
+	elif test "${UNAME_MACHINE}" = "mips" ; then
+	  cat >$dummy.c <<EOF
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __MIPSEB__
+  printf ("%s-unknown-linux-gnu\n", argv[1]);
+#endif
+#ifdef __MIPSEL__
+  printf ("%sel-unknown-linux-gnu\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	elif test "${UNAME_MACHINE}" = "s390"; then
+	  echo s390-ibm-linux && exit 0
+	elif test "${UNAME_MACHINE}" = "x86_64"; then
+	  echo x86_64-unknown-linux-gnu && exit 0
+	else
+	  # Either a pre-BFD a.out linker (linux-gnuoldld)
+	  # or one that does not give us useful --help.
+	  # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
+	  # If ld does not provide *any* "supported emulations:"
+	  # that means it is gnuoldld.
+	  echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
+	  test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
+
+	  case "${UNAME_MACHINE}" in
+	  i?86)
+	    VENDOR=pc;
+	    ;;
+	  *)
+	    VENDOR=unknown;
+	    ;;
+	  esac
+	  # Determine whether the default compiler is a.out or elf
+	  cat >$dummy.c <<EOF
+#include <features.h>
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+	int main (int argc, char *argv[]) {
+#else
+	int main (argc, argv) int argc; char *argv[]; {
+#endif
+#ifdef __ELF__
+# ifdef __GLIBC__
+#  if __GLIBC__ >= 2
+    printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
+#  else
+    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+#  endif
+# else
+   printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
+# endif
+#else
+  printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
+#endif
+  return 0;
+}
+EOF
+	  $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
+	  rm -f $dummy.c $dummy
+	  test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
+	fi ;;
+# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
+# are messed up and put the nodename in both sysname and nodename.
+    i?86:DYNIX/ptx:4*:*)
+	echo i386-sequent-sysv4
+	exit 0 ;;
+    i?86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+	# I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+	exit 0 ;;
+    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
+	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+	else
+		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+	fi
+	exit 0 ;;
+    i?86:*:5:7*)
+        # Fixed at (any) Pentium or better
+        UNAME_MACHINE=i586
+        if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
+	    echo ${UNAME_MACHINE}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
+	else
+	    echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
+	fi
+	exit 0 ;;
+    i?86:*:3.2:*)
+	if test -f /usr/options/cb.name; then
+		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+	elif /bin/uname -X 2>/dev/null >/dev/null ; then
+		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
+		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
+		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
+			&& UNAME_MACHINE=i586
+		(/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		(/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
+			&& UNAME_MACHINE=i686
+		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+	else
+		echo ${UNAME_MACHINE}-pc-sysv32
+	fi
+	exit 0 ;;
+    i?86:*DOS:*:*)
+	echo ${UNAME_MACHINE}-pc-msdosdjgpp
+	exit 0 ;;
+    pc:*:*:*)
+	# Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+	echo i386-pc-msdosdjgpp
+        exit 0 ;;
+    Intel:Mach:3*:*)
+	echo i386-pc-mach3
+	exit 0 ;;
+    paragon:*:*:*)
+	echo i860-intel-osf1
+	exit 0 ;;
+    i860:*:4.*:*) # i860-SVR4
+	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+	else # Add other i860-SVR4 vendors below as they are discovered.
+	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+	fi
+	exit 0 ;;
+    mini*:CTIX:SYS*5:*)
+	# "miniframe"
+	echo m68010-convergent-sysv
+	exit 0 ;;
+    M68*:*:R3V[567]*:*)
+	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
+    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
+	OS_REL=''
+	test -r /etc/.relid \
+	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
+	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && echo i486-ncr-sysv4 && exit 0 ;;
+    m68*:LynxOS:2.*:*)
+	echo m68k-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    mc68030:UNIX_System_V:4.*:*)
+	echo m68k-atari-sysv4
+	exit 0 ;;
+    i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
+	echo i386-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    TSUNAMI:LynxOS:2.*:*)
+	echo sparc-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
+	echo rs6000-unknown-lynxos${UNAME_RELEASE}
+	exit 0 ;;
+    SM[BE]S:UNIX_SV:*:*)
+	echo mips-dde-sysv${UNAME_RELEASE}
+	exit 0 ;;
+    RM*:ReliantUNIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    RM*:SINIX-*:*:*)
+	echo mips-sni-sysv4
+	exit 0 ;;
+    *:SINIX-*:*:*)
+	if uname -p 2>/dev/null >/dev/null ; then
+		UNAME_MACHINE=`(uname -p) 2>/dev/null`
+		echo ${UNAME_MACHINE}-sni-sysv4
+	else
+		echo ns32k-sni-sysv
+	fi
+	exit 0 ;;
+    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                           # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit 0 ;;
+    *:UNIX_System_V:4*:FTX*)
+	# From Gerald Hewes <hewes@openmarket.com>.
+	# How about differentiating between stratus architectures? -djm
+	echo hppa1.1-stratus-sysv4
+	exit 0 ;;
+    *:*:*:FTX*)
+	# From seanf@swdc.stratus.com.
+	echo i860-stratus-sysv4
+	exit 0 ;;
+    mc68*:A/UX:*:*)
+	echo m68k-apple-aux${UNAME_RELEASE}
+	exit 0 ;;
+    news*:NEWS-OS:6*:*)
+	echo mips-sony-newsos6
+	exit 0 ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+	if [ -d /usr/nec ]; then
+	        echo mips-nec-sysv${UNAME_RELEASE}
+	else
+	        echo mips-unknown-sysv${UNAME_RELEASE}
+	fi
+        exit 0 ;;
+    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
+	echo powerpc-be-beos
+	exit 0 ;;
+    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
+	echo powerpc-apple-beos
+	exit 0 ;;
+    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
+	echo i586-pc-beos
+	exit 0 ;;
+    SX-4:SUPER-UX:*:*)
+	echo sx4-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    SX-5:SUPER-UX:*:*)
+	echo sx5-nec-superux${UNAME_RELEASE}
+	exit 0 ;;
+    Power*:Rhapsody:*:*)
+	echo powerpc-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Rhapsody:*:*)
+	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+	exit 0 ;;
+    *:Darwin:*:*)
+	echo `uname -p`-apple-darwin${UNAME_RELEASE}
+	exit 0 ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+	if test "${UNAME_MACHINE}" = "x86pc"; then
+		UNAME_MACHINE=pc
+	fi
+	echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+	exit 0 ;;
+    *:QNX:*:4*)
+	echo i386-pc-qnx
+	exit 0 ;;
+    NSR-[KW]:NONSTOP_KERNEL:*:*)
+	echo nsr-tandem-nsk${UNAME_RELEASE}
+	exit 0 ;;
+    BS2000:POSIX*:*:*)
+	echo bs2000-siemens-sysv
+	exit 0 ;;
+    DS/*:UNIX_System_V:*:*)
+	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+	exit 0 ;;
+    *:Plan9:*:*)
+	# "uname -m" is not consistent, so use $cputype instead. 386
+	# is converted to i386 for consistency with other x86
+	# operating systems.
+	if test "$cputype" = "386"; then
+	    UNAME_MACHINE=i386
+	else
+	    UNAME_MACHINE="$cputype"
+	fi
+	echo ${UNAME_MACHINE}-unknown-plan9
+	exit 0 ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+	  ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+	printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+	printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+#if !defined (ultrix)
+  printf ("vax-dec-bsd\n"); exit (0);
+#else
+  printf ("vax-dec-ultrix\n"); exit (0);
+#endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
+rm -f $dummy.c $dummy
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+	echo c1-convex-bsd
+	exit 0 ;;
+    c2*)
+	if getsysinfo -f scalar_acc
+	then echo c32-convex-bsd
+	else echo c2-convex-bsd
+	fi
+	exit 0 ;;
+    c34*)
+	echo c34-convex-bsd
+	exit 0 ;;
+    c38*)
+	echo c38-convex-bsd
+	exit 0 ;;
+    c4*)
+	echo c4-convex-bsd
+	exit 0 ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
+
+    ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/config.sub	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,1328 @@
+#! /bin/sh
+# Configuration validation subroutine script, version 1.1.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+#   Free Software Foundation, Inc.
+
+version='2000-09-11'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Please send patches to <config-patches@gnu.org>.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#	CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#	CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help               print this help, then exit
+  -V, --version            print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case "$1" in
+    --version | --vers* | -V )
+       echo "$version" ; exit 0 ;;
+    --help | --h* | -h )
+       echo "$usage"; exit 0 ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )	# Use stdin as input.
+       break ;;
+    -* )
+       exec >&2
+       echo "$me: invalid option $1"
+       echo "$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit 0;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+	-sun*os*)
+		# Prevent following clause from handling this invalid input.
+		;;
+	-dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+	-att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+	-unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+	-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+	-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+	-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+	-apple | -axis)
+		os=
+		basic_machine=$1
+		;;
+	-sim | -cisco | -oki | -wec | -winbond)
+		os=
+		basic_machine=$1
+		;;
+	-scout)
+		;;
+	-wrs)
+		os=-vxworks
+		basic_machine=$1
+		;;
+	-hiux*)
+		os=-hiuxwe2
+		;;
+	-sco5)
+		os=-sco3.2v5
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco4)
+		os=-sco3.2v4
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2.[4-9]*)
+		os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco3.2v[4-9]*)
+		# Don't forget version if it is 3.2v4 or newer.
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-sco*)
+		os=-sco3.2v2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-udk*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-isc)
+		os=-isc2.2
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-clix*)
+		basic_machine=clipper-intergraph
+		;;
+	-isc*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+		;;
+	-lynx*)
+		os=-lynxos
+		;;
+	-ptx*)
+		basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+		;;
+	-windowsnt*)
+		os=`echo $os | sed -e 's/windowsnt/winnt/'`
+		;;
+	-psos*)
+		os=-psos
+		;;
+	-mint | -mint[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+	# Recognize the basic CPU types without company name.
+	# Some are omitted here because they have special meanings below.
+	tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
+		| arme[lb] | armv[2345] | armv[345][lb] | pyramid | mn10200 | mn10300 | tron | a29k \
+		| 580 | i960 | h8300 \
+		| x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
+		| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
+		| hppa64 \
+		| alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+		| alphaev6[78] \
+		| we32k | ns16k | clipper | i370 | sh | sh[34] \
+		| powerpc | powerpcle \
+		| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
+		| mips64orion | mips64orionel | mipstx39 | mipstx39el \
+		| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
+		| mips64vr5000 | miprs64vr5000el | mcore \
+		| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
+		| thumb | d10v | d30v | fr30 | avr)
+		basic_machine=$basic_machine-unknown
+		;;
+	m6811 | m68hc11 | m6812 | m68hc12)
+		# Motorola 68HC11/12.
+		basic_machine=$basic_machine-unknown
+		os=-none
+		;;
+	m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
+		;;
+
+	# We use `pc' rather than `unknown'
+	# because (1) that's what they normally are, and
+	# (2) the word "unknown" tends to confuse beginning users.
+	i[234567]86 | x86_64)
+	  basic_machine=$basic_machine-pc
+	  ;;
+	# Object if more than one company name word.
+	*-*-*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+	# Recognize the basic CPU types with company name.
+	# FIXME: clean up the formatting here.
+	vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+	      | m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
+	      | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
+	      | power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
+	      | xmp-* | ymp-* \
+	      | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
+	      | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+	      | hppa2.0n-* | hppa64-* \
+	      | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+	      | alphaev6[78]-* \
+	      | we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
+	      | clipper-* | orion-* \
+	      | sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
+	      | sparc64-* | sparcv9-* | sparc86x-* | mips16-* | mips64-* | mipsel-* \
+	      | mips64el-* | mips64orion-* | mips64orionel-* \
+	      | mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
+	      | mipstx39-* | mipstx39el-* | mcore-* \
+	      | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
+	      | m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
+	      | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+	      | bs2000-* | tic54x-* | c54x-* | x86_64-*)
+		;;
+	# Recognize the various machine names and aliases which stand
+	# for a CPU type and a company and sometimes even an OS.
+	386bsd)
+		basic_machine=i386-unknown
+		os=-bsd
+		;;
+	3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+		basic_machine=m68000-att
+		;;
+	3b*)
+		basic_machine=we32k-att
+		;;
+	a29khif)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	adobe68k)
+		basic_machine=m68010-adobe
+		os=-scout
+		;;
+	alliant | fx80)
+		basic_machine=fx80-alliant
+		;;
+	altos | altos3068)
+		basic_machine=m68k-altos
+		;;
+	am29k)
+		basic_machine=a29k-none
+		os=-bsd
+		;;
+	amdahl)
+		basic_machine=580-amdahl
+		os=-sysv
+		;;
+	amiga | amiga-*)
+		basic_machine=m68k-unknown
+		;;
+	amigaos | amigados)
+		basic_machine=m68k-unknown
+		os=-amigaos
+		;;
+	amigaunix | amix)
+		basic_machine=m68k-unknown
+		os=-sysv4
+		;;
+	apollo68)
+		basic_machine=m68k-apollo
+		os=-sysv
+		;;
+	apollo68bsd)
+		basic_machine=m68k-apollo
+		os=-bsd
+		;;
+	aux)
+		basic_machine=m68k-apple
+		os=-aux
+		;;
+	balance)
+		basic_machine=ns32k-sequent
+		os=-dynix
+		;;
+	convex-c1)
+		basic_machine=c1-convex
+		os=-bsd
+		;;
+	convex-c2)
+		basic_machine=c2-convex
+		os=-bsd
+		;;
+	convex-c32)
+		basic_machine=c32-convex
+		os=-bsd
+		;;
+	convex-c34)
+		basic_machine=c34-convex
+		os=-bsd
+		;;
+	convex-c38)
+		basic_machine=c38-convex
+		os=-bsd
+		;;
+	cray | ymp)
+		basic_machine=ymp-cray
+		os=-unicos
+		;;
+	cray2)
+		basic_machine=cray2-cray
+		os=-unicos
+		;;
+	[ctj]90-cray)
+		basic_machine=c90-cray
+		os=-unicos
+		;;
+	crds | unos)
+		basic_machine=m68k-crds
+		;;
+	cris | cris-* | etrax*)
+		basic_machine=cris-axis
+		;;
+	da30 | da30-*)
+		basic_machine=m68k-da30
+		;;
+	decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+		basic_machine=mips-dec
+		;;
+	delta | 3300 | motorola-3300 | motorola-delta \
+	      | 3300-motorola | delta-motorola)
+		basic_machine=m68k-motorola
+		;;
+	delta88)
+		basic_machine=m88k-motorola
+		os=-sysv3
+		;;
+	dpx20 | dpx20-*)
+		basic_machine=rs6000-bull
+		os=-bosx
+		;;
+	dpx2* | dpx2*-bull)
+		basic_machine=m68k-bull
+		os=-sysv3
+		;;
+	ebmon29k)
+		basic_machine=a29k-amd
+		os=-ebmon
+		;;
+	elxsi)
+		basic_machine=elxsi-elxsi
+		os=-bsd
+		;;
+	encore | umax | mmax)
+		basic_machine=ns32k-encore
+		;;
+	es1800 | OSE68k | ose68k | ose | OSE)
+		basic_machine=m68k-ericsson
+		os=-ose
+		;;
+	fx2800)
+		basic_machine=i860-alliant
+		;;
+	genix)
+		basic_machine=ns32k-ns
+		;;
+	gmicro)
+		basic_machine=tron-gmicro
+		os=-sysv
+		;;
+	h3050r* | hiux*)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	h8300hms)
+		basic_machine=h8300-hitachi
+		os=-hms
+		;;
+	h8300xray)
+		basic_machine=h8300-hitachi
+		os=-xray
+		;;
+	h8500hms)
+		basic_machine=h8500-hitachi
+		os=-hms
+		;;
+	harris)
+		basic_machine=m88k-harris
+		os=-sysv3
+		;;
+	hp300-*)
+		basic_machine=m68k-hp
+		;;
+	hp300bsd)
+		basic_machine=m68k-hp
+		os=-bsd
+		;;
+	hp300hpux)
+		basic_machine=m68k-hp
+		os=-hpux
+		;;
+	hp3k9[0-9][0-9] | hp9[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k2[0-9][0-9] | hp9k31[0-9])
+		basic_machine=m68000-hp
+		;;
+	hp9k3[2-9][0-9])
+		basic_machine=m68k-hp
+		;;
+	hp9k6[0-9][0-9] | hp6[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hp9k7[0-79][0-9] | hp7[0-79][0-9])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k78[0-9] | hp78[0-9])
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+		# FIXME: really hppa2.0-hp
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][13679] | hp8[0-9][13679])
+		basic_machine=hppa1.1-hp
+		;;
+	hp9k8[0-9][0-9] | hp8[0-9][0-9])
+		basic_machine=hppa1.0-hp
+		;;
+	hppa-next)
+		os=-nextstep3
+		;;
+	hppaosf)
+		basic_machine=hppa1.1-hp
+		os=-osf
+		;;
+	hppro)
+		basic_machine=hppa1.1-hp
+		os=-proelf
+		;;
+	i370-ibm* | ibm*)
+		basic_machine=i370-ibm
+		;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+	i[34567]86v32)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv32
+		;;
+	i[34567]86v4*)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv4
+		;;
+	i[34567]86v)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-sysv
+		;;
+	i[34567]86sol2)
+		basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+		os=-solaris2
+		;;
+	i386mach)
+		basic_machine=i386-mach
+		os=-mach
+		;;
+	i386-vsta | vsta)
+		basic_machine=i386-unknown
+		os=-vsta
+		;;
+	i386-go32 | go32)
+		basic_machine=i386-unknown
+		os=-go32
+		;;
+	i386-mingw32 | mingw32)
+		basic_machine=i386-unknown
+		os=-mingw32
+		;;
+	i[34567]86-pw32 | pw32)
+		basic_machine=i586-unknown
+		os=-pw32
+		;;
+	iris | iris4d)
+		basic_machine=mips-sgi
+		case $os in
+		    -irix*)
+			;;
+		    *)
+			os=-irix4
+			;;
+		esac
+		;;
+	isi68 | isi)
+		basic_machine=m68k-isi
+		os=-sysv
+		;;
+	m88k-omron*)
+		basic_machine=m88k-omron
+		;;
+	magnum | m3230)
+		basic_machine=mips-mips
+		os=-sysv
+		;;
+	merlin)
+		basic_machine=ns32k-utek
+		os=-sysv
+		;;
+	miniframe)
+		basic_machine=m68000-convergent
+		;;
+	*mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+		basic_machine=m68k-atari
+		os=-mint
+		;;
+	mipsel*-linux*)
+		basic_machine=mipsel-unknown
+		os=-linux-gnu
+		;;
+	mips*-linux*)
+		basic_machine=mips-unknown
+		os=-linux-gnu
+		;;
+	mips3*-*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+		;;
+	mips3*)
+		basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+		;;
+	mmix*)
+		basic_machine=mmix-knuth
+		os=-mmixware
+		;;
+	monitor)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	msdos)
+		basic_machine=i386-unknown
+		os=-msdos
+		;;
+	mvs)
+		basic_machine=i370-ibm
+		os=-mvs
+		;;
+	ncr3000)
+		basic_machine=i486-ncr
+		os=-sysv4
+		;;
+	netbsd386)
+		basic_machine=i386-unknown
+		os=-netbsd
+		;;
+	netwinder)
+		basic_machine=armv4l-rebel
+		os=-linux
+		;;
+	news | news700 | news800 | news900)
+		basic_machine=m68k-sony
+		os=-newsos
+		;;
+	news1000)
+		basic_machine=m68030-sony
+		os=-newsos
+		;;
+	news-3600 | risc-news)
+		basic_machine=mips-sony
+		os=-newsos
+		;;
+	necv70)
+		basic_machine=v70-nec
+		os=-sysv
+		;;
+	next | m*-next )
+		basic_machine=m68k-next
+		case $os in
+		    -nextstep* )
+			;;
+		    -ns2*)
+		      os=-nextstep2
+			;;
+		    *)
+		      os=-nextstep3
+			;;
+		esac
+		;;
+	nh3000)
+		basic_machine=m68k-harris
+		os=-cxux
+		;;
+	nh[45]000)
+		basic_machine=m88k-harris
+		os=-cxux
+		;;
+	nindy960)
+		basic_machine=i960-intel
+		os=-nindy
+		;;
+	mon960)
+		basic_machine=i960-intel
+		os=-mon960
+		;;
+	np1)
+		basic_machine=np1-gould
+		;;
+	nsr-tandem)
+		basic_machine=nsr-tandem
+		;;
+	op50n-* | op60c-*)
+		basic_machine=hppa1.1-oki
+		os=-proelf
+		;;
+	OSE68000 | ose68000)
+		basic_machine=m68000-ericsson
+		os=-ose
+		;;
+	os68k)
+		basic_machine=m68k-none
+		os=-os68k
+		;;
+	pa-hitachi)
+		basic_machine=hppa1.1-hitachi
+		os=-hiuxwe2
+		;;
+	paragon)
+		basic_machine=i860-intel
+		os=-osf
+		;;
+	pbd)
+		basic_machine=sparc-tti
+		;;
+	pbb)
+		basic_machine=m68k-tti
+		;;
+        pc532 | pc532-*)
+		basic_machine=ns32k-pc532
+		;;
+	pentium | p5 | k5 | k6 | nexen)
+		basic_machine=i586-pc
+		;;
+	pentiumpro | p6 | 6x86 | athlon)
+		basic_machine=i686-pc
+		;;
+	pentiumii | pentium2)
+		basic_machine=i786-pc
+		;;
+	pentium-* | p5-* | k5-* | k6-* | nexen-*)
+		basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumpro-* | p6-* | 6x86-* | athlon-*)
+		basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pentiumii-* | pentium2-*)
+		basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	pn)
+		basic_machine=pn-gould
+		;;
+	power)	basic_machine=rs6000-ibm
+		;;
+	ppc)	basic_machine=powerpc-unknown
+	        ;;
+	ppc-*)	basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ppcle | powerpclittle | ppc-le | powerpc-little)
+		basic_machine=powerpcle-unknown
+	        ;;
+	ppcle-* | powerpclittle-*)
+		basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+		;;
+	ps2)
+		basic_machine=i386-ibm
+		;;
+	rom68k)
+		basic_machine=m68k-rom68k
+		os=-coff
+		;;
+	rm[46]00)
+		basic_machine=mips-siemens
+		;;
+	rtpc | rtpc-*)
+		basic_machine=romp-ibm
+		;;
+	sa29200)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	sequent)
+		basic_machine=i386-sequent
+		;;
+	sh)
+		basic_machine=sh-hitachi
+		os=-hms
+		;;
+	sparclite-wrs)
+		basic_machine=sparclite-wrs
+		os=-vxworks
+		;;
+	sps7)
+		basic_machine=m68k-bull
+		os=-sysv2
+		;;
+	spur)
+		basic_machine=spur-unknown
+		;;
+	st2000)
+		basic_machine=m68k-tandem
+		;;
+	stratus)
+		basic_machine=i860-stratus
+		os=-sysv4
+		;;
+	sun2)
+		basic_machine=m68000-sun
+		;;
+	sun2os3)
+		basic_machine=m68000-sun
+		os=-sunos3
+		;;
+	sun2os4)
+		basic_machine=m68000-sun
+		os=-sunos4
+		;;
+	sun3os3)
+		basic_machine=m68k-sun
+		os=-sunos3
+		;;
+	sun3os4)
+		basic_machine=m68k-sun
+		os=-sunos4
+		;;
+	sun4os3)
+		basic_machine=sparc-sun
+		os=-sunos3
+		;;
+	sun4os4)
+		basic_machine=sparc-sun
+		os=-sunos4
+		;;
+	sun4sol2)
+		basic_machine=sparc-sun
+		os=-solaris2
+		;;
+	sun3 | sun3-*)
+		basic_machine=m68k-sun
+		;;
+	sun4)
+		basic_machine=sparc-sun
+		;;
+	sun386 | sun386i | roadrunner)
+		basic_machine=i386-sun
+		;;
+	sv1)
+		basic_machine=sv1-cray
+		os=-unicos
+		;;
+	symmetry)
+		basic_machine=i386-sequent
+		os=-dynix
+		;;
+	t3e)
+		basic_machine=t3e-cray
+		os=-unicos
+		;;
+	tic54x | c54x*)
+		basic_machine=tic54x-unknown
+		os=-coff
+		;;
+	tx39)
+		basic_machine=mipstx39-unknown
+		;;
+	tx39el)
+		basic_machine=mipstx39el-unknown
+		;;
+	tower | tower-32)
+		basic_machine=m68k-ncr
+		;;
+	udi29k)
+		basic_machine=a29k-amd
+		os=-udi
+		;;
+	ultra3)
+		basic_machine=a29k-nyu
+		os=-sym1
+		;;
+	v810 | necv810)
+		basic_machine=v810-nec
+		os=-none
+		;;
+	vaxv)
+		basic_machine=vax-dec
+		os=-sysv
+		;;
+	vms)
+		basic_machine=vax-dec
+		os=-vms
+		;;
+	vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+	vxworks960)
+		basic_machine=i960-wrs
+		os=-vxworks
+		;;
+	vxworks68)
+		basic_machine=m68k-wrs
+		os=-vxworks
+		;;
+	vxworks29k)
+		basic_machine=a29k-wrs
+		os=-vxworks
+		;;
+	w65*)
+		basic_machine=w65-wdc
+		os=-none
+		;;
+	w89k-*)
+		basic_machine=hppa1.1-winbond
+		os=-proelf
+		;;
+	xmp)
+		basic_machine=xmp-cray
+		os=-unicos
+		;;
+        xps | xps100)
+		basic_machine=xps100-honeywell
+		;;
+	z8k-*-coff)
+		basic_machine=z8k-unknown
+		os=-sim
+		;;
+	none)
+		basic_machine=none-none
+		os=-none
+		;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+	w89k)
+		basic_machine=hppa1.1-winbond
+		;;
+	op50n)
+		basic_machine=hppa1.1-oki
+		;;
+	op60c)
+		basic_machine=hppa1.1-oki
+		;;
+	mips)
+		if [ x$os = x-linux-gnu ]; then
+			basic_machine=mips-unknown
+		else
+			basic_machine=mips-mips
+		fi
+		;;
+	romp)
+		basic_machine=romp-ibm
+		;;
+	rs6000)
+		basic_machine=rs6000-ibm
+		;;
+	vax)
+		basic_machine=vax-dec
+		;;
+	pdp11)
+		basic_machine=pdp11-dec
+		;;
+	we32k)
+		basic_machine=we32k-att
+		;;
+	sh3 | sh4)
+		base_machine=sh-unknown
+		;;
+	sparc | sparcv9)
+		basic_machine=sparc-sun
+		;;
+        cydra)
+		basic_machine=cydra-cydrome
+		;;
+	orion)
+		basic_machine=orion-highlevel
+		;;
+	orion105)
+		basic_machine=clipper-highlevel
+		;;
+	mac | mpw | mac-mpw)
+		basic_machine=m68k-apple
+		;;
+	pmac | pmac-mpw)
+		basic_machine=powerpc-apple
+		;;
+	c4x*)
+		basic_machine=c4x-none
+		os=-coff
+		;;
+	*)
+		echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+		exit 1
+		;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+	*-digital*)
+		basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+		;;
+	*-commodore*)
+		basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+		;;
+	*)
+		;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+	# -solaris* is a basic system type, with this one exception.
+	-solaris1 | -solaris1.*)
+		os=`echo $os | sed -e 's|solaris1|sunos4|'`
+		;;
+	-solaris)
+		os=-solaris2
+		;;
+	-svr4*)
+		os=-sysv4
+		;;
+	-unixware*)
+		os=-sysv4.2uw
+		;;
+	-gnu/linux*)
+		os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+		;;
+	# First accept the basic system types.
+	# The portable systems comes first.
+	# Each alternative MUST END IN A *, to match a version number.
+	# -sysv* is not here because it comes later, after sysvr4.
+	-gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+	      | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+	      | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+	      | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+	      | -aos* \
+	      | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+	      | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+	      | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \
+	      | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+	      | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+	      | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+	      | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+	      | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
+	      | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+	      | -openstep* | -oskit* | -conix* | -pw32*)
+	# Remember, each alternative MUST END IN *, to match a version number.
+		;;
+	-qnx*)
+		case $basic_machine in
+		    x86-* | i[34567]86-*)
+			;;
+		    *)
+			os=-nto$os
+			;;
+		esac
+		;;
+	-nto*)
+		os=-nto-qnx
+		;;
+	-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+	      | -windows* | -osx | -abug | -netware* | -os9* | -beos* \
+	      | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+		;;
+	-mac*)
+		os=`echo $os | sed -e 's|mac|macos|'`
+		;;
+	-linux*)
+		os=`echo $os | sed -e 's|linux|linux-gnu|'`
+		;;
+	-sunos5*)
+		os=`echo $os | sed -e 's|sunos5|solaris2|'`
+		;;
+	-sunos6*)
+		os=`echo $os | sed -e 's|sunos6|solaris3|'`
+		;;
+	-opened*)
+		os=-openedition
+		;;
+	-wince*)
+		os=-wince
+		;;
+	-osfrose*)
+		os=-osfrose
+		;;
+	-osf*)
+		os=-osf
+		;;
+	-utek*)
+		os=-bsd
+		;;
+	-dynix*)
+		os=-bsd
+		;;
+	-acis*)
+		os=-aos
+		;;
+	-386bsd)
+		os=-bsd
+		;;
+	-ctix* | -uts*)
+		os=-sysv
+		;;
+	-ns2 )
+	        os=-nextstep2
+		;;
+	-nsk*)
+		os=-nsk
+		;;
+	# Preserve the version number of sinix5.
+	-sinix5.*)
+		os=`echo $os | sed -e 's|sinix|sysv|'`
+		;;
+	-sinix*)
+		os=-sysv4
+		;;
+	-triton*)
+		os=-sysv3
+		;;
+	-oss*)
+		os=-sysv3
+		;;
+	-svr4)
+		os=-sysv4
+		;;
+	-svr3)
+		os=-sysv3
+		;;
+	-sysvr4)
+		os=-sysv4
+		;;
+	# This must come after -sysvr4.
+	-sysv*)
+		;;
+	-ose*)
+		os=-ose
+		;;
+	-es1800*)
+		os=-ose
+		;;
+	-xenix)
+		os=-xenix
+		;;
+        -*mint | -*MiNT)
+	        os=-mint
+		;;
+	-none)
+		;;
+	*)
+		# Get rid of the `-' at the beginning of $os.
+		os=`echo $os | sed 's/[^-]*-//'`
+		echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+		exit 1
+		;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+	*-acorn)
+		os=-riscix1.2
+		;;
+	arm*-rebel)
+		os=-linux
+		;;
+	arm*-semi)
+		os=-aout
+		;;
+        pdp11-*)
+		os=-none
+		;;
+	*-dec | vax-*)
+		os=-ultrix4.2
+		;;
+	m68*-apollo)
+		os=-domain
+		;;
+	i386-sun)
+		os=-sunos4.0.2
+		;;
+	m68000-sun)
+		os=-sunos3
+		# This also exists in the configure program, but was not the
+		# default.
+		# os=-sunos4
+		;;
+	m68*-cisco)
+		os=-aout
+		;;
+	mips*-cisco)
+		os=-elf
+		;;
+	mips*-*)
+		os=-elf
+		;;
+	*-tti)	# must be before sparc entry or we get the wrong os.
+		os=-sysv3
+		;;
+	sparc-* | *-sun)
+		os=-sunos4.1.1
+		;;
+	*-be)
+		os=-beos
+		;;
+	*-ibm)
+		os=-aix
+		;;
+	*-wec)
+		os=-proelf
+		;;
+	*-winbond)
+		os=-proelf
+		;;
+	*-oki)
+		os=-proelf
+		;;
+	*-hp)
+		os=-hpux
+		;;
+	*-hitachi)
+		os=-hiux
+		;;
+	i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+		os=-sysv
+		;;
+	*-cbm)
+		os=-amigaos
+		;;
+	*-dg)
+		os=-dgux
+		;;
+	*-dolphin)
+		os=-sysv3
+		;;
+	m68k-ccur)
+		os=-rtu
+		;;
+	m88k-omron*)
+		os=-luna
+		;;
+	*-next )
+		os=-nextstep
+		;;
+	*-sequent)
+		os=-ptx
+		;;
+	*-crds)
+		os=-unos
+		;;
+	*-ns)
+		os=-genix
+		;;
+	i370-*)
+		os=-mvs
+		;;
+	*-next)
+		os=-nextstep3
+		;;
+        *-gould)
+		os=-sysv
+		;;
+        *-highlevel)
+		os=-bsd
+		;;
+	*-encore)
+		os=-bsd
+		;;
+        *-sgi)
+		os=-irix
+		;;
+        *-siemens)
+		os=-sysv4
+		;;
+	*-masscomp)
+		os=-rtu
+		;;
+	f301-fujitsu)
+		os=-uxpv
+		;;
+	*-rom68k)
+		os=-coff
+		;;
+	*-*bug)
+		os=-coff
+		;;
+	*-apple)
+		os=-macos
+		;;
+	*-atari*)
+		os=-mint
+		;;
+	*)
+		os=-none
+		;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+	*-unknown)
+		case $os in
+			-riscix*)
+				vendor=acorn
+				;;
+			-sunos*)
+				vendor=sun
+				;;
+			-aix*)
+				vendor=ibm
+				;;
+			-beos*)
+				vendor=be
+				;;
+			-hpux*)
+				vendor=hp
+				;;
+			-mpeix*)
+				vendor=hp
+				;;
+			-hiux*)
+				vendor=hitachi
+				;;
+			-unos*)
+				vendor=crds
+				;;
+			-dgux*)
+				vendor=dg
+				;;
+			-luna*)
+				vendor=omron
+				;;
+			-genix*)
+				vendor=ns
+				;;
+			-mvs* | -opened*)
+				vendor=ibm
+				;;
+			-ptx*)
+				vendor=sequent
+				;;
+			-vxsim* | -vxworks*)
+				vendor=wrs
+				;;
+			-aux*)
+				vendor=apple
+				;;
+			-hms*)
+				vendor=hitachi
+				;;
+			-mpw* | -macos*)
+				vendor=apple
+				;;
+			-*mint | -*MiNT)
+				vendor=atari
+				;;
+		esac
+		basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+		;;
+esac
+
+echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/configure.in	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,86 @@
+dnl Process this file with autoconf to produce a configure script.
+AC_INIT(README)
+
+dnl Setup for automake
+SDL_VERSION=1.2.0
+AM_INIT_AUTOMAKE(SDL_tests, $SDL_VERSION)
+
+dnl Detect the canonical host and target build environment
+AC_CANONICAL_HOST
+AC_CANONICAL_TARGET
+
+dnl Check for tools
+
+AC_PROG_CC
+
+dnl Check for compiler environment
+
+AC_C_CONST
+
+dnl Figure out which math library to use
+case "$target" in
+    *-*-cygwin* | *-*-mingw32*)
+        MATHLIB=""
+        SYS_GL_LIBS="-lopengl32"
+        ;;
+    *-*-beos*)
+        MATHLIB=""
+        SYS_GL_LIBS="-lGL"
+        ;;
+    *-*-darwin*)
+        MATHLIB=""
+        SYS_GL_LIBS=""
+        ;;
+    *-*-aix*)
+        if test x$ac_cv_prog_gcc = xyes; then
+            CFLAGS="-mthreads"
+	fi
+        SYS_GL_LIBS=""
+        ;;
+    *)
+        MATHLIB="-lm"
+        AC_PATH_X
+        AC_PATH_XTRA
+        if test x$have_x = xyes; then
+            CFLAGS="$CFLAGS $X_CFLAGS"
+            SYS_GL_LIBS="$X_LIBS -lGL"
+        else
+            SYS_GL_LIBS="-lGL"
+        fi
+        ;;
+esac
+AC_SUBST(MATHLIB)
+
+dnl Check for SDL
+
+AM_PATH_SDL($SDL_VERSION,
+            :,
+	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
+)
+CFLAGS="$CFLAGS $SDL_CFLAGS"
+LIBS="$LIBS $SDL_LIBS"
+
+dnl Check for OpenGL
+AC_MSG_CHECKING(for OpenGL support)
+have_opengl=no
+AC_TRY_COMPILE([
+ #if defined(__APPLE__) && defined(__MACH__)
+ #include <OpenGL/gl.h>
+ #else
+ #include <GL/gl.h>
+ #endif
+],[
+],[
+have_opengl=yes
+])
+AC_MSG_RESULT($have_opengl)
+if test x$have_opengl = xyes; then
+    CFLAGS="$CFLAGS -DHAVE_OPENGL"
+    GL_LIBS="$SYS_GL_LIBS"
+else
+    GL_LIBS=""
+fi
+AC_SUBST(GL_LIBS)
+
+# Finally create all the generated files
+AC_OUTPUT([Makefile])
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/graywin.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,183 @@
+
+/* Simple program:  Fill a colormap with gray and stripe it down the screen */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+#include "SDL.h"
+
+#ifdef TEST_VGA16 /* Define this if you want to test VGA 16-color video modes */
+#define NUM_COLORS	16
+#else
+#define NUM_COLORS	256
+#endif
+
+/* Draw a randomly sized and colored box centered about (X,Y) */
+void DrawBox(SDL_Surface *screen, int X, int Y)
+{
+	static unsigned int seeded = 0;
+	SDL_Rect area;
+	Uint32 color;
+
+	/* Seed the random number generator */
+	if ( seeded == 0 ) {
+		srand(time(NULL));
+		seeded = 1;
+	}
+
+	/* Get the bounds of the rectangle */
+	area.w = (rand()%640);
+	area.h = (rand()%480);
+	area.x = X-(area.w/2);
+	area.y = Y-(area.h/2);
+	color = (rand()%NUM_COLORS);
+
+	/* Do it! */
+	SDL_FillRect(screen, &area, color);
+	SDL_UpdateRects(screen, 1, &area);
+}
+
+SDL_Surface *CreateScreen(Uint16 w, Uint16 h, Uint8 bpp, Uint32 flags)
+{
+	SDL_Surface *screen;
+	int i;
+	SDL_Color palette[NUM_COLORS];
+	Uint8 *buffer;
+
+	/* Set the video mode */
+	screen = SDL_SetVideoMode(w, h, bpp, flags);
+	if ( screen == NULL ) {
+		fprintf(stderr, "Couldn't set display mode: %s\n",
+							SDL_GetError());
+		return(NULL);
+	}
+	fprintf(stderr, "Screen is in %s mode\n",
+		(screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+
+	/* Set a gray colormap, reverse order from white to black */
+	for ( i=0; i<NUM_COLORS; ++i ) {
+		palette[i].r = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+		palette[i].g = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+		palette[i].b = (NUM_COLORS-1)-i * (256 / NUM_COLORS);
+	}
+	SDL_SetColors(screen, palette, 0, NUM_COLORS);
+
+	/* Set the surface pixels and refresh! */
+	if ( SDL_LockSurface(screen) < 0 ) {
+		fprintf(stderr, "Couldn't lock display surface: %s\n",
+							SDL_GetError());
+		return(NULL);
+	}
+	buffer = (Uint8 *)screen->pixels;
+	for ( i=0; i<screen->h; ++i ) {
+		memset(buffer,(i*(NUM_COLORS-1))/screen->h, screen->w);
+		buffer += screen->pitch;
+	}
+	SDL_UnlockSurface(screen);
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+	return(screen);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	Uint32 videoflags;
+	int    done;
+	SDL_Event event;
+	int width, height, bpp;
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+
+	/* See if we try to get a hardware colormap */
+	width = 640;
+	height = 480;
+	bpp = 8;
+	videoflags = SDL_SWSURFACE;
+	while ( argc > 1 ) {
+		--argc;
+		if ( argv[argc-1] && (strcmp(argv[argc-1], "-width") == 0) ) {
+			width = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( argv[argc-1] && (strcmp(argv[argc-1], "-height") == 0) ) {
+			height = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( argv[argc-1] && (strcmp(argv[argc-1], "-bpp") == 0) ) {
+			bpp = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( argv[argc] && (strcmp(argv[argc], "-hw") == 0) ) {
+			videoflags |= SDL_HWSURFACE;
+		} else
+		if ( argv[argc] && (strcmp(argv[argc], "-hwpalette") == 0) ) {
+			videoflags |= SDL_HWPALETTE;
+		} else
+		if ( argv[argc] && (strcmp(argv[argc], "-noframe") == 0) ) {
+			videoflags |= SDL_NOFRAME;
+		} else
+		if ( argv[argc] && (strcmp(argv[argc], "-fullscreen") == 0) ) {
+			videoflags |= SDL_FULLSCREEN;
+		} else {
+			fprintf(stderr, "Usage: %s [-warp] [-fullscreen]\n",
+								argv[0]);
+			exit(1);
+		}
+	}
+
+	/* Set a video mode */
+	screen = CreateScreen(width, height, bpp, videoflags);
+	if ( screen == NULL ) {
+		exit(2);
+	}
+		
+	/* Wait for a keystroke */
+	done = 0;
+	while ( !done && SDL_WaitEvent(&event) ) {
+		switch (event.type) {
+			case SDL_MOUSEBUTTONDOWN:
+				DrawBox(screen, event.button.x, event.button.y);
+				break;
+			case SDL_KEYDOWN:
+				/* Ignore ALT-TAB for windows */
+				if ( (event.key.keysym.sym == SDLK_LALT) ||
+				     (event.key.keysym.sym == SDLK_TAB) ) {
+					break;
+				}
+				/* Center the mouse on <SPACE> */
+				if ( event.key.keysym.sym == SDLK_SPACE ) {
+					SDL_WarpMouse(640/2, 480/2);
+					break;
+				}
+				/* Toggle fullscreen mode on <RETURN> */
+				if ( event.key.keysym.sym == SDLK_RETURN ) {
+					videoflags ^= SDL_FULLSCREEN;
+					screen = CreateScreen(
+						screen->w, screen->h,
+						screen->format->BitsPerPixel,
+								videoflags);
+					if ( screen == NULL ) {
+						fprintf(stderr,
+					"Couldn't toggle fullscreen mode\n");
+						done = 1;
+					}
+					break;
+				}
+				/* Any other key quits the application... */
+			case SDL_QUIT:
+				done = 1;
+				break;
+			default:
+				break;
+		}
+	}
+	SDL_Quit();
+	return(0);
+}
Binary file test/icon.bmp has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/install-sh	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,251 @@
+#!/bin/sh
+#
+# install - install a program, script, or datafile
+# This comes from X11R5 (mit/util/scripts/install.sh).
+#
+# Copyright 1991 by the Massachusetts Institute of Technology
+#
+# Permission to use, copy, modify, distribute, and sell this software and its
+# documentation for any purpose is hereby granted without fee, provided that
+# the above copyright notice appear in all copies and that both that
+# copyright notice and this permission notice appear in supporting
+# documentation, and that the name of M.I.T. not be used in advertising or
+# publicity pertaining to distribution of the software without specific,
+# written prior permission.  M.I.T. makes no representations about the
+# suitability of this software for any purpose.  It is provided "as is"
+# without express or implied warranty.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+transformbasename=""
+transform_arg=""
+instcmd="$mvprog"
+chmodcmd="$chmodprog 0755"
+chowncmd=""
+chgrpcmd=""
+stripcmd=""
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=""
+dst=""
+dir_arg=""
+
+while [ x"$1" != x ]; do
+    case $1 in
+	-c) instcmd="$cpprog"
+	    shift
+	    continue;;
+
+	-d) dir_arg=true
+	    shift
+	    continue;;
+
+	-m) chmodcmd="$chmodprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-o) chowncmd="$chownprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-g) chgrpcmd="$chgrpprog $2"
+	    shift
+	    shift
+	    continue;;
+
+	-s) stripcmd="$stripprog"
+	    shift
+	    continue;;
+
+	-t=*) transformarg=`echo $1 | sed 's/-t=//'`
+	    shift
+	    continue;;
+
+	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
+	    shift
+	    continue;;
+
+	*)  if [ x"$src" = x ]
+	    then
+		src=$1
+	    else
+		# this colon is to work around a 386BSD /bin/sh bug
+		:
+		dst=$1
+	    fi
+	    shift
+	    continue;;
+    esac
+done
+
+if [ x"$src" = x ]
+then
+	echo "install:	no input file specified"
+	exit 1
+else
+	true
+fi
+
+if [ x"$dir_arg" != x ]; then
+	dst=$src
+	src=""
+	
+	if [ -d $dst ]; then
+		instcmd=:
+		chmodcmd=""
+	else
+		instcmd=mkdir
+	fi
+else
+
+# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
+# might cause directories to be created, which would be especially bad 
+# if $src (and thus $dsttmp) contains '*'.
+
+	if [ -f $src -o -d $src ]
+	then
+		true
+	else
+		echo "install:  $src does not exist"
+		exit 1
+	fi
+	
+	if [ x"$dst" = x ]
+	then
+		echo "install:	no destination specified"
+		exit 1
+	else
+		true
+	fi
+
+# If destination is a directory, append the input filename; if your system
+# does not like double slashes in filenames, you may need to add some logic
+
+	if [ -d $dst ]
+	then
+		dst="$dst"/`basename $src`
+	else
+		true
+	fi
+fi
+
+## this sed command emulates the dirname command
+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
+
+# Make sure that the destination directory exists.
+#  this part is taken from Noah Friedman's mkinstalldirs script
+
+# Skip lots of stat calls in the usual case.
+if [ ! -d "$dstdir" ]; then
+defaultIFS='	
+'
+IFS="${IFS-${defaultIFS}}"
+
+oIFS="${IFS}"
+# Some sh's can't handle IFS=/ for some reason.
+IFS='%'
+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
+IFS="${oIFS}"
+
+pathcomp=''
+
+while [ $# -ne 0 ] ; do
+	pathcomp="${pathcomp}${1}"
+	shift
+
+	if [ ! -d "${pathcomp}" ] ;
+        then
+		$mkdirprog "${pathcomp}"
+	else
+		true
+	fi
+
+	pathcomp="${pathcomp}/"
+done
+fi
+
+if [ x"$dir_arg" != x ]
+then
+	$doit $instcmd $dst &&
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
+else
+
+# If we're going to rename the final executable, determine the name now.
+
+	if [ x"$transformarg" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		dstfile=`basename $dst $transformbasename | 
+			sed $transformarg`$transformbasename
+	fi
+
+# don't allow the sed command to completely eliminate the filename
+
+	if [ x"$dstfile" = x ] 
+	then
+		dstfile=`basename $dst`
+	else
+		true
+	fi
+
+# Make a temp file name in the proper directory.
+
+	dsttmp=$dstdir/#inst.$$#
+
+# Move or copy the file name to the temp name
+
+	$doit $instcmd $src $dsttmp &&
+
+	trap "rm -f ${dsttmp}" 0 &&
+
+# and set any options; do chmod last to preserve setuid bits
+
+# If any of these fail, we abort the whole thing.  If we want to
+# ignore errors from any of these, just make sure not to ignore
+# errors from the above "$doit $instcmd $src $dsttmp" command.
+
+	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
+
+# Now rename the file to the real destination.
+
+	$doit $rmcmd -f $dstdir/$dstfile &&
+	$doit $mvcmd $dsttmp $dstdir/$dstfile 
+
+fi &&
+
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/loopwave.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,102 @@
+
+/* Program to load a wave file and loop playing it using SDL sound */
+
+/* loopwaves.c is much more robust in handling WAVE files -- 
+	This is only for simple WAVEs
+*/
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_audio.h"
+
+struct {
+	SDL_AudioSpec spec;
+	Uint8   *sound;			/* Pointer to wave data */
+	Uint32   soundlen;		/* Length of wave data */
+	int      soundpos;		/* Current play position */
+} wave;
+
+void fillerup(void *unused, Uint8 *stream, int len)
+{
+	Uint8 *waveptr;
+	int    waveleft;
+
+	/* Set up the pointers */
+	waveptr = wave.sound + wave.soundpos;
+	waveleft = wave.soundlen - wave.soundpos;
+
+	/* Go! */
+	while ( waveleft <= len ) {
+		SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME);
+		stream += waveleft;
+		len -= waveleft;
+		waveptr = wave.sound;
+		waveleft = wave.soundlen;
+		wave.soundpos = 0;
+	}
+	SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME);
+	wave.soundpos += len;
+}
+
+static int done = 0;
+void poked(int sig)
+{
+	done = 1;
+}
+
+int main(int argc, char *argv[])
+{
+	char name[32];
+
+	/* Load the SDL library */
+	if ( SDL_Init(SDL_INIT_AUDIO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	if ( argv[1] == NULL ) {
+		fprintf(stderr, "Usage: %s <wavefile>\n", argv[0]);
+		exit(1);
+	}
+
+	/* Load the wave file into memory */
+	if ( SDL_LoadWAV(argv[1],
+			&wave.spec, &wave.sound, &wave.soundlen) == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s\n",
+						argv[1], SDL_GetError());
+		exit(1);
+	}
+	wave.spec.callback = fillerup;
+
+	/* Set the signals */
+#ifdef SIGHUP
+	signal(SIGHUP, poked);
+#endif
+	signal(SIGINT, poked);
+#ifdef SIGQUIT
+	signal(SIGQUIT, poked);
+#endif
+	signal(SIGTERM, poked);
+
+	/* Initialize fillerup() variables */
+	if ( SDL_OpenAudio(&wave.spec, NULL) < 0 ) {
+		fprintf(stderr, "Couldn't open audio: %s\n", SDL_GetError());
+		SDL_FreeWAV(wave.sound);
+		exit(2);
+	}
+	SDL_PauseAudio(0);
+
+	/* Let the audio run */
+	printf("Using audio driver: %s\n", SDL_AudioDriverName(name, 32));
+	while ( ! done && (SDL_GetAudioStatus() == SDL_AUDIO_PLAYING) )
+		SDL_Delay(1000);
+
+	/* Clean up on signal */
+	SDL_CloseAudio();
+	SDL_FreeWAV(wave.sound);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/missing	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,190 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+# Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+# Franc,ois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+case "$1" in
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]"
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing - GNU libit 0.0"
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+  aclocal)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acinclude.m4' or \`configure.in'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`configure.in'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`acconfig.h' or \`configure.in'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' configure.in`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+				       sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`configure.in'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+	   sed 's/\.am$/.in/' |
+	   while read f; do touch "$f"; done
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.y)
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.c
+	    fi
+	    SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" y.tab.h
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f y.tab.h ]; then
+	echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+	echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+	case "$LASTARG" in
+	*.l)
+	    SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+	    if [ -f "$SRCFILE" ]; then
+	         cp "$SRCFILE" lex.yy.c
+	    fi
+	  ;;
+	esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+	echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is missing on your system.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file`
+    fi
+    touch $file
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and you do not seem to have it handy on your
+         system.  You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequirements for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/mkinstalldirs	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,40 @@
+#! /bin/sh
+# mkinstalldirs --- make directory hierarchy
+# Author: Noah Friedman <friedman@prep.ai.mit.edu>
+# Created: 1993-05-16
+# Public domain
+
+# $Id$
+
+errstatus=0
+
+for file
+do
+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
+   shift
+
+   pathcomp=
+   for d
+   do
+     pathcomp="$pathcomp$d"
+     case "$pathcomp" in
+       -* ) pathcomp=./$pathcomp ;;
+     esac
+
+     if test ! -d "$pathcomp"; then
+        echo "mkdir $pathcomp"
+
+        mkdir "$pathcomp" || lasterr=$?
+
+        if test ! -d "$pathcomp"; then
+  	  errstatus=$lasterr
+        fi
+     fi
+
+     pathcomp="$pathcomp/"
+   done
+done
+
+exit $errstatus
+
+# mkinstalldirs ends here
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/picture.xbm	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,14 @@
+#define picture_width 32
+#define picture_height 32
+static char picture_bits[] = {
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x80, 0x01, 0x18,
+   0x64, 0x6f, 0xf6, 0x26, 0x0a, 0x00, 0x00, 0x50, 0xf2, 0xff, 0xff, 0x4f,
+   0x14, 0x04, 0x00, 0x28, 0x14, 0x0e, 0x00, 0x28, 0x10, 0x32, 0x00, 0x08,
+   0x94, 0x03, 0x00, 0x08, 0xf4, 0x04, 0x00, 0x08, 0xb0, 0x08, 0x00, 0x08,
+   0x34, 0x01, 0x00, 0x28, 0x34, 0x01, 0x00, 0x28, 0x12, 0x00, 0x40, 0x48,
+   0x12, 0x20, 0xa6, 0x48, 0x14, 0x50, 0x11, 0x29, 0x14, 0x50, 0x48, 0x2a,
+   0x10, 0x27, 0xac, 0x0e, 0xd4, 0x71, 0xe8, 0x0a, 0x74, 0x20, 0xa8, 0x0a,
+   0x14, 0x20, 0x00, 0x08, 0x10, 0x50, 0x00, 0x08, 0x14, 0x00, 0x00, 0x28,
+   0x14, 0x00, 0x00, 0x28, 0xf2, 0xff, 0xff, 0x4f, 0x0a, 0x00, 0x00, 0x50,
+   0x64, 0x6f, 0xf6, 0x26, 0x18, 0x80, 0x01, 0x18, 0x00, 0x00, 0x00, 0x00,
+   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
Binary file test/sail.bmp has changed
Binary file test/sample.bmp has changed
Binary file test/sample.wav has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testalpha.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,440 @@
+
+/* Simple program:  Fill a colormap with gray and stripe it down the screen,
+		    Then move an alpha valued sprite around the screen.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+#define FRAME_TICKS	(1000/30)		/* 30 frames/second */
+
+/* Create a "light" -- a yellowish surface with variable alpha */
+SDL_Surface *CreateLight(SDL_Surface *screen, int radius)
+{
+	Uint8  trans, alphamask;
+	int    range, addition;
+	int    xdist, ydist;
+	Uint16 x, y;
+	Uint16 skip;
+	Uint32 pixel;
+	SDL_Surface *light;
+
+#ifdef LIGHT_16BIT
+	Uint16 *buf;
+
+	/* Create a 16 (4/4/4/4) bpp square with a full 4-bit alpha channel */
+	/* Note: this isn't any faster than a 32 bit alpha surface */
+	alphamask = 0x0000000F;
+	light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 16,
+			0x0000F000, 0x00000F00, 0x000000F0, alphamask);
+#else
+	Uint32 *buf;
+
+	/* Create a 32 (8/8/8/8) bpp square with a full 8-bit alpha channel */
+	alphamask = 0x000000FF;
+	light = SDL_CreateRGBSurface(SDL_SWSURFACE, 2*radius, 2*radius, 32,
+			0xFF000000, 0x00FF0000, 0x0000FF00, alphamask);
+	if ( light == NULL ) {
+		fprintf(stderr, "Couldn't create light: %s\n", SDL_GetError());
+		return(NULL);
+	}
+#endif
+
+	/* Fill with a light yellow-orange color */
+	skip = light->pitch-(light->w*light->format->BytesPerPixel);
+#ifdef LIGHT_16BIT
+	buf = (Uint16 *)light->pixels;
+#else
+	buf = (Uint32 *)light->pixels;
+#endif
+        /* Get a tranparent pixel value - we'll add alpha later */
+	pixel = SDL_MapRGBA(light->format, 0xFF, 0xDD, 0x88, 0);
+	for ( y=0; y<light->h; ++y ) {
+		for ( x=0; x<light->w; ++x ) {
+			*buf++ = pixel;
+		}
+		buf += skip;	/* Almost always 0, but just in case... */
+	}
+
+	/* Calculate alpha values for the surface. */
+#ifdef LIGHT_16BIT
+	buf = (Uint16 *)light->pixels;
+#else
+	buf = (Uint32 *)light->pixels;
+#endif
+	for ( y=0; y<light->h; ++y ) {
+		for ( x=0; x<light->w; ++x ) {
+			/* Slow distance formula (from center of light) */
+			xdist = x-(light->w/2);
+			ydist = y-(light->h/2);
+			range = (int)sqrt(xdist*xdist+ydist*ydist);
+
+			/* Scale distance to range of transparency (0-255) */
+			if ( range > radius ) {
+				trans = alphamask;
+			} else {
+				/* Increasing transparency with distance */
+				trans = (Uint8)((range*alphamask)/radius);
+
+				/* Lights are very transparent */
+				addition = (alphamask+1)/8;
+				if ( (int)trans+addition > alphamask ) {
+					trans = alphamask;
+				} else {
+					trans += addition;
+				}
+			}
+			/* We set the alpha component as the right N bits */
+			*buf++ |= (255-trans);
+		}
+		buf += skip;	/* Almost always 0, but just in case... */
+	}
+	/* Enable RLE acceleration of this alpha surface */
+	SDL_SetAlpha(light, SDL_SRCALPHA|SDL_RLEACCEL, 0);
+
+	/* We're done! */
+	return(light);
+}
+
+static Uint32 flashes = 0;
+static Uint32 flashtime = 0;
+
+void FlashLight(SDL_Surface *screen, SDL_Surface *light, int x, int y)
+{
+	SDL_Rect position;
+	Uint32   ticks1;
+	Uint32   ticks2;
+
+	/* Easy, center light */
+	position.x = x-(light->w/2);
+	position.y = y-(light->h/2);
+	position.w = light->w;
+	position.h = light->h;
+	ticks1 = SDL_GetTicks();
+	SDL_BlitSurface(light, NULL, screen, &position);
+	ticks2 = SDL_GetTicks();
+	SDL_UpdateRects(screen, 1, &position);
+	++flashes;
+
+	/* Update time spend doing alpha blitting */
+	flashtime += (ticks2-ticks1);
+}
+
+static int sprite_visible = 0;
+static SDL_Surface *sprite;
+static SDL_Surface *backing;
+static SDL_Rect    position;
+static int         x_vel, y_vel;
+static int	   alpha_vel;
+
+int LoadSprite(SDL_Surface *screen, char *file)
+{
+	SDL_Surface *converted;
+
+	/* Load the sprite image */
+	sprite = SDL_LoadBMP(file);
+	if ( sprite == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+		return(-1);
+	}
+
+	/* Set transparent pixel as the pixel at (0,0) */
+	if ( sprite->format->palette ) {
+		SDL_SetColorKey(sprite, SDL_SRCCOLORKEY,
+						*(Uint8 *)sprite->pixels);
+	}
+
+	/* Convert sprite to video format */
+	converted = SDL_DisplayFormat(sprite);
+	SDL_FreeSurface(sprite);
+	if ( converted == NULL ) {
+		fprintf(stderr, "Couldn't convert background: %s\n",
+							SDL_GetError());
+		return(-1);
+	}
+	sprite = converted;
+
+	/* Create the background */
+	backing = SDL_CreateRGBSurface(SDL_SWSURFACE, sprite->w, sprite->h, 8,
+								0, 0, 0, 0);
+	if ( backing == NULL ) {
+		fprintf(stderr, "Couldn't create background: %s\n",
+							SDL_GetError());
+		SDL_FreeSurface(sprite);
+		return(-1);
+	}
+
+	/* Convert background to video format */
+	converted = SDL_DisplayFormat(backing);
+	SDL_FreeSurface(backing);
+	if ( converted == NULL ) {
+		fprintf(stderr, "Couldn't convert background: %s\n",
+							SDL_GetError());
+		SDL_FreeSurface(sprite);
+		return(-1);
+	}
+	backing = converted;
+
+	/* Set the initial position of the sprite */
+	position.x = (screen->w-sprite->w)/2;
+	position.y = (screen->h-sprite->h)/2;
+	position.w = sprite->w;
+	position.h = sprite->h;
+	x_vel = 0; y_vel = 0;
+	alpha_vel = 1;
+
+	/* We're ready to roll. :) */
+	return(0);
+}
+
+void AttractSprite(Uint16 x, Uint16 y)
+{
+	x_vel = ((int)x-position.x)/10;
+	y_vel = ((int)y-position.y)/10;
+}
+
+void MoveSprite(SDL_Surface *screen, SDL_Surface *light)
+{
+	SDL_Rect updates[2];
+	int alpha;
+
+	/* Erase the sprite if it was visible */
+	if ( sprite_visible ) {
+		updates[0] = position;
+		SDL_BlitSurface(backing, NULL, screen, &updates[0]);
+	} else {
+		updates[0].x = 0; updates[0].y = 0;
+		updates[0].w = 0; updates[0].h = 0;
+		sprite_visible = 1;
+	}
+
+	/* Since the sprite is off the screen, we can do other drawing
+	   without being overwritten by the saved area behind the sprite.
+	 */
+	if ( light != NULL ) {
+		int x, y;
+
+		SDL_GetMouseState(&x, &y);
+		FlashLight(screen, light, x, y);
+	}
+	   
+	/* Move the sprite, bounce at the wall */
+	position.x += x_vel;
+	if ( (position.x < 0) || (position.x >= screen->w) ) {
+		x_vel = -x_vel;
+		position.x += x_vel;
+	}
+	position.y += y_vel;
+	if ( (position.y < 0) || (position.y >= screen->h) ) {
+		y_vel = -y_vel;
+		position.y += y_vel;
+	}
+
+	/* Update transparency (fade in and out) */
+	alpha = sprite->format->alpha;
+	if ( (alpha+alpha_vel) < 0 ) {
+		alpha_vel = -alpha_vel;
+	} else
+	if ( (alpha+alpha_vel) > 255 ) {
+		alpha_vel = -alpha_vel;
+	}
+	SDL_SetAlpha(sprite, SDL_SRCALPHA, (Uint8)(alpha+alpha_vel));
+
+	/* Save the area behind the sprite */
+	updates[1] = position;
+	SDL_BlitSurface(screen, &updates[1], backing, NULL);
+	
+	/* Blit the sprite onto the screen */
+	updates[1] = position;
+	SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
+
+	/* Make it so! */
+	SDL_UpdateRects(screen, 2, updates);
+}
+
+void WarpSprite(SDL_Surface *screen, int x, int y)
+{
+	SDL_Rect updates[2];
+
+	/* Erase, move, Draw, update */
+	updates[0] = position;
+	SDL_BlitSurface(backing, NULL, screen, &updates[0]);
+	position.x = x-sprite->w/2;	/* Center about X */
+	position.y = y-sprite->h/2;	/* Center about Y */
+	updates[1] = position;
+	SDL_BlitSurface(screen, &updates[1], backing, NULL);
+	updates[1] = position;
+	SDL_BlitSurface(sprite, NULL, screen, &updates[1]);
+	SDL_UpdateRects(screen, 2, updates);
+}
+
+int main(int argc, char *argv[])
+{
+	const SDL_VideoInfo *info;
+	SDL_Surface *screen;
+	Uint8  video_bpp;
+	Uint32 videoflags;
+	Uint8 *buffer;
+	int    i, done;
+	SDL_Event event;
+	SDL_Surface *light;
+	int mouse_pressed;
+	Uint32 ticks, lastticks;
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Alpha blending doesn't work well at 8-bit color */
+	info = SDL_GetVideoInfo();
+	if ( info->vfmt->BitsPerPixel > 8 ) {
+		video_bpp = info->vfmt->BitsPerPixel;
+	} else {
+		video_bpp = 16;
+	}
+	videoflags = SDL_SWSURFACE;
+	while ( argc > 1 ) {
+		--argc;
+		if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
+			video_bpp = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( strcmp(argv[argc], "-hw") == 0 ) {
+			videoflags |= SDL_HWSURFACE;
+		} else
+		if ( strcmp(argv[argc], "-warp") == 0 ) {
+			videoflags |= SDL_HWPALETTE;
+		} else
+		if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
+			videoflags |= SDL_FULLSCREEN;
+		} else {
+			fprintf(stderr, 
+			"Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n",
+								argv[0]);
+			exit(1);
+		}
+	}
+
+	/* Set 640x480 video mode */
+	if ( (screen=SDL_SetVideoMode(640,480,video_bpp,videoflags)) == NULL ) {
+		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
+						video_bpp, SDL_GetError());
+		exit(2);
+	}
+
+	/* Set the surface pixels and refresh! */
+	if ( SDL_LockSurface(screen) < 0 ) {
+		fprintf(stderr, "Couldn't lock the display surface: %s\n",
+							SDL_GetError());
+		exit(2);
+	}
+	buffer=(Uint8 *)screen->pixels;
+	for ( i=0; i<screen->h; ++i ) {
+		memset(buffer,(i*255)/screen->h, screen->pitch);
+		buffer += screen->pitch;
+	}
+	SDL_UnlockSurface(screen);
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+	/* Create the light */
+	light = CreateLight(screen, 82);
+	if ( light == NULL ) {
+		exit(1);
+	}
+
+	/* Load the sprite */
+	if ( LoadSprite(screen, "icon.bmp") < 0 ) {
+		SDL_FreeSurface(light);
+		exit(1);
+	}
+
+	/* Set a clipping rectangle to clip the outside edge of the screen */
+	{ SDL_Rect clip;
+		clip.x = 32;
+		clip.y = 32;
+		clip.w = screen->w-(2*32);
+		clip.h = screen->h-(2*32);
+		SDL_SetClipRect(screen, &clip);
+	}
+
+	/* Wait for a keystroke */
+	lastticks = SDL_GetTicks();
+	done = 0;
+	mouse_pressed = 0;
+	while ( !done ) {
+		/* Update the frame -- move the sprite */
+		if ( mouse_pressed ) {
+			MoveSprite(screen, light);
+			mouse_pressed = 0;
+		} else {
+			MoveSprite(screen, NULL);
+		}
+
+		/* Slow down the loop to 30 frames/second */
+		ticks = SDL_GetTicks();
+		if ( (ticks-lastticks) < FRAME_TICKS ) {
+#ifdef CHECK_SLEEP_GRANULARITY
+fprintf(stderr, "Sleeping %d ticks\n", FRAME_TICKS-(ticks-lastticks));
+#endif
+			SDL_Delay(FRAME_TICKS-(ticks-lastticks));
+#ifdef CHECK_SLEEP_GRANULARITY
+fprintf(stderr, "Slept %d ticks\n", (SDL_GetTicks()-ticks));
+#endif
+		}
+		lastticks = ticks;
+
+		/* Check for events */
+		while ( SDL_PollEvent(&event) ) {
+			switch (event.type) {
+				/* Attract sprite while mouse is held down */
+				case SDL_MOUSEMOTION:
+					if (event.motion.state != 0) {
+						AttractSprite(event.motion.x,
+								event.motion.y);
+						mouse_pressed = 1;
+					}
+					break;
+				case SDL_MOUSEBUTTONDOWN:
+					if ( event.button.button == 1 ) {
+						AttractSprite(event.button.x,
+						              event.button.y);
+						mouse_pressed = 1;
+					} else {
+						SDL_Rect area;
+
+						area.x = event.button.x-16;
+						area.y = event.button.y-16;
+						area.w = 32;
+						area.h = 32;
+						SDL_FillRect(screen, &area, 0);
+						SDL_UpdateRects(screen,1,&area);
+					}
+					break;
+				case SDL_KEYDOWN:
+					/* Any keypress quits the app... */
+				case SDL_QUIT:
+					done = 1;
+					break;
+				default:
+					break;
+			}
+		}
+	}
+	SDL_FreeSurface(light);
+	SDL_FreeSurface(sprite);
+	SDL_FreeSurface(backing);
+
+	/* Print out some timing information */
+	if ( flashes > 0 ) {
+		printf("%d alpha blits, ~%4.4f ms per blit\n", 
+			flashes, (float)flashtime/flashes);
+	}
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testbitmap.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,147 @@
+
+/* Simple program:  Test bitmap blits */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "picture.xbm"
+
+SDL_Surface *LoadXBM(SDL_Surface *screen, int w, int h, Uint8 *bits)
+{
+	SDL_Surface *bitmap;
+	Uint8 *line;
+
+	/* Allocate the bitmap */
+	bitmap = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, 1, 0, 0, 0, 0);
+	if ( bitmap == NULL ) {
+		fprintf(stderr, "Couldn't allocate bitmap: %s\n",
+						SDL_GetError());
+		return(NULL);
+	}
+
+	/* Copy the pixels */
+	line = (Uint8 *)bitmap->pixels;
+	w = (w+7)/8;
+	while ( h-- ) {
+		memcpy(line, bits, w);
+		/* X11 Bitmap images have the bits reversed */
+		{ int i, j; Uint8 *buf, byte;
+			for ( buf=line, i=0; i<w; ++i, ++buf ) {
+				byte = *buf;
+				*buf = 0;
+				for ( j=7; j>=0; --j ) {
+					*buf |= (byte&0x01)<<j;
+					byte >>= 1;
+				}
+			}
+		}
+		line += bitmap->pitch;
+		bits += w;
+	}
+	return(bitmap);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	SDL_Surface *bitmap;
+	Uint8  video_bpp;
+	Uint32 videoflags;
+	Uint8 *buffer;
+	int i, done;
+	SDL_Event event;
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	video_bpp = 0;
+	videoflags = SDL_SWSURFACE;
+	while ( argc > 1 ) {
+		--argc;
+		if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
+			video_bpp = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( strcmp(argv[argc], "-warp") == 0 ) {
+			videoflags |= SDL_HWPALETTE;
+		} else
+		if ( strcmp(argv[argc], "-hw") == 0 ) {
+			videoflags |= SDL_HWSURFACE;
+		} else
+		if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
+			videoflags |= SDL_FULLSCREEN;
+		} else {
+			fprintf(stderr,
+			"Usage: %s [-bpp N] [-warp] [-hw] [-fullscreen]\n",
+								argv[0]);
+			exit(1);
+		}
+	}
+
+	/* Set 640x480 video mode */
+	if ( (screen=SDL_SetVideoMode(640,480,video_bpp,videoflags)) == NULL ) {
+		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
+						video_bpp, SDL_GetError());
+		exit(2);
+	}
+
+	/* Set the surface pixels and refresh! */
+	if ( SDL_LockSurface(screen) < 0 ) {
+		fprintf(stderr, "Couldn't lock the display surface: %s\n",
+							SDL_GetError());
+		exit(2);
+	}
+	buffer=(Uint8 *)screen->pixels;
+	for ( i=0; i<screen->h; ++i ) {
+		memset(buffer,(i*255)/screen->h, screen->pitch);
+		buffer += screen->pitch;
+	}
+	SDL_UnlockSurface(screen);
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+	/* Load the bitmap */
+	bitmap = LoadXBM(screen, picture_width, picture_height,
+					(Uint8 *)picture_bits);
+	if ( bitmap == NULL ) {
+		exit(1);
+	}
+
+	/* Wait for a keystroke */
+	done = 0;
+	while ( !done ) {
+		/* Check for events */
+		while ( SDL_PollEvent(&event) ) {
+			switch (event.type) {
+				case SDL_MOUSEBUTTONDOWN: {
+					SDL_Rect dst;
+
+					dst.x = event.button.x - bitmap->w/2;
+					dst.y = event.button.y - bitmap->h/2;
+					dst.w = bitmap->w;
+					dst.h = bitmap->h;
+					SDL_BlitSurface(bitmap, NULL,
+								screen, &dst);
+					SDL_UpdateRects(screen,1,&dst);
+					}
+					break;
+				case SDL_KEYDOWN:
+					/* Any key press quits the app... */
+					done = 1;
+					break;
+				case SDL_QUIT:
+					done = 1;
+					break;
+				default:
+					break;
+			}
+		}
+	}
+	SDL_FreeSurface(bitmap);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testcdrom.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,189 @@
+
+/* Test the SDL CD-ROM audio functions */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include "SDL.h"
+
+
+static void PrintStatus(int driveindex, SDL_CD *cdrom)
+{
+	CDstatus status;
+	char *status_str;
+
+	status = SDL_CDStatus(cdrom);
+	switch (status) {
+		case CD_TRAYEMPTY:
+			status_str = "tray empty";
+			break;
+		case CD_STOPPED:
+			status_str = "stopped";
+			break;
+		case CD_PLAYING:
+			status_str = "playing";
+			break;
+		case CD_PAUSED:
+			status_str = "paused";
+			break;
+		case CD_ERROR:
+			status_str = "error state";
+			break;
+	}
+	printf("Drive %d status: %s\n", driveindex, status_str);
+	if ( status >= CD_PLAYING ) {
+		int m, s, f;
+		FRAMES_TO_MSF(cdrom->cur_frame, &m, &s, &f);
+		printf("Currently playing track %d, %d:%2.2d\n",
+			cdrom->track[cdrom->cur_track].id, m, s);
+	}
+}
+
+static void ListTracks(SDL_CD *cdrom)
+{
+	int i;
+	int m, s, f;
+
+	SDL_CDStatus(cdrom);
+	printf("Drive tracks: %d\n", cdrom->numtracks);
+	for ( i=0; i<cdrom->numtracks; ++i ) {
+		FRAMES_TO_MSF(cdrom->track[i].length, &m, &s, &f);
+		if ( f > 0 )
+			++s;
+		printf("\tTrack (index %d) %d: %d:%2.2d\n", i,
+					cdrom->track[i].id, m, s);
+	}
+}
+
+static void PrintUsage(char *argv0)
+{
+	fprintf(stderr, "Usage: %s [drive#] [command] [command] ...\n", argv0);
+	fprintf(stderr, "Where 'command' is one of:\n");
+	fprintf(stderr, "	-status\n");
+	fprintf(stderr, "	-list\n");
+	fprintf(stderr, "	-play [first_track] [first_frame] [num_tracks] [num_frames]\n");
+	fprintf(stderr, "	-pause\n");
+	fprintf(stderr, "	-resume\n");
+	fprintf(stderr, "	-stop\n");
+	fprintf(stderr, "	-eject\n");
+	fprintf(stderr, "	-sleep <milliseconds>\n");
+}
+
+int main(int argc, char *argv[])
+{
+	int drive;
+	int i;
+	SDL_CD *cdrom;
+
+	/* Initialize SDL first */
+	if ( SDL_Init(SDL_INIT_CDROM) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Find out how many CD-ROM drives are connected to the system */
+	if ( SDL_CDNumDrives() == 0 ) {
+		printf("No CD-ROM devices detected\n");
+		exit(0);
+	}
+	printf("Drives available: %d\n", SDL_CDNumDrives());
+	for ( i=0; i<SDL_CDNumDrives(); ++i ) {
+		printf("Drive %d:  \"%s\"\n", i, SDL_CDName(i));
+	}
+
+	/* Open the CD-ROM */
+	drive = 0;
+	i=1;
+	if ( argv[i] && isdigit(argv[i][0]) ) {
+		drive = atoi(argv[i++]);
+	}
+	cdrom = SDL_CDOpen(drive);
+	if ( cdrom == NULL ) {
+		fprintf(stderr, "Couldn't open drive %d: %s\n", drive,
+							SDL_GetError());
+		exit(2);
+	}
+#ifdef TEST_NULLCD
+	cdrom = NULL;
+#endif
+	
+	/* Find out which function to perform */
+	for ( ; argv[i]; ++i ) {
+		if ( strcmp(argv[i], "-status") == 0 ) {
+			/* PrintStatus(drive, cdrom); */
+		} else
+		if ( strcmp(argv[i], "-list") == 0 ) {
+			ListTracks(cdrom);
+		} else
+		if ( strcmp(argv[i], "-play") == 0 ) {
+			int strack, sframe;
+			int ntrack, nframe;
+
+			strack = 0;
+			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+				strack = atoi(argv[++i]);
+			}
+			sframe = 0;
+			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+				sframe = atoi(argv[++i]);
+			}
+			ntrack = 0;
+			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+				ntrack = atoi(argv[++i]);
+			}
+			nframe = 0;
+			if ( argv[i+1] && isdigit(argv[i+1][0]) ) {
+				nframe = atoi(argv[++i]);
+			}
+			if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
+				if ( SDL_CDPlayTracks(cdrom, strack, sframe,
+							ntrack, nframe) < 0 ) {
+					fprintf(stderr,
+			"Couldn't play tracks %d/%d for %d/%d: %s\n",
+				strack, sframe, ntrack, nframe, SDL_GetError());
+				}
+			} else {
+				fprintf(stderr, "No CD in drive!\n");
+			}
+		} else
+		if ( strcmp(argv[i], "-pause") == 0 ) {
+			if ( SDL_CDPause(cdrom) < 0 ) {
+				fprintf(stderr, "Couldn't pause CD: %s\n",
+								SDL_GetError());
+			}
+		} else
+		if ( strcmp(argv[i], "-resume") == 0 ) {
+			if ( SDL_CDResume(cdrom) < 0 ) {
+				fprintf(stderr, "Couldn't resume CD: %s\n",
+								SDL_GetError());
+			}
+		} else
+		if ( strcmp(argv[i], "-stop") == 0 ) {
+			if ( SDL_CDStop(cdrom) < 0 ) {
+				fprintf(stderr, "Couldn't eject CD: %s\n",
+								SDL_GetError());
+			}
+		} else
+		if ( strcmp(argv[i], "-eject") == 0 ) {
+			if ( SDL_CDEject(cdrom) < 0 ) {
+				fprintf(stderr, "Couldn't eject CD: %s\n",
+								SDL_GetError());
+			}
+		} else
+		if ( (strcmp(argv[i], "-sleep") == 0) &&
+				(argv[i+1] && isdigit(argv[i+1][0])) ) {
+			SDL_Delay(atoi(argv[++i]));
+			printf("Delayed %d milliseconds\n", atoi(argv[i]));
+		} else {
+			PrintUsage(argv[0]);
+			SDL_CDClose(cdrom);
+			exit(1);
+		}
+	}
+	PrintStatus(drive, cdrom);
+	SDL_CDClose(cdrom);
+
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testerror.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,54 @@
+
+/* Simple test of the SDL threading code and error handling */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+static int alive = 0;
+
+int ThreadFunc(void *data)
+{
+	/* Set the child thread error string */
+	SDL_SetError("Thread %s (%d) had a problem: %s",
+			(char *)data, SDL_ThreadID(), "nevermind");
+	while ( alive ) {
+		printf("Thread '%s' is alive!\n", (char *)data);
+		SDL_Delay(1*1000);
+	}
+	printf("Child thread error string: %s\n", SDL_GetError());
+	return(0);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Thread *thread;
+
+	/* Load the SDL library */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Set the error value for the main thread */
+	SDL_SetError("No worries");
+
+	alive = 1;
+	thread = SDL_CreateThread(ThreadFunc, "#1");
+	if ( thread == NULL ) {
+		fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+		exit(1);
+	}
+	SDL_Delay(5*1000);
+	printf("Waiting for thread #1\n");
+	alive = 0;
+	SDL_WaitThread(thread, NULL);
+
+	printf("Main thread error string: %s\n", SDL_GetError());
+
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testgamma.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,190 @@
+
+/* Bring up a window and manipulate the gamma on it */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+/* Turn a normal gamma value into an appropriate gamma ramp */
+void CalculateGamma(double gamma, Uint16 *ramp)
+{
+	int i, value;
+
+	gamma = 1.0 / gamma;
+	for ( i=0; i<256; ++i ) {
+		value = (int)(pow((double)i/256.0, gamma)*65535.0 + 0.5);
+		if ( value > 65535 ) {
+			value = 65535;
+		}
+		ramp[i] = (Uint16)value;
+	}
+}
+
+/* This can be used as a general routine for all of the test programs */
+int get_video_args(char *argv[], int *w, int *h, int *bpp, Uint32 *flags)
+{
+	int i;
+
+	*w = 640;
+	*h = 480;
+	*bpp = 0;
+	*flags = SDL_SWSURFACE;
+
+	for ( i=1; argv[i]; ++i ) {
+		if ( strcmp(argv[i], "-width") == 0 ) {
+			if ( argv[i+1] ) {
+				*w = atoi(argv[++i]);
+			}
+		} else
+		if ( strcmp(argv[i], "-height") == 0 ) {
+			if ( argv[i+1] ) {
+				*h = atoi(argv[++i]);
+			}
+		} else
+		if ( strcmp(argv[i], "-bpp") == 0 ) {
+			if ( argv[i+1] ) {
+				*bpp = atoi(argv[++i]);
+			}
+		} else
+		if ( strcmp(argv[i], "-fullscreen") == 0 ) {
+			*flags |= SDL_FULLSCREEN;
+		} else
+		if ( strcmp(argv[i], "-hw") == 0 ) {
+			*flags |= SDL_HWSURFACE;
+		} else
+		if ( strcmp(argv[i], "-hwpalette") == 0 ) {
+			*flags |= SDL_HWPALETTE;
+		} else
+			break;
+	}
+	return i;
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	SDL_Surface *image;
+	float gamma;
+	int i;
+	int w, h, bpp;
+	Uint32 flags;
+	Uint16 ramp[256];
+	Uint16 red_ramp[256];
+	Uint32 then, timeout;
+
+	/* Check command line arguments */
+	argv += get_video_args(argv, &w, &h, &bpp, &flags);
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr,
+			"Couldn't initialize SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Initialize the display, always use hardware palette */
+	screen = SDL_SetVideoMode(w, h, bpp, flags | SDL_HWPALETTE);
+	if ( screen == NULL ) {
+		fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
+						w, h, SDL_GetError());
+		exit(1);
+	}
+
+	/* Set the window manager title bar */
+	SDL_WM_SetCaption("SDL gamma test", "testgamma");
+
+	/* Set the desired gamma, if any */
+	gamma = 1.0f;
+	if ( *argv ) {
+		gamma = (float)atof(*argv);
+	}
+	if ( SDL_SetGamma(gamma, gamma, gamma) < 0 ) {
+		fprintf(stderr, "Unable to set gamma: %s\n", SDL_GetError());
+		exit(1);
+	}
+
+#if 0 /* This isn't supported.  Integrating the gamma ramps isn't exact */
+	/* See what gamma was actually set */
+	float real[3];
+	if ( SDL_GetGamma(&real[0], &real[1], &real[2]) < 0 ) {
+		printf("Couldn't get gamma: %s\n", SDL_GetError());
+	} else {
+		printf("Set gamma values: R=%2.2f, G=%2.2f, B=%2.2f\n",
+			real[0], real[1], real[2]);
+	}
+#endif
+
+	/* Do all the drawing work */
+	image = SDL_LoadBMP("sample.bmp");
+	if ( image ) {
+		SDL_Rect dst;
+
+		dst.x = (screen->w - image->w)/2;
+		dst.y = (screen->h - image->h)/2;
+		dst.w = image->w;
+		dst.h = image->h;
+		SDL_BlitSurface(image, NULL, screen, &dst);
+		SDL_UpdateRects(screen, 1, &dst);
+	}
+
+	/* Wait a bit, handling events */
+	then = SDL_GetTicks();
+	timeout = (5*1000);
+	while ( (SDL_GetTicks()-then) < timeout ) {
+		SDL_Event event;
+
+		while ( SDL_PollEvent(&event) ) {
+			switch (event.type) {
+			    case SDL_QUIT:	/* Quit now */
+				timeout = 0;
+				break;
+			    case SDL_KEYDOWN:
+				switch (event.key.keysym.sym) {
+				    case SDLK_SPACE:	/* Go longer.. */
+					timeout += (5*1000);
+					break;
+				    case SDLK_UP:
+					gamma += 0.2f;
+					SDL_SetGamma(gamma, gamma, gamma);
+					break;
+				    case SDLK_DOWN:
+					gamma -= 0.2f;
+					SDL_SetGamma(gamma, gamma, gamma);
+					break;
+				    case SDLK_ESCAPE:
+					timeout = 0;
+					break;
+				    default:
+					break;
+				}
+				break;
+			}
+		}
+	}
+
+	/* Perform a gamma flash to red using color ramps */
+	while ( gamma < 10.0 ) {
+		/* Increase the red gamma and decrease everything else... */
+		gamma += 0.1f;
+		CalculateGamma(gamma, red_ramp);
+		CalculateGamma(1.0/gamma, ramp);
+		SDL_SetGammaRamp(red_ramp, ramp, ramp);
+	}
+	/* Finish completely red */
+	memset(red_ramp, 255, sizeof(red_ramp));
+	memset(ramp, 0, sizeof(ramp));
+	SDL_SetGammaRamp(red_ramp, ramp, ramp);
+
+	/* Now fade out to black */
+	for ( i=(red_ramp[0] >> 8); i >= 0; --i ) {
+		memset(red_ramp, i, sizeof(red_ramp));
+		SDL_SetGammaRamp(red_ramp, NULL, NULL);
+	}
+	SDL_Delay(1*1000);
+
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testgl.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,519 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <math.h>
+
+#include "SDL.h"
+
+#ifdef HAVE_OPENGL
+#ifdef WIN32
+#include <windows.h>
+#endif
+#if defined(__APPLE__) && defined(__MACH__)
+#include <OpenGL/gl.h>
+#else
+#include <GL/gl.h>
+#endif
+
+#define SHADED_CUBE
+
+
+void HotKey_ToggleFullScreen(void)
+{
+	SDL_Surface *screen;
+
+	screen = SDL_GetVideoSurface();
+	if ( SDL_WM_ToggleFullScreen(screen) ) {
+		printf("Toggled fullscreen mode - now %s\n",
+		    (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+	} else {
+		printf("Unable to toggle fullscreen mode\n");
+	}
+}
+
+void HotKey_ToggleGrab(void)
+{
+	SDL_GrabMode mode;
+
+	printf("Ctrl-G: toggling input grab!\n");
+	mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+	if ( mode == SDL_GRAB_ON ) {
+		printf("Grab was on\n");
+	} else {
+		printf("Grab was off\n");
+	}
+	mode = SDL_WM_GrabInput(!mode);
+	if ( mode == SDL_GRAB_ON ) {
+		printf("Grab is now on\n");
+	} else {
+		printf("Grab is now off\n");
+	}
+}
+
+void HotKey_Iconify(void)
+{
+	printf("Ctrl-Z: iconifying window!\n");
+	SDL_WM_IconifyWindow();
+}
+
+int HandleEvent(SDL_Event *event)
+{
+	int done;
+
+	done = 0;
+	switch( event->type ) {
+	    case SDL_ACTIVEEVENT:
+		/* See what happened */
+		printf( "app %s ", event->active.gain ? "gained" : "lost" );
+		if ( event->active.state & SDL_APPACTIVE ) {
+			printf( "active " );
+		} else if ( event->active.state & SDL_APPMOUSEFOCUS ) {
+			printf( "mouse " );
+		} else if ( event->active.state & SDL_APPINPUTFOCUS ) {
+			printf( "input " );
+		}
+		printf( "focus\n" );
+		break;
+		
+
+	    case SDL_KEYDOWN:
+		if ( event->key.keysym.sym == SDLK_ESCAPE ) {
+			done = 1;
+		}
+		if ( (event->key.keysym.sym == SDLK_g) &&
+		     (event->key.keysym.mod & KMOD_CTRL) ) {
+			HotKey_ToggleGrab();
+		}
+		if ( (event->key.keysym.sym == SDLK_z) &&
+		     (event->key.keysym.mod & KMOD_CTRL) ) {
+			HotKey_Iconify();
+		}
+		if ( (event->key.keysym.sym == SDLK_RETURN) &&
+		     (event->key.keysym.mod & KMOD_ALT) ) {
+			HotKey_ToggleFullScreen();
+		}
+		printf("key '%s' pressed\n", 
+			SDL_GetKeyName(event->key.keysym.sym));
+		break;
+	    case SDL_QUIT:
+		done = 1;
+		break;
+	}
+	return(done);
+}
+
+void DrawSDLLogo(void)
+{
+	static SDL_Surface *image = NULL;
+	static int x = 0;
+	static int y = 0;
+	static int delta_x = 1;
+	static int delta_y = 1;
+	static Uint32 last_moved = 0;
+
+	SDL_Rect dst;
+	SDL_Surface *screen;
+
+	if ( image == NULL ) {
+		SDL_Surface *temp;
+
+		temp = SDL_LoadBMP("icon.bmp");
+		if ( temp == NULL ) {
+			return;
+		}
+		image = SDL_CreateRGBSurface(
+				SDL_SWSURFACE,
+				temp->w, temp->h,
+				32,
+#if SDL_BYTEORDER == SDL_LIL_ENDIAN
+				0x000000FF, 
+				0x0000FF00, 
+				0x00FF0000, 
+ 			       0xFF000000
+#else
+ 			       0xFF000000,
+ 			       0x00FF0000, 
+ 			       0x0000FF00, 
+ 			       0x000000FF
+#endif
+ 			       );
+		if ( image != NULL ) {
+			SDL_BlitSurface(temp, NULL, image, NULL);
+		}
+		SDL_FreeSurface(temp);
+		if ( image == NULL ) {
+			return;
+		}
+	}
+
+	screen = SDL_GetVideoSurface();
+
+	/* Show the image on the screen */
+	dst.x = x;
+	dst.y = y;
+	dst.w = image->w;
+	dst.h = image->h;
+
+	/* Move it around
+           Note that we do not clear the old position.  This is because we
+           perform a glClear() which clears the framebuffer and then only
+           update the new area.
+           Note that you can also achieve interesting effects by modifying
+           the screen surface alpha channel.  It's set to 255 by default..
+         */
+	if ( (SDL_GetTicks() - last_moved) > 100 ) {
+		x += delta_x;
+		if ( x < 0 ) {
+			x = 0;
+			delta_x = -delta_x;
+		} else
+		if ( (x+image->w) > screen->w ) {
+			x = screen->w-image->w;
+			delta_x = -delta_x;
+		}
+		y += delta_y;
+		if ( y < 0 ) {
+			y = 0;
+			delta_y = -delta_y;
+		} else
+		if ( (y+image->h) > screen->h ) {
+			y = screen->h-image->h;
+			delta_y = -delta_y;
+		}
+		SDL_BlitSurface(image, NULL, screen, &dst);
+	}
+	SDL_UpdateRects(screen, 1, &dst);
+}
+
+int RunGLTest( int argc, char* argv[],
+               int logo, int slowly, int bpp, float gamma )
+{
+	int i;
+	int rgb_size[3];
+	int w = 640;
+	int h = 480;
+	int done = 0;
+	int frames;
+	Uint32 start_time, this_time;
+        float color[8][3]= {{ 1.0,  1.0,  0.0}, 
+			    { 1.0,  0.0,  0.0},
+			    { 0.0,  0.0,  0.0},
+			    { 0.0,  1.0,  0.0},
+			    { 0.0,  1.0,  1.0},
+			    { 1.0,  1.0,  1.0},
+			    { 1.0,  0.0,  1.0},
+			    { 0.0,  0.0,  1.0}};
+	float cube[8][3]= {{ 0.5,  0.5, -0.5}, 
+			   { 0.5, -0.5, -0.5},
+			   {-0.5, -0.5, -0.5},
+			   {-0.5,  0.5, -0.5},
+			   {-0.5,  0.5,  0.5},
+			   { 0.5,  0.5,  0.5},
+			   { 0.5, -0.5,  0.5},
+			   {-0.5, -0.5,  0.5}};
+	Uint32 video_flags;
+	int value;
+
+	if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
+		fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit( 1 );
+	}
+
+	/* See if we should detect the display depth */
+	if ( bpp == 0 ) {
+		if ( SDL_GetVideoInfo()->vfmt->BitsPerPixel <= 8 ) {
+			bpp = 8;
+		} else {
+			bpp = 16;  /* More doesn't seem to work */
+		}
+	}
+
+	/* Set the flags we want to use for setting the video mode */
+	if ( logo ) {
+		video_flags = SDL_OPENGLBLIT;
+	} else {
+		video_flags = SDL_OPENGL;
+	}
+	for ( i=1; argv[i]; ++i ) {
+		if ( strcmp(argv[1], "-fullscreen") == 0 ) {
+			video_flags |= SDL_FULLSCREEN;
+		}
+	}
+
+	/* Initialize the display */
+	switch (bpp) {
+	    case 8:
+		rgb_size[0] = 2;
+		rgb_size[1] = 3;
+		rgb_size[2] = 3;
+		break;
+	    case 15:
+	    case 16:
+		rgb_size[0] = 5;
+		rgb_size[1] = 5;
+		rgb_size[2] = 5;
+		break;
+            default:
+		rgb_size[0] = 8;
+		rgb_size[1] = 8;
+		rgb_size[2] = 8;
+		break;
+	}
+	SDL_GL_SetAttribute( SDL_GL_RED_SIZE, rgb_size[0] );
+	SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, rgb_size[1] );
+	SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, rgb_size[2] );
+	SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
+	SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
+	if ( SDL_SetVideoMode( w, h, bpp, video_flags ) == NULL ) {
+		fprintf(stderr, "Couldn't set GL mode: %s\n", SDL_GetError());
+		SDL_Quit();
+		exit(1);
+	}
+
+	printf("Screen BPP: %d\n", SDL_GetVideoSurface()->format->BitsPerPixel);
+	printf("\n");
+	printf( "Vendor     : %s\n", glGetString( GL_VENDOR ) );
+	printf( "Renderer   : %s\n", glGetString( GL_RENDERER ) );
+	printf( "Version    : %s\n", glGetString( GL_VERSION ) );
+	printf( "Extensions : %s\n", glGetString( GL_EXTENSIONS ) );
+	printf("\n");
+
+	SDL_GL_GetAttribute( SDL_GL_RED_SIZE, &value );
+	printf( "SDL_GL_RED_SIZE: requested %d, got %d\n", rgb_size[0],value);
+	SDL_GL_GetAttribute( SDL_GL_GREEN_SIZE, &value );
+	printf( "SDL_GL_GREEN_SIZE: requested %d, got %d\n", rgb_size[1],value);
+	SDL_GL_GetAttribute( SDL_GL_BLUE_SIZE, &value );
+	printf( "SDL_GL_BLUE_SIZE: requested %d, got %d\n", rgb_size[2],value);
+	SDL_GL_GetAttribute( SDL_GL_DEPTH_SIZE, &value );
+	printf( "SDL_GL_DEPTH_SIZE: requested %d, got %d\n", bpp, value );
+	SDL_GL_GetAttribute( SDL_GL_DOUBLEBUFFER, &value );
+	printf( "SDL_GL_DOUBLEBUFFER: requested 1, got %d\n", value );
+
+	/* Set the window manager title bar */
+	SDL_WM_SetCaption( "SDL GL test", "testgl" );
+
+	/* Set the gamma for the window */
+	if ( gamma != 0.0 ) {
+		SDL_SetGamma(gamma, gamma, gamma);
+	}
+
+	glViewport( 0, 0, w, h );
+	glMatrixMode( GL_PROJECTION );
+	glLoadIdentity( );
+
+	glOrtho( -2.0, 2.0, -2.0, 2.0, -20.0, 20.0 );
+
+	glMatrixMode( GL_MODELVIEW );
+	glLoadIdentity( );
+
+	glEnable(GL_DEPTH_TEST);
+
+	glDepthFunc(GL_LESS);
+
+	glShadeModel(GL_SMOOTH);
+
+	/* Loop until done. */
+	start_time = SDL_GetTicks();
+	frames = 0;
+	while( !done ) {
+		GLenum gl_error;
+		char* sdl_error;
+		SDL_Event event;
+
+		/* Do our drawing, too. */
+		glClearColor( 0.0, 0.0, 0.0, 1.0 );
+		glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+		glBegin( GL_QUADS );
+
+#ifdef SHADED_CUBE
+			glColor3fv(color[0]);
+			glVertex3fv(cube[0]);
+			glColor3fv(color[1]);
+			glVertex3fv(cube[1]);
+			glColor3fv(color[2]);
+			glVertex3fv(cube[2]);
+			glColor3fv(color[3]);
+			glVertex3fv(cube[3]);
+			
+			glColor3fv(color[3]);
+			glVertex3fv(cube[3]);
+			glColor3fv(color[4]);
+			glVertex3fv(cube[4]);
+			glColor3fv(color[7]);
+			glVertex3fv(cube[7]);
+			glColor3fv(color[2]);
+			glVertex3fv(cube[2]);
+			
+			glColor3fv(color[0]);
+			glVertex3fv(cube[0]);
+			glColor3fv(color[5]);
+			glVertex3fv(cube[5]);
+			glColor3fv(color[6]);
+			glVertex3fv(cube[6]);
+			glColor3fv(color[1]);
+			glVertex3fv(cube[1]);
+			
+			glColor3fv(color[5]);
+			glVertex3fv(cube[5]);
+			glColor3fv(color[4]);
+			glVertex3fv(cube[4]);
+			glColor3fv(color[7]);
+			glVertex3fv(cube[7]);
+			glColor3fv(color[6]);
+			glVertex3fv(cube[6]);
+
+			glColor3fv(color[5]);
+			glVertex3fv(cube[5]);
+			glColor3fv(color[0]);
+			glVertex3fv(cube[0]);
+			glColor3fv(color[3]);
+			glVertex3fv(cube[3]);
+			glColor3fv(color[4]);
+			glVertex3fv(cube[4]);
+
+			glColor3fv(color[6]);
+			glVertex3fv(cube[6]);
+			glColor3fv(color[1]);
+			glVertex3fv(cube[1]);
+			glColor3fv(color[2]);
+			glVertex3fv(cube[2]);
+			glColor3fv(color[7]);
+			glVertex3fv(cube[7]);
+#else // flat cube
+			glColor3f(1.0, 0.0, 0.0);
+			glVertex3fv(cube[0]);
+			glVertex3fv(cube[1]);
+			glVertex3fv(cube[2]);
+			glVertex3fv(cube[3]);
+			
+			glColor3f(0.0, 1.0, 0.0);
+			glVertex3fv(cube[3]);
+			glVertex3fv(cube[4]);
+			glVertex3fv(cube[7]);
+			glVertex3fv(cube[2]);
+			
+			glColor3f(0.0, 0.0, 1.0);
+			glVertex3fv(cube[0]);
+			glVertex3fv(cube[5]);
+			glVertex3fv(cube[6]);
+			glVertex3fv(cube[1]);
+			
+			glColor3f(0.0, 1.0, 1.0);
+			glVertex3fv(cube[5]);
+			glVertex3fv(cube[4]);
+			glVertex3fv(cube[7]);
+			glVertex3fv(cube[6]);
+
+			glColor3f(1.0, 1.0, 0.0);
+			glVertex3fv(cube[5]);
+			glVertex3fv(cube[0]);
+			glVertex3fv(cube[3]);
+			glVertex3fv(cube[4]);
+
+			glColor3f(1.0, 0.0, 1.0);
+			glVertex3fv(cube[6]);
+			glVertex3fv(cube[1]);
+			glVertex3fv(cube[2]);
+			glVertex3fv(cube[7]);
+#endif /* SHADED_CUBE */
+
+		glEnd( );
+		
+		glMatrixMode(GL_MODELVIEW);
+		glRotatef(5.0, 1.0, 1.0, 1.0);
+
+		/* Draw 2D logo onto the 3D display */
+		if ( logo ) {
+			DrawSDLLogo();
+		}
+
+		SDL_GL_SwapBuffers( );
+
+		/* Check for error conditions. */
+		gl_error = glGetError( );
+
+		if( gl_error != GL_NO_ERROR ) {
+			fprintf( stderr, "testgl: OpenGL error: %d\n", gl_error );
+		}
+
+		sdl_error = SDL_GetError( );
+
+		if( sdl_error[0] != '\0' ) {
+			fprintf(stderr, "testgl: SDL error '%s'\n", sdl_error);
+			SDL_ClearError();
+		}
+
+		/* Allow the user to see what's happening */
+		if ( slowly ) {
+			SDL_Delay( 20 );
+		}
+
+		/* Check if there's a pending event. */
+		while( SDL_PollEvent( &event ) ) {
+			done = HandleEvent(&event);
+		}
+		++frames;
+	}
+
+	/* Print out the frames per second */
+	this_time = SDL_GetTicks();
+	if ( this_time != start_time ) {
+		printf("%2.2f FPS\n",
+			((float)frames/(this_time-start_time))*1000.0);
+	}
+
+	/* Destroy our GL context, etc. */
+	SDL_Quit( );
+	return(0);
+}
+
+int main(int argc, char *argv[])
+{
+	int i, logo;
+	int numtests;
+	int bpp = 0;
+	int slowly;
+	float gamma = 0.0;
+
+	logo = 0;
+	slowly = 0;
+	numtests = 1;
+	for ( i=1; argv[i]; ++i ) {
+		if ( strcmp(argv[i], "-twice") == 0 ) {
+			++numtests;
+		}
+		if ( strcmp(argv[i], "-logo") == 0 ) {
+			logo = 1;
+		}
+		if ( strcmp(argv[i], "-slow") == 0 ) {
+			slowly = 1;
+		}
+		if ( strcmp(argv[i], "-bpp") == 0 ) {
+ 		       bpp = atoi(argv[++i]);
+		}
+		if ( strcmp(argv[i], "-gamma") == 0 ) {
+ 		       gamma = (float)atof(argv[++i]);
+		}
+		if ( strncmp(argv[i], "-h", 2) == 0 ) {
+ 		       printf(
+"Usage: %s [-twice] [-logo] [-slow] [-bpp n] [-gamma n]\n",
+ 			      argv[0]);
+			exit(0);
+		}
+	}
+	for ( i=0; i<numtests; ++i ) {
+ 	       RunGLTest(argc, argv, logo, slowly, bpp, gamma);
+	}
+	return 0;
+}
+
+#else /* HAVE_OPENGL */
+
+int main(int argc, char *argv[])
+{
+	printf("No OpenGL support on this system\n");
+	return 1;
+}
+
+#endif /* HAVE_OPENGL */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testhread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,75 @@
+
+/* Simple test of the SDL threading code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+static int alive = 0;
+
+int ThreadFunc(void *data)
+{
+	printf("Started thread %s: My thread id is %u\n",
+				(char *)data, SDL_ThreadID());
+	while ( alive ) {
+		printf("Thread '%s' is alive!\n", (char *)data);
+		SDL_Delay(1*1000);
+	}
+	printf("Thread '%s' exiting!\n", (char *)data);
+	return(0);
+}
+
+static void killed(int sig)
+{
+	printf("Killed with SIGTERM, waiting 5 seconds to exit\n");
+	SDL_Delay(5*1000);
+	alive = 0;
+	exit(0);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Thread *thread;
+
+	/* Load the SDL library */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	alive = 1;
+	thread = SDL_CreateThread(ThreadFunc, "#1");
+	if ( thread == NULL ) {
+		fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+		exit(1);
+	}
+	SDL_Delay(5*1000);
+	printf("Waiting for thread #1\n");
+	alive = 0;
+	SDL_WaitThread(thread, NULL);
+
+	alive = 1;
+	thread = SDL_CreateThread(ThreadFunc, "#2");
+	if ( thread == NULL ) {
+		fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+		exit(1);
+	}
+	SDL_Delay(5*1000);
+	printf("Killing thread #2\n");
+	SDL_KillThread(thread);
+
+	alive = 1;
+	signal(SIGTERM, killed);
+	thread = SDL_CreateThread(ThreadFunc, "#3");
+	if ( thread == NULL ) {
+		fprintf(stderr, "Couldn't create thread: %s\n", SDL_GetError());
+		exit(1);
+	}
+	raise(SIGTERM);
+
+	return(0);	/* Never reached */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testjoystick.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,178 @@
+
+/* Simple program to test the SDL joystick routines */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+#define SCREEN_WIDTH	640
+#define SCREEN_HEIGHT	480
+
+void WatchJoystick(SDL_Joystick *joystick)
+{
+	SDL_Surface *screen;
+	const char *name;
+	int i, done;
+	SDL_Event event;
+	int x, y, draw;
+	SDL_Rect axis_area[2];
+
+	/* Set a video mode to display joystick axis position */
+	screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 16, 0);
+	if ( screen == NULL ) {
+		fprintf(stderr, "Couldn't set video mode: %s\n",SDL_GetError());
+		return;
+	}
+
+	/* Print info about the joystick we are watching */
+	name = SDL_JoystickName(SDL_JoystickIndex(joystick));
+	printf("Watching joystick %d: (%s)\n", SDL_JoystickIndex(joystick),
+	       name ? name : "Unknown Joystick");
+	printf("Joystick has %d axes, %d hats, %d balls, and %d buttons\n",
+	       SDL_JoystickNumAxes(joystick), SDL_JoystickNumHats(joystick),
+	       SDL_JoystickNumBalls(joystick),SDL_JoystickNumButtons(joystick));
+
+	/* Initialize drawing rectangles */
+	memset(axis_area, 0, (sizeof axis_area));
+	draw = 0;
+
+	/* Loop, getting joystick events! */
+	done = 0;
+	while ( ! done ) {
+		while ( SDL_PollEvent(&event) ) {
+			switch (event.type) {
+			    case SDL_JOYAXISMOTION:
+				printf("Joystick %d axis %d value: %d\n",
+				       event.jaxis.which,
+				       event.jaxis.axis,
+				       event.jaxis.value);
+				break;
+			    case SDL_JOYHATMOTION:
+				printf("Joystick %d hat %d value:",
+				       event.jhat.which,
+				       event.jhat.hat);
+				if ( event.jhat.value == SDL_HAT_CENTERED )
+					printf(" centered");
+				if ( event.jhat.value & SDL_HAT_UP )
+					printf(" up");
+				if ( event.jhat.value & SDL_HAT_RIGHT )
+					printf(" right");
+				if ( event.jhat.value & SDL_HAT_DOWN )
+					printf(" down");
+				if ( event.jhat.value & SDL_HAT_LEFT )
+					printf(" left");
+				printf("\n");
+				break;
+			    case SDL_JOYBALLMOTION:
+				printf("Joystick %d ball %d delta: (%d,%d)\n",
+				       event.jball.which,
+				       event.jball.ball,
+				       event.jball.xrel,
+				       event.jball.yrel);
+				break;
+			    case SDL_JOYBUTTONDOWN:
+				printf("Joystick %d button %d down\n",
+				       event.jbutton.which,
+				       event.jbutton.button);
+				break;
+			    case SDL_JOYBUTTONUP:
+				printf("Joystick %d button %d up\n",
+				       event.jbutton.which,
+				       event.jbutton.button);
+				break;
+			    case SDL_KEYDOWN:
+				if ( event.key.keysym.sym != SDLK_ESCAPE ) {
+					break;
+				}
+				/* Fall through to signal quit */
+			    case SDL_QUIT:
+				done = 1;
+				break;
+			    default:
+				break;
+			}
+		}
+		/* Update visual joystick state */
+		for ( i=0; i<SDL_JoystickNumButtons(joystick); ++i ) {
+			SDL_Rect area;
+
+			area.x = i*34;
+			area.y = SCREEN_HEIGHT-34;
+			area.w = 32;
+			area.h = 32;
+			if (SDL_JoystickGetButton(joystick, i) == SDL_PRESSED) {
+				SDL_FillRect(screen, &area, 0xFFFF);
+			} else {
+				SDL_FillRect(screen, &area, 0x0000);
+			}
+			SDL_UpdateRects(screen, 1, &area);
+		}
+
+		/* Erase previous axes */
+		SDL_FillRect(screen, &axis_area[draw], 0x0000);
+
+		/* Draw the X/Y axis */
+		draw = !draw;
+		x = (((int)SDL_JoystickGetAxis(joystick, 0))+32768);
+		x *= SCREEN_WIDTH;
+		x /= 65535;
+		if ( x < 0 ) {
+			x = 0;
+		} else
+		if ( x > (SCREEN_WIDTH-16) ) {
+			x = SCREEN_WIDTH-16;
+		}
+		y = (((int)SDL_JoystickGetAxis(joystick, 1))+32768);
+		y *= SCREEN_HEIGHT;
+		y /= 65535;
+		if ( y < 0 ) {
+			y = 0;
+		} else
+		if ( y > (SCREEN_HEIGHT-16) ) {
+			y = SCREEN_HEIGHT-16;
+		}
+		axis_area[draw].x = (Sint16)x;
+		axis_area[draw].y = (Sint16)y;
+		axis_area[draw].w = 16;
+		axis_area[draw].h = 16;
+		SDL_FillRect(screen, &axis_area[draw], 0xFFFF);
+
+		SDL_UpdateRects(screen, 2, axis_area);
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	const char *name;
+	int i;
+	SDL_Joystick *joystick;
+
+	/* Initialize SDL (Note: video is required to start event loop) */
+	if ( SDL_Init(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+
+	/* Print information about the joysticks */
+	printf("There are %d joysticks attached\n", SDL_NumJoysticks());
+	for ( i=0; i<SDL_NumJoysticks(); ++i ) {
+		name = SDL_JoystickName(i);
+		printf("Joystick %d: %s\n",i,name ? name : "Unknown Joystick");
+	}
+
+	if ( argv[1] ) {
+		joystick = SDL_JoystickOpen(atoi(argv[1]));
+		if ( joystick == NULL ) {
+			printf("Couldn't open joystick %d: %s\n", atoi(argv[1]),
+			       SDL_GetError());
+		} else {
+			WatchJoystick(joystick);
+			SDL_JoystickClose(joystick);
+		}
+	}
+	SDL_QuitSubSystem(SDL_INIT_VIDEO|SDL_INIT_JOYSTICK);
+
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testkeys.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,23 @@
+
+/* Print out all the keysyms we have, just to verify them */
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+	SDLKey key;
+
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",
+							SDL_GetError());
+		exit(1);
+	}
+	for ( key=SDLK_FIRST; key<SDLK_LAST; ++key ) {
+		printf("Key #%d, \"%s\"\n", key, SDL_GetKeyName(key));
+	}
+	SDL_Quit();
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testlock.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,89 @@
+
+/* Test the thread and mutex locking functions 
+   Also exercises the system's signal/thread interaction
+*/
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+#include "SDL_mutex.h"
+#include "SDL_thread.h"
+
+static SDL_mutex *mutex = NULL;
+static Uint32 mainthread;
+static SDL_Thread *threads[6];
+
+void printid(void)
+{
+	printf("Process %u:  exiting\n", SDL_ThreadID());
+}
+	
+void terminate(int sig)
+{
+	printf("Process %u:  raising SIGTERM\n", SDL_ThreadID());
+	raise(SIGTERM);
+}
+void closemutex(int sig)
+{
+	Uint32 id = SDL_ThreadID();
+	int i;
+	printf("Process %u:  Cleaning up...\n", id == mainthread ? 0 : id);
+	for ( i=0; i<6; ++i )
+		SDL_KillThread(threads[i]);
+	SDL_DestroyMutex(mutex);
+	exit(sig);
+}
+int Run(void *data)
+{
+	if ( SDL_ThreadID() == mainthread )
+		signal(SIGTERM, closemutex);
+	while ( 1 ) {
+		printf("Process %u ready to work\n", SDL_ThreadID());
+		if ( SDL_mutexP(mutex) < 0 ) {
+			fprintf(stderr, "Couldn't lock mutex: %s", SDL_GetError());
+			exit(1);
+		}
+		printf("Process %u, working!\n", SDL_ThreadID());
+		SDL_Delay(1*1000);
+		printf("Process %u, done!\n", SDL_ThreadID());
+		if ( SDL_mutexV(mutex) < 0 ) {
+			fprintf(stderr, "Couldn't unlock mutex: %s", SDL_GetError());
+			exit(1);
+		}
+		/* If this sleep isn't done, then threads may starve */
+		SDL_Delay(10);
+	}
+	return(0);
+}
+
+int main(int argc, char *argv[])
+{
+	int i;
+	int maxproc = 6;
+
+	/* Load the SDL library */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "%s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	if ( (mutex=SDL_CreateMutex()) == NULL ) {
+		fprintf(stderr, "Couldn't create mutex: %s\n", SDL_GetError());
+		exit(1);
+	}
+
+	mainthread = SDL_ThreadID();
+	printf("Main thread: %u\n", mainthread);
+	atexit(printid);
+	for ( i=0; i<maxproc; ++i ) {
+		if ( (threads[i]=SDL_CreateThread(Run, NULL)) == NULL )
+			fprintf(stderr, "Couldn't create thread!\n");
+	}
+	signal(SIGINT, terminate);
+	Run(NULL);
+
+	return(0);	/* Never reached */
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testpalette.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,332 @@
+/*
+ * testpalette.c
+ *
+ * A simple test of runtime palette modification for animation
+ * (using the SDL_SetPalette() API). 
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <math.h>
+
+/* This isn't in the Windows headers */
+#ifndef M_PI
+#define M_PI	3.14159265358979323846
+#endif
+
+#include <SDL.h>
+
+/* screen size */
+#define SCRW 640
+#define SCRH 480
+
+#define NBOATS 5
+#define SPEED 2
+
+#ifndef MIN
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+#endif
+#ifndef MAX
+#define MAX(a, b) ((a) > (b) ? (a) : (b))
+#endif
+
+/*
+ * wave colours: Made by taking a narrow cross-section of a wave picture
+ * in Gimp, saving in PPM ascii format and formatting with Emacs macros.
+ */
+static SDL_Color wavemap[] = {
+    {0,2,103}, {0,7,110}, {0,13,117}, {0,19,125},
+    {0,25,133}, {0,31,141}, {0,37,150}, {0,43,158},
+    {0,49,166}, {0,55,174}, {0,61,182}, {0,67,190},
+    {0,73,198}, {0,79,206}, {0,86,214}, {0,96,220},
+    {5,105,224}, {12,112,226}, {19,120,227}, {26,128,229},
+    {33,135,230}, {40,143,232}, {47,150,234}, {54,158,236},
+    {61,165,238}, {68,173,239}, {75,180,241}, {82,188,242},
+    {89,195,244}, {96,203,246}, {103,210,248}, {112,218,250},
+    {124,224,250}, {135,226,251}, {146,229,251}, {156,231,252},
+    {167,233,252}, {178,236,252}, {189,238,252}, {200,240,252},
+    {211,242,252}, {222,244,252}, {233,247,252}, {242,249,252},
+    {237,250,252}, {209,251,252}, {174,251,252}, {138,252,252},
+    {102,251,252}, {63,250,252}, {24,243,252}, {7,225,252},
+    {4,203,252}, {3,181,252}, {2,158,252}, {1,136,251},
+    {0,111,248}, {0,82,234}, {0,63,213}, {0,50,192},
+    {0,39,172}, {0,28,152}, {0,17,132}, {0,7,114}
+};
+
+static void sdlerr(char *when)
+{
+    fprintf(stderr, "SDL error: %s: %s\n", when, SDL_GetError());
+    exit(1);
+}
+
+/* create a background surface */
+static SDL_Surface *make_bg(SDL_Surface *screen, int startcol)
+{
+    int i;
+    SDL_Surface *bg = SDL_CreateRGBSurface(SDL_SWSURFACE, screen->w, screen->h,
+					   8, 0, 0, 0, 0);
+    if(!bg)
+	sdlerr("creating background surface");
+
+    /* set the palette to the logical screen palette so that blits
+       won't be translated */
+    SDL_SetColors(bg, screen->format->palette->colors, 0, 256);
+
+    /* Make a wavy background pattern using colours 0-63 */
+    if(SDL_LockSurface(bg) < 0)
+	sdlerr("locking background");
+    for(i = 0; i < SCRH; i++) {
+	Uint8 *p = (Uint8 *)bg->pixels + i * bg->pitch;
+	int j, d;
+	d = 0;
+	for(j = 0; j < SCRW; j++) {
+	    int v = MAX(d, -2);
+	    v = MIN(v, 2);
+	    if(i > 0)
+		v += p[-bg->pitch] + 65 - startcol;
+	    p[j] = startcol + (v & 63);
+	    d += ((rand() >> 3) % 3) - 1;
+	}
+    }
+    SDL_UnlockSurface(bg);
+    return(bg);
+}
+
+/*
+ * Return a surface flipped horisontally. Only works for 8bpp;
+ * extension to arbitrary bitness is left as an exercise for the reader.
+ */
+static SDL_Surface *hflip(SDL_Surface *s)
+{
+    int i;
+    SDL_Surface *z = SDL_CreateRGBSurface(SDL_SWSURFACE, s->w, s->h, 8,
+					  0, 0, 0, 0);
+    /* copy palette */
+    SDL_SetColors(z, s->format->palette->colors,
+		  0, s->format->palette->ncolors);
+    if(SDL_LockSurface(s) < 0 || SDL_LockSurface(z) < 0)
+	sdlerr("locking flip images");
+
+    for(i = 0; i < s->h; i++) {
+	int j;
+	Uint8 *from = (Uint8 *)s->pixels + i * s->pitch;
+	Uint8 *to = (Uint8 *)z->pixels + i * z->pitch + s->w - 1;
+	for(j = 0; j < s->w; j++)
+	    to[-j] = from[j];
+    }
+
+    SDL_UnlockSurface(z);
+    SDL_UnlockSurface(s);
+    return z;
+}
+
+int main(int argc, char **argv)
+{
+    SDL_Color cmap[256];
+    SDL_Surface *screen;
+    SDL_Surface *bg;
+    SDL_Surface *boat[2];
+    unsigned vidflags = 0;
+    unsigned start;
+    int fade_max = 400;
+    int fade_level, fade_dir;
+    int boatcols, frames, i, red;
+    int boatx[NBOATS], boaty[NBOATS], boatdir[NBOATS];
+    int gamma_fade = 0;
+    int gamma_ramp = 0;
+
+    if(SDL_Init(SDL_INIT_VIDEO) < 0)
+	sdlerr("initialising SDL");
+
+    atexit(SDL_Quit);
+
+    while(--argc) {
+	++argv;
+	if(strcmp(*argv, "-hw") == 0)
+	    vidflags |= SDL_HWSURFACE;
+	else if(strcmp(*argv, "-fullscreen") == 0)
+	    vidflags |= SDL_FULLSCREEN;
+	else if(strcmp(*argv, "-nofade") == 0)
+	    fade_max = 1;
+	else if(strcmp(*argv, "-gamma") == 0)
+	    gamma_fade = 1;
+	else if(strcmp(*argv, "-gammaramp") == 0)
+	    gamma_ramp = 1;
+	else {
+	    fprintf(stderr,
+		    "usage: testpalette "
+		    " [-hw] [-fullscreen] [-nofade] [-gamma] [-gammaramp]\n");
+	    return 1;
+	}
+    }
+
+    /* Ask explicitly for 8bpp and a hardware palette */
+    if(!(screen = SDL_SetVideoMode(SCRW, SCRH, 8, vidflags | SDL_HWPALETTE))) {
+	fprintf(stderr, "error setting %dx%d 8bpp indexed mode: %s\n",
+		SCRW, SCRH, SDL_GetError());
+	return 1;
+    }
+
+    if(!(boat[0] = SDL_LoadBMP("sail.bmp")))
+	sdlerr("loading sail.bmp");
+    /* We've chosen magenta (#ff00ff) as colour key for the boat */
+    SDL_SetColorKey(boat[0], SDL_SRCCOLORKEY | SDL_RLEACCEL,
+		    SDL_MapRGB(boat[0]->format, 0xff, 0x00, 0xff));
+    boatcols = boat[0]->format->palette->ncolors;
+    boat[1] = hflip(boat[0]);
+    SDL_SetColorKey(boat[1], SDL_SRCCOLORKEY | SDL_RLEACCEL,
+		    SDL_MapRGB(boat[1]->format, 0xff, 0x00, 0xff));
+
+    /*
+     * First set the physical screen palette to black, so the user won't
+     * see our initial drawing on the screen.
+     */
+    memset(cmap, 0, sizeof(cmap));
+    SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, 256);
+
+    /*
+     * Proper palette management is important when playing games with the
+     * colormap. We have divided the palette as follows:
+     *
+     * index 0..(boatcols-1):		used for the boat
+     * index boatcols..(boatcols+63):	used for the waves
+     */
+    SDL_SetPalette(screen, SDL_LOGPAL,
+		   boat[0]->format->palette->colors, 0, boatcols);
+    SDL_SetPalette(screen, SDL_LOGPAL, wavemap, boatcols, 64);
+
+    /*
+     * Now the logical screen palette is set, and will remain unchanged.
+     * The boats already have the same palette so fast blits can be used.
+     */
+    memcpy(cmap, screen->format->palette->colors, 256 * sizeof(SDL_Color));
+
+    /* save the index of the red colour for later */
+    red = SDL_MapRGB(screen->format, 0xff, 0x00, 0x00);
+
+    bg = make_bg(screen, boatcols); /* make a nice wavy background surface */
+
+    /* initial screen contents */
+    if(SDL_BlitSurface(bg, NULL, screen, NULL) < 0)
+	sdlerr("blitting background to screen");
+    SDL_Flip(screen);		/* actually put the background on screen */
+
+    /* determine initial boat placements */
+    for(i = 0; i < NBOATS; i++) {
+	boatx[i] = (rand() % (SCRW + boat[0]->w)) - boat[0]->w;
+	boaty[i] = i * (SCRH - boat[0]->h) / (NBOATS - 1);
+	boatdir[i] = ((rand() >> 5) & 1) * 2 - 1;
+    }
+
+    start = SDL_GetTicks();
+    frames = 0;
+    fade_dir = 1;
+    fade_level = 0;
+    do {
+	SDL_Event e;
+	SDL_Rect updates[NBOATS];
+	SDL_Rect r;
+	int redphase;
+
+	/* A small event loop: just exit on any key or mouse button event */
+	while(SDL_PollEvent(&e)) {
+	    if(e.type == SDL_KEYDOWN || e.type == SDL_QUIT
+	       || e.type == SDL_MOUSEBUTTONDOWN) {
+		if(fade_dir < 0)
+		    fade_level = 0;
+		fade_dir = -1;
+	    }
+	}
+
+	/* move boats */
+	for(i = 0; i < NBOATS; i++) {
+	    int old_x = boatx[i];
+	    /* update boat position */
+	    boatx[i] += boatdir[i] * SPEED;
+	    if(boatx[i] <= -boat[0]->w || boatx[i] >= SCRW)
+		boatdir[i] = -boatdir[i];
+
+	    /* paint over the old boat position */
+	    r.x = old_x;
+	    r.y = boaty[i];
+	    r.w = boat[0]->w;
+	    r.h = boat[0]->h;
+	    if(SDL_BlitSurface(bg, &r, screen, &r) < 0)
+		sdlerr("blitting background");
+
+	    /* construct update rectangle (bounding box of old and new pos) */
+	    updates[i].x = MIN(old_x, boatx[i]);
+	    updates[i].y = boaty[i];
+	    updates[i].w = boat[0]->w + SPEED;
+	    updates[i].h = boat[0]->h;
+	    /* clip update rectangle to screen */
+	    if(updates[i].x < 0) {
+		updates[i].w += updates[i].x;
+		updates[i].x = 0;
+	    }
+	    if(updates[i].x + updates[i].w > SCRW)
+		updates[i].w = SCRW - updates[i].x;
+	}
+
+	for(i = 0; i < NBOATS; i++) {
+	    /* paint boat on new position */
+	    r.x = boatx[i];
+	    r.y = boaty[i];
+	    if(SDL_BlitSurface(boat[(boatdir[i] + 1) / 2], NULL,
+			       screen, &r) < 0)
+		sdlerr("blitting boat");
+	}
+
+	/* cycle wave palette */
+	for(i = 0; i < 64; i++)
+	    cmap[boatcols + ((i + frames) & 63)] = wavemap[i];
+
+	if(fade_dir) {
+	    /* Fade the entire palette in/out */
+	    fade_level += fade_dir;
+
+	    if(gamma_fade) {
+		/* Fade linearly in gamma level (lousy) */
+		float level = (float)fade_level / fade_max;
+		if(SDL_SetGamma(level, level, level) < 0)
+		    sdlerr("setting gamma");
+
+	    } else if(gamma_ramp) {
+		/* Fade using gamma ramp (better) */
+		Uint16 ramp[256];
+		for(i = 0; i < 256; i++)
+		    ramp[i] = (i * fade_level / fade_max) << 8;
+		if(SDL_SetGammaRamp(ramp, ramp, ramp) < 0)
+		    sdlerr("setting gamma ramp");
+
+	    } else {
+		/* Fade using direct palette manipulation (best) */
+		memcpy(cmap, screen->format->palette->colors,
+		       boatcols * sizeof(SDL_Color));
+		for(i = 0; i < boatcols + 64; i++) {
+		    cmap[i].r = cmap[i].r * fade_level / fade_max;
+		    cmap[i].g = cmap[i].g * fade_level / fade_max;
+		    cmap[i].b = cmap[i].b * fade_level / fade_max;
+		}
+	    }
+	    if(fade_level == fade_max)
+		fade_dir = 0;
+	}
+
+	/* pulse the red colour (done after the fade, for a night effect) */
+	redphase = frames % 64;
+	cmap[red].r = (int)(255 * sin(redphase * M_PI / 63));
+
+	SDL_SetPalette(screen, SDL_PHYSPAL, cmap, 0, boatcols + 64);
+
+	/* update changed areas of the screen */
+	SDL_UpdateRects(screen, NBOATS, updates);
+	frames++;
+    } while(fade_level > 0);
+
+    printf("%d frames, %.2f fps\n",
+	   frames, 1000.0 * frames / (SDL_GetTicks() - start));
+    return 0;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testsem.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,76 @@
+
+/* Simple test of the SDL semaphore code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+#define NUM_THREADS 10
+
+static SDL_sem *sem;
+int alive = 1;
+
+int ThreadFunc(void *data)
+{
+	while ( alive ) {
+		SDL_SemWait(sem);
+		fprintf(stderr, "Thread number %d has got the semaphore (value = %d)!\n", (int)data, SDL_SemValue(sem));
+		SDL_Delay(200);
+		SDL_SemPost(sem);
+		fprintf(stderr, "Thread number %d has released the semaphore (value = %d)!\n", (int)data, SDL_SemValue(sem));
+		SDL_Delay(1); /* For the scheduler */
+	}
+	printf("Thread number %d exiting.\n", (int)data);
+	return 0;
+}
+
+static void killed(int sig)
+{
+	alive = 0;
+}
+
+int main(int argc, char **argv)
+{
+	SDL_Thread *threads[NUM_THREADS];
+	int i, init_sem;
+
+	if(argc < 2) {
+		fprintf(stderr,"Usage: %s init_value\n", argv[0]);
+		exit(1);
+	}
+
+	/* Load the SDL library */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+	signal(SIGTERM, killed);
+	signal(SIGINT, killed);
+	
+	init_sem = atoi(argv[1]);
+	sem = SDL_CreateSemaphore(init_sem);
+	
+	printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem);
+	/* Create all the threads */
+	for( i = 0; i < NUM_THREADS; ++i ) {
+		threads[i] = SDL_CreateThread(ThreadFunc, (void*)i);
+	}
+
+	/* Wait 10 seconds */
+	SDL_Delay(10 * 1000);
+
+	/* Wait for all threads to finish */
+	printf("Waiting for threads to finish\n");
+	alive = 0;
+	for( i = 0; i < NUM_THREADS; ++i ) {
+		SDL_WaitThread(threads[i], NULL);
+	}
+	printf("Finished waiting for threads\n");
+
+	SDL_DestroySemaphore(sem);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testsprite.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,290 @@
+
+/* Simple program:  Move N sprites around on the screen as fast as possible */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <time.h>
+
+#include "SDL.h"
+
+#define NUM_SPRITES	100
+#define MAX_SPEED 	1
+
+SDL_Surface *sprite;
+int numsprites;
+SDL_Rect *sprite_rects;
+SDL_Rect *positions;
+SDL_Rect *velocities;
+int sprites_visible;
+
+int LoadSprite(SDL_Surface *screen, char *file)
+{
+	SDL_Surface *temp;
+
+	/* Load the sprite image */
+	sprite = SDL_LoadBMP(file);
+	if ( sprite == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s", file, SDL_GetError());
+		return(-1);
+	}
+
+	/* Set transparent pixel as the pixel at (0,0) */
+	if ( sprite->format->palette ) {
+		SDL_SetColorKey(sprite, (SDL_SRCCOLORKEY|SDL_RLEACCEL),
+						*(Uint8 *)sprite->pixels);
+	}
+
+	/* Convert sprite to video format */
+	temp = SDL_DisplayFormat(sprite);
+	SDL_FreeSurface(sprite);
+	if ( temp == NULL ) {
+		fprintf(stderr, "Couldn't convert background: %s\n",
+							SDL_GetError());
+		return(-1);
+	}
+	sprite = temp;
+
+	/* We're ready to roll. :) */
+	return(0);
+}
+
+void MoveSprites(SDL_Surface *screen, Uint32 background)
+{
+	int i, nupdates;
+	SDL_Rect area, *position, *velocity;
+
+	nupdates = 0;
+	/* Erase all the sprites if necessary */
+	if ( sprites_visible ) {
+		SDL_FillRect(screen, NULL, background);
+	}
+
+	/* Move the sprite, bounce at the wall, and draw */
+	for ( i=0; i<numsprites; ++i ) {
+		position = &positions[i];
+		velocity = &velocities[i];
+		position->x += velocity->x;
+		if ( (position->x < 0) || (position->x >= screen->w) ) {
+			velocity->x = -velocity->x;
+			position->x += velocity->x;
+		}
+		position->y += velocity->y;
+		if ( (position->y < 0) || (position->y >= screen->h) ) {
+			velocity->y = -velocity->y;
+			position->y += velocity->y;
+		}
+
+		/* Blit the sprite onto the screen */
+		area = *position;
+		SDL_BlitSurface(sprite, NULL, screen, &area);
+		sprite_rects[nupdates++] = area;
+	}
+
+	/* Update the screen! */
+	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		SDL_Flip(screen);
+	} else {
+		SDL_UpdateRects(screen, nupdates, sprite_rects);
+	}
+	sprites_visible = 1;
+}
+
+/* This is a way of telling whether or not to use hardware surfaces */
+Uint32 FastestFlags(Uint32 flags)
+{
+	const SDL_VideoInfo *info;
+
+	/* Hardware acceleration is only used in fullscreen mode */
+	flags |= SDL_FULLSCREEN;
+
+	/* Check for various video capabilities */
+	info = SDL_GetVideoInfo();
+	if ( info->blit_hw_CC && info->blit_fill ) {
+		/* We use accelerated colorkeying and color filling */
+		flags |= SDL_HWSURFACE;
+	}
+	/* If we have enough video memory, and will use accelerated
+	   blits directly to it, then use page flipping.
+	 */
+	if ( (flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		/* Direct hardware blitting without double-buffering
+		   causes really bad flickering.
+		 */
+		SDL_Surface *screen = SDL_GetVideoSurface();
+		if ( info->video_mem > (screen->h*screen->pitch) ) {
+			flags |= SDL_DOUBLEBUF;
+		} else {
+			flags &= ~SDL_HWSURFACE;
+		}
+	}
+
+	/* Return the flags */
+	return(flags);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	Uint8 *mem;
+	int width, height;
+	Uint8  video_bpp;
+	Uint32 videoflags;
+	Uint32 background;
+	int    i, done;
+	SDL_Event event;
+	Uint32 then, now, frames;
+
+	/* Initialize SDL */
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	numsprites = NUM_SPRITES;
+	videoflags = SDL_SWSURFACE|SDL_ANYFORMAT;
+	width = 640;
+	height = 480;
+	video_bpp = 8;
+	while ( argc > 1 ) {
+		--argc;
+		if ( strcmp(argv[argc-1], "-width") == 0 ) {
+			width = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( strcmp(argv[argc-1], "-height") == 0 ) {
+			height = atoi(argv[argc]);
+			--argc;
+		} else
+		if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
+			video_bpp = atoi(argv[argc]);
+			videoflags &= ~SDL_ANYFORMAT;
+			--argc;
+		} else
+		if ( strcmp(argv[argc], "-fast") == 0 ) {
+			videoflags = FastestFlags(videoflags);
+		} else
+		if ( strcmp(argv[argc], "-hw") == 0 ) {
+			videoflags ^= SDL_HWSURFACE;
+		} else
+		if ( strcmp(argv[argc], "-flip") == 0 ) {
+			videoflags ^= SDL_DOUBLEBUF;
+		} else
+		if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
+			videoflags ^= SDL_FULLSCREEN;
+		} else
+		if ( isdigit(argv[argc][0]) ) {
+			numsprites = atoi(argv[argc]);
+		} else {
+			fprintf(stderr, 
+	"Usage: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen] [numsprites]\n",
+								argv[0]);
+			exit(1);
+		}
+	}
+
+	/* Set video mode */
+	screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
+	if ( ! screen ) {
+		fprintf(stderr, "Couldn't set %dx%d video mode: %s\n",
+					width, height, SDL_GetError());
+		exit(2);
+	}
+
+	/* Load the sprite */
+	if ( LoadSprite(screen, "icon.bmp") < 0 ) {
+		exit(1);
+	}
+
+	/* Allocate memory for the sprite info */
+	mem = (Uint8 *)malloc(4*sizeof(SDL_Rect)*numsprites);
+	if ( mem == NULL ) {
+		SDL_FreeSurface(sprite);
+		fprintf(stderr, "Out of memory!\n");
+		exit(2);
+	}
+	sprite_rects = (SDL_Rect *)mem;
+	positions = sprite_rects;
+	sprite_rects += numsprites;
+	velocities = sprite_rects;
+	sprite_rects += numsprites;
+	srand(time(NULL));
+	for ( i=0; i<numsprites; ++i ) {
+		positions[i].x = rand()%screen->w;
+		positions[i].y = rand()%screen->h;
+		positions[i].w = sprite->w;
+		positions[i].h = sprite->h;
+		velocities[i].x = 0;
+		velocities[i].y = 0;
+		while ( ! velocities[i].x && ! velocities[i].y ) {
+			velocities[i].x = (rand()%(MAX_SPEED*2+1))-MAX_SPEED;
+			velocities[i].y = (rand()%(MAX_SPEED*2+1))-MAX_SPEED;
+		}
+	}
+	background = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00);
+
+	/* Print out information about our surfaces */
+	printf("Screen is at %d bits per pixel\n",screen->format->BitsPerPixel);
+	if ( (screen->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		printf("Screen is in video memory\n");
+	} else {
+		printf("Screen is in system memory\n");
+	}
+	if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) {
+		printf("Screen has double-buffering enabled\n");
+	}
+	if ( (sprite->flags & SDL_HWSURFACE) == SDL_HWSURFACE ) {
+		printf("Sprite is in video memory\n");
+	} else {
+		printf("Sprite is in system memory\n");
+	}
+	/* Run a sample blit to trigger blit acceleration */
+	{ SDL_Rect dst;
+		dst.x = 0;
+		dst.y = 0;
+		dst.w = sprite->w;
+		dst.h = sprite->h;
+		SDL_BlitSurface(sprite, NULL, screen, &dst);
+		SDL_FillRect(screen, &dst, background);
+	}
+	if ( (sprite->flags & SDL_HWACCEL) == SDL_HWACCEL ) {
+		printf("Sprite blit uses hardware acceleration\n");
+	}
+	if ( (sprite->flags & SDL_RLEACCEL) == SDL_RLEACCEL ) {
+		printf("Sprite blit uses RLE acceleration\n");
+	}
+
+	/* Loop, blitting sprites and waiting for a keystroke */
+	frames = 0;
+	then = SDL_GetTicks();
+	done = 0;
+	sprites_visible = 0;
+	while ( !done ) {
+		/* Check for events */
+		++frames;
+		while ( SDL_PollEvent(&event) ) {
+			switch (event.type) {
+				case SDL_KEYDOWN:
+					/* Any keypress quits the app... */
+				case SDL_QUIT:
+					done = 1;
+					break;
+				default:
+					break;
+			}
+		}
+		MoveSprites(screen, background);
+	}
+	SDL_FreeSurface(sprite);
+	free(mem);
+
+	/* Print out some timing information */
+	now = SDL_GetTicks();
+	if ( now > then ) {
+		printf("%2.2f frames per second\n",
+					((double)frames*1000)/(now-then));
+	}
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testtimer.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,87 @@
+
+/* Test program to check the resolution of the SDL timer on the current
+   platform
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "SDL.h"
+
+#define DEFAULT_RESOLUTION	1
+
+static int ticks = 0;
+
+static Uint32 ticktock(Uint32 interval)
+{
+	++ticks;
+	return(interval);
+}
+
+static Uint32 callback(Uint32 interval, void *param)
+{
+  printf("Timer %d : param = %d\n", interval, (int) param);
+  return interval;
+}
+
+int main(int argc, char *argv[])
+{
+	int desired;
+	SDL_TimerID t1, t2, t3;
+
+	if ( SDL_Init(SDL_INIT_TIMER) < 0 ) {
+		fprintf(stderr, "Couldn't load SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Start the timer */
+	desired = 0;
+	if ( argv[1] ) {
+		desired = atoi(argv[1]);
+	}
+	if ( desired == 0 ) {
+		desired = DEFAULT_RESOLUTION;
+	}
+	SDL_SetTimer(desired, ticktock);
+
+	/* Wait 10 seconds */
+	printf("Waiting 10 seconds\n");
+	SDL_Delay(10*1000);
+
+	/* Stop the timer */
+	SDL_SetTimer(0, NULL);
+
+	/* Print the results */
+	if ( ticks ) {
+		fprintf(stderr,
+		"Timer resolution: desired = %d ms, actual = %f ms\n",
+					desired, (double)(10*1000)/ticks);
+	}
+	
+	/* Test multiple timers */
+	printf("Testing multiple timers...\n");
+	t1 = SDL_AddTimer(100, callback, (void*)1);
+	if(!t1)
+	  fprintf(stderr,"Could not create timer 1\n");
+	t2 = SDL_AddTimer(50, callback, (void*)2);
+	if(!t2)
+	  fprintf(stderr,"Could not create timer 2\n");
+	t3 = SDL_AddTimer(233, callback, (void*)3);
+	if(!t3)
+	  fprintf(stderr,"Could not create timer 3\n");
+	
+	/* Wait 10 seconds */
+	printf("Waiting 10 seconds\n");
+	SDL_Delay(10*1000);
+
+	printf("Removing timer 1 and waiting 5 more seconds\n");
+	SDL_RemoveTimer(t1);
+
+	SDL_Delay(5*1000);
+
+	SDL_RemoveTimer(t2);
+	SDL_RemoveTimer(t3);
+
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testtypes.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,48 @@
+
+#include <stdio.h>
+
+#include "SDL_types.h"
+
+int main(int argc, char *argv[])
+{
+	int error = 0;
+	int verbose = 1;
+
+	if ( argv[1] && (strcmp(argv[1], "-q") == 0) )
+		verbose = 0;
+
+	if ( sizeof(Uint8) != 1 ) {
+		if ( verbose )
+			printf("sizeof(Uint8) != 1, instead = %d\n",
+								sizeof(Uint8));
+		++error;
+	}
+	if ( sizeof(Uint16) != 2 ) {
+		if ( verbose )
+			printf("sizeof(Uint16) != 2, instead = %d\n",
+								sizeof(Uint16));
+		++error;
+	}
+	if ( sizeof(Uint32) != 4 ) {
+		if ( verbose )
+			printf("sizeof(Uint32) != 4, instead = %d\n",
+								sizeof(Uint32));
+		++error;
+	}
+#ifdef SDL_HAS_64BIT_TYPE
+	if ( sizeof(Uint64) != 8 ) {
+		if ( verbose )
+			printf("sizeof(Uint64) != 8, instead = %d\n",
+								sizeof(Uint64));
+		++error;
+	}
+#else
+	if ( verbose ) {
+		printf("WARNING: No 64-bit datatype on this platform\n");
+	}
+#endif
+	if ( verbose && ! error )
+		printf("All data types are the expected size.\n");
+
+	return( error ? 1 : 0 );
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testver.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,39 @@
+
+/* Test program to compare the compile-time version of SDL with the linked
+   version of SDL
+*/
+
+#include <stdio.h>
+
+#include "SDL.h"
+#include "SDL_byteorder.h"
+
+int main(int argc, char *argv[])
+{
+	SDL_version compiled;
+
+	/* Initialize SDL */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+#ifdef DEBUG
+	fprintf(stderr, "SDL initialized\n");
+#endif
+#if SDL_VERSION_ATLEAST(1, 2, 0)
+	printf("Compiled with SDL 1.2 or newer\n");
+#else
+	printf("Compiled with SDL older than 1.2\n");
+#endif
+	SDL_VERSION(&compiled);
+	printf("Compiled version: %d.%d.%d\n",
+			compiled.major, compiled.minor, compiled.patch);
+	printf("Linked version: %d.%d.%d\n",
+			SDL_Linked_Version()->major,
+			SDL_Linked_Version()->minor,
+			SDL_Linked_Version()->patch);
+	printf("This is a %s endian machine.\n",
+		(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
+	SDL_Quit();
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testvidinfo.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,78 @@
+
+/* Simple program -- figure out what kind of video display we have */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "SDL.h"
+
+int main(int argc, char *argv[])
+{
+	const SDL_VideoInfo *info;
+	int i;
+	SDL_Rect **modes;
+
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr,
+			"Couldn't initialize SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	info = SDL_GetVideoInfo();
+	printf(
+"Current display: %d bits-per-pixel\n",info->vfmt->BitsPerPixel);
+	if ( info->vfmt->palette == NULL ) {
+		printf("	Red Mask = 0x%.8x\n", info->vfmt->Rmask);
+		printf("	Green Mask = 0x%.8x\n", info->vfmt->Gmask);
+		printf("	Blue Mask = 0x%.8x\n", info->vfmt->Bmask);
+	}
+	/* Print available fullscreen video modes */
+	modes = SDL_ListModes(NULL, SDL_FULLSCREEN);
+	if ( modes == (SDL_Rect **)0 ) {
+		printf("No available fullscreen video modes\n");
+	} else
+	if ( modes == (SDL_Rect **)-1 ) {
+		printf("No special fullscreen video modes\n");
+	} else {
+		printf("Fullscreen video modes:\n");
+		for ( i=0; modes[i]; ++i ) {
+			printf("\t%dx%d\n", modes[i]->w, modes[i]->h);
+		}
+	}
+	if ( info->wm_available ) {
+		printf("A window manager is available\n");
+	}
+	if ( info->hw_available ) {
+		printf("Hardware surfaces are available (%dK video memory)\n",
+			info->video_mem);
+	}
+	if ( info->blit_hw ) {
+		printf(
+"Copy blits between hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_hw_CC ) {
+		printf(
+"Colorkey blits between hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_hw_A ) {
+		printf(
+"Alpha blits between hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_sw ) {
+		printf(
+"Copy blits from software surfaces to hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_sw_CC ) {
+		printf(
+"Colorkey blits from software surfaces to hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_sw_A ) {
+		printf(
+"Alpha blits from software surfaces to hardware surfaces are accelerated\n");
+	}
+	if ( info->blit_fill ) {
+		printf(
+"Color fills on hardware surfaces are accelerated\n");
+	}
+	SDL_Quit();
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testwin.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,361 @@
+
+/* Bring up a window and play with it */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#define BENCHMARK_SDL
+
+#define NOTICE(X)	printf("%s", X);
+
+#include "SDL.h"
+
+void DrawPict(SDL_Surface *screen, char *bmpfile,
+					int speedy, int flip, int nofade)
+{
+	SDL_Surface *picture;
+	SDL_Rect dest, update;
+	int i, centered;
+	int ncolors;
+	SDL_Color *colors, *cmap;
+
+	/* Load the image into a surface */
+	if ( bmpfile == NULL ) {
+		bmpfile = "sample.bmp";		/* Sample image */
+	}
+fprintf(stderr, "Loading picture: %s\n", bmpfile);
+	picture = SDL_LoadBMP(bmpfile);
+	if ( picture == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s\n", bmpfile,
+							SDL_GetError());
+		return;
+	}
+
+	/* Set the display colors -- on a hicolor display this is a no-op */
+	if ( picture->format->palette ) {
+		ncolors = picture->format->palette->ncolors;
+		colors  = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+		cmap    = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+		memcpy(colors, picture->format->palette->colors,
+						ncolors*sizeof(SDL_Color));
+	} else {
+		int       r, g, b;
+
+		/* Allocate 256 color palette */
+		ncolors = 256;
+		colors  = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+		cmap    = (SDL_Color *)malloc(ncolors*sizeof(SDL_Color));
+
+		/* Set a 3,3,2 color cube */
+		for ( r=0; r<8; ++r ) {
+			for ( g=0; g<8; ++g ) {
+				for ( b=0; b<4; ++b ) {
+					i = ((r<<5)|(g<<2)|b);
+					colors[i].r = r<<5;
+					colors[i].g = g<<5;
+					colors[i].b = b<<6;
+				}
+			}
+		}
+	}
+NOTICE("testwin: setting colors\n");
+	if ( ! SDL_SetColors(screen, colors, 0, ncolors) &&
+				(screen->format->palette != NULL) ) {
+		fprintf(stderr,
+"Warning: Couldn't set all of the colors, but SDL will map the image\n"
+"         (colormap fading will suffer - try the -warp option)\n"
+		);
+	}
+
+	/* Set the screen to black (not really necessary) */
+	if ( SDL_LockSurface(screen) == 0 ) {
+		Uint32 black;
+		Uint8 *pixels;
+
+		black = SDL_MapRGB(screen->format, 0, 0, 0);
+		pixels = (Uint8 *)screen->pixels;
+		for ( i=0; i<screen->h; ++i ) {
+			memset(pixels, black,
+				screen->w*screen->format->BytesPerPixel);
+			pixels += screen->pitch;
+		}
+		SDL_UnlockSurface(screen);
+		SDL_UpdateRect(screen, 0, 0, 0, 0);
+	}
+	
+	/* Display the picture */
+	if ( speedy ) {
+		SDL_Surface *displayfmt;
+
+fprintf(stderr, "Converting picture\n");
+		displayfmt = SDL_DisplayFormat(picture);
+		if ( displayfmt == NULL ) {
+			fprintf(stderr,
+				"Couldn't convert image: %s\n", SDL_GetError());
+			goto done;
+		}
+		SDL_FreeSurface(picture);
+		picture = displayfmt;
+	}
+	printf("(image surface located in %s memory)\n", 
+			(picture->flags&SDL_HWSURFACE) ? "video" : "system");
+	centered = (screen->w - picture->w)/2;
+	if ( centered < 0 ) {
+		centered = 0;
+	}
+	dest.y = (screen->h - picture->h)/2;
+	dest.w = picture->w;
+	dest.h = picture->h;
+NOTICE("testwin: moving image\n");
+	for ( i=0; i<=centered; ++i ) {
+		dest.x = i;
+		update = dest;
+		if ( SDL_BlitSurface(picture, NULL, screen, &update) < 0 ) {
+			fprintf(stderr, "Blit failed: %s\n", SDL_GetError());
+			break;
+		}
+		if ( flip ) {
+			SDL_Flip(screen);
+		} else {
+			SDL_UpdateRects(screen, 1, &update);
+		}
+	}
+
+#ifdef SCREENSHOT
+	if ( SDL_SaveBMP(screen, "screen.bmp") < 0 )
+		printf("Couldn't save screen: %s\n", SDL_GetError());
+#endif
+
+#ifndef BENCHMARK_SDL
+	/* Let it sit there for a while */
+	SDL_Delay(5*1000);
+#endif
+	/* Fade the colormap */
+	if ( ! nofade ) {
+		int maxstep;
+		SDL_Color final;
+		SDL_Color palcolors[256];
+		struct {
+			Sint16 r, g, b;
+		} cdist[256];
+
+NOTICE("testwin: fading out...\n");
+		memcpy(cmap, colors, ncolors*sizeof(SDL_Color));
+		maxstep = 32-1;
+		final.r = 0xFF;
+		final.g = 0x00;
+		final.b = 0x00;
+		memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+		for ( i=0; i<ncolors; ++i ) {
+			cdist[i].r = final.r-palcolors[i].r;
+			cdist[i].g = final.g-palcolors[i].g;
+			cdist[i].b = final.b-palcolors[i].b;
+		}
+		for ( i=0; i<=maxstep/2; ++i ) {	/* halfway fade */
+			int c;
+			for ( c=0; c<ncolors; ++c ) {
+				colors[c].r =
+					palcolors[c].r+((cdist[c].r*i))/maxstep;
+				colors[c].g =
+					palcolors[c].g+((cdist[c].g*i))/maxstep;
+				colors[c].b =
+					palcolors[c].b+((cdist[c].b*i))/maxstep;
+			}
+			SDL_SetColors(screen, colors, 0, ncolors);
+			SDL_Delay(1);
+		}
+		final.r = 0x00;
+		final.g = 0x00;
+		final.b = 0x00;
+		memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+		for ( i=0; i<ncolors; ++i ) {
+			cdist[i].r = final.r-palcolors[i].r;
+			cdist[i].g = final.g-palcolors[i].g;
+			cdist[i].b = final.b-palcolors[i].b;
+		}
+		maxstep /= 2;
+		for ( i=0; i<=maxstep; ++i ) {		/* finish fade out */
+			int c;
+			for ( c=0; c<ncolors; ++c ) {
+				colors[c].r =
+					palcolors[c].r+((cdist[c].r*i))/maxstep;
+				colors[c].g =
+					palcolors[c].g+((cdist[c].g*i))/maxstep;
+				colors[c].b =
+					palcolors[c].b+((cdist[c].b*i))/maxstep;
+			}
+			SDL_SetColors(screen, colors, 0, ncolors);
+			SDL_Delay(1);
+		}
+		for ( i=0; i<ncolors; ++i ) {
+			colors[i].r = final.r;
+			colors[i].g = final.g;
+			colors[i].b = final.b;
+		}
+		SDL_SetColors(screen, colors, 0, ncolors);
+NOTICE("testwin: fading in...\n");
+		memcpy(palcolors, colors, ncolors*sizeof(SDL_Color));
+		for ( i=0; i<ncolors; ++i ) {
+			cdist[i].r = cmap[i].r-palcolors[i].r;
+			cdist[i].g = cmap[i].g-palcolors[i].g;
+			cdist[i].b = cmap[i].b-palcolors[i].b;
+		}
+		for ( i=0; i<=maxstep; ++i ) {	/* 32 step fade in */
+			int c;
+			for ( c=0; c<ncolors; ++c ) {
+				colors[c].r =
+					palcolors[c].r+((cdist[c].r*i))/maxstep;
+				colors[c].g =
+					palcolors[c].g+((cdist[c].g*i))/maxstep;
+				colors[c].b =
+					palcolors[c].b+((cdist[c].b*i))/maxstep;
+			}
+			SDL_SetColors(screen, colors, 0, ncolors);
+			SDL_Delay(1);
+		}
+NOTICE("testwin: fading over\n");
+	}
+	
+done:
+	/* Free the picture and return */
+	SDL_FreeSurface(picture);
+	free(colors); free(cmap);
+	return;
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	/* Options */
+	int speedy, flip, nofade;
+	int delay;
+	int w, h;
+	int desired_bpp;
+	Uint32 video_flags;
+#ifdef BENCHMARK_SDL
+	Uint32 then, now;
+#endif
+	/* Set default options and check command-line */
+	speedy = 0;
+	flip = 0;
+	nofade = 0;
+	delay = 1;
+	w = 640;
+	h = 480;
+	desired_bpp = 0;
+	video_flags = 0;
+	while ( argc > 1 ) {
+		if ( strcmp(argv[1], "-speedy") == 0 ) {
+			speedy = 1;
+			argv += 1;
+			argc -= 1;
+		} else
+		if ( strcmp(argv[1], "-nofade") == 0 ) {
+			nofade = 1;
+			argv += 1;
+			argc -= 1;
+		} else
+		if ( strcmp(argv[1], "-delay") == 0 ) {
+			if ( argv[2] ) {
+				delay = atoi(argv[2]);
+				argv += 2;
+				argc -= 2;
+			} else {
+				fprintf(stderr,
+				"The -delay option requires an argument\n");
+				exit(1);
+			}
+		} else
+		if ( strcmp(argv[1], "-width") == 0 ) {
+			if ( argv[2] && ((w = atoi(argv[2])) > 0) ) {
+				argv += 2;
+				argc -= 2;
+			} else {
+				fprintf(stderr,
+				"The -width option requires an argument\n");
+				exit(1);
+			}
+		} else
+		if ( strcmp(argv[1], "-height") == 0 ) {
+			if ( argv[2] && ((h = atoi(argv[2])) > 0) ) {
+				argv += 2;
+				argc -= 2;
+			} else {
+				fprintf(stderr,
+				"The -height option requires an argument\n");
+				exit(1);
+			}
+		} else
+		if ( strcmp(argv[1], "-bpp") == 0 ) {
+			if ( argv[2] ) {
+				desired_bpp = atoi(argv[2]);
+				argv += 2;
+				argc -= 2;
+			} else {
+				fprintf(stderr,
+				"The -bpp option requires an argument\n");
+				exit(1);
+			}
+		} else
+		if ( strcmp(argv[1], "-warp") == 0 ) {
+			video_flags |= SDL_HWPALETTE;
+			argv += 1;
+			argc -= 1;
+		} else
+		if ( strcmp(argv[1], "-hw") == 0 ) {
+			video_flags |= SDL_HWSURFACE;
+			argv += 1;
+			argc -= 1;
+		} else
+		if ( strcmp(argv[1], "-flip") == 0 ) {
+			video_flags |= SDL_DOUBLEBUF;
+			argv += 1;
+			argc -= 1;
+		} else
+		if ( strcmp(argv[1], "-fullscreen") == 0 ) {
+			video_flags |= SDL_FULLSCREEN;
+			argv += 1;
+			argc -= 1;
+		} else
+			break;
+	}
+
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr,
+			"Couldn't initialize SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);			/* Clean up on exit */
+
+	/* Initialize the display */
+	screen = SDL_SetVideoMode(w, h, desired_bpp, video_flags);
+	if ( screen == NULL ) {
+		fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+					w, h, desired_bpp, SDL_GetError());
+		exit(1);
+	}
+	printf("Set %dx%dx%d mode\n",
+			screen->w, screen->h, screen->format->BitsPerPixel);
+	printf("(video surface located in %s memory)\n",
+			(screen->flags&SDL_HWSURFACE) ? "video" : "system");
+	if ( screen->flags & SDL_DOUBLEBUF ) {
+		printf("Double-buffering enabled\n");
+		flip = 1;
+	}
+
+	/* Set the window manager title bar */
+	SDL_WM_SetCaption("SDL test window", "testwin");
+
+	/* Do all the drawing work */
+#ifdef BENCHMARK_SDL
+	then = SDL_GetTicks();
+	DrawPict(screen, argv[1], speedy, flip, nofade);
+	now = SDL_GetTicks();
+	printf("Time: %d milliseconds\n", now-then);
+#else
+	DrawPict(screen, argv[1], speedy, flip, nofade);
+#endif
+	SDL_Delay(delay*1000);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testwm.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,350 @@
+
+/* Test out the window manager interaction functions */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "SDL.h"
+
+/* Is the cursor visible? */
+static int visible = 1;
+
+SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+{
+	SDL_Surface *icon;
+	Uint8       *pixels;
+	Uint8       *mask;
+	int          mlen, i;
+
+	*maskp = NULL;
+
+	/* Load the icon surface */
+	icon = SDL_LoadBMP(file);
+	if ( icon == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+		return(NULL);
+	}
+
+	/* Check width and height */
+	if ( (icon->w%8) != 0 ) {
+		fprintf(stderr, "Icon width must be a multiple of 8!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+	if ( icon->format->palette == NULL ) {
+		fprintf(stderr, "Icon must have a palette!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+
+	/* Set the colorkey */
+	SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *)icon->pixels));
+
+	/* Create the mask */
+	pixels = (Uint8 *)icon->pixels;
+	printf("Transparent pixel: (%d,%d,%d)\n",
+				icon->format->palette->colors[*pixels].r,
+				icon->format->palette->colors[*pixels].g,
+				icon->format->palette->colors[*pixels].b);
+	mlen = icon->w*icon->h;
+	mask = (Uint8 *)malloc(mlen/8);
+	if ( mask == NULL ) {
+		fprintf(stderr, "Out of memory!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+	memset(mask, 0, mlen/8);
+	for ( i=0; i<mlen; ) {
+		if ( pixels[i] != *pixels )
+			mask[i/8] |= 0x01;
+		++i;
+		if ( (i%8) != 0 )
+			mask[i/8] <<= 1;
+	}
+	*maskp = mask;
+	return(icon);
+}
+
+void HotKey_ToggleFullScreen(void)
+{
+	SDL_Surface *screen;
+
+	screen = SDL_GetVideoSurface();
+	if ( SDL_WM_ToggleFullScreen(screen) ) {
+		printf("Toggled fullscreen mode - now %s\n",
+		    (screen->flags&SDL_FULLSCREEN) ? "fullscreen" : "windowed");
+	} else {
+		printf("Unable to toggle fullscreen mode\n");
+	}
+}
+
+void HotKey_ToggleGrab(void)
+{
+	SDL_GrabMode mode;
+
+	printf("Ctrl-G: toggling input grab!\n");
+	mode = SDL_WM_GrabInput(SDL_GRAB_QUERY);
+	if ( mode == SDL_GRAB_ON ) {
+		printf("Grab was on\n");
+	} else {
+		printf("Grab was off\n");
+	}
+	mode = SDL_WM_GrabInput(!mode);
+	if ( mode == SDL_GRAB_ON ) {
+		printf("Grab is now on\n");
+	} else {
+		printf("Grab is now off\n");
+	}
+}
+
+void HotKey_Iconify(void)
+{
+	printf("Ctrl-Z: iconifying window!\n");
+	SDL_WM_IconifyWindow();
+}
+
+void HotKey_Quit(void)
+{
+	SDL_Event event;
+
+	printf("Posting internal quit request\n");
+	event.type = SDL_USEREVENT;
+	SDL_PushEvent(&event);
+}
+
+int FilterEvents(const SDL_Event *event)
+{
+	static int reallyquit = 0;
+
+	switch (event->type) {
+
+		case SDL_ACTIVEEVENT:
+			/* See what happened */
+			printf("App %s ",
+				event->active.gain ? "gained" : "lost");
+			if ( event->active.state & SDL_APPACTIVE )
+				printf("active ");
+			if ( event->active.state & SDL_APPMOUSEFOCUS )
+				printf("mouse ");
+			if ( event->active.state & SDL_APPINPUTFOCUS )
+				printf("input ");
+			printf("focus\n");
+
+			/* See if we are iconified or restored */
+			if ( event->active.state & SDL_APPACTIVE ) {
+				printf("App has been %s\n",
+					event->active.gain ?
+						 "restored" : "iconified");
+			}
+			return(0);
+
+		/* We want to toggle visibility on buttonpress */
+		case SDL_MOUSEBUTTONDOWN:
+		case SDL_MOUSEBUTTONUP:
+			if ( event->button.state == SDL_PRESSED ) {
+				visible = !visible;
+				SDL_ShowCursor(visible);
+			}
+			printf("Mouse button %d has been %s\n",
+				event->button.button,
+				(event->button.state == SDL_PRESSED) ?
+						"pressed" : "released");
+			return(0);
+
+		/* Show relative mouse motion */
+		case SDL_MOUSEMOTION:
+#if 0
+			printf("Mouse relative motion: {%d,%d}\n",
+				event->motion.xrel, event->motion.yrel);
+#endif
+			return(0);
+
+		case SDL_KEYDOWN:
+			if ( event->key.keysym.sym == SDLK_ESCAPE ) {
+				HotKey_Quit();
+			}
+			if ( (event->key.keysym.sym == SDLK_g) &&
+			     (event->key.keysym.mod & KMOD_CTRL) ) {
+				HotKey_ToggleGrab();
+			}
+			if ( (event->key.keysym.sym == SDLK_z) &&
+			     (event->key.keysym.mod & KMOD_CTRL) ) {
+				HotKey_Iconify();
+			}
+			if ( (event->key.keysym.sym == SDLK_RETURN) &&
+			     (event->key.keysym.mod & KMOD_ALT) ) {
+				HotKey_ToggleFullScreen();
+			}
+			return(0);
+
+		/* Pass the video resize event through .. */
+		case SDL_VIDEORESIZE:
+			return(1);
+
+		/* This is important!  Queue it if we want to quit. */
+		case SDL_QUIT:
+			if ( ! reallyquit ) {
+				reallyquit = 1;
+				printf("Quit requested\n");
+				return(0);
+			}
+			printf("Quit demanded\n");
+			return(1);
+
+		/* This will never happen because events queued directly
+		   to the event queue are not filtered.
+		 */
+		case SDL_USEREVENT:
+			return(1);
+
+		/* Drop all other events */
+		default:
+			return(0);
+	}
+}
+
+static Uint8  video_bpp;
+static Uint32 video_flags;
+
+int SetVideoMode(int w, int h)
+{
+	SDL_Surface *screen;
+	int i;
+	Uint8 *buffer;
+	SDL_Color palette[256];
+
+	screen = SDL_SetVideoMode(w, h, video_bpp, video_flags);
+	if (  screen == NULL ) {
+		fprintf(stderr, "Couldn't set %dx%dx%d video mode: %s\n",
+					w, h, video_bpp, SDL_GetError());
+		return(-1);
+	}
+	printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
+						"fullscreen" : "windowed");
+
+	/* Set the surface pixels and refresh! */
+	for ( i=0; i<256; ++i ) {
+		palette[i].r = 255-i;
+		palette[i].g = 255-i;
+		palette[i].b = 255-i;
+	}
+	SDL_SetColors(screen, palette, 0, 256);
+	if ( SDL_LockSurface(screen) < 0 ) {
+		fprintf(stderr, "Couldn't lock display surface: %s\n",
+							SDL_GetError());
+		return(-1);
+	}
+	buffer = (Uint8 *)screen->pixels;
+	for ( i=0; i<screen->h; ++i ) {
+		memset(buffer,(i*255)/screen->h,
+				screen->w*screen->format->BytesPerPixel);
+		buffer += screen->pitch;
+	}
+	SDL_UnlockSurface(screen);
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+	return(0);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Event event;
+	char *title;
+	SDL_Surface *icon;
+	Uint8 *icon_mask;
+	int parsed;
+
+	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
+		fprintf(stderr,
+			"Couldn't initialize SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Check command line arguments */
+	video_bpp = 8;
+	video_flags = SDL_SWSURFACE;
+	parsed = 1;
+	while ( parsed ) {
+		if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) {
+			video_flags |= SDL_FULLSCREEN;
+			argc -= 1;
+			argv += 1;
+		} else
+		if ( (argc >= 2) && (strcmp(argv[1], "-resize") == 0) ) {
+			video_flags |= SDL_RESIZABLE;
+			argc -= 1;
+			argv += 1;
+		} else
+		if ( (argc >= 2) && (strcmp(argv[1], "-noframe") == 0) ) {
+			video_flags |= SDL_NOFRAME;
+			argc -= 1;
+			argv += 1;
+		} else
+		if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) {
+			video_bpp = atoi(argv[2]);
+			argc -= 2;
+			argv += 2;
+		} else {
+			parsed = 0;
+		}
+	}
+
+	/* Set the icon -- this must be done before the first mode set */
+	icon = LoadIconSurface("icon.bmp", &icon_mask);
+	if ( icon != NULL ) {
+		SDL_WM_SetIcon(icon, icon_mask);
+	}
+	if ( icon_mask != NULL )
+		free(icon_mask);
+
+	/* Set the title bar */
+	if ( argv[1] == NULL )
+		title = "Testing  1.. 2.. 3...";
+	else
+		title = argv[1];
+	SDL_WM_SetCaption(title, "testwm");
+
+	/* See if it's really set */
+	SDL_WM_GetCaption(&title, NULL);
+	if ( title )
+		printf("Title was set to: %s\n", title);
+	else
+		printf("No window title was set!\n");
+
+	/* Initialize the display */
+	if ( SetVideoMode(640, 480) < 0 ) {
+		return(1);
+	}
+
+	/* Set an event filter that discards everything but QUIT */
+	SDL_SetEventFilter(FilterEvents);
+
+	/* Ignore key up events, they don't even get filtered */
+	SDL_EventState(SDL_KEYUP, SDL_IGNORE);
+
+	/* Loop, waiting for QUIT */
+	while ( SDL_WaitEvent(&event) ) {
+		switch (event.type) {
+			case SDL_VIDEORESIZE:
+				printf("Got a resize event: %dx%d\n",
+				       event.resize.w, event.resize.h);
+				SetVideoMode(event.resize.w, event.resize.h);
+				break;
+			case SDL_USEREVENT:
+				printf("Handling internal quit request\n");
+				/* Fall through to the quit handler */
+			case SDL_QUIT:
+				printf("Bye bye..\n");
+				return(0);
+			default:
+				/* This should never happen */
+				printf("Warning: Event %d wasn't filtered\n",
+								event.type);
+				break;
+		}
+	}
+	printf("SDL_WaitEvent() error: %s\n", SDL_GetError());
+	return(255);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/threadwin.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,307 @@
+
+/* Test out the multi-threaded event handling functions */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+/* Are we done yet? */
+static int done = 0;
+
+/* Is the cursor visible? */
+static int visible = 1;
+
+SDL_Surface *LoadIconSurface(char *file, Uint8 **maskp)
+{
+	SDL_Surface *icon;
+	Uint8       *pixels;
+	Uint8       *mask;
+	int          mlen, i;
+
+	*maskp = NULL;
+
+	/* Load the icon surface */
+	icon = SDL_LoadBMP(file);
+	if ( icon == NULL ) {
+		fprintf(stderr, "Couldn't load %s: %s\n", file, SDL_GetError());
+		return(NULL);
+	}
+
+	/* Check width and height */
+	if ( (icon->w%8) != 0 ) {
+		fprintf(stderr, "Icon width must be a multiple of 8!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+	if ( icon->format->palette == NULL ) {
+		fprintf(stderr, "Icon must have a palette!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+
+	/* Set the colorkey */
+	SDL_SetColorKey(icon, SDL_SRCCOLORKEY, *((Uint8 *)icon->pixels));
+
+	/* Create the mask */
+	pixels = (Uint8 *)icon->pixels;
+	printf("Transparent pixel: (%d,%d,%d)\n",
+				icon->format->palette->colors[*pixels].r,
+				icon->format->palette->colors[*pixels].g,
+				icon->format->palette->colors[*pixels].b);
+	mlen = icon->w*icon->h;
+	mask = (Uint8 *)malloc(mlen/8);
+	if ( mask == NULL ) {
+		fprintf(stderr, "Out of memory!\n");
+		SDL_FreeSurface(icon);
+		return(NULL);
+	}
+	memset(mask, 0, mlen/8);
+	for ( i=0; i<mlen; ) {
+		if ( pixels[i] != *pixels )
+			mask[i/8] |= 0x01;
+		++i;
+		if ( (i%8) != 0 )
+			mask[i/8] <<= 1;
+	}
+	*maskp = mask;
+	return(icon);
+}
+
+int FilterEvents(const SDL_Event *event)
+{
+	static int reallyquit = 0;
+
+	switch (event->type) {
+
+		case SDL_ACTIVEEVENT:
+			/* See what happened */
+			printf("App %s ",
+				event->active.gain ? "gained" : "lost");
+			if ( event->active.state & SDL_APPACTIVE )
+				printf("active ");
+			if ( event->active.state & SDL_APPMOUSEFOCUS )
+				printf("mouse ");
+			if ( event->active.state & SDL_APPINPUTFOCUS )
+				printf("input ");
+			printf("focus\n");
+
+			/* See if we are iconified or restored */
+			if ( event->active.state & SDL_APPACTIVE ) {
+				printf("App has been %s\n",
+					event->active.gain ?
+						 "restored" : "iconified");
+			}
+			return(0);
+
+		/* This is important!  Queue it if we want to quit. */
+		case SDL_QUIT:
+			if ( ! reallyquit ) {
+				reallyquit = 1;
+				printf("Quit requested\n");
+				return(0);
+			}
+			printf("Quit demanded\n");
+			return(1);
+
+		/* Mouse and keyboard events go to threads */
+		case SDL_MOUSEMOTION:
+		case SDL_MOUSEBUTTONDOWN:
+		case SDL_MOUSEBUTTONUP:
+		case SDL_KEYDOWN:
+		case SDL_KEYUP:
+			return(1);
+
+		/* Drop all other events */
+		default:
+			return(0);
+	}
+}
+
+int HandleMouse(void *unused)
+{
+	SDL_Event events[10];
+	int i, found;
+	Uint32 mask;
+
+	/* Handle mouse events here */
+	mask = (SDL_MOUSEMOTIONMASK|SDL_MOUSEBUTTONDOWNMASK|SDL_MOUSEBUTTONUPMASK);
+	while ( ! done ) {
+		found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
+		for ( i=0; i<found; ++i ) {
+			switch(events[i].type) {
+				/* We want to toggle visibility on buttonpress */
+				case SDL_MOUSEBUTTONDOWN:
+				case SDL_MOUSEBUTTONUP:
+					if ( events[i].button.state == SDL_PRESSED ) {
+						visible = !visible;
+						SDL_ShowCursor(visible);
+					}
+					printf("Mouse button %d has been %s\n",
+						events[i].button.button,
+						(events[i].button.state == SDL_PRESSED) ?
+						"pressed" : "released");
+					break;
+				/* Show relative mouse motion */
+				case SDL_MOUSEMOTION:
+					printf("Mouse relative motion: {%d,%d}\n",
+							events[i].motion.xrel, events[i].motion.yrel);
+					break;
+			}
+		}
+		/* Give up some CPU to allow events to arrive */
+		SDL_Delay(20);
+	}
+	return(0);
+}
+
+int HandleKeyboard(void *unused)
+{
+	SDL_Event events[10];
+	int i, found;
+	Uint32 mask;
+
+	/* Handle mouse events here */
+	mask = (SDL_KEYDOWNMASK|SDL_KEYUPMASK);
+	while ( ! done ) {
+		found = SDL_PeepEvents(events, 10, SDL_GETEVENT, mask);
+		for ( i=0; i<found; ++i ) {
+			switch(events[i].type) {
+			    /* We want to toggle visibility on buttonpress */
+			    case SDL_KEYDOWN:
+			    case SDL_KEYUP:
+			    	/* Allow hitting <ESC> to quit the app */
+			    	if ( events[i].key.keysym.sym == SDLK_ESCAPE ) {
+			    		done = 1;
+			    	}
+			    	printf("Key '%c' has been %s\n",
+						events[i].key.keysym.unicode,
+					(events[i].key.state == SDL_PRESSED) ?
+						"pressed" : "released");
+			    	break;
+			}
+		}
+		/* Give up some CPU to allow events to arrive */
+		SDL_Delay(20);
+	}
+	return(0);
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Surface *screen;
+	SDL_Surface *icon;
+	Uint8 *icon_mask;
+	int i, parsed;
+	Uint8 *buffer;
+	SDL_Color palette[256];
+	Uint32 init_flags;
+	Uint8  video_bpp;
+	Uint32 video_flags;
+	SDL_Thread *mouse_thread;
+	SDL_Thread *keybd_thread;
+
+	/* Set the options, based on command line arguments */
+	init_flags = SDL_INIT_VIDEO;
+	video_bpp = 8;
+	video_flags = SDL_SWSURFACE;
+	parsed = 1;
+	while ( parsed ) {
+		/* If the threaded option is enabled, and the SDL library hasn't
+		   been compiled with threaded events enabled, then the mouse and
+		   keyboard won't respond.
+		 */
+		if ( (argc >= 2) && (strcmp(argv[1], "-threaded") == 0) ) {
+			init_flags |= SDL_INIT_EVENTTHREAD;
+			argc -= 1;
+			argv += 1;
+			printf("Running with threaded events\n");
+		} else
+		if ( (argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0) ) {
+			video_flags |= SDL_FULLSCREEN;
+			argc -= 1;
+			argv += 1;
+		} else
+		if ( (argc >= 3) && (strcmp(argv[1], "-bpp") == 0) ) {
+			video_bpp = atoi(argv[2]);
+			argc -= 2;
+			argv += 2;
+		} else {
+			parsed = 0;
+		}
+	}
+
+	/* Initialize SDL with the requested flags */
+	if ( SDL_Init(init_flags) < 0 ) {
+		fprintf(stderr,
+			"Couldn't initialize SDL: %s\n", SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+	/* Set the icon -- this must be done before the first mode set */
+	icon = LoadIconSurface("icon.bmp", &icon_mask);
+	if ( icon != NULL ) {
+		SDL_WM_SetIcon(icon, icon_mask);
+	}
+	if ( icon_mask != NULL )
+		free(icon_mask);
+
+	/* Initialize the display */
+	screen = SDL_SetVideoMode(640, 480, video_bpp, video_flags);
+	if (  screen == NULL ) {
+		fprintf(stderr, "Couldn't set 640x480x%d video mode: %s\n",
+						video_bpp, SDL_GetError());
+		exit(1);
+	}
+	printf("Running in %s mode\n", screen->flags & SDL_FULLSCREEN ?
+						"fullscreen" : "windowed");
+
+	/* Enable printable characters */
+	SDL_EnableUNICODE(1);
+
+	/* Set an event filter that discards everything but QUIT */
+	SDL_SetEventFilter(FilterEvents);
+
+	/* Create the event handling threads */
+	mouse_thread = SDL_CreateThread(HandleMouse, NULL);
+	keybd_thread = SDL_CreateThread(HandleKeyboard, NULL);
+
+	/* Set the surface pixels and refresh! */
+	for ( i=0; i<256; ++i ) {
+		palette[i].r = 255-i;
+		palette[i].g = 255-i;
+		palette[i].b = 255-i;
+	}
+	SDL_SetColors(screen, palette, 0, 256);
+	if ( SDL_LockSurface(screen) < 0 ) {
+		fprintf(stderr, "Couldn't lock display surface: %s\n",
+							SDL_GetError());
+		exit(2);
+	}
+	buffer = (Uint8 *)screen->pixels;
+	for ( i=0; i<screen->h; ++i ) {
+		memset(buffer,(i*255)/screen->h,
+				screen->w*screen->format->BytesPerPixel);
+		buffer += screen->pitch;
+	}
+	SDL_UnlockSurface(screen);
+	SDL_UpdateRect(screen, 0, 0, 0, 0);
+
+	/* Loop, waiting for QUIT */
+	while ( ! done ) {
+		if ( ! (init_flags & SDL_INIT_EVENTTHREAD) ) {
+			SDL_PumpEvents(); /* Needed when event thread is off */
+		}
+		if ( SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUITMASK) ) {
+			done = 1;
+		}
+		/* Give up some CPU so the events can accumulate */
+		SDL_Delay(20);
+	}
+	SDL_WaitThread(mouse_thread, NULL);
+	SDL_WaitThread(keybd_thread, NULL);
+	return(0);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/torturethread.c	Thu Apr 26 16:45:43 2001 +0000
@@ -0,0 +1,85 @@
+
+/* Simple test of the SDL threading code */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_thread.h"
+
+#define NUMTHREADS 10
+
+static char volatile time_for_threads_to_die[NUMTHREADS];
+
+int SubThreadFunc(void *data) {
+	while(! *(int volatile *)data) {
+		; /*SDL_Delay(10); /* do nothing */
+	}
+	return 0;
+}
+
+int ThreadFunc(void *data) {
+	SDL_Thread *sub_threads[NUMTHREADS];
+	int flags[NUMTHREADS];
+	int i;
+	int tid = (int ) data;
+
+	fprintf(stderr, "Creating Thread %d\n", tid);
+
+	for(i = 0; i < NUMTHREADS; i++) {
+		flags[i] = 0;
+		sub_threads[i] = SDL_CreateThread(SubThreadFunc, &flags[i]);
+	}
+
+	printf("Thread '%d' waiting for signal\n", tid);
+	while(time_for_threads_to_die[tid] != 1) {
+		; /* do nothing */
+	}
+
+	printf("Thread '%d' sending signals to subthreads\n", tid);
+	for(i = 0; i <  NUMTHREADS; i++) {
+		flags[i] = 1;
+		SDL_WaitThread(sub_threads[i], NULL);
+	}
+
+	printf("Thread '%d' exiting!\n", tid);
+
+	return 0;
+}
+
+int main(int argc, char *argv[])
+{
+	SDL_Thread *threads[NUMTHREADS];
+	int i;
+
+	/* Load the SDL library */
+	if ( SDL_Init(0) < 0 ) {
+		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
+		exit(1);
+	}
+	atexit(SDL_Quit);
+
+
+	signal(SIGSEGV, SIG_DFL);
+	for(i = 0; i < NUMTHREADS; i++) {
+		time_for_threads_to_die[i] = 0;
+		threads[i] = SDL_CreateThread(ThreadFunc, (void *) i);
+	
+		if ( threads[i] == NULL ) {
+			fprintf(stderr,
+			"Couldn't create thread: %s\n", SDL_GetError());
+			exit(1);
+		}
+	}
+
+	for(i = 0; i < NUMTHREADS; i++) {
+		time_for_threads_to_die[i] = 1;
+	}
+
+	for(i = NUMTHREADS-1; i >= 0; --i) {
+		SDL_WaitThread(threads[i], NULL);
+	}
+	return(0);	/* Never reached */
+}