From d06594ed217833ac9a253a2f6c3fd9bf68f7ef9f Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 15:26:02 +0100 Subject: [PATCH 01/21] Begin adding AmigaOS3.x support --- CMake/git.cmake | 17 + CMake/out_of_tree.cmake | 3 + CMakeLists.txt | 236 ++++ README.AmigaOS | 141 +- amiga/makefile-support/SDL_amigaversion.h | 4 + amiga/makefile-support/SDL_version.h | 91 ++ include/SDL_amigaversion.h.in | 4 + include/SDL_config.h | 300 +--- include/SDL_config_amiga.h | 170 ++- include/SDL_config_amigaos4.h | 311 ++++ include/SDL_version.h.in | 91 ++ include/SDL_video.h | 17 + mydebug.h | 16 + src/SDL.c | 13 +- src/audio/SDL_audio.c | 100 +- src/audio/SDL_sysaudio.h | 27 +- src/audio/amigaos/SDL_ahiaudio.c | 223 ++- src/audio/amigaos/SDL_ahiaudio.h | 36 +- src/cdrom/beos/SDL_syscdrom.cc | 68 +- src/cdrom/macosx/SDL_syscdrom.c | 164 ++- src/cpuinfo/SDL_cpuinfo.c | 31 +- src/events/SDL_mouse.c | 5 + src/thread/amigaos/SDL_syssem.c | 521 ++++++- src/thread/amigaos/SDL_systhread.c | 236 +++- src/thread/amigaos/SDL_systhread_c.h | 25 +- src/thread/amigaos/SDL_thread.c | 71 +- src/timer/SDL_systimer.h | 4 + src/timer/amigaos/SDL_systimer.c | 360 +++-- src/timer/dummy/SDL_systimer.c | 2 +- src/timer/mint/SDL_vbltimer.S | 4 +- src/video/SDL_RLEaccel.c | 5 +- src/video/SDL_blit.c | 11 + src/video/SDL_blit_A.c | 4 + src/video/SDL_blit_N.c | 100 ++ src/video/SDL_surface.c | 60 +- src/video/SDL_video.c | 749 +++++----- src/video/SDL_yuv_sw.c | 85 +- src/video/cybergfx/SDL_amigaevents.c | 459 ++++-- src/video/cybergfx/SDL_amigamouse.c | 75 +- src/video/cybergfx/SDL_amigamouse_c.h | 3 +- src/video/cybergfx/SDL_cgxaccel.c | 286 ++-- src/video/cybergfx/SDL_cgxgl.c | 6 +- src/video/cybergfx/SDL_cgxgl_c.h | 1 + src/video/cybergfx/SDL_cgximage.c | 960 ++++++++----- src/video/cybergfx/SDL_cgxmodes.c | 397 +++--- src/video/cybergfx/SDL_cgxvideo.c | 1569 ++++++++++++--------- src/video/cybergfx/SDL_cgxvideo.h | 158 ++- src/video/cybergfx/SDL_cgxwm.c | 303 +++- 48 files changed, 5672 insertions(+), 2850 deletions(-) create mode 100644 CMake/git.cmake create mode 100644 CMake/out_of_tree.cmake create mode 100644 CMakeLists.txt create mode 100644 amiga/makefile-support/SDL_amigaversion.h create mode 100644 amiga/makefile-support/SDL_version.h create mode 100644 include/SDL_amigaversion.h.in create mode 100644 include/SDL_config_amigaos4.h create mode 100644 include/SDL_version.h.in create mode 100644 mydebug.h diff --git a/CMake/git.cmake b/CMake/git.cmake new file mode 100644 index 000000000..daaec569b --- /dev/null +++ b/CMake/git.cmake @@ -0,0 +1,17 @@ +function(get_git_tag output_var) + execute_process( + COMMAND git describe --abbrev=0 --tags + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_TAG + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(${output_var} ${GIT_TAG} PARENT_SCOPE) +endfunction(get_git_tag) + +function(get_git_commit_hash output_var) + execute_process( + COMMAND git log -1 --format=-%h + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_COMMIT_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE) + set(${output_var} ${GIT_COMMIT_HASH} PARENT_SCOPE) +endfunction(get_git_commit_hash) \ No newline at end of file diff --git a/CMake/out_of_tree.cmake b/CMake/out_of_tree.cmake new file mode 100644 index 000000000..17b83051b --- /dev/null +++ b/CMake/out_of_tree.cmake @@ -0,0 +1,3 @@ +if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + message(WARNING [[In-source build detected, please eg. create a new directory and use `cmake ..`]]) +endif() \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..c1f939294 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,236 @@ +cmake_minimum_required(VERSION 3.10) + +include(CMake/out_of_tree.cmake) + +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Release") +endif() + +option(DEBUG "Enable debug mode in engine" OFF) +option(APOLLOBLIT "Enable AMMX blitting for Vampire Accelerators" ON) +option(DEBUG_RELEASE "Enable options for debug release" OFF) + +if(DEBUG_RELEASE) + set(CMAKE_BUILD_TYPE "Debug") + set(DEBUG ON) +endif() + +include(CMake/git.cmake) +get_git_tag(GIT_TAG) +if(NOT CMAKE_BUILD_TYPE MATCHES "Release") + get_git_commit_hash(GIT_COMMIT_HASH) +endif() + +project(SDL1.2 + VERSION ${GIT_TAG} + LANGUAGES C ASM) + +# Lowercase project name for binaries and packaging +string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) +string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME_LOWER) +string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} SYSTEM_ARCH_LOWER) + +include(GNUInstallDirs) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake") + +set(LIBNAME "SDL") + +# Make version variables +string(REPLACE "." ";" VERSION_LIST ${GIT_TAG}) +list(GET VERSION_LIST 0 SDL_MAJOR_VERSION) +list(GET VERSION_LIST 1 SDL_MINOR_VERSION) +list(GET VERSION_LIST 2 SDL_PATCHLEVEL) + +message(STATUS "SDL version: ${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}") + +# Build date Information +string(TIMESTAMP VER_YEAR "%Y") +string(TIMESTAMP VER_MONTH "%m") +string(TIMESTAMP VER_DAY "%d") +string(REGEX REPLACE "^0+" "" VER_MONTH "${VER_MONTH}") +string(REGEX REPLACE "^0+" "" VER_DAY "${VER_DAY}") + +# Set Amiga version +set(AMIGA_VERSION "${SDL_MAJOR_VERSION}${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}") + +# Final build filename, for example "milkytracker-1.02.00-win32.zip" +set(BUILD_FILENAME "SDL-${GIT_TAG}-${SYSTEM_NAME_LOWER}-${SYSTEM_ARCH_LOWER}") + +set(CPACK_GENERATOR ZIP) +set(CPACK_PACKAGE_NAME ${PROJECT_NAME_LOWER}) +set(CPACK_PACKAGE_VENDOR "AmigaDev Team") +set(CPACK_PACKAGE_CONTACT "support@amigadev.com") +set(CPACK_PACKAGE_FILE_NAME ${BUILD_FILENAME}) +set(CPACK_PACKAGE_VERSION_MAJOR ${SDL_MAJOR_VERSION}) +set(CPACK_PACKAGE_VERSION_MINOR ${SDL_MINOR_VERSION}) +set(CPACK_PACKAGE_VERSION_PATCH ${SDL_PATCHLEVEL}) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SDL1.2") +include(CPack) + +# Generate version header from the above +configure_file( + ${PROJECT_SOURCE_DIR}/include/SDL_version.h.in + ${PROJECT_BINARY_DIR}/include/SDL_version.h +) + +configure_file( + ${PROJECT_SOURCE_DIR}/include/SDL_amigaversion.h.in + ${PROJECT_BINARY_DIR}/include/SDL_amigaversion.h +) + +set(CMAKE_CXX_STANDARD 14) + + + +add_library(${LIBNAME} + STATIC + # MAIN + ${PROJECT_SOURCE_DIR}/src/SDL.c + ${PROJECT_SOURCE_DIR}/src/SDL_error.c + ${PROJECT_SOURCE_DIR}/src/SDL_fatal.c + ${PROJECT_SOURCE_DIR}/SDL_lutstub.s + + # CPUINFO + ${PROJECT_SOURCE_DIR}/src/cpuinfo/SDL_cpuinfo.c + + # AUDIO + ${PROJECT_SOURCE_DIR}/src/audio/SDL_audio.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_audiocvt.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer_m68k.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_wave.c + #${PROJECT_SOURCE_DIR}/src/audio/dummy/SDL_dummyaudio.c + #${PROJECT_SOURCE_DIR}/src/audio/disk/SDL_diskaudio.c + ${PROJECT_SOURCE_DIR}/src/audio/amigaos/SDL_ahiaudio.c + + # VIDEO + ${PROJECT_SOURCE_DIR}/src/video/SDL_RLEaccel.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_0.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_1.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_A.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_N.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_bmp.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_cursor.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_pixels.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_surface.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_stretch.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv_sw.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_video.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_gamma.c + + # CYBERGRAPHICS + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxvideo.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxmodes.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgximage.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_amigaevents.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_amigamouse.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxgl.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxwm.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxyuv.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxaccel.c + ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxgl_wrapper.c + + # TIMER + ${PROJECT_SOURCE_DIR}/src/timer/amigaos/SDL_systimer.c + ${PROJECT_SOURCE_DIR}/src/timer/SDL_timer.c + + # JOYSTICK + ${PROJECT_SOURCE_DIR}/src/joystick/SDL_joystick.c + ${PROJECT_SOURCE_DIR}/src/joystick/SDL_sysjoystick.c + + # EVENTS + ${PROJECT_SOURCE_DIR}/src/events/SDL_quit.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_active.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_keyboard.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_mouse.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_resize.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_events.c + + # FILE + ${PROJECT_SOURCE_DIR}/src/file/SDL_rwops.c + + # THREADS + ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_sysmutex.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syssem.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_systhread.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_thread.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syscond.c + + # STDLIB + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_stdlib.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_malloc.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_getenv.c) + +target_include_directories(${LIBNAME} + PRIVATE + ${PROJECT_SOURCE_DIR}/ + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/include-GL + ${PROJECT_SOURCE_DIR}/src/audio + ${PROJECT_SOURCE_DIR}/src/audio/dummy + ${PROJECT_SOURCE_DIR}/src/audio/disk + ${PROJECT_SOURCE_DIR}/src/audio/amigaos + ${PROJECT_SOURCE_DIR}/src/events + ${PROJECT_SOURCE_DIR}/src/joystick + ${PROJECT_SOURCE_DIR}/src/main/amigaos + ${PROJECT_SOURCE_DIR}/src/thread + ${PROJECT_SOURCE_DIR}/src/thread/amigaos + ${PROJECT_SOURCE_DIR}/src/thread/pth + ${PROJECT_SOURCE_DIR}/src/thread/pthread + ${PROJECT_SOURCE_DIR}/src/timer + ${PROJECT_SOURCE_DIR}/src/video + ${PROJECT_SOURCE_DIR}/src/video/cybergfx + ${PROJECT_SOURCE_DIR}/src/video/apollo + ${PROJECT_SOURCE_DIR}/src/video/dummy) + +target_compile_definitions(${LIBNAME} PRIVATE $<$:NOIXEMUL _HAVE_STDINT_H>) + +if(NOT DEBUG) + target_compile_options(${LIBNAME} PUBLIC $<$:-O3 -ffast-math>) +endif() + +if(AMIGA) + if(NOT DEBUG) + target_compile_definitions(${LIBNAME} PRIVATE $<$:NO_AMIGADEBUG>) + endif() + + if(APOLLOBLIT) + target_compile_definitions(${LIBNAME} PRIVATE $<$:APOLLO_BLIT>) + target_compile_options(${LIBNAME} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include) + target_include_directories(${LIBNAME} PUBLIC video/apollo) + enable_language(ASM-VASM) + target_sources(${LIBNAME} + PRIVATE + # APOLLO AMMX + src/video/apollo/blitapollo.asm + src/video/apollo/apolloammxenable.asm + src/video/apollo/colorkeyapollo.asm) + + endif() +endif() + + +file(GLOB INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/*.h) +file(GLOB BIN_INCLUDE_FILES ${PROJECT_BINARY_DIR}/include/*.h) +list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES}) + +file(GLOB GL_INCLUDE_FILES include-GL/*.h) + +install(FILES ${PROJECT_BINARY_DIR}/libSDL.a DESTINATION "lib${LIB_SUFFIX}") +install(FILES ${INCLUDE_FILES} DESTINATION include/SDL) +install(FILES ${GL_INCLUDE_FILES} DESTINATION include/GL) + +install(FILES + README + README-SDL.txt + README.AmigaOS + LICENSE + CREDITS + COPYING + BUGS + DESTINATION ./) diff --git a/README.AmigaOS b/README.AmigaOS index e0d890640..bb27faad3 100644 --- a/README.AmigaOS +++ b/README.AmigaOS @@ -1,12 +1,137 @@ -The AmigaOS code has been removed from SDL, since it had been broken for a - long time and had a few bits of fairly invasive code #ifdef'd into the - SDL core. +Important notes: -However, there is an OS4 version of SDL here: - http://www.rcdrummond.net/amiga/index.html +If you dont need opengl then the agl.library need not load.you can link with -lgl_dummy and the agl.library is not load. +If you want use SDL with libnix you must link with -lsdl_libnix or you get linker error. -And a MorphOS version here: - http://www.lehtoranta.net/powersdl/ +but: NEVER USE sdl_libnix WITH ixemul because as soon a SDL program call a unix API func(memalloc / fileaccess) in a subthread ixemul crash. + So libsdl.a is need and the new V61 and above ixemul to run well. ---ryan. +All needed files are in lib dir. +In bin dir are the files that are need that a configure script detect SDL correct with pkgconfig.copy the files to your bin path. +when you do crosscompile and have more compilers, be careful i dont know a way how more than 1 pkgconfig can work together. +build of sdl_noixemul: + +activate in thread/amigaos/sdl_systhread.c the line +#define NOIXEMUL + + + +----------------------------- +SDL1.2.14d + +H.R. 28-Aug-2019 + - fixes to double buffering: actually, I was surprised to find that code in a semi-working + state at all :-) + +H.R. 20-Apr-2019 + - some fixes to SDL_cgximage.c, namely regarding compilation with a regular m68k-amigaos-gcc (2.95+) + - please note that you may have to add WriteLUTPixelArray() to the toolchain (missing in last + CyberGFX SDK), within the file inline/cybergraphics.h + + static __inline ULONG + WriteLUTPixelArray(BASE_PAR_DECL APTR srcRect, UWORD SrcX, UWORD SrcY, UWORD SrcMod, struct RastPort * a1arg, APTR ColorTab, UWORD DestX, UWORD DestY, UWORD SizeX, UWORD SizeY, UBYTE CTFormat) + { + BASE_EXT_DECL + register ULONG res __asm("d0"); + register void * a6 __asm("a6") = BASE_NAME; + register APTR a0 __asm("a0") = srcRect; + register UWORD d0 __asm("d0") = SrcX; + register UWORD d1 __asm("d1") = SrcY; + register UWORD d2 __asm("d2") = SrcMod; + register struct RastPort * a1 __asm("a1") = a1arg; + register APTR a2 __asm("a2") = ColorTab; + register UWORD d3 __asm("d3") = DestX; + register UWORD d4 __asm("d4") = DestY; + register UWORD d5 __asm("d5") = SizeX; + register UWORD d6 __asm("d6") = SizeY; + register UBYTE d7 __asm("d7") = CTFormat; + __asm volatile ("jsr a6@(-0xc6:W)" + : "=r" (res) + : "r" (a6), "r" (a0), "r" (d0), "r" (d1), "r" (d2), "r" (a1), "r" (a2), "r" (d3), "r" (d4), "r" (d5), "r" (d6), "r" (d7) + : "d0", "d1", "a0", "a1", "fp0", "fp1", "cc", "memory"); + return res; + } + + + +H.R: AMMX code for several blitting functions, see video/apollo with runtime selection between plain 68k code and AMMX, see SDL_cgxvideo.c as well + +H.R: 18-Apr-2017 _ApolloKeyRGB565toRGB565: disabled AMMX version of ColorKeying (for now, storem is not working in Gold2) + +H.R: Nov-2017 + - some fixes to 32 Bit RGB variants support (not full fix, due to limitations in the cybergraphics color format specifications + in comparison to Picasso96) + - some fixes to the AHI sound functions + +SDL1.2.14c + +toggle fullscreen clear now window/screen correct + +SDL 1.2.14b + +on window mode when SDL Window is open or resize it is now clear with black (do not work in before version) + +SDL1.2.14 + +For whats new in SDL 1.2.14 see the attached doc.this are amiga enhancements only + +when the SDL Window is not active then the SDL app is switch to TaskPri -1. This help to make your Amiga Desktop always fast, even if a +SDL App need 100% CPU load. + +If you dont like the feature you can switch it off with that enviroment variable. + +SDL_NoLowerTaskPri + +when open a own screen sdl try first to get a RGB16 Screen or when 32 bit screen want BGRA32 screenmode.If that fail it use whats here and write a message not optimal screenmode. + +Add functions to access SDL window window addr (to move/ resize or add a menu to it(usefull if you want a SDL program use with arexx and external GUI) + +SDL_AmigaLockWindow(); // to avoid that the sdl app close the window do always a look as long you access the window pointer. + struct Window * win = SDL_AmigaWindowAddr(); +if (win) // do only something if the address is get + { + ........ + } + + SDL_AmigaUnlockWindow(); + + + +SDL1.2.13 Version2 GCC linkerlibs + +* sdl Threads can now work with ixemul, this allow much more programs get working. + sdl for working with libnix is named as libsdl_libnix.a and attached in adchive + +* Joystick that is default on SDL Port 0 use now Amiga Port 1 so you need not remove your mouse and plug joystick in. + the second joystick use then Port 0 + +* SDL_HWSURFACE work now on rgb16 and rgb32 bgra32 screen mode and give 2-3* more speed in defendguin and work more systemfriendly + on a bitmap that is later copy with AOS blitbitmaprastport on GFX Card to window.So windows on top of SDL windows are now correct visible + resize of window work now with overlays. +* audio with more than 2 channels can play and surround is now correct convert to 2 channels. + on 8 bit fullscreen mode YUV overlay play now fast 256 color grey video + +* ahi use Unit 3 so you can define here a low quality setting for faster speed, withot touch your default setting + +* SDL opengl work now with stormmesa and quarktex(winuae HW3d opengl) and if you have Warp3d HW also it use Warp3d HW.note the limit on Voodoo3 of textures to 256*256 is + here, but if the game have all images in png files you can convert images to be 256*256.they look of course not so sharp after convert, but game can play fast. + Note: need link with libgl.a(attached).If you dont want opengl, you can use libgl_dummy.a(attached) + You need also the new includes copy to your sdl dir. + +* check if enough memory is here before allocbitmap, so it handle low memory situitions better now. + +---------------------------------------------------------- +This is port of SDL 1.2.15 to AmigaOS 68k. + +There are many fixes, timer and semaphore working correct, and faster speed. + +A HotKey is add CTRL+ALT+H.If press only every 2. second frame is draw to GFX Card. + +this give better playable results on slow amigas because a game that is written for 30 fps need now only transfer 15 fps to gfx card to work at correct speed. + +IMPORTANT: Use the new includes, this work too on old SDL + +sources can download here + +https://github.com/AmigaPorts/libSDL12 diff --git a/amiga/makefile-support/SDL_amigaversion.h b/amiga/makefile-support/SDL_amigaversion.h new file mode 100644 index 000000000..1d48e039d --- /dev/null +++ b/amiga/makefile-support/SDL_amigaversion.h @@ -0,0 +1,4 @@ +#ifndef SDL_AMIGAVERSION_H +#define SDL_AMIGAVERSION_H +static const char __attribute((used)) amiga_ver[] = "$VER: SDL.library 12.16 (06.02.2020) Amiga port of SDL v1.2.16\0"; +#endif /* SDL_AMIGAVERSION_H */ diff --git a/amiga/makefile-support/SDL_version.h b/amiga/makefile-support/SDL_version.h new file mode 100644 index 000000000..4385ebf0b --- /dev/null +++ b/amiga/makefile-support/SDL_version.h @@ -0,0 +1,91 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_version.h + * This header defines the current SDL version + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Version Number + * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + */ +/*@{*/ +#define SDL_MAJOR_VERSION 1 +#define SDL_MINOR_VERSION 2 +#define SDL_PATCHLEVEL 16 +/*@}*/ + +typedef struct SDL_version { + 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 * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff --git a/include/SDL_amigaversion.h.in b/include/SDL_amigaversion.h.in new file mode 100644 index 000000000..30511b18e --- /dev/null +++ b/include/SDL_amigaversion.h.in @@ -0,0 +1,4 @@ +#ifndef SDL_AMIGAVERSION_H +#define SDL_AMIGAVERSION_H +static const char __attribute((used)) amiga_ver[] = "$VER: SDL.library ${AMIGA_VERSION} (${VER_DAY}.${VER_MONTH}.${VER_YEAR}) Amiga port of SDL v${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}\0"; +#endif /* SDL_AMIGAVERSION_H */ diff --git a/include/SDL_config.h b/include/SDL_config.h index 998ae0bcb..9c90f946d 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -1,4 +1,3 @@ -/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ /* SDL - Simple DirectMedia Layer Copyright (C) 1997-2006 Sam Lantinga @@ -24,288 +23,27 @@ #ifndef _SDL_config_h #define _SDL_config_h -/* This is a set of defines to configure the SDL features */ - -/* General platform specific identifiers */ #include "SDL_platform.h" -/* C language features */ -/* #undef const */ -/* #undef inline */ -/* #undef volatile */ - -/* C datatypes */ -/* #undef size_t */ -/* #undef int8_t */ -/* #undef uint8_t */ -/* #undef int16_t */ -/* #undef uint16_t */ -/* #undef int32_t */ -/* #undef uint32_t */ -/* #undef int64_t */ -/* #undef uint64_t */ -/* #undef uintptr_t */ -#define SDL_HAS_64BIT_TYPE 1 - -/* Endianness */ -#define SDL_BYTEORDER 4321 - -/* Comment this if you want to build without any C library requirements */ -#define HAVE_LIBC 1 -#if HAVE_LIBC - -/* Useful headers */ -#define HAVE_ALLOCA_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STDARG_H 1 -#define HAVE_MALLOC_H 1 -/* #undef HAVE_MEMORY_H */ -#define HAVE_STRING_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_MATH_H 1 -#define HAVE_ICONV_H 1 -#define HAVE_SIGNAL_H 1 -/* #undef HAVE_ALTIVEC_H */ - -/* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -/* #undef HAVE_UNSETENV */ -#endif -#define HAVE_QSORT 1 -#define HAVE_ABS 1 -#define HAVE_BCOPY 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 -#define HAVE_STRLEN 1 -#define HAVE_STRLCPY 1 -#define HAVE_STRLCAT 1 -#define HAVE_STRDUP 1 -/* #undef HAVE__STRREV */ -/* #undef HAVE__STRUPR */ -/* #undef HAVE__STRLWR */ -/* #undef HAVE_INDEX */ -/* #undef HAVE_RINDEX */ -#define HAVE_STRCHR 1 -#define HAVE_STRRCHR 1 -#define HAVE_STRSTR 1 -/* #undef HAVE_ITOA */ -/* #undef HAVE__LTOA */ -/* #undef HAVE__UITOA */ -/* #undef HAVE__ULTOA */ -#define HAVE_STRTOL 1 -#define HAVE_STRTOUL 1 -/* #undef HAVE__I64TOA */ -/* #undef HAVE__UI64TOA */ -#define HAVE_STRTOLL 1 -#define HAVE_STRTOULL 1 -#define HAVE_STRTOD 1 -#define HAVE_ATOI 1 -#define HAVE_ATOF 1 -#define HAVE_STRCMP 1 -#define HAVE_STRNCMP 1 -/* #undef HAVE__STRICMP */ -#define HAVE_STRCASECMP 1 -/* #undef HAVE__STRNICMP */ -#define HAVE_STRNCASECMP 1 -#define HAVE_SSCANF 1 -#define HAVE_SNPRINTF 1 -#define HAVE_VSNPRINTF 1 -#define HAVE_ICONV 1 -/* #undef HAVE_SIGACTION */ -#define HAVE_SETJMP 1 -/* #undef HAVE_NANOSLEEP */ -/* #undef HAVE_CLOCK_GETTIME */ -/* #undef HAVE_DLVSYM */ - +/* Add any platform that doesn't build using the configure system */ +#if defined(__DREAMCAST__) +#include "SDL_config_dreamcast.h" +#elif defined(__MACOS__) +#include "SDL_config_macos.h" +#elif defined(__MACOSX__) +#include "SDL_config_macosx.h" +#elif defined(__SYMBIAN32__) +#include "SDL_config_symbian.h" /* must be before win32! */ +#elif defined(__WIN32__) +#include "SDL_config_win32.h" +#elif defined(__OS2__) +#include "SDL_config_os2.h" +#elif defined(__amigaos4__) +#include "SDL_config_amigaos4.h" +#elif defined(__AMIGA__) +#include "SDL_config_amiga.h" #else -/* We may need some replacement for stdarg.h here */ -#include -#endif /* HAVE_LIBC */ - -/* Allow disabling of core subsystems */ -/* #undef SDL_AUDIO_DISABLED */ -/* #undef SDL_CDROM_DISABLED */ -/* #undef SDL_CPUINFO_DISABLED */ -/* #undef SDL_EVENTS_DISABLED */ -/* #undef SDL_FILE_DISABLED */ -/* #undef SDL_JOYSTICK_DISABLED */ -#define SDL_LOADSO_AMIGAOS4 1 -/* #undef SDL_THREADS_DISABLED */ -/* #undef SDL_TIMERS_DISABLED */ -/* #undef SDL_VIDEO_DISABLED */ - -/* Enable various audio drivers */ -/* #undef SDL_AUDIO_DRIVER_AHI */ -/* #undef SDL_AUDIO_DRIVER_ALSA */ -/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ -#define SDL_AUDIO_DRIVER_AMIGAOS4 1 -/* #undef SDL_AUDIO_DRIVER_ARTS */ -/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ -/* #undef SDL_AUDIO_DRIVER_BAUDIO */ -/* #undef SDL_AUDIO_DRIVER_BSD */ -/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ -/* #undef SDL_AUDIO_DRIVER_DART */ -/* #undef SDL_AUDIO_DRIVER_DC */ -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 -/* #undef SDL_AUDIO_DRIVER_DMEDIA */ -/* #undef SDL_AUDIO_DRIVER_DSOUND */ -/* #undef SDL_AUDIO_DRIVER_ESD */ -/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ -/* #undef SDL_AUDIO_DRIVER_MINT */ -/* #undef SDL_AUDIO_DRIVER_MMEAUDIO */ -/* #undef SDL_AUDIO_DRIVER_NAS */ -/* #undef SDL_AUDIO_DRIVER_OSS */ -/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */ -/* #undef SDL_AUDIO_DRIVER_PAUD */ -/* #undef SDL_AUDIO_DRIVER_QNXNTO */ -/* #undef SDL_AUDIO_DRIVER_SNDMGR */ -/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */ -/* #undef SDL_AUDIO_DRIVER_WAVEOUT */ - -/* Enable various cdrom drivers */ -/* #undef SDL_CDROM_AIX */ -/* #undef SDL_CDROM_BEOS */ -/* #undef SDL_CDROM_BSDI */ -/* #undef SDL_CDROM_DC */ -/* #undef SDL_CDROM_DUMMY */ -/* #undef SDL_CDROM_FREEBSD */ -/* #undef SDL_CDROM_LINUX */ -/* #undef SDL_CDROM_MACOS */ -/* #undef SDL_CDROM_MACOSX */ -/* #undef SDL_CDROM_MINT */ -/* #undef SDL_CDROM_OPENBSD */ -/* #undef SDL_CDROM_OS2 */ -/* #undef SDL_CDROM_OSF */ -/* #undef SDL_CDROM_QNX */ -/* #undef SDL_CDROM_WIN32 */ - -/* Enable various input drivers */ -/* #undef SDL_INPUT_TSLIB */ -/* #undef SDL_JOYSTICK_AMIGA */ -#define SDL_JOYSTICK_AMIGAINPUT 1 -/* #undef SDL_JOYSTICK_BEOS */ -/* #undef SDL_JOYSTICK_DC */ -/* #undef SDL_JOYSTICK_DUMMY */ -/* #undef SDL_JOYSTICK_IOKIT */ -/* #undef SDL_JOYSTICK_LINUX */ -/* #undef SDL_JOYSTICK_LINUXEV */ -/* #undef SDL_JOYSTICK_MACOS */ -/* #undef SDL_JOYSTICK_MINT */ -/* #undef SDL_JOYSTICK_OS2 */ -/* #undef SDL_JOYSTICK_RISCOS */ -/* #undef SDL_JOYSTICK_WINMM */ -/* #undef SDL_JOYSTICK_USBHID */ -/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ - -/* Enable various shared object loading systems */ -/* #undef SDL_LOADSO_BEOS */ -/* #undef SDL_LOADSO_DLCOMPAT */ -/* #undef SDL_LOADSO_DLOPEN */ -/* #undef SDL_LOADSO_DUMMY */ -/* #undef SDL_LOADSO_LDG */ -/* #undef SDL_LOADSO_MACOS */ -/* #undef SDL_LOADSO_OS2 */ -/* #undef SDL_LOADSO_WIN32 */ - -/* Enable various threading systems */ -/* #undef SDL_THREAD_AMIGA */ -#define SDL_THREAD_AMIGAOS4 1 -/* #undef SDL_THREAD_BEOS */ -/* #undef SDL_THREAD_DC */ -/* #undef SDL_THREAD_EPOC */ -/* #undef SDL_THREAD_OS2 */ -/* #undef SDL_THREAD_PTH */ -/* #undef SDL_THREAD_PTHREAD */ -/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX */ -/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */ -/* #undef SDL_THREAD_SPROC */ -/* #undef SDL_THREAD_WIN32 */ - -/* Enable various timer systems */ -/* #undef SDL_TIMER_AMIGA */ -#define SDL_TIMER_AMIGAOS4 1 -/* #undef SDL_TIMER_BEOS */ -/* #undef SDL_TIMER_DC */ -/* #undef SDL_TIMER_DUMMY */ -/* #undef SDL_TIMER_EPOC */ -/* #undef SDL_TIMER_MACOS */ -/* #undef SDL_TIMER_MINT */ -/* #undef SDL_TIMER_OS2 */ -/* #undef SDL_TIMER_RISCOS */ -/* #undef SDL_TIMER_UNIX */ -/* #undef SDL_TIMER_WIN32 */ -/* #undef SDL_TIMER_WINCE */ - -/* Enable various video drivers */ -/* #undef SDL_VIDEO_DRIVER_AALIB */ -#define SDL_VIDEO_DRIVER_AMIGAOS4 1 -/* #undef SDL_VIDEO_DRIVER_BWINDOW */ -/* #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS */ -/* #undef SDL_VIDEO_DRIVER_DC */ -/* #undef SDL_VIDEO_DRIVER_DDRAW */ -/* #undef SDL_VIDEO_DRIVER_DGA */ -/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ -/* #undef SDL_VIDEO_DRIVER_DRAWSPROCKET */ -#define SDL_VIDEO_DRIVER_DUMMY 1 -/* #undef SDL_VIDEO_DRIVER_EPOC */ -/* #undef SDL_VIDEO_DRIVER_FBCON */ -/* #undef SDL_VIDEO_DRIVER_GAPI */ -/* #undef SDL_VIDEO_DRIVER_GEM */ -/* #undef SDL_VIDEO_DRIVER_GGI */ -/* #undef SDL_VIDEO_DRIVER_IPOD */ -/* #undef SDL_VIDEO_DRIVER_NANOX */ -/* #undef SDL_VIDEO_DRIVER_OS2FS */ -/* #undef SDL_VIDEO_DRIVER_PHOTON */ -/* #undef SDL_VIDEO_DRIVER_PICOGUI */ -/* #undef SDL_VIDEO_DRIVER_PS2GS */ -/* #undef SDL_VIDEO_DRIVER_QTOPIA */ -/* #undef SDL_VIDEO_DRIVER_QUARTZ */ -/* #undef SDL_VIDEO_DRIVER_RISCOS */ -/* #undef SDL_VIDEO_DRIVER_SVGALIB */ -/* #undef SDL_VIDEO_DRIVER_TOOLBOX */ -/* #undef SDL_VIDEO_DRIVER_VGL */ -/* #undef SDL_VIDEO_DRIVER_WINDIB */ -/* #undef SDL_VIDEO_DRIVER_WSCONS */ -/* #undef SDL_VIDEO_DRIVER_X11 */ -/* #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE */ -/* #undef SDL_VIDEO_DRIVER_X11_DPMS */ -/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC */ -/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT */ -/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */ -/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER */ -/* #undef SDL_VIDEO_DRIVER_X11_VIDMODE */ -/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */ -/* #undef SDL_VIDEO_DRIVER_X11_XME */ -/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */ -/* #undef SDL_VIDEO_DRIVER_X11_XV */ -/* #undef SDL_VIDEO_DRIVER_XBIOS */ - -/* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 -/* #undef SDL_VIDEO_OPENGL_GLX */ -/* #undef SDL_VIDEO_OPENGL_WGL */ -/* #undef SDL_VIDEO_OPENGL_OSMESA */ -/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ - -/* Enable assembly routines */ -#define SDL_ASSEMBLY_ROUTINES 1 -/* #undef SDL_HERMES_BLITTERS */ -/* #undef SDL_ALTIVEC_BLITTERS */ +#include "SDL_config_minimal.h" +#endif /* platform config */ #endif /* _SDL_config_h */ diff --git a/include/SDL_config_amiga.h b/include/SDL_config_amiga.h index 23e086192..0578a0767 100644 --- a/include/SDL_config_amiga.h +++ b/include/SDL_config_amiga.h @@ -24,57 +24,169 @@ #define _SDL_config_amiga_h #include "SDL_platform.h" +#include +#ifndef _HAVE_STDINT_H /* This is a set of defines to configure the SDL features */ -#define SDL_HAS_64BIT_TYPE 1 +#ifndef _INT8_T_DECLARED +typedef signed char int8_t; +#define _INT8_T_DECLARED +#endif + +#ifndef _UINT8_T_DECLARED +typedef unsigned char uint8_t; +#define _UINT8_T_DECLARED +#endif + +#ifndef _INT16_T_DECLARED +typedef signed short int16_t; +#define _INT16_T_DECLARED +#endif + +#ifndef _UINT16_T_DECLARED +typedef unsigned short uint16_t; +#define _UINT16_T_DECLARED +#endif + +#ifndef _INT32_T_DECLARED +typedef signed int int32_t; +#define _INT32_T_DECLARED +#endif + +#ifndef _UINT32_T_DECLARED +typedef unsigned int uint32_t; +#define _UINT32_T_DECLARED +#endif + +#ifndef size_t +//typedef unsigned int size_t; +#endif + +#ifndef _UINTPTR_T_DECLARED +typedef unsigned int uintptr_t; +#define _UINTPTR_T_DECLARED +#endif + +#ifndef _INT64_T_DECLARED +typedef signed long long int64_t; +#define _INT64_T_DECLARED +#endif + +#ifndef _UINT64_T_DECLARED +typedef unsigned long long uint64_t; +#define _UINT64_T_DECLARED +#endif + +#endif /* _HAVE_STDINT_H */ + +#define SDL_HAS_64BIT_TYPE 1 +#define SDL_BYTEORDER SDL_BIG_ENDIAN + +//#define HAVE_LIBC 1 /* Useful headers */ -#define HAVE_SYS_TYPES_H 1 -#define HAVE_STDIO_H 1 -#define STDC_HEADERS 1 -#define HAVE_STRING_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_SIGNAL_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +#define HAVE_MEMORY_H 1 +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +//#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +//#define HAVE_SIGNAL_H 0 /* C library functions */ -#define HAVE_MALLOC 1 -#define HAVE_CALLOC 1 -#define HAVE_REALLOC 1 -#define HAVE_FREE 1 -#define HAVE_ALLOCA 1 -#define HAVE_GETENV 1 -#define HAVE_PUTENV 1 -#define HAVE_MEMSET 1 -#define HAVE_MEMCPY 1 -#define HAVE_MEMMOVE 1 -#define HAVE_MEMCMP 1 +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +#define HAVE_UNSETENV 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define SDL_revcpy memmove +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_INDEX 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__UITOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE__I64TOA 1 +#define HAVE__UI64TOA 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE_STRICMP 1 +#define HAVE_STRCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_SETJMP 1 +#define HAVE_CLOCK_GETTIME 1 /* Enable various audio drivers */ -#define SDL_AUDIO_DRIVER_AHI 1 -#define SDL_AUDIO_DRIVER_DISK 1 -#define SDL_AUDIO_DRIVER_DUMMY 1 +#define SDL_AUDIO_DRIVER_AHI 1 +//#define SDL_AUDIO_DRIVER_DISK 1 +//#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various cdrom drivers */ -#define SDL_CDROM_DUMMY 1 +#define SDL_CDROM_DISABLED 1 +//#define SDL_CDROM_AMIGA 1 /* Enable various input drivers */ -#define SDL_JOYSTICK_AMIGA 1 +//#define SDL_JOYSTICK_AMIGA 1 /* Enable various shared object loading systems */ -#define SDL_LOADSO_DUMMY 1 +//#define SDL_LOADSO_AMIGA 1 /* Enable various threading systems */ -#define SDL_THREAD_AMIGA 1 +#define SDL_THREAD_AMIGA 1 /* Enable various timer systems */ -#define SDL_TIMER_AMIGA 1 +#define SDL_TIMER_AMIGA 1 /* Enable various video drivers */ #define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1 -#define SDL_VIDEO_DRIVER_DUMMY 1 /* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 - +//#define SDL_VIDEO_OPENGL 1 + +#define __MEM_AMIGA 1 + +/* Enable assembly routines where available */ +#define SDL_ASSEMBLY_ROUTINES 1 +#define SDL_AMIGA_NOWINDOW 0x10000 +#ifdef __cplusplus +extern "C" { +#endif +void SDL_AmigaLockWindow(void); +void SDL_AmigaUnlockWindow(void); +struct Window * SDL_AmigaWindowAddr(void); +#ifdef __cplusplus +} +#endif #endif /* _SDL_config_amiga_h */ diff --git a/include/SDL_config_amigaos4.h b/include/SDL_config_amigaos4.h new file mode 100644 index 000000000..998ae0bcb --- /dev/null +++ b/include/SDL_config_amigaos4.h @@ -0,0 +1,311 @@ +/* include/SDL_config.h. Generated from SDL_config.h.in by configure. */ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifndef _SDL_config_h +#define _SDL_config_h + +/* This is a set of defines to configure the SDL features */ + +/* General platform specific identifiers */ +#include "SDL_platform.h" + +/* C language features */ +/* #undef const */ +/* #undef inline */ +/* #undef volatile */ + +/* C datatypes */ +/* #undef size_t */ +/* #undef int8_t */ +/* #undef uint8_t */ +/* #undef int16_t */ +/* #undef uint16_t */ +/* #undef int32_t */ +/* #undef uint32_t */ +/* #undef int64_t */ +/* #undef uint64_t */ +/* #undef uintptr_t */ +#define SDL_HAS_64BIT_TYPE 1 + +/* Endianness */ +#define SDL_BYTEORDER 4321 + +/* Comment this if you want to build without any C library requirements */ +#define HAVE_LIBC 1 +#if HAVE_LIBC + +/* Useful headers */ +#define HAVE_ALLOCA_H 1 +#define HAVE_SYS_TYPES_H 1 +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STDLIB_H 1 +#define HAVE_STDARG_H 1 +#define HAVE_MALLOC_H 1 +/* #undef HAVE_MEMORY_H */ +#define HAVE_STRING_H 1 +#define HAVE_STRINGS_H 1 +#define HAVE_INTTYPES_H 1 +#define HAVE_STDINT_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#define HAVE_ICONV_H 1 +#define HAVE_SIGNAL_H 1 +/* #undef HAVE_ALTIVEC_H */ + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ +#define HAVE_GETENV 1 +#define HAVE_PUTENV 1 +/* #undef HAVE_UNSETENV */ +#endif +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_BCOPY 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE_STRLCPY 1 +#define HAVE_STRLCAT 1 +#define HAVE_STRDUP 1 +/* #undef HAVE__STRREV */ +/* #undef HAVE__STRUPR */ +/* #undef HAVE__STRLWR */ +/* #undef HAVE_INDEX */ +/* #undef HAVE_RINDEX */ +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +/* #undef HAVE_ITOA */ +/* #undef HAVE__LTOA */ +/* #undef HAVE__UITOA */ +/* #undef HAVE__ULTOA */ +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +/* #undef HAVE__I64TOA */ +/* #undef HAVE__UI64TOA */ +#define HAVE_STRTOLL 1 +#define HAVE_STRTOULL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +/* #undef HAVE__STRICMP */ +#define HAVE_STRCASECMP 1 +/* #undef HAVE__STRNICMP */ +#define HAVE_STRNCASECMP 1 +#define HAVE_SSCANF 1 +#define HAVE_SNPRINTF 1 +#define HAVE_VSNPRINTF 1 +#define HAVE_ICONV 1 +/* #undef HAVE_SIGACTION */ +#define HAVE_SETJMP 1 +/* #undef HAVE_NANOSLEEP */ +/* #undef HAVE_CLOCK_GETTIME */ +/* #undef HAVE_DLVSYM */ + +#else +/* We may need some replacement for stdarg.h here */ +#include +#endif /* HAVE_LIBC */ + +/* Allow disabling of core subsystems */ +/* #undef SDL_AUDIO_DISABLED */ +/* #undef SDL_CDROM_DISABLED */ +/* #undef SDL_CPUINFO_DISABLED */ +/* #undef SDL_EVENTS_DISABLED */ +/* #undef SDL_FILE_DISABLED */ +/* #undef SDL_JOYSTICK_DISABLED */ +#define SDL_LOADSO_AMIGAOS4 1 +/* #undef SDL_THREADS_DISABLED */ +/* #undef SDL_TIMERS_DISABLED */ +/* #undef SDL_VIDEO_DISABLED */ + +/* Enable various audio drivers */ +/* #undef SDL_AUDIO_DRIVER_AHI */ +/* #undef SDL_AUDIO_DRIVER_ALSA */ +/* #undef SDL_AUDIO_DRIVER_ALSA_DYNAMIC */ +#define SDL_AUDIO_DRIVER_AMIGAOS4 1 +/* #undef SDL_AUDIO_DRIVER_ARTS */ +/* #undef SDL_AUDIO_DRIVER_ARTS_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_BAUDIO */ +/* #undef SDL_AUDIO_DRIVER_BSD */ +/* #undef SDL_AUDIO_DRIVER_COREAUDIO */ +/* #undef SDL_AUDIO_DRIVER_DART */ +/* #undef SDL_AUDIO_DRIVER_DC */ +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 +/* #undef SDL_AUDIO_DRIVER_DMEDIA */ +/* #undef SDL_AUDIO_DRIVER_DSOUND */ +/* #undef SDL_AUDIO_DRIVER_ESD */ +/* #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC */ +/* #undef SDL_AUDIO_DRIVER_MINT */ +/* #undef SDL_AUDIO_DRIVER_MMEAUDIO */ +/* #undef SDL_AUDIO_DRIVER_NAS */ +/* #undef SDL_AUDIO_DRIVER_OSS */ +/* #undef SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H */ +/* #undef SDL_AUDIO_DRIVER_PAUD */ +/* #undef SDL_AUDIO_DRIVER_QNXNTO */ +/* #undef SDL_AUDIO_DRIVER_SNDMGR */ +/* #undef SDL_AUDIO_DRIVER_SUNAUDIO */ +/* #undef SDL_AUDIO_DRIVER_WAVEOUT */ + +/* Enable various cdrom drivers */ +/* #undef SDL_CDROM_AIX */ +/* #undef SDL_CDROM_BEOS */ +/* #undef SDL_CDROM_BSDI */ +/* #undef SDL_CDROM_DC */ +/* #undef SDL_CDROM_DUMMY */ +/* #undef SDL_CDROM_FREEBSD */ +/* #undef SDL_CDROM_LINUX */ +/* #undef SDL_CDROM_MACOS */ +/* #undef SDL_CDROM_MACOSX */ +/* #undef SDL_CDROM_MINT */ +/* #undef SDL_CDROM_OPENBSD */ +/* #undef SDL_CDROM_OS2 */ +/* #undef SDL_CDROM_OSF */ +/* #undef SDL_CDROM_QNX */ +/* #undef SDL_CDROM_WIN32 */ + +/* Enable various input drivers */ +/* #undef SDL_INPUT_TSLIB */ +/* #undef SDL_JOYSTICK_AMIGA */ +#define SDL_JOYSTICK_AMIGAINPUT 1 +/* #undef SDL_JOYSTICK_BEOS */ +/* #undef SDL_JOYSTICK_DC */ +/* #undef SDL_JOYSTICK_DUMMY */ +/* #undef SDL_JOYSTICK_IOKIT */ +/* #undef SDL_JOYSTICK_LINUX */ +/* #undef SDL_JOYSTICK_LINUXEV */ +/* #undef SDL_JOYSTICK_MACOS */ +/* #undef SDL_JOYSTICK_MINT */ +/* #undef SDL_JOYSTICK_OS2 */ +/* #undef SDL_JOYSTICK_RISCOS */ +/* #undef SDL_JOYSTICK_WINMM */ +/* #undef SDL_JOYSTICK_USBHID */ +/* #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H */ + +/* Enable various shared object loading systems */ +/* #undef SDL_LOADSO_BEOS */ +/* #undef SDL_LOADSO_DLCOMPAT */ +/* #undef SDL_LOADSO_DLOPEN */ +/* #undef SDL_LOADSO_DUMMY */ +/* #undef SDL_LOADSO_LDG */ +/* #undef SDL_LOADSO_MACOS */ +/* #undef SDL_LOADSO_OS2 */ +/* #undef SDL_LOADSO_WIN32 */ + +/* Enable various threading systems */ +/* #undef SDL_THREAD_AMIGA */ +#define SDL_THREAD_AMIGAOS4 1 +/* #undef SDL_THREAD_BEOS */ +/* #undef SDL_THREAD_DC */ +/* #undef SDL_THREAD_EPOC */ +/* #undef SDL_THREAD_OS2 */ +/* #undef SDL_THREAD_PTH */ +/* #undef SDL_THREAD_PTHREAD */ +/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX */ +/* #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP */ +/* #undef SDL_THREAD_SPROC */ +/* #undef SDL_THREAD_WIN32 */ + +/* Enable various timer systems */ +/* #undef SDL_TIMER_AMIGA */ +#define SDL_TIMER_AMIGAOS4 1 +/* #undef SDL_TIMER_BEOS */ +/* #undef SDL_TIMER_DC */ +/* #undef SDL_TIMER_DUMMY */ +/* #undef SDL_TIMER_EPOC */ +/* #undef SDL_TIMER_MACOS */ +/* #undef SDL_TIMER_MINT */ +/* #undef SDL_TIMER_OS2 */ +/* #undef SDL_TIMER_RISCOS */ +/* #undef SDL_TIMER_UNIX */ +/* #undef SDL_TIMER_WIN32 */ +/* #undef SDL_TIMER_WINCE */ + +/* Enable various video drivers */ +/* #undef SDL_VIDEO_DRIVER_AALIB */ +#define SDL_VIDEO_DRIVER_AMIGAOS4 1 +/* #undef SDL_VIDEO_DRIVER_BWINDOW */ +/* #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS */ +/* #undef SDL_VIDEO_DRIVER_DC */ +/* #undef SDL_VIDEO_DRIVER_DDRAW */ +/* #undef SDL_VIDEO_DRIVER_DGA */ +/* #undef SDL_VIDEO_DRIVER_DIRECTFB */ +/* #undef SDL_VIDEO_DRIVER_DRAWSPROCKET */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +/* #undef SDL_VIDEO_DRIVER_EPOC */ +/* #undef SDL_VIDEO_DRIVER_FBCON */ +/* #undef SDL_VIDEO_DRIVER_GAPI */ +/* #undef SDL_VIDEO_DRIVER_GEM */ +/* #undef SDL_VIDEO_DRIVER_GGI */ +/* #undef SDL_VIDEO_DRIVER_IPOD */ +/* #undef SDL_VIDEO_DRIVER_NANOX */ +/* #undef SDL_VIDEO_DRIVER_OS2FS */ +/* #undef SDL_VIDEO_DRIVER_PHOTON */ +/* #undef SDL_VIDEO_DRIVER_PICOGUI */ +/* #undef SDL_VIDEO_DRIVER_PS2GS */ +/* #undef SDL_VIDEO_DRIVER_QTOPIA */ +/* #undef SDL_VIDEO_DRIVER_QUARTZ */ +/* #undef SDL_VIDEO_DRIVER_RISCOS */ +/* #undef SDL_VIDEO_DRIVER_SVGALIB */ +/* #undef SDL_VIDEO_DRIVER_TOOLBOX */ +/* #undef SDL_VIDEO_DRIVER_VGL */ +/* #undef SDL_VIDEO_DRIVER_WINDIB */ +/* #undef SDL_VIDEO_DRIVER_WSCONS */ +/* #undef SDL_VIDEO_DRIVER_X11 */ +/* #undef SDL_VIDEO_DRIVER_X11_DGAMOUSE */ +/* #undef SDL_VIDEO_DRIVER_X11_DPMS */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR */ +/* #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER */ +/* #undef SDL_VIDEO_DRIVER_X11_VIDMODE */ +/* #undef SDL_VIDEO_DRIVER_X11_XINERAMA */ +/* #undef SDL_VIDEO_DRIVER_X11_XME */ +/* #undef SDL_VIDEO_DRIVER_X11_XRANDR */ +/* #undef SDL_VIDEO_DRIVER_X11_XV */ +/* #undef SDL_VIDEO_DRIVER_XBIOS */ + +/* Enable OpenGL support */ +#define SDL_VIDEO_OPENGL 1 +/* #undef SDL_VIDEO_OPENGL_GLX */ +/* #undef SDL_VIDEO_OPENGL_WGL */ +/* #undef SDL_VIDEO_OPENGL_OSMESA */ +/* #undef SDL_VIDEO_OPENGL_OSMESA_DYNAMIC */ + +/* Enable assembly routines */ +#define SDL_ASSEMBLY_ROUTINES 1 +/* #undef SDL_HERMES_BLITTERS */ +/* #undef SDL_ALTIVEC_BLITTERS */ + +#endif /* _SDL_config_h */ diff --git a/include/SDL_version.h.in b/include/SDL_version.h.in new file mode 100644 index 000000000..bdc0425a7 --- /dev/null +++ b/include/SDL_version.h.in @@ -0,0 +1,91 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2012 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/** @file SDL_version.h + * This header defines the current SDL version + */ + +#ifndef _SDL_version_h +#define _SDL_version_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +extern "C" { +#endif + +/** @name Version Number + * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL + */ +/*@{*/ +#define SDL_MAJOR_VERSION ${SDL_MAJOR_VERSION} +#define SDL_MINOR_VERSION ${SDL_MINOR_VERSION} +#define SDL_PATCHLEVEL ${SDL_PATCHLEVEL} +/*@}*/ + +typedef struct SDL_version { + 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 * SDLCALL SDL_Linked_Version(void); + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif +#include "close_code.h" + +#endif /* _SDL_version_h */ diff --git a/include/SDL_video.h b/include/SDL_video.h index f9c4e0702..2ba26b5ba 100644 --- a/include/SDL_video.h +++ b/include/SDL_video.h @@ -145,6 +145,9 @@ typedef struct SDL_Surface { #define SDL_NOFRAME 0x00000020 /**< No window caption or edge frame */ /*@}*/ +/** Available for SDLA_SetQuickLazyBlit() */ +#define SDLA_QUICKLAZY 0x00000040 /**< Blitting from same src to same dest format, skip long considerations */ + /** Used internally (read-only) */ /*@{*/ #define SDL_HWACCEL 0x00000100 /**< Blit uses hardware acceleration */ @@ -615,6 +618,20 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW extern DECLSPEC int SDLCALL SDL_SetColorKey (SDL_Surface *surface, Uint32 flag, Uint32 key); +/** + * Sets the quick'n'lazy blit mode in a blittable surface. + * This simply means that blit modes and methods are cached across + * subsequent calls. If you intend to blit a given source surface + * to different destinations (in terms of depth and available + * hardware acceleration), clear the lazy state before doing so. + * + * Clearing the lazy state just reverts the surface to normal blitting + * operation. + */ +extern DECLSPEC void SDLCALL SDLA_SetQuickLazyBlit + (SDL_Surface *surface, Uint32 yesno ); + + /** * 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 diff --git a/mydebug.h b/mydebug.h new file mode 100644 index 000000000..c0069736a --- /dev/null +++ b/mydebug.h @@ -0,0 +1,16 @@ +#ifndef MYDEBUG + +#ifndef NO_AMIGADEBUG +#define D(x) x +#define bug kprintf + +extern void kprintf(const char *, ...); + +#else +#define D(x) +#endif + +#define MAKE_HIT() {char *a=NULL,b;b=*a;} + +#define MYDEBUG +#endif diff --git a/src/SDL.c b/src/SDL.c index de9b3d652..1d6f703aa 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -28,6 +28,7 @@ #if !SDL_VIDEO_DISABLED #include "video/SDL_leaks.h" #endif +#include "mydebug.h" #if SDL_THREAD_PTH #include @@ -46,14 +47,17 @@ extern void SDL_CDROMQuit(void); extern void SDL_StartTicks(void); extern int SDL_TimerInit(void); extern void SDL_TimerQuit(void); +#if defined(__AMIGA__) && !defined(__amigaos4__) +#include "SDL_systimer.h" +#endif #endif /* The current SDL version */ static SDL_version version = { SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL }; -#ifdef __amigaos4__ -static const char __attribute((used)) amiga_ver[] = "$VER: SDL1_2_15 1.4 (22.01.2018)\0"; +#if defined(__amigaos4__) || defined(__AMIGA__) +#include "SDL_amigaversion.h" #endif /* The initialized subsystems */ @@ -303,9 +307,12 @@ void SDL_Quit(void) printf("[SDL_Quit] : Returning!\n"); fflush(stdout); #endif -#ifdef __amigaos4__ +#if defined(__AMIGA__) && defined(__amigaos4__) os4_quit(); #endif +#if defined(__AMIGA__) && !defined(__amigaos4__) + amiga_quit_timer(); +#endif } /* Return the library version number */ diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index fc9b56500..571853f9f 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -118,7 +118,7 @@ static AudioBootStrap *bootstrap[] = { #endif #if SDL_AUDIO_DRIVER_EPOCAUDIO &EPOCAudio_bootstrap, -#endif +#endif #if SDL_AUDIO_DRIVER_AMIGAOS4 &AmigaOS4_bootstrap, #endif @@ -130,6 +130,10 @@ SDL_AudioDevice *current_audio = NULL; int SDL_AudioInit(const char *driver_name); void SDL_AudioQuit(void); +#if SDL_AUDIO_DRIVER_AHI +static int audio_configured = 0; +#endif + /* The general mixing thread function */ int SDLCALL SDL_RunAudio(void *audiop) { @@ -139,17 +143,42 @@ int SDLCALL SDL_RunAudio(void *audiop) void *udata; void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len); int silence; +#if SDL_AUDIO_DRIVER_AHI + int started = 0; + +/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */ + + D(bug("Task audio started audio struct:<%lx>...\n",audiop)); + + D(bug("Before Openaudio...")); + if(audio->OpenAudio(audio, &audio->spec)==-1) + { + D(bug("Open audio failed...\n")); + return(-1); + } + D(bug("OpenAudio...OK\n")); +#endif /* Perform any thread setup */ if ( audio->ThreadInit ) { audio->ThreadInit(audio); } audio->threadid = SDL_ThreadID(); - +#if SDL_AUDIO_DRIVER_AHI + SetTaskPri(audio->threadid,11); +#endif /* Set up the mixing function */ fill = audio->spec.callback; udata = audio->spec.userdata; +#if SDL_AUDIO_DRIVER_AHI + audio_configured = 1; + + D(bug("Audio configured... Checking for conversion\n")); + SDL_mutexP(audio->mixer_lock); + D(bug("Semaphore obtained...\n")); +#endif + if ( audio->convert.needed ) { if ( audio->convert.src_format == AUDIO_U8 ) { silence = 0x80; @@ -162,6 +191,12 @@ int SDLCALL SDL_RunAudio(void *audiop) stream_len = audio->spec.size; } +#if SDL_AUDIO_DRIVER_AHI + + SDL_mutexV(audio->mixer_lock); + D(bug("Entering audio loop...\n")); +#endif + #ifdef __OS2__ /* Increase the priority of this thread to make sure that the audio will be continuous all the time! */ @@ -186,6 +221,16 @@ int SDLCALL SDL_RunAudio(void *audiop) /* 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 SDL_AUDIO_DRIVER_AHI + if ( started > 1 ) +#endif + audio->WaitAudio(audio); + } + /* Fill the current buffer with sound */ if ( audio->convert.needed ) { if ( audio->convert.buf ) { @@ -222,21 +267,27 @@ int SDLCALL SDL_RunAudio(void *audiop) /* Ready current buffer for play and change current buffer */ if ( stream != audio->fake_stream ) { audio->PlayAudio(audio); +#if SDL_AUDIO_DRIVER_AHI +/* AmigaOS don't have to wait the first time audio is played! */ + started++; +#endif } - - /* Wait for an audio buffer to become available */ - if ( stream == audio->fake_stream ) { - SDL_Delay((audio->spec.samples*1000)/audio->spec.freq); - } else { - audio->WaitAudio(audio); - } + } - /* Wait for the audio to drain.. */ if ( audio->WaitDone ) { audio->WaitDone(audio); } +#if SDL_AUDIO_DRIVER_AHI + D(bug("WaitAudio...Done\n")); + + audio->CloseAudio(audio); + + D(bug("CloseAudio..Done, subtask exiting...\n")); + audio_configured = 0; +#endif + #ifdef __OS2__ #ifdef DEBUG_BUILD printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); @@ -483,6 +534,8 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) while ( power2 < samples ) { power2 *= 2; } + if( (unsigned int)power2 > 65536 ) /* <0, >65536 */ + power2 = 2048; desired->samples = power2; } if ( desired->callback == NULL ) { @@ -511,12 +564,32 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) audio->enabled = 1; audio->paused = 1; +#ifndef SDL_AUDIO_DRIVER_AHI + D(bug("AHI OpenAudio\n")); + /* AmigaOS opens audio inside the main loop */ audio->opened = audio->OpenAudio(audio, &audio->spec)+1; if ( ! audio->opened ) { SDL_CloseAudio(); return(-1); } +#else + D(bug("Locking semaphore...")); + SDL_mutexP(audio->mixer_lock); + + audio->thread = SDL_CreateThread(SDL_RunAudio, audio); + D(bug("Created thread...\n")); + + if ( audio->thread == NULL ) { + SDL_mutexV(audio->mixer_lock); + SDL_CloseAudio(); + SDL_SetError("Couldn't create audio thread"); + return(-1); + } + + while(!audio_configured) + SDL_Delay(100); +#endif /* If the audio driver changes the buffer size, accept it */ if ( audio->spec.samples != desired->samples ) { @@ -560,6 +633,7 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) } } +#ifndef SDL_AUDIO_DRIVER_AHI /* Start the audio thread if necessary */ switch (audio->opened) { case 1: @@ -581,6 +655,10 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) /* The audio is now playing */ break; } +#else + SDL_mutexV(audio->mixer_lock); + D(bug("SDL_OpenAudio USCITA...\n")); +#endif return(0); } @@ -654,10 +732,12 @@ void SDL_AudioQuit(void) SDL_FreeAudioMem(audio->convert.buf); } +#ifndef SDL_AUDIO_DRIVER_AHI if ( audio->opened ) { audio->CloseAudio(audio); audio->opened = 0; } +#endif /* Free the driver data */ audio->free(audio); current_audio = NULL; diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 6771137df..08caf631b 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -27,6 +27,27 @@ #include "SDL_mutex.h" #include "SDL_thread.h" +#ifdef __AMIGA__ +#include +#include +#if defined(__SASC) || defined(WARPOS) +#include +#else +#ifdef MORPHOS +#include +#else +#include +#include +#include +#endif +#endif + +#ifdef SDL_AUDIO_DRIVER_AHI +#include +#endif +#endif +#include "mydebug.h" + /* The SDL audio driver */ typedef struct SDL_AudioDevice SDL_AudioDevice; @@ -183,7 +204,7 @@ extern AudioBootStrap MMEAUDIO_bootstrap; extern AudioBootStrap DART_bootstrap; #endif #if SDL_AUDIO_DRIVER_EPOCAUDIO -extern AudioBootStrap EPOCAudio_bootstrap; +extern AudioBootStrap EPOCAudio_bootstrap; #endif #if SDL_AUDIO_DRIVER_AMIGAOS4 extern AudioBootStrap AmigaOS4_bootstrap; @@ -192,4 +213,8 @@ extern AudioBootStrap AmigaOS4_bootstrap; /* This is the current audio device */ extern SDL_AudioDevice *current_audio; +#if !defined(__SASC) && !defined(WARPOS) +extern struct ExecBase *SysBase; +#endif + #endif /* _SDL_sysaudio_h */ diff --git a/src/audio/amigaos/SDL_ahiaudio.c b/src/audio/amigaos/SDL_ahiaudio.c index c9a4c1a4f..4c2ec1604 100644 --- a/src/audio/amigaos/SDL_ahiaudio.c +++ b/src/audio/amigaos/SDL_ahiaudio.c @@ -22,44 +22,40 @@ #include "SDL_config.h" /* Allow access to a raw mixing buffer (for AmigaOS) */ - +#include "SDL_endian.h" #include "SDL_audio.h" +#include "../SDL_audiomem.h" #include "../SDL_audio_c.h" #include "SDL_ahiaudio.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 init fuctions */ +static int AHI_AudioAvailable(void); +static SDL_AudioDevice *AHI_CreateDevice(int devindex); +static void AHI_DeleteDevice(SDL_AudioDevice *device); -/* Audio driver bootstrap functions */ +/* Audio driver export functions */ +/* pre thread functions */ +static int AHI_OpenAudio(SDL_AudioDevice *self, SDL_AudioSpec *spec); +static void AHI_CloseAudio(SDL_AudioDevice *self); + +/* thread functions */ +static void AHI_WaitAudio(SDL_AudioDevice *self); +static void AHI_PlayAudio(SDL_AudioDevice *self); +static Uint8 *AHI_GetAudioBuf(SDL_AudioDevice *self); -static int Audio_Available(void) -{ - int ok=0; +/* Audio driver bootstrap functions */ +static int AHI_AudioAvailable(void) { + int ok = 0; struct MsgPort *p; struct AHIRequest *req; - if(p=CreateMsgPort()) - { - if(req=(struct AHIRequest *)CreateIORequest(p,sizeof(struct AHIRequest))) - { - req->ahir_Version=4; + if ( p = CreateMsgPort() ) { + if ( req = (struct AHIRequest *)CreateIORequest(p, sizeof(struct AHIRequest))) { + req->ahir_Version = 4; - if(!OpenDevice(AHINAME,0,(struct IORequest *)req,NULL)) - { + if ( !OpenDevice(AHINAME, 0, (struct IORequest *)req, NULL) ) { D(bug("AHI available.\n")); - ok=1; + ok = 1; CloseDevice((struct IORequest *)req); } DeleteIORequest((struct IORequest *)req); @@ -67,18 +63,16 @@ static int Audio_Available(void) DeleteMsgPort(p); } - D(if(!ok) bug("AHI not available\n")); + D(if ( !ok ) bug("AHI not available\n")); return ok; } -static void Audio_DeleteDevice(SDL_AudioDevice *device) -{ +static void AHI_DeleteDevice(SDL_AudioDevice *device) { SDL_free(device->hidden); SDL_free(device); } -static SDL_AudioDevice *Audio_CreateDevice(int devindex) -{ +static SDL_AudioDevice *AHI_CreateDevice(int devindex) { SDL_AudioDevice *this; #ifndef NO_AMIGADEBUG @@ -86,20 +80,20 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) #endif /* Initialize all variables that we clean on shutdown */ - this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); + this = (SDL_AudioDevice *)malloc(sizeof(SDL_AudioDevice)); if ( this ) { - SDL_memset(this, 0, (sizeof *this)); + SDL_memset(this, 0, sizeof(SDL_AudioDevice)); this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); + SDL_malloc(sizeof(struct SDL_PrivateAudioData)); } - if ( (this == NULL) || (this->hidden == NULL) ) { + if ((this == NULL) || (this->hidden == NULL)) { SDL_OutOfMemory(); if ( this ) { SDL_free(this); } - return(0); + return (0); } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); + SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); /* Set the function pointers */ this->OpenAudio = AHI_OpenAudio; @@ -108,62 +102,64 @@ static SDL_AudioDevice *Audio_CreateDevice(int devindex) this->GetAudioBuf = AHI_GetAudioBuf; this->CloseAudio = AHI_CloseAudio; - this->free = Audio_DeleteDevice; + this->free = AHI_DeleteDevice; return this; } +#define DRIVER_NAME "amigaos" + AudioBootStrap AHI_bootstrap = { - "AHI", Audio_Available, Audio_CreateDevice + DRIVER_NAME,"AmigaOS3 AHI audio", + AHI_AudioAvailable, AHI_CreateDevice }; +void static AHI_WaitAudio(SDL_AudioDevice *self) { + OS3AudioData * data = self->hidden; -void static AHI_WaitAudio(_THIS) -{ - if(!CheckIO((struct IORequest *)audio_req[current_buffer])) - { + if ( !CheckIO((struct IORequest *)audio_req[current_buffer]) ) { WaitIO((struct IORequest *)audio_req[current_buffer]); -// AbortIO((struct IORequest *)audio_req[current_buffer]); + //AbortIO((struct IORequest *)audio_req[current_buffer]); } } -static void AHI_PlayAudio(_THIS) -{ - if(playing>1) +static void AHI_PlayAudio(SDL_AudioDevice *self) { + OS3AudioData * data = self->hidden; + + 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->hidden->size; - 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); + 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 = data->size; + 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 = data->freq; + audio_req[current_buffer]->ahir_Volume = 0x10000; + audio_req[current_buffer]->ahir_Type = data->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; + current_buffer ^= 1; playing++; } -static Uint8 *AHI_GetAudioBuf(_THIS) -{ - return(mixbuf[current_buffer]); +static Uint8 *AHI_GetAudioBuf(SDL_AudioDevice *self) { + OS3AudioData * data = self->hidden; + + return (mixbuf[current_buffer]); } -static void AHI_CloseAudio(_THIS) -{ +static void AHI_CloseAudio(SDL_AudioDevice *self) { D(bug("Closing audio...\n")); - - playing=0; + OS3AudioData * data = self->hidden; if(audio_req[0]) { - if(audio_req[1]) + if(audio_req[1] && playing>1) { D(bug("Break req[1]...\n")); @@ -176,36 +172,37 @@ static void AHI_CloseAudio(_THIS) AbortIO((struct IORequest *)audio_req[0]); WaitIO((struct IORequest *)audio_req[0]); - if(audio_req[1]) + // Abort again to be sure to break the dbuffering process. + if(audio_req[1] && playing>1) { D(bug("Break AGAIN req[1]...\n")); AbortIO((struct IORequest *)audio_req[1]); WaitIO((struct IORequest *)audio_req[1]); } -// Double abort to be sure to break the dbuffering process. - SDL_Delay(200); D(bug("Reqs breaked, closing device...\n")); CloseDevice((struct IORequest *)audio_req[0]); D(bug("Device closed, freeing memory...\n")); - myfree(audio_req[1]); - D(bug("Memory freed, deleting IOReq...\n")); + SDL_free(audio_req[1]); + D(bug("Memory freed, deleting IOReq...\n")); DeleteIORequest((struct IORequest *)audio_req[0]); audio_req[0]=audio_req[1]=NULL; + + Delay(3); // wait 60 ms to be safe } + playing=0; + D(bug("Freeing mixbuf[0]...\n")); if ( mixbuf[0] != NULL ) { - myfree(mixbuf[0]); -// SDL_FreeAudioMem(mixbuf[0]); + SDL_FreeAudioMem(mixbuf[0]); mixbuf[0] = NULL; } D(bug("Freeing mixbuf[1]...\n")); if ( mixbuf[1] != NULL ) { - myfree(mixbuf[1]); -// SDL_FreeAudioMem(mixbuf[1]); + SDL_FreeAudioMem(mixbuf[1]); mixbuf[1] = NULL; } @@ -215,48 +212,46 @@ static void AHI_CloseAudio(_THIS) DeleteMsgPort(audio_port); audio_port = NULL; } + D(bug("...done!\n")); } -static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) -{ -// int width; - +static int AHI_OpenAudio(SDL_AudioDevice *self, SDL_AudioSpec *spec) { D(bug("AHI opening...\n")); + OS3AudioData * data = self->hidden; /* Determine the audio parameters from the AudioSpec */ switch ( spec->format & 0xFF ) { - - case 8: { /* Signed 8 bit audio data */ + case 8: { + /* Signed 8 bit audio data */ D(bug("Samples a 8 bit...\n")); spec->format = AUDIO_S8; - this->hidden->bytespersample=1; - if(spec->channels<2) - this->hidden->type = AHIST_M8S; + data->bytespersample = 1; + if ( spec->channels < 2 ) + data->type = AHIST_M8S; else - this->hidden->type = AHIST_S8S; + data->type = AHIST_S8S; } - break; + break; case 16: { /* Signed 16 bit audio data */ D(bug("Samples a 16 bit...\n")); spec->format = AUDIO_S16MSB; - this->hidden->bytespersample=2; - if(spec->channels<2) - this->hidden->type = AHIST_M16S; + data->bytespersample = 2; + if ( spec->channels < 2 ) + data->type = AHIST_M16S; else - this->hidden->type = AHIST_S16S; + data->type = AHIST_S16S; } - break; + break; default: { SDL_SetError("Unsupported audio format"); - return(-1); + return (-1); } } - if(spec->channels!=1 && spec->channels!=2) - { + if ( spec->channels != 1 && spec->channels != 2 ) { D(bug("Wrong channel number!\n")); SDL_SetError("Channel number non supported"); return -1; @@ -268,16 +263,14 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) D(bug("Before CreateMsgPort\n")); - if(!(audio_port=CreateMsgPort())) - { + 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)))) - { + if ( !(audio_req[0] = (struct AHIRequest *)CreateIORequest(audio_port, sizeof(struct AHIRequest)))) { SDL_SetError("Unable to create an AHIRequest"); DeleteMsgPort(audio_port); return -1; @@ -285,41 +278,39 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) audio_req[0]->ahir_Version = 4; - if(OpenDevice(AHINAME,0,(struct IORequest *)audio_req[0],NULL)) - { + 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 and size */ - this->hidden->freq = spec->freq; - this->hidden->size = spec->size; + data->freq = spec->freq; + data->size = spec->size; D(bug("Before buffer allocation\n")); /* Allocate mixing buffer */ - mixbuf[0] = (Uint8 *)mymalloc(spec->size); - mixbuf[1] = (Uint8 *)mymalloc(spec->size); + mixbuf[0] = (Uint8 *)SDL_malloc(spec->size); + mixbuf[1] = (Uint8 *)SDL_malloc(spec->size); D(bug("Before audio_req allocation\n")); - if(!(audio_req[1]=mymalloc(sizeof(struct AHIRequest)))) - { + if ( !(audio_req[1] = SDL_malloc(sizeof(struct AHIRequest)))) { SDL_OutOfMemory(); - return(-1); + return (-1); } - + D(bug("Before audio_req memcpy\n")); - SDL_memcpy(audio_req[1],audio_req[0],sizeof(struct AHIRequest)); + SDL_memcpy(audio_req[1], audio_req[0], sizeof(struct AHIRequest)); if ( mixbuf[0] == NULL || mixbuf[1] == NULL ) { SDL_OutOfMemory(); - return(-1); + return (-1); } D(bug("Before mixbuf memset\n")); @@ -327,11 +318,11 @@ static int AHI_OpenAudio(_THIS, SDL_AudioSpec *spec) SDL_memset(mixbuf[0], spec->silence, spec->size); SDL_memset(mixbuf[1], spec->silence, spec->size); - current_buffer=0; - playing=0; + current_buffer = 0; + playing = 0; - D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n",spec->freq,mixbuf[0],mixbuf[1],spec->size,this->hidden->bytespersample*8,spec->channels)); + D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n", spec->freq, mixbuf[0], mixbuf[1], spec->size, this->hidden->bytespersample * 8, spec->channels)); /* We're ready to rock and roll. :-) */ - return(0); + return (0); } diff --git a/src/audio/amigaos/SDL_ahiaudio.h b/src/audio/amigaos/SDL_ahiaudio.h index b9ef339c6..b3c286e9f 100644 --- a/src/audio/amigaos/SDL_ahiaudio.h +++ b/src/audio/amigaos/SDL_ahiaudio.h @@ -26,11 +26,23 @@ #include #include -#ifdef __SASC + +#if defined(__SASC) || defined(WARPOS) #include #else +#ifdef MORPHOS +#include +#else + #include +#include +#include + #endif +#endif + +#include +#include #include #include "mydebug.h" @@ -38,23 +50,25 @@ #include "../SDL_sysaudio.h" /* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this +#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,size; - Uint8 *mixbuf[2]; /* The app mixing buffer */ + struct AHIRequest *ahi_IORequest[2]; + struct MsgPort *ahi_ReplyPort; + Sint32 freq, type, bytespersample, size; + Uint8 *audio_MixBuffer[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) +#define audio_port (data->ahi_ReplyPort) +#define audio_req (data->ahi_IORequest) +#define mixbuf (data->audio_MixBuffer) +#define current_buffer (data->current_buffer) +#define playing (data->playing) + +typedef struct SDL_PrivateAudioData OS3AudioData; #endif /* _SDL_ahiaudio_h */ diff --git a/src/cdrom/beos/SDL_syscdrom.cc b/src/cdrom/beos/SDL_syscdrom.cc index 9a62c3839..a9aa9c63e 100644 --- a/src/cdrom/beos/SDL_syscdrom.cc +++ b/src/cdrom/beos/SDL_syscdrom.cc @@ -59,7 +59,7 @@ extern "C" { #define POS_REL_F(pos) pos.position[15] /* The maximum number of CD-ROM drives we'll detect */ -#define MAX_DRIVES 16 +#define MAX_DRIVES 16 /* A list of available CD-ROM drives */ static char *SDL_cdlist[MAX_DRIVES]; @@ -194,7 +194,7 @@ int SDL_SYS_CDInit(void) return(0); } } - + /* Scan the system for CD-ROM drives */ try_dir("/dev/disk"); return 0; @@ -202,43 +202,43 @@ int SDL_SYS_CDInit(void) int try_dir(const char *directory) -{ - BDirectory dir; - dir.SetTo(directory); - if(dir.InitCheck() != B_NO_ERROR) { - return false; - } - dir.Rewind(); - BEntry entry; - while(dir.GetNextEntry(&entry) >= 0) { - BPath path; - const char *name; - entry_ref e; - - if(entry.GetPath(&path) != B_NO_ERROR) - continue; - name = path.Path(); - - if(entry.GetRef(&e) != B_NO_ERROR) - continue; - - if(entry.IsDirectory()) { - if(SDL_strcmp(e.name, "floppy") == 0) +{ + BDirectory dir; + dir.SetTo(directory); + if(dir.InitCheck() != B_NO_ERROR) { + return false; + } + dir.Rewind(); + BEntry entry; + while(dir.GetNextEntry(&entry) >= 0) { + BPath path; + const char *name; + entry_ref e; + + if(entry.GetPath(&path) != B_NO_ERROR) + continue; + name = path.Path(); + + if(entry.GetRef(&e) != B_NO_ERROR) + continue; + + if(entry.IsDirectory()) { + if(SDL_strcmp(e.name, "floppy") == 0) continue; /* ignore floppy (it is not silent) */ int devfd = try_dir(name); if(devfd >= 0) return devfd; - } - else { - int devfd; - device_geometry g; + } + else { + int devfd; + device_geometry g; - if(SDL_strcmp(e.name, "raw") != 0) + if(SDL_strcmp(e.name, "raw") != 0) continue; /* ignore partitions */ - devfd = open(name, O_RDONLY); - if(devfd < 0) - continue; + devfd = open(name, O_RDONLY); + if(devfd < 0) + continue; if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) { if(g.device_type == B_CD) @@ -247,7 +247,7 @@ int try_dir(const char *directory) } } close(devfd); - } + } } return B_ERROR; } @@ -273,7 +273,7 @@ static int SDL_SYS_CDioctl(int index, int command, void *arg) static const char *SDL_SYS_CDName(int drive) { return(SDL_cdlist[drive]); -} +} static int SDL_SYS_CDOpen(int drive) { diff --git a/src/cdrom/macosx/SDL_syscdrom.c b/src/cdrom/macosx/SDL_syscdrom.c index 501875022..43982e697 100644 --- a/src/cdrom/macosx/SDL_syscdrom.c +++ b/src/cdrom/macosx/SDL_syscdrom.c @@ -59,14 +59,14 @@ static int LoadTracks (SDL_CD *cdrom) /* Check if tracks are already loaded */ if ( tracks[cdrom->id] != NULL ) return 0; - + /* Allocate memory for tracks */ tracks[cdrom->id] = (FSRef*) SDL_calloc (1, sizeof(**tracks) * cdrom->numtracks); if (tracks[cdrom->id] == NULL) { SDL_OutOfMemory (); return -1; } - + /* Load tracks */ if (ListTrackFiles (volumes[cdrom->id], tracks[cdrom->id], cdrom->numtracks) < 0) return -1; @@ -78,21 +78,20 @@ static int LoadTracks (SDL_CD *cdrom) static FSRef* GetFileForOffset (SDL_CD *cdrom, int start, int length, int *outStartFrame, int *outStopFrame) { int i; - + for (i = 0; i < cdrom->numtracks; i++) { - if (cdrom->track[i].offset <= start && start < (cdrom->track[i].offset + cdrom->track[i].length)) break; } - + if (i == cdrom->numtracks) return NULL; - + currentTrack = i; *outStartFrame = start - cdrom->track[i].offset; - + if ((*outStartFrame + length) < cdrom->track[i].length) { *outStopFrame = *outStartFrame + length; length = 0; @@ -105,48 +104,48 @@ static FSRef* GetFileForOffset (SDL_CD *cdrom, int start, int length, int *outS nextTrackFrame = cdrom->track[i+1].offset; nextTrackFramesRemaining = length; } - + return &tracks[cdrom->id][i]; } /* Setup another file for playback, or stop playback (called from another thread) */ static void CompletionProc (SDL_CD *cdrom) { - + Lock (); - + if (nextTrackFrame > 0 && nextTrackFramesRemaining > 0) { - + /* Load the next file to play */ int startFrame, stopFrame; FSRef *file; - + PauseFile (); ReleaseFile (); - - file = GetFileForOffset (cdrom, nextTrackFrame, + + file = GetFileForOffset (cdrom, nextTrackFrame, nextTrackFramesRemaining, &startFrame, &stopFrame); - + if (file == NULL) { status = CD_STOPPED; Unlock (); return; } - + LoadFile (file, startFrame, stopFrame); - + SetCompletionProc (CompletionProc, cdrom); - + PlayFile (); } else { - + /* Release the current file */ PauseFile (); ReleaseFile (); status = CD_STOPPED; } - + Unlock (); } @@ -154,7 +153,7 @@ static void CompletionProc (SDL_CD *cdrom) #pragma mark -- Driver Functions -- /* Initialize */ -int SDL_SYS_CDInit (void) +int SDL_SYS_CDInit (void) { /* Initialize globals */ volumes = NULL; @@ -167,7 +166,7 @@ int SDL_SYS_CDInit (void) didReadTOC = SDL_FALSE; cacheTOCNumTracks = -1; currentDrive = -1; - + /* Fill in function pointers */ SDL_CDcaps.Name = SDL_SYS_CDName; SDL_CDcaps.Open = SDL_SYS_CDOpen; @@ -180,15 +179,15 @@ int SDL_SYS_CDInit (void) SDL_CDcaps.Eject = SDL_SYS_CDEject; SDL_CDcaps.Close = SDL_SYS_CDClose; - /* + /* Read the list of "drives" - + This is currently a hack that infers drives from mounted audio CD volumes, rather than actual CD-ROM devices - which means it may not act as expected sometimes. */ - + /* Find out how many cd volumes are mounted */ SDL_numcds = DetectAudioCDVolumes (NULL, 0); @@ -197,47 +196,47 @@ int SDL_SYS_CDInit (void) so tray empty can be reported. */ if (SDL_numcds == 0) { - + fakeCD = SDL_TRUE; SDL_numcds = 1; status = CD_TRAYEMPTY; - + return 0; } - + /* Allocate space for volumes */ volumes = (FSVolumeRefNum*) SDL_calloc (1, sizeof(*volumes) * SDL_numcds); if (volumes == NULL) { SDL_OutOfMemory (); return -1; } - + /* Allocate space for tracks */ tracks = (FSRef**) SDL_calloc (1, sizeof(*tracks) * (SDL_numcds + 1)); if (tracks == NULL) { SDL_OutOfMemory (); return -1; } - + /* Mark the end of the tracks array */ tracks[ SDL_numcds ] = (FSRef*)-1; - - /* + + /* Redetect, now save all volumes for later Update SDL_numcds just in case it changed */ { int numVolumes = SDL_numcds; - + SDL_numcds = DetectAudioCDVolumes (volumes, numVolumes); - + /* If more cds suddenly show up, ignore them */ if (SDL_numcds > numVolumes) { SDL_SetError ("Some CD's were added but they will be ignored"); SDL_numcds = numVolumes; } } - + return 0; } @@ -245,17 +244,16 @@ int SDL_SYS_CDInit (void) void SDL_SYS_CDQuit(void) { ReleaseFile(); - + if (volumes != NULL) free (volumes); - + if (tracks != NULL) { - FSRef **ptr; for (ptr = tracks; *ptr != (FSRef*)-1; ptr++) if (*ptr != NULL) free (*ptr); - + free (tracks); } } @@ -274,7 +272,7 @@ static const char *SDL_SYS_CDName (int drive) OSStatus err = noErr; HParamBlockRec pb; GetVolParmsInfoBuffer volParmsInfo; - + if (fakeCD) return "Fake CD-ROM Device"; @@ -314,17 +312,17 @@ static int SDL_SYS_CDGetTOC (SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + if (didReadTOC) { cdrom->numtracks = cacheTOCNumTracks; return 0; } - - + + ReadTOCData (volumes[cdrom->id], cdrom); didReadTOC = SDL_TRUE; cacheTOCNumTracks = cdrom->numtracks; - + return 0; } @@ -333,14 +331,14 @@ static CDstatus SDL_SYS_CDStatus (SDL_CD *cdrom, int *position) { if (position) { int trackFrame; - + Lock (); trackFrame = GetCurrentFrame (); Unlock (); - + *position = cdrom->track[currentTrack].offset + trackFrame; } - + return status; } @@ -349,41 +347,41 @@ static int SDL_SYS_CDPlay(SDL_CD *cdrom, int start, int length) { int startFrame, stopFrame; FSRef *ref; - + if (fakeCD) { SDL_SetError (kErrorFakeDevice); return -1; } - + Lock(); - + if (LoadTracks (cdrom) < 0) return -2; - + if (PauseFile () < 0) return -3; - + if (ReleaseFile () < 0) return -4; - + ref = GetFileForOffset (cdrom, start, length, &startFrame, &stopFrame); if (ref == NULL) { SDL_SetError ("SDL_SYS_CDPlay: No file for start=%d, length=%d", start, length); return -5; } - + if (LoadFile (ref, startFrame, stopFrame) < 0) return -6; - + SetCompletionProc (CompletionProc, cdrom); - + if (PlayFile () < 0) return -7; - + status = CD_PLAYING; - + Unlock(); - + return 0; } @@ -394,18 +392,18 @@ static int SDL_SYS_CDPause(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + status = CD_PAUSED; - + Unlock (); - + return 0; } @@ -416,18 +414,18 @@ static int SDL_SYS_CDResume(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PlayFile () < 0) { Unlock (); return -2; } - + status = CD_PLAYING; - + Unlock (); - + return 0; } @@ -438,23 +436,23 @@ static int SDL_SYS_CDStop(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + if (ReleaseFile () < 0) { Unlock (); return -3; } - + status = CD_STOPPED; - + Unlock (); - + return 0; } @@ -468,21 +466,21 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) SDL_SetError (kErrorFakeDevice); return -1; } - + Lock (); - + if (PauseFile () < 0) { Unlock (); return -2; } - + if (ReleaseFile () < 0) { Unlock (); return -3; } - + status = CD_STOPPED; - + /* Eject the volume */ err = FSEjectVolumeSync(volumes[cdrom->id], kNilOptions, &dissenter); @@ -491,16 +489,16 @@ static int SDL_SYS_CDEject(SDL_CD *cdrom) SDL_SetError ("PBUnmountVol returned %d", err); return -4; } - + status = CD_TRAYEMPTY; /* Invalidate volume and track info */ volumes[cdrom->id] = 0; free (tracks[cdrom->id]); tracks[cdrom->id] = NULL; - + Unlock (); - + return 0; } diff --git a/src/cpuinfo/SDL_cpuinfo.c b/src/cpuinfo/SDL_cpuinfo.c index 62adf36e6..4ff4ee848 100644 --- a/src/cpuinfo/SDL_cpuinfo.c +++ b/src/cpuinfo/SDL_cpuinfo.c @@ -37,9 +37,20 @@ #include #endif -#ifdef __amigaos4__ +#if defined(WARPUP) +#include + +#pragma pack(2) +#include +#endif +#if defined(__amigaos4__) #include #include +#elif defined(WARPUP) +#include +#include +#include +#pragma pack() #endif #define CPU_HAS_RDTSC 0x00000001 @@ -370,7 +381,10 @@ static __inline__ int CPU_haveSSE2(void) static __inline__ int CPU_haveAltiVec(void) { +#ifndef WARPUP volatile int altivec = 0; +#endif + #if (defined(__MACOSX__) && (defined(__ppc__) || defined(__ppc64__))) || (defined(__OpenBSD__) && defined(__powerpc__)) # ifdef __OpenBSD__ int selectors[2] = { CTL_MACHDEP, CPU_ALTIVEC }; @@ -381,14 +395,25 @@ static __inline__ int CPU_haveAltiVec(void) size_t length = sizeof(hasVectorUnit); int error = sysctl(selectors, 2, &hasVectorUnit, &length, NULL, 0); if( 0 == error ) - altivec = (hasVectorUnit != 0); -#elif defined __amigaos4__ + altivec = (hasVectorUnit != 0); +#elif defined(__amigaos4__) { uint32 vec_unit; IExec->GetCPUInfoTags(GCIT_VectorUnit, &vec_unit, TAG_DONE); altivec = (vec_unit == VECTORTYPE_ALTIVEC); } +#elif defined(WARPUP) + int altivec = 0; + if (PowerPCBase->lib_Version >= 17) + { + struct TagItem cputags[2] = { {GETINFO_CPU, 0}, {TAG_END,0} }; + GetInfo(cputags); + if (cputags[0].ti_Data & CPUF_G4) + { + altivec = 1; + } + } #elif SDL_ALTIVEC_BLITTERS && HAVE_SETJMP void (*handler)(int sig); handler = signal(SIGILL, illegal_instruction); diff --git a/src/events/SDL_mouse.c b/src/events/SDL_mouse.c index 0320d6167..6c2ef5892 100644 --- a/src/events/SDL_mouse.c +++ b/src/events/SDL_mouse.c @@ -117,6 +117,11 @@ int SDL_PrivateMouseMotion(Uint8 buttonstate, int relative, Sint16 x, Sint16 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; diff --git a/src/thread/amigaos/SDL_syssem.c b/src/thread/amigaos/SDL_syssem.c index a31a2133b..e44ca4583 100644 --- a/src/thread/amigaos/SDL_syssem.c +++ b/src/thread/amigaos/SDL_syssem.c @@ -21,128 +21,521 @@ */ #include "SDL_config.h" -/* An implementation of semaphores using mutexes and condition variables */ +#include /* for malloc/free */ +#ifndef NO_AMIGADEBUG +#define NO_AMIGADEBUG +#endif +#ifdef MORPHOS +#include +#else + +#include +#include +#include + +#endif + +#include "SDL_error.h" #include "SDL_thread.h" #include "SDL_systhread_c.h" +//#include "SDL_systimer.h" + +//#include +#include +//#include + + +#define NEWLIST(_l) \ +do \ +{ \ + struct List *l = (struct List *)(_l); \ + \ + l->lh_TailPred = (struct Node *)l; \ + l->lh_Tail = 0; \ + l->lh_Head = (struct Node *)&l->lh_Tail; \ +} while (0) + +#define ADDHEAD(_l, _n) \ +do \ +{ \ + struct Node *n = (struct Node *)(_n); \ + struct List *l = (struct List *)(_l); \ + \ + n->ln_Succ = l->lh_Head; \ + n->ln_Pred = (struct Node *)&l->lh_Head; \ + l->lh_Head->ln_Pred = n; \ + l->lh_Head = n; \ +} while (0) + +#define ADDTAIL(_l, _n) \ +do \ +{ \ + struct Node *n = (struct Node *)(_n); \ + struct List *l = (struct List *)(_l); \ + \ + n->ln_Succ = (struct Node *)&l->lh_Tail; \ + n->ln_Pred = l->lh_TailPred; \ + l->lh_TailPred->ln_Succ = n; \ + l->lh_TailPred = n; \ +} while (0) + +#define REMOVE(_n) \ +do \ +{ \ + struct Node *n = (struct Node *)(_n); \ + \ + n->ln_Pred->ln_Succ = n->ln_Succ; \ + n->ln_Succ->ln_Pred = n->ln_Pred; \ +} while (0) + + +extern struct timerequest *TimerReq[2]; + +struct waitnode { + struct MinNode node; + struct Task *task; + ULONG sigmask; +}; +struct SDL_semaphore { + struct SignalSemaphore sem; + struct MinList waitlist; + int sem_value; +}; -struct SDL_semaphore -{ - struct SignalSemaphore Sem; +struct mywaitdata { + struct MsgPort port; + struct timerequest timereq; + ULONG extramask; + BOOL pending; }; -#undef D +#define FALLBACKSIGNAL SIGBREAKB_CTRL_E -#define D(x) +static +void mywaitdone(struct mywaitdata *data) { + if ( data->pending ) { + data->pending = FALSE; + AbortIO((struct IORequest *)&data->timereq); + WaitIO((struct IORequest *)&data->timereq); + } -SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_sem *sem; + if ((BYTE)data->port.mp_SigBit != -1 ) { + FreeSignal(data->port.mp_SigBit); + data->port.mp_SigBit = (UBYTE) - 1; + } + CloseDevice((struct IORequest *)&data->timereq); +} + +static +int mywaitinit(struct mywaitdata *data, Uint32 timeout) { + int error; + + data->extramask = 0; + data->pending = FALSE; + if ((BYTE)(data->port.mp_SigBit = AllocSignal(-1)) != -1 ) { + struct timerequest *req = TimerReq[timeout < 100]; /* 0 = VBlank, 1 = MicroHz */ + + data->port.mp_Node.ln_Type = NT_MSGPORT; + data->port.mp_Flags = PA_SIGNAL; + data->port.mp_SigTask = FindTask(NULL); + NEWLIST(&data->port.mp_MsgList); + + data->timereq.tr_node.io_Message.mn_Node.ln_Type = NT_REPLYMSG; + data->timereq.tr_node.io_Message.mn_ReplyPort = &data->port; + data->timereq.tr_node.io_Message.mn_Length = sizeof(data->timereq); + error = OpenDevice(TIMERNAME, UNIT_MICROHZ, (struct IORequest *)&data->timereq, 0L); + if ( error ) D(bug("Can't open timer device\n")); + //data->timereq.tr_node.io_Device = req->tr_node.io_Device; + //data->timereq.tr_node.io_Unit = req->tr_node.io_Unit; + + return 0; + } - sem = (SDL_sem *)SDL_malloc(sizeof(*sem)); + mywaitdone(data); - if ( ! sem ) { - SDL_OutOfMemory(); - return(0); + return -1; +} + +static +int mywait(struct mywaitdata *data, Uint32 timeout) { + ULONG wsig, sigs; + + wsig = 1 << data->timereq.tr_node.io_Message.mn_ReplyPort->mp_SigBit; + + if ( !data->pending ) { + data->pending = TRUE; + data->timereq.tr_node.io_Command = TR_ADDREQUEST; + data->timereq.tr_time.tv_secs = timeout / 1000; + data->timereq.tr_time.tv_micro = (timeout % 1000) * 1000; + SendIO((struct IORequest *)&data->timereq); } - D(bug("Creating semaphore %lx...\n",sem)); + sigs = Wait(wsig | data->extramask | SIGBREAKF_CTRL_C); + + if ( sigs & wsig ) { + data->pending = FALSE; + WaitIO((struct IORequest *)&data->timereq); + } else { + if ( data->pending && data->extramask == 0 ) { + data->pending = FALSE; + AbortIO((struct IORequest *)&data->timereq); + WaitIO((struct IORequest *)&data->timereq); + } + } + + data->extramask &= sigs; + + if ( sigs & SIGBREAKF_CTRL_C ) { + return -1; + } + + return 0; +} - SDL_memset(sem,0,sizeof(*sem)); +/* Create a semaphore, initialized with value */ +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { + SDL_sem *sem; + + D(bug("[include] SDL_CreateSemaphore(%ld)\n", initial_value)); + + sem = malloc(sizeof(*sem)); + if ( sem ) { + memset(&sem->sem, 0, sizeof(sem->sem)); + InitSemaphore(&sem->sem); - InitSemaphore(&sem->Sem); + NEWLIST(&sem->waitlist); - return(sem); + sem->sem_value = initial_value; + } else { + SDL_OutOfMemory(); + } + + return sem; } -void SDL_DestroySemaphore(SDL_sem *sem) -{ - D(bug("Destroying semaphore %lx...\n",sem)); +void SDL_DestroySemaphore(SDL_sem *sem) { + D(bug("[include] SDL_DestroySemaphore()\n")); + D(bug("Destroying semaphore %lx...\n", sem)); if ( sem ) { -// Condizioni per liberare i task in attesa? - SDL_free(sem); +#if 1 + + struct mywaitdata data; + + if ( mywaitinit(&data, 10) == 0 ) { + ObtainSemaphore(&sem->sem); + + sem->sem_value = -1; + + while ( !IsListEmpty((struct List *)&sem->waitlist)) { + struct waitnode *wn; + int res; + + D(bug("[include] bug, semaphore %lx busy!\n", sem)); + + for ( wn = (struct waitnode *)sem->waitlist.mlh_Head; + wn->node.mln_Succ; + wn = (struct waitnode *)wn->node.mln_Succ ) { + Signal(wn->task, wn->sigmask); + } + + ReleaseSemaphore(&sem->sem); + Delay(2); + res = mywait(&data, 10); + + ObtainSemaphore(&sem->sem); + + if ( res < 0 ) { + break; + } + } + + ReleaseSemaphore(&sem->sem); + } + + mywaitdone(&data); + +#endif + + free(sem); } } -int SDL_SemTryWait(SDL_sem *sem) -{ - if ( ! sem ) { +int SDL_SemTryWait(SDL_sem *sem) { + int retval; + + D(bug("[include] SDL_SemTryWait()\n")); + + if ( !sem ) { SDL_SetError("Passed a NULL semaphore"); return -1; } - D(bug("TryWait semaphore...%lx\n",sem)); + ObtainSemaphore(&sem->sem); + + if ( sem->sem_value > 0 ) { + --sem->sem_value; + retval = 0; + } else { + retval = SDL_MUTEX_TIMEDOUT; + } - ObtainSemaphore(&sem->Sem); -// ReleaseSemaphore(&sem->Sem); + ReleaseSemaphore(&sem->sem); - return 1; + return retval; } -int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) -{ +int SDL_SemWait(SDL_sem *sem) { int retval; + struct waitnode wn; + LONG signal; + D(bug("[include] SDL_SemWait(0x%08.8lx) from thread 0x%08.8lx\n", sem, FindTask(NULL))); - if ( ! sem ) { + if ( !sem ) { SDL_SetError("Passed a NULL semaphore"); return -1; } - D(bug("WaitTimeout (%ld) semaphore...%lx\n",timeout,sem)); + retval = 0; + signal = -1; + + ObtainSemaphore(&sem->sem); + + D(bug("[include] SDL_SemWait(): from thread 0x%08.8lx initial sem_value: %ld\n", FindTask(NULL), sem->sem_value)); + + while ( sem->sem_value <= 0 ) { + ULONG sigmask; + + if ( signal == -1 ) { + wn.task = FindTask(NULL); + signal = AllocSignal(-1); + if ( signal == -1 ) { + signal = FALLBACKSIGNAL; + SetSignal(1 << FALLBACKSIGNAL, 0); + } + wn.sigmask = 1 << signal; + + ADDTAIL(&sem->waitlist, &wn); + } + + D(bug("[include] SDL_SemWait(): waiting for semaphore... \n")); + + ReleaseSemaphore(&sem->sem); + + sigmask = Wait(wn.sigmask | SIGBREAKF_CTRL_C); + + ObtainSemaphore(&sem->sem); + + if ( sigmask & SIGBREAKF_CTRL_C ) { + D(bug("[include] SDL_SemWait(): was aborted...\n")); + retval = -1; + break; + } + } + + if ( signal != -1 ) { + REMOVE(&wn); + + if ( signal != FALLBACKSIGNAL ) { + FreeSignal(signal); + } + } - /* A timeout of 0 is an easy case */ + if ( retval == 0 ) { + --sem->sem_value; + + D(bug("[include] SDL_SemWait(): final sem_value: %ld\n", sem->sem_value)); + } + + ReleaseSemaphore(&sem->sem); + D(bug("done...\n")); + + return retval; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { + struct mywaitdata data; + int retval; + + D(bug("[include] SDL_SemWaitTimeout()\n")); + + if ( !sem ) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + /* Try the easy cases first */ if ( timeout == 0 ) { - ObtainSemaphore(&sem->Sem); - return 1; + return SDL_SemTryWait(sem); } - if(!(retval=AttemptSemaphore(&sem->Sem))) - { - SDL_Delay(timeout); - retval=AttemptSemaphore(&sem->Sem); + if ( timeout == SDL_MUTEX_MAXWAIT ) { + return SDL_SemWait(sem); } - if(retval==TRUE) +#if 1 + + if ( mywaitinit(&data, timeout) == 0 ) { + struct waitnode wn; + LONG signal; + + retval = 0; + signal = -1; + + ObtainSemaphore(&sem->sem); + + while ( sem->sem_value <= 0 ) { + if ( signal == -1 ) { + wn.task = FindTask(NULL); + signal = AllocSignal(-1); + if ( signal == -1 ) { + signal = FALLBACKSIGNAL; + SetSignal(1 << FALLBACKSIGNAL, 0); + } + wn.sigmask = 1 << signal; + + ADDTAIL(&sem->waitlist, &wn); + } + + ReleaseSemaphore(&sem->sem); + + data.extramask = wn.sigmask; + retval = mywait(&data, timeout); + + ObtainSemaphore(&sem->sem); + + /* CTRL-C? */ + if ( retval < 0 ) { + break; + } + + /* Timed out? (== no 'semaphore released'-signal) */ + if ( data.extramask == 0 ) { + retval = SDL_MUTEX_TIMEDOUT; + + break; + } + + /* + * Not timed out, someone released the semaphore. + * See if we can get it. If we can't, continue waiting. + */ + } + + if ( signal != -1 ) { + REMOVE(&wn); + + if ( signal != FALLBACKSIGNAL ) { + FreeSignal(signal); + } + } + + /* If can obtain (no timeout, no break), obtain it */ + if ( retval == 0 ) { + --sem->sem_value; + + D(bug("[include] SDL_SemWaitTimeout(): final sem_value: %ld\n", sem->sem_value)); + } + + ReleaseSemaphore(&sem->sem); + } else retval = -1; + + mywaitdone(&data); + +#else + + /* Ack! We have to busy wait... */ + timeout += SDL_GetTicks(); + + if (mywaitinit(&data, 1) == 0) { -// ReleaseSemaphore(&sem->Sem); - retval=1; + do + { + retval = SDL_SemTryWait(sem); + if (retval == 0) + { + break; + } + + if (mywait(&data, 1) < 0) + { + retval = -1; + break; + } + + } while (SDL_GetTicks() < timeout); } + else retval = -1; + + mywaitdone(&data); + +#endif return retval; } -int SDL_SemWait(SDL_sem *sem) -{ - ObtainSemaphore(&sem->Sem); - return 0; -} +Uint32 SDL_SemValue(SDL_sem *sem) { + int retval; -Uint32 SDL_SemValue(SDL_sem *sem) -{ - Uint32 value; + D(bug("[include] SDL_SemValue()\n")); - value = 0; - if ( sem ) { - #ifdef STORMC4_WOS - value = sem->Sem.ssppc_SS.ss_NestCount; - #else - value = sem->Sem.ss_NestCount; - #endif + if ( !sem ) { + SDL_SetError("Passed a NULL semaphore"); + return 0; + } + + ObtainSemaphoreShared(&sem->sem); + + retval = sem->sem_value; + + ReleaseSemaphore(&sem->sem); + + if ( retval < 0 ) { + retval = 0; } - return value; + + return (Uint32)retval; } -int SDL_SemPost(SDL_sem *sem) -{ - if ( ! sem ) { +int SDL_SemPost(SDL_sem *sem) { + struct waitnode *wn; + + if ( !sem ) { SDL_SetError("Passed a NULL semaphore"); return -1; } - D(bug("SemPost semaphore...%lx\n",sem)); - ReleaseSemaphore(&sem->Sem); + ObtainSemaphore(&sem->sem); + + D(bug("[include] SDL_SemPost(0x%08.8lx): initial sem_value: %ld\n", sem, sem->sem_value)); + +#if 1 + + /* Wake whatever task happens to be first in the waitlist */ + wn = (struct waitnode *)sem->waitlist.mlh_Head; + if ( wn->node.mln_Succ ) { + Signal(wn->task, wn->sigmask); + } + +#else + + for (wn = (struct waitnode *) sem->waitlist.mlh_Head; + wn->node.mln_Succ; + wn = (struct waitnode *) wn->node.mln_Succ) + { + Signal(wn->task, wn->sigmask); + } + +#endif + + ++sem->sem_value; + + D(bug("[include] SDL_SemPost(): final sem_value: %ld\n", sem->sem_value)); + + ReleaseSemaphore(&sem->sem); + return 0; } diff --git a/src/thread/amigaos/SDL_systhread.c b/src/thread/amigaos/SDL_systhread.c index c6b42e776..394dc5be0 100644 --- a/src/thread/amigaos/SDL_systhread.c +++ b/src/thread/amigaos/SDL_systhread.c @@ -21,50 +21,112 @@ */ #include "SDL_config.h" -/* BeOS thread management routines for SDL */ +#include +#include +#include "SDL.h" +#include +#include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_thread.h" -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" +#include "SDL_thread_c.h" +#include "SDL_systhread.h" #include "mydebug.h" +#ifdef APOLLO_BLIT +#include "apolloammxenable.h" +#endif + +#ifdef AROS +#include +#endif + typedef struct { int (*func)(void *); void *data; SDL_Thread *info; struct Task *wait; +#ifdef SHARED_LIB + APTR LibBase; +#endif } thread_args; #ifndef MORPHOS -#if defined(__SASC) && !defined(__PPC__) +#if defined(__SASC) && !defined(__PPC__) __saveds __asm Uint32 RunThread(register __a0 char *args ) -#elif defined(__PPC__) -Uint32 RunThread(char *args) +#elif defined(__PPC__) || defined(AROS) +Uint32 RunThread(char *) +#elif !defined(SHARED_LIB) +Uint32 __saveds + +RunThread(char *p1) #else -Uint32 __saveds RunThread(char *args __asm("a0") ) +Uint32 RunThread(char * p1) #endif { - #ifdef STORMC4_WOS + register char *args __asm("a0"); + struct Task *Father; + + long *pid; + APTR ixemulbase = 0; +#ifndef SHARED_LIB +#ifdef WARPOS thread_args *data=(thread_args *)args; - #else - thread_args *data=(thread_args *)atol(args); - #endif +#else + thread_args *data = (thread_args *)atol(args); +#endif - struct Task *Father; +#else /* SHARED_LIB */ + thread_args *data; - D(bug("Received data: %lx\n",data)); - Father=data->wait; + register APTR base __asm("a6"); + { + ULONG temp=0; - SDL_RunThread(data); + while(*args >= '0' && *args <= '9') + temp = (temp * 10) + (*args++ - '0'); + + data=(thread_args *)temp; + } + + base=data->LibBase; + mygeta4(); + D(bug("Library base: %lx\n",base)); +#endif + + D(bug("Received data: %lx, father:%lx\n", data, data->wait)); + Father = data->wait; +#ifdef APOLLO_BLIT + Apollo_EnableAMMX(); /* AMMX is per task, enable for all threads (if applicable) */ +#endif + +#ifndef NOIXEMUL + { + + ixemulbase = OpenLibrary("ixemul.library", 51); + if ( ixemulbase ) { + ix_CreateChildData(Father, 0); + SDL_RunThread(data); + CloseLibrary(ixemulbase); + Signal(Father, SIGBREAKF_CTRL_F); + + } + } +#else + { + SDL_RunThread(data); + D(bug("Thread exited, signaling father (%lx)...\n",Father)); Signal(Father,SIGBREAKF_CTRL_F); D(bug("Thread with data %lx ended\n",data)); - return(0); + } +#endif + + return (0); } -#else +#else /* Morphos code */ #include @@ -94,58 +156,120 @@ void *RunThread=&RunThreadStruct; #endif -int SDL_SYS_CreateThread(SDL_Thread *thread, void *args) -{ +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) - SDL_snprintf(buffer, SDL_arraysize(buffer),"%ld",args); - - #ifdef STORMC4_WOS - thread->handle=CreateTaskPPCTags(TASKATTR_CODE, RunThread, - TASKATTR_NAME, "SDL subtask", - TASKATTR_STACKSIZE, 100000, - (args ? TASKATTR_R3 : TAG_IGNORE), args, - TASKATTR_INHERITR2, TRUE, - TAG_DONE); - #else - 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); - #endif - - if(!thread->handle) +#ifdef WARPOS + struct TagItem tags[6]; +#endif + +#ifdef SHARED_LIB + extern void *myLibPtr; + + ((thread_args *)args)->LibBase= myLibPtr; + D(bug("CreateThread: librarybase %lx\n",myLibPtr)); +#endif + + D(bug("Sending %lx to the new thread...\n", args)); + + if( args ) + SDL_snprintf(buffer, SDL_arraysize(buffer), "%ld", args); + + +#ifdef WARPOS + tags[0].ti_Tag = TASKATTR_CODE; tags[0].ti_Data = (ULONG)RunThread; + tags[1].ti_Tag = TASKATTR_NAME; tags[1].ti_Data = (ULONG)"include subtask"; + tags[2].ti_Tag = TASKATTR_STACKSIZE; tags[2].ti_Data = 100000; + tags[3].ti_Tag = (args ? TASKATTR_R3 : TAG_IGNORE); tags[3].ti_Data = (ULONG)args; + tags[4].ti_Tag = TASKATTR_INHERITR2; tags[4].ti_Data = TRUE; + tags[5].ti_Tag = TAG_DONE; tags[5].ti_Data = 0; + + thread->handle=CreateTaskPPC(tags); +#else { + unsigned int stack; + struct Task *t; + long *pid; + + thread->handle = (struct Task *)CreateNewProcTags( + /*NP_Output, Output(), + NP_Input, Input(),*/ + NP_Name, (ULONG)"include subtask", + /*NP_CloseOutput, FALSE, + NP_CloseInput, FALSE,*/ + NP_StackSize, 100000, + NP_Entry, (ULONG)RunThread, + NP_Cli, TRUE, + NP_Arguments, (ULONG)buffer, + TAG_DONE); + } + + /*Delay(1); // its a testhack dont activate + Disable(); + struct Task *t; + struct Task *t2; + APTR *data; + t = FindTask(0); + data = t->tc_UserData; + t2 = thread->handle; + t2->tc_UserData = data; + Enable();*/ +#endif + + if ( !thread->handle ) { SDL_SetError("Not enough resources to create thread"); - return(-1); + return (-1); } - return(0); + return (0); } -void SDL_SYS_SetupThread(void) -{ +void SDL_SYS_SetupThread(void) { } -Uint32 SDL_ThreadID(void) -{ - return((Uint32)FindTask(NULL)); +Uint32 SDL_ThreadID(void) { + return ((Uint32)FindTask(NULL)); } -void SDL_SYS_WaitThread(SDL_Thread *thread) -{ - SetSignal(0L,SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); - Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); +void SDL_SYS_WaitThread(SDL_Thread *thread) { + + + struct Node *n; + int found; + SetSignal(0L, SIGBREAKF_CTRL_F); + for ( ;; ) { + struct List *t; + found = 0; + Disable(); + t = &SysBase->TaskWait; + for ( n = t->lh_Head; + n; + n = n->ln_Succ ) + if ( thread->handle == n )found = 1; + t = &SysBase->TaskReady; + + for ( n = t->lh_Head; + n; + n = n->ln_Succ ) + if ( thread->handle == n )found = 1; + if ( FindTask(0) == n )found = 1; + Enable(); + + + if ( !found ) //check if the task is here + { + + return; + + //SetSignal(0L,SIGBREAKF_CTRL_F); + //Wait(SIGBREAKF_CTRL_F|SIGBREAKF_CTRL_C); + + } + Delay(2); + } } -void SDL_SYS_KillThread(SDL_Thread *thread) -{ - Signal((struct Task *)thread->handle,SIGBREAKF_CTRL_C); +void SDL_SYS_KillThread(SDL_Thread *thread) { + Signal((struct Task *)thread->handle, SIGBREAKF_CTRL_C); } diff --git a/src/thread/amigaos/SDL_systhread_c.h b/src/thread/amigaos/SDL_systhread_c.h index 53ba3c8c6..b20018c26 100644 --- a/src/thread/amigaos/SDL_systhread_c.h +++ b/src/thread/amigaos/SDL_systhread_c.h @@ -24,20 +24,37 @@ #include #include #include -#if defined (__SASC) || defined(STORMC4_WOS) + +#if defined (__SASC) || defined(WARPOS) || defined(AROS) #include #include #else +#ifdef MORPHOS +#include +#include +#else + #include #include + +#endif +#endif + +#include + +#ifndef AROS + +#include + #endif -#include "mydebug.h" +#include +#include "../../../mydebug.h" extern struct ExecBase *SysBase; extern struct DosLibrary *DOSBase; -#ifdef STORMC4_WOS +#ifdef WARPOS #include /* use powerpc.library functions instead og exec */ @@ -57,5 +74,5 @@ extern struct DosLibrary *DOSBase; #else #define SYS_ThreadHandle struct Task * -#endif /*STORMC4_WOS*/ +#endif /* WARPOS */ diff --git a/src/thread/amigaos/SDL_thread.c b/src/thread/amigaos/SDL_thread.c index 7698f49f3..9e1600598 100644 --- a/src/thread/amigaos/SDL_thread.c +++ b/src/thread/amigaos/SDL_thread.c @@ -23,12 +23,17 @@ /* System independent thread management routines for SDL */ +#include +#include +#include + +#include "SDL_error.h" #include "SDL_mutex.h" #include "SDL_thread.h" -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" +#include "SDL_thread_c.h" +#include "SDL_systhread.h" -#define ARRAY_CHUNKSIZE 32 +#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. @@ -39,10 +44,9 @@ static SDL_Thread **SDL_Threads = NULL; static struct SignalSemaphore thread_lock; int thread_lock_created = 0; -int SDL_ThreadsInit(void) -{ +int SDL_ThreadsInit(void) { InitSemaphore(&thread_lock); - thread_lock_created=1; + thread_lock_created = 1; return 0; } @@ -51,14 +55,12 @@ int SDL_ThreadsInit(void) 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; +void SDL_ThreadsQuit() { + thread_lock_created = 0; } /* Routines for manipulating the thread list */ -static void SDL_AddThread(SDL_Thread *thread) -{ +static void SDL_AddThread(SDL_Thread *thread) { SDL_Thread **threads; /* WARNING: @@ -94,17 +96,16 @@ static void SDL_AddThread(SDL_Thread *thread) SDL_Threads = threads; } SDL_Threads[SDL_numthreads++] = thread; -done: + done: ReleaseSemaphore(&thread_lock); } -static void SDL_DelThread(SDL_Thread *thread) -{ +static void SDL_DelThread(SDL_Thread *thread) { int i; if ( thread_lock_created ) { ObtainSemaphore(&thread_lock); - for ( i=0; ithreadid ) { errbuf = &SDL_Threads[i]->errbuf; break; @@ -147,20 +147,23 @@ SDL_error *SDL_GetErrBuf(void) } ReleaseSemaphore(&thread_lock); } - return(errbuf); + 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; +#ifdef SHARED_LIB + APTR LibBase; +#endif } thread_args; -void SDL_RunThread(void *data) -{ +void SDL_RunThread(void *data) { thread_args *args; int (*userfunc)(void *); void *userdata; @@ -181,14 +184,13 @@ void SDL_RunThread(void *data) statusloc = &args->info->status; /* Wake up the parent thread */ - Signal(args->wait,SIGBREAKF_CTRL_E); + Signal(args->wait, SIGBREAKF_CTRL_E); /* Run the function */ *statusloc = userfunc(userdata); } -SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) -{ +SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) { SDL_Thread *thread; thread_args *args; int ret; @@ -197,7 +199,7 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) thread = (SDL_Thread *)SDL_malloc(sizeof(*thread)); if ( thread == NULL ) { SDL_OutOfMemory(); - return(NULL); + return (NULL); } SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; @@ -217,13 +219,13 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) SDL_free(thread); SDL_free(args); SDL_OutOfMemory(); - return(NULL); + return (NULL); } /* Add the thread to the list of available threads */ SDL_AddThread(thread); - D(bug("Starting thread...\n")); + D(bug("Starting thread with args %lx...\n", args)); /* Create the thread and go! */ ret = SDL_SYS_CreateThread(thread, args); @@ -241,11 +243,10 @@ SDL_Thread *SDL_CreateThread(int (*fn)(void *), void *data) SDL_free(args); /* Everything is running now */ - return(thread); + return (thread); } -void SDL_WaitThread(SDL_Thread *thread, int *status) -{ +void SDL_WaitThread(SDL_Thread *thread, int *status) { if ( thread ) { SDL_SYS_WaitThread(thread); if ( status ) { @@ -256,8 +257,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status) } } -Uint32 SDL_GetThreadID(SDL_Thread *thread) -{ +Uint32 SDL_GetThreadID(SDL_Thread *thread) { Uint32 id; if ( thread ) { @@ -265,11 +265,10 @@ Uint32 SDL_GetThreadID(SDL_Thread *thread) } else { id = SDL_ThreadID(); } - return(id); + return (id); } -void SDL_KillThread(SDL_Thread *thread) -{ +void SDL_KillThread(SDL_Thread *thread) { if ( thread ) { SDL_SYS_KillThread(thread); SDL_WaitThread(thread, NULL); diff --git a/src/timer/SDL_systimer.h b/src/timer/SDL_systimer.h index d19b67987..88c52846e 100644 --- a/src/timer/SDL_systimer.h +++ b/src/timer/SDL_systimer.h @@ -38,3 +38,7 @@ extern int SDL_SYS_StartTimer(void); /* Stop a previously started timer */ extern void SDL_SYS_StopTimer(void); + +#if defined(__AMIGA__) && !defined(__amigaos4__) +extern void amiga_quit_timer(void); +#endif diff --git a/src/timer/amigaos/SDL_systimer.c b/src/timer/amigaos/SDL_systimer.c index a213b6142..7c6191ac3 100644 --- a/src/timer/amigaos/SDL_systimer.c +++ b/src/timer/amigaos/SDL_systimer.c @@ -23,244 +23,296 @@ #ifdef SDL_TIMER_AMIGA +#include +#include #include +#include #include #include #include #include #include -#include -#ifdef __SASC -#include -#include -#include -#include -#include -#elif defined(STORMC4_WOS) -#include -#include -#include + +#include + +#ifdef MORPHOS +#include +#include +#include #else + +#include #include #include #include + #endif -#include "mydebug.h" -extern struct DosLibrary *DOSBase; -extern struct ExecBase *SysBase; -static struct GfxBase *GfxBase; +#include "../../mydebug.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 first ticks value of the application */ -#if !defined(__PPC__) || defined(STORMC4_WOS) || defined(MORPHOS) -static clock_t start; +#ifdef MORPHOS +#include +#else -void SDL_StartTicks(void) -{ - /* Set first ticks value */ - start=clock(); -} +#include -Uint32 SDL_GetTicks (void) -{ - clock_t ticks; +#endif - ticks=clock()-start; +extern struct ExecBase *SysBase; -#ifdef __SASC -// CLOCKS_PER_SEC == 1000 ! +static struct timeval basetime; +struct Library *TimerBase; - return(ticks); -#else -// CLOCKS_PER_SEC != 1000 ! +struct Task *OwnerTask; +struct timerequest *TimerReq[2]; /* Local copy! */ +unsigned long ticks; - return ticks*(1000/CLOCKS_PER_SEC); -#endif +void delete_timer(struct timerequest *tr) { + struct MsgPort *tp; + + if ( tr != 0 ) { + tp = tr->tr_node.io_Message.mn_ReplyPort; + + if ( tp != 0 ) DeleteMsgPort(tp); + + CloseDevice((struct IORequest *)tr); + DeleteIORequest((struct IORequest *)tr); + } } -void SDL_Delay (Uint32 ms) -{ -// Do a busy wait if time is less than 50ms +struct timerequest *create_timer(ULONG unit) { + /* return a pointer to a timer request. If any problem, return NULL */ + LONG error; + struct MsgPort *timerport; + struct timerequest *TimerIO; - if(ms<50) - { - clock_t to_wait=clock(); + timerport = CreateMsgPort(); + if ( timerport == NULL ) + return (NULL); -#ifndef __SASC - ms*=(CLOCKS_PER_SEC/1000); -#endif - to_wait+=ms; + TimerIO = (struct timerequest *) + CreateIORequest(timerport, sizeof(struct timerequest)); - while(clock()tr_node.io_Device = TimerReq[0]->tr_node.io_Device; + //TimerIO->tr_node.io_Unit = TimerReq[0]->tr_node.io_Unit; -void PPC_TimerInit(void); -APTR MyTimer; + if ( error != 0 ) { + D(bug("Can't open timer device\n")); -ULONG start[2]; + delete_timer(TimerIO); + return (NULL); + } -void SDL_StartTicks(void) -{ - /* Set first ticks value */ - if(!MyTimer) - PPC_TimerInit(); - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,start); - start[1]>>=10; - start[1]|=((result[0]&0x3ff)<<22); - start[0]>>=10; + return (TimerIO); } -Uint32 SDL_GetTicks (void) -{ - ULONG result[2]; - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); +/* more precise timer than AmigaDOS Delay() */ +void wait_for_timer(struct timerequest *tr, struct timeval *tv) { + tr->tr_node.io_Command = TR_ADDREQUEST; /* add a new timer request */ + + /* structure assignment */ + tr->tr_time = *tv; -// PPCAsr64p(result,10); -// Non va, la emulo: + /* post request to the timer -- will go to sleep till done */ + DoIO((struct IORequest *)tr); +} + +LONG time_delay(struct timeval *tv, LONG unit) { + struct timerequest *tr; + /* get a pointer to an initialized timer request block */ + tr = create_timer(unit); - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); + /* any nonzero return says timedelay routine didn't work. */ + if ( tr == NULL ) + return (-1L); -// Non mi interessa piu' result[0] + wait_for_timer(tr, tv); - return result[1]*1000/MY_CLOCKS_PER_SEC; + /* deallocate temporary structures */ + delete_timer(tr); + return (0L); } -void SDL_Delay (Uint32 ms) -{ -// Do a busy wait if time is less than 50ms - - if(ms<50) - { - ULONG to_wait[2],actual[2]; - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); - actual[1]=0; - to_wait[1]+=ms*1000/MY_CLOCKS_PER_SEC; - - while(actual[1]tr_node.io_Device; + + TimerReq[0] = TimerIO_2; + TimerReq[1] = TimerIO_2; + /* Close the timer device */ + //CloseDevice((struct IORequest *) TimerIO_2); + } else + D(bug("Error: Could not open timer device\n")); + + /* Delete the IORequest structure */ + //DeleteIORequest(TimerIO_2); + } else + D(bug("Error: Could not create I/O structure\n")); + + /* Delete the port */ + //DeleteMsgPort(TimerMP_2); } } -void PPC_TimerInit(void) -{ - struct TagItem tags[]= - { - PPCTIMERTAG_CPU,TRUE, - TAG_DONE,0 - }; - - - if(MyTimer=PPCCreateTimerObject(tags)) - { - ULONG result[2]; - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_TICKSPERSEC,result); - D(bug("Timer inizializzato, TPS: %lu - %lu\n",result[0],result[1])); -// PPCAsr64p(result,10); - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); - result[0]>>=10; - - D(bug("Shiftato TPS: %lu - %lu\n",result[0],result[1])); - MY_CLOCKS_PER_SEC=result[1]; - - PPCGetTimerObject(MyTimer,PPCTIMERTAG_CURRENTTICKS,result); - - D(bug("Current ticks: %lu - %lu\n",result[0],result[1])); - result[1]>>=10; - result[1]|=((result[0]&0x3ff)<<22); - result[0]>>=10; -// PPCAsr64p(result,10); - D(bug("Shiftato: %lu - %lu\n",result[0],result[1])); - } - else - { - D(bug("Errore nell'inizializzazione del timer!\n")); - } +void SDL_StartTicks(void) { + if ( !TimerBase )gettimerbase(); + GetSysTime(&basetime); } +//#define ECLOCK + +Uint32 SDL_GetTicks(void) { + struct EClockVal time1; + long efreq; + long long eval; + struct timeval tv; + Uint32 ticks; + + if ( !TimerBase )gettimerbase(); + +#ifndef ECLOCK + GetSysTime(&tv); + if ( basetime.tv_micro > tv.tv_micro ) { + tv.tv_secs--; + + tv.tv_micro += 1000000; + } + + ticks = ((tv.tv_secs - basetime.tv_secs) * 1000) + ((tv.tv_micro - basetime.tv_micro) / 1000); +#else + efreq = ReadEClock(&time1); + eval = time1.ev_lo; + eval +=(time1.ev_hi << 32); + ticks = eval /(efreq/1000); #endif + return ticks; +} + +void SDL_Delay(Uint32 ms) { + struct timeval tv; + + if ( ms == 0 ) return; + + if ( ms & 0xff000000 ) return; //time to large + tv.tv_secs = ms / 1000; + tv.tv_micro = (ms % 1000) * 1000; + + time_delay(&tv, UNIT_MICROHZ); +} + #include "SDL_thread.h" /* Data to handle a single periodic alarm */ static int timer_alive = 0; static SDL_Thread *timer_thread = NULL; +struct Library *TimerBase; -static int RunTimer(void *unused) -{ +int RunTimer(void *unused) { + struct timeval tv; + struct timerequest *tr; + unsigned long threadid; D(bug("SYSTimer: Entering RunTimer loop...")); + threadid = SDL_ThreadID(); + SetTaskPri(threadid, 4); + + /* get a pointer to an initialized timer request block */ + tr = create_timer(UNIT_MICROHZ); + + /* any nonzero return says timedelay routine didn't work. */ + if ( tr == NULL ) + return (-1L); - if(GfxBase==NULL) - GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",37); + /* deallocate temporary structures */ while ( timer_alive ) { - if ( SDL_timer_running ) { - SDL_ThreadedTimerCheck(); - } - if(GfxBase) - WaitTOF(); // Check the timer every fifth of seconds. Was SDL_Delay(1)->BusyWait! - else - Delay(1); + ULONG running = SDL_timer_running; + + tv.tv_secs = 0; + tv.tv_micro = 4000; + + wait_for_timer(tr, &tv); + //time_delay(&tv, UNIT_MICROHZ ); + + if ( running ) SDL_ThreadedTimerCheck(); + } + D(bug("SYSTimer: EXITING RunTimer loop...")); - return(0); + + delete_timer(tr); + return 0; } /* This is only called if the event thread is not running */ -int SDL_SYS_TimerInit(void) -{ +int SDL_SYS_TimerInit(void) { D(bug("Creating thread for the timer (NOITIMER)...\n")); timer_alive = 1; timer_thread = SDL_CreateThread(RunTimer, NULL); - if ( timer_thread == NULL ) - { - D(bug("Creazione del thread fallita...\n")); + if ( timer_thread == NULL ) { + D(bug("Thread creation failed...\n")); - return(-1); + return (-1); } - return(SDL_SetTimerThreaded(1)); + + return (SDL_SetTimerThreaded(1)); } -void SDL_SYS_TimerQuit(void) -{ +void SDL_SYS_TimerQuit(void) { timer_alive = 0; if ( timer_thread ) { SDL_WaitThread(timer_thread, NULL); timer_thread = NULL; } + + D(bug("SYS_TimerQuit\n")); } -int SDL_SYS_StartTimer(void) +void amiga_quit_timer(void) //called at end of sdl program from sdl.c { + if ( TimerIO_2 ) { + CloseDevice((struct IORequest *)TimerIO_2); + DeleteIORequest(TimerIO_2); + DeleteMsgPort(TimerMP_2); + TimerIO_2 = 0; + } +} + +int SDL_SYS_StartTimer(void) { SDL_SetError("Internal logic error: AmigaOS uses threaded timer"); - return(-1); + return -1; } -void SDL_SYS_StopTimer(void) -{ +void SDL_SYS_StopTimer(void) { return; } diff --git a/src/timer/dummy/SDL_systimer.c b/src/timer/dummy/SDL_systimer.c index cc266bc9a..1e74b0872 100644 --- a/src/timer/dummy/SDL_systimer.c +++ b/src/timer/dummy/SDL_systimer.c @@ -24,7 +24,7 @@ #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED) #include "SDL_timer.h" -#include "../SDL_timer_c.h" +#include "SDL_timer_c.h" void SDL_StartTicks(void) { diff --git a/src/timer/mint/SDL_vbltimer.S b/src/timer/mint/SDL_vbltimer.S index 7837afce0..cac9fb338 100644 --- a/src/timer/mint/SDL_vbltimer.S +++ b/src/timer/mint/SDL_vbltimer.S @@ -119,7 +119,7 @@ bcl_search_place: /* Then install ourselves */ place_found: movel a0,(a1) - moveq #0,d0 + moveq #0,d0 exit_vbl_queue: /* Restart interrupts */ @@ -133,7 +133,7 @@ _SDL_AtariVblUninstall: movel sp@(4),d0 cmpl my_vector,d0 bnes badvector - + movel #_my_vbl,d0 /* Stop interrupts */ diff --git a/src/video/SDL_RLEaccel.c b/src/video/SDL_RLEaccel.c index d4b191c27..535c120fc 100644 --- a/src/video/SDL_RLEaccel.c +++ b/src/video/SDL_RLEaccel.c @@ -1645,8 +1645,9 @@ static int RLEColorkeySurface(SDL_Surface *surface) Uint8 *rlebuf, *dst; int maxn; int y; - Uint8 *srcbuf, *lastline; + Uint8 *srcbuf, *curbuf, *lastline; int maxsize = 0; + int skip, run; int bpp = surface->format->BytesPerPixel; getpix_func getpix; Uint32 ckey, rgbmask; @@ -1680,7 +1681,9 @@ static int RLEColorkeySurface(SDL_Surface *surface) /* Set up the conversion */ srcbuf = (Uint8 *)surface->pixels; + curbuf = srcbuf; maxn = bpp == 4 ? 65535 : 255; + skip = run = 0; dst = rlebuf; rgbmask = ~surface->format->Amask; ckey = surface->format->colorkey & rgbmask; diff --git a/src/video/SDL_blit.c b/src/video/SDL_blit.c index e3f194aee..f814866e3 100644 --- a/src/video/SDL_blit.c +++ b/src/video/SDL_blit.c @@ -39,6 +39,10 @@ #include "mmx.h" #endif +#if defined(APOLLO_BLIT) +#include "blitapollo.h" +#endif + /* The general purpose software blit routine */ static int SDL_SoftBlit(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) @@ -154,6 +158,12 @@ static __inline__ void SDL_memcpySSE(Uint8 *to, const Uint8 *from, int len) static void SDL_BlitCopy(SDL_BlitInfo *info) { +#if defined(APOLLO_BLIT) + ApolloCopyRect( info->s_pixels, info->d_pixels, + info->s_skip, info->d_skip, + info->d_width*info->dst->BytesPerPixel, + info->d_height ); +#else Uint8 *src, *dst; int w, h; int srcskip, dstskip; @@ -198,6 +208,7 @@ static void SDL_BlitCopy(SDL_BlitInfo *info) src += srcskip; dst += dstskip; } +#endif } static void SDL_BlitCopyOverlap(SDL_BlitInfo *info) diff --git a/src/video/SDL_blit_A.c b/src/video/SDL_blit_A.c index cfbd57907..ff4f6deda 100644 --- a/src/video/SDL_blit_A.c +++ b/src/video/SDL_blit_A.c @@ -2785,6 +2785,10 @@ SDL_loblit SDL_CalculateAlphaBlit(SDL_Surface *surface, int blit_index) SDL_PixelFormat *sf = surface->format; SDL_PixelFormat *df = surface->map->dst->format; +#if defined(APOLLO_BLITDBG) + printf("SDL_CalculateAlphaBlit amask %d sBPP %d dBPP %d\n",sf->Amask,sf->BytesPerPixel,df->BytesPerPixel); +#endif + if(sf->Amask == 0) { if((surface->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { if(df->BytesPerPixel == 1) diff --git a/src/video/SDL_blit_N.c b/src/video/SDL_blit_N.c index b46daa334..19e66feb3 100644 --- a/src/video/SDL_blit_N.c +++ b/src/video/SDL_blit_N.c @@ -35,6 +35,11 @@ enum blit_features { BLIT_FEATURE_HAS_ARM_SIMD = 8 }; +#if defined(APOLLO_BLIT) +#include "blitapollo.h" +#include "colorkeyapollo.h" +#endif + #if SDL_ALTIVEC_BLITTERS #if __MWERKS__ #pragma altivec_model on @@ -2267,6 +2272,17 @@ static void BlitNto1Key(SDL_BlitInfo *info) static void Blit2to2Key(SDL_BlitInfo *info) { +#if defined(APOLLO_BLIT) + ApolloKeyRGB565toRGB565( // works with 555, too (unless 1 bit is defined as alpha, ofc) + (Uint8 *)info->s_pixels, + (Uint8 *)info->d_pixels, + info->s_skip, + info->d_skip, + info->d_width, + info->d_height, + info->src->colorkey + ); +#else int width = info->d_width; int height = info->d_height; Uint16 *srcp = (Uint16 *)info->s_pixels; @@ -2294,6 +2310,7 @@ static void Blit2to2Key(SDL_BlitInfo *info) srcp += srcskip; dstp += dstskip; } +#endif } static void BlitNtoNKey(SDL_BlitInfo *info) @@ -2379,6 +2396,35 @@ static void BlitNtoNKeyCopyAlpha(SDL_BlitInfo *info) } } +#if defined(APOLLO_BLIT) + +#define APOLLOCONVERT( __a__ ) \ +static void Convert##__a__ (SDL_BlitInfo *info);\ +static void Convert##__a__ (SDL_BlitInfo *info) \ +{\ + __a__( \ + (Uint8 *)info->s_pixels,\ + (Uint8 *)info->d_pixels,\ + info->s_skip,\ + info->d_skip,\ + info->d_width,\ + info->d_height\ + );\ +} + +APOLLOCONVERT( ApolloBGRAtoRGB565 ) +APOLLOCONVERT( ApolloARGBtoRGB565 ) +APOLLOCONVERT( ApolloRGBtoRGB565 ) +APOLLOCONVERT( ApolloBGRtoRGB565 ) + +APOLLOCONVERT( ApolloARGBtoRGB24 ) +APOLLOCONVERT( ApolloBGRAtoRGB24 ) +APOLLOCONVERT( ApolloBGRtoRGB24 ) + +APOLLOCONVERT( ApolloARGBtoBGRA ) + +#endif + /* Normal N to N optimized blitters */ struct blit_table { Uint32 srcR, srcG, srcB; @@ -2425,6 +2471,14 @@ static const struct blit_table normal_blit_2[] = { { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 } }; static const struct blit_table normal_blit_3[] = { +#if defined(APOLLO_BLIT) + { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F, + 0, (void*)(1), ConvertApolloRGBtoRGB565, NO_ALPHA }, + { 0x000000FF,0x0000FF00,0x00FF0000, 2, 0x0000F800,0x000007E0,0x0000001F, + 0, (void*)(1), ConvertApolloBGRtoRGB565, NO_ALPHA }, + { 0x000000FF,0x0000FF00,0x00FF0000, 3, 0x00FF0000,0x0000FF00,0x000000FF, + 0, (void*)(1), ConvertApolloBGRtoRGB24, NO_ALPHA }, +#endif /* Default for 24-bit RGB source, never optimized */ { 0,0,0, 0, 0,0,0, 0, NULL, BlitNtoN, 0 } }; @@ -2473,6 +2527,21 @@ static const struct blit_table normal_blit_4[] = { #if SDL_ARM_SIMD_BLITTERS { 0x000000FF,0x0000FF00,0x00FF0000, 4, 0x00FF0000,0x0000FF00,0x000000FF, BLIT_FEATURE_HAS_ARM_SIMD, NULL, Blit_BGR888_RGB888ARMSIMD, NO_ALPHA | COPY_ALPHA }, +#endif +#if defined(APOLLO_BLIT) + { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F, + 0, (void*)(1), ConvertApolloARGBtoRGB565, NO_ALPHA }, + { 0x0000FF00,0x00FF0000,0xFF000000, 2, 0x0000001F,0x000007E0,0x0000F800, + 0, (void*)(1), ConvertApolloBGRAtoRGB565, NO_ALPHA }, + { 0x00FF0000,0x0000FF00,0x000000FF, 3, 0x00FF0000,0x0000FF00,0x000000FF, + 0, (void*)(1), ConvertApolloARGBtoRGB24, NO_ALPHA }, + { 0x0000FF00,0x00FF0000,0xFF000000, 3, 0x00FF0000,0x0000FF00,0x000000FF, + 0, (void*)(1), ConvertApolloBGRAtoRGB24, NO_ALPHA }, + + { 0x0000FF00,0x00FF0000,0xFF000000, 4, 0x00FF0000,0x0000FF00,0x000000FF, + 0, (void*)(1), ConvertApolloARGBtoBGRA, NO_ALPHA }, + { 0x00FF0000,0x0000FF00,0x000000FF, 4, 0x0000FF00,0x00FF0000,0xFF000000, + 0, (void*)(1), ConvertApolloARGBtoBGRA, NO_ALPHA }, #endif { 0x00FF0000,0x0000FF00,0x000000FF, 2, 0x0000F800,0x000007E0,0x0000001F, 0, NULL, Blit_RGB888_RGB565, NO_ALPHA }, @@ -2503,6 +2572,17 @@ SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index) srcfmt = surface->format; dstfmt = surface->map->dst->format; +#if defined(APOLLO_BLITDBG) + printf("SDL_CalculateBlitN from BPP %d to BPP %d blit_index %d AMask %x ",srcfmt->BytesPerPixel,dstfmt->BytesPerPixel,blit_index,srcfmt->Amask); + printf("Src %x %x %x Dst %x %x %x\n", + srcfmt->Rmask, + srcfmt->Gmask, + srcfmt->Bmask, + dstfmt->Rmask, + dstfmt->Gmask, + dstfmt->Bmask ); +#endif + if ( blit_index & 2 ) { /* alpha or alpha+colorkey */ return SDL_CalculateAlphaBlit(surface, blit_index); @@ -2600,6 +2680,26 @@ SDL_loblit SDL_CalculateBlitN(SDL_Surface *surface, int blit_index) } } +#if defined(APOLLO_BLITDBG) + if( sdata->aux_data == (void*)(1) ) + { + printf("AMMX blit "); + } + else + { + printf("C blit "); + } + printf("Src %x %x %x @BPP%d Dst %x %x %x @BPP %d\n", + srcfmt->Rmask, + srcfmt->Gmask, + srcfmt->Bmask, + srcfmt->BytesPerPixel, + dstfmt->Rmask, + dstfmt->Gmask, + dstfmt->Bmask, + dstfmt->BytesPerPixel + ); +#endif #ifdef DEBUG_ASM #if SDL_HERMES_BLITTERS if ( blitfun == ConvertMMX ) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index 73f05034d..a4925645b 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -57,6 +57,7 @@ SDL_Surface * SDL_CreateRGBSurface (Uint32 flags, } else { screen = NULL; } + if ( screen && ((screen->flags&SDL_HWSURFACE) == SDL_HWSURFACE) ) { if ( (flags&(SDL_SRCCOLORKEY|SDL_SRCALPHA)) != 0 ) { flags |= SDL_HWSURFACE; @@ -394,13 +395,26 @@ void SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect) *rect = surface->clip_rect; } } + +/* see SDL_video.h */ +void SDLA_SetQuickLazyBlit(SDL_Surface *surface, Uint32 yesno ) +{ + if( surface ) + { + if( yesno ) + surface->flags |= SDLA_QUICKLAZY; + else + surface->flags &= ~SDLA_QUICKLAZY; + } +} + /* * Set up a blit between two surfaces -- split into three parts: - * The upper part, SDL_UpperBlit(), performs clipping and rectangle + * The upper part, SDL_UpperBlit(), performs clipping and rectangle * verification. The lower part is a pointer to a low level * accelerated blitting function. * - * These parts are separated out and each used internally by this + * These parts are separated out and each used internally by this * library in the optimimum places. They are exported so that if * you know exactly what you are doing, you can optimize your code * by calling the one(s) you need. @@ -411,15 +425,35 @@ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_blit do_blit; SDL_Rect hw_srcrect; SDL_Rect hw_dstrect; +#ifdef __AMIGA__ + int skipflag = 0; - /* 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); + /* applies to software blitting only */ + if( src->flags & SDLA_QUICKLAZY ) + { + if( src->map->sw_blit ) + { + if( src->map->sw_data->blit ) + { + skipflag = 1; + } } } + if( !skipflag ) + { +#endif + /* 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); + } + } +#ifdef __AMIGA__ + } +#endif + /* Figure out which blitter to use */ if ( (src->flags & SDL_HWACCEL) == SDL_HWACCEL ) { if ( src == SDL_VideoSurface ) { @@ -447,7 +481,9 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, { SDL_Rect fulldst; int srcx, srcy, w, h; - +#ifdef __AMIGA__ + extern int toggle,skipframe; +#endif /* Make sure the surfaces aren't locked */ if ( ! src || ! dst ) { SDL_SetError("SDL_UpperBlit: passed a NULL surface"); @@ -467,7 +503,7 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, /* clip the source rectangle to the source surface */ if(srcrect) { int maxw, maxh; - + srcx = srcrect->x; w = srcrect->w; if(srcx < 0) { @@ -489,7 +525,7 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, maxh = src->h - srcy; if(maxh < h) h = maxh; - + } else { srcx = srcy = 0; w = src->w; @@ -548,7 +584,7 @@ static int SDL_FillRect4(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) return -1; } -/* +/* * This function performs a fast fill of the given rectangle with 'color' */ int SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) @@ -828,7 +864,7 @@ void SDL_UnlockSurface (SDL_Surface *surface) } } -/* +/* * Convert a surface into the specified pixel format. */ SDL_Surface * SDL_ConvertSurface (SDL_Surface *surface, diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 9f44b3fd2..2c93bc89e 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -31,6 +31,24 @@ #include "../events/SDL_sysevents.h" #include "../events/SDL_events_c.h" +#ifdef __AMIGA__ +#include +#include + +#include "../mydebug.h" + +extern struct ExecBase *SysBase; +short ac68080 = 0; +void *old_buffer; + +static int is_vampire() { + if ( SysBase->AttnFlags & (1 << 10)) { + printf("Vampire accelerator detected, using SAGA Direct Draw\n"); + return 1; + } else + return 0; +} +#endif /* Available video drivers */ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_QUARTZ @@ -143,9 +161,10 @@ SDL_VideoDevice *current_video = NULL; /* Various local functions */ int SDL_VideoInit(const char *driver_name, Uint32 flags); void SDL_VideoQuit(void); -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect* rects); +void SDL_GL_UpdateRectsLock(SDL_VideoDevice *this, int numrects, SDL_Rect *rects); static SDL_GrabMode SDL_WM_GrabInputOff(void); + #if SDL_VIDEO_OPENGL static int lock_count = 0; #endif @@ -154,14 +173,15 @@ static int lock_count = 0; /* * Initialize the video and event subsystems -- determine native pixel format */ -int SDL_VideoInit (const char *driver_name, Uint32 flags) -{ +int SDL_VideoInit(const char *driver_name, Uint32 flags) { SDL_VideoDevice *video; int index; int i; SDL_PixelFormat vformat; Uint32 video_flags; - +#ifdef __AMIGA__ + ac68080 = is_vampire(); +#endif /* Toggle the event thread flags, based on OS requirements */ #if defined(MUST_THREAD_EVENTS) flags |= SDL_INIT_EVENTTHREAD; @@ -181,13 +201,13 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) index = 0; video = NULL; if ( driver_name != NULL ) { -#if 0 /* This will be replaced with a better driver selection API */ +#if 0 /* This will be replaced with a better driver selection API */ if ( SDL_strrchr(driver_name, ':') != NULL ) { index = atoi(SDL_strrchr(driver_name, ':')+1); } #endif - for ( i=0; bootstrap[i]; ++i ) { - if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0) { + for ( i = 0; bootstrap[i]; ++i ) { + if ( SDL_strcasecmp(bootstrap[i]->name, driver_name) == 0 ) { if ( bootstrap[i]->available() ) { video = bootstrap[i]->create(index); break; @@ -195,8 +215,8 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) } } } else { - for ( i=0; bootstrap[i]; ++i ) { - if ( bootstrap[i]->available() ) { + for ( i = 0; bootstrap[i]; ++i ) { + if ( bootstrap[i]->available()) { video = bootstrap[i]->create(index); if ( video != NULL ) { break; @@ -206,7 +226,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) } if ( video == NULL ) { SDL_SetError("No available video device"); - return(-1); + return (-1); } current_video = video; current_video->name = bootstrap[i]->name; @@ -219,11 +239,11 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video->gammacols = NULL; video->gamma = NULL; video->wm_title = NULL; - video->wm_icon = NULL; + video->wm_icon = NULL; video->offset_x = 0; video->offset_y = 0; SDL_memset(&video->info, 0, (sizeof video->info)); - + video->displayformatalphapixel = NULL; /* Set some very sane GL defaults */ @@ -246,24 +266,24 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) video->gl_config.multisamplesamples = 0; video->gl_config.accelerated = -1; /* not known, don't set */ video->gl_config.swap_control = -1; /* not known, don't set */ - + /* Initialize the video subsystem */ SDL_memset(&vformat, 0, sizeof(vformat)); if ( video->VideoInit(video, &vformat) < 0 ) { SDL_VideoQuit(); - return(-1); + return (-1); } /* Create a zero sized video surface of the appropriate format */ video_flags = SDL_SWSURFACE; SDL_VideoSurface = SDL_CreateRGBSurface(video_flags, 0, 0, - vformat.BitsPerPixel, - vformat.Rmask, vformat.Gmask, vformat.Bmask, 0); + vformat.BitsPerPixel, + vformat.Rmask, vformat.Gmask, vformat.Bmask, 0); if ( SDL_VideoSurface == NULL ) { SDL_VideoQuit(); - return(-1); + return (-1); } - SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */ + SDL_PublicSurface = NULL; /* Until SDL_SetVideoMode() */ #if 0 /* Don't change the current palette - may be used by other programs. * The application can't do anything with the display surface until @@ -282,49 +302,46 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags) /* Start the event loop */ if ( SDL_StartEventLoop(flags) < 0 ) { SDL_VideoQuit(); - return(-1); + return (-1); } SDL_CursorInit(flags & SDL_INIT_EVENTTHREAD); /* We're ready to go! */ - return(0); + return (0); } -char *SDL_VideoDriverName(char *namebuf, int maxlen) -{ +char *SDL_VideoDriverName(char *namebuf, int maxlen) { if ( current_video != NULL ) { SDL_strlcpy(namebuf, current_video->name, maxlen); - return(namebuf); + return (namebuf); } - return(NULL); + return (NULL); } /* * Get the current display surface */ -SDL_Surface *SDL_GetVideoSurface(void) -{ +SDL_Surface *SDL_GetVideoSurface(void) { SDL_Surface *visible; visible = NULL; if ( current_video ) { visible = current_video->visible; } - return(visible); + return (visible); } /* * Get the current information about the video hardware */ -const SDL_VideoInfo *SDL_GetVideoInfo(void) -{ +const SDL_VideoInfo *SDL_GetVideoInfo(void) { const SDL_VideoInfo *info; info = NULL; if ( current_video ) { info = ¤t_video->info; } - return(info); + return (info); } /* @@ -334,20 +351,19 @@ const SDL_VideoInfo *SDL_GetVideoInfo(void) * if any dimension is okay for the given format. If 'format' is NULL, * the mode list will be for the format given by SDL_GetVideoInfo()->vfmt */ -SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags) -{ +SDL_Rect **SDL_ListModes(SDL_PixelFormat *format, Uint32 flags) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; SDL_Rect **modes; modes = NULL; - if ( SDL_VideoSurface ) { + if ( SDL_VideoSurface) { if ( format == NULL ) { format = SDL_VideoSurface->format; } modes = video->ListModes(this, format, flags); } - return(modes); + return (modes); } /* @@ -359,14 +375,14 @@ SDL_Rect ** SDL_ListModes (SDL_PixelFormat *format, Uint32 flags) * but will emulate the requested bits-per-pixel with a shadow surface. */ static Uint8 SDL_closest_depths[4][8] = { - /* 8 bit closest depth ordering */ - { 0, 8, 16, 15, 32, 24, 0, 0 }, - /* 15,16 bit closest depth ordering */ - { 0, 16, 15, 32, 24, 8, 0, 0 }, - /* 24 bit closest depth ordering */ - { 0, 24, 32, 16, 15, 8, 0, 0 }, - /* 32 bit closest depth ordering */ - { 0, 32, 16, 15, 24, 8, 0, 0 } + /* 8 bit closest depth ordering */ + { 0, 8, 16, 15, 32, 24, 0, 0 }, + /* 15,16 bit closest depth ordering */ + { 0, 16, 15, 32, 24, 8, 0, 0 }, + /* 24 bit closest depth ordering */ + { 0, 24, 32, 16, 15, 8, 0, 0 }, + /* 32 bit closest depth ordering */ + { 0, 32, 16, 15, 24, 8, 0, 0 } }; @@ -376,8 +392,7 @@ static Uint8 SDL_closest_depths[4][8] = { #define NEGATIVE_ONE -1 #endif -int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) -{ +int SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) { int table, b, i; int supported; SDL_PixelFormat format; @@ -385,16 +400,16 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) /* Currently 1 and 4 bpp are not supported */ if ( bpp < 8 || bpp > 32 ) { - return(0); + return (0); } - if ( (width <= 0) || (height <= 0) ) { - return(0); + if ((width <= 0) || (height <= 0)) { + return (0); } /* Search through the list valid of modes */ SDL_memset(&format, 0, sizeof(format)); supported = 0; - table = ((bpp+7)/8)-1; + table = ((bpp + 7) / 8) - 1; SDL_closest_depths[table][0] = bpp; SDL_closest_depths[table][7] = 0; for ( b = 0; !supported && SDL_closest_depths[table][b]; ++b ) { @@ -403,40 +418,38 @@ int SDL_VideoModeOK (int width, int height, int bpp, Uint32 flags) if ( sizes == (SDL_Rect **)0 ) { /* No sizes supported at this bit-depth */ continue; - } else - if (sizes == (SDL_Rect **)NEGATIVE_ONE) { + } else if ( sizes == (SDL_Rect * *) NEGATIVE_ONE ) { /* Any size supported at this bit-depth */ supported = 1; continue; - } else if (current_video->handles_any_size) { + } else if ( current_video->handles_any_size ) { /* Driver can center a smaller surface to simulate fullscreen */ - for ( i=0; sizes[i]; ++i ) { + for ( i = 0; sizes[i]; ++i ) { if ((sizes[i]->w >= width) && (sizes[i]->h >= height)) { supported = 1; /* this mode can fit the centered window. */ break; } } } else - for ( i=0; sizes[i]; ++i ) { - if ((sizes[i]->w == width) && (sizes[i]->h == height)) { - supported = 1; - break; + for ( i = 0; sizes[i]; ++i ) { + if ((sizes[i]->w == width) && (sizes[i]->h == height)) { + supported = 1; + break; + } } - } } if ( supported ) { --b; - return(SDL_closest_depths[table][b]); + return (SDL_closest_depths[table][b]); } else { - return(0); + 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) -{ +static int SDL_GetVideoMode(int *w, int *h, int *BitsPerPixel, Uint32 flags) { int table, b, i; int supported; int native_bpp; @@ -446,27 +459,29 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) /* Check parameters */ if ( *BitsPerPixel < 8 || *BitsPerPixel > 32 ) { SDL_SetError("Invalid bits per pixel (range is {8...32})"); - return(0); + return (0); } if ((*w <= 0) || (*h <= 0)) { SDL_SetError("Invalid width or height"); - return(0); + return (0); } /* Try the original video mode, get the closest depth */ native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags); + D(bug("screen depth %ld\n", native_bpp)); + if ( native_bpp == *BitsPerPixel ) { - return(1); + return (1); } if ( native_bpp > 0 ) { *BitsPerPixel = native_bpp; - return(1); + return (1); } /* No exact size match at any depth, look for closest match */ SDL_memset(&format, 0, sizeof(format)); supported = 0; - table = ((*BitsPerPixel+7)/8)-1; + 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 ) { @@ -478,53 +493,55 @@ static int SDL_GetVideoMode (int *w, int *h, int *BitsPerPixel, Uint32 flags) /* No sizes supported at this bit-depth */ continue; } - best=0; - for ( i=0; sizes[i]; ++i ) { + best = 0; + for ( i = 0; sizes[i]; ++i ) { /* Mode with both dimensions bigger or equal than asked ? */ if ((sizes[i]->w >= *w) && (sizes[i]->h >= *h)) { /* Mode with any dimension smaller or equal than current best ? */ if ((sizes[i]->w <= sizes[best]->w) || (sizes[i]->h <= sizes[best]->h)) { /* Now choose the mode that has less pixels */ if ((sizes[i]->w * sizes[i]->h) <= (sizes[best]->w * sizes[best]->h)) { - best=i; + best = i; supported = 1; } } } } - if (supported) { - *w=sizes[best]->w; - *h=sizes[best]->h; + if ( supported ) { + *w = sizes[best]->w; + *h = sizes[best]->h; *BitsPerPixel = SDL_closest_depths[table][b]; } } - if ( ! supported ) { + if ( !supported ) { SDL_SetError("No video mode large enough for %dx%d", *w, *h); } - return(supported); + return (supported); } /* This should probably go somewhere else -- like SDL_surface.c */ -static void SDL_ClearSurface(SDL_Surface *surface) -{ +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)) { + if ((surface->flags & SDL_HWSURFACE) && (surface->flags & SDL_DOUBLEBUF)) { SDL_Flip(surface); SDL_FillRect(surface, NULL, black); } +#ifndef __AMIGA__ if (surface->flags&SDL_FULLSCREEN) { +#endif SDL_Flip(surface); +#ifndef __AMIGA__ } +#endif } /* * Create a shadow surface suitable for fooling the app. :-) */ -static void SDL_CreateShadowSurface(int depth) -{ +static void SDL_CreateShadowSurface(int depth) { Uint32 Rmask, Gmask, Bmask; /* Allocate the shadow surface */ @@ -535,9 +552,7 @@ static void SDL_CreateShadowSurface(int depth) } else { Rmask = Gmask = Bmask = 0; } - SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, - SDL_VideoSurface->w, SDL_VideoSurface->h, - depth, Rmask, Gmask, Bmask, 0); + SDL_ShadowSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, SDL_VideoSurface->w, SDL_VideoSurface->h, depth, Rmask, Gmask, Bmask, 0); if ( SDL_ShadowSurface == NULL ) { return; } @@ -546,37 +561,33 @@ static void SDL_CreateShadowSurface(int depth) if ( SDL_ShadowSurface->format->palette ) { SDL_ShadowSurface->flags |= SDL_HWPALETTE; if ( depth == (SDL_VideoSurface->format)->BitsPerPixel ) { - SDL_memcpy(SDL_ShadowSurface->format->palette->colors, - SDL_VideoSurface->format->palette->colors, - SDL_VideoSurface->format->palette->ncolors* - sizeof(SDL_Color)); + SDL_memcpy(SDL_ShadowSurface->format->palette->colors, SDL_VideoSurface->format->palette->colors, SDL_VideoSurface->format->palette->ncolors * sizeof(SDL_Color)); } else { - SDL_DitherColors( - SDL_ShadowSurface->format->palette->colors, depth); + SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, depth); } } /* If the video surface is resizable, the shadow should say so */ - if ( (SDL_VideoSurface->flags & SDL_RESIZABLE) == SDL_RESIZABLE ) { + 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 ) { + 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 ) { + 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 ) { + if ((SDL_VideoSurface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { SDL_ShadowSurface->flags |= SDL_DOUBLEBUF; } return; } #ifdef __QNXNTO__ - #include +#include #endif /* __QNXNTO__ */ #ifdef WIN32 @@ -586,8 +597,7 @@ static void SDL_CreateShadowSurface(int depth) /* * Set the requested video mode, allocating a shadow buffer if necessary. */ -SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) -{ +SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { SDL_VideoDevice *video, *this; SDL_Surface *prev_mode, *mode; int video_w; @@ -600,12 +610,19 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) sysevents_mouse_pressed = 0; #endif +#ifdef __AMIGA__ +#ifndef APOLLO_BLIT + flags &= ~SDL_DOUBLEBUF; +#endif + if (getenv("SDL_HWSURFACE"))flags |= SDL_HWSURFACE ; + if (getenv("SDL_SWSURFACE"))flags &= ~SDL_HWSURFACE ; +#endif /* 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); + if ( !current_video ) { + if ( SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0 ) { + return (NULL); } } this = video = current_video; @@ -627,8 +644,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) video_w = width; video_h = height; video_bpp = bpp; - if ( ! SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { - return(NULL); + if ( !SDL_GetVideoMode(&video_w, &video_h, &video_bpp, flags) ) { + return (NULL); } /* Check the requested flags */ @@ -647,10 +664,10 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) flags |= SDL_HWSURFACE; } - is_opengl = ( ( flags & SDL_OPENGL ) == SDL_OPENGL ); + is_opengl = ((flags & SDL_OPENGL) == SDL_OPENGL); if ( is_opengl ) { /* These flags are for 2D video modes only */ - flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF); + flags &= ~(SDL_HWSURFACE | SDL_DOUBLEBUF); } /* Reset the keyboard here so event callbacks can run */ @@ -674,7 +691,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) SDL_free(video->physpal); video->physpal = NULL; } - if( video->gammacols) { + if ( video->gammacols ) { SDL_free(video->gammacols); video->gammacols = NULL; } @@ -687,17 +704,18 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) 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 */ - /* But not on OS/2 */ + /* But not on OS/2 */ #ifndef __OS2__ - SDL_PrivateResize(mode->w, mode->h); + SDL_PrivateResize(mode->w, mode->h); #endif - /* Sam - If we asked for OpenGL mode, and didn't get it, fail */ - if ( is_opengl && !(mode->flags & SDL_OPENGL) ) { - mode = NULL; - SDL_SetError("OpenGL not available"); - } + /* Sam - If we asked for OpenGL mode, and didn't get it, fail */ + if ( is_opengl && !(mode->flags & SDL_OPENGL)) { + mode = NULL; + SDL_SetError("OpenGL not available"); + } } /* * rcg11292000 @@ -712,19 +730,20 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) */ SDL_VideoSurface = (mode != NULL) ? mode : prev_mode; + D(bug("surface depth of SDL_VideoSurface %ld \n", SDL_VideoSurface->format->BitsPerPixel)); + if ( (mode != NULL) && (!is_opengl) ) { /* Sanity check */ if ( (mode->w < width) || (mode->h < height) ) { SDL_SetError("Video mode smaller than requested"); - return(NULL); + return (NULL); } /* If we have a palettized surface, create a default palette */ if ( mode->format->palette ) { SDL_PixelFormat *vf = mode->format; SDL_DitherColors(vf->palette->colors, vf->BitsPerPixel); - video->SetColors(this, 0, vf->palette->ncolors, - vf->palette->colors); + video->SetColors(this, 0, vf->palette->ncolors, vf->palette->colors); } /* Clear the surface to black */ @@ -735,15 +754,14 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) SDL_ClearSurface(mode); /* Now adjust the offsets to match the desired mode */ - video->offset_x = (mode->w-width)/2; - video->offset_y = (mode->h-height)/2; - mode->offset = video->offset_y*mode->pitch + - video->offset_x*mode->format->BytesPerPixel; + video->offset_x = (mode->w - width) / 2; + video->offset_y = (mode->h - height) / 2; + mode->offset = video->offset_y * mode->pitch + video->offset_x * mode->format->BytesPerPixel; #ifdef DEBUG_VIDEO - fprintf(stderr, - "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n", - width, height, bpp, - mode->w, mode->h, mode->format->BitsPerPixel, mode->offset); + fprintf(stderr, + "Requested mode: %dx%dx%d, obtained mode %dx%dx%d (offset %d)\n", + width, height, bpp, + mode->w, mode->h, mode->format->BitsPerPixel, mode->offset); #endif mode->w = width; mode->h = height; @@ -754,11 +772,11 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) /* If we failed setting a video mode, return NULL... (Uh Oh!) */ if ( mode == NULL ) { - return(NULL); + return (NULL); } /* If there is no window manager, set the SDL_NOFRAME flag */ - if ( ! video->info.wm_available ) { + if ( !video->info.wm_available ) { mode->flags |= SDL_NOFRAME; } @@ -780,29 +798,28 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) #define __SDL_NOGETPROCADDR__ #endif #ifdef __SDL_NOGETPROCADDR__ - #define SDL_PROC(ret,func,params) video->func=func; +#define SDL_PROC(ret,func,params) video->func=func; #else - #define SDL_PROC(ret,func,params) \ - do { \ - video->func = SDL_GL_GetProcAddress(#func); \ - if ( ! video->func ) { \ - SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ - return(NULL); \ - } \ - } while ( 0 ); +#define SDL_PROC(ret,func,params) \ + do { \ + video->func = SDL_GL_GetProcAddress(#func); \ + if ( ! video->func ) { \ + SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ + return(NULL); \ + } \ + } while ( 0 ); #endif /* __SDL_NOGETPROCADDR__ */ #include "SDL_glfuncs.h" -#undef SDL_PROC +#undef SDL_PROC } #endif /* SDL_VIDEO_OPENGL */ /* If we're running OpenGL, make the context current */ - if ( (video->screen->flags & SDL_OPENGL) && - video->GL_MakeCurrent ) { + if ((video->screen->flags & SDL_OPENGL) && video->GL_MakeCurrent ) { if ( video->GL_MakeCurrent(this) < 0 ) { - return(NULL); + return (NULL); } } @@ -817,15 +834,13 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) extension, or implements the core OpenGL 1.2 API, it will support the GL_UNSIGNED_SHORT_5_6_5 texture format. */ - if ( (bpp == 16) && - (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || - (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f)) + if ( (bpp == 16) && (SDL_strstr((const char *)video->glGetString(GL_EXTENSIONS), "GL_EXT_packed_pixels") || (SDL_atof((const char *)video->glGetString(GL_VERSION)) >= 1.2f)) ) { video->is_32bit = 0; SDL_VideoSurface = SDL_CreateRGBSurface( - flags, - width, - height, + flags, + width, + height, 16, 31 << 11, 63 << 5, @@ -838,10 +853,10 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) { video->is_32bit = 1; SDL_VideoSurface = SDL_CreateRGBSurface( - flags, - width, - height, - 32, + flags, + width, + height, + 32, #if SDL_BYTEORDER == SDL_LIL_ENDIAN 0x000000FF, 0x0000FF00, @@ -885,7 +900,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) video->UpdateRects = SDL_GL_UpdateRectsLock; #else SDL_SetError("Somebody forgot to #define SDL_VIDEO_OPENGL"); - return(NULL); + return (NULL); #endif } @@ -896,68 +911,74 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags) 3. We need a software surface and got a hardware surface. */ if ( !(SDL_VideoSurface->flags & SDL_OPENGL) && - ( - ( !(flags&SDL_ANYFORMAT) && - (SDL_VideoSurface->format->BitsPerPixel != bpp)) || - ( (flags&SDL_HWPALETTE) && - !(SDL_VideoSurface->flags&SDL_HWPALETTE)) || - /* If the surface is in hardware, video writes are visible - as soon as they are performed, so we need to buffer them - */ - ( ((flags&SDL_HWSURFACE) == SDL_SWSURFACE) && - (SDL_VideoSurface->flags&SDL_HWSURFACE)) || - ( (flags&SDL_DOUBLEBUF) && - (SDL_VideoSurface->flags&SDL_HWSURFACE) && - !(SDL_VideoSurface->flags&SDL_DOUBLEBUF)) - ) ) { - SDL_CreateShadowSurface(bpp); + ( + (!(flags & SDL_ANYFORMAT) && + (SDL_VideoSurface->format->BitsPerPixel != bpp)) || + ((flags & SDL_HWPALETTE) && + !(SDL_VideoSurface->flags & SDL_HWPALETTE)) || + /* If the surface is in hardware, video writes are visible + as soon as they are performed, so we need to buffer them + */ + (((flags & SDL_HWSURFACE) == SDL_SWSURFACE) && + (SDL_VideoSurface->flags & SDL_HWSURFACE)) || + ((flags & SDL_DOUBLEBUF) && + (SDL_VideoSurface->flags & SDL_HWSURFACE) && + !(SDL_VideoSurface->flags & SDL_DOUBLEBUF)) + )) { + D(bug("Create Shadow surface\n")); + + SDL_CreateShadowSurface(bpp); //mode->format->BitsPerPixel); + if ( SDL_ShadowSurface == NULL ) { SDL_SetError("Couldn't create shadow surface"); - return(NULL); + return (NULL); } SDL_PublicSurface = SDL_ShadowSurface; } else { + D(bug("Using no Shadowsurface \n")); SDL_PublicSurface = SDL_VideoSurface; } video->info.vfmt = SDL_VideoSurface->format; video->info.current_w = SDL_VideoSurface->w; video->info.current_h = SDL_VideoSurface->h; +#ifdef __AMIGA__ + if (!(flags&SDL_FULLSCREEN)) + ac68080 = 0; +#endif /* We're done! */ return(SDL_PublicSurface); } -/* +/* * Convert a surface into the video pixel format. */ -SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface) -{ +SDL_Surface *SDL_DisplayFormat(SDL_Surface *surface) { Uint32 flags; - if ( ! SDL_PublicSurface ) { + if ( !SDL_PublicSurface) { SDL_SetError("No video mode has been set"); - return(NULL); + return (NULL); } /* Set the flags appropriate for copying to display surface */ - if (((SDL_PublicSurface->flags&SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw) + if (((SDL_PublicSurface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) && current_video->info.blit_hw ) flags = SDL_HWSURFACE; - else + else flags = SDL_SWSURFACE; #ifdef AUTORLE_DISPLAYFORMAT flags |= (surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA)); flags |= SDL_RLEACCELOK; #else - flags |= surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA|SDL_RLEACCELOK); + flags |= surface->flags & (SDL_SRCCOLORKEY | SDL_SRCALPHA | SDL_RLEACCELOK); #endif - return(SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags)); + return (SDL_ConvertSurface(surface, SDL_PublicSurface->format, flags)); } /* * Convert a surface into a format that's suitable for blitting to * the screen, but including an alpha channel. */ -SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) -{ +SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) { SDL_PixelFormat *vf; SDL_PixelFormat *format; SDL_Surface *converted; @@ -968,23 +989,23 @@ SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) Uint32 gmask = 0x0000ff00; Uint32 bmask = 0x000000ff; - if ( ! SDL_PublicSurface ) { + if ( !SDL_PublicSurface) { SDL_SetError("No video mode has been set"); - return(NULL); + return (NULL); } vf = SDL_PublicSurface->format; - switch(vf->BytesPerPixel) { - case 2: - /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. - For anything else (like ARGB4444) it doesn't matter - since we have no special code for it anyway */ - if ( (vf->Rmask == 0x1f) && - (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) { - rmask = 0xff; - bmask = 0xff0000; - } - break; + switch ( vf->BytesPerPixel ) { + case 2: + /* For XGY5[56]5, use, AXGY8888, where {X, Y} = {R, B}. + For anything else (like ARGB4444) it doesn't matter + since we have no special code for it anyway */ + if ((vf->Rmask == 0x1f) && + (vf->Bmask == 0xf800 || vf->Bmask == 0x7c00)) { + rmask = 0xff; + bmask = 0xff0000; + } + break; case 3: case 4: @@ -1001,24 +1022,23 @@ SDL_Surface *SDL_DisplayFormatAlpha(SDL_Surface *surface) } break; - default: - /* We have no other optimised formats right now. When/if a new - optimised alpha format is written, add the converter here */ - break; + default: + /* We have no other optimised formats right now. When/if a new + optimised alpha format is written, add the converter here */ + break; } format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); flags = SDL_PublicSurface->flags & SDL_HWSURFACE; flags |= surface->flags & (SDL_SRCALPHA | SDL_RLEACCELOK); converted = SDL_ConvertSurface(surface, format, flags); SDL_FreeFormat(format); - return(converted); + return (converted); } /* * Update a specific portion of the physical screen */ -void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) -{ +void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) { if ( screen ) { SDL_Rect rect; @@ -1027,9 +1047,9 @@ void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) w = screen->w; if ( h == 0 ) h = screen->h; - if ( (int)(x+w) > screen->w ) + if ((int)(x + w) > screen->w ) return; - if ( (int)(y+h) > screen->h ) + if ((int)(y + h) > screen->h ) return; /* Fill the rectangle */ @@ -1040,21 +1060,21 @@ void SDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) SDL_UpdateRects(screen, 1, &rect); } } -void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects) -{ + +void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { int i; SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; - if ( (screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) { + if ((screen->flags & (SDL_OPENGL | SDL_OPENGLBLIT)) == SDL_OPENGL ) { SDL_SetError("OpenGL active, use SDL_GL_SwapBuffers()"); return; } - if ( screen == SDL_ShadowSurface ) { + if ( screen == SDL_ShadowSurface) { /* Blit the shadow surface using saved mapping */ SDL_Palette *pal = screen->format->palette; SDL_Color *saved_colors = NULL; - if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE) ) { + if ( pal && !(SDL_VideoSurface->flags & SDL_HWPALETTE)) { /* simulated 8bpp, use correct physical palette */ saved_colors = pal->colors; if ( video->gammacols ) { @@ -1065,19 +1085,19 @@ void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects) pal->colors = video->physpal->colors; } } - if ( SHOULD_DRAWCURSOR(SDL_cursorstate) ) { + if ( SHOULD_DRAWCURSOR(SDL_cursorstate)) { SDL_LockCursor(); SDL_DrawCursor(SDL_ShadowSurface); - for ( i=0; ioffset ) { - for ( i=0; ioffset_x; rects[i].y += video->offset_y; } video->UpdateRects(this, numrects, rects); - for ( i=0; ioffset_x; rects[i].y -= video->offset_y; } @@ -1108,8 +1128,24 @@ void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects) /* * Performs hardware double buffering, if possible, or a full update if not. */ +#if defined(__AMIGA__) +int SDL_Flip_m68k(SDL_Surface *screen) +#else int SDL_Flip(SDL_Surface *screen) +#endif { +#ifdef __AMIGA__ + extern int skipframe,toggle; + + if (skipframe) { + if (toggle < skipframe) { + toggle++; + return 0; + } + toggle = 0; + } +#endif + SDL_VideoDevice *video = current_video; /* Copy the shadow surface to the video surface */ if ( screen == SDL_ShadowSurface ) { @@ -1140,34 +1176,44 @@ int SDL_Flip(SDL_Surface *screen) SDL_EraseCursor(SDL_ShadowSurface); SDL_UnlockCursor(); } else { - SDL_LowerBlit(SDL_ShadowSurface, &rect, - SDL_VideoSurface, &rect); + SDL_LowerBlit(SDL_ShadowSurface, &rect, SDL_VideoSurface, &rect); } if ( saved_colors ) { pal->colors = saved_colors; } /* Fall through to video surface update */ +#ifndef __AMIGA__ screen = SDL_VideoSurface; +#endif } - if ( (screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { - SDL_VideoDevice *this = current_video; - return(video->FlipHWSurface(this, SDL_VideoSurface)); + if ((screen->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF ) { + SDL_VideoDevice *this = current_video; + return (video->FlipHWSurface(this, SDL_VideoSurface)); } else { SDL_UpdateRect(screen, 0, 0, 0, 0); } return(0); } -static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, - int firstcolor, int ncolors) -{ +#ifdef __AMIGA__ +int SDL_Flip(SDL_Surface *screen) { + if ( ac68080 ) { + old_buffer = screen->pixels; + screen->pixels = (void *)(~31 & (31 + (Uint32)old_buffer)); + *(volatile Uint32 *)0xDFF1EC = (Uint32)screen->pixels; + return (0); + } else + return SDL_Flip_m68k(screen); +} +#endif + +static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { SDL_Palette *pal = screen->format->palette; SDL_Palette *vidpal; if ( colors != (pal->colors + firstcolor) ) { - SDL_memcpy(pal->colors + firstcolor, colors, - ncolors * sizeof(*colors)); + SDL_memcpy(pal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } if ( current_video && SDL_VideoSurface ) { @@ -1179,16 +1225,13 @@ static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, * changes to its logical palette so that * updates are always identity blits */ - SDL_memcpy(vidpal->colors + firstcolor, colors, - ncolors * sizeof(*colors)); + SDL_memcpy(vidpal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } } SDL_FormatChanged(screen); } -static int SetPalette_physical(SDL_Surface *screen, - SDL_Color *colors, int firstcolor, int ncolors) -{ +static int SetPalette_physical(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { SDL_VideoDevice *video = current_video; int gotall = 1; @@ -1196,10 +1239,9 @@ static int SetPalette_physical(SDL_Surface *screen, /* We need to copy the new colors, since we haven't * already done the copy in the logical set above. */ - SDL_memcpy(video->physpal->colors + firstcolor, - colors, ncolors * sizeof(*colors)); + SDL_memcpy(video->physpal->colors + firstcolor, colors, ncolors * sizeof(*colors)); } - if ( screen == SDL_ShadowSurface ) { + if ( screen == SDL_ShadowSurface) { if ( SDL_VideoSurface->flags & SDL_HWPALETTE ) { /* * The real screen is also indexed - set its physical @@ -1213,25 +1255,19 @@ static int SetPalette_physical(SDL_Surface *screen, * The video surface is not indexed - invalidate any * active shadow-to-video blit mappings. */ - if ( screen->map->dst == SDL_VideoSurface ) { + if ( screen->map->dst == SDL_VideoSurface) { SDL_InvalidateMap(screen->map); } if ( video->gamma ) { - if( ! video->gammacols ) { + if ( !video->gammacols ) { SDL_Palette *pp = video->physpal; - if(!pp) + if ( !pp ) pp = screen->format->palette; video->gammacols = SDL_malloc(pp->ncolors - * sizeof(SDL_Color)); - SDL_ApplyGamma(video->gamma, - pp->colors, - video->gammacols, - pp->ncolors); + * sizeof(SDL_Color)); + SDL_ApplyGamma(video->gamma, pp->colors, video->gammacols, pp->ncolors); } else { - SDL_ApplyGamma(video->gamma, colors, - video->gammacols - + firstcolor, - ncolors); + SDL_ApplyGamma(video->gamma, colors, video->gammacols + firstcolor, ncolors); } } SDL_UpdateRect(screen, 0, 0, 0, 0); @@ -1246,7 +1282,7 @@ static int SetPalette_physical(SDL_Surface *screen, colors = gcolors; } gotall = video->SetColors(video, firstcolor, ncolors, colors); - if ( ! gotall ) { + if ( !gotall ) { /* The video flags shouldn't have SDL_HWPALETTE, and the video driver is responsible for copying back the correct colors into the video surface palette. @@ -1267,9 +1303,7 @@ static int SetPalette_physical(SDL_Surface *screen, * * Return nonzero if all colours were set as requested, or 0 otherwise. */ -int SDL_SetPalette(SDL_Surface *screen, int which, - SDL_Color *colors, int firstcolor, int ncolors) -{ +int SDL_SetPalette(SDL_Surface *screen, int which, SDL_Color *colors, int firstcolor, int ncolors) { SDL_Palette *pal; int gotall; int palsize; @@ -1287,8 +1321,8 @@ int SDL_SetPalette(SDL_Surface *screen, int which, /* Verify the parameters */ pal = screen->format->palette; - if( !pal ) { - return 0; /* not a palettized surface */ + if ( !pal ) { + return 0; /* not a palettized surface */ } gotall = 1; palsize = 1 << screen->format->BitsPerPixel; @@ -1329,31 +1363,26 @@ int SDL_SetPalette(SDL_Surface *screen, int which, } SDL_memcpy(pp->colors, pal->colors, size); } - if ( ! SetPalette_physical(screen, - colors, firstcolor, ncolors) ) { + if ( !SetPalette_physical(screen, colors, firstcolor, ncolors)) { gotall = 0; } } return gotall; } -int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor, - int ncolors) -{ - return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, - colors, firstcolor, ncolors); +int SDL_SetColors(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { + return SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, colors, firstcolor, ncolors); } /* * Clean up the video subsystem */ -void SDL_VideoQuit (void) -{ +void SDL_VideoQuit(void) { SDL_Surface *ready_to_go; if ( current_video ) { - SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *video = current_video; + SDL_VideoDevice *this = current_video; /* Halt event processing before doing anything else */ SDL_StopEventLoop(); @@ -1412,8 +1441,7 @@ void SDL_VideoQuit (void) } /* Load the GL driver library */ -int SDL_GL_LoadLibrary(const char *path) -{ +int SDL_GL_LoadLibrary(const char *path) { SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; int retval; @@ -1428,11 +1456,10 @@ int SDL_GL_LoadLibrary(const char *path) SDL_SetError("No dynamic GL support in video driver"); } } - return(retval); + return (retval); } -void *SDL_GL_GetProcAddress(const char* proc) -{ +void *SDL_GL_GetProcAddress(const char *proc) { SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; void *func; @@ -1451,13 +1478,12 @@ void *SDL_GL_GetProcAddress(const char* proc) } /* Set the specified GL attribute for setting up a GL video mode */ -int SDL_GL_SetAttribute( SDL_GLattr attr, int value ) -{ +int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { int retval; SDL_VideoDevice *video = current_video; retval = 0; - switch (attr) { + switch ( attr ) { case SDL_GL_RED_SIZE: video->gl_config.red_size = value; break; @@ -1514,15 +1540,14 @@ int SDL_GL_SetAttribute( SDL_GLattr attr, int value ) retval = -1; break; } - return(retval); + return (retval); } /* Retrieve an attribute value from the windowing system. */ -int SDL_GL_GetAttribute(SDL_GLattr attr, int* value) -{ +int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { int retval = -1; - SDL_VideoDevice* video = current_video; - SDL_VideoDevice* this = current_video; + SDL_VideoDevice *video = current_video; + SDL_VideoDevice *this = current_video; if ( video->GL_GetAttribute ) { retval = this->GL_GetAttribute(this, attr, value); @@ -1534,8 +1559,7 @@ int SDL_GL_GetAttribute(SDL_GLattr attr, int* value) } /* Perform a GL buffer swap on the current GL context */ -void SDL_GL_SwapBuffers(void) -{ +void SDL_GL_SwapBuffers(void) { SDL_VideoDevice *video = current_video; SDL_VideoDevice *this = current_video; @@ -1547,16 +1571,14 @@ void SDL_GL_SwapBuffers(void) } /* Update rects with locking */ -void SDL_GL_UpdateRectsLock(SDL_VideoDevice* this, int numrects, SDL_Rect *rects) -{ +void SDL_GL_UpdateRectsLock(SDL_VideoDevice *this, int numrects, SDL_Rect *rects) { SDL_GL_Lock(); - SDL_GL_UpdateRects(numrects, rects); + SDL_GL_UpdateRects(numrects, rects); SDL_GL_Unlock(); } /* Update rects without state setting and changing (the caller is responsible for it) */ -void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) -{ +void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) { #if SDL_VIDEO_OPENGL SDL_VideoDevice *this = current_video; SDL_Rect update, tmp; @@ -1582,42 +1604,42 @@ void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) if ( update.h > 256 ) update.h = 256; - + this->glFlush(); - this->glTexSubImage2D( - GL_TEXTURE_2D, - 0, - 0, - 0, - update.w, - update.h, + this->glTexSubImage2D( + GL_TEXTURE_2D, + 0, + 0, + 0, + update.w, + update.h, this->is_32bit? GL_RGBA : GL_RGB, #ifdef GL_VERSION_1_2 this->is_32bit ? GL_UNSIGNED_BYTE : GL_UNSIGNED_SHORT_5_6_5, #else GL_UNSIGNED_BYTE, #endif - (Uint8 *)this->screen->pixels + - this->screen->format->BytesPerPixel * update.x + + (Uint8 *)this->screen->pixels + + this->screen->format->BytesPerPixel * update.x + update.y * this->screen->pitch ); - + this->glFlush(); /* * Note the parens around the function name: - * This is because some OpenGL implementations define glTexCoord etc + * This is because some OpenGL implementations define glTexCoord etc * as macros, and we don't want them expanded here. */ this->glBegin(GL_TRIANGLE_STRIP); - (this->glTexCoord2f)( 0.0, 0.0 ); + (this->glTexCoord2f)( 0.0, 0.0 ); (this->glVertex2i)( update.x, update.y ); - (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); + (this->glTexCoord2f)( (float)(update.w / 256.0), 0.0 ); (this->glVertex2i)( update.x + update.w, update.y ); (this->glTexCoord2f)( 0.0, (float)(update.h / 256.0) ); (this->glVertex2i)( update.x, update.y + update.h ); - (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); + (this->glTexCoord2f)( (float)(update.w / 256.0), (float)(update.h / 256.0) ); (this->glVertex2i)( update.x + update.w , update.y + update.h ); - this->glEnd(); - + this->glEnd(); + tmp.x += 256; tmp.w -= 256; } @@ -1629,8 +1651,7 @@ void SDL_GL_UpdateRects(int numrects, SDL_Rect *rects) } /* Lock == save current state */ -void SDL_GL_Lock() -{ +void SDL_GL_Lock() { #if SDL_VIDEO_OPENGL lock_count--; if (lock_count==-1) @@ -1647,7 +1668,7 @@ void SDL_GL_Lock() this->glDisable(GL_FOG); this->glDisable(GL_ALPHA_TEST); this->glDisable(GL_DEPTH_TEST); - this->glDisable(GL_SCISSOR_TEST); + this->glDisable(GL_SCISSOR_TEST); this->glDisable(GL_STENCIL_TEST); this->glDisable(GL_CULL_FACE); @@ -1677,8 +1698,7 @@ void SDL_GL_Lock() } /* Unlock == restore saved state */ -void SDL_GL_Unlock() -{ +void SDL_GL_Unlock() { #if SDL_VIDEO_OPENGL lock_count++; if (lock_count==0) @@ -1701,10 +1721,9 @@ void SDL_Audio_SetCaption(const char *caption); /* * Sets/Gets the title and icon text of the display window, if any. */ -void SDL_WM_SetCaption (const char *title, const char *icon) -{ +void SDL_WM_SetCaption(const char *title, const char *icon) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( video ) { if ( title ) { @@ -1719,8 +1738,8 @@ void SDL_WM_SetCaption (const char *title, const char *icon) } video->wm_icon = SDL_strdup(icon); } - if ( (title || icon) && (video->SetCaption != NULL) ) { - video->SetCaption(this, video->wm_title,video->wm_icon); + if ((title || icon) && (video->SetCaption != NULL)) { + video->SetCaption(this, video->wm_title, video->wm_icon); } } @@ -1728,8 +1747,7 @@ void SDL_WM_SetCaption (const char *title, const char *icon) SDL_Audio_SetCaption(title); } -void SDL_WM_GetCaption (char **title, char **icon) -{ +void SDL_WM_GetCaption(char **title, char **icon) { SDL_VideoDevice *video = current_video; if ( video ) { @@ -1744,73 +1762,74 @@ void SDL_WM_GetCaption (char **title, char **icon) /* Utility function used by SDL_WM_SetIcon(); * flags & 1 for color key, flags & 2 for alpha channel. */ -static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags) -{ +static void CreateMaskFromColorKeyOrAlpha(SDL_Surface *icon, Uint8 *mask, int flags) { int x, y; Uint32 colorkey; #define SET_MASKBIT(icon, x, y, mask) \ - mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) + mask[(y*((icon->w+7)/8))+(x/8)] &= ~(0x01<<(7-(x%8))) colorkey = icon->format->colorkey; - switch (icon->format->BytesPerPixel) { - case 1: { Uint8 *pixels; - for ( y=0; yh; ++y ) { - pixels = (Uint8 *)icon->pixels + y*icon->pitch; - for ( x=0; xw; ++x ) { + 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; + break; - case 2: { Uint16 *pixels; - for ( y=0; yh; ++y ) { + case 2: { + Uint16 *pixels; + for ( y = 0; y < icon->h; ++y ) { pixels = (Uint16 *)icon->pixels + - y*icon->pitch/2; - for ( x=0; xw; ++x ) { - if ( (flags & 1) && *pixels == colorkey ) { + y * icon->pitch / 2; + for ( x = 0; x < icon->w; ++x ) { + if ((flags & 1) && *pixels == colorkey ) { SET_MASKBIT(icon, x, y, mask); - } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { + } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0 ) { SET_MASKBIT(icon, x, y, mask); } pixels++; } } } - break; + break; - case 4: { Uint32 *pixels; - for ( y=0; yh; ++y ) { + case 4: { + Uint32 *pixels; + for ( y = 0; y < icon->h; ++y ) { pixels = (Uint32 *)icon->pixels + - y*icon->pitch/4; - for ( x=0; xw; ++x ) { - if ( (flags & 1) && *pixels == colorkey ) { + y * icon->pitch / 4; + for ( x = 0; x < icon->w; ++x ) { + if ((flags & 1) && *pixels == colorkey ) { SET_MASKBIT(icon, x, y, mask); - } else if((flags & 2) && (*pixels & icon->format->Amask) == 0) { + } else if ((flags & 2) && (*pixels & icon->format->Amask) == 0 ) { SET_MASKBIT(icon, x, y, mask); } pixels++; } } } - break; + break; } } /* * Sets the window manager icon for the display window. */ -void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask) -{ +void SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( icon && video->SetIcon ) { /* Generate a mask if necessary, and create the icon! */ if ( mask == NULL ) { - int mask_len = icon->h*(icon->w+7)/8; + int mask_len = icon->h * (icon->w + 7) / 8; int flags = 0; mask = (Uint8 *)SDL_malloc(mask_len); if ( mask == NULL ) { @@ -1819,7 +1838,7 @@ void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask) SDL_memset(mask, ~0, mask_len); if ( icon->flags & SDL_SRCCOLORKEY ) flags |= 1; if ( icon->flags & SDL_SRCALPHA ) flags |= 2; - if( flags ) { + if ( flags ) { CreateMaskFromColorKeyOrAlpha(icon, mask, flags); } video->SetIcon(video, icon, mask); @@ -1835,19 +1854,18 @@ void SDL_WM_SetIcon (SDL_Surface *icon, Uint8 *mask) * This function returns the final grab mode after calling the * driver dependent function. */ -static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) -{ +static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; /* Only do something if we have support for grabs */ if ( video->GrabInput == NULL ) { - return(video->input_grab); + return (video->input_grab); } /* If the final grab mode if off, only then do we actually grab */ #ifdef DEBUG_GRAB - printf("SDL_WM_GrabInputRaw(%d) ... ", mode); + printf("SDL_WM_GrabInputRaw(%d) ... ", mode); #endif if ( mode == SDL_GRAB_OFF ) { if ( video->input_grab != SDL_GRAB_OFF ) { @@ -1865,21 +1883,21 @@ static SDL_GrabMode SDL_WM_GrabInputRaw(SDL_GrabMode mode) } } #ifdef DEBUG_GRAB - printf("Final mode %d\n", video->input_grab); + printf("Final mode %d\n", video->input_grab); #endif /* Return the final grab state */ if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - return(mode); + return (mode); } -SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) -{ + +SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) { SDL_VideoDevice *video = current_video; /* If the video isn't initialized yet, we can't do anything */ - if ( ! video ) { + if ( !video ) { return SDL_GRAB_OFF; } @@ -1889,23 +1907,23 @@ SDL_GrabMode SDL_WM_GrabInput(SDL_GrabMode mode) if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - return(mode); + return (mode); } #ifdef DEBUG_GRAB - printf("SDL_WM_GrabInput(%d) ... ", mode); + printf("SDL_WM_GrabInput(%d) ... ", mode); #endif /* If the video surface is fullscreen, we always grab */ if ( mode >= SDL_GRAB_FULLSCREEN ) { mode -= SDL_GRAB_FULLSCREEN; } - if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { + if ( SDL_VideoSurface && (SDL_VideoSurface->flags & SDL_FULLSCREEN)) { mode += SDL_GRAB_FULLSCREEN; } - return(SDL_WM_GrabInputRaw(mode)); + return (SDL_WM_GrabInputRaw(mode)); } -static SDL_GrabMode SDL_WM_GrabInputOff(void) -{ + +static SDL_GrabMode SDL_WM_GrabInputOff(void) { SDL_GrabMode mode; /* First query the current grab state */ @@ -1915,38 +1933,36 @@ static SDL_GrabMode SDL_WM_GrabInputOff(void) SDL_WM_GrabInputRaw(SDL_GRAB_OFF); /* Return the old state */ - return(mode); + return (mode); } /* * Iconify the window in window managed environments. * A successful iconification will result in an SDL_APPACTIVE loss event. */ -int SDL_WM_IconifyWindow(void) -{ +int SDL_WM_IconifyWindow(void) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; int retval; retval = 0; if ( video->IconifyWindow ) { retval = video->IconifyWindow(this); } - return(retval); + return (retval); } /* * Toggle fullscreen mode */ -int SDL_WM_ToggleFullScreen(SDL_Surface *surface) -{ +int SDL_WM_ToggleFullScreen(SDL_Surface *surface) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; int toggled; toggled = 0; if ( SDL_PublicSurface && (surface == SDL_PublicSurface) && - video->ToggleFullScreen ) { + video->ToggleFullScreen ) { if ( surface->flags & SDL_FULLSCREEN ) { toggled = video->ToggleFullScreen(this, 0); if ( toggled ) { @@ -1965,20 +1981,19 @@ int SDL_WM_ToggleFullScreen(SDL_Surface *surface) SDL_WM_GrabInput(video->input_grab); } } - return(toggled); + return (toggled); } /* * Get some platform dependent window manager information */ -int SDL_GetWMInfo (SDL_SysWMinfo *info) -{ +int SDL_GetWMInfo(SDL_SysWMinfo *info) { SDL_VideoDevice *video = current_video; - SDL_VideoDevice *this = current_video; + SDL_VideoDevice *this = current_video; if ( video && video->GetWMInfo ) { - return(video->GetWMInfo(this, info)); + return (video->GetWMInfo(this, info)); } else { - return(0); + return (0); } } diff --git a/src/video/SDL_yuv_sw.c b/src/video/SDL_yuv_sw.c index c555ce06c..650483205 100644 --- a/src/video/SDL_yuv_sw.c +++ b/src/video/SDL_yuv_sw.c @@ -356,6 +356,68 @@ static void Color32DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix, } } +static void Grey8DitherYV12Mod1X( int *colortab, Uint32 *rgb_2_pix, + unsigned char *lum, unsigned char *cr, + unsigned char *cb, unsigned char *out, + int rows, int cols, int mod ) +{ // for mp4 used + 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 = (unsigned char *) 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++ = L; + + + L = *lum++; + *row1++ = L; + + ///* Now, do second row. */ + + L = *lum2++; + *row2++ = L; + + L = *lum2++; + *row2++ = L; + } + + /* + * 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 @@ -939,13 +1001,26 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S Uint32 Rmask, Gmask, Bmask; /* Only RGB packed pixel conversion supported */ - if ( (display->format->BytesPerPixel != 2) && - (display->format->BytesPerPixel != 3) && + if ( (display->format->BytesPerPixel != 1) && + (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); } + if (display->format->BytesPerPixel == 1) + { + struct SDL_Color color; + for (i=0;i<256;i++) + { + color.r=i; + color.g=i; + color.b=i; + SDL_SetColors(display,&color,i,1); + } + } + /* Verify that we support the format */ switch (format) { case SDL_YV12_OVERLAY: @@ -1100,6 +1175,12 @@ SDL_Overlay *SDL_CreateYUV_SW(_THIS, int width, int height, Uint32 format, SDL_S #endif swdata->Display2X = Color32DitherYV12Mod2X; } + //new + if ( display->format->BytesPerPixel == 1 ) { + swdata->Display1X = Grey8DitherYV12Mod1X; + swdata->Display2X = Grey8DitherYV12Mod1X; + } + //new break; case SDL_YUY2_OVERLAY: case SDL_UYVY_OVERLAY: diff --git a/src/video/cybergfx/SDL_amigaevents.c b/src/video/cybergfx/SDL_amigaevents.c index 333d0fa38..df41df79d 100644 --- a/src/video/cybergfx/SDL_amigaevents.c +++ b/src/video/cybergfx/SDL_amigaevents.c @@ -19,35 +19,81 @@ Sam Lantinga slouken@libsdl.org */ +#ifdef AROS +# define _STRUCT_TIMEVAL 1 +#endif +long _sdl_no_lower_taskpri; +long _sdl_audiovolume; + #include "SDL_config.h" /* Handle the event stream, converting Amiga events into SDL events */ #include "SDL.h" #include "SDL_syswm.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" +#include "../events/SDL_sysevents.h" +#include "SDL_sysvideo.h" +#include "../events/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" +#include +#include +#include +#include /* 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; + +SDL_keysym *amiga_TranslateKey(int code, int qual, 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 +#define MOUSE_FUDGE_FACTOR 8 + +SDL_AmigaNoLowerTaskpri() { + _sdl_no_lower_taskpri = 1; +} + +//extern size_t SDL_strlcpy(char *, const char *, size_t); +/* + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + + // Copy as many bytes as will fit + if (n != 0 && --n != 0) { + do { + if ((*d++ = *s++) == 0) + break; + } while (--n != 0); + } + // Not enough room in dst, add NUL and traverse rest of src + if (n == 0) { + if (siz != 0) + *d = '\0'; // NUL-terminate dst + while (*s++) + ; + } + + return(s - src - 1); // count does not include NUL + } +*/ #if 0 static inline int amiga_WarpedMotion(_THIS, struct IntuiMessage *m) @@ -126,104 +172,170 @@ static int amiga_GetButton(int code) } } -static int amiga_DispatchEvent(_THIS,struct IntuiMessage *msg) +static int mousex, mousey, oldtaskpri; + +static int amiga_DispatchEvent(_THIS, struct IntuiMessage *msg) { int class=msg->Class,code=msg->Code; int posted; + int qual = msg->Qualifier; + APTR *fh = 0; posted = 0; - switch (class) { - /* Gaining mouse coverage? */ - case IDCMP_ACTIVEWINDOW: + + switch ( class ) { + /* Gaining mouse coverage? */ + case IDCMP_ACTIVEWINDOW: + this->hidden->window_active = 1; + this->hidden->oldqual = 0; posted = SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); + if ( !_sdl_no_lower_taskpri ) { + fh = Open("env:SDL_NOLOWERTASKPRI", 1005); + if ( !fh ) { + if ( oldtaskpri == 0 )SetTaskPri(FindTask(0), 0); + } + if ( fh )Close(fh); + } break; - /* Losing mouse coverage? */ - case IDCMP_INACTIVEWINDOW: + /* Losing mouse coverage? */ + case IDCMP_INACTIVEWINDOW: + this->hidden->window_active = 0; posted = SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); + if ( !_sdl_no_lower_taskpri ) { + fh = Open("env:SDL_NOLOWERTASKPRI", 1005); + if ( !fh ) { + oldtaskpri = SetTaskPri(FindTask(0), -1); + if ( oldtaskpri != 0 )SetTaskPri(FindTask(0), oldtaskpri); // only a thread with pri 0 is lower + + } + if ( fh )Close(fh); + } break; #if 0 - /* Gaining input focus? */ - case IDCMP_ACTIVEWINDOW: + /* 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; + break; - /* Losing input focus? */ - case IDCMP_INACTIVEWINDOW: + /* 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; + 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); + /* Mouse motion? */ + case IDCMP_MOUSEMOVE: + + if ( SDL_VideoSurface) { + //posted = SDL_PrivateMouseMotion(0, 0, + // msg->MouseX-SDL_Window->BorderLeft, + // msg->MouseY-SDL_Window->BorderTop); + mousex = msg->MouseX - SDL_Window->BorderLeft; + mousey = msg->MouseY - SDL_Window->BorderTop; } - break; + break; - /* Mouse button press? */ + /* Mouse button press? */ case IDCMP_MOUSEBUTTONS: - if(!(code&IECODE_UP_PREFIX)) - { + + if ( !(code & IECODE_UP_PREFIX)) { + if ( msg->MouseX < SDL_Window->BorderLeft || msg->MouseY < 0 || msg->MouseX >= (current_w + SDL_Window->BorderLeft) || msg->MouseY >= (current_h + SDL_Window->BorderTop)) { + break; + } posted = SDL_PrivateMouseButton(SDL_PRESSED, - amiga_GetButton(code), 0, 0); - } - /* Mouse button release? */ - else - { - code&=~IECODE_UP_PREFIX; + amiga_GetButton(code), 0, 0); + } + /* Mouse button release? */ + else { + code &= ~IECODE_UP_PREFIX; posted = SDL_PrivateMouseButton(SDL_RELEASED, - amiga_GetButton(code), 0, 0); + amiga_GetButton(code), 0, 0); } break; - case IDCMP_RAWKEY: + case IDCMP_RAWKEY: - /* Key press? */ + /* Key press? */ + if ((msg->Qualifier && IEQUALIFIER_LALT) && (msg->Qualifier && IEQUALIFIER_CONTROL) && (code == 0x25)) { + extern int skipframe, toggle; - if( !(code&IECODE_UP_PREFIX) ) - { + if ( skipframe == 0 ) { + skipframe = 1; + toggle = 1; + } else { + skipframe = 0; + toggle = 0; + } + + } + switch ( code ) { + case 0x7a : + case 0x7b : { + //if(!(code & IECODE_UP_PREFIX)) + { + SDL_PrivateMouseButton(SDL_PRESSED, + code == 0x7a ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, 0, 0); + } + //else + { + //code &= ~IECODE_UP_PREFIX; + SDL_PrivateMouseButton(SDL_RELEASED, + code == 0x7a ? SDL_BUTTON_WHEELUP : SDL_BUTTON_WHEELDOWN, 0, 0); + } + break; + } + } + if ( !(code & IECODE_UP_PREFIX)) { SDL_keysym keysym; posted = SDL_PrivateKeyboard(SDL_PRESSED, - amiga_TranslateKey(code, &keysym)); - } - else - { - /* Key release? */ + amiga_TranslateKey(code, msg->Qualifier, &keysym)); + } else { + /* Key release? */ SDL_keysym keysym; - code&=~IECODE_UP_PREFIX; + code &= ~IECODE_UP_PREFIX; - /* Check to see if this is a repeated key */ + /* 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; + amiga_TranslateKey(code, msg->Qualifier, &keysym)); + + if ( SDL_TranslateUNICODE ) // fix when press a key and release qualifier before key.key is repeat endless without that fix + { + posted = SDL_PrivateKeyboard(SDL_RELEASED, + amiga_TranslateKey(code, IEQUALIFIER_RSHIFT, &keysym)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + amiga_TranslateKey(code, IEQUALIFIER_RALT, &keysym)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + amiga_TranslateKey(code, IEQUALIFIER_CONTROL, &keysym)); + posted = SDL_PrivateKeyboard(SDL_RELEASED, + amiga_TranslateKey(code, 0, &keysym)); + } + } + break; /* Have we been iconified? */ #if 0 - case UnmapNotify: { + case UnmapNotify: { #ifdef DEBUG_XEVENTS printf("UnmapNotify!\n"); #endif posted=SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS); - } - break; + } + break; - /* Have we been restored? */ + /* Have we been restored? */ - case MapNotify: { + case MapNotify: { #ifdef DEBUG_XEVENTS printf("MapNotify!\n"); #endif @@ -231,7 +343,7 @@ printf("MapNotify!\n"); posted = SDL_PrivateAppActive(1, SDL_APPACTIVE); if ( SDL_VideoSurface && - (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) + (SDL_VideoSurface->flags & SDL_FULLSCREEN) ) { CGX_EnterFullScreen(this); } else { @@ -240,69 +352,73 @@ printf("MapNotify!\n"); if ( SDL_VideoSurface ) { CGX_RefreshDisplay(this); } - } - break; - case Expose: + } + 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->BorderLeft-SDL_Window->BorderRight, - SDL_Window->Height-SDL_Window->BorderTop-SDL_Window->BorderBottom); + /* Have we been resized? */ + case IDCMP_NEWSIZE: + SDL_PrivateResize(SDL_Window->Width - SDL_Window->BorderLeft - SDL_Window->BorderRight, + SDL_Window->Height - SDL_Window->BorderTop - SDL_Window->BorderBottom); break; - /* Have we been requested to quit? */ - case IDCMP_CLOSEWINDOW: - posted = SDL_PrivateQuit(); - break; + /* Have we been requested to quit? */ + case IDCMP_CLOSEWINDOW: + posted = SDL_PrivateQuit(); + break; - /* Do we need to refresh ourselves? */ + /* 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; + 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); + SDL_VERSION(&wmmsg.version); #if 0 - wmmsg.subsystem = SDL_SYSWM_CGX; - wmmsg.event.xevent = xevent; + wmmsg.subsystem = SDL_SYSWM_CGX; + wmmsg.event.xevent = xevent; #endif - posted = SDL_PrivateSysWMEvent(&wmmsg); + posted = SDL_PrivateSysWMEvent(&wmmsg); + } } - } - break; + break; } ReplyMsg((struct Message *)msg); - return(posted); + return (posted); } -void amiga_PumpEvents(_THIS) -{ +void amiga_PumpEvents(_THIS) { int pending; struct IntuiMessage *m; - + if ((!SDL_Window) || (!SDL_Window->UserPort))return 0; + mousex = -16000; // to collect only the last mousepos and detect if a mousemove have come. + mousey = -16000; /* Keep processing pending events */ pending = 0; - while ( m=(struct IntuiMessage *)GetMsg(SDL_Window->UserPort) ) { - amiga_DispatchEvent(this,m); + + while ( m = (struct IntuiMessage *)GetMsg(SDL_Window->UserPort)) { + amiga_DispatchEvent(this, m); ++pending; } + if ( mousex != -16000 ) { + SDL_PrivateMouseMotion(0, 0, mousex, mousey); + } } -void amiga_InitKeymap(void) -{ +void amiga_InitKeymap(void) { int i; /* Map the miscellaneous keys */ - for ( i=0; iscancode = code; keysym->sym = MISC_keymap[code]; - + unsigned long unicode; + char buffer[5]; #ifdef DEBUG_KEYS fprintf(stderr, "Translating key 0x%.4x (%d)\n", xsym, xkey->keycode); #endif - /* Get the translated SDL virtual keysym */ + /* Get the translated include virtual keysym */ if ( keysym->sym==SDLK_UNKNOWN ) { - #ifdef STORMC4_WOS +#ifdef STORMC4_WOS if(!KeymapBase) - #else +#else if(!ConsoleDevice) - #endif +#endif { - #ifdef STORMC4_WOS +#ifdef STORMC4_WOS KeymapBase=OpenLibrary("keymap.library", 0L); - #else +#else if(ConPort=CreateMsgPort()) { if(ConReq=CreateIORequest(ConPort,sizeof(struct IOStdReq))) @@ -468,20 +586,20 @@ SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) ConPort=NULL; } } - #endif +#endif } - #ifdef STORMC4_WOS +#ifdef STORMC4_WOS if(KeymapBase) - #else +#else if(ConsoleDevice) - #endif +#endif { struct InputEvent event; long actual; - char buffer[5]; - event.ie_Qualifier=0; + + event.ie_Qualifier=qual; event.ie_Class=IECLASS_RAWKEY; event.ie_SubClass=0L; event.ie_Code=code; @@ -490,11 +608,11 @@ SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) event.ie_NextEvent=NULL; event.ie_Prev1DownCode=event.ie_Prev1DownQual=event.ie_Prev2DownCode=event.ie_Prev2DownQual=0; - #ifdef STORMC4_WOS +#ifdef STORMC4_WOS if( (actual=MapRawKey(&event,buffer,5,NULL))>=0) - #else +#else if( (actual=RawKeyConvert(&event,buffer,5,NULL))>=0) - #endif +#endif { if(actual>1) { @@ -511,7 +629,29 @@ SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) } } - keysym->mod = KMOD_NONE; + int mod; + mod = KMOD_NONE; + + if (qual & IEQUALIFIER_LSHIFT) + mod |= KMOD_LSHIFT; + if (qual & IEQUALIFIER_RSHIFT) + mod |= KMOD_RSHIFT; + if (qual & IEQUALIFIER_CAPSLOCK) + mod |= KMOD_CAPS; + if (qual & IEQUALIFIER_CONTROL) + mod |= KMOD_LCTRL | KMOD_RCTRL; + if (qual & IEQUALIFIER_LALT) + mod |= KMOD_LALT; + if (qual & IEQUALIFIER_RALT) + mod |= KMOD_RALT; + if (qual & IEQUALIFIER_LCOMMAND) + mod |= KMOD_LMETA; + if (qual & IEQUALIFIER_RCOMMAND) + mod |= KMOD_RMETA; + if (qual & IEQUALIFIER_NUMERICPAD) + mod |= KMOD_NUM; + + keysym->mod = mod; /* If UNICODE is on, get the UNICODE value for the key */ keysym->unicode = 0; @@ -525,11 +665,106 @@ SDL_keysym *amiga_TranslateKey(int code, SDL_keysym *keysym) keysym->unicode = keybuf[0]; } #endif + unicode = keysym->sym; + + if (unicode > 255) + unicode = 0; + //} } + + keysym->unicode = unicode; return(keysym); } -void amiga_InitOSKeymap(_THIS) -{ + +#else +struct Library *KeymapBase; + +SDL_keysym *amiga_TranslateKey(int code, int qual, SDL_keysym *keysym) { + ULONG key, unicode; + WORD actual = -1; + SDLMod mod; + + D(bug("[include] amiga_TranslateKey()\n")); + + /* Get the raw keyboard scancode */ + + if ( !KeymapBase ) { + KeymapBase = OpenLibrary("keymap.library", 0L); + } + keysym->scancode = code; + keysym->sym = MISC_keymap[code]; + key = 0; + + /* Get the translated include virtual keysym */ + if ( keysym->sym == SDLK_UNKNOWN ) { + struct InputEvent ie; + UBYTE buffer[4]; + + //qual &= ~(IEQUALIFIER_CONTROL|IEQUALIFIER_LALT|IEQUALIFIER_RALT); + + ie.ie_Class = IECLASS_RAWKEY; + ie.ie_SubClass = 0; + ie.ie_Code = code; + ie.ie_Qualifier = SDL_TranslateUNICODE ? qual : qual & ~(IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT | IEQUALIFIER_CAPSLOCK | IEQUALIFIER_CONTROL | IEQUALIFIER_LALT | IEQUALIFIER_RALT); + //ie.ie_Qualifier = qual;// & ~(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT|IEQUALIFIER_CAPSLOCK); + ie.ie_EventAddress = NULL; + + actual = MapRawKey(&ie, buffer, 4, NULL); + + if ( actual == 1 ) { + key = *buffer; + keysym->sym = *buffer; + } + } + + mod = KMOD_NONE; + + if ( qual & IEQUALIFIER_LSHIFT ) + mod |= KMOD_LSHIFT; + if ( qual & IEQUALIFIER_RSHIFT ) + mod |= KMOD_RSHIFT; + if ( qual & IEQUALIFIER_CAPSLOCK ) + mod |= KMOD_CAPS; + if ( qual & IEQUALIFIER_CONTROL ) + mod |= KMOD_LCTRL | KMOD_RCTRL; + if ( qual & IEQUALIFIER_LALT ) + mod |= KMOD_LALT; + if ( qual & IEQUALIFIER_RALT ) + mod |= KMOD_RALT; + if ( qual & IEQUALIFIER_LCOMMAND ) + mod |= KMOD_LMETA; + if ( qual & IEQUALIFIER_RCOMMAND ) + mod |= KMOD_RMETA; + if ( qual & IEQUALIFIER_NUMERICPAD ) + mod |= KMOD_NUM; + + keysym->mod = mod; + + /* unicode support */ + unicode = 0; + + if ( SDL_TranslateUNICODE ) { + //if (KeymapBase->lib_Version >= 51) + //{ + // unicode = ToUCS4(keysym->sym, NULL); + //} + //else + //{ + unicode = keysym->sym; + + if ( unicode > 255 ) + unicode = 0; + //} + } + + keysym->unicode = unicode; + + return (keysym); +} + +#endif + +void amiga_InitOSKeymap(_THIS) { amiga_InitKeymap(); } diff --git a/src/video/cybergfx/SDL_amigamouse.c b/src/video/cybergfx/SDL_amigamouse.c index 64940a82d..df8eee9e3 100644 --- a/src/video/cybergfx/SDL_amigamouse.c +++ b/src/video/cybergfx/SDL_amigamouse.c @@ -19,59 +19,90 @@ Sam Lantinga slouken@libsdl.org */ -#include "SDL_config.h" -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_cursor_c.h" +#include "SDL_config.h" +#include "SDL_events_c.h" +//#include "SDL_error.h" +//#include "SDL_mouse.h" +//#include "SDL_cursor_c.h" #include "SDL_amigamouse_c.h" /* The implementation dependent data for the window manager cursor */ -typedef void * WMCursor; +typedef void *WMCursor; -void amiga_FreeWMCursor(_THIS, WMcursor *cursor) -{ +void amiga_FreeWMCursor(_THIS, WMcursor *cursor) { } WMcursor *amiga_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) -{ + 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) -{ +int amiga_ShowWMCursor(_THIS, WMcursor *cursor) { /* Don't do anything if the display is gone */ - if ( SDL_Display == NULL) { - return(0); + if ( SDL_Display == NULL ) { + return (0); } /* Set the Amiga prefs cursor cursor, or blank if cursor is NULL */ - - if ( SDL_Window ) { + 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); + if ( SDL_Window)SetPointer(SDL_Window, (UWORD * )SDL_BlankCursor, 1, 1, 0, 0); } } else { // Show cursor - ClearPointer(SDL_Window); + if ( SDL_Window)ClearPointer(SDL_Window); } SDL_Unlock_EventThread(); } - return(1); + return (1); } -void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y) -{ +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) -{ +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 } diff --git a/src/video/cybergfx/SDL_amigamouse_c.h b/src/video/cybergfx/SDL_amigamouse_c.h index aad19b627..a2aefe411 100644 --- a/src/video/cybergfx/SDL_amigamouse_c.h +++ b/src/video/cybergfx/SDL_amigamouse_c.h @@ -25,8 +25,7 @@ /* Functions to be exported */ extern void amiga_FreeWMCursor(_THIS, WMcursor *cursor); -extern WMcursor *amiga_CreateWMCursor(_THIS, - Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); +extern WMcursor *amiga_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y); extern int amiga_ShowWMCursor(_THIS, WMcursor *cursor); extern void amiga_WarpWMCursor(_THIS, Uint16 x, Uint16 y); extern void amiga_CheckMouseMode(_THIS); diff --git a/src/video/cybergfx/SDL_cgxaccel.c b/src/video/cybergfx/SDL_cgxaccel.c index 24605e355..3bced80f0 100644 --- a/src/video/cybergfx/SDL_cgxaccel.c +++ b/src/video/cybergfx/SDL_cgxaccel.c @@ -27,137 +27,131 @@ #include "../SDL_blit.h" #include "SDL_cgxvideo.h" -static int CGX_HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect, - SDL_Surface *dst, SDL_Rect *dstrect); +#ifdef AROS +#include +#endif +#define Bug + +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__) || defined(MORPHOS) -#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) +#if 1 +/* + * it was: defined(__SASC) || defined(__PPC__) || defined(MORPHOS) + * + * This is a workaround for an old gcc 2.7.x bug... + */ + +#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) +void BMKBRP(struct BitMap *a,long b, long c,struct RastPort *d,long e,long f,long g,long h,unsigned long 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) +void BBRP(struct BitMap *a,long b, long c,struct RastPort *d,long e,long f,long g,long h,unsigned long 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) +void BBB(struct BitMap *a,long b, long c,struct BitMap *d,long e,long f,long g,long h,unsigned long i,unsigned long j,PLANEPTR 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) +int CGX_SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key) { + return -1; // do no accel blits + if ( surface->hwdata ) { + if ( surface->hwdata->mask ) SDL_free(surface->hwdata->mask); - if(surface->hwdata->mask=SDL_malloc(RASSIZE(surface->w,surface->h))) - { - Uint32 pitch,ok=0; + if ( surface->hwdata->mask = SDL_malloc(RASSIZE(surface->w, surface->h))) { + Uint32 pitch, ok = 0; APTR lock; SDL_memset(surface->hwdata->mask,255,RASSIZE(surface->w,surface->h)); - D(bug("Building colorkey mask: color: %ld, size: %ld x %ld, %ld bytes...Bpp:%ld\n",key,surface->w,surface->h,RASSIZE(surface->w,surface->h),surface->format->BytesPerPixel)); + D(bug("Building colorkey mask: color: %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; + 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; + pitch -= surface->w; - for(i=0;ih;i++) - { - for(t=128,j=0;jw;j++) - { - if(*map==k) - *dest&=~t; + for ( i = 0; i < surface->h; i++ ) { + for ( t = 128, j = 0; j < surface->w; j++ ) { + if ( *map == k ) + *dest &= ~t; - t>>=1; + t >>= 1; - if(t==0) - { + if ( t == 0 ) { dest++; - t=128; + t = 128; } map++; } - map+=pitch; + 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) - { + 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; + t = 128; } mapw++; } - map+=pitch; + map += pitch; } } - break; - case 4: - { + break; + case 4: { Uint32 *mapl; - register int i,j,t; - register unsigned char *dest=surface->hwdata->mask,*map=surface->pixels; + 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 ( i = surface->h; i; --i ) { + mapl = (Uint32 *)map; - for(t=128,j=surface->w;j;--j) - { - if(*mapl==key) - *dest&=~t; + for ( t = 128, j = surface->w; j; --j ) { + if ( *mapl == key ) + *dest &= ~t; - t>>=1; + t >>= 1; - if(t==0) - { + if ( t == 0 ) { dest++; - t=128; + t = 128; } mapl++; } - map+=pitch; + map += pitch; } } - break; + break; default: D(bug("Pixel mode non supported for color key...")); SDL_free(surface->hwdata->mask); - surface->hwdata->mask=NULL; - ok=-1; + surface->hwdata->mask = NULL; + ok = -1; } UnLockBitMap(lock); D(bug("...Colorkey built!\n")); @@ -170,26 +164,25 @@ int CGX_SetHWColorKey(_THIS,SDL_Surface *surface, Uint32 key) 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))) - { +int CGX_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst) { + // Doesn't support yet alpha blitting + if ( this->hidden->swap_bytes )return 0; + if ( src->hwdata && !(src->flags & (SDL_SRCALPHA))) { D(bug("CheckHW blit... OK!\n")); - if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { + if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) { if ( CGX_SetHWColorKey(this, src, src->format->colorkey) < 0 ) { src->flags &= ~SDL_HWACCEL; - return -1; + + return 0; } } - src->flags|=SDL_HWACCEL; + src->flags |= SDL_HWACCEL; src->map->hw_blit = CGX_HWAccelBlit; + return 1; - } - else + } else src->flags &= ~SDL_HWACCEL; D(bug("CheckHW blit... NO!\n")); @@ -197,66 +190,85 @@ int CGX_CheckHWBlit(_THIS,SDL_Surface *src,SDL_Surface *dst) return 0; } -static int temprp_init=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) - { + 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_init = 1; } - temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; + temprp.BitMap = (struct BitMap *)dst->hwdata->bmap; + if ( temprp.BitMap ) + BMKBRP(src->hwdata->bmap, srcrect->x, srcrect->y, + &temprp, dstrect->x, dstrect->y, + srcrect->w, srcrect->h, 0xc0, src->hwdata->mask); + else + BMKBRP(src->hwdata->bmap, srcrect->x, srcrect->y, + SDL_RastPort, dstrect->x, dstrect->y, + srcrect->w, srcrect->h, 0xc0, src->hwdata->mask); - 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); + + /*if(dst==SDL_VideoSurface) + { + long b_src; + if (!src->hwdata->bmap)b_src = SDL_RastPort->BitMap; + else b_src = src->hwdata->bmap; + BBRP(b_src,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->bmap ) + BBB(src->hwdata->bmap, srcrect->x, srcrect->y, dst->hwdata->bmap, dstrect->x, dstrect->y, srcrect->w, srcrect->h, 0xc0, 0xff, NULL); + else if ( !dst->hwdata->bmap ) + BBB(src->hwdata->bmap, srcrect->x, srcrect->y, SDL_RastPort->BitMap, dstrect->x, dstrect->y, srcrect->w, srcrect->h, 0xc0, 0xff, NULL); return 0; } -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); +int CGX_FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) { + unsigned int handle; + + if ( dst->format->Bmask == 0xff000000 )color = SDL_Swap32(color); // for bgra32 mode data must swap. + if ( dst->format->Bmask == 0x1f ) { + Uint32 r, g, b; + b = (color & 0x1f) << 3; // from rgb16 mode data must change to fit the argb FillPixelArray format. + g = ((color >> 5) & 0x3f) << 2; + r = ((color >> 11) & 0x1f) << 3; + color = b | (g << 8) | (r << 16); } - else if(dst->hwdata) - { - if(!temprp_init) - { + if ( dst->hwdata ) { + if ( !temprp_init ) { InitRastPort(&temprp); - temprp_init=1; + temprp_init = 1; } - temprp.BitMap=(struct BitMap *)dst->hwdata->bmap; - - FillPixelArray(&temprp,dstrect->x,dstrect->y,dstrect->w,dstrect->h,color); + temprp.BitMap = (struct BitMap *)dst->hwdata->bmap; + if ( temprp.BitMap == 0 )temprp.BitMap = SDL_RastPort->BitMap; + if ( dst->format->BitsPerPixel == 8 ) //because CGX fillpixelarray dont work on 8 bit screens + { + if ( this->screen->hwdata->lock ) { + UnLockBitMap(this->screen->hwdata->lock); + SetAPen(&temprp, color); + RectFill(&temprp, dstrect->x, dstrect->y, dstrect->w + dstrect->x, dstrect->h + dstrect->y); + this->screen->hwdata->lock = LockBitMapTags(temprp.BitMap, LBMI_BASEADDRESS, (ULONG) & this->screen->pixels, + TAG_DONE); + return; + } + SetAPen(&temprp, color); + RectFill(&temprp, dstrect->x, dstrect->y, dstrect->w + dstrect->x, dstrect->h + dstrect->y); + } else + FillPixelArray(&temprp, dstrect->x, dstrect->y, dstrect->w, dstrect->h, color); } return 0; } diff --git a/src/video/cybergfx/SDL_cgxgl.c b/src/video/cybergfx/SDL_cgxgl.c index e19614b9d..40ccbd6d3 100644 --- a/src/video/cybergfx/SDL_cgxgl.c +++ b/src/video/cybergfx/SDL_cgxgl.c @@ -34,9 +34,9 @@ AmigaMesaContext glcont=NULL; int CGX_GL_Init(_THIS) { #if SDL_VIDEO_OPENGL - int i = 0; + int i = 0; struct TagItem attributes [ 14 ]; /* 14 should be more than enough :) */ - struct Window *win = (struct Window *)SDL_Window; + struct Window *win = (struct Window *)SDL_Window; // default config. Always used... attributes[i].ti_Tag = AMA_Window; attributes[i++].ti_Data = (unsigned long)win; @@ -47,7 +47,7 @@ int CGX_GL_Init(_THIS) attributes[i].ti_Tag = AMA_DirectRender; attributes[i++].ti_Data = GL_TRUE; // double buffer ? - attributes[i].ti_Tag = AMA_DoubleBuf; + //attributes[i].ti_Tag = AMA_DoubleBuf;attributes[i++].ti_Data = GL_TRUE; if ( this->gl_config.double_buffer ) { attributes[i++].ti_Data = GL_TRUE; } diff --git a/src/video/cybergfx/SDL_cgxgl_c.h b/src/video/cybergfx/SDL_cgxgl_c.h index 4c04f59a5..e1fc5c032 100644 --- a/src/video/cybergfx/SDL_cgxgl_c.h +++ b/src/video/cybergfx/SDL_cgxgl_c.h @@ -40,6 +40,7 @@ struct SDL_PrivateGLData { extern int CGX_GL_Init(_THIS); extern void CGX_GL_Quit(_THIS); extern int CGX_GL_Update(_THIS); + #if SDL_VIDEO_OPENGL extern int CGX_GL_MakeCurrent(_THIS); extern int CGX_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); diff --git a/src/video/cybergfx/SDL_cgximage.c b/src/video/cybergfx/SDL_cgximage.c index 3e8938efe..8be24a0b2 100644 --- a/src/video/cybergfx/SDL_cgximage.c +++ b/src/video/cybergfx/SDL_cgximage.c @@ -19,124 +19,259 @@ Sam Lantinga slouken@libsdl.org */ -#include "SDL_config.h" +#define BITMAPMEM + +#include + +#ifndef _HAVE_STDINT_H + +#include +#endif + +#include "SDL_config.h" +#include "SDL_error.h" #include "SDL_endian.h" #include "SDL_cgximage_c.h" #ifdef HAVE_KSTAT #include #endif +#ifndef RECTFMT_RAW +#define RECTFMT_RAW (5UL) +#endif + +#include "mydebug.h" + +// this is an undocumented feature of CGX, and recently of AROS +// and P96, if it's not defined let define it ourselves. + +int skipframe = 0, toggle = 0; + + +#define USE_CGX_WRITELUTPIXEL +#if 1 #ifdef USE_CGX_WRITELUTPIXEL -#if defined(__SASC) || defined(__PPC__) - #define WLUT WriteLUTPixelArray -#else +#if defined(MORPHOS) || defined(__SASC) || defined(AROS) || defined(WARPOS) || defined(__GNUC__) +#define WLUT WriteLUTPixelArray +#elif STORMC4_M68K + 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); } +{ + WriteLUTPixelArray(a,b,c,d,e,f,g,h,i,l,m); +} +#else +#error "empty WLUT" + +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) {}; +#endif #endif #endif +#if 0 +// this is an old workaround for a gcc optimizer bug, it shouldn't be needed anymore + +static void WLPA(SDL_Surface *s,SDL_Rect *rect,struct RastPort *rp,APTR colortable,struct Window *win); + +static void WLPA(SDL_Surface *s,SDL_Rect *rect,struct RastPort *rp,APTR colortable,struct Window *win) +{ + WriteLUTPixelArray(s->pixels,rect->x, rect->y,s->pitch,rp,colortable, + win->BorderLeft+rect->x,win->BorderTop+rect->y,rect->w,rect->h,CTABFMT_XRGB8); +} +#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 use_picasso96=1; +BOOL SafeDisp = TRUE, SafeChange = TRUE; +struct MsgPort *safeport = NULL, *dispport = NULL; +ULONG safe_sigbit, disp_sigbit; +int use_picasso96 = 0; -int CGX_SetupImage(_THIS, SDL_Surface *screen) -{ - SDL_Ximage=NULL; +Uint32 SDL_Swap2x16_b(Uint32 x) { +#ifdef APOLLO_BLIT + __asm__("rorw #8,%0\n\tswap %0\n\trorw #8,%0\n\tswap %0\t\n" : "=d" (x) : "0" (x) : "cc"); +#else + x = (x >> 24) | ((x >> 8) & 0xff00) | ((x << 8) & 0xff0000) | (x << 24); +#endif + return x; +} - if(screen->flags&SDL_HWSURFACE) { - ULONG pitch; +void bcopy_swap2(APTR dst, APTR src, int size) { + Uint32 *s; + Uint32 *d; + + s = src; + d = dst; + if ( !d )return; + if ( !s )return; + if ( size >= 16 ) { + do { + *(d++) = SDL_Swap2x16_b(*s++); + *(d++) = SDL_Swap2x16_b(*s++); + *(d++) = SDL_Swap2x16_b(*s++); + *(d++) = SDL_Swap2x16_b(*s++); + size -= 16; + } while ( size >= 16 ); + } + if ( size > 0 ) { + UWORD *s, *d; + + s = src; + d = dst; + + do { + //UWORD a = *s; + + //*d = ((a >> 8) & 0xff) | ((a & 0xff) << 8); + *d = SDL_Swap16(*s); + + s++; + d++; + size -= 2; + } while ( size > 0 ); + } + +} - if(!screen->hwdata) { - if(!(screen->hwdata=SDL_malloc(sizeof(struct private_hwdata)))) +#if 1 + +int CGX_SetupImage(_THIS, SDL_Surface *screen) { + ULONG pitch; + unsigned int format = BMF_MINPLANES | BMF_DISPLAYABLE; + struct BitMap *friendbmap = SDL_RastPort->BitMap; + + SDL_Ximage = NULL; + if ( screen->flags & SDL_HWSURFACE ) { + if ( this->hidden->swap_bytes && this->hidden->depth == 16 ) { + D(bug("Slow 16 bit pixel swap need better use a rgb16 screenmode \n")); + format = BMF_DISPLAYABLE | BMF_MINPLANES | BMF_SPECIALFMT | (PIXFMT_RGB16 << 24); + friendbmap = 0; + } + if ( this->hidden->swap_bytes && this->hidden->depth == 32 ) { + D(bug("Slow 32 bit pixel swap need better use a BGRA Screenmode \n")); + format = BMF_DISPLAYABLE | BMF_MINPLANES | BMF_SPECIALFMT | (PIXFMT_BGRA32 << 24); + friendbmap = 0; + } + + if ( !screen->hwdata ) { + if ( !(screen->hwdata = SDL_malloc(sizeof(struct private_hwdata)))) return -1; D(bug("Creating system accel struct\n")); } - screen->hwdata->lock=NULL; - screen->hwdata->allocated=0; - screen->hwdata->mask=NULL; - screen->hwdata->bmap=SDL_RastPort->BitMap; - screen->hwdata->videodata=this; - - if(!(screen->hwdata->lock=LockBitMapTags(screen->hwdata->bmap, - LBMI_BASEADDRESS,(ULONG)&screen->pixels, - LBMI_BYTESPERROW,(ULONG)&pitch,TAG_DONE))) { + screen->hwdata->lock = NULL; + screen->hwdata->bmap = 0; + screen->hwdata->allocated = 0; + screen->hwdata->mask = NULL; + screen->hwdata->videodata = this; + + //if ((!screen->flags&SDL_FULLSCREEN)) + { + if ( AvailMem(MEMF_LARGEST) < (screen->w * screen->h * (this->hidden->depth / 8) + 500000)) { + D(bug("Too little RAM for other bitmap \n")); + return -1; + } + if ( !(this->hidden->bmap = AllocBitMap(screen->w, screen->h, this->hidden->depth, format, friendbmap))) { + format &= ~BMF_DISPLAYABLE; + if ( !(this->hidden->bmap = AllocBitMap(screen->w, screen->h, this->hidden->depth, format, friendbmap))) { + D(bug("cant alloc Bitmap\n")); + return -1; + } + } + screen->hwdata->bmap = this->hidden->bmap; + D(bug("before lock %lx\n", screen->hwdata->bmap)); + if ( !(screen->hwdata->lock = LockBitMapTags(screen->hwdata->bmap, LBMI_BASEADDRESS, (ULONG)&screen->pixels, LBMI_BYTESPERROW, (ULONG)&pitch, TAG_DONE))) { + SDL_free(screen->hwdata); + screen->hwdata = NULL; + return -1; + } else { + UnLockBitMap(screen->hwdata->lock); + screen->hwdata->lock = NULL; + } + D(bug("after lock\n")); + screen->pitch = pitch; + this->UpdateRects = CGX_NormalUpdate; + return 0; + } + + if ( !(screen->hwdata->lock = LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, (ULONG)&screen->pixels, LBMI_BYTESPERROW, (ULONG)&pitch, TAG_DONE))) { SDL_free(screen->hwdata); - screen->hwdata=NULL; + screen->hwdata = NULL; + screen->hwdata->lock = NULL; return -1; - } - else { + } else { UnLockBitMap(screen->hwdata->lock); - screen->hwdata->lock=NULL; + screen->hwdata->lock = NULL; } - screen->pitch=pitch; + this->UpdateRects = (void (*)(_THIS, int numrects, SDL_Rect *rects))CGX_FlipHWSurface; + screen->pitch = pitch; - this->UpdateRects = CGX_FakeUpdate; - - D(bug("Accel video image configured (%lx, pitch %ld).\n",screen->pixels,screen->pitch)); + D(bug("HWSURFACE created\n")); + D(bug("Accel video image configured (%lx, pitch %ld).\n", screen->pixels, screen->pitch)); return 0; } - screen->pixels = SDL_malloc(screen->h*screen->pitch); + screen->pixels = SDL_malloc(screen->h * screen->pitch); // alloc screenmem if ( screen->pixels == NULL ) { SDL_OutOfMemory(); - return(-1); + return (-1); } - SDL_Ximage=screen->pixels; + SDL_Ximage = screen->pixels; if ( SDL_Ximage == NULL ) { SDL_SetError("Couldn't create XImage"); - return(-1); + return (-1); } this->UpdateRects = CGX_NormalUpdate; - return(0); + return (0); } -void CGX_DestroyImage(_THIS, SDL_Surface *screen) -{ +void CGX_DestroyImage(_THIS, SDL_Surface *screen) { + if ( this->hidden->bmap )FreeBitMap(this->hidden->bmap); + this->hidden->bmap = 0; if ( SDL_Ximage ) { SDL_free(SDL_Ximage); SDL_Ximage = NULL; } if ( screen ) { - screen->pixels = NULL; - if(screen->hwdata) { + screen->pixels = NULL; + if ( screen->hwdata ) { SDL_free(screen->hwdata); - screen->hwdata=NULL; + if ( this->hidden->bmap )FreeBitMap(this->hidden->bmap); + screen->hwdata = NULL; } } } +#endif + /* This is a hack to see whether this system has more than 1 CPU */ -static int num_CPU(void) -{ +static int num_CPU(void) { return 1; } -int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) -{ - int retval; +#if 1 - D(bug("Calling ResizeImage()\n")); +int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) { + int retval; + D(bug("Calling ResizeImage(%lx,%lx)\n", this, screen)); CGX_DestroyImage(this, screen); + D(bug("after Destroy Image(%lx,%lx)\n", this, screen)); - if ( flags & SDL_OPENGL ) { /* No image when using GL */ - retval = 0; + if ( flags & SDL_OPENGL ) { /* No image when using include-GL */ + retval = 0; } else { retval = CGX_SetupImage(this, screen); /* We support asynchronous blitting on the display */ @@ -146,218 +281,264 @@ int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags) } } } - return(retval); + + return retval; } -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)); +#endif - if(surface==SDL_VideoSurface) - { +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=SDL_malloc(sizeof(struct private_hwdata)))) + if ( !surface->hwdata ) { + if ( !(surface->hwdata = malloc(sizeof(struct private_hwdata)))) return -1; } - surface->hwdata->mask=NULL; - surface->hwdata->lock=NULL; - surface->hwdata->videodata=this; - surface->hwdata->allocated=0; + surface->hwdata->mask = NULL; + surface->hwdata->lock = NULL; + surface->hwdata->videodata = this; + surface->hwdata->allocated = 0; - if(surface->hwdata->bmap=AllocBitMap(surface->w,surface->h,this->hidden->depth,BMF_MINPLANES,SDL_Display->RastPort.BitMap)) - { - surface->hwdata->allocated=1; - surface->flags|=SDL_HWSURFACE; + if ( surface->hwdata->bmap = AllocBitMap(surface->w, surface->h, this->hidden->depth, BMF_MINPLANES, SDL_Display->RastPort.BitMap)) { + + surface->hwdata->allocated = 1; + surface->flags |= SDL_HWSURFACE; D(bug("...OK\n")); + return 0; - } - else - { + } else { SDL_free(surface->hwdata); - surface->hwdata=NULL; + surface->hwdata = NULL; } - return(-1); + return -1; } -void CGX_FreeHWSurface(_THIS, SDL_Surface *surface) -{ - if(surface && surface!=SDL_VideoSurface && surface->hwdata) - { + +void CGX_FreeHWSurface(_THIS, SDL_Surface *surface) { + + if ( surface && surface != SDL_VideoSurface && surface->hwdata ) { D(bug("Free hw surface.\n")); - if(surface->hwdata->mask) + if ( surface->hwdata->mask ) SDL_free(surface->hwdata->mask); - if(surface->hwdata->bmap&&surface->hwdata->allocated) + if ( surface->hwdata->bmap && surface->hwdata->allocated ) FreeBitMap(surface->hwdata->bmap); SDL_free(surface->hwdata); - surface->hwdata=NULL; - surface->pixels=NULL; + surface->hwdata = NULL; + surface->pixels = NULL; D(bug("end of free hw surface\n")); } return; } -int CGX_LockHWSurface(_THIS, SDL_Surface *surface) -{ - if (surface->hwdata) - { -// D(bug("Locking a bitmap...\n")); - if(!surface->hwdata->lock) - { +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->bmap ) { + if ( !(surface->hwdata->lock = LockBitMapTags(surface->hwdata->bmap, LBMI_BASEADDRESS, (ULONG)&surface->pixels, LBMI_BYTESPERROW, (ULONG)&pitch, TAG_DONE))) + return -1; + } else { + if ( !(surface->hwdata->lock = LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, (ULONG)&surface->pixels, LBMI_BYTESPERROW, (ULONG)&pitch, TAG_DONE))) + return -1; + } + // surface->pitch e' a 16bit! - 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 ( this->hidden->dbscrollscreen == 1 ) { + if ( this->hidden->dbpos ) + surface->pixels += pitch * this->hidden->dbheight; + } - 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)); + // + //} - 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)); - } - D(else bug("Already locked!!!\n")); + } D(else bug("Already locked!!!\n")); } - return(0); + return (0); } -void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface) -{ - if(surface->hwdata && surface->hwdata->lock) - { +void CGX_UnlockHWSurface(_THIS, SDL_Surface *surface) { + if ( surface->hwdata && surface->hwdata->lock ) { UnLockBitMap(surface->hwdata->lock); - surface->hwdata->lock=NULL; -// surface->pixels=NULL; + surface->hwdata->lock = NULL; + //surface->pixels=0xdeadbeef; } } -int CGX_FlipHWSurface(_THIS, SDL_Surface *surface) -{ - static int current=0; +int CGX_FlipHWSurface(_THIS, SDL_Surface *surface) { - if(this->hidden->dbuffer) + /*if (skipframe) { - if(!SafeChange) - { - Wait(disp_sigbit); -// Non faccio nulla, vuoto solo la porta - while(GetMsg(dispport)!=NULL) - ; - SafeChange=TRUE; - } + if (toggle < skipframe){toggle++;return 0;} + toggle =0; + }*/ + static int current = 0; + int mustlock = 0; + ULONG pitch; - 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; + //surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap; + + /* */ + if ( surface->hwdata->lock ) { + UnLockBitMap(surface->hwdata->lock); + mustlock = 1; + } + if ((surface->hwdata->lock = LockBitMapTags(SDL_RastPort->BitMap, + LBMI_BASEADDRESS, (ULONG) & surface->pixels, + LBMI_BYTESPERROW, (ULONG) & pitch, TAG_DONE))) { + if ( !mustlock ) { + UnLockBitMap(surface->hwdata->lock); + surface->hwdata->lock = NULL; } + } - if(!SafeDisp) + if ( this->hidden->dbuffer ) // currently deactivate + { + int ret; + //SDL_UpdateRect(surface, 0, 0, 0, 0); + //surface->hwdata->bmap=SDL_RastPort->BitMap=this->hidden->SB[current]->sb_BitMap; + //current^=1; + if ( this->hidden->dbscrollscreen == 1 ) { + struct BitMap *bm; + +// this->hidden->dbpos ^= this->hidden->dbheight; /* swap positions */ + if ( this->hidden->dbpos ) + this->hidden->dbpos = 0; + else this->hidden->dbpos = 1; + + bm = &this->hidden->dbitmap; + if ( this->hidden->dbpos ) /* if lower portion is shown, use regular screen buffer */ + bm = SDL_Display->RastPort.BitMap; + + surface->hwdata->bmap = bm;//SDL_RastPort->BitMap=bm; + +// ScreenPosition( SDL_Display, SPOS_ABSOLUTE, 0, this->hidden->dbpos, 0, 0 ); +// WaitBOVP(&SDL_Display->ViewPort); + SDL_Display->ViewPort.RasInfo->RyOffset = (this->hidden->dbpos) ? this->hidden->dbheight : 0; + ScrollVPort(&SDL_Display->ViewPort); + +// printf("SCROLLING %d (%d)\n",this->hidden->dbpos,SDL_Display->Height); + } else /* dbscrollscreen */ { - Wait(safe_sigbit); - while(GetMsg(safeport)!=NULL) - ; - SafeDisp=TRUE; - } + if ( !SafeChange ) { + Wait(disp_sigbit); + //Non faccio nulla, vuoto solo la porta + while ( GetMsg(dispport) != NULL ); + SafeChange = TRUE; + } + ret = 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; + } + //SDL_Delay(1); + } /* dbscrollscreen */ } - return(0); + return (0); } /* Byte-swap the pixels in the display image */ -static void CGX_SwapAllPixels(SDL_Surface *screen) -{ +static void CGX_SwapAllPixels(SDL_Surface *screen) { int x, y; - switch (screen->format->BytesPerPixel) { - case 2: { - Uint16 *spot; - for ( y=0; yh; ++y ) { - spot = (Uint16 *) ((Uint8 *)screen->pixels + - y * screen->pitch); - for ( x=0; xw; ++x, ++spot ) { - *spot = SDL_Swap16(*spot); + 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; yh; ++y ) { - spot = (Uint32 *) ((Uint8 *)screen->pixels + - y * screen->pitch); - for ( x=0; xw; ++x, ++spot ) { - *spot = SDL_Swap32(*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; + break; - default: - /* should never get here */ - break; + default: + /* should never get here */ + break; } } -static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects) -{ + +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; ipixels + - y * screen->pitch + minx * 2); - for ( x=minx; xformat->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; ipixels + - y * screen->pitch + minx * 4); - for ( x=minx; xpixels + y * screen->pitch + minx * 4); + for ( x = minx; x < maxx; ++x, ++spot ) { + *spot = SDL_Swap32(*spot); + } } } } - } - break; + break; - default: - /* should never get here */ - break; + default: + /* should never get here */ + break; } } @@ -366,42 +547,82 @@ static void CGX_SwapPixels(SDL_Surface *screen, int numrects, SDL_Rect *rects) #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); +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_FakeUpdate(_THIS, int numrects, SDL_Rect *rects) { } -static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) -{ - int i,format,customroutine=0; + +static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) { + int i, format, customroutine = 0; + unsigned char *bm_address; + Uint32 destpitch; + unsigned long handle; #ifndef USE_CGX_WRITELUTPIXEL int bpp; + #endif - if(this->hidden->same_format && !use_picasso96) - { - format=RECTFMT_RAW; + if ( this->screen->flags & SDL_HWSURFACE ) { + if ( this->screen->hwdata->lock ) // if there is a lock(only sdl_benchmark i see do this) we need release the look before call bltbitmaprastport + { + UnLockBitMap(this->screen->hwdata->lock); + + for ( i = 0; i < numrects; ++i ) { + if ( !rects[i].w ) { /* Clipped? */ + continue; + } + BltBitMapRastPort(this->hidden->bmap, rects[i].x, rects[i].y, + SDL_Window->RPort, rects[i].x, rects[i].y, + rects[i].w, rects[i].h, 0xc0); + } + this->screen->hwdata->lock = LockBitMapTags(this->hidden->bmap, LBMI_BASEADDRESS, (ULONG) & this->screen->pixels, + LBMI_BYTESPERROW, (ULONG) & destpitch, TAG_DONE); + return; + } + for ( i = 0; i < numrects; ++i ) { + if ( !rects[i].w ) { /* Clipped? */ + continue; + } + if ( this->hidden->bmap ) + BltBitMapRastPort(this->hidden->bmap, rects[i].x, rects[i].y, + SDL_Window->RPort, rects[i].x, rects[i].y, + rects[i].w, rects[i].h, 0xc0); + } + + + return; } - else switch(this->screen->format->BytesPerPixel) - { +#ifdef APOLLO_BLITDBG + printf("CGX_NormalUpdate: Screen Flags %x format BPP %d software swap pixels\n",this->screen->flags,this->screen->format->BytesPerPixel); +#endif + + //if(this->hidden->same_format && !use_picasso96 && !this->hidden->swap_bytes) + //{ + // format=RECTFMT_RAW; + //} + //else + switch ( this->screen->format->BytesPerPixel ) { case 4: - format=RECTFMT_RGBA; + if ( this->screen->format->Rmask == 0xff0000 ) + format = RECTFMT_ARGB; + else + format = RECTFMT_RGBA; + //customroutine=1; break; case 3: - format=RECTFMT_RGB; + format = RECTFMT_RGB; break; case 2: - customroutine=1; + //format=RECTFMT_RGBA; + customroutine = 1; break; case 1: // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth)); - if(this->hidden->depth>8) - { + if ( this->hidden->depth > 8 ) { #ifndef USE_CGX_WRITELUTPIXEL if(this->hidden->depth>32) customroutine=4; @@ -414,50 +635,49 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) customroutine=3; #else - customroutine=2; + customroutine = 2; #endif - + // format=RECTFMT_LUT8; Vecchia funzione x usare la WritePixelArray. - } - else - customroutine=1; + } else + customroutine = 1; break; default: - D(bug("Unable to blit this surface!\n")); + 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("Software Swapping! SLOOOW!\n")); - CGX_SwapPixels(this->screen, numrects, rects); - for ( i=0; iscreen->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) - { + //if ( swap_pixels && + // ((this->screen->format->BytesPerPixel%2) == 0) ) { + // D(bug("Software Swapping! SLOOOW!\n")); + // CGX_SwapPixels(this->screen, numrects, rects); + // for ( i=0; iscreen->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; iscreen,&rects[i],SDL_RastPort,SDL_XPixels,SDL_Window); + + 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); - 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)) @@ -472,9 +692,9 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 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; + destbase=bm_address+(SDL_Window->TopEdge/*+SDL_Window->BorderTop*/)*destpitch+(/*SDL_Window->BorderLeft+*/SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - for ( i=0; iscreen->pixels))+rects[i].x; src+=(rects[i].y*this->screen->pitch); - + for(j=rects[i].h;j;--j) { dst=dest; @@ -525,9 +745,9 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 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; + destbase=bm_address+(SDL_Window->TopEdge/*+SDL_Window->BorderTop*/)*destpitch+(/*SDL_Window->BorderLeft+*/SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - for ( i=0; iscreen->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) @@ -577,9 +797,9 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) 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; + destbase=bm_address+(SDL_Window->TopEdge/*+SDL_Window->BorderTop*/)*destpitch+(/*SDL_Window->BorderLeft+*/SDL_Window->LeftEdge)*this->hidden->BytesPerPixel; - for ( i=0; iscreen->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) @@ -611,99 +831,151 @@ static void CGX_NormalUpdate(_THIS, int numrects, SDL_Rect *rects) UnLockBitMap(handle); } #endif - } - else if(customroutine) - { + } else if ( customroutine ) { unsigned char *bm_address; - Uint32 destpitch; + Uint32 destpitch; APTR handle; // D(bug("Using customroutine!\n")); +#ifdef APOLLO_BLITDBG + { + int tst1 = (this->hidden->bmap) ? 1 : 0 ; + int tst2 = (this->hidden->swap_bytes) ? 1 : 0; + + printf("CGX_NormalUpdate 16 Bit hiddenbmap %d swapbytes %d\n",tst1,tst2); + } +#endif + if ( !this->hidden->bmap ) { + handle = LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, (ULONG) & bm_address, + LBMI_BYTESPERROW, (ULONG) & destpitch, TAG_DONE); + if ( !handle )return; + + } else { + for ( i = 0; i < numrects; ++i ) { + if ( !rects[i].w ) { /* Clipped? */ + continue; + } + + BltBitMapRastPort(this->hidden->bmap, rects[i].x, rects[i].y, + SDL_RastPort,/*SDL_Window->BorderLeft+*/rects[i].x,/*SDL_Window->BorderTop+*/rects[i].y, + rects[i].w, rects[i].h, 0xc0); + } + return; + } - 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; + register int j, srcwidth; + register unsigned char *src, *dest; -// Aggiungo il bordo della finestra se sono fullscreen. - if(currently_fullscreen) - destbase=bm_address; + // 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; + destbase = bm_address + (SDL_Window->TopEdge + SDL_Window->BorderTop) * destpitch + (SDL_Window->BorderLeft + SDL_Window->LeftEdge) * this->screen->format->BytesPerPixel; - for ( i=0; iscreen->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; + 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) - { - SDL_memcpy(dest,src,srcwidth); - src+=this->screen->pitch; - dest+=destpitch; + for ( j = rects[i].h; j; --j ) { + + if ( this->hidden->swap_bytes ) { + bcopy_swap2(dest, src, srcwidth); + } else { + SDL_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; iscreen->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); + 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); } } } -void CGX_RefreshDisplay(_THIS) -{ - int format,customroutine=0; +// need on toggle fullscreen +void CGX_RefreshDisplay(_THIS) { + int i, format, customroutine = 0; + + unsigned char *bm_address; + Uint32 destpitch; + unsigned long handle; #ifndef USE_CGX_WRITELUTPIXEL int bpp; #endif - /* Don't refresh a display that doesn't have an image (like GL) */ - if ( ! SDL_Ximage ) { + /* Don't refresh a display that doesn't have an image (like include-GL) */ + if ( !SDL_Ximage) { return; } + if ( this->screen->flags & SDL_HWSURFACE ) { + if ( this->screen->hwdata->lock ) { + UnLockBitMap(this->screen->hwdata->lock); + BltBitMapRastPort(this->hidden->bmap, 0, 0, SDL_Window->RPort, 0, 0, this->screen->w, this->screen->h, 0xc0); - if(this->hidden->same_format && !use_picasso96) + this->screen->hwdata->lock = LockBitMapTags(this->hidden->bmap, LBMI_BASEADDRESS, (ULONG) & this->screen->pixels, LBMI_BYTESPERROW, (ULONG) & destpitch, TAG_DONE); + return; + } + if ( this->hidden->bmap ) + BltBitMapRastPort(this->hidden->bmap, 0, 0, SDL_Window->RPort, 0, 0, this->screen->w, this->screen->h, 0xc0); + return; + } +#ifdef APOLLO_BLITDBG + printf("CGX_RefreshDisplay: Screen Flags %x format BPP %d software swap pixels\n",this->screen->flags,this->screen->format->BytesPerPixel); +#endif + /*if(this->hidden->same_format && !use_picasso96) { format=RECTFMT_RAW; } - else switch(this->screen->format->BytesPerPixel) - { + else */switch ( this->screen->format->BytesPerPixel ) { case 4: - format=RECTFMT_RGBA; + if ( this->screen->format->Rmask == 0x00ff00 ) + format = RECTFMT_RAW; //RECTFMT_BGRA; (BGRA not supported by CGX) + else if ( this->screen->format->Rmask == 0xff0000 ) + format = RECTFMT_ARGB; + else + format = RECTFMT_RGBA; break; case 3: - format=RECTFMT_RGB; + format = RECTFMT_RGB; break; case 2: - customroutine=1; + //format=RECTFMT_RGB; + customroutine = 1; break; case 1: // D(bug("soft depth: 8 hardbpp: %ld\n",this->hidden->depth)); - if(this->hidden->depth>8) - { + if ( this->hidden->depth > 8 ) { #ifndef USE_CGX_WRITELUTPIXEL if(this->hidden->depth>32) customroutine=4; @@ -716,31 +988,23 @@ void CGX_RefreshDisplay(_THIS) customroutine=3; #else - customroutine=2; + customroutine = 2; #endif // format=RECTFMT_LUT8; - } - else - customroutine=1; + } else + customroutine = 1; break; } - /* Check for endian-swapped X server, swap if necessary */ - if ( swap_pixels && - ((this->screen->format->BytesPerPixel%2) == 0) ) { + /* 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); + USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, SDL_RastPort, 0/*SDL_Window->BorderLeft*/, 0/*SDL_Window->BorderTop*/, this->screen->w, this->screen->h, format); CGX_SwapAllPixels(this->screen); - } - else if (customroutine==2) - { + } 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); + WLUT(this->screen->pixels, 0, 0, this->screen->pitch, SDL_RastPort, SDL_XPixels, 0/*SDL_Window->BorderLeft*/, 0/*SDL_Window->BorderTop*/, this->screen->w, this->screen->h, CTABFMT_XRGB8); #else unsigned char *bm_address; Uint32 destpitch; @@ -753,18 +1017,18 @@ void CGX_RefreshDisplay(_THIS) register unsigned char *mask,*dst; register unsigned char *src,*dest; -// Aggiungo il bordo della finestra se sono fullscreen. + // 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; + 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 + // SLOW routine, used for 8->24 bit mapping for(k=0;kscreen->w;k++) { mask=(unsigned char *)(&SDL_XPixels[src[k]]); @@ -794,12 +1058,12 @@ void CGX_RefreshDisplay(_THIS) 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; + 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) @@ -832,12 +1096,12 @@ void CGX_RefreshDisplay(_THIS) 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; + 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) @@ -856,51 +1120,47 @@ void CGX_RefreshDisplay(_THIS) UnLockBitMap(handle); } #endif - } - else if(customroutine) - { + } else if ( customroutine ) { unsigned char *bm_address; - Uint32 destpitch; + Uint32 destpitch; APTR handle; + if ( !this->hidden->bmap ) { + handle = LockBitMapTags(SDL_RastPort->BitMap, LBMI_BASEADDRESS, (ULONG) & bm_address, + LBMI_BYTESPERROW, (ULONG) & destpitch, TAG_DONE); + if ( !handle )return; - if(handle=LockBitMapTags(SDL_RastPort->BitMap, - LBMI_BASEADDRESS,(ULONG)&bm_address, - LBMI_BYTESPERROW,(ULONG)&destpitch,TAG_DONE)) + } else { + BltBitMapRastPort(this->hidden->bmap, 0, 0, SDL_RastPort,/*SDL_Window->BorderLeft+*/0,/*SDL_Window->BorderTop+*/0, this->screen->w, this->screen->h, 0xc0); + + return; + } { register int j; - register unsigned char *src,*dest; + 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; + 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; + dest = bm_address; + + src = this->screen->pixels; - 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) - { - SDL_memcpy(dest,src,this->screen->pitch*this->screen->h); - } - else - { - for(j=this->screen->h;j;--j) - { - SDL_memcpy(dest,src,this->screen->pitch); - src+=this->screen->pitch; - dest+=destpitch; + if ( this->screen->pitch == destpitch ) { + SDL_memcpy(dest, src, this->screen->pitch * this->screen->h); + } else { + for ( j = this->screen->h; j; --j ) { + SDL_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); + } else { + USE_WPA(this->screen->pixels, 0, 0, this->screen->pitch, SDL_RastPort, 0 /*SDL_Window->BorderLeft*/, 0/*SDL_Window->BorderTop*/, this->screen->w, this->screen->h, format); } } diff --git a/src/video/cybergfx/SDL_cgxmodes.c b/src/video/cybergfx/SDL_cgxmodes.c index fdf7dbd29..1b230001d 100644 --- a/src/video/cybergfx/SDL_cgxmodes.c +++ b/src/video/cybergfx/SDL_cgxmodes.c @@ -23,135 +23,133 @@ /* Utilities for getting and setting the X display mode */ + +#include +#include + #include "SDL_timer.h" +#include "SDL_error.h" #include "SDL_events.h" #include "../../events/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; +#include "mydebug.h" - if(SDL_Display) - depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); +#ifdef AROS +#include "SDL_cgximage_c.h" +#include +#endif - idok=BestCModeIDTags(CYBRBIDTG_NominalWidth,width, - CYBRBIDTG_NominalHeight,height, - CYBRBIDTG_Depth,depth, - TAG_DONE); +#define CGX_DEBUG - if(idok!=INVALID_ID) - { - if(SDL_Display) - { - if(currently_fullscreen) +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); + D(bug(" depth %ld display id %ld \n", depth, idok)); + if ( idok != INVALID_ID ) { + if ( SDL_Display ) { + if ( currently_fullscreen) CloseScreen(SDL_Display); else - UnlockPubScreen(NULL,SDL_Display); + UnlockPubScreen(NULL, SDL_Display); } - SDL_Display=GFX_Display=OpenScreenTags(NULL,SA_Width,width,SA_Height,height, - SA_Depth,depth,SA_DisplayID,idok, - SA_ShowTitle,FALSE, - TAG_DONE); + SDL_Display = GFX_Display = OpenScreenTags(NULL, SA_Width, width, SA_Height, height, + SA_Depth, depth, SA_DisplayID, idok, + SA_ShowTitle, FALSE, + TAG_DONE); } } -static void get_real_resolution(_THIS, int* w, int* h) -{ - *w = /*SDL_Display->Width*/ SDL_Window->Width-SDL_Window->BorderLeft-SDL_Window->BorderRight; - *h = /*SDL_Display->Height*/ SDL_Window->Height-SDL_Window->BorderBottom-SDL_Window->BorderTop; +static void get_real_resolution(_THIS, int *w, int *h) { + *w = /*SDL_Display->Width*/ SDL_Window->Width - SDL_Window->BorderLeft - SDL_Window->BorderRight; + *h = /*SDL_Display->Height*/ SDL_Window->Height - SDL_Window->BorderBottom - SDL_Window->BorderTop; } -static void move_cursor_to(_THIS, int x, int y) -{ +static void move_cursor_to(_THIS, int x, int y) { /* XWarpPointer(SDL_Display, None, SDL_Root, 0, 0, 0, 0, x, y); */ /* DA FARE! */ } -static void add_visual(_THIS, int depth, int class) -{ - Uint32 tID; - - tID=BestCModeIDTags(CYBRBIDTG_Depth,depth, - CYBRBIDTG_NominalWidth,640, - CYBRBIDTG_NominalHeight,480, - TAG_DONE); +static void add_visual(_THIS, int depth, int class) { + Uint32 tID = BestCModeIDTags( + CYBRBIDTG_NominalWidth, 640, + CYBRBIDTG_NominalHeight, 480, + CYBRBIDTG_Depth, depth, + //CYBRBIDTG_BoardName,"UAE", + TAG_DONE); - if(tID!=INVALID_ID) - { + 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->visuals[n].bpp = GetCyberIDAttr(CYBRIDATTR_BPPIX, tID); this->hidden->nvisuals++; + } } #define TrueColor 1 #define PseudoColor 2 -int CGX_GetVideoModes(_THIS) -{ - int i; +int CGX_GetVideoModes(_THIS) { + int i; ULONG nextid; - int nmodes=0; + int nmodes = 0; - SDL_modelist=NULL; + SDL_modelist = NULL; - nextid=NextDisplayInfo(INVALID_ID); + nextid = NextDisplayInfo(INVALID_ID); - while(nextid!=INVALID_ID) - { - if(IsCyberModeID(nextid)) - { + while ( nextid != INVALID_ID ) { + if ( IsCyberModeID(nextid)) { DisplayInfoHandle h; - if(h=FindDisplayInfo(nextid)) - { + if ( h = FindDisplayInfo(nextid)) { struct DimensionInfo info; - if(GetDisplayInfoData(h,(char *)&info,sizeof(struct DimensionInfo),DTAG_DIMS,NULL)) - { - int ok=0; + if ( GetDisplayInfoData(h, (char *)&info, sizeof(struct DimensionInfo), DTAG_DIMS, NULL)) { + int ok = 0; - for(i=0;iw == (info.Nominal.MaxX+1) && - SDL_modelist[i]->h == (info.Nominal.MaxY+1) ) - ok=1; + 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) - { + if ( !ok ) { nmodes++; - SDL_modelist = (SDL_Rect **)SDL_realloc(SDL_modelist,(nmodes+1)*sizeof(SDL_Rect *)); - SDL_modelist[nmodes]=NULL; + 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 *)SDL_malloc(sizeof(SDL_Rect)); + if ( SDL_modelist) { + SDL_modelist[nmodes - 1] = (SDL_Rect *)malloc(sizeof(SDL_Rect)); - if ( SDL_modelist[nmodes-1] == NULL ) + 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; + 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); + nextid = NextDisplayInfo(nextid); } @@ -164,153 +162,182 @@ int CGX_GetVideoModes(_THIS) 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 ( this->hidden->nvisuals == 0 ) { + int n = this->hidden->nvisuals; + + SDL_SetError("Bug in BestCModeIDTags Found use 16 bit screen fallback \n"); + + this->hidden->visuals[n].depth = 16; + this->hidden->visuals[n].visual = 0x50011100; + this->hidden->visuals[n].bpp = 2; + this->hidden->nvisuals++; } - if ( SDL_modelist == NULL ) { - SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); - i = 0; - if ( SDL_modelist ) { - SDL_modelist[i] = (SDL_Rect *)SDL_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;ihidden->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); + if ( SDL_modelist == NULL ) { + SDL_modelist = (SDL_Rect **)SDL_malloc((1+1)*sizeof(SDL_Rect *)); + i = 0; + if (SDL_modelist) { + SDL_modelist[i] = (SDL_Rect *)SDL_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; + } } - ); - return 0; + + 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; +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; + 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); - } +SDL_Rect **CGX_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) { + + struct Screen *sc; + int depth; + if ( CGX_SupportedVisual(this, format)) { + if ( flags & SDL_FULLSCREEN ) { + return ((SDL_Rect * *) - 1); + } else { + + sc = LockPubScreen(0); + depth = GetCyberMapAttr(sc->RastPort.BitMap, CYBRMATTR_DEPTH); + UnlockPubScreen(0, sc); + if ( format->BitsPerPixel == depth ) { + D(bug("bits per pixel %ld ok\n", format->BitsPerPixel)); + return ((SDL_Rect * *) - 1); + } else { + D(bug("bits per pixel %ld we want not\n", format->BitsPerPixel)); + return ((SDL_Rect **)0); + } + } + } else { + return ((SDL_Rect **)0); + } } -void CGX_FreeVideoModes(_THIS) -{ - int i; - - if ( SDL_modelist ) { - for ( i=0; SDL_modelist[i]; ++i ) { - SDL_free(SDL_modelist[i]); - } - SDL_free(SDL_modelist); - SDL_modelist = NULL; - } +void CGX_FreeVideoModes(_THIS) { + int i; + + if ( SDL_modelist) { + for ( i = 0; SDL_modelist[i]; ++i ) { + SDL_free(SDL_modelist[i]); + } + SDL_free(SDL_modelist); + SDL_modelist = NULL; + } } -int CGX_ResizeFullScreen(_THIS) -{ - int x, y; - int real_w, real_h; +int CGX_ResizeFullScreen(_THIS) { + int x, y; + int real_w, real_h; - if ( currently_fullscreen ) { + if ( currently_fullscreen) { /* Per ora non faccio nulla qui */ - } - return(1); + } + return (1); } -void _QueueEnterFullScreen(_THIS) -{ +void _QueueEnterFullScreen(_THIS) { } -int CGX_EnterFullScreen(_THIS) -{ - int okay; - Uint32 saved_flags; - - okay = 1; - saved_flags = this->screen->flags; - - 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); +int CGX_EnterFullScreen(_THIS) { + int okay; + Uint32 saved_flags; + + okay = 1; + saved_flags = this->screen->flags; + + 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; - this->screen->flags = saved_flags; + currently_fullscreen = 1; + this->screen->flags = saved_flags; - CGX_CreateWindow(this,this->screen,real_w,real_h,GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH),this->screen->flags); + 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 */ + /* 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); + return(okay); } -int CGX_LeaveFullScreen(_THIS) -{ - if ( currently_fullscreen ) { - int width,height; - if ( SDL_Window ) { +int CGX_LeaveFullScreen(_THIS) { + if ( currently_fullscreen) { + int width, height; + if ( SDL_Window) { CloseWindow(SDL_Window); - SDL_Window=NULL; + SDL_Window = NULL; } CloseScreen(SDL_Display); - GFX_Display=SDL_Display=LockPubScreen(NULL); + GFX_Display = SDL_Display = LockPubScreen(NULL); - currently_fullscreen = 0; + 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); - } + 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); + return (0); } diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index e3067464d..aafc8a2db 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -26,14 +26,28 @@ * gabriele.greco@aruba.it */ + #include "SDL_endian.h" -#include "SDL_timer.h" -#include "SDL_thread.h" +#include +#include + +#ifdef MORPHOS +#include +#else + +#include +#include +#include + +#endif + #include "SDL_video.h" #include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" +#include "SDL_sysvideo.h" +#include "SDL_thread.h" + +#include "SDL_pixels_c.h" +#include "SDL_events_c.h" #include "SDL_cgxgl_c.h" #include "SDL_cgxvideo.h" #include "SDL_cgxwm_c.h" @@ -41,43 +55,76 @@ #include "SDL_amigaevents_c.h" #include "SDL_cgxmodes_c.h" #include "SDL_cgximage_c.h" +#include "SDL_cgxyuv_c.h" + +#ifdef APOLLO_BLIT +#include "apolloammxenable.h" +#endif + +#ifdef _AROS +#include +#include +#endif + +#include "mydebug.h" + +#ifdef __cplusplus +extern "C" { +#endif + +unsigned long _sdl_windowaddr; /* 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); +static struct SignalSemaphore sem; /* CGX driver bootstrap functions */ -struct Library *CyberGfxBase=NULL; -struct IntuitionBase *IntuitionBase=NULL; -struct GfxBase *GfxBase=NULL; +struct Library *CyberGfxBase = NULL; +struct IntuitionBase *IntuitionBase = NULL; +struct GfxBase *GfxBase = NULL; + +void SDL_AmigaLockWindow() { + ObtainSemaphore(&sem); +} + +void SDL_AmigaUnlockWindow() { + ReleaseSemaphore(&sem); +} -int CGX_SetGamma(_THIS, float red, float green, float blue) -{ - SDL_SetError("Gamma correction not supported"); - return -1; +struct Window *SDL_AmigaWindowAddr(void) { + return (struct Window *)_sdl_windowaddr; } -int CGX_GetGamma(_THIS, float red, float green, float blue) -{ - SDL_SetError("Gamma correction not supported"); - return -1; +int CGX_SetGamma(_THIS, float red, float green, float blue) { + SDL_SetError("Gamma correction not supported"); + return -1; } -int CGX_SetGammaRamp(_THIS, Uint16 *ramp) -{ +int CGX_GetGamma(_THIS, float red, float green, float blue) { + SDL_SetError("Gamma correction not supported"); + return -1; +} + +int CGX_SetGammaRamp(_THIS, Uint16 *ramp) { #if 0 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); + SDL_SetError("Gamma correction not supported on this visual"); + return(-1); } /* Calculate the appropriate palette for the given gamma ramp */ @@ -96,75 +143,73 @@ int CGX_SetGammaRamp(_THIS, Uint16 *ramp) return(0); #else - SDL_SetError("Gamma correction not supported on this visual"); - return(-1); + SDL_SetError("Gamma correction not supported on this visual"); + return (-1); #endif } -static void DestroyScreen(_THIS) -{ - if(currently_fullscreen) - { - if(this->hidden->dbuffer) - { - extern struct MsgPort *safeport,*dispport; +static void DestroyScreen(_THIS) { + if ( currently_fullscreen) { + if ( this->hidden->dbuffer == 2 ) { + this->hidden->dbuffer = 0; - this->hidden->dbuffer=0; + if ( SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort ) + free(SDL_RastPort); + SDL_RastPort = NULL; + } + if ( this->hidden->dbuffer == 1 ) { + extern struct MsgPort *safeport, *dispport; - if(safeport) - { - while(GetMsg(safeport)!=NULL); + this->hidden->dbuffer = 0; + + if ( safeport ) { + while ( GetMsg(safeport) != NULL ); DeleteMsgPort(safeport); } - if(dispport) - { - while(GetMsg(dispport)!=NULL); + 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; + 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[1]); - if(this->hidden->SB[0]) - FreeScreenBuffer(SDL_Display,this->hidden->SB[0]); + if ( this->hidden->SB[1] ) + FreeScreenBuffer(SDL_Display, this->hidden->SB[1]); + if ( this->hidden->SB[0] ) + FreeScreenBuffer(SDL_Display, this->hidden->SB[0]); - this->hidden->SB[0]=this->hidden->SB[1]=NULL; + this->hidden->SB[0] = this->hidden->SB[1] = NULL; - if(SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort) + if ( SDL_RastPort && SDL_RastPort != &SDL_Display->RastPort ) SDL_free(SDL_RastPort); - SDL_RastPort=NULL; + SDL_RastPort = NULL; } CloseScreen(GFX_Display); - currently_fullscreen=0; - } - else if(GFX_Display) - UnlockPubScreen(NULL,GFX_Display); + currently_fullscreen = 0; + } else if ( GFX_Display) + UnlockPubScreen(NULL, GFX_Display); GFX_Display = NULL; } -static int CGX_Available(void) -{ +static int CGX_Available(void) { struct Library *l; - l = OpenLibrary("cybergraphics.library",0L); + l = OpenLibrary("cybergraphics.library", 0L); if ( l != NULL ) { D(bug("CGX video device AVAILABLE\n")); CloseLibrary(l); - } - D(else bug("**CGX video device UNAVAILABLE\n")); + } D(else bug("**CGX video device UNAVAILABLE\n")); - return(l != NULL); + return (l != NULL); } -static void CGX_DeleteDevice(SDL_VideoDevice *device) -{ +static void CGX_DeleteDevice(SDL_VideoDevice *device) { if ( device ) { if ( device->hidden ) { SDL_free(device->hidden); @@ -176,25 +221,23 @@ static void CGX_DeleteDevice(SDL_VideoDevice *device) } } -static SDL_VideoDevice *CGX_CreateDevice(int devindex) -{ +static SDL_VideoDevice *CGX_CreateDevice(int devindex) { SDL_VideoDevice *device; - + InitSemaphore(&sem); /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); if ( device ) { - SDL_memset(device, 0, (sizeof *device)); + memset(device, 0, (sizeof *device)); device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); + malloc((sizeof *device->hidden)); device->gl_data = (struct SDL_PrivateGLData *) - SDL_malloc((sizeof *device->gl_data)); + malloc((sizeof *device->gl_data)); } - if ( (device == NULL) || (device->hidden == NULL) || - (device->gl_data == NULL) ) { + if ((device == NULL) || (device->hidden == NULL) || (device->gl_data == NULL)) { D(bug("Unable to create video device!\n")); SDL_OutOfMemory(); CGX_DeleteDevice(device); - return(0); + return (0); } SDL_memset(device->hidden, 0, sizeof(*device->hidden)); SDL_memset(device->gl_data, 0, sizeof(*device->gl_data)); @@ -208,13 +251,16 @@ static SDL_VideoDevice *CGX_CreateDevice(int devindex) device->SetVideoMode = CGX_SetVideoMode; device->ToggleFullScreen = CGX_ToggleFullScreen; device->UpdateMouse = CGX_UpdateMouse; +#ifdef XFREE86_XV + device->CreateYUVOverlay = X11_CreateYUVOverlay; +#endif 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->SetHWColorKey = NULL;//CGX_SetHWColorKey; device->SetHWAlpha = NULL; device->LockHWSurface = CGX_LockHWSurface; device->UnlockHWSurface = CGX_UnlockHWSurface; @@ -253,137 +299,142 @@ VideoBootStrap CGX_bootstrap = { "CGX", "AmigaOS CyberGraphics", CGX_Available, CGX_CreateDevice }; -Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) -{ - D(if(type==0)bug("REAL pixel format: ")); +Uint32 MakeBitMask(_THIS, int type, int format, int *bpp, struct SDL_Surface *screen) { + D(if ( type == 0 )bug("REAL pixel format: ")); - if(this->hidden->depth==*bpp) - { + if ( this->hidden->depth == *bpp ) { + D(bug("Pixel Format %ld\n", format)); + 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: + return 0; + break; + case PIXFMT_RGB16: - 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; - } + switch ( type ) { + case 0: - 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: ")); + return 63488; + case 1: + return 2016; + case 2: + return 31; + } + case PIXFMT_BGR16: + case PIXFMT_RGB16PC: + switch ( type ) { + case 0: + return 0; + //return 0b11111000; //248 + return 248; // old - switch(*bpp) - { + //return 0x7C00; + case 1: + return 0; + //return 0b110000000000111; + //return 24583; + return 57351; // old + + + case 2: + return 0; + //return 0b1111100000000; //7936 + return 7936; // old + + } + + 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")); + if ( screen && (screen->flags & SDL_HWSURFACE)) { return 0x00ff00; } + return 0xff000000; + case 1: + if ( screen && (screen->flags & SDL_HWSURFACE)) { return 0xff0000; } //green + return 0x00ff0000; + case 2: + if ( screen && (screen->flags & SDL_HWSURFACE))return 0xff000000; //blue + return 0x0000ff00; + + } + 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) - { + D(if ( type == 0 ) bug("RGBA32\n")); + switch ( type ) { case 0: return 0xff000000; case 1: @@ -393,9 +444,8 @@ Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) } break; case 24: -use_truecolor: - switch(type) - { + use_truecolor: + switch ( type ) { case 0: D(bug("RGB24\n")); return 0xff0000; @@ -406,12 +456,13 @@ Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) } case 16: case 15: - D(if(type==0) bug("Not supported, switching to 24bit!\n")); - *bpp=24; + 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")); + D(if ( type == 0 )bug("This is a chunky display\n")); // For chunky display mask is always 0; return 0; } @@ -419,40 +470,72 @@ Uint32 MakeBitMask(_THIS,int type,int format,int *bpp) return 0; } -static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) -{ +static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) { int i; + char *test; struct Library *RTGBase; + int bpp; + + bpp = vformat->BitsPerPixel; + D(bug("VideoInit... Opening libraries\n")); - if(!IntuitionBase) { - if( !(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",39L))) { + if ( !IntuitionBase ) { + if ( !(IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 39L))) { SDL_SetError("Couldn't open intuition V39+"); return -1; } } - if(!GfxBase) { - if( !(GfxBase=(struct GfxBase *)OpenLibrary("graphics.library",39L))) { + if ( !GfxBase ) { + if ( !(GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 39L))) { SDL_SetError("Couldn't open graphics V39+"); return -1; } } - if(!CyberGfxBase) { - if( !(CyberGfxBase=OpenLibrary("cybergraphics.library",40L))) { + if ( !CyberGfxBase ) { + if ( !(CyberGfxBase = OpenLibrary("cybergraphics.library", 40L))) { SDL_SetError("Couldn't open cybergraphics."); - return(-1); + return (-1); } } - if(RTGBase=OpenLibrary("libs:picasso96/rtg.library",0L)) { - extern int use_picasso96; +// enable AMMX for Apollo Core +#ifdef APOLLO_BLIT + if( !Apollo_EnableAMMX() ) + { + /* abort for Apollo builds -> disabled for now, current code is m68k clean */ +#if 0 + struct EasyStruct myES = + { + sizeof(struct EasyStruct), + 0, + "Amiga include Error", + "Cannot initialize include CGXVideo on this computer\nThis is an AMMX include build for Apollo Core\nand AMMX could not be detected.", + "Abort", + }; + EasyRequest(NULL, &myES, NULL ); + + SDL_SetError("Couldn't find active Apollo Core AMMX."); + return(-1); +#endif + } +#endif - CloseLibrary(RTGBase); - use_picasso96=1; +// check if P96 is present and if we don't need the fix +#ifndef AROS + test = getenv("USE_P96_FIX"); + if ( test && *test != '0' ) { + if ( RTGBase = OpenLibrary("libs:picasso96/rtg.library", 0L)) { + extern int use_picasso96; + + CloseLibrary(RTGBase); + use_picasso96 = 1; + } } +#endif D(bug("Library intialized, locking screen...\n")); @@ -461,176 +544,199 @@ static int CGX_VideoInit(_THIS, SDL_PixelFormat *vformat) if ( SDL_Display == NULL ) { D(bug("Cannot lock display...\n")); SDL_SetError("Couldn't lock the display"); - return(-1); + return (-1); } - this->info.current_w = SDL_Display->Width; - this->info.current_h = SDL_Display->Height; D(bug("Checking if we are using a CGX native display...\n")); - if(!IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort))) - { - Uint32 okid=BestCModeIDTags(CYBRBIDTG_NominalWidth,SDL_Display->Width, - CYBRBIDTG_NominalHeight,SDL_Display->Height, - CYBRBIDTG_Depth,8, - TAG_DONE); + if ( !IsCyberModeID(GetVPModeID(&SDL_Display->ViewPort)) ) { //selden reach + + Uint32 okid = INVALID_ID; + if ( bpp == 32 ) { + UWORD pixfmt[] = { PIXFMT_BGRA32, -1 }; + unsigned long *ret; + struct CyberModeNode *cnode; + ret = AllocCModeListTags(CYBRMREQ_MinWidth, SDL_Display->Width, CYBRMREQ_MinHeight, SDL_Display->Height, + CYBRMREQ_MaxWidth, SDL_Display->Width + 1000, CYBRMREQ_MaxHeight, SDL_Display->Height + 1000, + CYBRMREQ_MaxDepth, bpp, CYBRMREQ_MinDepth, bpp, CYBRMREQ_CModelArray, &pixfmt); + if ( ret ) { + cnode = *ret; + if ( cnode )okid = cnode->DisplayID; + } + } + if ( bpp == 16 ) { + UWORD pixfmt[] = { PIXFMT_RGB16, -1 }; + unsigned long *ret; + struct CyberModeNode *cnode; + ret = AllocCModeListTags(CYBRMREQ_MinWidth, SDL_Display->Width, CYBRMREQ_MinHeight, SDL_Display->Height, + CYBRMREQ_MaxWidth, SDL_Display->Width + 1000, CYBRMREQ_MaxHeight, SDL_Display->Height + 1000, + CYBRMREQ_MaxDepth, bpp, CYBRMREQ_MinDepth, 16, CYBRMREQ_CModelArray, &pixfmt); + if ( ret ) { + cnode = *ret; + if ( cnode )okid = cnode->DisplayID; + } + } + D(bug("%screenmode ID%ld\n", okid)); + if ( okid == INVALID_ID ) { + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, SDL_Display->Width, + CYBRBIDTG_NominalHeight, SDL_Display->Height, + CYBRBIDTG_Depth, bpp, + TAG_DONE); + } - D(bug("Default visual is not CGX native!\n")); - UnlockPubScreen(NULL,SDL_Display); + UnlockPubScreen(NULL, SDL_Display); - GFX_Display=NULL; + 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 ( okid != INVALID_ID ) { //selden reach - if(!GFX_Display) - { + GFX_Display = OpenScreenTags(NULL, + //SA_Width,SDL_Display->Width, + //SA_Height,SDL_Display->Height, + SA_Title, "include Screen", + SA_Depth, bpp, SA_Quiet, TRUE, + SA_ShowTitle, FALSE, + SA_DisplayID, okid, + TAG_DONE); + } else + D(bug("Cant get a valid screenmode ID with BestCModeIDTags\n")); + + if ( !GFX_Display) { SDL_SetError("Unable to open a suited CGX display"); return -1; - } - else SDL_Display=GFX_Display; + } else + SDL_Display = GFX_Display; - } - else GFX_Display = SDL_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; - } - + // Non e' detto che sia cosi' pero', alcune schede potrebbero gestire i modi in modo differente D(bug("Before GetVideoModes....\n")); /* Get the available video modes */ - if(CGX_GetVideoModes(this) < 0) - return -1; + 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; + 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; // SDL_XColorMap = SDL_DisplayColormap; this->hidden->depth = this->hidden->visuals[i].depth; - D(bug("Init: Setting screen depth to: %ld\n",this->hidden->depth)); vformat->BitsPerPixel = this->hidden->visuals[i].depth; /* this->hidden->visuals[i].bpp; */ + D(bug("depth %ld hidden depth %ld\n", vformat->BitsPerPixel, this->hidden->depth)); { int form; APTR handle; struct DisplayInfo info; - if(!(handle=FindDisplayInfo(this->hidden->visuals[i].visual))) - { + if ( !(handle = FindDisplayInfo(this->hidden->visuals[i].visual))) { D(bug("Unable to get visual info...\n")); return -1; } - if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) { + if ( !GetDisplayInfoData(handle, (char *)&info, sizeof(struct DisplayInfo), DTAG_DISP, NULL)) { D(bug("Unable to get visual info data...\n")); return -1; } - form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); + 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 + // 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, 0); + vformat->Gmask = MakeBitMask(this, 1, form, &this->hidden->depth, 0); + vformat->Bmask = MakeBitMask(this, 2, form, &this->hidden->depth, 0); - 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); } } /* See if we have been passed a window to use */ -/* SDL_windowid = SDL_getenv("SDL_WINDOWID"); */ - SDL_windowid=NULL; +/* SDL_windowid = getenv("SDL_WINDOWID"); */ + SDL_windowid = NULL; /* Create the blank cursor */ - SDL_BlankCursor = AllocMem(16,MEMF_CHIP|MEMF_CLEAR); + SDL_BlankCursor = AllocMem(16, MEMF_CHIP | MEMF_CLEAR); /* Fill in some window manager capabilities */ this->info.wm_available = 1; + this->info.hw_available = 1; this->info.blit_hw = 1; - this->info.blit_hw_CC = 1; + this->info.blit_hw_CC = 0; 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->info.video_mem = 8000; // Not always true but almost any Amiga card has this memory! - this->hidden->same_format=0; - SDL_RastPort=&SDL_Display->RastPort; + this->hidden->same_format = 0; + SDL_RastPort = &SDL_Display->RastPort; /* We're done! */ D(bug("End of CGX_VideoInit\n")); - return(0); + return (0); } -void CGX_DestroyWindow(_THIS, SDL_Surface *screen) -{ +void CGX_DestroyWindow(_THIS, SDL_Surface *screen) { D(bug("Destroy Window...\n")); - if ( ! SDL_windowid ) { + if ( !SDL_windowid) { /* Hide the managed window */ - int was_fullscreen=0; + int was_fullscreen = 0; /* Clean up OpenGL */ if ( screen ) { - screen->flags &= ~(SDL_OPENGL|SDL_OPENGLBLIT); + screen->flags &= ~(SDL_OPENGL | SDL_OPENGLBLIT); } - if ( screen && (screen->flags & SDL_FULLSCREEN) ) { - was_fullscreen=1; + if ( screen && (screen->flags & SDL_FULLSCREEN)) { + was_fullscreen = 1; screen->flags &= ~SDL_FULLSCREEN; // CGX_LeaveFullScreen(this); tolto x crash } /* Destroy the output window */ - if ( SDL_Window ) { + SDL_AmigaLockWindow(); + if ( SDL_Window) { CloseWindow(SDL_Window); - SDL_Window=NULL; + if ( SDL_Window_Background)CloseWindow(SDL_Window_Background); + SDL_Window = NULL; + _sdl_windowaddr = 0; + SDL_Window_Background = NULL; + } + SDL_AmigaUnlockWindow(); /* Free the colormap entries */ - if ( SDL_XPixels ) { + if ( SDL_XPixels) { int numcolors; unsigned long pixel; - if(this->screen->format&&this->hidden->depth==8&&!was_fullscreen) - { - numcolors = 1<screen->format->BitsPerPixel; + if ( this->screen->format && this->hidden->depth == 8 && !was_fullscreen ) { + numcolors = 1 << this->screen->format->BitsPerPixel; - if(numcolors>256) - numcolors=256; + if ( numcolors > 256 ) + numcolors = 256; - if(!was_fullscreen&&this->hidden->depth==8) - { - for ( pixel=0; pixel=0) - ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); + 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]); } } } @@ -640,108 +746,89 @@ void CGX_DestroyWindow(_THIS, SDL_Surface *screen) } } -static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) -{ +static void CGX_SetSizeHints(_THIS, int w, int h, Uint32 flags) { if ( flags & SDL_RESIZABLE ) { - WindowLimits(SDL_Window, 32, 32,4096,4096); + WindowLimits(SDL_Window, 32, 32, 4096, 4096); } else { - WindowLimits(SDL_Window, w,h,w,h); + WindowLimits(SDL_Window, w, h, w, h); } if ( flags & SDL_FULLSCREEN ) { - flags&=~SDL_RESIZABLE; - } else if ( SDL_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); + 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) -{ + int w, int h, int bpp, Uint32 flags) { #if 0 int i, depth; Uint32 vis; #endif - D(bug("CGX_CreateWindow\n")); + D(bug("CGX_CreateWindow %d\n", bpp)); /* If a window is already present, destroy it and start fresh */ - if ( SDL_Window ) { + if ( SDL_Window) { CGX_DestroyWindow(this, screen); } - + // if ( (screen->flags&SDL_FULLSCREEN) != SDL_FULLSCREEN ) { + // /* There's no windowed double-buffering */ + // screen->flags &= ~SDL_DOUBLEBUF; + //} /* See if we have been given a window id */ - if ( SDL_windowid ) { + if ( SDL_windowid) { SDL_Window = (struct Window *)atol(SDL_windowid); } else { 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("Setting screen depth to: %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))) + if ( !(handle = FindDisplayInfo(SDL_Visual))) return -1; - if(!GetDisplayInfoData(handle,(char *)&info,sizeof(struct DisplayInfo),DTAG_DISP,NULL)) + if ( !GetDisplayInfoData(handle, (char *)&info, sizeof(struct DisplayInfo), DTAG_DISP, NULL)) return -1; - form=GetCyberIDAttr(CYBRIDATTR_PIXFMT,SDL_Visual); + 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)); - if(flags&SDL_HWSURFACE) - { - if(bpp!=this->hidden->depth) - { - bpp=this->hidden->depth; - D(bug("Accel forces bpp to be equal (%ld)\n",bpp)); } } + if ( flags & SDL_HWSURFACE )screen->flags |= SDL_HWSURFACE; + - D(bug("BEFORE screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); + 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) ) + + if ( !SDL_ReallocFormat(screen, bpp, + MakeBitMask(this, 0, form, &bpp, screen), MakeBitMask(this, 1, form, &bpp, screen), MakeBitMask(this, 2, form, &bpp, screen), 0)) return -1; - D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n",bpp,this->hidden->depth)); + D(bug("AFTER screen allocation: bpp:%ld (real:%ld)\n", bpp, this->hidden->depth)); } @@ -751,106 +838,141 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, XFreeColormap(SDL_Display, SDL_XColorMap); } */ - if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT)==PIXFMT_LUT8 || bpp==8 ) { - int ncolors,i; - D(bug("XPixels palette allocation...\n")); + if ( GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_PIXFMT) == PIXFMT_LUT8 || bpp == 8 ) { + int ncolors, i; + D(bug("XPixels palette allocation...\n")); - /* Allocate the pixel flags */ + /* Allocate the pixel flags */ - if(bpp==8) - ncolors=256; - else - ncolors = 1 << screen->format->BitsPerPixel; + if ( bpp == 8 ) + ncolors = 256; + else + ncolors = 1 << screen->format->BitsPerPixel; - SDL_XPixels = (Sint32 *)SDL_malloc(ncolors * sizeof(Sint32)); + SDL_XPixels = (Sint32 *)malloc(ncolors * sizeof(Sint32)); - if(SDL_XPixels == NULL) { - SDL_OutOfMemory(); - return -1; - } + if ( SDL_XPixels == NULL ) { + SDL_OutOfMemory(); + return -1; + } - for(i=0;iflags |= SDL_HWPALETTE; - } + } /* resize the (possibly new) window manager window */ /* Create (or use) the X11 display window */ - if ( !SDL_windowid ) { - 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); + if ( !SDL_windowid) { + int left = (SDL_Display->Width - w) / 2; + int top = (SDL_Display->Height - h) / 2; + if ( left < 0 )left = 0; + if ( top < 0 )top = 0; - D(bug("Opening backdrop window %ldx%ld on display %lx!\n",w,h,SDL_Display)); + if ( flags & SDL_FULLSCREEN ) { + + //SetAPen(&sc->RastPort,1); // rest of display should be black + //RectFill(&sc->RastPort,0,0,w-1,h-1); + if ( left != 0 || top != 0 ) { + SDL_Window_Background = OpenWindowTags(NULL, WA_Left, 0, WA_Top, 0, + WA_Flags, WFLG_SIMPLE_REFRESH | WFLG_ACTIVATE | WFLG_RMBTRAP | WFLG_BORDERLESS | WFLG_BACKDROP + /*|WFLG_REPORTMOUSE */, + WA_IDCMP, 0, + //WA_Title,"include Backgroundwindow", + WA_CustomScreen, (ULONG)SDL_Display, + TAG_DONE); } - else - { - /* Create GimmeZeroZero window when OpenGL is used */ - unsigned long gzz = FALSE; - if( flags & SDL_OPENGL ) { - gzz = TRUE; - } + if ( SDL_Window_Background) { + SetAPen(SDL_Window_Background->RPort, 1); // rest of display should be black + RectFill(SDL_Window_Background->RPort, 0, 0, SDL_Window_Background->Width - 1, SDL_Window_Background->Height); + } + SDL_Window = OpenWindowTags(NULL, WA_Left, left, WA_Top, top, WA_Width, w, WA_Height, h, + WA_Flags, WFLG_ACTIVATE | WFLG_RMBTRAP | WFLG_BORDERLESS | WFLG_REPORTMOUSE, + WA_IDCMP, IDCMP_RAWKEY | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW, + WA_CustomScreen, (ULONG)SDL_Display, + TAG_DONE); + if ( SDL_Window) { - SDL_Window = OpenWindowTags(NULL,WA_InnerWidth,w,WA_InnerHeight,h, - WA_Flags,WFLG_REPORTMOUSE|WFLG_ACTIVATE|WFLG_RMBTRAP | ((flags&SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET|WFLG_CLOSEGADGET|WFLG_DRAGBAR | ((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, - WA_GimmeZeroZero, gzz, - TAG_DONE); - D(bug("Opening WB window of size: %ldx%ld!\n",w,h)); + + //ChangeWindowBox(SDL_Window,left,top,w,h); } + D(bug("Opening backdrop window %ldx%ld on display %lx!\n", w, h, SDL_Display)); + } else { + /* Create GimmeZeroZero window when OpenGL is used */ + unsigned long gzz = TRUE; + /*if( flags & SDL_OPENGL ) { + gzz = TRUE; + }*/ + + SDL_Window = OpenWindowTags(NULL, WA_Left, left, WA_Top, top, WA_InnerWidth, w, WA_InnerHeight, h, + WA_Flags, WFLG_REPORTMOUSE | WFLG_ACTIVATE | WFLG_RMBTRAP | ((flags & SDL_NOFRAME) ? 0 : (WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_DRAGBAR | ((flags & SDL_RESIZABLE) ? WFLG_SIZEGADGET | WFLG_SIZEBBOTTOM : 0))), + WA_IDCMP, IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE | IDCMP_MOUSEMOVE | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW, + WA_PubScreen, (ULONG)SDL_Display, + WA_GimmeZeroZero, gzz, + TAG_DONE); + + D(bug("Opening WB window of size: %ldx%ld!\n", w, h)); + } - if(!SDL_Window) + if ( !SDL_Window) return -1; } + this->hidden->swap_bytes = 0; + if ((flags & SDL_OPENGL) == 0 ) { + switch ( GetCyberMapAttr(SDL_Window->RPort->BitMap, CYBRMATTR_PIXFMT)) { + //case PIXFMT_RGB15PC: + case PIXFMT_RGB16PC: + case PIXFMT_BGR16PC: + this->hidden->swap_bytes = 1; + break; + case PIXFMT_BGRA32: - this->hidden->BytesPerPixel=GetCyberMapAttr(SDL_Window->RPort->BitMap,CYBRMATTR_BPPIX); - - if(screen->flags & SDL_DOUBLEBUF) - { - if(SDL_RastPort=SDL_malloc(sizeof(struct RastPort))) - { - InitRastPort(SDL_RastPort); - SDL_RastPort->BitMap=this->hidden->SB[1]->sb_BitMap; + //this->hidden->swap_bytes = 1; + break; } - else - return -1; } - else SDL_RastPort=SDL_Window->RPort; + this->hidden->BytesPerPixel = GetCyberMapAttr(SDL_Window->RPort->BitMap, CYBRMATTR_BPPIX); + { + long val = this->hidden->BytesPerPixel; + } + if ( screen->flags & SDL_DOUBLEBUF ) { + if ( SDL_RastPort = malloc(sizeof(struct RastPort))) { + InitRastPort(SDL_RastPort); + if ( this->hidden->dbscrollscreen == 1 ) /* use scrolling screen for double buffer */ + { +// SDL_RastPort->BitMap=SDL_Display->RastPort.BitMap; + SDL_RastPort->BitMap = &this->hidden->dbitmap; + } else + SDL_RastPort->BitMap = this->hidden->SB[1]->sb_BitMap; - if(flags&SDL_HWSURFACE) - screen->flags|=SDL_HWSURFACE; + } else + return -1; + } else + SDL_RastPort = SDL_Window->RPort; - if( !SDL_windowid ) { - CGX_SetSizeHints(this, w, h, flags); - } - /* Set our colormaps when not setting a GL mode */ -/* - if ( ! (flags & SDL_OPENGL) ) { - XSetWindowColormap(SDL_Display, SDL_Window, SDL_XColorMap); + if ( !SDL_windowid) { + CGX_SetSizeHints(this, w, h, flags); + current_w = w; + current_h = h; } -*/ /* Map them both and go fullscreen, if requested */ - if ( ! SDL_windowid ) { + if ( !SDL_windowid) { if ( flags & SDL_FULLSCREEN ) { screen->flags |= SDL_FULLSCREEN; - currently_fullscreen=1; -// CGX_EnterFullScreen(this); Ci siamo gia'! + currently_fullscreen = 1; + + //CGX_EnterFullScreen(this); //Ci siamo gia'! } else { screen->flags &= ~SDL_FULLSCREEN; } @@ -858,198 +980,297 @@ int CGX_CreateWindow(_THIS, SDL_Surface *screen, screen->w = w; screen->h = h; screen->pitch = SDL_CalculatePitch(screen); - CGX_ResizeImage(this, screen, flags); + if ( CGX_ResizeImage(this, screen, flags) < 0 )return -1; /* Make OpenGL Context if needed*/ - if(flags & SDL_OPENGL) { - if(this->gl_data->gl_active == 0) { - if(CGX_GL_Init(this) < 0) + if ( flags & SDL_OPENGL ) { + + if ( this->gl_data->gl_active == 0 ) { + if ( CGX_GL_Init(this) < 0 ) return -1; else screen->flags |= SDL_OPENGL; - } - else { - if(CGX_GL_Update(this) < 0) + } else { + if ( CGX_GL_Update(this) < 0 ) return -1; else screen->flags |= SDL_OPENGL; } } + _sdl_windowaddr = SDL_Window; + return 0; } int CGX_ResizeWindow(_THIS, - SDL_Surface *screen, int w, int h, Uint32 flags) -{ + SDL_Surface *screen, int w, int h, Uint32 flags) { + int retval = -1; D(bug("CGX_ResizeWindow\n")); - - if ( ! SDL_windowid ) { + if ( !SDL_windowid) { /* 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); + ChangeWindowBox(SDL_Window, SDL_Window->LeftEdge, SDL_Window->TopEdge, w + SDL_Window->BorderLeft + SDL_Window->BorderRight, + h + SDL_Window->BorderTop + SDL_Window->BorderBottom); screen->w = w; screen->h = h; screen->pitch = SDL_CalculatePitch(screen); - CGX_ResizeImage(this, screen, flags); + retval = CGX_ResizeImage(this, screen, flags); } - return(0); + return (retval); } static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, - int width, int height, int bpp, Uint32 flags) -{ + int width, int height, int bpp, Uint32 flags) { Uint32 saved_flags; - int needcreate=0; - - D(bug("CGX_SetVideoMode current:%lx\n",current)); + int needcreate = 0; + D(bug("CGX_SetVideoMode current:%lx\n", current)); +#ifdef APOLLO_BLIT + if( !Apollo_AMMXon ) + flags &= ~SDL_DOUBLEBUF; +#endif + //printf("flags %x dbfl %x\n",flags,SDL_DOUBLEBUF); /* Lock the event thread, in multi-threading environments */ SDL_Lock_EventThread(); + SDL_AmigaLockWindow(); // Check if the window needs to be closed or can be resized - if( (flags&SDL_FULLSCREEN) || (current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN))) - needcreate=1; + if ((flags & SDL_FULLSCREEN) || (current && current->flags & SDL_FULLSCREEN && !(flags & SDL_FULLSCREEN))) + needcreate = 1; // Check if we need to close an already existing videomode... - - if(current && current->flags&SDL_FULLSCREEN && !(flags&SDL_FULLSCREEN)) { + if ( current && current->flags & SDL_FULLSCREEN && !(flags & SDL_FULLSCREEN)) { unsigned long i; D(bug("Destroying image, window & screen!\n")); - CGX_DestroyImage(this,current); - CGX_DestroyWindow(this,current); + CGX_DestroyImage(this, current); + CGX_DestroyWindow(this, current); DestroyScreen(this); - GFX_Display=SDL_Display=LockPubScreen(NULL); - - bpp=this->hidden->depth=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH); + GFX_Display = SDL_Display = LockPubScreen(NULL); + bpp = this->hidden->depth = GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_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 */ + return NULL; /* should never happen */ } SDL_Visual = this->hidden->visuals[i].visual; - D(bug("Setting screen depth to: %ld\n",this->hidden->depth)); + D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); } /* Check the combination of flags we were passed */ if ( flags & SDL_FULLSCREEN ) { int i; + int swidth, sheight; + int dbscroll = 1; /* def: we can use a scrolling screen for doublebuffer */ +#ifndef APOLLO_BLIT + dbscroll = 0; /* disable except from Apollo SAGA driver (for now, needs testing on other HW) */ +#endif + if ( flags & SDL_DOUBLEBUF ) { + //printf("doublebuf requested\n"); + } else { + dbscroll = 0; + //printf("doublebuf not set\n"); + } /* Clear fullscreen flag if not supported */ - if ( SDL_windowid ) { + if ( SDL_windowid) { flags &= ~SDL_FULLSCREEN; - } - else if(current && current->flags&SDL_FULLSCREEN ) { - if(current->w!=width || - current->h!=height || - (this->hidden && this->hidden->depth!=bpp)) - { + } else if ( current && current->flags & SDL_FULLSCREEN ) { + if ( current->w != width || + current->h != height || + (this->hidden && this->hidden->depth != bpp)) { D(bug("Deleting previous window...\n")); - CGX_DestroyImage(this,current); - CGX_DestroyWindow(this,current); + 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; - - D(bug("Opening screen...\n")); - - 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; - - D(bug("Screen opened.\n")); - - if(flags&SDL_DOUBLEBUF) { - int ok=0; - D(bug("Start of DBuffering allocations...\n")); - - 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; + } else + buildnewscreen: + { + Uint32 okid = INVALID_ID; + /*if ((flags & SDL_OPENGL) && (bpp == 24)) + { + bpp = 32; + }*/ + if ( bpp == 32 ) { + UWORD pixfmt[] = { PIXFMT_BGRA32, -1 }; + unsigned long *ret; + struct CyberModeNode *cnode; + ret = AllocCModeListTags(CYBRMREQ_MinWidth, width, CYBRMREQ_MinHeight, height, + CYBRMREQ_MaxWidth, width + 1000, CYBRMREQ_MaxHeight, height + 1000, + CYBRMREQ_MaxDepth, bpp, CYBRMREQ_MinDepth, 32, CYBRMREQ_CModelArray, (&pixfmt), TAG_END); + if ( ret ) { + cnode = *ret; + if ( cnode )okid = cnode->DisplayID; + } + } + //if (bpp == 16) +// { +// UWORD pixfmt[] ={PIXFMT_RGB16,-1}; +// unsigned long *ret; +// struct CyberModeNode * cnode; +// ret = AllocCModeListTags(CYBRMREQ_MinWidth,width,CYBRMREQ_MinHeight,height, +// CYBRMREQ_MaxWidth,width+1000,CYBRMREQ_MaxHeight,height+1000, +// CYBRMREQ_MaxDepth,bpp,CYBRMREQ_MinDepth,16,CYBRMREQ_CModelArray,&pixfmt,TAG_END); +// if (ret) +// {cnode = *ret; +// if (cnode)okid = cnode->DisplayID; +// } +// if (!IsCyberModeID(okid))okid = INVALID_ID; +// } + + + if ( okid == INVALID_ID ) { + okid = BestCModeIDTags(CYBRBIDTG_NominalWidth, width, + CYBRBIDTG_NominalHeight, height, + CYBRBIDTG_Depth, bpp, + TAG_DONE); + D(bug("Mode ID %lx\n", okid)); + } + swidth = width; + sheight = height; + + GFX_Display = NULL; + this->hidden->dbscrollscreen = 0; /* no doublebuffer scroll screen */ + D(bug("Opening screen...\n")); + if ( okid != INVALID_ID ) { + struct DimensionInfo dinfo; + + int result = GetDisplayInfoData(0, &dinfo, sizeof(struct DimensionInfo), DTAG_DIMS, okid); + if ( result ) { + swidth = dinfo.Nominal.MaxX; + sheight = dinfo.Nominal.MaxY; + + if ( dinfo.MaxRasterHeight < 2 * height ) { + dbscroll = 0; /* we can't scroll for double buffer */ + } + } + //printf("DBScroll %d\n",dbscroll); + if ( dbscroll ) { + /* open at native resolution, 2 times the native height */ + GFX_Display = OpenScreenTags(NULL, + SA_Top, 0, + SA_Left, 0, + SA_Width, swidth + 1, + SA_Height, sheight * 2 + 2, + SA_Title, "AMMX include Screen", +// SA_Quiet,TRUE,SA_ShowTitle,FALSE, + SA_AutoScroll, FALSE, + SA_Draggable, FALSE, + SA_Depth, bpp, + SA_Type, CUSTOMSCREEN, + SA_Exclusive, TRUE, + SA_DisplayID, okid, + TAG_DONE); + this->hidden->dbpos = 0; + this->hidden->dbheight = sheight; + //printf("open double buffered screen %x\n",(int)GFX_Display); + } + if ( !GFX_Display) { + dbscroll = 0; + GFX_Display = OpenScreenTags(NULL, + //SA_Width,width, + //SA_Height,height, + SA_Title, "include Screen", + SA_Quiet, TRUE, SA_ShowTitle, FALSE, + SA_Depth, bpp, + SA_DisplayID, okid, + TAG_DONE); + } + if ( dbscroll ) + this->hidden->dbscrollscreen = 1; /* use scrolling screen for double buffer */ + } else + D(bug("2: Cant get a valid screenmode ID with BestCModeIDTags\n")); + if ( !GFX_Display) { + GFX_Display = SDL_Display; + flags &= ~SDL_FULLSCREEN; + flags &= ~SDL_DOUBLEBUF; + D(bug("Screen cant open \n")); + } else { + UnlockPubScreen(NULL, SDL_Display); + SDL_Display = GFX_Display; + + D(bug("Screen opened.\n")); + + if ( flags & SDL_DOUBLEBUF ) { + if ( this->hidden->dbscrollscreen ) { + D(bug("Initialize double buffered scrolling screen\n")); + /* copy bitmap */ + memcpy(&this->hidden->dbitmap, GFX_Display->RastPort.BitMap, sizeof(struct BitMap)); + RectFill(&GFX_Display->RastPort, 0, 0, GFX_Display->Width, GFX_Display->Height); + /* move secondary bitmap further down */ + this->hidden->dbitmap.Planes[0] += this->hidden->dbitmap.BytesPerRow * this->hidden->dbheight; + this->hidden->dbuffer = 2; + current->flags |= SDL_DOUBLEBUF; + } else /* if( this->hidden->dbscrollscreen ) */ + { + int ok = 0; + D(bug("Start of DBuffering allocations...\n")); + + 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("Double buffering enabled!\n")); + this->hidden->dbuffer = 1; + current->flags |= SDL_DOUBLEBUF; + } + } else { + FreeScreenBuffer(SDL_Display, this->hidden->SB[1]); + this->hidden->SB[0] = 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( this->hidden->dbscrollscreen ) */ } - - if(!ok) - flags&=~SDL_DOUBLEBUF; } - } - if(GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_DEPTH)==bpp) - this->hidden->same_format=1; - } + 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("Setting screen depth to: %ld\n",this->hidden->depth)); + bpp = this->hidden->depth = GetCyberMapAttr(SDL_Display->RastPort.BitMap, CYBRMATTR_DEPTH); + D(bug("Setting screen depth to: %ld\n", this->hidden->depth)); for ( i = 0; i < this->hidden->nvisuals; i++ ) if ( this->hidden->visuals[i].depth == bpp ) /* era .depth */ @@ -1057,23 +1278,24 @@ static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, if ( i == this->hidden->nvisuals ) { SDL_SetError("No matching visual for requested depth"); - return NULL; /* should never happen */ + return NULL; /* should never happen */ } - SDL_Visual = this->hidden->visuals[i].visual; - + //SDL_Visual = this->hidden->visuals[i].visual; + SDL_Visual = this->hidden->visuals[i].visual; //no changecreen } /* Set up the X11 window */ saved_flags = current->flags; - if (SDL_Window && (saved_flags&SDL_OPENGL) == (flags&SDL_OPENGL) - && bpp == current->format->BitsPerPixel && !needcreate) { - if (CGX_ResizeWindow(this, current, width, height, flags) < 0) { + if ( SDL_Window && (saved_flags & SDL_OPENGL) == (flags & SDL_OPENGL) + && bpp == current->format->BitsPerPixel && !needcreate ) { + if ( CGX_ResizeWindow(this, current, width, height, flags) < 0 ) { current = NULL; goto done; } } else { - if (CGX_CreateWindow(this,current,width,height,bpp,flags) < 0) { + + if ( CGX_CreateWindow(this, current, width, height, bpp, flags) < 0 ) { current = NULL; goto done; } @@ -1082,7 +1304,7 @@ static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, #if 0 /* Set up the new mode framebuffer */ if ( ((current->w != width) || (current->h != height)) || - ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { + ((saved_flags&SDL_OPENGL) != (flags&SDL_OPENGL)) ) { current->w = width; current->h = height; current->pitch = SDL_CalculatePitch(current); @@ -1090,28 +1312,29 @@ static SDL_Surface *CGX_SetVideoMode(_THIS, SDL_Surface *current, } #endif - current->flags |= (flags&SDL_RESIZABLE); // Resizable only if the user asked it + current->flags |= (flags & SDL_RESIZABLE); // Resizable only if the user asked it - done: + done: + Delay(1); /* Release the event thread */ SDL_Unlock_EventThread(); + SDL_AmigaUnlockWindow(); /* We're done! */ - return(current); + return (current); } -static int CGX_ToggleFullScreen(_THIS, int on) -{ +static int CGX_ToggleFullScreen(_THIS, int on) { Uint32 event_thread; /* Don't switch if we don't own the window */ - if ( SDL_windowid ) { - return(0); + 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) ) { + if ( event_thread && (SDL_ThreadID() == event_thread)) { event_thread = 0; } if ( event_thread ) { @@ -1119,10 +1342,15 @@ static int CGX_ToggleFullScreen(_THIS, int on) } if ( on ) { this->screen->flags |= SDL_FULLSCREEN; + CGX_EnterFullScreen(this); + SDL_SetVideoMode(this->screen->w - this->offset_x, this->screen->h - this->offset_y, this->hidden->depth, this->screen->flags); + //SDL_FillRect(this->screen, NULL, 0); } else { this->screen->flags &= ~SDL_FULLSCREEN; CGX_LeaveFullScreen(this); + SDL_SetVideoMode(this->screen->w, this->screen->h, this->hidden->depth, this->screen->flags); + } CGX_RefreshDisplay(this); @@ -1132,170 +1360,153 @@ static int CGX_ToggleFullScreen(_THIS, int on) SDL_ResetKeyboard(); - return(1); + return (1); } -static void SetSingleColor(Uint32 fmt, unsigned char r, unsigned char g, unsigned char b, unsigned char *c) -{ - switch(fmt) - { +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) ; - } + 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) ; - } + 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) ; - } + 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) ; - } + 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; + 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; + 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; + 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; + + 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; + c[0] = r; + c[1] = g; + c[2] = b; + c[3] = 0; break; default: - D(bug("Error, SetSingleColor with PIXFMT %ld!\n",fmt)); + D(bug("Error, SetSingleColor with PIXFMT %ld!\n", fmt)); } } /* Update the current mouse state and position */ -static void CGX_UpdateMouse(_THIS) -{ +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) - ) - { + 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_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; +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 easy if we have a hidden colormap */ - if ( (this->screen->flags & SDL_HWPALETTE) && currently_fullscreen ) - { - ULONG xcmap[256*3+2]; + if ((this->screen->flags & SDL_HWPALETTE) && currently_fullscreen) { + ULONG xcmap[256 * 3 + 2]; + + xcmap[0] = (ncolors << 16); + xcmap[0] += firstcolor; - xcmap[0]=(ncolors<<16); - xcmap[0]+=firstcolor; +// D(bug("Setting %ld colors from color %ld on an HWPALETTE screen\n",ncolors,firstcolor)); -// D(bug("Setting %ld colors on an HWPALETTE screen\n",ncolors)); +// per ora ho sostituito questo gli altri casi sono ancora da gestire - for ( i=0; iViewPort,xcmap); + 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); + return (0); } - 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)); + if ( this->hidden->depth == 8 ) { +// D(bug("Obtaining %ld colors on the screen\n",ncolors)); - /* Free existing allocated colors */ - for ( pixel=0; pixelscreen->format->palette->ncolors; ++pixel ) { - if(SDL_XPixels[pixel]>=0) - ReleasePen(GFX_Display->ViewPort.ColorMap,SDL_XPixels[pixel]); + for ( pixel = firstcolor; pixel < ncolors + firstcolor; pixel++ ) { + if ( SDL_XPixels[pixel] >= 0 ) + ReleasePen(GFX_Display->ViewPort.ColorMap, SDL_XPixels[pixel]); } - /* Try to allocate all the colors */ - for ( i=0; iscreen->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); + /* Try to allocate all the colors */ + for ( i = 0; i < ncolors; i++ ) { + SDL_XPixels[i + firstcolor] = ObtainBestPenA(GFX_Display->ViewPort.ColorMap, colors[i].r << 24, colors[i].g << 24, colors[i].b << 24, NULL); } - } - else - { + } else { #ifndef USE_CGX_WRITELUTPIXEL Uint32 fmt; - D(bug("Preparing a conversion pixel table...\n")); +// D(bug("Preparing a conversion pixel table...\n")); fmt=GetCyberMapAttr(SDL_Display->RastPort.BitMap,CYBRMATTR_PIXFMT); - for(i=0;igl_data->gl_active == 1) { + if ( this->gl_data->gl_active == 1 ) { CGX_GL_Quit(this); } /* Start shutting down the windows */ @@ -1324,19 +1534,19 @@ static void CGX_VideoQuit(_THIS) CGX_DestroyImage(this, this->screen); D(bug("Destroying window...\n")); CGX_DestroyWindow(this, this->screen); -// Otherwise SDL_VideoQuit will try to free it! - SDL_VideoSurface=NULL; + // 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); + FreeMem(SDL_BlankCursor, 16); SDL_BlankCursor = NULL; } /* Close the X11 graphics connection */ - this->hidden->same_format=0; + this->hidden->same_format = 0; D(bug("Destroying screen...\n")); @@ -1346,30 +1556,29 @@ static void CGX_VideoQuit(_THIS) /* Close the X11 display connection */ SDL_Display = NULL; - /* Unload GL library after X11 shuts down */ + /* Unload include-GL library after X11 shuts down */ } D(bug("Closing libraries...\n")); - if( CyberGfxBase) { + if ( CyberGfxBase ) { CloseLibrary(CyberGfxBase); - CyberGfxBase=NULL; + CyberGfxBase = NULL; } - if (IntuitionBase) { + if ( IntuitionBase ) { CloseLibrary((struct Library *)IntuitionBase); - IntuitionBase=NULL; + IntuitionBase = NULL; } - if (GfxBase) { + if ( GfxBase ) { CloseLibrary((struct Library *)GfxBase); - GfxBase=NULL; + GfxBase = NULL; } - if ( this->screen && (this->screen->flags & SDL_HWSURFACE) ) { + if ( this->screen && (this->screen->flags & SDL_HWSURFACE)) { /* Direct screen access, no memory buffer */ this->screen->pixels = NULL; } D(bug("End of CGX_VideoQuit.\n")); - } diff --git a/src/video/cybergfx/SDL_cgxvideo.h b/src/video/cybergfx/SDL_cgxvideo.h index 9ef76ea55..88f492109 100644 --- a/src/video/cybergfx/SDL_cgxvideo.h +++ b/src/video/cybergfx/SDL_cgxvideo.h @@ -24,24 +24,42 @@ #ifndef _SDL_cgxvideo_h #define _SDL_cgxvideo_h +#include + +#ifndef AROS +#include +#endif + +#include #include #include #include #include #include -#if defined(__SASC) || defined(STORMC4_WOS) + +#if defined(__SASC) || defined(WARPOS) || defined(AROS) #include #include #include #include #include #else +#ifdef MORPHOS +#include +#include +#include +#include +#include +#else + #include #include #include #include #include + +#endif #endif #include "SDL_mouse.h" @@ -51,63 +69,78 @@ #define USE_CGX_WRITELUTPIXEL /* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this +#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 */ - - char *SDL_windowid; /* Flag: true if we have been passed a window */ - - /* The variables used for displaying graphics */ - Uint8 *Ximage; /* The X image for our window */ - int swap_pixels; /* Flag: true if display is swapped endian */ - - /* 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 { + 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 */ + + char *SDL_windowid; /* Flag: true if we have been passed a window */ + + /* 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 */ + int depth; /* number of significant bits/pixel */ + int bpp; /* pixel quantum in bits */ + } visuals[5]; /* at most entries for 8, 15, 16, 24 32 */ + 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 */ + short *iconcolors; /* List of colors used by the icon */ + int swap_bytes; + struct Window *SDL_Window_Background; + struct BitMap *bmap; + Uint32 oldqual, oldkey; + UBYTE window_active; + + /* additions for AMMX version */ + UBYTE dbscrollscreen; /* use scrolling screen instead of screen buffer swap (Vampire/Apollo) */ + UWORD dbpos; /* current screen position (vertical, scrolled) */ + UWORD dbheight; /* height of double buffer (half of total screen height) */ + struct BitMap dbitmap; /* custom bitmap for double buffering */ }; /* Old variable names */ @@ -122,12 +155,16 @@ struct SDL_PrivateVideoData { #define WMwindow (this->hidden->WMwindow) #define FSwindow (this->hidden->FSwindow) #define SDL_Window (this->hidden->SDL_Window) +#define SDL_Window_Background (this->hidden->SDL_Window_Background) + #define WM_DELETE_WINDOW (this->hidden->WM_DELETE_WINDOW) #define SDL_BlankCursor (this->hidden->BlankCursor) #define SDL_windowid (this->hidden->SDL_windowid) #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) @@ -144,10 +181,8 @@ struct SDL_PrivateVideoData { /* Used to get the X cursor from a window-manager specific cursor */ // extern Cursor SDL_GetWMXCursor(WMcursor *cursor); -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 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); @@ -157,16 +192,17 @@ extern struct GfxBase *GfxBase; extern struct ExecBase *SysBase; extern struct DosLibrary *DOSBase; -struct private_hwdata -{ +struct private_hwdata { struct BitMap *bmap; APTR lock; struct SDL_VideoDevice *videodata; APTR mask; int allocated; + struct Window *amigawindow; }; -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); +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 */ diff --git a/src/video/cybergfx/SDL_cgxwm.c b/src/video/cybergfx/SDL_cgxwm.c index 47a7d6002..fbfde4c4f 100644 --- a/src/video/cybergfx/SDL_cgxwm.c +++ b/src/video/cybergfx/SDL_cgxwm.c @@ -21,43 +21,306 @@ */ #include "SDL_config.h" -#include "SDL_version.h" -#include "SDL_timer.h" -#include "SDL_video.h" +#ifdef AROS +# define _STRUCT_TIMEVAL 1 +#endif + + +//#include "SDL_error.h" +//#include "SDL_timer.h" +//#include "SDL_video.h" #include "SDL_syswm.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_pixels_c.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) -{ -/* Not yet implemented */ +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); +void CGX_SetCaption(_THIS, const char *title, const char *icon) { + if ( SDL_Window) + SetWindowTitles(SDL_Window, (char *)title, (char *)icon); } /* Iconify the window */ -int CGX_IconifyWindow(_THIS) -{ -/* Not yet implemented */ +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 } -int CGX_GetWMInfo(_THIS, SDL_SysWMinfo *info) +#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 ) { - return(1); +#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); + SDL_SetError("Application not compiled with SDL %d.%d\n", SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return (-1); } } From 5272d275c2829cede0ac174d714695335908242d Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 15:40:03 +0100 Subject: [PATCH 02/21] Add some missing files --- .gitignore | 10 + src/main/amigaos/SDL_amigasas.c | 183 ++ src/main/amigaos/SDL_amigasas2.c | 160 ++ src/main/amigaos/SDL_amigastub.c | 326 ++++ src/main/amigaos/SDL_main.h | 114 ++ src/thread/amigaos/SDL_syscond.c | 216 +++ src/thread/amigaos/SDL_sysmutex.c | 133 ++ src/thread/amigaos/SDL_sysmutex_c.h | 39 + src/thread/amigaos/SDL_syssem_o.c | 185 ++ src/video/apollo/apolloammxenable.asm | 129 ++ src/video/apollo/apolloammxenable.h | 27 + src/video/apollo/asminterface.h | 46 + src/video/apollo/blitapollo.asm | 875 +++++++++ src/video/apollo/blitapollo.h | 61 + src/video/apollo/colorkeyapollo.asm | 259 +++ src/video/apollo/colorkeyapollo.h | 52 + src/video/cybergfx/SDL_agavideo.c | 752 ++++++++ src/video/cybergfx/SDL_cgxgl_wrapper.c | 2290 ++++++++++++++++++++++++ src/video/cybergfx/SDL_cgxyuv.c | 191 ++ src/video/cybergfx/SDL_cgxyuv_c.h | 45 + src/video/cybergfx/SDL_syswm.h | 187 ++ 21 files changed, 6280 insertions(+) create mode 100644 .gitignore create mode 100644 src/main/amigaos/SDL_amigasas.c create mode 100644 src/main/amigaos/SDL_amigasas2.c create mode 100644 src/main/amigaos/SDL_amigastub.c create mode 100644 src/main/amigaos/SDL_main.h create mode 100644 src/thread/amigaos/SDL_syscond.c create mode 100644 src/thread/amigaos/SDL_sysmutex.c create mode 100644 src/thread/amigaos/SDL_sysmutex_c.h create mode 100644 src/thread/amigaos/SDL_syssem_o.c create mode 100644 src/video/apollo/apolloammxenable.asm create mode 100644 src/video/apollo/apolloammxenable.h create mode 100644 src/video/apollo/asminterface.h create mode 100644 src/video/apollo/blitapollo.asm create mode 100644 src/video/apollo/blitapollo.h create mode 100644 src/video/apollo/colorkeyapollo.asm create mode 100644 src/video/apollo/colorkeyapollo.h create mode 100644 src/video/cybergfx/SDL_agavideo.c create mode 100644 src/video/cybergfx/SDL_cgxgl_wrapper.c create mode 100644 src/video/cybergfx/SDL_cgxyuv.c create mode 100644 src/video/cybergfx/SDL_cgxyuv_c.h create mode 100644 src/video/cybergfx/SDL_syswm.h diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..35ad8a9b6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +#objects +*.go +*.a +*.ao +*.o +*.ll +/Default/ +.idea/ +build/ +cmake-build-*/* diff --git a/src/main/amigaos/SDL_amigasas.c b/src/main/amigaos/SDL_amigasas.c new file mode 100644 index 000000000..7a39fd68e --- /dev/null +++ b/src/main/amigaos/SDL_amigasas.c @@ -0,0 +1,183 @@ +/******************************************************************************/ +/* */ +/* includes */ +/* */ +/******************************************************************************/ + +#include +#include + +#include "../../../mydebug.h" + +/******************************************************************************/ +/* */ +/* global declarations */ +/* */ +/******************************************************************************/ + +extern struct ExecBase *SysBase; +extern struct DosLibrary *DOSBase; +extern struct Library *UtilityBase; + +/******************************************************************************/ +/* */ +/* user library initialization */ +/* */ +/* !!! CAUTION: This function may run in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +int __saveds __asm + +__UserLibInit(register __a6 struct Library *libbase) { + /* required !!! */ + SysBase = *(struct ExecBase **)4; + + D(bug("***include.library init: %lx\n", libbase)); + + if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39L))) { + D(bug("unable to open dos.library\n")); + return 1; + } + + if ( !(UtilityBase = OpenLibrary("utility.library", 37L))) { + D(bug("***unable to open utility.library.\n")); + CloseLibrary((struct Library *)DOSBase); + return 1; + } + + return 0; +} + +/******************************************************************************/ +/* */ +/* user library cleanup */ +/* */ +/* !!! CAUTION: This function runs in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +void __saveds __asm + +__UserLibCleanup(register __a6 struct Library *myLib) { + D(bug("***include.library cleanup\n")); + CloseLibrary(UtilityBase); + CloseLibrary((struct Library *)DOSBase); +} + +/******************************************************************************/ +/* */ +/* library dependent function(s) */ +/* */ +/******************************************************************************/ + +#define ADDTABL_0(x) \ + __saveds __asm LIB##x(void) \ + { \ + extern __stdargs long x(void); \ + return x(); \ + } +#define ADDTABL_1(x, y) \ + __saveds __asm LIB##x(register __##y long arg1) \ + { \ + extern __stdargs long x(long); \ + return x(arg1); \ + } +#define ADDTABL_2(x, y, z) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2) \ + { \ + extern __stdargs long x(long, long); \ + return x(arg1, arg2); \ + } +#define ADDTABL_3(x, y, z, t) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3) \ + { \ + extern __stdargs long x(long, long, long); \ + return x(arg1, arg2, arg3); \ + } +#define ADDTABL_4(x, y, z, t, v) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4) \ + { \ + extern __stdargs long x(long, long, long, long); \ + return x(arg1, arg2, arg3, arg4); \ + } +#define ADDTABL_5(x, y, z, t, v, k) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4, register __##k long arg5) \ + { \ + extern __stdargs long x(long, long, long, long, long); \ + return x(arg1, arg2, arg3, arg4, arg5); \ + } + +ADDTABL_1(SDL_Init, d0) /* One Argument in d0 */ +ADDTABL_0(SDL_Quit) + +ADDTABL_1(SDL_InitSubSystem, d0) + +ADDTABL_1(SDL_QuitSubSystem, d0) + +ADDTABL_1(SDL_WasInit, d0) + +ADDTABL_0(SDL_GetError) + +ADDTABL_2(SDL_RWFromFile, a0, d0) + +ADDTABL_2(SDL_RWFromFP, a0, d0) + +ADDTABL_2(SDL_RWFromMem, a0, d0) + +// video + +ADDTABL_2(SDL_LoadBMP_RW, a0, d0) + +ADDTABL_3(SDL_SetColorKey, a0, d0, d1) + +ADDTABL_1(SDL_DisplayFormat, a0) + +ADDTABL_1(SDL_FreeSurface, a0) + +ADDTABL_3(SDL_FillRect, a0, a1, d0) + +ADDTABL_4(SDL_UpperBlit, a0, d0, a1, d1) + +ADDTABL_1(SDL_Flip, a0) + +ADDTABL_3(SDL_UpdateRects, a0, d0, a1) + +ADDTABL_5(SDL_UpdateRect, a0, d0, d1, d2, d3) + +ADDTABL_0(SDL_GetVideoInfo) + +ADDTABL_4(SDL_SetVideoMode, d0, d1, d2, d3) + +ADDTABL_4(SDL_MapRGB, a0, d0, d1, d2) + +// timer +ADDTABL_0(SDL_GetTicks) + +ADDTABL_1(SDL_Delay, d0) + +// events +ADDTABL_1(SDL_PollEvent, a0) + +ADDTABL_1(SDL_WaitEvent, a0) + +ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2) + +/******************************************************************************/ +/* */ +/* endtable marker (required!) */ +/* */ +/******************************************************************************/ + +// ADDTABL_END() + +void _XCEXIT(void) { + D(bug("Warning include.library attempted exit, sleeping forever!\n")); + Wait(0); // resto in wait forever +} + +/******************************************************************************/ +/* */ +/* end of simplelib.c */ +/* */ +/******************************************************************************/ diff --git a/src/main/amigaos/SDL_amigasas2.c b/src/main/amigaos/SDL_amigasas2.c new file mode 100644 index 000000000..9ebcc6764 --- /dev/null +++ b/src/main/amigaos/SDL_amigasas2.c @@ -0,0 +1,160 @@ +/******************************************************************************/ +/* */ +/* includes */ +/* */ +/******************************************************************************/ + +#include +#include + +/******************************************************************************/ +/* */ +/* global declarations */ +/* */ +/******************************************************************************/ + +extern void D(bug(char *, ...); + +extern struct ExecBase *SysBase; +extern struct DosLibrary *DOSBase; +extern struct Library *UtilityBase; + +/******************************************************************************/ +/* */ +/* user library initialization */ +/* */ +/* !!! CAUTION: This function may run in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +int __saveds __asm + +__UserLibInit(register __a6 struct Library *libbase) { + /* required !!! */ + SysBase = *(struct ExecBase **)4; + + D(bug("***include.library init: %lx\n", libbase)); + + if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39L))) { + D(bug("unable to open dos.library\n")); + return 1; + } + + if ( !(UtilityBase = OpenLibrary("utility.library", 37L))) { + D(bug("***unable to open utility.library.\n")); + CloseLibrary((struct Library *)DOSBase); + return 1; + } + + return 0; +} + +/******************************************************************************/ +/* */ +/* user library cleanup */ +/* */ +/* !!! CAUTION: This function runs in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +void __saveds __asm + +__UserLibCleanup(register __a6 struct Library *myLib) { + D(bug("***include.library cleanup\n")); + CloseLibrary(UtilityBase); + CloseLibrary((struct Library *)DOSBase); +} + +/******************************************************************************/ +/* */ +/* library dependent function(s) */ +/* */ +/******************************************************************************/ + +#define ADDTABL_0(x) \ + __saveds __asm LIB##x(void) {D(bug("Chiamata " #x "()\n")); } +#define ADDTABL_1(x, y) \ + __saveds __asm LIB##x(register __##y long arg1) {D(bug("Chiamata " #x "(%ld)\n", arg1)); } +#define ADDTABL_2(x, y, z) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2) {D(bug("Chiamata " #x "(%ld,%ld)\n", arg1, arg2)); } +#define ADDTABL_3(x, y, z, t) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3) {D(bug("Chiamata " #x "(%ld,%ld,%ld)\n", arg1, arg2, arg3)); } +#define ADDTABL_4(x, y, z, t, v) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4) {D(bug("Chiamata " #x "(%ld,%ld,%ld,%ld)\n", arg1, arg2, arg3, arg4)); } +#define ADDTABL_5(x, y, z, t, v, k) \ + __saveds __asm LIB##x(register __##y long arg1, register __##z long arg2, register __##t long arg3, register __##v long arg4, register __##k long arg5) {D(bug("Chiamata " #x "(%ld,%ld,%ld,%ld,%ld)\n", arg1, arg2, arg3, arg4, arg5)); } + + +ADDTABL_1(SDL_Init, d0) /* One Argument in d0 */ +ADDTABL_0(SDL_Quit) + +ADDTABL_1(SDL_InitSubSystem, d0) + +ADDTABL_1(SDL_QuitSubSystem, d0) + +ADDTABL_1(SDL_WasInit, d0) + +ADDTABL_0(SDL_GetError) + +ADDTABL_2(SDL_RWFromFile, a0, d0) + +ADDTABL_2(SDL_RWFromFP, a0, d0) + +ADDTABL_2(SDL_RWFromMem, a0, d0) + +// video + +ADDTABL_2(SDL_LoadBMP_RW, a0, d0) + +ADDTABL_3(SDL_SetColorKey, a0, d0, d1) + +ADDTABL_1(SDL_DisplayFormat, a0) + +ADDTABL_1(SDL_FreeSurface, a0) + +ADDTABL_3(SDL_FillRect, a0, a1, d0) + +ADDTABL_4(SDL_UpperBlit, a0, d0, a1, d1) + +ADDTABL_1(SDL_Flip, a0) + +ADDTABL_3(SDL_UpdateRects, a0, d0, a1) + +ADDTABL_5(SDL_UpdateRect, a0, d0, d1, d2, d3) + +ADDTABL_0(SDL_GetVideoInfo) + +ADDTABL_4(SDL_SetVideoMode, d0, d1, d2, d3) + +ADDTABL_4(SDL_MapRGB, a0, d0, d1, d2) + +// timer +ADDTABL_0(SDL_GetTicks) + +ADDTABL_1(SDL_Delay, d0) + +// events +ADDTABL_1(SDL_PollEvent, a0) + +ADDTABL_1(SDL_WaitEvent, a0) + +ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2) + +/******************************************************************************/ +/* */ +/* endtable marker (required!) */ +/* */ +/******************************************************************************/ + +// ADDTABL_END() + +void _XCEXIT(void) { + D(bug("Warning include.library attempted exit, sleeping forever!\n")); + Wait(0); // resto in wait forever +} + +/******************************************************************************/ +/* */ +/* end of simplelib.c */ +/* */ +/******************************************************************************/ diff --git a/src/main/amigaos/SDL_amigastub.c b/src/main/amigaos/SDL_amigastub.c new file mode 100644 index 000000000..c9067c06e --- /dev/null +++ b/src/main/amigaos/SDL_amigastub.c @@ -0,0 +1,326 @@ +/******************************************************************************/ +/* */ +/* includes */ +/* */ +/******************************************************************************/ + +#include +#include +#include +#include +#include +#include "../../../stabs.h" +#include "../../../mydebug.h" + +/******************************************************************************/ +/* */ +/* exports */ +/* */ +/******************************************************************************/ + +const BYTE LibName[] = "include.library"; +#include "SDL_amigaversion.h" + +const UWORD LibVersion = 12; +const UWORD LibRevision = 6; + +/******************************************************************************/ +/* */ +/* global declarations */ +/* */ +/******************************************************************************/ + +struct Library *myLibPtr; + +struct ExecBase *SysBase; +struct DosLibrary *__DOSBase, *DOSBase; +struct Library *__UtilityBase, *__MathIeeeDoubBasBase, *__MathIeeeSingBasBase, *__MathIeeeDoubTransBase; + +/******************************************************************************/ +/* */ +/* user library initialization */ +/* */ +/* !!! CAUTION: This function may run in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +int __UserLibInit(struct Library *myLib) { + /* setup your library base - to access library functions over *this* basePtr! */ + + myLibPtr = myLib; + + /* required !!! */ + SysBase = *(struct ExecBase **)4; + + D(bug("***include.library init\n")); + + if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39L))) { + D(bug("unable to open dos.library\n")); + return 1; + } + + __DOSBase = DOSBase; + + if ( !(__UtilityBase = OpenLibrary("utility.library", 37L))) { + D(bug("***unable to open utility.library.\n")); + CloseLibrary((struct Library *)__DOSBase); + return 1; + } + + + if ( !(__MathIeeeSingBasBase = OpenLibrary("mathieeesingbas.library", 33L))) { + D(bug("***unable to open mathieeesingbas.library.\n")); + CloseLibrary(__UtilityBase); + CloseLibrary((struct Library *)__DOSBase); + return 1; + } + + if ( !(__MathIeeeDoubBasBase = OpenLibrary("mathieeedoubbas.library", 33L))) { + D(bug("***unable to open mathieeedoubbas.library.\n")); + CloseLibrary(__MathIeeeSingBasBase); + CloseLibrary(__UtilityBase); + CloseLibrary((struct Library *)__DOSBase); + return 1; + } + + if ( !(__MathIeeeDoubTransBase = OpenLibrary("mathieeedoubtrans.library", 33L))) { + D(bug("***unable to open mathdoubtransbase.library.\n")); + CloseLibrary(__MathIeeeSingBasBase); + CloseLibrary(__MathIeeeDoubBasBase); + CloseLibrary(__UtilityBase); + CloseLibrary((struct Library *)__DOSBase); + return 1; + } + + __initstdio(); + __initstdfio(); + __initamigapath(); + __initclock(); + + return 0; +} + +/******************************************************************************/ +/* */ +/* user library cleanup */ +/* */ +/* !!! CAUTION: This function runs in a forbidden state !!! */ +/* */ +/******************************************************************************/ + +void __UserLibCleanup() { + D(bug("***include.library cleanup\n")); + + __exitmalloc(); + __exitstdio(); + __exitstdfio(); + + CloseLibrary(__MathIeeeDoubTransBase); + CloseLibrary(__MathIeeeDoubBasBase); + CloseLibrary(__MathIeeeSingBasBase); + CloseLibrary(__UtilityBase); + CloseLibrary((struct Library *)DOSBase); + +} + +/******************************************************************************/ +/* */ +/* library dependent function(s) */ +/* */ +/******************************************************************************/ + +// General +ADDTABL_1(SDL_Init, d0); /* One Argument in d0 */ +ADDTABL_0(SDL_Quit); +ADDTABL_1(SDL_InitSubSystem, d0); +ADDTABL_1(SDL_QuitSubSystem, d0); +ADDTABL_1(SDL_WasInit, d0); + +// RWops +ADDTABL_2(SDL_RWFromFile, a0, a1); +ADDTABL_2(SDL_RWFromFP, a0, d0); +ADDTABL_2(SDL_RWFromMem, a0, d0); +ADDTABL_0(SDL_AllocRW); +ADDTABL_1(SDL_FreeRW, a0); + +// video +ADDTABL_2(SDL_LoadBMP_RW, a0, d0); +ADDTABL_1(SDL_DisplayFormat, a0); +ADDTABL_1(SDL_FreeSurface, a0); +ADDTABL_3(SDL_FillRect, a0, a1, d0); +ADDTABL_4(SDL_UpperBlit, a0, d0, a1, d1); +ADDTABL_1(SDL_Flip, a0); +ADDTABL_3(SDL_UpdateRects, a0, d0, a1); +ADDTABL_5(SDL_UpdateRect, a0, d0, d1, d2, d3); +ADDTABL_0(SDL_GetVideoInfo); +ADDTABL_4(SDL_SetVideoMode, d0, d1, d2, d3); +ADDTABL_4(SDL_MapRGB, a0, d0, d1, d2); +ADDTABL_5(SDL_MapRGBA, a0, d0, d1, d2, d3); +ADDTABL_2(SDL_VideoDriverName, a0, d0); +ADDTABL_0(SDL_GetVideoSurface); +ADDTABL_4(SDL_VideoModeOK, d0, d1, d2, d3); +ADDTABL_2(SDL_ListModes, a0, d0); +ADDTABL_3(SDL_SetGamma, d0, d1, d2); +ADDTABL_3(SDL_SetGammaRamp, d0, d1, d2); +ADDTABL_3(SDL_GetGammaRamp, d0, d1, d2); +ADDTABL_4(SDL_SetColors, a0, a1, d0, d1); +ADDTABL_5(SDL_SetPalette, a0, d0, a1, d1, d2); +ADDTABL_5(SDL_GetRGB, d0, a0, d1, d2, d3); +ADDTABL_6(SDL_GetRGBA, d0, a0, d1, d2, d3, d4); +ADDTABL_8(SDL_CreateRGBSurface, d0, d1, d2, d3, d4, d5, d6, d7); +ADDTABL_9(SDL_CreateRGBSurfaceFrom, a0, d0, d1, d2, d3, d4, d5, d6, d7); +ADDTABL_1(SDL_LockSurface, a0); +ADDTABL_1(SDL_UnlockSurface, a0); +ADDTABL_3(SDL_SaveBMP_RW, a0, a1, d0); +ADDTABL_3(SDL_SetColorKey, a0, d0, d1); +ADDTABL_3(SDL_SetAlpha, a0, d0, d1); +ADDTABL_2(SDL_SetClipRect, a0, a1); +ADDTABL_2(SDL_GetClipRect, a0, a1); +ADDTABL_3(SDL_ConvertSurface, a0, a1, d0); +ADDTABL_1(SDL_DisplayFormatAlpha, a0); + +// overlay +ADDTABL_4(SDL_CreateYUVOverlay, d0, d1, d2, a0); +ADDTABL_1(SDL_LockYUVOverlay, a0); +ADDTABL_1(SDL_UnlockYUVOverlay, a0); +ADDTABL_2(SDL_DisplayYUVOverlay, a0, a1); +ADDTABL_1(SDL_FreeYUVOverlay, a0); + +// include-GL +ADDTABL_1(SDL_GL_LoadLibrary, a0); +ADDTABL_1(SDL_GL_GetProcAddress, a0); +ADDTABL_2(SDL_GL_SetAttribute, d0, d1); +ADDTABL_2(SDL_GL_GetAttribute, d0, a0); +ADDTABL_0(SDL_GL_SwapBuffers); +ADDTABL_2(SDL_GL_UpdateRects, d0, a0); +ADDTABL_0(SDL_GL_Lock); +ADDTABL_0(SDL_GL_Unlock); + +// WM +ADDTABL_2(SDL_WM_SetCaption, a0, a1); +ADDTABL_2(SDL_WM_GetCaption, a0, a1); +ADDTABL_2(SDL_WM_SetIcon, a0, a1); +ADDTABL_0(SDL_WM_IconifyWindow); +ADDTABL_1(SDL_WM_ToggleFullScreen, a0); +ADDTABL_1(SDL_WM_GrabInput, a0); + +// timer +ADDTABL_0(SDL_GetTicks); +ADDTABL_1(SDL_Delay, d0); +ADDTABL_2(SDL_SetTimer, d0, a0); +ADDTABL_3(SDL_AddTimer, d0, a0, a1); +ADDTABL_1(SDL_RemoveTimer, d0); + +// events +ADDTABL_0(SDL_PumpEvents); +ADDTABL_1(SDL_PollEvent, a0); +ADDTABL_1(SDL_WaitEvent, a0); +ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2); +ADDTABL_1(SDL_PushEvent, a0); +ADDTABL_1(SDL_SetEventFilter, d0); +ADDTABL_0(SDL_GetEventFilter); +ADDTABL_2(SDL_EventState, d0, d1); + +// joy +ADDTABL_0(SDL_NumJoysticks); +ADDTABL_1(SDL_JoystickName, d0); +ADDTABL_1(SDL_JoystickOpen, d0); +ADDTABL_1(SDL_JoystickOpened, d0); +ADDTABL_1(SDL_JoystickIndex, a0); +ADDTABL_1(SDL_JoystickNumAxes, a0); +ADDTABL_1(SDL_JoystickNumBalls, a0); +ADDTABL_1(SDL_JoystickNumHats, a0); +ADDTABL_1(SDL_JoystickNumButtons, a0); +ADDTABL_0(SDL_JoystickUpdate); +ADDTABL_1(SDL_JoystickEventState, d0); +ADDTABL_2(SDL_JoystickGetAxis, a0, d0); +ADDTABL_2(SDL_JoystickGetHat, a0, d0); +ADDTABL_4(SDL_JoystickGetBall, a0, d0, a1, a2); +ADDTABL_2(SDL_JoystickGetButton, a0, d0); +ADDTABL_1(SDL_JoystickClose, a0); + +// keyboard +ADDTABL_1(SDL_EnableUNICODE, d0); +ADDTABL_2(SDL_EnableKeyRepeat, d0, d1); +ADDTABL_1(SDL_GetKeyState, a0); +ADDTABL_0(SDL_GetModState); +ADDTABL_1(SDL_SetModState, d0); +ADDTABL_1(SDL_GetKeyName, d0); + +// mouse +ADDTABL_2(SDL_GetMouseState, a0, a1); +ADDTABL_2(SDL_GetRelativeMouseState, a0, a1); +ADDTABL_2(SDL_WarpMouse, d0, d1); +ADDTABL_6(SDL_CreateCursor, a0, a1, d0, d1, d2, d3); +ADDTABL_1(SDL_SetCursor, a0); +ADDTABL_0(SDL_GetCursor); +ADDTABL_1(SDL_FreeCursor, a0); +ADDTABL_1(SDL_ShowCursor, d0); + +// app +ADDTABL_0(SDL_GetAppState); + +// error +ADDTABL_2(SDL_SetError, a0, a1); +ADDTABL_0(SDL_GetError); +ADDTABL_0(SDL_ClearError); + +// audio +ADDTABL_1(SDL_AudioInit, a0); +ADDTABL_0(SDL_AudioQuit); +ADDTABL_2(SDL_AudioDriverName, a0, d0); +ADDTABL_2(SDL_OpenAudio, a0, a1); +ADDTABL_0(SDL_GetAudioStatus); +ADDTABL_1(SDL_PauseAudio, d0); +ADDTABL_5(SDL_LoadWAV_RW, a0, d0, a1, a2, a3); +ADDTABL_1(SDL_FreeWAV, a0); +ADDTABL_7(SDL_BuildAudioCVT, a0, d0, d1, d2, d3, d4, d5); +ADDTABL_1(SDL_ConvertAudio, a0); +ADDTABL_4(SDL_MixAudio, a0, a1, d0, d1); +ADDTABL_0(SDL_LockAudio); +ADDTABL_0(SDL_UnlockAudio); +ADDTABL_0(SDL_CloseAudio); + +// thread +ADDTABL_2(SDL_CreateThread, a0, a1); +ADDTABL_0(SDL_ThreadID); +ADDTABL_1(SDL_GetThreadID, a0); +ADDTABL_2(SDL_WaitThread, a0, a1); +ADDTABL_1(SDL_KillThread, a0); + +// version +ADDTABL_0(SDL_Linked_Version); + +// extensions +ADDTABL_4(SDL_SoftStretch, a0, a1, a2, a3); +//ADDTABL_2(SDL_free,a0,a1); +/******************************************************************************/ +/* */ +/* endtable marker (required!) */ +/* */ +/******************************************************************************/ + +ADDTABL_END(); + +long _WBenchMsg; + +void exit(int a) { + D(bug("***WARNING exit call from within the library!***\n")); + + for ( ;; ); +} + +#if 0 +char *getenv(char *a) +{ + D(bug("provata getenv(%s)\n",a)); + + return NULL; +} +#endif + +/******************************************************************************/ +/* */ +/* end of simplelib.c */ +/* */ +/******************************************************************************/ diff --git a/src/main/amigaos/SDL_main.h b/src/main/amigaos/SDL_main.h new file mode 100644 index 000000000..ad6468ded --- /dev/null +++ b/src/main/amigaos/SDL_main.h @@ -0,0 +1,114 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +/* Include the include main definition header */ + + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_main.h,v 1.3 2003/09/07 17:09:23 gabry Exp $"; +#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(_WIN32) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(macintosh) || defined(__APPLE__) || \ + defined(__SYMBIAN32__) || defined(QWS) + +#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 include 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 void SDLCALL SDL_SetModuleHandle(void *hInst); +* This can also be called, but is no longer necessary */ +extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +* From the include 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 SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); + +#ifdef __cplusplus +} +#endif +#include "close_code.h" +#endif + +#endif /* Need to redefine main()? */ + +#endif /* _SDL_main_h */ diff --git a/src/thread/amigaos/SDL_syscond.c b/src/thread/amigaos/SDL_syscond.c new file mode 100644 index 000000000..40480c07a --- /dev/null +++ b/src/thread/amigaos/SDL_syscond.c @@ -0,0 +1,216 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_syscond.c,v 1.3 2003/09/07 17:09:24 gabry Exp $"; +#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 +#include + +#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); +} diff --git a/src/thread/amigaos/SDL_sysmutex.c b/src/thread/amigaos/SDL_sysmutex.c new file mode 100644 index 000000000..d7a74a976 --- /dev/null +++ b/src/thread/amigaos/SDL_sysmutex.c @@ -0,0 +1,133 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_sysmutex.c,v 1.3 2003/09/07 17:09:24 gabry Exp $"; +#endif + +/* An implementation of mutexes using semaphores */ + +#include +#include + +#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 */ +} diff --git a/src/thread/amigaos/SDL_sysmutex_c.h b/src/thread/amigaos/SDL_sysmutex_c.h new file mode 100644 index 000000000..e3a501f1f --- /dev/null +++ b/src/thread/amigaos/SDL_sysmutex_c.h @@ -0,0 +1,39 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_mutex_c_h +#define _SDL_mutex_c_h + +#if !SDL_THREADS_DISABLED + +struct SDL_mutex { + int recursive; + Uint32 owner; + SDL_sem *sem; +}; + +#endif + + +#endif /* _SDL_mutex_c_h */ + diff --git a/src/thread/amigaos/SDL_syssem_o.c b/src/thread/amigaos/SDL_syssem_o.c new file mode 100644 index 000000000..c2a6a4ca5 --- /dev/null +++ b/src/thread/amigaos/SDL_syssem_o.c @@ -0,0 +1,185 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_syssem.c,v 1.2 2002/11/20 08:52:35 gabry Exp $"; +#endif + +/* An implementation of semaphores using mutexes and condition variables */ + +#include "SDL_error.h" +#include "SDL_thread.h" +#include "SDL_systhread_c.h" +#include + +#ifdef _AROS +#include "SDL_timer.h" +#include +#endif + +struct SDL_semaphore { + struct SignalSemaphore Sem; + Uint32 count; + Uint32 waiters_count; + SDL_mutex *count_lock; + SDL_cond *count_nonzero; +}; + +#undef D + +#define D(x) kprintf + +SDL_sem *SDL_CreateSemaphore(Uint32 initial_value) { + SDL_sem *sem; + + sem = (SDL_sem *)malloc(sizeof(*sem)); + + if ( !sem ) { + SDL_OutOfMemory(); + return (0); + } + + D(bug("Creating semaphore %lx...\n", sem)); + + memset(sem, 0, sizeof(*sem)); + + InitSemaphore(&sem->Sem); + if ( initial_value )ObtainSemaphore(&sem->Sem); + 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) { + if ( !sem ) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + D(bug("TryWait semaphore...%lx\n", sem)); + + ObtainSemaphore(&sem->Sem); +// ReleaseSemaphore(&sem->Sem); + + return 1; +} + +int SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout) { + int retval; + struct timerequest *tr; + struct timeval tv; + + if ( !sem ) { + SDL_SetError("Passed a NULL semaphore"); + return -1; + } + + D(bug("WaitTimeout (%ld) semaphore...%lx\n", timeout, sem)); + + /* 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); +*/ + +/* get a pointer to an initialized timer request block */ + tr = create_timer(UNIT_MICROHZ); + tv.tv_secs = 0; + tv.tv_micro = 1000; // 1 ms + if ( !(retval = AttemptSemaphore(&sem->Sem))) { + while ((timeout > 0) && (retval == FALSE)) { + wait_for_timer(tr, tv); + retval = AttemptSemaphore(&sem->Sem); + timeout--; + } + } + + if ( retval == TRUE ) { +// ReleaseSemaphore(&sem->Sem); + retval = 1; + } + delete_timer(tr); + return retval; +} + +int SDL_SemWait(SDL_sem *sem) { + ObtainSemaphore(&sem->Sem); + return 0; +// return SDL_SemWaitTimeout(sem, SDL_MUTEX_MAXWAIT); +} + +Uint32 SDL_SemValue(SDL_sem *sem) { + Uint32 value; + + value = 0; + if ( sem ) { +#ifdef WARPOS + value = sem->Sem.ssppc_SS.ss_NestCount; +#else + value = sem->Sem.ss_NestCount; +#endif +// SDL_UnlockMutex(sem->count_lock); + } + 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)); + if ( !sem->Sem.ss_NestCount ) { + D(bug("No other tasks wait for semaphore %lx", sem)); + return 0; + } + ReleaseSemaphore(&sem->Sem); +#if 0 + SDL_LockMutex(sem->count_lock); + if ( sem->waiters_count > 0 ) { + SDL_CondSignal(sem->count_nonzero); + } + ++sem->count; + SDL_UnlockMutex(sem->count_lock); +#endif + return 0; +} + diff --git a/src/video/apollo/apolloammxenable.asm b/src/video/apollo/apolloammxenable.asm new file mode 100644 index 000000000..ba9cccceb --- /dev/null +++ b/src/video/apollo/apolloammxenable.asm @@ -0,0 +1,129 @@ +; ------------------------------------------------------------------------------ +; | Apollo AMMX enable | +; | Henryk Richter | +; | All rights reserved | +; ------------------------------------------------------------------------------ +; +; + + XDEF _Apollo_EnableAMMX + XDEF _Apollo_AMMXon ;0.b = Off, 1.b = On + XDEF _Apollo_AMMX2on ;0.b = Off, 1.b = On (BSEL, PCMP) + + + include exec/types.i + include lvo/exec_lib.i + include exec/exec.i + + section .text + +; ASM _SAVEDS int Apollo_EnableAMMX( void ); +; +; return: 0 = no AMMX available +; 1 = AMMX ready for use + +_Apollo_EnableAMMX: + movem.l d1-a6,-(sp) + sf _Apollo_AMMX2on + + suba.l a1,a1 + move.l 4.w,a6 + jsr _LVOFindTask(a6) + move.l d0,a4 + + ;move.l 4.w,a6 + jsr _LVODisable(A6) + move.l TC_TRAPCODE(a4),-(sp) + + ;test if we are running on Apollo + move.l #Apollo_TrapCatch,TC_TRAPCODE(a4) + clr.b TrapCaught + + ;AMMX test: perm D0 to D0 and see if we get the desired byte swap + move.l #$DEADBEEF,d0 + dc.w $FE3F,$0000,$807C,$5476 ;VPERM #$807C5476,D0,D0,D0 (actually embeds or.w #$5476,d0 when interpreted as 2 word op) + nop ;just in case the trap is triggered somewhere else + + cmp.l #$ADDEEFBE,d0 + sne TrapCaught ;behave as if instruction was not executed in case we get the wrong result + + move.l (sp)+,TC_TRAPCODE(a4) + move.l 4.w,a6 + jsr _LVOEnable(A6) + + + moveq #0,d0 ;return: fail + tst.b TrapCaught + bne.s .noAMMX + + ; 2nd test for AMMX2: check + jsr _LVODisable(A6) + move.l TC_TRAPCODE(a4),-(sp) + + move.l #Apollo_TrapCatch,TC_TRAPCODE(a4) + move.l #$DEADBEEF,D0 + move.l #$FF00FF00,D1 + move.l #$55445544,D2 + dc.w $FE00,$1229 ;BSEL D0,D1,D2 = $FE00,$1229 (if(D1&1) D0 else D2 ) + nop + nop ;see below, addq.l #8 + nop + cmp.l #$DE44BE44,d2 + sne TrapCaught + + move.l (sp)+,TC_TRAPCODE(a4) + move.l 4.w,a6 + jsr _LVOEnable(A6) + + ifne 0 + + moveq #1,d0 ;def: on + add.b TrapCaught,d0 ;if( -1 ) d0 = 0 else d0 = 1 + + else + + moveq #0,d0 + tst.b TrapCaught + bne.s .noAMMX2 + moveq #1,d0 +.noAMMX2: + endc + + move.b d0,_Apollo_AMMX2on +.enableAMMX: + ; set Bit #11 in SR to announce the use of AMMX + move.l 4.w,a6 + jsr _LVODisable(a6) + jsr _LVOSuperState(a6) + move sr,d1 + or.w #$800,d1 + move d1,sr + jsr _LVOUserState(a6) + jsr _LVOEnable(a6) + moveq #1,d0 ;return: ok + +.noAMMX + move.b d0,_Apollo_AMMXon + movem.l (sp)+,d1-a6 + rts + +;********************************************************** +; Check whether an Apollo instruction causes a Trap +; assumes 10 byte of code (2 + 8) +;********************************************************** +Apollo_TrapCatch: + st TrapCaught + ADDQ #4,SP + ADDQ.L #8,2(sp) ;VPERM #....,....,... + rte + + section data,bss + +TrapCaught: ds.b 1 +_Apollo_AMMXon: ds.b 1 +_Apollo_AMMX2on: ds.b 1 + ds.b 1 ;alignment + + + + diff --git a/src/video/apollo/apolloammxenable.h b/src/video/apollo/apolloammxenable.h new file mode 100644 index 000000000..6b2b2d510 --- /dev/null +++ b/src/video/apollo/apolloammxenable.h @@ -0,0 +1,27 @@ +/* + apolloammxenable.h + + author: Henryk Richter + + purpose: Enable AMMX (per task) + +*/ +#ifndef _INC_APOLLOAMMXENABLE_H +#define _INC_APOLLOAMMXENABLE_H + +#include "asminterface.h" + +/* + return 0 = fail + 1 = AMMX ready for use +*/ +ASM int Apollo_EnableAMMX( void ); + +/* + 1 = AMMX is ready for use + 0 = AMMX unavailable +*/ +extern unsigned char Apollo_AMMXon; +extern unsigned char Apollo_AMMX2on; + +#endif /* _INC_APOLLOAMMXENABLE_H */ diff --git a/src/video/apollo/asminterface.h b/src/video/apollo/asminterface.h new file mode 100644 index 000000000..f064f6210 --- /dev/null +++ b/src/video/apollo/asminterface.h @@ -0,0 +1,46 @@ +/* + asminterface.h + + Henryk Richter + + Interface macros for ASM subroutines for GCC and SAS/C + + syntax: + ASM SAVEDS int some_asm_subroutine( + ASMR(d3) unsigned int some_data ASMREG(d3), + ASMR(a0) unsigned char *some_address ASMREG(a0) + ); + + Reason for the double spec of An/Dn: some compilers (SAS) require the register + on the left hand side, gcc on the right hand side. I wanted to avoid a big macro + for the whole argument and moved the stuff into two macros per argument. + +*/ +#ifndef _INC_ASMINTERFACE_H +#define _INC_ASMINTERFACE_H + +#ifdef __SASC + +#define ASM __asm +#define ASMR(x) register __ ## x +#define ASMREG(x) +#define SAVEDS __saveds + +#else /* __SASC */ + +#ifdef __GNUC__ + +#define ASM +#define ASMR(x) register +#define ASMREG(x) __asm("" #x "") +#define SAVEDS __saveds + +#else /* __GNUC__ */ + +#error "Compiler not supported yet in asminterface.h" + +#endif /* __GNUC__ */ +#endif /* __SASC */ + + +#endif /* _INC_ASMINTERFACE_H */ diff --git a/src/video/apollo/blitapollo.asm b/src/video/apollo/blitapollo.asm new file mode 100644 index 000000000..064ad3984 --- /dev/null +++ b/src/video/apollo/blitapollo.asm @@ -0,0 +1,875 @@ +; ------------------------------------------------------------------------------ +; | Apollo AMMX blitting functions | +; | Henryk Richter | +; | All rights reserved | +; ------------------------------------------------------------------------------ +; + +; enable debugging code block (unused right now) +DEBUG EQU 0 +; AMMX usage instruction set fuse, "burned" on first use (i.e. replace by appropriate branch) +; this means, the code will branch to 68k generic code or AMMX code +; of this define is FALSE (=0), the code will be Apollo only +DOFUSE68 EQU 1 + + ifne DOFUSE68 + XREF _Apollo_AMMXon ;0.b = Off, 1.b = On +_LVOCacheClearU EQU -636 ;yes, yes I know... + endc + + ; target: RGB565 + XDEF _ApolloARGBtoRGB565 + XDEF _ApolloRGBtoRGB565 ; + XDEF _ApolloBGRtoRGB565 + XDEF _ApolloBGRAtoRGB565 ; + + + ;target: RGB24 + XDEF _ApolloARGBtoRGB24 + XDEF _ApolloBGRAtoRGB24 ;untested + XDEF _ApolloBGRtoRGB24 ; 24 Bit BGR to 24 Bit RGB24 (and vice versa) + + ;target: RGB32 + XDEF _ApolloARGBtoBGRA ; 32 Bit ARGB to 32 Bit BGRA (and vice versa) + + ;target: Any (byte copy, rectangular) + XDEF _ApolloCopyRect + + machine ac68080 + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Macros +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + +; macro stuff +; CONVHEAD4P +; move (a0)+,(a1)+ ;number of bytes according to input/output pixel formats +; CONVMID4P +; move.b (a0)+,(a1)+ ; single conversion if number of pixels is not a multiple of 4 +; CONVEND4P +; CONVLINEEND + +; conversion header (set up variables and define outer loop) +; variables used/modified in the macros +; D5 - horizontal loop count (in pixels) +; D4 - trashed in CONVHEAD4P +; D0 - trashed in CONVHEAD4P +; +CONVHEAD4P macro + ; 4 pixels per loop + remaining pixels afterwards - change size to match + ; + ; 4 instructions, one Apollo cycle + moveq #-4,d5 ;F $fffffffc + and.l d0,d5 ;F clear lower 2 bits + moveq #3,d4 ;F + and.l d4,d0 ;F keep lower 2 bits + sub.l d0,d5 ;total width - (0,1,2,3) -> simplifies loop +.yloop: + move.l d5,d0 +.xloop: + ble .xleftover ;less than 4 pixels remaining ? + endm + + ;(a0)+,(a1)+ in here + +CONVMID4P macro + subq.l #4,d0 ; + bra .xloop +.xleftover: + beq.s .xnoleftover + ;1...3 pixels left over (if width is not a multiple of 4 + endm + + ;(a0)+,(a1)+ in here + +CONVEND4P macro + addq.l #1,d0 + bra.s .xleftover ;leftover loop + +.xnoleftover: ;end of x loop + endm + +CONVLINEEND macro + subq.l #1,d1 + + adda.l d2,a0 ;add skip values + adda.l d3,a1 + + bne .yloop + endm + +CONVHEAD8P macro + ; 8 pixels per loop + remaining pixels afterwards - change size to match + ; + ; 4 instructions, one Apollo cycle + moveq #-8,d5 ;F $fffffff8 + and.l d0,d5 ;F clear lower 3 bits + moveq #7,d4 ;F + and.l d4,d0 ;F keep lower 3 bits + sub.l d0,d5 ;total width - (0,1,2,3,...,7) -> simplifies loop +.yloop: + move.l d5,d0 +.xloop: + ble.s .xleftover ;less than 4 pixels remaining ? + endm + + ;(a0)+,(a1)+ in here + +CONVMID8P macro + subq.l #8,d0 ; + bra.s .xloop +.xleftover: + beq.s .xnoleftover + ;1...3 pixels left over (if width is not a multiple of 4 + endm + + ;(a0)+,(a1)+ in here + +CONVEND8P macro ;same as 4P + addq.l #1,d0 + bra.s .xleftover ;leftover loop + +.xnoleftover: ;end of x loop + endm + +; in: - +; out: - +; trash: D4 +FUSE68 macro + ifne DOFUSE68 + move.w #\1-*-2,d4 ;see routine below, don't change this on it's own + bsr.w BurnFuse ;this is somewhat cautious but it could be more + ;efficient with bsr.w, followed by dc.w \1-*-... + else + ;do nothing if disabled + endc + endm + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Code section +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + section .text + +; In: A0 - iptr +; A1 - optr +; D2 - skipped bytes in input after "width" pixels +; D3 - skipped bytes in output after "width" pixels +; D0 - width in pixels to copy +; D1 - height in pixels to copy +; +; Out: +; - + +; Called once per burned fuse function +; (note: could be optimized to burn all fuses at once) + ifne DOFUSE68 + +BurnFuse: + movem.l d0/a0,-(sp) + move.l 8(sp),a0 ;return address (skipping the saved registers) + + tst.b _Apollo_AMMXon ;have Apollo AMMX ? + beq.s .burn68k + + ; + ; burn in Apollo by executing nonsense code + ; + move.w #$283c,-8(a0) ;move.l #xxx,d4 ;TODO: short-range branch + move.w #$7A00,-2(a0) ;moveq #0,d5 ;fused instructions, 1 cycle lost on Apollo + + bra.s .ret + +.burn68k: + ; + ; burn in 68k Code Path + ; + move.w #$6000,-8(a0) ;replace "move.w #branch,d4" by "bra.w branch" + subq.l #8,8(sp) ;jump to the correct branch, before the BSR + + movem.l d1/a1/a6,-(sp) + move.l 4.w,a6 + jsr _LVOCacheClearU(a6) + movem.l (sp)+,d1/a1/a6 + +.ret: + movem.l (sp)+,d0/a0 + rts + + endc + + + +_ApolloCopyRect: + movem.l d4-d5,-(sp) + + FUSE68 m68kCopyRect ;trash: d4,d5 + + CONVHEAD8P ;set up d5 (trash D0,D4 but D4 is useable now) + + load (a0)+,E0 ;this doesn't copy more data per cycle than 68k version, + store E0,(a1)+ ;BUT! Less strain on the write buffers due to 64 Bit transfers + + CONVMID8P ;end of regular xloop + + move.b (a0)+,(a1)+ + + CONVEND8P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + +; plain m68k version +m68kCopyRect: + CONVHEAD8P ;set up d5 (trash D0,D4 but D4 is useable now) + + move.l (a0)+,(a1)+ + move.l (a0)+,(a1)+ + + CONVMID8P ;end of regular xloop + + move.b (a0)+,(a1)+ + + CONVEND8P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + + + +;------------------------------------------------------------------------------------------------ +; +; 16 Bit RGB565 targets +; +;------------------------------------------------------------------------------------------------ + +; 32 Bit ARGB32 to 16 Bit RGB565 +_ApolloARGBtoRGB565: + movem.l d4-d5,-(sp) + + FUSE68 m68kARGBtoRGB565 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 16 Bytes = 4 Pixels + load (a0),E0 ;ARGB ARGB + load 8(a0),E1 ;ARGB ARGB + lea 16(a0),a0 ; + ;STORE RGB565 in A1 + pack3216 E0,E1,(a1)+ + + CONVMID4P ;end of regular xloop + + move.l (a0)+,d4 + pack3216 d4,d4,d4 + move.w d4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + + + +; 24 Bit BGR24 to 16 Bit RGB565 +_ApolloBGRtoRGB565: + movem.l d4-d5,-(sp) + + FUSE68 m68kBGRtoRGB565 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 12 Bytes = 4 Pixels + load (a0),E0 ;B0G0R0B1G1R1B2G2 + move.l 8(a0),d4 ;xxxxxxxxR2B3G3R3 + lea 12(a0),a0 ; + + vperm #$CC76FFED,E0,D4,E1 + vperm #$22105543,E0,D4,E0 + + ;STORE RGB565 in A1 + pack3216 E0,E1,(a1)+ + + CONVMID4P ;end of regular xloop + + move.l (a0),d4 ;xx xx xx xx B0 G0 R0 xx + vperm #$66546654,d4,d4,d4 + pack3216 d4,d4,d4 + addq.l #3,a0 + + move.w d4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + +; 24 Bit RGB24 to 16 Bit RGB565 +_ApolloRGBtoRGB565: + movem.l d4-d5,-(sp) + + FUSE68 m68kRGBtoRGB565 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 12 Bytes = 4 Pixels + load (a0),E0 ;R0G0B0R1G1B1R2G2 + move.l 8(a0),d4 ;xxxxxxxxB2R3G3B3 + lea 12(a0),a0 ; + + vperm #$667CDDEF,E0,D4,E1 + vperm #$00123345,E0,D4,E0 + + ;STORE RGB565 in A1 + pack3216 E0,E1,(a1)+ + + CONVMID4P ;end of regular xloop + + move.l (a0),d4 ;xx xx xx xx R0 G0 B0 xx + vperm #$44564456,d4,d4,d4 + pack3216 d4,d4,d4 + addq.l #3,a0 + + move.w d4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + + +; 32 Bit BGRA to 16 Bit RGB565 +_ApolloBGRAtoRGB565: + movem.l d4-d5,-(sp) + FUSE68 m68kBGRAtoRGB565 ;permanently branch to plain 68k Routine if AMMX is unavailable + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + load (a0),E0 ;BGRA BGRA + load 8(a0),E1 ;BGRA BGRA + lea 16(a0),a0 ; + + ;PERMUTE BGRA TO ARGB + vperm #$32107654,E0,E0,E0 ; ARGB ARGB + vperm #$32107654,E1,E1,E1 ; ARGB ARGB + + ;STORE RGB565 in A1 + pack3216 E0,E1,(a1)+ + + CONVMID4P ;end of regular xloop + + movex.l (a0)+,d4 + ;move.l (a0)+,d4 + ;vperm #$76547654,d4,d4,d4 ; BGRA2ARGB + pack3216 d4,d4,d4 + move.w d4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + ifne DOFUSE68 +; +; PLAIN 68k code for cases where Apollo is unavailable +; +rgb565_rmask: dc.l $f800f800 +rgb565_gmask: dc.l $00FC00FC ;after shift: $07E007E0 + +m68kARGBtoRGB565: ;trash: d4,d5 + movem.l d6/d7,-(sp) + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + + ;A R G B A R G B + ;0 1 2 3 4 5 6 7 + ;R5 G6 B5 + rept 2 + move.l 1(a0),D4 ;R0(8) G0(8) B0(8) n + moveq #0,d6 + move.w D4,d6 ;B0(8) n + move.w 5(a0),D4 ;R0(8) G0(8) R1(8) G1(8) + lsl.l #5,d6 ;0 B0(5) n n + move.l rgb565_gmask(pc),d7 ; + clr.w d6 ;0 B0(5) 0 0 + and.l D4,d7 ;0 G0(6) 0 G1(6) + move.b 7(a0),d6 ;0 B0(5) 0 B1(8) + lsl.l #3,d7 ; G0(6) G1(6) + and.l rgb565_rmask(pc),D4 ;R0(5) R1(5) + lsr.w #3,d6 ;0 B0(5) 0 B1(5) + or.l d7,D4 ;R0(5)G0(6) R1(5)G1(6) + addq.l #8,a0 ;next input pixels + or.l d6,D4 ;R0(5)G0(6)B0(5) R1(5)G1(6)B1(5) + move.l D4,(a1)+ ;store 32 Bit = 2 Pixels + endr + + CONVMID4P ;end of regular xloop + + move.w #$f800,D4 ; + move.b 3(a0),d7 ; B0(8) + move.w #$fc,d6 ; + and.w 1(a0),D4 ; R0(5) + lsr.b #3,d7 ; B0(5) + and.b 2(a0),d6 ; G0(6)<<2 + or.b d7,D4 ; R0(5)...B0(5) + lsl.w #3,d6 ; G0(6) + or.w d6,D4 ; R0(5)G0(6)B0(5) + addq.l #4,a0 + move.w D4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d6/d7 + movem.l (sp)+,d4-d5 + rts + + +; 24 Bit BGR24 to 16 Bit RGB565 (not too fast) +m68kBGRtoRGB565: + movem.l d6/d7,-(sp) + + CONVHEAD4P ;set up D4 (trash D0,D4 but D4 is useable now) + + rept 4 + move.w 2(a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b (a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #3,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + endr + + CONVMID4P ;end of regular xloop + + move.w 2(a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b (a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #3,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d6/d7 + movem.l (sp)+,d4-d5 + rts + +; 24 Bit RGB24 to 16 Bit RGB565 +m68kRGBtoRGB565: + movem.l d6/d7,-(sp) + + CONVHEAD4P ;set up D4 (trash D0,D4 but D4 is useable now) + + rept 4 + move.w (a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b 2(a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #3,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + endr + + CONVMID4P ;end of regular xloop + + move.w (a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b 2(a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #3,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d6/d7 + movem.l (sp)+,d4-d5 + rts + + + +; 32 Bit BGRA to 16 Bit RGB565 +m68kBGRAtoRGB565: + movem.l d6/d7,-(sp) + + CONVHEAD4P ;set up D4 (trash D0,D4 but D4 is useable now) + + rept 4 + move.w 2(a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b (a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #4,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + endr + + CONVMID4P ;end of regular xloop + + move.w 2(a0),D4 ;R n + move.w #$00fc,d6 ; + and.b 1(a0),d6 ;G(6)<<2 + and.w #$f800,d4 ; + move.b (a0),d7 ;B(8) + lsl.w #3,d6 ;G(6) + lsr.b #3,d7 ;B(5) + or.w d6,D4 + addq.l #4,a0 + or.b d7,D4 ; + move.w D4,(a1)+ ; + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d6/d7 + movem.l (sp)+,d4-d5 + rts + + endc ;DOFUSE68 + +;------------------------------------------------------------------------------------------------ +; +; 24 Bit RGB targets +; +;------------------------------------------------------------------------------------------------ + +; 32 Bit ARGB to 24 Bit RGB24 +_ApolloARGBtoRGB24: + movem.l d4-d5,-(sp) + FUSE68 m68kARGBtoRGB24 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 16 Bytes = 4 Pixels + load (a0),E0 ;A0R0G0B0 A1R1G1B1 + load 8(a0),E1 ;A2R2G2B2 A3R3G3B3 + lea 16(a0),a0 ; + + vperm #$1235679a,E0,E1,E2 ;R0 G0 B0 R1 G1 B1 R2 G2 + vperm #$BDEFBDEF,E0,E1,D4 ;B2 R3 G3 B3 B2 R3 G3 B3 + + store e2,(a1) ; + move.l d4,8(a1) ; + lea 12(a1),a1 ; + + + CONVMID4P ;end of regular xloop + + move.b 1(a0),(a1)+ ;R + move.b 2(a0),(a1)+ ;G + move.b 3(a0),(a1)+ ;B + addq.l #4,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + +; 32 Bit BGRA to 24 Bit RGB24 +_ApolloBGRAtoRGB24: + movem.l d4-d5,-(sp) + FUSE68 m68kBGRAtoRGB24 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 16 Bytes = 4 Pixels + load (a0),E0 ;B0G0R0A0 B1G1R1A1 + load 8(a0),E1 ;B2G2R2A2 B3G3R3A3 + lea 16(a0),a0 ; + + vperm #$210654A9,E0,E1,E2 ;R0 G0 B0 R1 G1 B1 R2 G2 + vperm #$8EDC8EDC,E0,E1,D4 ;B2 R3 G3 B3 B2 R3 G3 B3 + + store e2,(a1) ; + move.l d4,8(a1) ; + lea 12(a1),a1 ; + + + CONVMID4P ;end of regular xloop + + move.b 2(a0),(a1)+ ;R + move.b 1(a0),(a1)+ ;G + move.b (a0),(a1)+ ;B + addq.l #4,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + +; 24 Bit BGR to 24 Bit RGB24 (and vice versa) +_ApolloBGRtoRGB24: + movem.l d4-d5,-(sp) + FUSE68 m68kBGRtoRGB24 ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 12 Bytes = 4 Pixels + load (a0),E0 ;B0 G0 R0 B1 G1 R1 B2 G2 + move.l 8(a0),d4 ;xx xx xx xx R2 B3 G3 R3 + lea 12(a0),a0 ; + + vperm #$210543C7,E0,D4,E1 ;R0 G0 B0 R1 G1 B1 R2 G2 + vperm #$6FED6FED,E0,D4,D4 ;B2 R3 G3 B3 B2 R3 G3 B3 + + store e1,(a1) + move.l d4,8(a1) + lea 12(a1),a1 ; + + CONVMID4P ;end of regular xloop + + move.b 2(a0),(a1)+ + move.b 1(a0),(a1)+ + move.b (a0),(a1)+ + addq.l #3,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + + + ifne DOFUSE68 + +; 32 Bit ARGB to 24 Bit RGB24 +m68kARGBtoRGB24: + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;TODO: 32 bit moves + ;ARGB ARGB ARGB ARGB (4x 32 Bit) + ;RGBR GBRG BRGB (3x 32 Bit) + rept 4 + move.b 1(a0),(a1)+ ;R + move.b 2(a0),(a1)+ ;G + move.b 3(a0),(a1)+ ;B + addq.l #4,a0 + endr + + CONVMID4P ;end of regular xloop + + move.b 1(a0),(a1)+ ;R + move.b 2(a0),(a1)+ ;G + move.b 3(a0),(a1)+ ;B + addq.l #4,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + +; 32 Bit BGRA to 24 Bit RGB24 +m68kBGRAtoRGB24: + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + rept 4 + move.b 2(a0),(a1)+ ;R + move.b 1(a0),(a1)+ ;G + move.b (a0),(a1)+ ;B + addq.l #4,a0 + endr + + CONVMID4P ;end of regular xloop + + move.b 2(a0),(a1)+ ;R + move.b 1(a0),(a1)+ ;G + move.b (a0),(a1)+ ;B + addq.l #4,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + +; 24 Bit BGR to 24 Bit RGB24 (and vice versa) +m68kBGRtoRGB24: + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + rept 4 + move.b 2(a0),(a1)+ + move.b 1(a0),(a1)+ + move.b (a0),(a1)+ + addq.l #3,a0 + endr + + CONVMID4P ;end of regular xloop + + move.b 2(a0),(a1)+ + move.b 1(a0),(a1)+ + move.b (a0),(a1)+ + addq.l #3,a0 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + endc ;DOFUSE68 + + + +;------------------------------------------------------------------------------------------------ +; +; 32 Bit ARGB targets +; +;------------------------------------------------------------------------------------------------ + +; 32 Bit ARGB to 32 Bit BGRA (and vice versa) +_ApolloARGBtoBGRA: + movem.l d4-d5,-(sp) + FUSE68 m68kARGBtoBGRA ;trash: d4,d5 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;LOAD 16 Bytes = 4 Pixels + load (a0),E0 ;A0R0G0B0 A1R1G1B1 + load 8(a0),E1 ;A2R2G2B2 A3R3G3B3 + lea 16(a0),a0 ; + vperm #$32107654,E0,E0,E0 ;BGRA BGRA + vperm #$32107654,E1,E1,E1 ;BGRA BGRA + store e0,(a1) ; + store e1,8(a1) ; + lea 16(a1),a1 ; + ;6cyc/4 Pixels = 1.5cyc/pixel + + CONVMID4P ;end of regular xloop + + movex.l (a0)+,d4 + move.l d4,(a1)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + movem.l (sp)+,d4-d5 + rts + + + ifne DOFUSE68 + +m68kARGBtoBGRA: + move.l d6,-(sp) + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + rept 2 + move.l (a0)+,d4 + move.l (a0)+,d6 + ror.w #8,d4 + swap d6 + swap d4 + ror.w #8,d6 + ror.w #8,d4 + swap d6 + swap d4 + move.l d4,(a1)+ + move.l d6,(a1)+ + ;7cyc/2 Pixels = 3.5cyc/pixel + endr + + CONVMID4P ;end of regular xloop + + move.l (a0)+,d4 + ror.w #8,d4 + swap d4 + ror.w #8,d4 + swap d4 + move.l d4,(a0)+ + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + move.l (sp)+,d6 + movem.l (sp)+,d4-d5 + rts + + endc ;DOFUSE68 + + + + ifne 1 + + + else + + + endc + + + + + +;******************************************************************************************** +;* +;* OLD STUFF, LARGELY UNTESTED, NEEDS CONVERSION TO MACRO STYLE +;* +;******************************************************************************************** + + + + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Data section +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + +; section data,data +;curbank: dc.b 0 +; cnop 0,4 + + + + END diff --git a/src/video/apollo/blitapollo.h b/src/video/apollo/blitapollo.h new file mode 100644 index 000000000..b8ff9b7f6 --- /dev/null +++ b/src/video/apollo/blitapollo.h @@ -0,0 +1,61 @@ +/* + blitapollo.h + + author: Henryk Richter + + purpose: AMMX optimized include blitter functions + +*/ +#ifndef _INC_BLITAPOLLO_H +#define _INC_BLITAPOLLO_H + +#include "asminterface.h" + +/* + interface for all functions + input: iptr = input in any color format + optr = output in any color format + istride = line width (total, in bytes) of input + ostride = line width (total, in bytes) of output + w = width (in pixels) to copy + h = height (in pixels) to copy +*/ +#define APOLLOBLIT(_name_) \ +ASM void _name_( ASMR(a0) unsigned char *iptr ASMREG(a0),\ + ASMR(a1) unsigned char *optr ASMREG(a1),\ + ASMR(d2) unsigned int istride ASMREG(d2),\ + ASMR(d3) unsigned int ostride ASMREG(d3),\ + ASMR(d0) unsigned int w ASMREG(d0),\ + ASMR(d1) unsigned int h ASMREG(d1)\ +); + +#define APOLLOBLITPROTO \ +ASM void (*)( ASMR(a0) unsigned char *iptr ASMREG(a0),\ + ASMR(a1) unsigned char *optr ASMREG(a1),\ + ASMR(d2) unsigned int istride ASMREG(d2),\ + ASMR(d3) unsigned int ostride ASMREG(d3),\ + ASMR(d0) unsigned int w ASMREG(d0),\ + ASMR(d1) unsigned int h ASMREG(d1)\ +) + +/* generic: copy bytes, note: width must be multiplied with byte per pixel before calling for this one */ +APOLLOBLIT( ApolloCopyRect ); + +/* target: RGB565 */ +APOLLOBLIT( ApolloARGBtoRGB565 ); +APOLLOBLIT( ApolloRGBtoRGB565 ); +APOLLOBLIT( ApolloBGRtoRGB565 ); +APOLLOBLIT( ApolloBGRAtoRGB565 ); + +/*APOLLOBLIT( ApolloBGRAtoRGB565LE );*/ /* rewrite this one! */ + +/* target: RGB24 */ +APOLLOBLIT( ApolloARGBtoRGB24 ); +APOLLOBLIT( ApolloBGRAtoRGB24 ); +APOLLOBLIT( ApolloBGRtoRGB24 ); + +/* target: RGB32 */ +APOLLOBLIT( ApolloARGBtoBGRA ); + + +#endif /* _INC_BLITAPOLLO_H */ diff --git a/src/video/apollo/colorkeyapollo.asm b/src/video/apollo/colorkeyapollo.asm new file mode 100644 index 000000000..aa57f8aee --- /dev/null +++ b/src/video/apollo/colorkeyapollo.asm @@ -0,0 +1,259 @@ +; ------------------------------------------------------------------------------ +; | Apollo AMMX blitting functions | +; | Henryk Richter | +; | All rights reserved | +; ------------------------------------------------------------------------------ +; + +; enable debugging code block (unused right now) +DEBUG EQU 0 +; +; AMMX usage instruction set fuse, "burned" on first use (i.e. replace by appropriate branch) +; this means, the code will branch to 68k generic code or AMMX code +; of this define is FALSE (=0), the code will be Apollo only +DOFUSE68 EQU 1 +FUSE68CHECK macro + tst.b _Apollo_AMMX2on ;have Apollo AMMX2 ? (AMMX1: _Apollo_AMMXon + endm + + ifne DOFUSE68 + XREF _Apollo_AMMXon ;0.b = Off, 1.b = On + XREF _Apollo_AMMX2on +_LVOCacheClearU EQU -636 ;yes, yes I know... + endc + + + XDEF _ApolloKeyARGBtoARGB ;TODO + XDEF _ApolloKeyRGB565toRGB565 ; + + + machine ac68080 + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Macros +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + +; macro stuff +; CONVHEAD4P +; move (a0)+,(a1)+ ;number of bytes according to input/output pixel formats +; CONVMID4P +; move.b (a0)+,(a1)+ ; single conversion if number of pixels is not a multiple of 4 +; CONVEND4P +; CONVLINEEND + +; conversion header (set up variables and define outer loop) +; variables used/modified in the macros +; D5 - horizontal loop count (in pixels) +; D4 - trashed in CONVHEAD4P +; D0 - trashed in CONVHEAD4P +; +CONVHEAD4P macro + ; 4 pixels per loop + remaining pixels afterwards - change size to match + ; + ; 4 instructions, one Apollo cycle + moveq #-4,d5 ;F $fffffffc + and.l d0,d5 ;F clear lower 2 bits + moveq #3,d4 ;F + and.l d4,d0 ;F keep lower 2 bits + sub.l d0,d5 ;total width - (0,1,2,3) -> simplifies loop +.yloop: + move.l d5,d0 +.xloop: + ble.s .xleftover ;less than 4 pixels remaining ? + endm + + ;(a0)+,(a1)+ in here + +CONVMID4P macro + subq.l #4,d0 ; + bra.s .xloop +.xleftover: + beq.s .xnoleftover + ;1...3 pixels left over (if width is not a multiple of 4 + endm + + ;(a0)+,(a1)+ in here + +CONVEND4P macro + addq.l #1,d0 + bra.s .xleftover ;leftover loop + +.xnoleftover: ;end of x loop + endm + +CONVLINEEND macro + subq.l #1,d1 + + adda.l d2,a0 ;add skip values + adda.l d3,a1 + + bne.s .yloop + endm + +; in: - +; out: - +; trash: D4 +FUSE68 macro + ifne DOFUSE68 + move.w #\1-*-2,d4 ;see routine below, don't change this on it's own + bsr.w BurnFuse ;this is somewhat cautious but it could be more + ;efficient with bsr.w, followed by dc.w \1-*-... + else + ;do nothing if disabled + endc + endm + + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Code section +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + section .text + +; Called once per burned fuse function +; (note: could be optimized to burn all fuses at once) + ifne DOFUSE68 + +BurnFuse: + movem.l d0/a0,-(sp) + move.l 8(sp),a0 ;return address (skipping the saved registers) + + FUSE68CHECK + beq.s .burn68k + + ; + ; burn in Apollo by executing nonsense code + ; + move.w #$283c,-8(a0) ;move.l #xxx,d4 ;TODO: short-range branch + move.w #$7A00,-2(a0) ;moveq #0,d5 ;fused instructions, 1 cycle lost on Apollo + + bra.s .ret + +.burn68k: + ; + ; burn in 68k Code Path + ; + move.w #$6000,-8(a0) ;replace "move.w #branch,d4" by "bra.w branch" + subq.l #8,8(sp) ;jump to the correct branch, before the BSR + + movem.l d1/a1/a6,-(sp) + move.l 4.w,a6 + jsr _LVOCacheClearU(a6) + movem.l (sp)+,d1/a1/a6 + +.ret: + movem.l (sp)+,d0/a0 + rts + + endc + + +; In: A0 - iptr +; A1 - optr +; D2 - skipped bytes in input after "width" pixels +; D3 - skipped bytes in output after "width" pixels +; D0 - width in pixels to copy +; D1 - height in pixels to copy +; D6 - color key +; +; Out: +; - + +_ApolloKeyARGBtoARGB: + + rts + +;BlitNtoNPixelAlpha + +;D6 = key color +_ApolloKeyRGB565toRGB565: + movem.l d4-d5,-(sp) + bra m68kKeyRGB565toRGB565 +; FUSE68 m68kKeyRGB565toRGB565 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;AMMX assisted branch-free version + + cmp (a0)+,d6 ;pixel A + sne d4 + lsl.l #2,d4 + cmp (a0)+,d6 ;pixel B + sne d4 + lsl.l #2,d4 + cmp (a0)+,d6 ;pixel C + sne d4 + lsl.l #2,d4 + cmp (a0)+,d6 ;pixel D + sne d4 + load -8(a0),E0 + lsr.l #6,d4 ;result in D4 AABBCCDD + storeM E0,D4,(a1)+ ; + + + CONVMID4P ;end of regular xloop + + move (a0)+,d4 + cmp.w d6,d4 + beq.s .skip5 + move.w d4,(a1) +.skip5 addq.l #2,a1 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + +ApolloKeyRGB565toRGB565_end: + movem.l (sp)+,d4-d5 + rts + + +m68kKeyRGB565toRGB565: ;safe to use: D4 + + CONVHEAD4P ;set up d5 (trash D0,D4 but D4 is useable now) + + ;plain 68k version + ;actually not that bad, Apollo Core will + ;fuse beq and move.w into implicit movec +RGB565CKEY MACRO + move (a0)+,d4 + cmp.w d6,d4 + beq.s \1 + move.w d4,(a1) +\1 addq.l #2,a1 + endm + + RGB565CKEY .skipP1 + RGB565CKEY .skipP2 + RGB565CKEY .skipP3 + RGB565CKEY .skipP4 + + CONVMID4P ;end of regular xloop + + RGB565CKEY .skipP5 + + CONVEND4P ;end of leftover xloop + CONVLINEEND ;y loop: advance a0/a1, loop if lines left + + bra ApolloKeyRGB565toRGB565_end + +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ +; +; Data section +; +;------------------------------------------------------------------------------------------------ +;------------------------------------------------------------------------------------------------ + +; section data,data +;curbank: dc.b 0 +; cnop 0,4 + + + END diff --git a/src/video/apollo/colorkeyapollo.h b/src/video/apollo/colorkeyapollo.h new file mode 100644 index 000000000..ed6d37091 --- /dev/null +++ b/src/video/apollo/colorkeyapollo.h @@ -0,0 +1,52 @@ +/* + colorkeyapollo.h + + author: Henryk Richter + + purpose: AMMX optimized include blitter functions + +*/ +#ifndef _INC_COLORKEYAPOLLO_H +#define _INC_COLORKEYAPOLLO_H + +#include "asminterface.h" + +/* + interface for all functions + input: iptr = input in any color format + optr = output in any color format + istride = line width (total, in bytes) of input + ostride = line width (total, in bytes) of output + w = width (in pixels) to copy + h = height (in pixels) to copy + key = color key to compare (if match, no write) +*/ +#define APOLLOCBLIT(_name_) \ +ASM void _name_( ASMR(a0) unsigned char *iptr ASMREG(a0),\ + ASMR(a1) unsigned char *optr ASMREG(a1),\ + ASMR(d2) unsigned int istride ASMREG(d2),\ + ASMR(d3) unsigned int ostride ASMREG(d3),\ + ASMR(d0) unsigned int w ASMREG(d0),\ + ASMR(d1) unsigned int h ASMREG(d1),\ + ASMR(d6) unsigned int key ASMREG(d6)\ +); + + +/* target: RGB565 */ +//APOLLOCBLIT( ApolloARGBtoRGB565 ); +//APOLLOCBLIT( ApolloRGBtoRGB565 ); +//APOLLOCBLIT( ApolloBGRtoRGB565 ); +//APOLLOCBLIT( ApolloBGRAtoRGB565 ); + +/* target: RGB24 */ +//APOLLOCBLIT( ApolloARGBtoRGB24 ); +//APOLLOCBLIT( ApolloBGRAtoRGB24 ); +//APOLLOCBLIT( ApolloBGRtoRGB24 ); + +/* target: RGB32 */ +//APOLLOCBLIT( ApolloKeyARGBtoARGB ); + +APOLLOCBLIT( ApolloKeyRGB565toRGB565 ); + + +#endif /* _INC_COLORKEYAPOLLO_H */ diff --git a/src/video/cybergfx/SDL_agavideo.c b/src/video/cybergfx/SDL_agavideo.c new file mode 100644 index 000000000..62a9d9b0a --- /dev/null +++ b/src/video/cybergfx/SDL_agavideo.c @@ -0,0 +1,752 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + + +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" +#include "../../events/SDL_events_c.h" + +#include +#include +#include + + +#include "amigaos_video_AGA.h" +#include "amigaos_events.h" +#include "amigaos_mouse.h" + + +#include "amiga_c2p_aga.h" + + +// PAL modes! +static SDL_Rect + RECT_640x512 = { 0, 0, 640, 512 }, + RECT_640x480 = { 0, 0, 640, 480 }, + RECT_640x256 = { 0, 0, 640, 256 }, + RECT_320x256 = { 0, 0, 320, 256 }, + RECT_320x240 = { 0, 0, 320, 240 }, + RECT_320x200 = { 0, 0, 320, 200 }; + +static SDL_Rect *vid_modes[] = { + &RECT_640x512, + &RECT_640x480, + &RECT_640x256, + &RECT_320x256, + &RECT_320x240, + &RECT_320x200, + NULL +}; + + +static struct Window *_hardwareWindow = NULL; +static struct Screen *_hardwareScreen = NULL; + +// Hardware double buffering. +static struct ScreenBuffer *_hardwareScreenBuffer[2]; +static BYTE _currentScreenBuffer = 0; + + +// AGA C2P. +static void *c2p[2] = { NULL, NULL }; + +// Palette data +static SDL_Color *_currentPalette; +static int _paletteDirtyStart, _paletteDirtyEnd; + + +// These settings are for PAL HIGH RES! +#define AGA_VIDEO_DEPTH 8 +#define AGA_MAX_VIDEO_WIDTH 640 +#define AGA_MAX_VIDEO_HEIGHT 512 + + +static int AGA_VideoInit(SDL_PixelFormat *vformat) { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("[AGA_VideoInit]: START\n"); +#endif + + /* Set the screen depth */ + vformat->BitsPerPixel = AGA_VIDEO_DEPTH; + + vformat->BytesPerPixel = 1; + + // Not used for 8 bit screens. + vformat->Rmask = 0; + vformat->Gmask = 0; + vformat->Bmask = 0; + + // allocate palette storage + _currentPalette = (SDL_Color *)SDL_calloc(256, sizeof(SDL_Color)); + + _paletteDirtyStart = 256; + _paletteDirtyEnd = 0; + + /* We're done! */ + return (0); +} + +static SDL_Rect **AGA_ListModes(SDL_PixelFormat *format, Uint32 flags) { + switch ( format->BitsPerPixel ) { + case 8: + return vid_modes; + default: + return NULL; + } +} + + +static void AGA_ShutdownMode(void) { + if ( _hardwareWindow ) { + ClearPointer(_hardwareWindow); + CloseWindow(_hardwareWindow); + _hardwareWindow = NULL; + } + + if ( _hardwareScreen ) { + if ( _hardwareScreenBuffer[0] ) { + ChangeScreenBuffer(_hardwareScreen, _hardwareScreenBuffer[0]); + WaitTOF(); + WaitTOF(); + FreeScreenBuffer(_hardwareScreen, _hardwareScreenBuffer[0]); + _hardwareScreenBuffer[0] = NULL; + } + + if ( _hardwareScreenBuffer[1] ) { + FreeScreenBuffer(_hardwareScreen, _hardwareScreenBuffer[1]); + _hardwareScreenBuffer[1] = NULL; + } + + // Only close the screen if we actaully opened it ;) + if ( current_video->hidden->fullScreen ) { + CloseScreen(_hardwareScreen); + } + + _hardwareScreen = NULL; + } + + + if ( c2p[0] ) { + c2p8_deinit_stub(c2p[0]); + c2p[0] = NULL; + } + + if ( c2p[1] ) { + c2p8_deinit_stub(c2p[1]); + c2p[1] = NULL; + } + + // Clear the hidden pointers. + current_video->hidden->hardwareScreen = NULL; + current_video->hidden->hardwareWindow = NULL; + current_video->hidden->fullScreen = 0; +} + +static struct Screen *CreateHardwareScreen(ULONG modeId, int width, int height, int depth) { + + // Create the hardware screen. + return OpenScreenTags(NULL, + SA_Depth, depth, + SA_DisplayID, modeId, + SA_Top, 0, + SA_Left, 0, + SA_Width, width, + SA_Height, height, + SA_Type, CUSTOMSCREEN, + SA_Quiet, TRUE, + SA_ShowTitle, FALSE, + SA_Draggable, FALSE, + SA_Exclusive, TRUE, + SA_AutoScroll, FALSE, + TAG_END); +} + +static struct Window *CreateHardwareWindow(int width, int height) { + + return OpenWindowTags(NULL, + WA_Left, 0, + WA_Top, 0, + WA_InnerWidth, width, + WA_InnerHeight, height, + WA_PubScreen, (ULONG)_hardwareScreen, + WA_Backdrop, FALSE, + WA_Borderless, FALSE, + WA_Title, (ULONG)"include is Alive!", + WA_DragBar, TRUE, + WA_CloseGadget, TRUE, + WA_SizeGadget, TRUE, + WA_Activate, TRUE, + WA_SimpleRefresh, TRUE, + WA_NoCareRefresh, TRUE, + WA_ReportMouse, TRUE, + WA_RMBTrap, TRUE, + WA_IDCMP, IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_NEWSIZE, + WA_GimmeZeroZero, TRUE, + TAG_END); +} + +static struct Window *CreateFullScreenHardwareWindow(int width, int height) { + + return OpenWindowTags(NULL, + WA_Left, 0, + WA_Top, 0, + WA_Width, width, + WA_Height, height, + WA_CustomScreen, (ULONG)_hardwareScreen, + WA_Backdrop, TRUE, + WA_Borderless, TRUE, + WA_Activate, TRUE, + WA_SimpleRefresh, TRUE, + WA_NoCareRefresh, TRUE, + WA_ReportMouse, TRUE, + WA_RMBTrap, TRUE, + WA_IDCMP, IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_DELTAMOVE | IDCMP_MOUSEBUTTONS, + TAG_END); +} + + +static SDL_Surface *AGA_SetVideoMode(SDL_Surface *current, int width, int height, int bpp, Uint32 flags) { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("AGA_SetVideoMode(width=%d, height=%d, bpp=%d)\n", width, height, bpp); +#endif + + +#ifdef DEBUG_VIDEO + if (flags&SDL_HWPALETTE) { + SDL_LogDebugMsgchar("SDL_HWPALETTE requested\n"); + } else { + SDL_LogDebugMsgchar("SDL_HWPALETTE NOT requested\n"); + } + + if (flags&SDL_DOUBLEBUF) { + SDL_LogDebugMsgchar("AGA_SetVideoMode() - SDL_DOUBLEBUF requested\n"); + } else { + SDL_LogDebugMsgchar("SDL_DOUBLEBUF NOT requested\n"); + } + + if (flags&SDL_FULLSCREEN) { + SDL_LogDebugMsgchar("AGA_SetVideoMode() - SDL_FULLSCREEN requested\n"); + } else { + SDL_LogDebugMsgchar("SDL_FULLSCREEN NOT requested\n"); + } + + if (flags&SDL_RESIZABLE) { + SDL_LogDebugMsgchar("AGA_SetVideoMode() - SDL_RESIZABLE requested\n"); + } else { + SDL_LogDebugMsgchar("SDL_RESIZABLE NOT requested\n"); + } +#endif + + + + // Check args. + if ( bpp != AGA_VIDEO_DEPTH ) { + SDL_SetError("Invalid depth requested, only %d bit mode supported", AGA_VIDEO_DEPTH); + return NULL; + } + + if ( flags & SDL_FULLSCREEN ) { + if ( width > AGA_MAX_VIDEO_WIDTH ) { + SDL_SetError("Requested width cannot be greater than %d", AGA_MAX_VIDEO_WIDTH); + return NULL; + } + + if ( height > AGA_MAX_VIDEO_HEIGHT ) { + SDL_SetError("Requested height cannot be greater than %d", AGA_MAX_VIDEO_HEIGHT); + return NULL; + } + } else { + _hardwareScreen = LockPubScreen(NULL); + if ( !_hardwareScreen ) { + SDL_SetError("Couldn't lock the display"); + return NULL; + } + + UnlockPubScreen(NULL, _hardwareScreen); + + // Check that the current WB Screen depth matches the requested bit depth. + if ( _hardwareScreen->RastPort.BitMap->Depth != AGA_VIDEO_DEPTH ) { + SDL_SetError("Invalid Workbench Screen depth, only %d bit mode supported", AGA_VIDEO_DEPTH); + return NULL; + } + + // And that it's big enough. + if ( width > _hardwareScreen->Width ) { + SDL_SetError("Requested width cannot be greater than the width of the Workbench Screen"); + return NULL; + } + + if ( height > _hardwareScreen->Height ) { + SDL_SetError("Requested height cannot be greater than the height of the Workbench Screen"); + return NULL; + } + } + + + + + // Free any existing mode. + AGA_ShutdownMode(); + + + if ( flags & SDL_FULLSCREEN ) { + ULONG modeId = INVALID_ID; + DisplayInfoHandle handle; + struct DisplayInfo dispinfo; + struct DimensionInfo dimsinfo; + + + // Automatically choose the best mode. + modeId = BestModeID(BIDTAG_NominalWidth, width, + BIDTAG_NominalHeight, height, + BIDTAG_DesiredWidth, width, + BIDTAG_DesiredHeight, height, + BIDTAG_Depth, bpp, + BIDTAG_MonitorID, PAL_MONITOR_ID, + TAG_END); + + + // Verify the mode choosen. + if ( modeId != INVALID_ID ) { + if ((handle = FindDisplayInfo(modeId)) == NULL ) { + SDL_SetError("Couldn't find Display Info for requested mode"); + return NULL; + } + + if ( GetDisplayInfoData(handle, (UBYTE * ) & dispinfo, sizeof(dispinfo), DTAG_DISP, 0) == 0 ) { + SDL_SetError("Couldn't get Display Info Data for requested mode"); + return NULL; + } + + if ( GetDisplayInfoData(handle, (UBYTE * ) & dimsinfo, sizeof(dimsinfo), DTAG_DIMS, 0) == 0 ) { + SDL_SetError("Couldn't get Display Info Data for requested mode"); + return NULL; + } + + if ( dimsinfo.MaxDepth != bpp ) { + modeId = INVALID_ID; + } + + if ((dimsinfo.Nominal.MaxX + 1) != width ) { + modeId = INVALID_ID; + } + + if ((dimsinfo.Nominal.MaxY + 1) < height ) { + modeId = INVALID_ID; + } + } + + if ( modeId == INVALID_ID ) { + SDL_SetError("Couldn't find a Screen Mode for requested mode"); + return NULL; + } + + // Create the hardware screen. + _hardwareScreen = CreateHardwareScreen(modeId, width, height, bpp); + if ( !_hardwareScreen ) { + SDL_SetError("Couldn't create a Hardware Screen for requested mode"); + return NULL; + } + + + + // See if we need to set up double buffering. + if ( flags & SDL_DOUBLEBUF ) { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("Setting up double buffering for a full screen mode\n"); +#endif + _hardwareScreenBuffer[0] = AllocScreenBuffer(_hardwareScreen, NULL, SB_SCREEN_BITMAP); + _hardwareScreenBuffer[1] = AllocScreenBuffer(_hardwareScreen, NULL, 0); + + c2p[0] = c2p8_reloc_stub(_hardwareScreenBuffer[0]->sb_BitMap); + c2p[1] = c2p8_reloc_stub(_hardwareScreenBuffer[1]->sb_BitMap); + + _currentScreenBuffer = 1; + + + flags = (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF); + } else { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("Not using double buffering for a full screen mode\n"); +#endif + _hardwareScreenBuffer[0] = NULL; + _hardwareScreenBuffer[1] = NULL; + + c2p[0] = NULL; + c2p[1] = NULL; + + // Overwrite the flags - maybe not cool? + flags = (SDL_FULLSCREEN | SDL_SWSURFACE | SDL_HWPALETTE); + } + + + // Create the hardware window. + _hardwareWindow = CreateFullScreenHardwareWindow(width, height); + if ( !_hardwareWindow ) { + SDL_SetError("Couldn't create a Hardware Window for requested mode"); + return NULL; + } + + // Set the hidden pointers. + current_video->hidden->fullScreen = TRUE; + current_video->hidden->hardwareScreen = _hardwareScreen; + current_video->hidden->hardwareWindow = _hardwareWindow; + } else { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("Setting up a Windowed mode\n"); +#endif + + + //SDL_HWPALETTE - think this is OK + //SDL_HWSURFACE - think this is OK + + // Overwrite the flags - maybe not cool? + flags = (SDL_SWSURFACE | SDL_HWPALETTE); + + + // Create the hardware window. + _hardwareWindow = CreateHardwareWindow(width, height); + if ( !_hardwareWindow ) { + SDL_SetError("Couldn't create a Hardware Window for requested mode"); + return NULL; + } + + // Set the hidden pointers. + current_video->hidden->fullScreen = FALSE; + current_video->hidden->hardwareScreen = _hardwareScreen; + current_video->hidden->hardwareWindow = _hardwareWindow; + } + + + if ( current ) { + SDL_FreeSurface(current); + current = NULL; + } + + current = SDL_CreateRGBSurface(flags, width, height, bpp, 0, 0, 0, 0); + + +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("Setting current_video\n"); +#endif + + + + // Set the default grab mode. + //current_video->input_grab = SDL_GRAB_OFF; + + // Update info to match the new mode. + current_video->info.vfmt = current->format; + current_video->info.current_w = current->w; + current_video->info.current_h = current->h; + current_video->info.video_mem = 2048; // AGA. + + + /* We're done */ +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("Finished setting mode %dx%d\n", width, height); +#endif + + return current; +} + + +static int AGA_ToggleFullScreen(int on) { + // TODO +} + +static void AGA_updatePalette() { + + int i, numberOfEntries; + ULONG _agaPalette[256 * 3 + 2]; + +#ifdef DEBUG_PALETTE + SDL_LogDebugMsgchar ("AGA_updatePalette()\n"); + + SDL_LogDebugMsgchar("AGA_updatePalette() - _paletteDirtyStart = %d\n", _paletteDirtyStart); + SDL_LogDebugMsgchar("AGA_updatePalette() - _paletteDirtyEnd = %d\n", _paletteDirtyEnd); +#endif + + numberOfEntries = (_paletteDirtyEnd - _paletteDirtyStart); + + for ( i = 0; i < numberOfEntries; i++ ) { + _agaPalette[i * 3 + 1] = _currentPalette[_paletteDirtyStart + i].r << 24; + _agaPalette[i * 3 + 2] = _currentPalette[_paletteDirtyStart + i].g << 24; + _agaPalette[i * 3 + 3] = _currentPalette[_paletteDirtyStart + i].b << 24; + } + + _agaPalette[0] = (numberOfEntries << 16) + _paletteDirtyStart; + + // Terminator: NEEDED + _agaPalette[((numberOfEntries * 3) + 1)] = 0x00000000; + + LoadRGB32(&_hardwareScreen->ViewPort, _agaPalette); + + + // Reset. + _paletteDirtyStart = 256; + _paletteDirtyEnd = 0; +} + + +static int AGA_AllocHWSurface(SDL_Surface *surface) { + return -1; +} + +static void AGA_FreeHWSurface(SDL_Surface *surface) { + +} + +static int AGA_LockHWSurface(SDL_Surface *surface) { + return -1; +} + +static void AGA_UnlockHWSurface(SDL_Surface *surface) { + +} + +// Note - Not really a HW surface! +static int AGA_FlipHWSurface(SDL_Surface *surface) { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("AGA_FlipHWSurface()\n"); +#endif + + // Check whether the palette was changed. + if ( _paletteDirtyEnd != 0 ) { + AGA_updatePalette(); + } + + c2p8_stub(c2p[_currentScreenBuffer], _hardwareScreenBuffer[_currentScreenBuffer]->sb_BitMap, (UBYTE * )SDL_VideoSurface->pixels, (SDL_VideoSurface->w * SDL_VideoSurface->h)); + + if ( ChangeScreenBuffer(_hardwareScreen, _hardwareScreenBuffer[_currentScreenBuffer])) { + // Flip. + _currentScreenBuffer = _currentScreenBuffer ^ 1; + } + + return 0; // Strange but true! +} + +static void AGA_UpdateRects(int numrects, SDL_Rect *rects) { + int i; + Uint16 dirtyStart, dirtyEnd; + UBYTE *src; + + +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("AGA_UpdateRects()\n"); +#endif + + // Seed. + dirtyStart = SDL_VideoSurface->h; + dirtyEnd = 0; + + + // Find dirty strip extents. + for ( i = 0; i < numrects; i++ ) { + SDL_Rect *r = rects + i; + if ( !r ) { + continue; + } + + if ( r->y < dirtyStart ) { + dirtyStart = r->y; + } + + if ((r->y + r->h) > dirtyEnd ) { + dirtyEnd = (r->y + r->h); + } + } + + + // render straight to screen, no double buffering. + src = (UBYTE * )SDL_VideoSurface->pixels + (dirtyStart * SDL_VideoSurface->w); + + // Check whether the palette was changed. + if ( _paletteDirtyEnd != 0 ) { + AGA_updatePalette(); + } + + WaitTOF(); + + + //WriteChunkyPixels(rp,xstart,ystart,xstop,ystop,array,bytesperrow) + //WriteChunkyPixels(_hardwareWindow->RPort, 0, dirtyStart, SDL_VideoSurface->w - 1, dirtyEnd - 1, src, SDL_VideoSurface->w); + //WriteChunkyPixels(_hardwareWindow->RPort, 0, dirtyStart, SDL_VideoSurface->w - 1, dirtyEnd - 1, src, SDL_VideoSurface->w); + + + //c2p1x1_8_c5_bm_stub(SDL_VideoSurface->w, (dirtyEnd - dirtyStart), 0, dirtyStart, src, (UBYTE*)_hardwareScreen->RastPort.BitMap); + c2p1x1_8_c5_bm_stub(SDL_VideoSurface->w, (dirtyEnd - dirtyStart), 0, dirtyStart, src, (UBYTE *)_hardwareWindow->RPort->BitMap); +} + +static int AGA_SetColors(int firstcolor, int ncolors, SDL_Color *colors) { +#ifdef DEBUG_PALETTE + SDL_LogDebugMsgchar("AGA_SetColors()\n"); + + SDL_LogDebugMsgchar("AGA_SetColors() - firstcolor = %d\n", firstcolor); + SDL_LogDebugMsgchar("AGA_SetColors() - ncolors = %d\n", ncolors); +#endif + + SDL_memcpy(_currentPalette + firstcolor, colors, ncolors * sizeof(*colors)); + + if ( firstcolor < _paletteDirtyStart ) { + _paletteDirtyStart = firstcolor; + } + + if ( firstcolor + ncolors > _paletteDirtyEnd ) { + _paletteDirtyEnd = firstcolor + ncolors; + } + + return 1; +} + +/* Note: If we are terminated, this could be called in the middle of + another include video routine -- notably UpdateRects. +*/ +static void AGA_VideoQuit() { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("AGA_VideoQuit()\n"); +#endif + + // Free any existing mode. + AGA_ShutdownMode(); + + if ( current_video ) { + // Clear the hidden pointers. + current_video->hidden->hardwareScreen = NULL; + current_video->hidden->hardwareWindow = NULL; + + if ( SDL_VideoSurface != NULL ) { + SDL_free(SDL_VideoSurface->pixels); + SDL_VideoSurface->pixels = NULL; + } + } + + if ( _currentPalette ) { + SDL_free(_currentPalette); + _currentPalette = NULL; + } +} + +// This function fills in the structure pointed to by info with window-manager specific information. +static int AGA_GetWMInfo(SDL_SysWMinfo *info) { + if ( info ) { + info->version.major = SDL_MAJOR_VERSION; + info->version.minor = SDL_MINOR_VERSION; + info->version.patch = SDL_PATCHLEVEL; + + return 1; + } else { + return -1; + } +} + + +/* AGA driver bootstrap functions */ +static int AGA_Available(void) { + // TODO - see if this is an AGA machine! + + return 1; +} + +static void AGA_DeleteDevice() { + if ( current_video ) { +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("[AGA_DeleteDevice]: current_video is not NULL\n"); +#endif + SDL_free(current_video->hidden); + SDL_free(current_video); + } +} + +static SDL_VideoDevice *AGA_CreateDevice(int devindex) { + SDL_VideoDevice *device; + +#ifdef DEBUG_VIDEO + SDL_LogDebugMsgchar("[AGA_CreateDevice]: devindex = %d\n", devindex); +#endif + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *)SDL_malloc(sizeof(SDL_VideoDevice)); + if ( device ) { + SDL_memset(device, 0, (sizeof *device)); + device->hidden = (struct SDL_PrivateVideoData *)SDL_malloc((sizeof *device->hidden)); + } + if ((device == NULL) || (device->hidden == NULL)) { + SDL_OutOfMemory(); + if ( device ) { + SDL_free(device); + } + return (0); + } + SDL_memset(device->hidden, 0, (sizeof *device->hidden)); + + + /* Set the function pointers */ + device->VideoInit = AGA_VideoInit; + device->ListModes = AGA_ListModes; + device->SetVideoMode = AGA_SetVideoMode; + device->ToggleFullScreen = AGA_ToggleFullScreen; + device->CreateYUVOverlay = NULL; + device->SetColors = AGA_SetColors; + device->UpdateRects = AGA_UpdateRects; + device->VideoQuit = AGA_VideoQuit; + + device->AllocHWSurface = AGA_AllocHWSurface; + device->CheckHWBlit = NULL; + device->FillHWRect = NULL; + device->SetHWColorKey = NULL; + device->SetHWAlpha = NULL; + device->LockHWSurface = AGA_LockHWSurface; + device->UnlockHWSurface = AGA_UnlockHWSurface; + device->FlipHWSurface = AGA_FlipHWSurface; + device->FreeHWSurface = AGA_FreeHWSurface; + + device->UpdateMouse = NULL; + device->GrabInput = NULL; + + device->SetCaption = NULL; + device->SetIcon = NULL; + device->IconifyWindow = NULL; + device->GetWMInfo = AGA_GetWMInfo; + + device->FreeWMCursor = amiga_FreeWMCursor; + device->CreateWMCursor = amiga_CreateWMCursor; + device->ShowWMCursor = amiga_ShowWMCursor; + device->WarpWMCursor = amiga_WarpWMCursor; + device->MoveWMCursor = NULL; + device->CheckMouseMode = NULL; + + device->InitOSKeymap = amiga_InitOSKeymap; + device->PumpEvents = amiga_PumpEvents; + + device->free = AGA_DeleteDevice; + + return device; +} + +VideoBootStrap AGA_bootstrap = { + "AGA", "AmigaOS AGA", + AGA_Available, AGA_CreateDevice +}; diff --git a/src/video/cybergfx/SDL_cgxgl_wrapper.c b/src/video/cybergfx/SDL_cgxgl_wrapper.c new file mode 100644 index 000000000..adbd65b8a --- /dev/null +++ b/src/video/cybergfx/SDL_cgxgl_wrapper.c @@ -0,0 +1,2290 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_cgxgl_wrapper.c,v 1.2 2002/11/20 08:51:38 gabry Exp $"; +#endif + +#include +/* wrapper functions for StormMesa */ + +#ifdef SDL_VIDEO_OPENGL + +#include +#include +#include + +/* The include-GL API */ + +/* + * Miscellaneous + */ + + void AmiglClearIndex( GLfloat c ) { + glClearIndex(c); + } + + void AmiglClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) { + glClearColor(red, green, blue, alpha); + } + + void AmiglClear( GLbitfield mask ) { + glClear(mask); + } + + void AmiglIndexMask( GLuint mask ) { + glIndexMask(mask); + } + + void AmiglColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ) { + glColorMask(red, green, blue, alpha); + } + + void AmiglAlphaFunc( GLenum func, GLclampf ref ) { + glAlphaFunc(func, ref); + } + + void AmiglBlendFunc( GLenum sfactor, GLenum dfactor ) { + glBlendFunc(sfactor, dfactor); + } + + void AmiglLogicOp( GLenum opcode ) { + glLogicOp(opcode); + } + + void AmiglCullFace( GLenum mode ) { + glCullFace(mode); + } + + void AmiglFrontFace( GLenum mode ) { + glFrontFace(mode); + } + + void AmiglPointSize( GLfloat size ) { + glPointSize(size); + } + + void AmiglLineWidth( GLfloat width ) { + glLineWidth(width); + } + + void AmiglLineStipple( GLint factor, GLushort pattern ) { + glLineStipple(factor, pattern); + } + + void AmiglPolygonMode( GLenum face, GLenum mode ) { + glPolygonMode(face, mode); + } + + void AmiglPolygonOffset( GLfloat factor, GLfloat units ) { + glPolygonOffset(factor, units); + } + + void AmiglPolygonStipple( const GLubyte *mask ) { + glPolygonStipple(mask); + } + + void AmiglGetPolygonStipple( GLubyte *mask ) { + glGetPolygonStipple(mask); + } + + void AmiglEdgeFlag( GLboolean flag ) { + glEdgeFlag(flag); + } + + void AmiglEdgeFlagv( const GLboolean *flag ) { + glEdgeFlagv(flag); + } + + void AmiglScissor( GLint x, GLint y, GLsizei width, GLsizei height) { + glScissor(x, y, width, height); + } + + void AmiglClipPlane( GLenum plane, const GLdouble *equation ) { + glClipPlane(plane, equation); + } + + void AmiglGetClipPlane( GLenum plane, GLdouble *equation ) { + glGetClipPlane(plane, equation); + } + + void AmiglDrawBuffer( GLenum mode ) { + glDrawBuffer(mode); + } + + void AmiglReadBuffer( GLenum mode ) { + glReadBuffer(mode); + } + + void AmiglEnable( GLenum cap ) { + glEnable(cap); + } + + void AmiglDisable( GLenum cap ) { + glDisable(cap); + } + + GLboolean AmiglIsEnabled( GLenum cap ) { + return glIsEnabled(cap); + } + + void AmiglEnableClientState( GLenum cap ) { /* 1.1 */ + glEnableClientState(cap); + } + + void AmiglDisableClientState( GLenum cap ) { /* 1.1 */ + glDisableClientState(cap); + } + + void AmiglGetBooleanv( GLenum pname, GLboolean *params ) { + glGetBooleanv(pname, params); + } + + void AmiglGetDoublev( GLenum pname, GLdouble *params ) { + glGetDoublev(pname, params); + } + + void AmiglGetFloatv( GLenum pname, GLfloat *params ) { + glGetFloatv(pname, params); + } + + void AmiglGetIntegerv( GLenum pname, GLint *params ) { + glGetIntegerv(pname, params); + } + + void AmiglPushAttrib( GLbitfield mask ) { + glPushAttrib(mask); + } + + void AmiglPopAttrib( void ) { + glPopAttrib(); + } + + void AmiglPushClientAttrib( GLbitfield mask ) { /* 1.1 */ + glPushClientAttrib(mask); + } + + void AmiglPopClientAttrib( void ) { /* 1.1 */ + glPopClientAttrib(); + } + + GLint AmiglRenderMode( GLenum mode ) { + return glRenderMode(mode); + } + + GLenum AmiglGetError( void ) { + return glGetError(); + } + + const GLubyte* AmiglGetString( GLenum name ) { + return glGetString(name); + } + + void AmiglFinish( void ) { + glFinish(); + } + + void AmiglFlush( void ) { + glFlush(); + } + + void AmiglHint( GLenum target, GLenum mode ) { + glHint(target, mode); + } + +/* + * Depth Buffer + */ + + void AmiglClearDepth( GLclampd depth ) { + glClearDepth(depth); + } + + void AmiglDepthFunc( GLenum func ) { + glDepthFunc(func); + } + + void AmiglDepthMask( GLboolean flag ) { + glDepthMask(flag); + } + + void AmiglDepthRange( GLclampd near_val, GLclampd far_val ) { + glDepthRange(near_val, far_val); + } + +/* + * Accumulation Buffer + */ + + void AmiglClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha ) { + glClearAccum(red, green, blue, alpha); + } + + void AmiglAccum( GLenum op, GLfloat value ) { + glAccum(op, value); + } + +/* + * Transformation + */ + + void AmiglMatrixMode( GLenum mode ) { + glMatrixMode(mode); + } + + void AmiglOrtho( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ) { + glOrtho(left, right, bottom, top, near_val, far_val); + } + + void AmiglFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near_val, GLdouble far_val ) { + glFrustum(left, right, bottom, top, near_val, far_val); + } + + void AmiglViewport( GLint x, GLint y, GLsizei width, GLsizei height ) { + glViewport(x, y, width, height); + } + + void AmiglPushMatrix( void ) { + glPushMatrix(); + } + + void AmiglPopMatrix( void ) { + glPopMatrix(); + } + + void AmiglLoadIdentity( void ) { + glLoadIdentity(); + } + + void AmiglLoadMatrixd( const GLdouble *m ) { + glLoadMatrixd(m); + } + + void AmiglLoadMatrixf( const GLfloat *m ) { + glLoadMatrixf(m); + } + + void AmiglMultMatrixd( const GLdouble *m ) { + glMultMatrixd(m); + } + + void AmiglMultMatrixf( const GLfloat *m ) { + glMultMatrixf(m); + } + + void AmiglRotated( GLdouble angle, GLdouble x, GLdouble y, GLdouble z ) { + glRotated(angle, x, y, z); + } + + void AmiglRotatef( GLfloat angle, GLfloat x, GLfloat y, GLfloat z ) { + glRotatef(angle, x, y, z); + } + + void AmiglScaled( GLdouble x, GLdouble y, GLdouble z ) { + glScaled(x, y, z); + } + + void AmiglScalef( GLfloat x, GLfloat y, GLfloat z ) { + glScalef(x, y, z); + } + + void AmiglTranslated( GLdouble x, GLdouble y, GLdouble z ) { + glTranslated(x, y, z); + } + + void AmiglTranslatef( GLfloat x, GLfloat y, GLfloat z ) { + glTranslatef(x, y, z); + } + +/* + * Display Lists + */ + + GLboolean AmiglIsList( GLuint list ) { + return glIsList(list); + } + + void AmiglDeleteLists( GLuint list, GLsizei range ) { + glDeleteLists(list, range); + } + + GLuint AmiglGenLists( GLsizei range ) { + return glGenLists(range); + } + + void AmiglNewList( GLuint list, GLenum mode ) { + glNewList(list, mode); + } + + void AmiglEndList( void ) { + glEndList(); + } + + void AmiglCallList( GLuint list ) { + glCallList(list); + } + + void AmiglCallLists( GLsizei n, GLenum type, const GLvoid *lists ) { + glCallLists(n, type, lists); + } + + void AmiglListBase( GLuint base ) { + glListBase(base); + } + +/* + * Drawing Functions + */ + + void AmiglBegin( GLenum mode ) { + glBegin(mode); + } + + void AmiglEnd( void ) { + glEnd(); + } + + void AmiglVertex2d( GLdouble x, GLdouble y ) { glVertex2d(x, y); } + void AmiglVertex2f( GLfloat x, GLfloat y ) { glVertex2f(x, y); } + void AmiglVertex2i( GLint x, GLint y ) { glVertex2i(x, y); } + void AmiglVertex2s( GLshort x, GLshort y ) { glVertex2s(x, y); } + + void AmiglVertex3d( GLdouble x, GLdouble y, GLdouble z ) { glVertex3d(x, y, z); } + void AmiglVertex3f( GLfloat x, GLfloat y, GLfloat z ) { glVertex3f(x, y, z); } + void AmiglVertex3i( GLint x, GLint y, GLint z ) { glVertex3i(x, y, z); } + void AmiglVertex3s( GLshort x, GLshort y, GLshort z ) { glVertex3s(x, y, z); } + + void AmiglVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ){ glVertex4d(x, y, z, w); } + void AmiglVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { glVertex4f(x, y, z, w); } + void AmiglVertex4i( GLint x, GLint y, GLint z, GLint w ) { glVertex4i(x, y, z, w); } + void AmiglVertex4s( GLshort x, GLshort y, GLshort z, GLshort w ) { glVertex4s(x, y, z, w); } + + void AmiglVertex2dv( const GLdouble *v ) { glVertex2dv(v); } + void AmiglVertex2fv( const GLfloat *v ) { glVertex2fv(v); } + void AmiglVertex2iv( const GLint *v ) { glVertex2iv(v); } + void AmiglVertex2sv( const GLshort *v ) { glVertex2sv(v); } + + void AmiglVertex3dv( const GLdouble *v ) { glVertex3dv(v); } + void AmiglVertex3fv( const GLfloat *v ) { glVertex3fv(v); } + void AmiglVertex3iv( const GLint *v ) { glVertex3iv(v); } + void AmiglVertex3sv( const GLshort *v ) { glVertex3sv(v); } + + void AmiglVertex4dv( const GLdouble *v ) { glVertex4dv(v); } + void AmiglVertex4fv( const GLfloat *v ) { glVertex4fv(v); } + void AmiglVertex4iv( const GLint *v ) { glVertex4iv(v); } + void AmiglVertex4sv( const GLshort *v ) { glVertex4sv(v); } + + void AmiglNormal3b( GLbyte nx, GLbyte ny, GLbyte nz ) { glNormal3b(nx, ny, nz); } + void AmiglNormal3d( GLdouble nx, GLdouble ny, GLdouble nz ){ glNormal3d(nx, ny, nz); } + void AmiglNormal3f( GLfloat nx, GLfloat ny, GLfloat nz ) { glNormal3f(nx, ny, nz); } + void AmiglNormal3i( GLint nx, GLint ny, GLint nz ) { glNormal3i(nx, ny, nz); } + void AmiglNormal3s( GLshort nx, GLshort ny, GLshort nz ) { glNormal3s(nx, ny, nz); } + + void AmiglNormal3bv( const GLbyte *v ) { glNormal3bv(v); } + void AmiglNormal3dv( const GLdouble *v ) { glNormal3dv(v); } + void AmiglNormal3fv( const GLfloat *v ) { glNormal3fv(v); } + void AmiglNormal3iv( const GLint *v ) { glNormal3iv(v); } + void AmiglNormal3sv( const GLshort *v ) { glNormal3sv(v); } + + void AmiglIndexd( GLdouble c ) { glIndexd(c); } + void AmiglIndexf( GLfloat c ) { glIndexf(c); } + void AmiglIndexi( GLint c ) { glIndexi(c); } + void AmiglIndexs( GLshort c ) { glIndexs(c); } + void AmiglIndexub( GLubyte c ) { glIndexub(c); } + + void AmiglIndexdv( const GLdouble *c ) { glIndexdv(c); } + void AmiglIndexfv( const GLfloat *c ) { glIndexfv(c); } + void AmiglIndexiv( const GLint *c ) { glIndexiv(c); } + void AmiglIndexsv( const GLshort *c ) { glIndexsv(c); } + void AmiglIndexubv( const GLubyte *c ) { glIndexubv(c); } + + void AmiglColor3b( GLbyte red, GLbyte green, GLbyte blue ) { glColor3b(red, green, blue); } + void AmiglColor3d( GLdouble red, GLdouble green, GLdouble blue ) { glColor3d(red, green, blue); } + void AmiglColor3f( GLfloat red, GLfloat green, GLfloat blue ) { glColor3f(red, green, blue); } + void AmiglColor3i( GLint red, GLint green, GLint blue ) { glColor3i(red, green, blue); } + void AmiglColor3s( GLshort red, GLshort green, GLshort blue ) { glColor3s(red, green, blue); } + void AmiglColor3ub( GLubyte red, GLubyte green, GLubyte blue ) { glColor3ub(red, green, blue); } + void AmiglColor3ui( GLuint red, GLuint green, GLuint blue ) { glColor3ui(red, green, blue); } + void AmiglColor3us( GLushort red, GLushort green, GLushort blue ){ glColor3us(red, green, blue); } + + void AmiglColor4b( GLbyte red, GLbyte green, + GLbyte blue, GLbyte alpha ) { glColor4b(red, green, blue, alpha); } + void AmiglColor4d( GLdouble red, GLdouble green, + GLdouble blue, GLdouble alpha ) { glColor4d(red, green, blue, alpha); } + void AmiglColor4f( GLfloat red, GLfloat green, + GLfloat blue, GLfloat alpha ) { glColor4f(red, green, blue, alpha); } + void AmiglColor4i( GLint red, GLint green, + GLint blue, GLint alpha ) { glColor4i(red, green, blue, alpha); } + void AmiglColor4s( GLshort red, GLshort green, + GLshort blue, GLshort alpha ) { glColor4s(red, green, blue, alpha); } + void AmiglColor4ub( GLubyte red, GLubyte green, + GLubyte blue, GLubyte alpha ) { glColor4ub(red, green, blue, alpha); } + void AmiglColor4ui( GLuint red, GLuint green, + GLuint blue, GLuint alpha ) { glColor4ui(red, green, blue, alpha); } + void AmiglColor4us( GLushort red, GLushort green, + GLushort blue, GLushort alpha ){ glColor4us(red, green, blue, alpha); } + + void AmiglColor3bv( const GLbyte *v ) { glColor3bv(v); } + void AmiglColor3dv( const GLdouble *v ) { glColor3dv(v); } + void AmiglColor3fv( const GLfloat *v ) { glColor3fv(v); } + void AmiglColor3iv( const GLint *v ) { glColor3iv(v); } + void AmiglColor3sv( const GLshort *v ) { glColor3sv(v); } + void AmiglColor3ubv( const GLubyte *v ) { glColor3ubv(v); } + void AmiglColor3uiv( const GLuint *v ) { glColor3uiv(v); } + void AmiglColor3usv( const GLushort *v ) { glColor3usv(v); } + + void AmiglColor4bv( const GLbyte *v ) { glColor4bv(v); } + void AmiglColor4dv( const GLdouble *v ) { glColor4dv(v); } + void AmiglColor4fv( const GLfloat *v ) { glColor4fv(v); } + void AmiglColor4iv( const GLint *v ) { glColor4iv(v); } + void AmiglColor4sv( const GLshort *v ) { glColor4sv(v); } + void AmiglColor4ubv( const GLubyte *v ) { glColor4ubv(v); } + void AmiglColor4uiv( const GLuint *v ) { glColor4uiv(v); } + void AmiglColor4usv( const GLushort *v ) { glColor4usv(v); } + + void AmiglTexCoord1d( GLdouble s ) { glTexCoord1d(s); } + void AmiglTexCoord1f( GLfloat s ) { glTexCoord1f(s); } + void AmiglTexCoord1i( GLint s ) { glTexCoord1i(s); } + void AmiglTexCoord1s( GLshort s ) { glTexCoord1s(s); } + + void AmiglTexCoord2d( GLdouble s, GLdouble t ) { glTexCoord2d(s, t); } + void AmiglTexCoord2f( GLfloat s, GLfloat t ) { glTexCoord2f(s, t); } + void AmiglTexCoord2i( GLint s, GLint t ) { glTexCoord2i(s, t); } + void AmiglTexCoord2s( GLshort s, GLshort t ) { glTexCoord2s(s, t); } + + void AmiglTexCoord3d( GLdouble s, GLdouble t, GLdouble r ) { glTexCoord3d(s, t, r); } + void AmiglTexCoord3f( GLfloat s, GLfloat t, GLfloat r ) { glTexCoord3f(s, t, r); } + void AmiglTexCoord3i( GLint s, GLint t, GLint r ) { glTexCoord3i(s, t, r); } + void AmiglTexCoord3s( GLshort s, GLshort t, GLshort r ) { glTexCoord3s(s, t, r); } + + void AmiglTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q ) { glTexCoord4d(s, t, r, q); } + void AmiglTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q ) { glTexCoord4f(s, t, r, q); } + void AmiglTexCoord4i( GLint s, GLint t, GLint r, GLint q ) { glTexCoord4i(s, t, r, q); } + void AmiglTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q ) { glTexCoord4s(s, t, r, q); } + + void AmiglTexCoord1dv( const GLdouble *v ) { glTexCoord1dv(v); } + void AmiglTexCoord1fv( const GLfloat *v ) { glTexCoord1fv(v); } + void AmiglTexCoord1iv( const GLint *v ) { glTexCoord1iv(v); } + void AmiglTexCoord1sv( const GLshort *v ) { glTexCoord1sv(v); } + + void AmiglTexCoord2dv( const GLdouble *v ) { glTexCoord2dv(v); } + void AmiglTexCoord2fv( const GLfloat *v ) { glTexCoord2fv(v); } + void AmiglTexCoord2iv( const GLint *v ) { glTexCoord2iv(v); } + void AmiglTexCoord2sv( const GLshort *v ) { glTexCoord2sv(v); } + + void AmiglTexCoord3dv( const GLdouble *v ) { glTexCoord3dv(v); } + void AmiglTexCoord3fv( const GLfloat *v ) { glTexCoord3fv(v); } + void AmiglTexCoord3iv( const GLint *v ) { glTexCoord3iv(v); } + void AmiglTexCoord3sv( const GLshort *v ) { glTexCoord3sv(v); } + + void AmiglTexCoord4dv( const GLdouble *v ) { glTexCoord4dv(v); } + void AmiglTexCoord4fv( const GLfloat *v ) { glTexCoord4fv(v); } + void AmiglTexCoord4iv( const GLint *v ) { glTexCoord4iv(v); } + void AmiglTexCoord4sv( const GLshort *v ) { glTexCoord4sv(v); } + + void AmiglRasterPos2d( GLdouble x, GLdouble y ) { glRasterPos2d(x, y); } + void AmiglRasterPos2f( GLfloat x, GLfloat y ) { glRasterPos2f(x, y); } + void AmiglRasterPos2i( GLint x, GLint y ) { glRasterPos2i(x, y); } + void AmiglRasterPos2s( GLshort x, GLshort y ) { glRasterPos2s(x, y); } + + void AmiglRasterPos3d( GLdouble x, GLdouble y, GLdouble z ) { glRasterPos3d(x, y, z); } + void AmiglRasterPos3f( GLfloat x, GLfloat y, GLfloat z ) { glRasterPos3f(x, y, z); } + void AmiglRasterPos3i( GLint x, GLint y, GLint z ) { glRasterPos3i(x, y, z); } + void AmiglRasterPos3s( GLshort x, GLshort y, GLshort z ) { glRasterPos3s(x, y, z); } + + void AmiglRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w ) { glRasterPos4d(x, y, z, w); } + void AmiglRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { glRasterPos4f(x, y, z, w); } + void AmiglRasterPos4i( GLint x, GLint y, GLint z, GLint w ) { glRasterPos4i(x, y, z, w); } + void AmiglRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w ) { glRasterPos4s(x, y, z, w); } + + void AmiglRasterPos2dv( const GLdouble *v ) { glRasterPos2dv(v); } + void AmiglRasterPos2fv( const GLfloat *v ) { glRasterPos2fv(v); } + void AmiglRasterPos2iv( const GLint *v ) { glRasterPos2iv(v); } + void AmiglRasterPos2sv( const GLshort *v ) { glRasterPos2sv(v); } + + void AmiglRasterPos3dv( const GLdouble *v ) { glRasterPos3dv(v); } + void AmiglRasterPos3fv( const GLfloat *v ) { glRasterPos3fv(v); } + void AmiglRasterPos3iv( const GLint *v ) { glRasterPos3iv(v); } + void AmiglRasterPos3sv( const GLshort *v ) { glRasterPos3sv(v); } + + void AmiglRasterPos4dv( const GLdouble *v ) { glRasterPos4dv(v); } + void AmiglRasterPos4fv( const GLfloat *v ) { glRasterPos4fv(v); } + void AmiglRasterPos4iv( const GLint *v ) { glRasterPos4iv(v); } + void AmiglRasterPos4sv( const GLshort *v ) { glRasterPos4sv(v); } + + void AmiglRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 ) { glRectd(x1, y1, x2, y2); } + void AmiglRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 ) { glRectf(x1, y1, x2, y2); } + void AmiglRecti( GLint x1, GLint y1, GLint x2, GLint y2 ) { glRecti(x1, y1, x2, y2); } + void AmiglRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 ) { glRects(x1, y1, x2, y2); } + + void AmiglRectdv( const GLdouble *v1, const GLdouble *v2 ) { glRectdv(v1, v2); } + void AmiglRectfv( const GLfloat *v1, const GLfloat *v2 ) { glRectfv(v1, v2); } + void AmiglRectiv( const GLint *v1, const GLint *v2 ) { glRectiv(v1, v2); } + void AmiglRectsv( const GLshort *v1, const GLshort *v2 ) { glRectsv(v1, v2); } + +/* + * Vertex Arrays (1.1) + */ + + void AmiglVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ) { + glVertexPointer(size, type, stride, ptr); + } + + void AmiglNormalPointer( GLenum type, GLsizei stride, const GLvoid *ptr ) { + glNormalPointer(type, stride, ptr); + } + + void AmiglColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ) { + glColorPointer(size, type, stride, ptr); + } + + void AmiglIndexPointer( GLenum type, GLsizei stride, const GLvoid *ptr ) { + glIndexPointer(type, stride, ptr); + } + + void AmiglTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *ptr ) { + glTexCoordPointer(size, type, stride, ptr); + } + + void AmiglEdgeFlagPointer( GLsizei stride, const GLboolean *ptr ) { + glEdgeFlagPointer(stride, ptr); } + + void AmiglGetPointerv( GLenum pname, void **params ) { + glGetPointerv(pname, params); + } + + void AmiglArrayElement( GLint i ) { glArrayElement(i); } + + void AmiglDrawArrays( GLenum mode, GLint first, GLsizei count ) { + glDrawArrays(mode, first, count); + } + + void AmiglDrawElements( GLenum mode, GLsizei count, GLenum type, const GLvoid *indices ) { + glDrawElements(mode, count, type, indices); + } + + void AmiglInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer ) { + glInterleavedArrays(format, stride, pointer); + } + +/* + * Lighting + */ + + void AmiglShadeModel( GLenum mode ) { glShadeModel(mode); } + + void AmiglLightf( GLenum light, GLenum pname, GLfloat param ) { glLightf(light, pname, param); } + void AmiglLighti( GLenum light, GLenum pname, GLint param ) { glLighti(light, pname, param); } + void AmiglLightfv( GLenum light, GLenum pname, + const GLfloat *params ) { glLightfv(light, pname, params); } + void AmiglLightiv( GLenum light, GLenum pname, + const GLint *params ) { glLightiv(light, pname, params); } + + void AmiglGetLightfv( GLenum light, GLenum pname, + GLfloat *params ) { glGetLightfv(light, pname, params); } + void AmiglGetLightiv( GLenum light, GLenum pname, + GLint *params ) { glGetLightiv(light, pname, params); } + + void AmiglLightModelf( GLenum pname, GLfloat param ) { glLightModelf(pname, param); } + void AmiglLightModeli( GLenum pname, GLint param ) { glLightModeli(pname, param); } + void AmiglLightModelfv( GLenum pname, const GLfloat *params ) { glLightModelfv(pname, params); } + void AmiglLightModeliv( GLenum pname, const GLint *params ) { glLightModeliv(pname, params); } + + void AmiglMaterialf( GLenum face, GLenum pname, GLfloat param ) { glMaterialf(face, pname, param); } + void AmiglMateriali( GLenum face, GLenum pname, GLint param ) { glMateriali(face, pname, param); } + void AmiglMaterialfv( GLenum face, GLenum pname, const GLfloat *params ) { glMaterialfv(face, pname, params); } + void AmiglMaterialiv( GLenum face, GLenum pname, const GLint *params ) { glMaterialiv(face, pname, params); } + + void AmiglGetMaterialfv( GLenum face, GLenum pname, GLfloat *params ) { glGetMaterialfv(face, pname, params); } + void AmiglGetMaterialiv( GLenum face, GLenum pname, GLint *params ) { glGetMaterialiv(face, pname, params); } + + void AmiglColorMaterial( GLenum face, GLenum mode ) { glColorMaterial(face, mode); } + +/* + * Raster functions + */ + + void AmiglPixelZoom( GLfloat xfactor, GLfloat yfactor ) { glPixelZoom(xfactor, yfactor); } + + void AmiglPixelStoref( GLenum pname, GLfloat param ) { glPixelStoref(pname, param); } + void AmiglPixelStorei( GLenum pname, GLint param ) { glPixelStorei(pname, param); } + + void AmiglPixelTransferf( GLenum pname, GLfloat param ) { glPixelTransferf(pname, param); } + void AmiglPixelTransferi( GLenum pname, GLint param ) { glPixelTransferi(pname, param); } + + void AmiglPixelMapfv( GLenum map, GLint mapsize, + const GLfloat *values ) { glPixelMapfv(map, mapsize, values); } + void AmiglPixelMapuiv( GLenum map, GLint mapsize, + const GLuint *values ) { glPixelMapuiv(map, mapsize, values); } + void AmiglPixelMapusv( GLenum map, GLint mapsize, + const GLushort *values ) { glPixelMapusv(map, mapsize, values); } + + void AmiglGetPixelMapfv( GLenum map, GLfloat *values ) { glGetPixelMapfv(map, values); } + void AmiglGetPixelMapuiv( GLenum map, GLuint *values ) { glGetPixelMapuiv(map, values); } + void AmiglGetPixelMapusv( GLenum map, GLushort *values ){ glGetPixelMapusv(map, values); } + + void AmiglBitmap( GLsizei width, GLsizei height, + GLfloat xorig, GLfloat yorig, + GLfloat xmove, GLfloat ymove, + const GLubyte *bitmap ) { + + glBitmap(width, height, xorig, yorig, xmove, ymove, bitmap); + } + + void AmiglReadPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + GLvoid *pixels ) { + + glReadPixels(x, y, width, height, format, type, pixels); + } + + void AmiglDrawPixels( GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) { + glDrawPixels(width, height, format, type, pixels); + } + + void AmiglCopyPixels( GLint x, GLint y, + GLsizei width, GLsizei height, + GLenum type ) { + glCopyPixels(x, y, width, height, type); + } + +/* + * Stenciling + */ + + void AmiglStencilFunc( GLenum func, GLint ref, GLuint mask ) { + glStencilFunc(func, ref, mask); + } + + void AmiglStencilMask( GLuint mask ) { + glStencilMask(mask); + } + + void AmiglStencilOp( GLenum fail, GLenum zfail, GLenum zpass ) { + glStencilOp(fail, zfail, zpass); + } + + void AmiglClearStencil( GLint s ) { + glClearStencil(s); + } + +/* + * Texture mapping + */ + + void AmiglTexGend( GLenum coord, GLenum pname, GLdouble param ) { glTexGend(coord, pname, param); } + void AmiglTexGenf( GLenum coord, GLenum pname, GLfloat param ) { glTexGenf(coord, pname, param); } + void AmiglTexGeni( GLenum coord, GLenum pname, GLint param ) { glTexGeni(coord, pname, param); } + + void AmiglTexGendv( GLenum coord, GLenum pname, const GLdouble *params ) { glTexGendv(coord, pname, params); } + void AmiglTexGenfv( GLenum coord, GLenum pname, const GLfloat *params ) { glTexGenfv(coord, pname, params); } + void AmiglTexGeniv( GLenum coord, GLenum pname, const GLint *params ) { glTexGeniv(coord, pname, params); } + + void AmiglGetTexGendv( GLenum coord, GLenum pname, GLdouble *params ) { glGetTexGendv(coord, pname, params); } + void AmiglGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params ) { glGetTexGenfv(coord, pname, params); } + void AmiglGetTexGeniv( GLenum coord, GLenum pname, GLint *params ) { glGetTexGeniv(coord, pname, params); } + + void AmiglTexEnvf( GLenum target, GLenum pname, GLfloat param ) { glTexEnvf(target, pname, param); } + void AmiglTexEnvi( GLenum target, GLenum pname, GLint param ) { glTexEnvi(target, pname, param); } + + void AmiglTexEnvfv( GLenum target, GLenum pname, const GLfloat *params ) { glTexEnvfv(target, pname, params); } + void AmiglTexEnviv( GLenum target, GLenum pname, const GLint *params ) { glTexEnviv(target, pname, params); } + + void AmiglGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params ) { glGetTexEnvfv(target, pname, params); } + void AmiglGetTexEnviv( GLenum target, GLenum pname, GLint *params ) { glGetTexEnviv(target, pname, params); } + + void AmiglTexParameterf( GLenum target, GLenum pname, GLfloat param ) { glTexParameterf(target, pname, param); } + void AmiglTexParameteri( GLenum target, GLenum pname, GLint param ) { glTexParameteri(target, pname, param); } + + void AmiglTexParameterfv( GLenum target, GLenum pname, const GLfloat *params ) { + glTexParameterfv(target, pname, params); + } + void AmiglTexParameteriv( GLenum target, GLenum pname, const GLint *params ) { + glTexParameteriv(target, pname, params); + } + + void AmiglGetTexParameterfv( GLenum target, GLenum pname, GLfloat *params) { + glGetTexParameterfv(target, pname, params); + } + void AmiglGetTexParameteriv( GLenum target, GLenum pname, GLint *params ) { + glGetTexParameteriv(target, pname, params); + } + + void AmiglGetTexLevelParameterfv( GLenum target, GLint level, GLenum pname, GLfloat *params ) { + glGetTexLevelParameterfv(target, level, pname, params); + } + void AmiglGetTexLevelParameteriv( GLenum target, GLint level, GLenum pname, GLint *params ) { + glGetTexLevelParameteriv(target, level, pname, params); + } + + void AmiglTexImage1D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) { + + glTexImage1D(target, level, internalFormat, + width, border, format, type, pixels); + } + + void AmiglTexImage2D( GLenum target, GLint level, + GLint internalFormat, + GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, + const GLvoid *pixels ) { + + glTexImage2D(target, level, internalFormat, + width, height, border, format, type, pixels); + } + + void AmiglGetTexImage( GLenum target, GLint level, + GLenum format, GLenum type, + GLvoid *pixels ) { + + glGetTexImage(target, level, format, type, pixels); + } + +/* 1.1 functions */ + + void AmiglGenTextures( GLsizei n, GLuint *textures ) { + glGenTextures(n, textures); + } + + void AmiglDeleteTextures( GLsizei n, const GLuint *textures) { + glDeleteTextures(n, textures); + } + + void AmiglBindTexture( GLenum target, GLuint texture ) { + glBindTexture(target, texture); + } + + void AmiglPrioritizeTextures( GLsizei n, const GLuint *textures, const GLclampf *priorities ) { + glPrioritizeTextures(n, textures, priorities); + } + + GLboolean AmiglAreTexturesResident( GLsizei n, const GLuint *textures, GLboolean *residences ) { + return glAreTexturesResident(n, textures, residences); + } + + GLboolean AmiglIsTexture( GLuint texture ) { + return glIsTexture(texture); + } + + void AmiglTexSubImage1D( GLenum target, GLint level, + GLint xoffset, + GLsizei width, GLenum format, + GLenum type, const GLvoid *pixels ) { + + glTexSubImage1D(target, level, xoffset, width, format, type, pixels); + } + + void AmiglTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, + GLenum format, GLenum type, + const GLvoid *pixels ) { + + glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); + } + + void AmiglCopyTexImage1D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLint border ) { + + glCopyTexImage1D(target, level, internalformat, x, y, width, border); + } + + void AmiglCopyTexImage2D( GLenum target, GLint level, + GLenum internalformat, + GLint x, GLint y, + GLsizei width, GLsizei height, + GLint border ){ + + glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); + } + + void AmiglCopyTexSubImage1D( GLenum target, GLint level, + GLint xoffset, GLint x, GLint y, + GLsizei width ) { + + glCopyTexSubImage1D(target, level, xoffset, x, y, width); + } + + void AmiglCopyTexSubImage2D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint x, GLint y, + GLsizei width, GLsizei height ) { + + glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); + } + +/* + * Evaluators + */ + + void AmiglMap1d( GLenum target, GLdouble u1, GLdouble u2, + GLint stride, + GLint order, const GLdouble *points ) { + glMap1d(target, u1, u2, stride, order, points); + } + void AmiglMap1f( GLenum target, GLfloat u1, GLfloat u2, + GLint stride, + GLint order, const GLfloat *points ) { + glMap1f(target, u1, u2, stride, order, points); + } + + void AmiglMap2d( GLenum target, + GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, + GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, + const GLdouble *points ) { + glMap2d(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + } + void AmiglMap2f( GLenum target, + GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, + GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, + const GLfloat *points ) { + glMap2f(target, u1, u2, ustride, uorder, v1, v2, vstride, vorder, points); + } + + void AmiglGetMapdv( GLenum target, GLenum query, GLdouble *v ) { + glGetMapdv(target, query, v); + } + void AmiglGetMapfv( GLenum target, GLenum query, GLfloat *v ) { + glGetMapfv(target, query, v); + } + void AmiglGetMapiv( GLenum target, GLenum query, GLint *v ) { + glGetMapiv(target, query, v); + } + + void AmiglEvalCoord1d( GLdouble u ) { + glEvalCoord1d(u); + } + void AmiglEvalCoord1f( GLfloat u ) { + glEvalCoord1f(u); + } + + void AmiglEvalCoord1dv( const GLdouble *u ) { + glEvalCoord1dv(u); + } + void AmiglEvalCoord1fv( const GLfloat *u ) { + glEvalCoord1fv(u); + } + + void AmiglEvalCoord2d( GLdouble u, GLdouble v ) { + glEvalCoord2d(u, v); + } + void AmiglEvalCoord2f( GLfloat u, GLfloat v ) { + glEvalCoord2f(u, v); + } + + void AmiglEvalCoord2dv( const GLdouble *u ) { + glEvalCoord2dv(u); + } + void AmiglEvalCoord2fv( const GLfloat *u ) { + glEvalCoord2fv(u); + } + + void AmiglMapGrid1d( GLint un, GLdouble u1, GLdouble u2 ) { + glMapGrid1d(un, u1, u2); + } + void AmiglMapGrid1f( GLint un, GLfloat u1, GLfloat u2 ) { + glMapGrid1f(un, u1, u2); + } + + void AmiglMapGrid2d( GLint un, GLdouble u1, GLdouble u2, GLint vn, GLdouble v1, GLdouble v2 ) { + glMapGrid2d(un, u1, u2, vn, v1, v2); + } + void AmiglMapGrid2f( GLint un, GLfloat u1, GLfloat u2, GLint vn, GLfloat v1, GLfloat v2 ) { + glMapGrid2f(un, u1, u2, vn, v1, v2); + } + + void AmiglEvalPoint1( GLint i ) { + glEvalPoint1(i); + } + + void AmiglEvalPoint2( GLint i, GLint j ) { + glEvalPoint2(i, j); + } + + void AmiglEvalMesh1( GLenum mode, GLint i1, GLint i2 ) { + glEvalMesh1(mode, i1, i2); + } + + void AmiglEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 ) { + glEvalMesh2(mode, i1, i2, j1, j2); + } + +/* + * Fog + */ + + void AmiglFogf( GLenum pname, GLfloat param ) { + glFogf(pname, param); + } + + void AmiglFogi( GLenum pname, GLint param ) { + glFogi(pname, param); + } + + void AmiglFogfv( GLenum pname, const GLfloat *params ) { + glFogfv(pname, params); + } + + void AmiglFogiv( GLenum pname, const GLint *params ) { + glFogiv(pname, params); + } + +/* + * Selection and Feedback + */ + + void AmiglFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer ) { + glFeedbackBuffer(size, type, buffer); + } + + void AmiglPassThrough( GLfloat token ) { + glPassThrough(token); + } + + void AmiglSelectBuffer( GLsizei size, GLuint *buffer ) { + glSelectBuffer(size, buffer); + } + + void AmiglInitNames( void ) { + glInitNames(); + } + + void AmiglLoadName( GLuint name ) { + glLoadName(name); + } + + void AmiglPushName( GLuint name ) { + glPushName(name); + } + + void AmiglPopName( void ) { + glPopName(); + } + +/* + * 1.0 Extensions + */ + +/* GL_EXT_blend_minmax */ + void AmiglBlendEquationEXT( GLenum mode ) { + glBlendEquationEXT(mode); + } + +/* GL_EXT_blend_color */ + void AmiglBlendColorEXT( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha ) { + glBlendColorEXT(red, green, blue, alpha); + } + +/* GL_EXT_polygon_offset */ + void AmiglPolygonOffsetEXT( GLfloat factor, GLfloat bias ) { + glPolygonOffsetEXT(factor, bias); + } + +/* GL_EXT_vertex_array */ + + void AmiglVertexPointerEXT( GLint size, GLenum type, + GLsizei stride, + GLsizei count, const GLvoid *ptr ) { + glVertexPointerEXT(size, type, stride, count, ptr); + } + + void AmiglNormalPointerEXT( GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr ) { + glNormalPointerEXT(type, stride, count, ptr); + } + + void AmiglColorPointerEXT( GLint size, GLenum type, + GLsizei stride, + GLsizei count, const GLvoid *ptr ) { + glColorPointerEXT(size, type, stride, count, ptr); + } + + void AmiglIndexPointerEXT( GLenum type, GLsizei stride, + GLsizei count, const GLvoid *ptr ) { + glIndexPointerEXT(type, stride, count, ptr); + } + + void AmiglTexCoordPointerEXT( GLint size, GLenum type, + GLsizei stride, GLsizei count, + const GLvoid *ptr ) { + glTexCoordPointerEXT(size, type, stride, count, ptr); + } + + void AmiglEdgeFlagPointerEXT( GLsizei stride, GLsizei count, const GLboolean *ptr ) { + glEdgeFlagPointerEXT(stride, count, ptr); + } + + void AmiglGetPointervEXT( GLenum pname, void **params ) { + glGetPointervEXT(pname, params); + } + + void AmiglArrayElementEXT( GLint i ) { + glArrayElementEXT(i); + } + + void AmiglDrawArraysEXT( GLenum mode, GLint first, GLsizei count ) { + glDrawArraysEXT(mode, first, count); + } + +/* GL_EXT_texture_object */ + + void AmiglGenTexturesEXT( GLsizei n, GLuint *textures ) { + glGenTexturesEXT(n, textures); + } + + void AmiglDeleteTexturesEXT( GLsizei n, const GLuint *textures) { + glDeleteTexturesEXT(n, textures); + } + + void AmiglBindTextureEXT( GLenum target, GLuint texture ) { + glBindTextureEXT(target, texture); + } + + void AmiglPrioritizeTexturesEXT( GLsizei n, const GLuint *textures, const GLclampf *priorities ) { + glPrioritizeTexturesEXT(n, textures, priorities); + } + + GLboolean AmiglAreTexturesResidentEXT( GLsizei n, const GLuint *textures, GLboolean *residences ) { + return glAreTexturesResidentEXT(n, textures, residences); + } + + GLboolean AmiglIsTextureEXT( GLuint texture ) { + return glIsTextureEXT(texture); + } + +/* GL_EXT_texture3D */ + + void AmiglTexImage3DEXT( GLenum target, GLint level, + GLenum internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) { + + glTexImage3DEXT(target, level, internalFormat, width, height, depth, border, + format, type, pixels); + } + + void AmiglTexSubImage3DEXT( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels) { + + glTexSubImage3DEXT(target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels); + } + + void AmiglCopyTexSubImage3DEXT( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ) { + + glCopyTexSubImage3DEXT(target, level, xoffset, yoffset, zoffset, + x, y, width, height); + } + +/* GL_EXT_color_table */ + + void AmiglColorTableEXT( GLenum target, GLenum internalformat, + GLsizei width, GLenum format, + GLenum type, const GLvoid *table ) { + glColorTableEXT(target, internalformat, width, format, type, table); + } + + void AmiglColorSubTableEXT( GLenum target, + GLsizei start, GLsizei count, + GLenum format, GLenum type, + const GLvoid *data ) { + glColorSubTableEXT(target, start, count, format, type, data); + } + + void AmiglGetColorTableEXT( GLenum target, GLenum format, + GLenum type, GLvoid *table ) { + glGetColorTableEXT(target, format, type, table); + } + + void AmiglGetColorTableParameterfvEXT( GLenum target, + GLenum pname, + GLfloat *params ) { + glGetColorTableParameterfvEXT(target, pname, params); + } + + void AmiglGetColorTableParameterivEXT( GLenum target, + GLenum pname, + GLint *params ) { + glGetColorTableParameterivEXT(target, pname, params); + } + +/* GL_SGIS_multitexture */ + + void AmiglMultiTexCoord1dSGIS(GLenum target, GLdouble s) { + glMultiTexCoord1dSGIS(target, s); + } + void AmiglMultiTexCoord1dvSGIS(GLenum target, const GLdouble *v) { + glMultiTexCoord1dvSGIS(target, v); + } + void AmiglMultiTexCoord1fSGIS(GLenum target, GLfloat s) { + glMultiTexCoord1fSGIS(target, s); + } + void AmiglMultiTexCoord1fvSGIS(GLenum target, const GLfloat *v) { + glMultiTexCoord1fvSGIS(target, v); + } + void AmiglMultiTexCoord1iSGIS(GLenum target, GLint s) { + glMultiTexCoord1iSGIS(target, s); + } + void AmiglMultiTexCoord1ivSGIS(GLenum target, const GLint *v) { + glMultiTexCoord1ivSGIS(target, v); + } + void AmiglMultiTexCoord1sSGIS(GLenum target, GLshort s) { + glMultiTexCoord1sSGIS(target, s); + } + void AmiglMultiTexCoord1svSGIS(GLenum target, const GLshort *v) { + glMultiTexCoord1svSGIS(target, v); + } + void AmiglMultiTexCoord2dSGIS(GLenum target, GLdouble s, GLdouble t) { + glMultiTexCoord2dSGIS(target, s, t); + } + void AmiglMultiTexCoord2dvSGIS(GLenum target, const GLdouble *v) { + glMultiTexCoord2dvSGIS(target, v); + } + void AmiglMultiTexCoord2fSGIS(GLenum target, GLfloat s, GLfloat t) { + glMultiTexCoord2fSGIS(target, s, t); + } + void AmiglMultiTexCoord2fvSGIS(GLenum target, const GLfloat *v) { + glMultiTexCoord2fvSGIS(target, v); + } + void AmiglMultiTexCoord2iSGIS(GLenum target, GLint s, GLint t) { + glMultiTexCoord2iSGIS(target, s, t); + } + void AmiglMultiTexCoord2ivSGIS(GLenum target, const GLint *v) { + glMultiTexCoord2ivSGIS(target, v); + } + void AmiglMultiTexCoord2sSGIS(GLenum target, GLshort s, GLshort t) { + glMultiTexCoord2sSGIS(target, s, t); + } + void AmiglMultiTexCoord2svSGIS(GLenum target, const GLshort *v) { + glMultiTexCoord2svSGIS(target, v); + } + void AmiglMultiTexCoord3dSGIS(GLenum target, GLdouble s, GLdouble t, GLdouble r) { + glMultiTexCoord3dSGIS(target, s, t, r); + } + void AmiglMultiTexCoord3dvSGIS(GLenum target, const GLdouble *v) { + glMultiTexCoord3dvSGIS(target, v); + } + void AmiglMultiTexCoord3fSGIS(GLenum target, GLfloat s, GLfloat t, GLfloat r) { + glMultiTexCoord3fSGIS(target, s, t, r); + } + void AmiglMultiTexCoord3fvSGIS(GLenum target, const GLfloat *v) { + glMultiTexCoord3fvSGIS(target, v); + } + void AmiglMultiTexCoord3iSGIS(GLenum target, GLint s, GLint t, GLint r) { + glMultiTexCoord3iSGIS(target, s, t, r); + } + void AmiglMultiTexCoord3ivSGIS(GLenum target, const GLint *v) { + glMultiTexCoord3ivSGIS(target, v); + } + void AmiglMultiTexCoord3sSGIS(GLenum target, GLshort s, GLshort t, GLshort r) { + glMultiTexCoord3sSGIS(target, s, t, r); + } + void AmiglMultiTexCoord3svSGIS(GLenum target, const GLshort *v) { + glMultiTexCoord3svSGIS(target, v); + } + void AmiglMultiTexCoord4dSGIS(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) { + glMultiTexCoord4dSGIS(target, s, t, r, q); + } + void AmiglMultiTexCoord4dvSGIS(GLenum target, const GLdouble *v) { + glMultiTexCoord4dvSGIS(target, v); + } + void AmiglMultiTexCoord4fSGIS(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) { + glMultiTexCoord4fSGIS(target, s, t, r, q); + } + void AmiglMultiTexCoord4fvSGIS(GLenum target, const GLfloat *v) { + glMultiTexCoord4fvSGIS(target, v); + } + void AmiglMultiTexCoord4iSGIS(GLenum target, GLint s, GLint t, GLint r, GLint q) { + glMultiTexCoord4iSGIS(target, s, t, r, q); + } + void AmiglMultiTexCoord4ivSGIS(GLenum target, const GLint *v) { + glMultiTexCoord4ivSGIS(target, v); + } + void AmiglMultiTexCoord4sSGIS(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) { + glMultiTexCoord4sSGIS(target, s, t, r, q); + } + void AmiglMultiTexCoord4svSGIS(GLenum target, const GLshort *v) { + glMultiTexCoord4svSGIS(target, v); + } + + void AmiglMultiTexCoordPointerSGIS(GLenum target, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer) { + glMultiTexCoordPointerSGIS(target, size, type, stride, pointer); + } + + void AmiglSelectTextureSGIS(GLenum target) { + glSelectTextureSGIS(target); + } + + void AmiglSelectTextureCoordSetSGIS(GLenum target) { + glSelectTextureCoordSetSGIS(target); + } + +/* GL_EXT_multitexture */ + + void AmiglMultiTexCoord1dEXT(GLenum target, GLdouble s) { + glMultiTexCoord1dEXT(target, s); + } + void AmiglMultiTexCoord1dvEXT(GLenum target, const GLdouble *v) { + glMultiTexCoord1dvEXT(target, v); + } + void AmiglMultiTexCoord1fEXT(GLenum target, GLfloat s) { + glMultiTexCoord1fEXT(target, s); + } + void AmiglMultiTexCoord1fvEXT(GLenum target, const GLfloat *v) { + glMultiTexCoord1fvEXT(target, v); + } + void AmiglMultiTexCoord1iEXT(GLenum target, GLint s) { + glMultiTexCoord1iEXT(target, s); + } + void AmiglMultiTexCoord1ivEXT(GLenum target, const GLint *v) { + glMultiTexCoord1ivEXT(target, v); + } + void AmiglMultiTexCoord1sEXT(GLenum target, GLshort s) { + glMultiTexCoord1sEXT(target, s); + } + void AmiglMultiTexCoord1svEXT(GLenum target, const GLshort *v) { + glMultiTexCoord1svEXT(target, v); + } + void AmiglMultiTexCoord2dEXT(GLenum target, GLdouble s, GLdouble t) { + glMultiTexCoord2dEXT(target, s, t); + } + void AmiglMultiTexCoord2dvEXT(GLenum target, const GLdouble *v) { + glMultiTexCoord2dvEXT(target, v); + } + void AmiglMultiTexCoord2fEXT(GLenum target, GLfloat s, GLfloat t) { + glMultiTexCoord2fEXT(target, s, t); + } + void AmiglMultiTexCoord2fvEXT(GLenum target, const GLfloat *v) { + glMultiTexCoord2fvEXT(target, v); + } + void AmiglMultiTexCoord2iEXT(GLenum target, GLint s, GLint t) { + glMultiTexCoord2iEXT(target, s, t); + } + void AmiglMultiTexCoord2ivEXT(GLenum target, const GLint *v) { + glMultiTexCoord2ivEXT(target, v); + } + void AmiglMultiTexCoord2sEXT(GLenum target, GLshort s, GLshort t) { + glMultiTexCoord2sEXT(target, s, t); + } + void AmiglMultiTexCoord2svEXT(GLenum target, const GLshort *v) { + glMultiTexCoord2svEXT(target, v); + } + void AmiglMultiTexCoord3dEXT(GLenum target, GLdouble s, GLdouble t, GLdouble r) { + glMultiTexCoord3dEXT(target, s, t, r); + } + void AmiglMultiTexCoord3dvEXT(GLenum target, const GLdouble *v) { + glMultiTexCoord3dvEXT(target, v); + } + void AmiglMultiTexCoord3fEXT(GLenum target, GLfloat s, GLfloat t, GLfloat r) { + glMultiTexCoord3fEXT(target, s, t, r); + } + void AmiglMultiTexCoord3fvEXT(GLenum target, const GLfloat *v) { + glMultiTexCoord3fvEXT(target, v); + } + void AmiglMultiTexCoord3iEXT(GLenum target, GLint s, GLint t, GLint r) { + glMultiTexCoord3iEXT(target, s, t, r); + } + void AmiglMultiTexCoord3ivEXT(GLenum target, const GLint *v) { + glMultiTexCoord3ivEXT(target, v); + } + void AmiglMultiTexCoord3sEXT(GLenum target, GLshort s, GLshort t, GLshort r) { + glMultiTexCoord3sEXT(target, s, t, r); + } + void AmiglMultiTexCoord3svEXT(GLenum target, const GLshort *v) { + glMultiTexCoord3svEXT(target, v); + } + void AmiglMultiTexCoord4dEXT(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q) { + glMultiTexCoord4dEXT(target, s, t, r, q); + } + void AmiglMultiTexCoord4dvEXT(GLenum target, const GLdouble *v) { + glMultiTexCoord4dvEXT(target, v); + } + void AmiglMultiTexCoord4fEXT(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q) { + glMultiTexCoord4fEXT(target, s, t, r, q); + } + void AmiglMultiTexCoord4fvEXT(GLenum target, const GLfloat *v) { + glMultiTexCoord4fvEXT(target, v); + } + void AmiglMultiTexCoord4iEXT(GLenum target, GLint s, GLint t, GLint r, GLint q) { + glMultiTexCoord4iEXT(target, s, t, r, q); + } + void AmiglMultiTexCoord4ivEXT(GLenum target, const GLint *v) { + glMultiTexCoord4ivEXT(target, v); + } + void AmiglMultiTexCoord4sEXT(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q) { + glMultiTexCoord4sEXT(target, s, t, r, q); + } + void AmiglMultiTexCoord4svEXT(GLenum target, const GLshort *v) { + glMultiTexCoord4svEXT(target, v); + } + void AmiglInterleavedTextureCoordSetsEXT( GLint factor ) { + glInterleavedTextureCoordSetsEXT(factor); + } + + void AmiglSelectTextureEXT( GLenum target ) { + glSelectTextureEXT(target); + } + + void AmiglSelectTextureCoordSetEXT( GLenum target ) { + glSelectTextureCoordSetEXT(target); + } + + void AmiglSelectTextureTransformEXT( GLenum target ) { + glSelectTextureTransformEXT(target); + } + +/* GL_EXT_point_parameters */ + void AmiglPointParameterfEXT( GLenum pname, GLfloat param ) { + glPointParameterfEXT(pname, param); + } + void AmiglPointParameterfvEXT( GLenum pname, const GLfloat *params ) { + glPointParameterfvEXT(pname, params); + } + +/* GL_MESA_window_pos */ + + void AmiglWindowPos2iMESA( GLint x, GLint y ) { + glWindowPos2iMESA(x, y); + } + void AmiglWindowPos2sMESA( GLshort x, GLshort y ) { + glWindowPos2sMESA(x, y); + } + void AmiglWindowPos2fMESA( GLfloat x, GLfloat y ) { + glWindowPos2fMESA(x, y); + } + void AmiglWindowPos2dMESA( GLdouble x, GLdouble y ) { + glWindowPos2dMESA(x, y); + } + void AmiglWindowPos2ivMESA( const GLint *p ) { + glWindowPos2ivMESA(p); + } + void AmiglWindowPos2svMESA( const GLshort *p ) { + glWindowPos2svMESA(p); + } + void AmiglWindowPos2fvMESA( const GLfloat *p ) { + glWindowPos2fvMESA(p); + } + void AmiglWindowPos2dvMESA( const GLdouble *p ) { + glWindowPos2dvMESA(p); + } + void AmiglWindowPos3iMESA( GLint x, GLint y, GLint z ) { + glWindowPos3iMESA(x, y, z); + } + void AmiglWindowPos3sMESA( GLshort x, GLshort y, GLshort z ) { + glWindowPos3sMESA(x, y, z); + } + void AmiglWindowPos3fMESA( GLfloat x, GLfloat y, GLfloat z ) { + glWindowPos3fMESA(x, y, z); + } + void AmiglWindowPos3dMESA( GLdouble x, GLdouble y, GLdouble z ) { + glWindowPos3dMESA(x, y, z); + } + void AmiglWindowPos3ivMESA( const GLint *p ) { + glWindowPos3ivMESA(p); + } + void AmiglWindowPos3svMESA( const GLshort *p ) { + glWindowPos3svMESA(p); + } + void AmiglWindowPos3fvMESA( const GLfloat *p ) { + glWindowPos3fvMESA(p); + } + void AmiglWindowPos3dvMESA( const GLdouble *p ) { + glWindowPos3dvMESA(p); + } + void AmiglWindowPos4iMESA( GLint x, GLint y, GLint z, GLint w ) { + glWindowPos4iMESA(x, y, z, w); + } + void AmiglWindowPos4sMESA( GLshort x, GLshort y, GLshort z, GLshort w ) { + glWindowPos4sMESA(x, y, z, w); + } + void AmiglWindowPos4fMESA( GLfloat x, GLfloat y, GLfloat z, GLfloat w ) { + glWindowPos4fMESA(x, y, z, w); + } + void AmiglWindowPos4dMESA( GLdouble x, GLdouble y, GLdouble z, GLdouble w) { + glWindowPos4dMESA(x, y, z, w); + } + void AmiglWindowPos4ivMESA( const GLint *p ) { + glWindowPos4ivMESA(p); + } + void AmiglWindowPos4svMESA( const GLshort *p ) { + glWindowPos4svMESA(p); + } + void AmiglWindowPos4fvMESA( const GLfloat *p ) { + glWindowPos4fvMESA(p); + } + void AmiglWindowPos4dvMESA( const GLdouble *p ) { + glWindowPos4dvMESA(p); + } + +/* GL_MESA_resize_buffers */ + + void AmiglResizeBuffersMESA( void ) { + glResizeBuffersMESA(); + } + +/* 1.2 functions */ + void AmiglDrawRangeElements( GLenum mode, GLuint start, + GLuint end, GLsizei count, GLenum type, const GLvoid *indices ) { + + glDrawRangeElements(mode, start, end, count, type, indices); + } + + void AmiglTexImage3D( GLenum target, GLint level, + GLenum internalFormat, + GLsizei width, GLsizei height, + GLsizei depth, GLint border, + GLenum format, GLenum type, + const GLvoid *pixels ) { + + glTexImage3D(target, level, internalFormat, width, height, depth, + border, format, type, pixels); + } + + void AmiglTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLsizei width, + GLsizei height, GLsizei depth, + GLenum format, + GLenum type, const GLvoid *pixels) { + + glTexSubImage3D(target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels); + } + + void AmiglCopyTexSubImage3D( GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLint zoffset, GLint x, + GLint y, GLsizei width, + GLsizei height ) { + + glCopyTexSubImage3D(target, level, xoffset, yoffset, zoffset, x, y, width, height); + } + +/* The GLU API */ + +/* + * + * Miscellaneous functions + * + */ + + void AmigluLookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez, + GLdouble centerx, GLdouble centery, + GLdouble centerz, + GLdouble upx, GLdouble upy, GLdouble upz ) { + + gluLookAt(eyex, eyey, eyez, centerx, centery, centerz, upx, upy, upz); + } + + void AmigluOrtho2D( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top ) { + gluOrtho2D(left, right, bottom, top); + } + + void AmigluPerspective( GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar ) { + gluPerspective(fovy, aspect, zNear, zFar); + } + + void AmigluPickMatrix( GLdouble x, GLdouble y, GLdouble width, GLdouble height, const GLint viewport[4] ) { + gluPickMatrix(x, y, width, height, viewport); + } + + GLint AmigluProject( GLdouble objx, GLdouble objy, GLdouble objz, + const GLdouble modelMatrix[16], + const GLdouble projMatrix[16], + const GLint viewport[4], + GLdouble *winx, GLdouble *winy, + GLdouble *winz ) { + + return gluProject(objx, objy, objz, modelMatrix, projMatrix, viewport, winx, winy, winz); + } + + GLint AmigluUnProject( GLdouble winx, GLdouble winy, + GLdouble winz, + const GLdouble modelMatrix[16], + const GLdouble projMatrix[16], + const GLint viewport[4], + GLdouble *objx, GLdouble *objy, + GLdouble *objz ) { + + return gluUnProject(winx, winy, winz, modelMatrix, projMatrix, viewport, objx, objy, objz); + } + + const GLubyte* AmigluErrorString( GLenum errorCode ) { + return gluErrorString(errorCode); + } + +/* + * + * Mipmapping and image scaling + * + */ + + GLint AmigluScaleImage( GLenum format, + GLint widthin, GLint heightin, + GLenum typein, const void *datain, + GLint widthout, GLint heightout, + GLenum typeout, void *dataout ) { + + return gluScaleImage(format, widthin, heightin, typein, datain, widthout, heightout, typeout, dataout); + } + + GLint AmigluBuild1DMipmaps( GLenum target, GLint components, + GLint width, GLenum format, + GLenum type, const void *data ) { + + return gluBuild1DMipmaps(target, components, width, format, type, data); + } + + GLint AmigluBuild2DMipmaps( GLenum target, GLint components, + GLint width, GLint height, + GLenum format, + GLenum type, const void *data ) { + + return gluBuild2DMipmaps(target, components, width, height, format, type, data); + } + +/* + * + * Quadrics + * + */ + + GLUquadricObj* AmigluNewQuadric( void ) { + return gluNewQuadric(); + } + + void AmigluDeleteQuadric( GLUquadricObj *state ) { + gluDeleteQuadric(state); + } + + void AmigluQuadricDrawStyle( GLUquadricObj *quadObject, GLenum drawStyle ) { + gluQuadricDrawStyle(quadObject, drawStyle); + } + + void AmigluQuadricOrientation( GLUquadricObj *quadObject, GLenum orientation ) { + gluQuadricOrientation(quadObject, orientation); + } + + void AmigluQuadricNormals( GLUquadricObj *quadObject, GLenum normals ) { + gluQuadricNormals(quadObject, normals); + } + + void AmigluQuadricTexture( GLUquadricObj *quadObject, GLboolean textureCoords ) { + gluQuadricTexture(quadObject, textureCoords); + } + + void AmigluQuadricCallback( GLUquadricObj *qobj, GLenum which, void (CALLBACK *fn)() ) { + gluQuadricCallback(qobj, which, fn); + } + + void AmigluCylinder( GLUquadricObj *qobj, + GLdouble baseRadius, + GLdouble topRadius, + GLdouble height, + GLint slices, GLint stacks ) { + + gluCylinder(qobj, baseRadius, topRadius, height, slices, stacks); + } + + void AmigluSphere( GLUquadricObj *qobj, GLdouble radius, GLint slices, GLint stacks ) { + gluSphere(qobj, radius, slices, stacks); + } + + void AmigluDisk( GLUquadricObj *qobj, + GLdouble innerRadius, GLdouble outerRadius, + GLint slices, GLint loops ) { + + gluDisk(qobj, innerRadius, outerRadius, slices, loops); + } + + void AmigluPartialDisk( GLUquadricObj *qobj, GLdouble innerRadius, + GLdouble outerRadius, GLint slices, + GLint loops, GLdouble startAngle, + GLdouble sweepAngle ) { + + gluPartialDisk(qobj, innerRadius, outerRadius, slices, loops, startAngle, sweepAngle); + } + +/* + * + * Nurbs + * + */ + + GLUnurbsObj* AmigluNewNurbsRenderer( void ) { + return gluNewNurbsRenderer(); + } + + void AmigluDeleteNurbsRenderer( GLUnurbsObj *nobj ) { + gluDeleteNurbsRenderer(nobj); + } + + void AmigluLoadSamplingMatrices( GLUnurbsObj *nobj, + const GLfloat modelMatrix[16], + const GLfloat projMatrix[16], + const GLint viewport[4] ) { + + gluLoadSamplingMatrices(nobj, modelMatrix, projMatrix, viewport); + } + + void AmigluNurbsProperty( GLUnurbsObj *nobj, GLenum property, GLfloat value ) { + gluNurbsProperty(nobj, property, value); + } + + void AmigluGetNurbsProperty( GLUnurbsObj *nobj, GLenum property, GLfloat *value ) { + gluGetNurbsProperty(nobj, property, value); + } + + void AmigluBeginCurve( GLUnurbsObj *nobj ) { + gluBeginCurve(nobj); + } + + void AmigluEndCurve( GLUnurbsObj * nobj ) { + gluEndCurve(nobj); + } + + void AmigluNurbsCurve( GLUnurbsObj *nobj, GLint nknots, + GLfloat *knot, GLint stride, + GLfloat *ctlarray, GLint order, + GLenum type ) { + + gluNurbsCurve(nobj, nknots, knot, stride, ctlarray, order, type); + } + + void AmigluBeginSurface( GLUnurbsObj *nobj ) { + gluBeginSurface(nobj); + } + + void AmigluEndSurface( GLUnurbsObj * nobj ) { + gluEndSurface(nobj); + } + + void AmigluNurbsSurface( GLUnurbsObj *nobj, + GLint sknot_count, GLfloat *sknot, + GLint tknot_count, GLfloat *tknot, + GLint s_stride, GLint t_stride, + GLfloat *ctlarray, + GLint sorder, GLint torder, + GLenum type ) { + + gluNurbsSurface(nobj, sknot_count, sknot, tknot_count, tknot, + s_stride, t_stride, ctlarray, sorder, torder, type); + } + + void AmigluBeginTrim( GLUnurbsObj *nobj ) { + gluBeginTrim(nobj); + } + + void AmigluEndTrim( GLUnurbsObj *nobj ) { + gluEndTrim(nobj); + } + + void AmigluPwlCurve( GLUnurbsObj *nobj, GLint count, GLfloat *array, GLint stride, GLenum type ) { + gluPwlCurve(nobj, count, array, stride, type); + } + + void AmigluNurbsCallback( GLUnurbsObj *nobj, GLenum which, void (CALLBACK *fn)() ) { + gluNurbsCallback(nobj, which, fn); + } + +/* + * + * Polygon tesselation + * + */ + + GLUtriangulatorObj* AmigluNewTess( void ) { + return gluNewTess(); + } + + void AmigluTessCallback( GLUtriangulatorObj *tobj, GLenum which, void (CALLBACK *fn)() ) { + gluTessCallback(tobj, which, fn); + } + + void AmigluDeleteTess( GLUtriangulatorObj *tobj ) { + gluDeleteTess(tobj); + } + + void AmigluBeginPolygon( GLUtriangulatorObj *tobj ) { + gluBeginPolygon(tobj); + } + + void AmigluEndPolygon( GLUtriangulatorObj *tobj ) { + gluEndPolygon(tobj); + } + + void AmigluNextContour( GLUtriangulatorObj *tobj, GLenum type ) { + gluNextContour(tobj, type); + } + + void AmigluTessVertex( GLUtriangulatorObj *tobj, GLdouble v[3], void *data ) { + gluTessVertex(tobj, v, data); + } + +/* + * + * New functions in GLU 1.1 + * + */ + + const GLubyte* AmigluGetString( GLenum name ) { + return gluGetString(name); + } + + +/* Find the functionAddress when the name is given */ +void *AmiGetGLProc(const char *proc) { + void *func = NULL; + + if(strcmp(proc, "glClearIndex") == 0) func = AmiglClearIndex; + else if(strcmp(proc, "glClearColor") == 0) func = AmiglClearColor; + else if(strcmp(proc, "glClear") == 0) func = AmiglClear; + else if(strcmp(proc, "glIndexMask") == 0) func = AmiglIndexMask; + else if(strcmp(proc, "glColorMask") == 0) func = AmiglColorMask; + else if(strcmp(proc, "glAlphaFunc") == 0) func = AmiglAlphaFunc; + else if(strcmp(proc, "glBlendFunc") == 0) func = AmiglBlendFunc; + else if(strcmp(proc, "glLogicOp") == 0) func = AmiglLogicOp; + else if(strcmp(proc, "glCullFace") == 0) func = AmiglCullFace; + else if(strcmp(proc, "glFrontFace") == 0) func = AmiglFrontFace; + else if(strcmp(proc, "glPointSize") == 0) func = AmiglPointSize; + else if(strcmp(proc, "glLineWidth") == 0) func = AmiglLineWidth; + else if(strcmp(proc, "glLineStipple") == 0) func = AmiglLineStipple; + else if(strcmp(proc, "glPolygonMode") == 0) func = AmiglPolygonMode; + else if(strcmp(proc, "glPolygonOffset") == 0) func = AmiglPolygonOffset; + else if(strcmp(proc, "glPolygonStipple") == 0) func = AmiglPolygonStipple; + else if(strcmp(proc, "glGetPolygonStipple") == 0) func = AmiglGetPolygonStipple; + else if(strcmp(proc, "glEdgeFlag") == 0) func = AmiglEdgeFlag; + else if(strcmp(proc, "glEdgeFlagv") == 0) func = AmiglEdgeFlagv; + else if(strcmp(proc, "glScissor") == 0) func = AmiglScissor; + else if(strcmp(proc, "glClipPlane") == 0) func = AmiglClipPlane; + else if(strcmp(proc, "glGetClipPlane") == 0) func = AmiglGetClipPlane; + else if(strcmp(proc, "glDrawBuffer") == 0) func = AmiglDrawBuffer; + else if(strcmp(proc, "glReadBuffer") == 0) func = AmiglReadBuffer; + else if(strcmp(proc, "glEnable") == 0) func = AmiglEnable; + else if(strcmp(proc, "glDisable") == 0) func = AmiglDisable; + else if(strcmp(proc, "glIsEnabled") == 0) func = AmiglIsEnabled; + else if(strcmp(proc, "glEnableClientState") == 0) func = AmiglEnableClientState; + else if(strcmp(proc, "glDisableClientState") == 0) func = AmiglDisableClientState; + else if(strcmp(proc, "glGetBooleanv") == 0) func = AmiglGetBooleanv; + else if(strcmp(proc, "glGetDoublev") == 0) func = AmiglGetDoublev; + else if(strcmp(proc, "glGetFloatv") == 0) func = AmiglGetFloatv; + else if(strcmp(proc, "glGetIntegerv") == 0) func = AmiglGetIntegerv; + else if(strcmp(proc, "glPushAttrib") == 0) func = glPushAttrib; + else if(strcmp(proc, "glPopAttrib") == 0) func = AmiglPopAttrib; + else if(strcmp(proc, "glPushClientAttrib") == 0) func = AmiglPushClientAttrib; + else if(strcmp(proc, "glPopClientAttrib") == 0) func = AmiglPopClientAttrib; + else if(strcmp(proc, "glRenderMode") == 0) func = AmiglRenderMode; + else if(strcmp(proc, "glGetError") == 0) func = AmiglGetError; + else if(strcmp(proc, "glGetString") == 0) func = AmiglGetString; + else if(strcmp(proc, "glFinish") == 0) func = AmiglFinish; + else if(strcmp(proc, "glFlush") == 0) func = AmiglFlush; + else if(strcmp(proc, "glHint") == 0) func = glHint; + else if(strcmp(proc, "glClearDepth") == 0) func = AmiglClearDepth; + else if(strcmp(proc, "glDepthFunc") == 0) func = AmiglDepthFunc; + else if(strcmp(proc, "glDepthMask") == 0) func = AmiglDepthMask; + else if(strcmp(proc, "glDepthRange") == 0) func = AmiglDepthRange; + else if(strcmp(proc, "glClearAccum") == 0) func = AmiglClearAccum; + else if(strcmp(proc, "glAccum") == 0) func = AmiglAccum; + else if(strcmp(proc, "glMatrixMode") == 0) func = AmiglMatrixMode; + else if(strcmp(proc, "glOrtho") == 0) func = AmiglOrtho; + else if(strcmp(proc, "glFrustum") == 0) func = AmiglFrustum; + else if(strcmp(proc, "glViewport") == 0) func = AmiglViewport; + else if(strcmp(proc, "glPushMatrix") == 0) func = AmiglPushMatrix; + else if(strcmp(proc, "glPopMatrix") == 0) func = AmiglPopMatrix; + else if(strcmp(proc, "glLoadIdentity") == 0) func = AmiglLoadIdentity; + else if(strcmp(proc, "glLoadMatrixd") == 0) func = AmiglLoadMatrixd; + else if(strcmp(proc, "glLoadMatrixf") == 0) func = AmiglLoadMatrixf; + else if(strcmp(proc, "glMultMatrixd") == 0) func = AmiglMultMatrixd; + else if(strcmp(proc, "glMultMatrixf") == 0) func = AmiglMultMatrixf; + else if(strcmp(proc, "glRotated") == 0) func = AmiglRotated; + else if(strcmp(proc, "glRotatef") == 0) func = AmiglRotatef; + else if(strcmp(proc, "glScaled") == 0) func = AmiglScaled; + else if(strcmp(proc, "glScalef") == 0) func = AmiglScalef; + else if(strcmp(proc, "glTranslated") == 0) func = AmiglTranslated; + else if(strcmp(proc, "glTranslatef") == 0) func = AmiglTranslatef; + else if(strcmp(proc, "glIsList") == 0) func = AmiglIsList; + else if(strcmp(proc, "glDeleteLists") == 0) func = AmiglDeleteLists; + else if(strcmp(proc, "glGenLists") == 0) func = AmiglGenLists; + else if(strcmp(proc, "glNewList") == 0) func = AmiglNewList; + else if(strcmp(proc, "glEndList") == 0) func = AmiglEndList; + else if(strcmp(proc, "glCallList") == 0) func = AmiglCallList; + else if(strcmp(proc, "glCallLists") == 0) func = AmiglCallLists; + else if(strcmp(proc, "glListBase") == 0) func = AmiglListBase; + else if(strcmp(proc, "glBegin") == 0) func = AmiglBegin; + else if(strcmp(proc, "glEnd") == 0) func = AmiglEnd; + else if(strcmp(proc, "glVertex2d") == 0) func = AmiglVertex2d; + else if(strcmp(proc, "glVertex2f") == 0) func = AmiglVertex2f; + else if(strcmp(proc, "glVertex2i") == 0) func = AmiglVertex2i; + else if(strcmp(proc, "glVertex2s") == 0) func = AmiglVertex2s; + else if(strcmp(proc, "glVertex3d") == 0) func = AmiglVertex3d; + else if(strcmp(proc, "glVertex3f") == 0) func = AmiglVertex3f; + else if(strcmp(proc, "glVertex3i") == 0) func = AmiglVertex3i; + else if(strcmp(proc, "glVertex3s") == 0) func = AmiglVertex3s; + else if(strcmp(proc, "glVertex4d") == 0) func = AmiglVertex4d; + else if(strcmp(proc, "glVertex4f") == 0) func = AmiglVertex4f; + else if(strcmp(proc, "glVertex4i") == 0) func = AmiglVertex4i; + else if(strcmp(proc, "glVertex4s") == 0) func = AmiglVertex4s; + else if(strcmp(proc, "glVertex2dv") == 0) func = AmiglVertex2dv; + else if(strcmp(proc, "glVertex2fv") == 0) func = AmiglVertex2fv; + else if(strcmp(proc, "glVertex2iv") == 0) func = AmiglVertex2iv; + else if(strcmp(proc, "glVertex2sv") == 0) func = AmiglVertex2sv; + else if(strcmp(proc, "glVertex3dv") == 0) func = AmiglVertex3dv; + else if(strcmp(proc, "glVertex3fv") == 0) func = AmiglVertex3fv; + else if(strcmp(proc, "glVertex3iv") == 0) func = AmiglVertex3iv; + else if(strcmp(proc, "glVertex3sv") == 0) func = AmiglVertex3sv; + else if(strcmp(proc, "glVertex4dv") == 0) func = AmiglVertex4dv; + else if(strcmp(proc, "glVertex4fv") == 0) func = AmiglVertex4fv; + else if(strcmp(proc, "glVertex4iv") == 0) func = AmiglVertex4iv; + else if(strcmp(proc, "glVertex4sv") == 0) func = AmiglVertex4sv; + else if(strcmp(proc, "glNormal3b") == 0) func = AmiglNormal3b; + else if(strcmp(proc, "glNormal3d") == 0) func = AmiglNormal3d; + else if(strcmp(proc, "glNormal3f") == 0) func = AmiglNormal3f; + else if(strcmp(proc, "glNormal3i") == 0) func = AmiglNormal3i; + else if(strcmp(proc, "glNormal3s") == 0) func = AmiglNormal3s; + else if(strcmp(proc, "glNormal3bv") == 0) func = AmiglNormal3bv; + else if(strcmp(proc, "glNormal3dv") == 0) func = AmiglNormal3dv; + else if(strcmp(proc, "glNormal3fv") == 0) func = AmiglNormal3fv; + else if(strcmp(proc, "glNormal3iv") == 0) func = AmiglNormal3iv; + else if(strcmp(proc, "glNormal3sv") == 0) func = AmiglNormal3sv; + else if(strcmp(proc, "glIndexd") == 0) func = AmiglIndexd; + else if(strcmp(proc, "glIndexf") == 0) func = AmiglIndexf; + else if(strcmp(proc, "glIndexi") == 0) func = AmiglIndexi; + else if(strcmp(proc, "glIndexs") == 0) func = AmiglIndexs; + else if(strcmp(proc, "glIndexub") == 0) func = AmiglIndexub; + else if(strcmp(proc, "glIndexdv") == 0) func = AmiglIndexdv; + else if(strcmp(proc, "glIndexfv") == 0) func = AmiglIndexfv; + else if(strcmp(proc, "glIndexiv") == 0) func = AmiglIndexiv; + else if(strcmp(proc, "glIndexsv") == 0) func = AmiglIndexsv; + else if(strcmp(proc, "glIndexubv") == 0) func = AmiglIndexubv; + else if(strcmp(proc, "glColor3b") == 0) func = AmiglColor3b; + else if(strcmp(proc, "glColor3d") == 0) func = AmiglColor3d; + else if(strcmp(proc, "glColor3f") == 0) func = AmiglColor3f; + else if(strcmp(proc, "glColor3i") == 0) func = AmiglColor3i; + else if(strcmp(proc, "glColor3s") == 0) func = AmiglColor3s; + else if(strcmp(proc, "glColor3ub") == 0) func = AmiglColor3ub; + else if(strcmp(proc, "glColor3ui") == 0) func = AmiglColor3ui; + else if(strcmp(proc, "glColor3us") == 0) func = AmiglColor3us; + else if(strcmp(proc, "glColor4b") == 0) func = AmiglColor4b; + else if(strcmp(proc, "glColor4d") == 0) func = AmiglColor4d; + else if(strcmp(proc, "glColor4f") == 0) func = AmiglColor4f; + else if(strcmp(proc, "glColor4i") == 0) func = AmiglColor4i; + else if(strcmp(proc, "glColor4s") == 0) func = AmiglColor4s; + else if(strcmp(proc, "glColor4ub") == 0) func = AmiglColor4ub; + else if(strcmp(proc, "glColor4ui") == 0) func = AmiglColor4ui; + else if(strcmp(proc, "glColor4us") == 0) func = AmiglColor4us; + else if(strcmp(proc, "glColor3bv") == 0) func = AmiglColor3bv; + else if(strcmp(proc, "glColor3dv") == 0) func = AmiglColor3dv; + else if(strcmp(proc, "glColor3fv") == 0) func = AmiglColor3fv; + else if(strcmp(proc, "glColor3iv") == 0) func = AmiglColor3iv; + else if(strcmp(proc, "glColor3sv") == 0) func = AmiglColor3sv; + else if(strcmp(proc, "glColor3ubv") == 0) func = AmiglColor3ubv; + else if(strcmp(proc, "glColor3uiv") == 0) func = AmiglColor3uiv; + else if(strcmp(proc, "glColor3usv") == 0) func = AmiglColor3usv; + else if(strcmp(proc, "glColor4bv") == 0) func = AmiglColor4bv; + else if(strcmp(proc, "glColor4dv") == 0) func = AmiglColor4dv; + else if(strcmp(proc, "glColor4fv") == 0) func = AmiglColor4fv; + else if(strcmp(proc, "glColor4iv") == 0) func = AmiglColor4iv; + else if(strcmp(proc, "glColor4sv") == 0) func = AmiglColor4sv; + else if(strcmp(proc, "glColor4ubv") == 0) func = AmiglColor4ubv; + else if(strcmp(proc, "glColor4uiv") == 0) func = AmiglColor4uiv; + else if(strcmp(proc, "glColor4usv") == 0) func = AmiglColor4usv; + else if(strcmp(proc, "glTexCoord1d") == 0) func = AmiglTexCoord1d; + else if(strcmp(proc, "glTexCoord1f") == 0) func = AmiglTexCoord1f; + else if(strcmp(proc, "glTexCoord1i") == 0) func = AmiglTexCoord1i; + else if(strcmp(proc, "glTexCoord1s") == 0) func = AmiglTexCoord1s; + else if(strcmp(proc, "glTexCoord2d") == 0) func = AmiglTexCoord2d; + else if(strcmp(proc, "glTexCoord2f") == 0) func = AmiglTexCoord2f; + else if(strcmp(proc, "glTexCoord2i") == 0) func = AmiglTexCoord2i; + else if(strcmp(proc, "glTexCoord2s") == 0) func = AmiglTexCoord2s; + else if(strcmp(proc, "glTexCoord3d") == 0) func = AmiglTexCoord3d; + else if(strcmp(proc, "glTexCoord3f") == 0) func = AmiglTexCoord3f; + else if(strcmp(proc, "glTexCoord3i") == 0) func = AmiglTexCoord3i; + else if(strcmp(proc, "glTexCoord3s") == 0) func = AmiglTexCoord3s; + else if(strcmp(proc, "glTexCoord4d") == 0) func = AmiglTexCoord4d; + else if(strcmp(proc, "glTexCoord4f") == 0) func = AmiglTexCoord4f; + else if(strcmp(proc, "glTexCoord4i") == 0) func = AmiglTexCoord4i; + else if(strcmp(proc, "glTexCoord4s") == 0) func = AmiglTexCoord4s; + else if(strcmp(proc, "glTexCoord1dv") == 0) func = AmiglTexCoord1dv; + else if(strcmp(proc, "glTexCoord1fv") == 0) func = AmiglTexCoord1fv; + else if(strcmp(proc, "glTexCoord1iv") == 0) func = AmiglTexCoord1iv; + else if(strcmp(proc, "glTexCoord1sv") == 0) func = AmiglTexCoord1sv; + else if(strcmp(proc, "glTexCoord2dv") == 0) func = AmiglTexCoord2dv; + else if(strcmp(proc, "glTexCoord2fv") == 0) func = AmiglTexCoord2fv; + else if(strcmp(proc, "glTexCoord2iv") == 0) func = AmiglTexCoord2iv; + else if(strcmp(proc, "glTexCoord2sv") == 0) func = AmiglTexCoord2sv; + else if(strcmp(proc, "glTexCoord3dv") == 0) func = AmiglTexCoord3dv; + else if(strcmp(proc, "glTexCoord3fv") == 0) func = AmiglTexCoord3fv; + else if(strcmp(proc, "glTexCoord3iv") == 0) func = AmiglTexCoord3iv; + else if(strcmp(proc, "glTexCoord3sv") == 0) func = AmiglTexCoord3sv; + else if(strcmp(proc, "glTexCoord4dv") == 0) func = AmiglTexCoord4dv; + else if(strcmp(proc, "glTexCoord4fv") == 0) func = AmiglTexCoord4fv; + else if(strcmp(proc, "glTexCoord4iv") == 0) func = AmiglTexCoord4iv; + else if(strcmp(proc, "glTexCoord4sv") == 0) func = AmiglTexCoord4sv; + else if(strcmp(proc, "glRasterPos2d") == 0) func = AmiglRasterPos2d; + else if(strcmp(proc, "glRasterPos2f") == 0) func = AmiglRasterPos2f; + else if(strcmp(proc, "glRasterPos2i") == 0) func = AmiglRasterPos2i; + else if(strcmp(proc, "glRasterPos2s") == 0) func = AmiglRasterPos2s; + else if(strcmp(proc, "glRasterPos3d") == 0) func = AmiglRasterPos3d; + else if(strcmp(proc, "glRasterPos3f") == 0) func = AmiglRasterPos3f; + else if(strcmp(proc, "glRasterPos3i") == 0) func = AmiglRasterPos3i; + else if(strcmp(proc, "glRasterPos3s") == 0) func = AmiglRasterPos3s; + else if(strcmp(proc, "glRasterPos4d") == 0) func = AmiglRasterPos4d; + else if(strcmp(proc, "glRasterPos4f") == 0) func = AmiglRasterPos4f; + else if(strcmp(proc, "glRasterPos4i") == 0) func = AmiglRasterPos4i; + else if(strcmp(proc, "glRasterPos4s") == 0) func = AmiglRasterPos4s; + else if(strcmp(proc, "glRasterPos2dv") == 0) func = AmiglRasterPos2dv; + else if(strcmp(proc, "glRasterPos2fv") == 0) func = AmiglRasterPos2fv; + else if(strcmp(proc, "glRasterPos2iv") == 0) func = AmiglRasterPos2iv; + else if(strcmp(proc, "glRasterPos2sv") == 0) func = AmiglRasterPos2sv; + else if(strcmp(proc, "glRasterPos3dv") == 0) func = AmiglRasterPos3dv; + else if(strcmp(proc, "glRasterPos3fv") == 0) func = AmiglRasterPos3fv; + else if(strcmp(proc, "glRasterPos3iv") == 0) func = AmiglRasterPos3iv; + else if(strcmp(proc, "glRasterPos3sv") == 0) func = AmiglRasterPos3sv; + else if(strcmp(proc, "glRasterPos4dv") == 0) func = AmiglRasterPos4dv; + else if(strcmp(proc, "glRasterPos4fv") == 0) func = AmiglRasterPos4fv; + else if(strcmp(proc, "glRasterPos4iv") == 0) func = AmiglRasterPos4iv; + else if(strcmp(proc, "glRasterPos4sv") == 0) func = AmiglRasterPos4sv; + else if(strcmp(proc, "glRectd") == 0) func = AmiglRectd; + else if(strcmp(proc, "glRectf") == 0) func = AmiglRectf; + else if(strcmp(proc, "glRecti") == 0) func = AmiglRecti; + else if(strcmp(proc, "glRects") == 0) func = AmiglRects; + else if(strcmp(proc, "glRectdv") == 0) func = AmiglRectdv; + else if(strcmp(proc, "glRectfv") == 0) func = AmiglRectfv; + else if(strcmp(proc, "glRectiv") == 0) func = AmiglRectiv; + else if(strcmp(proc, "glRectsv") == 0) func = AmiglRectsv; + else if(strcmp(proc, "glVertexPointer") == 0) func = AmiglVertexPointer; + else if(strcmp(proc, "glNormalPointer") == 0) func = AmiglNormalPointer; + else if(strcmp(proc, "glColorPointer") == 0) func = AmiglColorPointer; + else if(strcmp(proc, "glIndexPointer") == 0) func = AmiglIndexPointer; + else if(strcmp(proc, "glTexCoordPointer") == 0) func = AmiglTexCoordPointer; + else if(strcmp(proc, "glEdgeFlagPointer") == 0) func = AmiglEdgeFlagPointer; + else if(strcmp(proc, "glGetPointerv") == 0) func = AmiglGetPointerv; + else if(strcmp(proc, "glArrayElement") == 0) func = AmiglArrayElement; + else if(strcmp(proc, "glDrawArrays") == 0) func = AmiglDrawArrays; + else if(strcmp(proc, "glDrawElements") == 0) func = AmiglDrawElements; + else if(strcmp(proc, "glInterleavedArrays") == 0) func = AmiglInterleavedArrays; + else if(strcmp(proc, "glShadeModel") == 0) func = AmiglShadeModel; + else if(strcmp(proc, "glLightf") == 0) func = AmiglLightf; + else if(strcmp(proc, "glLighti") == 0) func = AmiglLighti; + else if(strcmp(proc, "glLightfv") == 0) func = AmiglLightfv; + else if(strcmp(proc, "glLightiv") == 0) func = AmiglLightiv; + else if(strcmp(proc, "glGetLightfv") == 0) func = AmiglGetLightfv; + else if(strcmp(proc, "glGetLightiv") == 0) func = AmiglGetLightiv; + else if(strcmp(proc, "glLightModelf") == 0) func = AmiglLightModelf; + else if(strcmp(proc, "glLightModeli") == 0) func = AmiglLightModeli; + else if(strcmp(proc, "glLightModelfv") == 0) func = AmiglLightModelfv; + else if(strcmp(proc, "glLightModeliv") == 0) func = AmiglLightModeliv; + else if(strcmp(proc, "glMaterialf") == 0) func = AmiglMaterialf; + else if(strcmp(proc, "glMateriali") == 0) func = AmiglMateriali; + else if(strcmp(proc, "glMaterialfv") == 0) func = AmiglMaterialfv; + else if(strcmp(proc, "glMaterialiv") == 0) func = AmiglMaterialiv; + else if(strcmp(proc, "glGetMaterialfv") == 0) func = AmiglGetMaterialfv; + else if(strcmp(proc, "glGetMaterialiv") == 0) func = AmiglGetMaterialiv; + else if(strcmp(proc, "glColorMaterial") == 0) func = AmiglColorMaterial; + else if(strcmp(proc, "glPixelZoom") == 0) func = AmiglPixelZoom; + else if(strcmp(proc, "glPixelStoref") == 0) func = AmiglPixelStoref; + else if(strcmp(proc, "glPixelStorei") == 0) func = AmiglPixelStorei; + else if(strcmp(proc, "glPixelTransferf") == 0) func = AmiglPixelTransferf; + else if(strcmp(proc, "glPixelTransferi") == 0) func = AmiglPixelTransferi; + else if(strcmp(proc, "glPixelMapfv") == 0) func = AmiglPixelMapfv; + else if(strcmp(proc, "glPixelMapuiv") == 0) func = AmiglPixelMapuiv; + else if(strcmp(proc, "glPixelMapusv") == 0) func = AmiglPixelMapusv; + else if(strcmp(proc, "glGetPixelMapfv") == 0) func = AmiglGetPixelMapfv; + else if(strcmp(proc, "glGetPixelMapuiv") == 0) func = AmiglGetPixelMapuiv; + else if(strcmp(proc, "glGetPixelMapusv") == 0) func = AmiglGetPixelMapusv; + else if(strcmp(proc, "glBitmap") == 0) func = AmiglBitmap; + else if(strcmp(proc, "glReadPixels") == 0) func = AmiglReadPixels; + else if(strcmp(proc, "glDrawPixels") == 0) func = AmiglDrawPixels; + else if(strcmp(proc, "glCopyPixels") == 0) func = AmiglCopyPixels; + else if(strcmp(proc, "glStencilFunc") == 0) func = AmiglStencilFunc; + else if(strcmp(proc, "glStencilMask") == 0) func = AmiglStencilMask; + else if(strcmp(proc, "glStencilOp") == 0) func = AmiglStencilOp; + else if(strcmp(proc, "glClearStencil") == 0) func = AmiglClearStencil; + else if(strcmp(proc, "glTexGend") == 0) func = AmiglTexGend; + else if(strcmp(proc, "glTexGenf") == 0) func = AmiglTexGenf; + else if(strcmp(proc, "glTexGeni") == 0) func = AmiglTexGeni; + else if(strcmp(proc, "glTexGendv") == 0) func = AmiglTexGendv; + else if(strcmp(proc, "glTexGenfv") == 0) func = AmiglTexGenfv; + else if(strcmp(proc, "glTexGeniv") == 0) func = AmiglTexGeniv; + else if(strcmp(proc, "glGetTexGendv") == 0) func = AmiglGetTexGendv; + else if(strcmp(proc, "glGetTexGenfv") == 0) func = AmiglGetTexGenfv; + else if(strcmp(proc, "glGetTexGeniv") == 0) func = AmiglGetTexGeniv; + else if(strcmp(proc, "glTexEnvf") == 0) func = AmiglTexEnvf; + else if(strcmp(proc, "glTexEnvi") == 0) func = AmiglTexEnvi; + else if(strcmp(proc, "glTexEnvfv") == 0) func = AmiglTexEnvfv; + else if(strcmp(proc, "glTexEnviv") == 0) func = AmiglTexEnviv; + else if(strcmp(proc, "glGetTexEnvfv") == 0) func = AmiglGetTexEnvfv; + else if(strcmp(proc, "glGetTexEnviv") == 0) func = AmiglGetTexEnviv; + else if(strcmp(proc, "glTexParameterf") == 0) func = AmiglTexParameterf; + else if(strcmp(proc, "glTexParameteri") == 0) func = AmiglTexParameteri; + else if(strcmp(proc, "glTexParameterfv") == 0) func = AmiglTexParameterfv; + else if(strcmp(proc, "glTexParameteriv") == 0) func = AmiglTexParameteriv; + else if(strcmp(proc, "glGetTexParameterfv") == 0) func = AmiglGetTexParameterfv; + else if(strcmp(proc, "glGetTexParameteriv") == 0) func = AmiglGetTexParameteriv; + else if(strcmp(proc, "glGetTexLevelParameterfv") == 0) func = AmiglGetTexLevelParameterfv; + else if(strcmp(proc, "glGetTexLevelParameteriv") == 0) func = AmiglGetTexLevelParameteriv; + else if(strcmp(proc, "glTexImage1D") == 0) func = AmiglTexImage1D; + else if(strcmp(proc, "glTexImage2D") == 0) func = AmiglTexImage2D; + else if(strcmp(proc, "glGetTexImage") == 0) func = AmiglGetTexImage; + else if(strcmp(proc, "glGenTextures") == 0) func = AmiglGenTextures; + else if(strcmp(proc, "glDeleteTextures") == 0) func = AmiglDeleteTextures; + else if(strcmp(proc, "glBindTexture") == 0) func = AmiglBindTexture; + else if(strcmp(proc, "glPrioritizeTextures") == 0) func = AmiglPrioritizeTextures; + else if(strcmp(proc, "glAreTexturesResident") == 0) func = AmiglAreTexturesResident; + else if(strcmp(proc, "glIsTexture") == 0) func = AmiglIsTexture; + else if(strcmp(proc, "glTexSubImage1D") == 0) func = AmiglTexSubImage1D; + else if(strcmp(proc, "glTexSubImage2D") == 0) func = AmiglTexSubImage2D; + else if(strcmp(proc, "glCopyTexImage1D") == 0) func = AmiglCopyTexImage1D; + else if(strcmp(proc, "glCopyTexImage2D") == 0) func = AmiglCopyTexImage2D; + else if(strcmp(proc, "glCopyTexSubImage1D") == 0) func = AmiglCopyTexSubImage1D; + else if(strcmp(proc, "glCopyTexSubImage2D") == 0) func = AmiglCopyTexSubImage2D; + else if(strcmp(proc, "glMap1d") == 0) func = AmiglMap1d; + else if(strcmp(proc, "glMap1f") == 0) func = AmiglMap1f; + else if(strcmp(proc, "glMap2d") == 0) func = AmiglMap2d; + else if(strcmp(proc, "glMap2f") == 0) func = AmiglMap2f; + else if(strcmp(proc, "glGetMapdv") == 0) func = AmiglGetMapdv; + else if(strcmp(proc, "glGetMapfv") == 0) func = AmiglGetMapfv; + else if(strcmp(proc, "glGetMapiv") == 0) func = AmiglGetMapiv; + else if(strcmp(proc, "glEvalCoord1d") == 0) func = AmiglEvalCoord1d; + else if(strcmp(proc, "glEvalCoord1f") == 0) func = AmiglEvalCoord1f; + else if(strcmp(proc, "glEvalCoord1dv") == 0) func = AmiglEvalCoord1dv; + else if(strcmp(proc, "glEvalCoord1fv") == 0) func = AmiglEvalCoord1fv; + else if(strcmp(proc, "glEvalCoord2d") == 0) func = AmiglEvalCoord2d; + else if(strcmp(proc, "glEvalCoord2f") == 0) func = AmiglEvalCoord2f; + else if(strcmp(proc, "glEvalCoord2dv") == 0) func = AmiglEvalCoord2dv; + else if(strcmp(proc, "glEvalCoord2fv") == 0) func = AmiglEvalCoord2fv; + else if(strcmp(proc, "glMapGrid1d") == 0) func = AmiglMapGrid1d; + else if(strcmp(proc, "glMapGrid1f") == 0) func = AmiglMapGrid1f; + else if(strcmp(proc, "glMapGrid2d") == 0) func = AmiglMapGrid2d; + else if(strcmp(proc, "glMapGrid2f") == 0) func = AmiglMapGrid2f; + else if(strcmp(proc, "glEvalPoint1") == 0) func = AmiglEvalPoint1; + else if(strcmp(proc, "glEvalPoint2") == 0) func = AmiglEvalPoint2; + else if(strcmp(proc, "glEvalMesh1") == 0) func = AmiglEvalMesh1; + else if(strcmp(proc, "glEvalMesh2") == 0) func = AmiglEvalMesh2; + else if(strcmp(proc, "glFogf") == 0) func = AmiglFogf; + else if(strcmp(proc, "glFogi") == 0) func = AmiglFogi; + else if(strcmp(proc, "glFogfv") == 0) func = AmiglFogfv; + else if(strcmp(proc, "glFogiv") == 0) func = AmiglFogiv; + else if(strcmp(proc, "glFeedbackBuffer") == 0) func = AmiglFeedbackBuffer; + else if(strcmp(proc, "glPassThrough") == 0) func = AmiglPassThrough; + else if(strcmp(proc, "glSelectBuffer") == 0) func = AmiglSelectBuffer; + else if(strcmp(proc, "glInitNames") == 0) func = AmiglInitNames; + else if(strcmp(proc, "glLoadName") == 0) func = AmiglLoadName; + else if(strcmp(proc, "glPushName") == 0) func = AmiglPushName; + else if(strcmp(proc, "glPopName") == 0) func = AmiglPopName; + else if(strcmp(proc, "glBlendEquationEXT") == 0) func = AmiglBlendEquationEXT; + else if(strcmp(proc, "glBlendColorEXT") == 0) func = AmiglBlendColorEXT; + else if(strcmp(proc, "glPolygonOffsetEXT") == 0) func = AmiglPolygonOffsetEXT; + else if(strcmp(proc, "glVertexPointerEXT") == 0) func = AmiglVertexPointerEXT; + else if(strcmp(proc, "glNormalPointerEXT") == 0) func = AmiglNormalPointerEXT; + else if(strcmp(proc, "glColorPointerEXT") == 0) func = AmiglColorPointerEXT; + else if(strcmp(proc, "glIndexPointerEXT") == 0) func = AmiglIndexPointerEXT; + else if(strcmp(proc, "glTexCoordPointerEXT") == 0) func = AmiglTexCoordPointerEXT; + else if(strcmp(proc, "glEdgeFlagPointerEXT") == 0) func = AmiglEdgeFlagPointerEXT; + else if(strcmp(proc, "glGetPointervEXT") == 0) func = AmiglGetPointervEXT; + else if(strcmp(proc, "glArrayElementEXT") == 0) func = AmiglArrayElementEXT; + else if(strcmp(proc, "glDrawArraysEXT") == 0) func = AmiglDrawArraysEXT; + else if(strcmp(proc, "glGenTexturesEXT") == 0) func = AmiglGenTexturesEXT; + else if(strcmp(proc, "glDeleteTexturesEXT") == 0) func = AmiglDeleteTexturesEXT; + else if(strcmp(proc, "glBindTextureEXT") == 0) func = AmiglBindTextureEXT; + else if(strcmp(proc, "glPrioritizeTexturesEXT") == 0) func = AmiglPrioritizeTexturesEXT; + else if(strcmp(proc, "glAreTexturesResidentEXT") == 0) func = AmiglAreTexturesResidentEXT; + else if(strcmp(proc, "glIsTextureEXT") == 0) func = AmiglIsTextureEXT; + else if(strcmp(proc, "glTexImage3DEXT") == 0) func = AmiglTexImage3DEXT; + else if(strcmp(proc, "glTexSubImage3DEXT") == 0) func = AmiglTexSubImage3DEXT; + else if(strcmp(proc, "glCopyTexSubImage3DEXT") == 0) func = AmiglCopyTexSubImage3DEXT; + else if(strcmp(proc, "glColorTableEXT") == 0) func = AmiglColorTableEXT; + else if(strcmp(proc, "glColorSubTableEXT") == 0) func = AmiglColorSubTableEXT; + else if(strcmp(proc, "glGetColorTableEXT") == 0) func = AmiglGetColorTableEXT; + else if(strcmp(proc, "glGetColorTableParameterfvEXT") == 0) func = AmiglGetColorTableParameterfvEXT; + else if(strcmp(proc, "glGetColorTableParameterivEXT") == 0) func = AmiglGetColorTableParameterivEXT; + else if(strcmp(proc, "glMultiTexCoord1dSGIS") == 0) func = AmiglMultiTexCoord1dSGIS; + else if(strcmp(proc, "glMultiTexCoord1dvSGIS") == 0) func = AmiglMultiTexCoord1dvSGIS; + else if(strcmp(proc, "glMultiTexCoord1fSGIS") == 0) func = AmiglMultiTexCoord1fSGIS; + else if(strcmp(proc, "glMultiTexCoord1fvSGIS") == 0) func = AmiglMultiTexCoord1fvSGIS; + else if(strcmp(proc, "glMultiTexCoord1iSGIS") == 0) func = AmiglMultiTexCoord1iSGIS; + else if(strcmp(proc, "glMultiTexCoord1ivSGIS") == 0) func = AmiglMultiTexCoord1ivSGIS; + else if(strcmp(proc, "glMultiTexCoord1sSGIS") == 0) func = AmiglMultiTexCoord1sSGIS; + else if(strcmp(proc, "glMultiTexCoord1svSGIS") == 0) func = AmiglMultiTexCoord1svSGIS; + else if(strcmp(proc, "glMultiTexCoord2dSGIS") == 0) func = AmiglMultiTexCoord2dSGIS; + else if(strcmp(proc, "glMultiTexCoord2dvSGIS") == 0) func = AmiglMultiTexCoord2dvSGIS; + else if(strcmp(proc, "glMultiTexCoord2fSGIS") == 0) func = AmiglMultiTexCoord2fSGIS; + else if(strcmp(proc, "glMultiTexCoord2fvSGIS") == 0) func = AmiglMultiTexCoord2fvSGIS; + else if(strcmp(proc, "glMultiTexCoord2iSGIS") == 0) func = AmiglMultiTexCoord2iSGIS; + else if(strcmp(proc, "glMultiTexCoord2ivSGIS") == 0) func = AmiglMultiTexCoord2ivSGIS; + else if(strcmp(proc, "glMultiTexCoord2sSGIS") == 0) func = AmiglMultiTexCoord2sSGIS; + else if(strcmp(proc, "glMultiTexCoord2svSGIS") == 0) func = AmiglMultiTexCoord2svSGIS; + else if(strcmp(proc, "glMultiTexCoord3dSGIS") == 0) func = AmiglMultiTexCoord3dSGIS; + else if(strcmp(proc, "glMultiTexCoord3dvSGIS") == 0) func = AmiglMultiTexCoord3dvSGIS; + else if(strcmp(proc, "glMultiTexCoord3fSGIS") == 0) func = AmiglMultiTexCoord3fSGIS; + else if(strcmp(proc, "glMultiTexCoord3fvSGIS") == 0) func = AmiglMultiTexCoord3fvSGIS; + else if(strcmp(proc, "glMultiTexCoord3iSGIS") == 0) func = AmiglMultiTexCoord3iSGIS; + else if(strcmp(proc, "glMultiTexCoord3ivSGIS") == 0) func = AmiglMultiTexCoord3ivSGIS; + else if(strcmp(proc, "glMultiTexCoord3sSGIS") == 0) func = AmiglMultiTexCoord3sSGIS; + else if(strcmp(proc, "glMultiTexCoord3svSGIS") == 0) func = AmiglMultiTexCoord3svSGIS; + else if(strcmp(proc, "glMultiTexCoord4dSGIS") == 0) func = AmiglMultiTexCoord4dSGIS; + else if(strcmp(proc, "glMultiTexCoord4dvSGIS") == 0) func = AmiglMultiTexCoord4dvSGIS; + else if(strcmp(proc, "glMultiTexCoord4fSGIS") == 0) func = AmiglMultiTexCoord4fSGIS; + else if(strcmp(proc, "glMultiTexCoord4fvSGIS") == 0) func = AmiglMultiTexCoord4fvSGIS; + else if(strcmp(proc, "glMultiTexCoord4iSGIS") == 0) func = AmiglMultiTexCoord4iSGIS; + else if(strcmp(proc, "glMultiTexCoord4ivSGIS") == 0) func = AmiglMultiTexCoord4ivSGIS; + else if(strcmp(proc, "glMultiTexCoord4sSGIS") == 0) func = AmiglMultiTexCoord4sSGIS; + else if(strcmp(proc, "glMultiTexCoord4svSGIS") == 0) func= AmiglMultiTexCoord4svSGIS; + else if(strcmp(proc, "glMultiTexCoordPointerSGIS") == 0) func = AmiglMultiTexCoordPointerSGIS; + else if(strcmp(proc, "glSelectTextureSGIS") == 0) func = AmiglSelectTextureSGIS; + else if(strcmp(proc, "glSelectTextureCoordSetSGIS") == 0) func = AmiglSelectTextureCoordSetSGIS; + else if(strcmp(proc, "glMultiTexCoord1dEXT") == 0) func = AmiglMultiTexCoord1dEXT; + else if(strcmp(proc, "glMultiTexCoord1dvEXT") == 0) func = AmiglMultiTexCoord1dvEXT; + else if(strcmp(proc, "glMultiTexCoord1fEXT") == 0) func = AmiglMultiTexCoord1fEXT; + else if(strcmp(proc, "glMultiTexCoord1fvEXT") == 0) func = AmiglMultiTexCoord1fvEXT; + else if(strcmp(proc, "glMultiTexCoord1iEXT") == 0) func = AmiglMultiTexCoord1iEXT; + else if(strcmp(proc, "glMultiTexCoord1ivEXT") == 0) func = AmiglMultiTexCoord1ivEXT; + else if(strcmp(proc, "glMultiTexCoord1sEXT") == 0) func = AmiglMultiTexCoord1sEXT; + else if(strcmp(proc, "glMultiTexCoord1svEXT") == 0) func = AmiglMultiTexCoord1svEXT; + else if(strcmp(proc, "glMultiTexCoord2dEXT") == 0) func = AmiglMultiTexCoord2dEXT; + else if(strcmp(proc, "glMultiTexCoord2dvEXT") == 0) func = AmiglMultiTexCoord2dvEXT; + else if(strcmp(proc, "glMultiTexCoord2fEXT") == 0) func = AmiglMultiTexCoord2fEXT; + else if(strcmp(proc, "glMultiTexCoord2fvEXT") == 0) func = AmiglMultiTexCoord2fvEXT; + else if(strcmp(proc, "glMultiTexCoord2iEXT") == 0) func = AmiglMultiTexCoord2iEXT; + else if(strcmp(proc, "glMultiTexCoord2ivEXT") == 0) func = AmiglMultiTexCoord2ivEXT; + else if(strcmp(proc, "glMultiTexCoord2sEXT") == 0) func = AmiglMultiTexCoord2sEXT; + else if(strcmp(proc, "glMultiTexCoord2svEXT") == 0) func = AmiglMultiTexCoord2svEXT; + else if(strcmp(proc, "glMultiTexCoord3dEXT") == 0) func = AmiglMultiTexCoord3dEXT; + else if(strcmp(proc, "glMultiTexCoord3dvEXT") == 0) func = AmiglMultiTexCoord3dvEXT; + else if(strcmp(proc, "glMultiTexCoord3fEXT") == 0) func = AmiglMultiTexCoord3fEXT; + else if(strcmp(proc, "glMultiTexCoord3fvEXT") == 0) func = AmiglMultiTexCoord3fvEXT; + else if(strcmp(proc, "glMultiTexCoord3iEXT") == 0) func = AmiglMultiTexCoord3iEXT; + else if(strcmp(proc, "glMultiTexCoord3ivEXT") == 0) func = AmiglMultiTexCoord3ivEXT; + else if(strcmp(proc, "glMultiTexCoord3sEXT") == 0) func = AmiglMultiTexCoord3sEXT; + else if(strcmp(proc, "glMultiTexCoord3svEXT") == 0) func = AmiglMultiTexCoord3svEXT; + else if(strcmp(proc, "glMultiTexCoord4dEXT") == 0) func = AmiglMultiTexCoord4dEXT; + else if(strcmp(proc, "glMultiTexCoord4dvEXT") == 0) func = AmiglMultiTexCoord4dvEXT; + else if(strcmp(proc, "glMultiTexCoord4fEXT") == 0) func = AmiglMultiTexCoord4fEXT; + else if(strcmp(proc, "glMultiTexCoord4fvEXT") == 0) func = AmiglMultiTexCoord4fvEXT; + else if(strcmp(proc, "glMultiTexCoord4iEXT") == 0) func = AmiglMultiTexCoord4iEXT; + else if(strcmp(proc, "glMultiTexCoord4ivEXT") == 0) func = AmiglMultiTexCoord4ivEXT; + else if(strcmp(proc, "glMultiTexCoord4sEXT") == 0) func = AmiglMultiTexCoord4sEXT; + else if(strcmp(proc, "glMultiTexCoord4svEXT") == 0) func = AmiglMultiTexCoord4svEXT; + else if(strcmp(proc, "glInterleavedTextureCoordSetsEXT") == 0) func = AmiglInterleavedTextureCoordSetsEXT; + else if(strcmp(proc, "glSelectTextureEXT") == 0) func = AmiglSelectTextureEXT; + else if(strcmp(proc, "glSelectTextureCoordSetEXT") == 0) func = AmiglSelectTextureCoordSetEXT; + else if(strcmp(proc, "glSelectTextureTransformEXT") == 0) func = AmiglSelectTextureTransformEXT; + else if(strcmp(proc, "glPointParameterfEXT") == 0) func = AmiglPointParameterfEXT; + else if(strcmp(proc, "glPointParameterfvEXT") == 0) func = AmiglPointParameterfvEXT; + else if(strcmp(proc, "glWindowPos2iMESA") == 0) func = AmiglWindowPos2iMESA; + else if(strcmp(proc, "glWindowPos2sMESA") == 0) func = AmiglWindowPos2sMESA; + else if(strcmp(proc, "glWindowPos2fMESA") == 0) func = AmiglWindowPos2fMESA; + else if(strcmp(proc, "glWindowPos2dMESA") == 0) func = AmiglWindowPos2dMESA; + else if(strcmp(proc, "glWindowPos2ivMESA") == 0) func = AmiglWindowPos2ivMESA; + else if(strcmp(proc, "glWindowPos2svMESA") == 0) func = AmiglWindowPos2svMESA; + else if(strcmp(proc, "glWindowPos2fvMESA") == 0) func = AmiglWindowPos2fvMESA; + else if(strcmp(proc, "glWindowPos2dvMESA") == 0) func = AmiglWindowPos2dvMESA; + else if(strcmp(proc, "glWindowPos3iMESA") == 0) func = AmiglWindowPos3iMESA; + else if(strcmp(proc, "glWindowPos3sMESA") == 0) func = AmiglWindowPos3sMESA; + else if(strcmp(proc, "glWindowPos3fMESA") == 0) func = AmiglWindowPos3fMESA; + else if(strcmp(proc, "glWindowPos3dMESA") == 0) func = AmiglWindowPos3dMESA; + else if(strcmp(proc, "glWindowPos3ivMESA") == 0) func = AmiglWindowPos3ivMESA; + else if(strcmp(proc, "glWindowPos3svMESA") == 0) func = AmiglWindowPos3svMESA; + else if(strcmp(proc, "glWindowPos3fvMESA") == 0) func = AmiglWindowPos3fvMESA; + else if(strcmp(proc, "glWindowPos3dvMESA") == 0) func = AmiglWindowPos3dvMESA; + else if(strcmp(proc, "glWindowPos4iMESA") == 0) func = AmiglWindowPos4iMESA; + else if(strcmp(proc, "glWindowPos4sMESA") == 0) func = AmiglWindowPos4sMESA; + else if(strcmp(proc, "glWindowPos4fMESA") == 0) func = AmiglWindowPos4fMESA; + else if(strcmp(proc, "glWindowPos4dMESA") == 0) func = AmiglWindowPos4dMESA; + else if(strcmp(proc, "glWindowPos4ivMESA") == 0) func = AmiglWindowPos4ivMESA; + else if(strcmp(proc, "glWindowPos4svMESA") == 0) func = AmiglWindowPos4svMESA; + else if(strcmp(proc, "glWindowPos4fvMESA") == 0) func = AmiglWindowPos4fvMESA; + else if(strcmp(proc, "glWindowPos4dvMESA") == 0) func = AmiglWindowPos4dvMESA; + else if(strcmp(proc, "glResizeBuffersMESA") == 0) func = AmiglResizeBuffersMESA; + else if(strcmp(proc, "glDrawRangeElements") == 0) func = AmiglDrawRangeElements; + else if(strcmp(proc, "glTexImage3D") == 0) func = AmiglTexImage3D; + else if(strcmp(proc, "glTexSubImage3D") == 0) func = AmiglTexSubImage3D; + else if(strcmp(proc, "glCopyTexSubImage3D") == 0) func = AmiglCopyTexSubImage3D; + else if(strcmp(proc, "gluLookAt") == 0) func = AmigluLookAt; + else if(strcmp(proc, "gluOrtho2D") == 0) func = AmigluOrtho2D; + else if(strcmp(proc, "gluPerspective") == 0) func = AmigluPerspective; + else if(strcmp(proc, "gluPickMatrix") == 0) func = AmigluPickMatrix; + else if(strcmp(proc, "gluProject") == 0) func = AmigluProject; + else if(strcmp(proc, "gluUnProject") == 0) func = AmigluUnProject; + else if(strcmp(proc, "gluErrorString") == 0) func = AmigluErrorString; + else if(strcmp(proc, "gluScaleImage") == 0) func = AmigluScaleImage; + else if(strcmp(proc, "gluBuild1DMipmaps") == 0) func = AmigluBuild1DMipmaps; + else if(strcmp(proc, "gluBuild2DMipmaps") == 0) func = AmigluBuild2DMipmaps; + else if(strcmp(proc, "gluNewQuadric") == 0) func = AmigluNewQuadric; + else if(strcmp(proc, "gluDeleteQuadric") == 0) func = AmigluDeleteQuadric; + else if(strcmp(proc, "gluQuadricDrawStyle") == 0) func = AmigluQuadricDrawStyle; + else if(strcmp(proc, "gluQuadricOrientation") == 0) func = AmigluQuadricOrientation; + else if(strcmp(proc, "gluQuadricNormals") == 0) func = AmigluQuadricNormals; + else if(strcmp(proc, "gluQuadricTexture") == 0) func = AmigluQuadricTexture; + else if(strcmp(proc, "gluQuadricCallback") == 0) func = AmigluQuadricCallback; + else if(strcmp(proc, "gluCylinder") == 0) func = AmigluCylinder; + else if(strcmp(proc, "gluSphere") == 0) func = AmigluSphere; + else if(strcmp(proc, "gluDisk") == 0) func = AmigluDisk; + else if(strcmp(proc, "gluPartialDisk") == 0) func = AmigluPartialDisk; + else if(strcmp(proc, "gluNewNurbsRenderer") == 0) func = AmigluNewNurbsRenderer; + else if(strcmp(proc, "gluDeleteNurbsRenderer") == 0) func = AmigluDeleteNurbsRenderer; + else if(strcmp(proc, "gluLoadSamplingMatrices") == 0) func = AmigluLoadSamplingMatrices; + else if(strcmp(proc, "gluNurbsProperty") == 0) func = AmigluNurbsProperty; + else if(strcmp(proc, "gluGetNurbsProperty") == 0) func = AmigluGetNurbsProperty; + else if(strcmp(proc, "gluBeginCurve") == 0) func = AmigluBeginCurve; + else if(strcmp(proc, "gluEndCurve") == 0) func = AmigluEndCurve; + else if(strcmp(proc, "gluNurbsCurve") == 0) func = AmigluNurbsCurve; + else if(strcmp(proc, "gluBeginSurface") == 0) func = AmigluBeginSurface; + else if(strcmp(proc, "gluEndSurface") == 0) func = AmigluEndSurface; + else if(strcmp(proc, "gluNurbsSurface") == 0) func = AmigluNurbsSurface; + else if(strcmp(proc, "gluBeginTrim") == 0) func = AmigluBeginTrim; + else if(strcmp(proc, "gluEndTrim") == 0) func = AmigluEndTrim; + else if(strcmp(proc, "gluPwlCurve") == 0) func = AmigluPwlCurve; + else if(strcmp(proc, "gluNurbsCallback") == 0) func = AmigluNurbsCallback; + else if(strcmp(proc, "gluNewTess") == 0) func = AmigluNewTess; + else if(strcmp(proc, "gluTessCallback") == 0) func = AmigluTessCallback; + else if(strcmp(proc, "gluDeleteTess") == 0) func = AmigluDeleteTess; + else if(strcmp(proc, "gluBeginPolygon") == 0) func = AmigluBeginPolygon; + else if(strcmp(proc, "gluEndPolygon") == 0) func = AmigluEndPolygon; + else if(strcmp(proc, "gluNextContour") == 0) func = AmigluNextContour; + else if(strcmp(proc, "gluTessVertex") == 0) func = AmigluTessVertex; + else if(strcmp(proc, "gluGetString") == 0) func = AmigluGetString; + + return func; +} + +#endif /*HAVE_OPENGL*/ diff --git a/src/video/cybergfx/SDL_cgxyuv.c b/src/video/cybergfx/SDL_cgxyuv.c new file mode 100644 index 000000000..776d91239 --- /dev/null +++ b/src/video/cybergfx/SDL_cgxyuv.c @@ -0,0 +1,191 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_cgxyuv.c,v 1.2 2002/11/20 08:51:55 gabry Exp $"; +#endif + +/* This is the XFree86 Xv extension implementation of YUV video overlays */ + +#ifdef XFREE86_XV + +#include +#include +#include +#include +#include +#include +#include + +#include "SDL_error.h" +#include "SDL_video.h" +#include "SDL_x11yuv_c.h" +#include "SDL_yuvfuncs.h" + +/* 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; + int adaptors; + XvAdaptorInfo *ainfo; + XShmSegmentInfo *yuvshm; + + 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; (iformat = format; + overlay->w = width; + overlay->h = height; + + /* Set up the YUV surface function structure */ + overlay->hwfuncs = &x11_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); + } + yuvshm = &hwdata->yuvshm; + memset(yuvshm, 0, sizeof(*yuvshm)); + hwdata->port = xv_port; + hwdata->image = XvShmCreateImage(GFX_Display, xv_port, format, + 0, width, height, yuvshm); + 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 = (caddr_t) 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); + + /* We're all done.. */ + return(overlay); +} + +int X11_LockYUVOverlay(_THIS, SDL_Overlay *overlay) +{ + overlay->pixels = overlay->hwdata->image->data; + /* What should the pitch be set to? */ + return(0); +} + +void X11_UnlockYUVOverlay(_THIS, SDL_Overlay *overlay) +{ + overlay->pixels = NULL; +} + +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 ) { + if ( hwdata->yuvshm.shmaddr ) { + XShmDetach(GFX_Display, &hwdata->yuvshm); + shmdt(hwdata->yuvshm.shmaddr); + } + if ( hwdata->image ) { + XFree(hwdata->image); + } + free(hwdata); + } +} + +#endif /* XFREE86_XV */ diff --git a/src/video/cybergfx/SDL_cgxyuv_c.h b/src/video/cybergfx/SDL_cgxyuv_c.h new file mode 100644 index 000000000..3ff7d0956 --- /dev/null +++ b/src/video/cybergfx/SDL_cgxyuv_c.h @@ -0,0 +1,45 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_cgxyuv_c.h,v 1.2 2002/11/20 08:51:56 gabry Exp $"; +#endif + +/* This is the XFree86 Xv extension implementation of YUV video overlays */ + +#include "SDL_video.h" +#include "SDL_cgxvideo.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 */ diff --git a/src/video/cybergfx/SDL_syswm.h b/src/video/cybergfx/SDL_syswm.h new file mode 100644 index 000000000..16aa3ac4e --- /dev/null +++ b/src/video/cybergfx/SDL_syswm.h @@ -0,0 +1,187 @@ +/* + include - Simple DirectMedia Layer + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public + License along with this library; if not, write to the Free + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + Sam Lantinga + slouken@libsdl.org +*/ + +#ifdef SAVE_RCSID +static char rcsid = + "@(#) $Id: SDL_syswm.h,v 1.3 2003/09/07 17:09:24 gabry Exp $"; +#endif + +/* Include file for include 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(__OpenBSD__)) && \ + (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX)) +/* AIX is unix, of course, but the native compiler CSet doesn't define unix */ +#include +#include + +/* 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 include 1.0.2 */ + Window fswindow; /* The X11 fullscreen window */ + Window wmwindow; /* The X11 managed input window */ + } x11; + } info; +} SDL_SysWMinfo; + +#elif defined(ENABLE_NANOX) +#include + +/* The generic custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int data; +}; + +/* The windows custom window manager information structure */ +typedef struct { + SDL_version version ; + GR_WINDOW_ID window ; /* The display window */ +} SDL_SysWMinfo; + +#elif defined(WIN32) +#define WIN32_LEAN_AND_MEAN +#include + +/* 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 */ + HGLRC hglrc; /* The OpenGL context, if any */ +} SDL_SysWMinfo; + +#elif defined(__riscos__) + +/* RISC OS custom event structure */ +struct SDL_SysWMmsg { + SDL_version version; + int eventCode; /* The window for the message */ + int pollBlock[64]; +}; + +/* The RISCOS custom window manager information structure */ +typedef struct { + SDL_version version; + int wimpVersion; /* Wimp version running under */ + int taskHandle; /* The RISCOS task handle */ + int window; /* The RISCOS 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 SDLCALL +SDL_GetWMInfo(SDL_SysWMinfo +*info); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +} +#endif + +#include "close_code.h" + +#endif /* _SDL_syswm_h */ From 3e109838cd8b74350ef5fdf7c8ae2c3d98673dc0 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 16:17:21 +0100 Subject: [PATCH 03/21] Add more missing files --- CMakeLists.txt | 2 +- src/main/amigaos/SDL_amigastub.c | 2 +- src/main/amigaos/SDL_inline.h | 549 ++++++++++++++++++++++++++++++ src/main/amigaos/SDL_lutstub.s | 28 ++ src/main/amigaos/SDL_lutstubrel.s | 33 ++ src/main/amigaos/SDLstub.c | 26 ++ src/main/amigaos/stabs.h | 164 +++++++++ 7 files changed, 802 insertions(+), 2 deletions(-) create mode 100644 src/main/amigaos/SDL_inline.h create mode 100644 src/main/amigaos/SDL_lutstub.s create mode 100644 src/main/amigaos/SDL_lutstubrel.s create mode 100644 src/main/amigaos/SDLstub.c create mode 100644 src/main/amigaos/stabs.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c1f939294..56d586746 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -89,7 +89,7 @@ add_library(${LIBNAME} ${PROJECT_SOURCE_DIR}/src/SDL.c ${PROJECT_SOURCE_DIR}/src/SDL_error.c ${PROJECT_SOURCE_DIR}/src/SDL_fatal.c - ${PROJECT_SOURCE_DIR}/SDL_lutstub.s + ${PROJECT_SOURCE_DIR}/src/main/amigaos/SDL_lutstub.s # CPUINFO ${PROJECT_SOURCE_DIR}/src/cpuinfo/SDL_cpuinfo.c diff --git a/src/main/amigaos/SDL_amigastub.c b/src/main/amigaos/SDL_amigastub.c index c9067c06e..4903b7852 100644 --- a/src/main/amigaos/SDL_amigastub.c +++ b/src/main/amigaos/SDL_amigastub.c @@ -9,7 +9,7 @@ #include #include #include -#include "../../../stabs.h" +#include "stabs.h" #include "../../../mydebug.h" /******************************************************************************/ diff --git a/src/main/amigaos/SDL_inline.h b/src/main/amigaos/SDL_inline.h new file mode 100644 index 000000000..a5568a43c --- /dev/null +++ b/src/main/amigaos/SDL_inline.h @@ -0,0 +1,549 @@ +/* Automatically generated header! Do not edit! */ + +#ifndef _INLINE_SDL_H +#define _INLINE_SDL_H + +// Since we don't need amiga structs here we can avoid including them +#define __INLINE_STUB_H + +#ifndef __INLINE_MACROS_H +#include +#endif /* !__INLINE_MACROS_H */ + +#ifndef SDL_BASE_NAME +extern struct Library *SDLBase; +#define SDL_BASE_NAME SDLBase +#endif /* !SDL_BASE_NAME */ + +#define SDL_AddTimer(interval, callback, param) \ + LP3(0x1aa, SDL_TimerID, SDL_AddTimer, Uint32, interval, d0, SDL_NewTimerCallback, callback, a0, void *, param, a1, \ + , SDL_BASE_NAME) + +#define SDL_AllocRW() \ + LP0(0x4e, SDL_RWops *, SDL_AllocRW, \ + , SDL_BASE_NAME) + +#define SDL_AudioDriverName(namebuf, maxlen) \ + LP2(0x2be, char *, SDL_AudioDriverName, char *, namebuf, a0, int, maxlen, d0, \ + , SDL_BASE_NAME) + +#define SDL_AudioInit(driver_name) \ + LP1(0x2b2, int, SDL_AudioInit, const char *, driver_name, a0, \ + , SDL_BASE_NAME) + +#define SDL_AudioQuit() \ + LP0NR(0x2b8, SDL_AudioQuit, \ + , SDL_BASE_NAME) + +#define SDL_BuildAudioCVT(cvt, src_format, src_channels, src_rate, dst_format, dst_channels, dst_rate) \ + LP7(0x2e2, int, SDL_BuildAudioCVT, SDL_AudioCVT *, cvt, a0, Uint16, src_format, d0, Uint8, src_channels, d1, int, src_rate, d2, Uint16, dst_format, d3, Uint8, dst_channels, d4, int, dst_rate, d5, \ + , SDL_BASE_NAME) + +#define SDL_ClearError() \ + LP0NR(0x2ac, SDL_ClearError, \ + , SDL_BASE_NAME) + +#define SDL_CloseAudio() \ + LP0NR(0x300, SDL_CloseAudio, \ + , SDL_BASE_NAME) + +#define SDL_ConvertAudio(cvt) \ + LP1(0x2e8, int, SDL_ConvertAudio, SDL_AudioCVT *, cvt, a0, \ + , SDL_BASE_NAME) + +#define SDL_ConvertSurface(src, fmt, flags) \ + LP3(0x11a, SDL_Surface *, SDL_ConvertSurface, SDL_Surface *, src, a0, SDL_PixelFormat *, fmt, a1, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_CreateCursor(data, mask, w, h, hot_x, hot_y) \ + LP6(0x27c, SDL_Cursor *, SDL_CreateCursor, Uint8 *, data, a0, Uint8 *, mask, a1, int, w, d0, int, h, d1, int, hot_x, d2, int, hot_y, d3, \ + , SDL_BASE_NAME) + +#define SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask) \ + LP8(0xe4, SDL_Surface *, SDL_CreateRGBSurface, Uint32, flags, d0, int, width, d1, int, height, d2, int, depth, d3, Uint32, Rmask, d4, Uint32, Gmask, d5, Uint32, Bmask, d6, Uint32, Amask, d7, \ + , SDL_BASE_NAME) + +#define SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask) \ + LP9(0xea, SDL_Surface *, SDL_CreateRGBSurfaceFrom, void *, pixels, a0, int, width, d0, int, height, d1, int, depth, d2, int, pitch, d3, Uint32, Rmask, d4, Uint32, Gmask, d5, Uint32, Bmask, d6, Uint32, Amask, d7, \ + , SDL_BASE_NAME) + +#define SDL_CreateThread(fn, data) \ + LP2FP(0x306, SDL_Thread *, SDL_CreateThread, __fpt, fn, a0, void *, data, a1, \ + , SDL_BASE_NAME, int (*__fpt)(void *)) + +#define SDL_CreateYUVOverlay(width, height, format, display) \ + LP4(0x126, SDL_Overlay *, SDL_CreateYUVOverlay, int, width, d0, int, height, d1, Uint32, format, d2, SDL_Surface *, display, a0, \ + , SDL_BASE_NAME) + +#define SDL_Delay(ms) \ + LP1NR(0x19e, SDL_Delay, Uint32, ms, d0, \ + , SDL_BASE_NAME) + +#define SDL_DisplayFormat(surface) \ + LP1(0x60, SDL_Surface *, SDL_DisplayFormat, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_DisplayFormatAlpha(surface) \ + LP1(0x120, SDL_Surface *, SDL_DisplayFormatAlpha, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_DisplayYUVOverlay(overlay, dstrect) \ + LP2(0x138, int, SDL_DisplayYUVOverlay, SDL_Overlay *, overlay, a0, SDL_Rect *, dstrect, a1, \ + , SDL_BASE_NAME) + +#define SDL_EnableKeyRepeat(delay, interval) \ + LP2(0x24c, int, SDL_EnableKeyRepeat, int, delay, d0, int, interval, d1, \ + , SDL_BASE_NAME) + +#define SDL_EnableUNICODE(enable) \ + LP1(0x246, int, SDL_EnableUNICODE, int, enable, d0, \ + , SDL_BASE_NAME) + +#define SDL_EventState(type, state) \ + LP2(0x1e0, Uint8, SDL_EventState, Uint8, type, d0, int, state, d1, \ + , SDL_BASE_NAME) + +#define SDL_FillRect(dst, dstrect, color) \ + LP3(0x6c, int, SDL_FillRect, SDL_Surface *, dst, a0, SDL_Rect *, dstrect, a1, Uint32, color, d0, \ + , SDL_BASE_NAME) + +#define SDL_Flip(screen) \ + LP1(0x78, int, SDL_Flip, SDL_Surface *, screen, a0, \ + , SDL_BASE_NAME) + +#define SDL_FreeCursor(cursor) \ + LP1NR(0x28e, SDL_FreeCursor, SDL_Cursor *, cursor, a0, \ + , SDL_BASE_NAME) + +#define SDL_FreeRW(area) \ + LP1NR(0x54, SDL_FreeRW, SDL_RWops *, area, a0, \ + , SDL_BASE_NAME) + +#define SDL_FreeSurface(surface) \ + LP1NR(0x66, SDL_FreeSurface, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_FreeWAV(audio_buf) \ + LP1NR(0x2dc, SDL_FreeWAV, Uint8 *, audio_buf, a0, \ + , SDL_BASE_NAME) + +#define SDL_FreeYUVOverlay(overlay) \ + LP1NR(0x13e, SDL_FreeYUVOverlay, SDL_Overlay *, overlay, a0, \ + , SDL_BASE_NAME) + +#define SDL_GL_GetAttribute(attr, value) \ + LP2(0x156, int, SDL_GL_GetAttribute, SDL_GLattr, attr, d0, int*, value, a0, \ + , SDL_BASE_NAME) + +#define SDL_GL_GetProcAddress(proc) \ + LP1(0x14a, void *, SDL_GL_GetProcAddress, const char*, proc, a0, \ + , SDL_BASE_NAME) + +#define SDL_GL_LoadLibrary(path) \ + LP1(0x144, int, SDL_GL_LoadLibrary, const char *, path, a0, \ + , SDL_BASE_NAME) + +#define SDL_GL_Lock() \ + LP0NR(0x168, SDL_GL_Lock, \ + , SDL_BASE_NAME) + +#define SDL_GL_SetAttribute(attr, value) \ + LP2(0x150, int, SDL_GL_SetAttribute, SDL_GLattr, attr, d0, int, value, d1, \ + , SDL_BASE_NAME) + +#define SDL_GL_SwapBuffers() \ + LP0NR(0x15c, SDL_GL_SwapBuffers, \ + , SDL_BASE_NAME) + +#define SDL_GL_Unlock() \ + LP0NR(0x16e, SDL_GL_Unlock, \ + , SDL_BASE_NAME) + +#define SDL_GL_UpdateRects(numrects, rects) \ + LP2NR(0x162, SDL_GL_UpdateRects, int, numrects, d0, SDL_Rect*, rects, a0, \ + , SDL_BASE_NAME) + +#define SDL_GetAppState() \ + LP0(0x29a, Uint8, SDL_GetAppState, \ + , SDL_BASE_NAME) + +#define SDL_GetAudioStatus() \ + LP0(0x2ca, SDL_audiostatus, SDL_GetAudioStatus, \ + , SDL_BASE_NAME) + +#define SDL_GetClipRect(surface, rect) \ + LP2NR(0x114, SDL_GetClipRect, SDL_Surface *, surface, a0, SDL_Rect *, rect, a1, \ + , SDL_BASE_NAME) + +#define SDL_GetCursor() \ + LP0(0x288, SDL_Cursor *, SDL_GetCursor, \ + , SDL_BASE_NAME) + +#define SDL_GetError() \ + LP0(0x2a6, char *, SDL_GetError, \ + , SDL_BASE_NAME) + +#define SDL_GetEventFilter() \ + LP0(0x1da, SDL_EventFilter, SDL_GetEventFilter, \ + , SDL_BASE_NAME) + +#define SDL_GetGammaRamp(red, green, blue) \ + LP3(0xc6, int, SDL_GetGammaRamp, Uint16 *, red, d0, Uint16 *, green, d1, Uint16 *, blue, d2, \ + , SDL_BASE_NAME) + +#define SDL_GetKeyName(key) \ + LP1(0x264, char *, SDL_GetKeyName, SDLKey, key, d0, \ + , SDL_BASE_NAME) + +#define SDL_GetKeyState(numkeys) \ + LP1(0x252, Uint8 *, SDL_GetKeyState, int *, numkeys, a0, \ + , SDL_BASE_NAME) + +#define SDL_GetModState() \ + LP0(0x258, SDLMod, SDL_GetModState, \ + , SDL_BASE_NAME) + +#define SDL_GetMouseState(x, y) \ + LP2(0x26a, Uint8, SDL_GetMouseState, int *, x, a0, int *, y, a1, \ + , SDL_BASE_NAME) + +#define SDL_GetRGB(pixel, format, r, g, b) \ + LP5NR(0xd8, SDL_GetRGB, Uint32, pixel, d0, SDL_PixelFormat *, format, a0, Uint8 *, r, d1, Uint8 *, g, d2, Uint8 *, b, d3, \ + , SDL_BASE_NAME) + +#define SDL_GetRGBA(pixel, format, r, g, b, a) \ + LP6NR(0xde, SDL_GetRGBA, Uint32, pixel, d0, SDL_PixelFormat *, format, a0, Uint8 *, r, d1, Uint8 *, g, d2, Uint8 *, b, d3, Uint8 *, a, d4, \ + , SDL_BASE_NAME) + +#define SDL_GetRelativeMouseState(x, y) \ + LP2(0x270, Uint8, SDL_GetRelativeMouseState, int *, x, a0, int *, y, a1, \ + , SDL_BASE_NAME) + +#define SDL_GetThreadID(thread) \ + LP1(0x312, Uint32, SDL_GetThreadID, SDL_Thread *, thread, a0, \ + , SDL_BASE_NAME) + +#define SDL_GetTicks() \ + LP0(0x198, Uint32, SDL_GetTicks, \ + , SDL_BASE_NAME) + +#define SDL_GetVideoInfo() \ + LP0(0x8a, const SDL_VideoInfo *, SDL_GetVideoInfo, \ + , SDL_BASE_NAME) + +#define SDL_GetVideoSurface() \ + LP0(0xa8, SDL_Surface *, SDL_GetVideoSurface, \ + , SDL_BASE_NAME) + +#define SDL_RealInit(flags) \ + LP1(0x1e, int, SDL_Init, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_InitSubSystem(flags) \ + LP1(0x2a, int, SDL_InitSubSystem, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickClose(joystick) \ + LP1NR(0x240, SDL_JoystickClose, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickEventState(state) \ + LP1(0x222, int, SDL_JoystickEventState, int, state, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickGetAxis(joystick, axis) \ + LP2(0x228, Sint16, SDL_JoystickGetAxis, SDL_Joystick *, joystick, a0, int, axis, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickGetBall(joystick, ball, dx, dy) \ + LP4(0x234, int, SDL_JoystickGetBall, SDL_Joystick *, joystick, a0, int, ball, d0, int *, dx, a1, int *, dy, a2, \ + , SDL_BASE_NAME) + +#define SDL_JoystickGetButton(joystick, button) \ + LP2(0x23a, Uint8, SDL_JoystickGetButton, SDL_Joystick *, joystick, a0, int, button, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickGetHat(joystick, hat) \ + LP2(0x22e, Uint8, SDL_JoystickGetHat, SDL_Joystick *, joystick, a0, int, hat, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickIndex(joystick) \ + LP1(0x1fe, int, SDL_JoystickIndex, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickName(device_index) \ + LP1(0x1ec, const char *, SDL_JoystickName, int, device_index, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickNumAxes(joystick) \ + LP1(0x204, int, SDL_JoystickNumAxes, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickNumBalls(joystick) \ + LP1(0x20a, int, SDL_JoystickNumBalls, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickNumButtons(joystick) \ + LP1(0x216, int, SDL_JoystickNumButtons, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickNumHats(joystick) \ + LP1(0x210, int, SDL_JoystickNumHats, SDL_Joystick *, joystick, a0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickOpen(device_index) \ + LP1(0x1f2, SDL_Joystick *, SDL_JoystickOpen, int, device_index, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickOpened(device_index) \ + LP1(0x1f8, int, SDL_JoystickOpened, int, device_index, d0, \ + , SDL_BASE_NAME) + +#define SDL_JoystickUpdate() \ + LP0NR(0x21c, SDL_JoystickUpdate, \ + , SDL_BASE_NAME) + +#define SDL_KillThread(thread) \ + LP1NR(0x31e, SDL_KillThread, SDL_Thread *, thread, a0, \ + , SDL_BASE_NAME) + +#define SDL_Linked_Version() \ + LP0(0x324, const SDL_version *, SDL_Linked_Version, \ + , SDL_BASE_NAME) + +#define SDL_ListModes(format, flags) \ + LP2(0xb4, SDL_Rect **, SDL_ListModes, SDL_PixelFormat *, format, a0, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_LoadBMP_RW(src, freesrc) \ + LP2(0x5a, SDL_Surface *, SDL_LoadBMP_RW, SDL_RWops *, src, a0, int, freesrc, d0, \ + , SDL_BASE_NAME) + +#define SDL_LoadWAV_RW(src, freesrc, spec, audio_buf, audio_len) \ + LP5(0x2d6, SDL_AudioSpec *, SDL_LoadWAV_RW, SDL_RWops *, src, a0, int, freesrc, d0, SDL_AudioSpec *, spec, a1, Uint8 **, audio_buf, a2, Uint32 *, audio_len, a3, \ + , SDL_BASE_NAME) + +#define SDL_LockAudio() \ + LP0NR(0x2f4, SDL_LockAudio, \ + , SDL_BASE_NAME) + +#define SDL_LockSurface(surface) \ + LP1(0xf0, int, SDL_LockSurface, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_LockYUVOverlay(overlay) \ + LP1(0x12c, int, SDL_LockYUVOverlay, SDL_Overlay *, overlay, a0, \ + , SDL_BASE_NAME) + +#define SDL_MapRGB(format, r, g, b) \ + LP4(0x96, Uint32, SDL_MapRGB, SDL_PixelFormat *, format, a0, Uint8, r, d0, Uint8, g, d1, Uint8, b, d2, \ + , SDL_BASE_NAME) + +#define SDL_MapRGBA(format, r, g, b, a) \ + LP5(0x9c, Uint32, SDL_MapRGBA, SDL_PixelFormat *, format, a0, Uint8, r, d0, Uint8, g, d1, Uint8, b, d2, Uint8, a, d3, \ + , SDL_BASE_NAME) + +#define SDL_MixAudio(dst, src, len, volume) \ + LP4NR(0x2ee, SDL_MixAudio, Uint8 *, dst, a0, const Uint8 *, src, a1, Uint32, len, d0, int, volume, d1, \ + , SDL_BASE_NAME) + +#define SDL_NumJoysticks() \ + LP0(0x1e6, int, SDL_NumJoysticks, \ + , SDL_BASE_NAME) + +#define SDL_OpenAudio(desired, obtained) \ + LP2(0x2c4, int, SDL_OpenAudio, SDL_AudioSpec *, desired, a0, SDL_AudioSpec *, obtained, a1, \ + , SDL_BASE_NAME) + +#define SDL_PauseAudio(pause_on) \ + LP1NR(0x2d0, SDL_PauseAudio, int, pause_on, d0, \ + , SDL_BASE_NAME) + +#define SDL_PeepEvents(events, numevents, action, mask) \ + LP4(0x1c8, int, SDL_PeepEvents, SDL_Event *, events, a0, int, numevents, d0, SDL_eventaction, action, d1, Uint32, mask, d2, \ + , SDL_BASE_NAME) + +#define SDL_PollEvent(event) \ + LP1(0x1bc, int, SDL_PollEvent, SDL_Event *, event, a0, \ + , SDL_BASE_NAME) + +#define SDL_PumpEvents() \ + LP0NR(0x1b6, SDL_PumpEvents, \ + , SDL_BASE_NAME) + +#define SDL_PushEvent(event) \ + LP1(0x1ce, int, SDL_PushEvent, SDL_Event *, event, a0, \ + , SDL_BASE_NAME) + +#define SDL_RealQuit() \ + LP0NR(0x24, SDL_Quit, \ + , SDL_BASE_NAME) + +#define SDL_QuitSubSystem(flags) \ + LP1NR(0x30, SDL_QuitSubSystem, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_RWFromFP(fp, autoclose) \ + LP2(0x42, SDL_RWops *, SDL_RWFromFP, FILE *, fp, a0, int, autoclose, d0, \ + , SDL_BASE_NAME) + +#define SDL_RWFromFile(file, mode) \ + LP2(0x3c, SDL_RWops *, SDL_RWFromFile, const char *, file, a0, const char *, mode, a1, \ + , SDL_BASE_NAME) + +#define SDL_RWFromMem(mem, size) \ + LP2(0x48, SDL_RWops *, SDL_RWFromMem, void *, mem, a0, int, size, d0, \ + , SDL_BASE_NAME) + +#define SDL_RemoveTimer(t) \ + LP1(0x1b0, SDL_bool, SDL_RemoveTimer, SDL_TimerID, t, d0, \ + , SDL_BASE_NAME) + +#define SDL_SaveBMP_RW(surface, dst, freedst) \ + LP3(0xfc, int, SDL_SaveBMP_RW, SDL_Surface *, surface, a0, SDL_RWops *, dst, a1, int, freedst, d0, \ + , SDL_BASE_NAME) + +#define SDL_SetAlpha(surface, flag, alpha) \ + LP3(0x108, int, SDL_SetAlpha, SDL_Surface *, surface, a0, Uint32, flag, d0, Uint8, alpha, d1, \ + , SDL_BASE_NAME) + +#define SDL_SetClipRect(surface, rect) \ + LP2(0x10e, SDL_bool, SDL_SetClipRect, SDL_Surface *, surface, a0, const SDL_Rect *, rect, a1, \ + , SDL_BASE_NAME) + +#define SDL_SetColorKey(surface, flag, key) \ + LP3(0x102, int, SDL_SetColorKey, SDL_Surface *, surface, a0, Uint32, flag, d0, Uint32, key, d1, \ + , SDL_BASE_NAME) + +#define SDL_SetColors(surface, colors, firstcolor, ncolors) \ + LP4(0xcc, int, SDL_SetColors, SDL_Surface *, surface, a0, SDL_Color *, colors, a1, int, firstcolor, d0, int, ncolors, d1, \ + , SDL_BASE_NAME) + +#define SDL_SetCursor(cursor) \ + LP1NR(0x282, SDL_SetCursor, SDL_Cursor *, cursor, a0, \ + , SDL_BASE_NAME) + +#define SDL_SetError(fmt, args...) \ + ({unsigned long _tags[] = { args }; SDL_SetErrorA(fmt, (void *)_tags);}) + +#define SDL_SetErrorA(fmt, arglist) \ + LP2NR(0x2a0, SDL_SetErrorA, const char *, fmt, a0, unsigned long *, arglist, a1, \ + , SDL_BASE_NAME) + +#define SDL_SetEventFilter(filter) \ + LP1NR(0x1d4, SDL_SetEventFilter, SDL_EventFilter, filter, d0, \ + , SDL_BASE_NAME) + +#define SDL_SetGamma(red, green, blue) \ + LP3(0xba, int, SDL_SetGamma, float, red, d0, float, green, d1, float, blue, d2, \ + , SDL_BASE_NAME) + +#define SDL_SetGammaRamp(red, green, blue) \ + LP3(0xc0, int, SDL_SetGammaRamp, Uint16 *, red, d0, Uint16 *, green, d1, Uint16 *, blue, d2, \ + , SDL_BASE_NAME) + +#define SDL_SetModState(modstate) \ + LP1NR(0x25e, SDL_SetModState, SDLMod, modstate, d0, \ + , SDL_BASE_NAME) + +#define SDL_SetPalette(surface, flags, colors, firstcolor, ncolors) \ + LP5(0xd2, int, SDL_SetPalette, SDL_Surface *, surface, a0, int, flags, d0, SDL_Color *, colors, a1, int, firstcolor, d1, int, ncolors, d2, \ + , SDL_BASE_NAME) + +#define SDL_SetTimer(interval, callback) \ + LP2(0x1a4, int, SDL_SetTimer, Uint32, interval, d0, SDL_TimerCallback, callback, a0, \ + , SDL_BASE_NAME) + +#define SDL_SetVideoMode(width, height, bpp, flags) \ + LP4(0x90, SDL_Surface *, SDL_SetVideoMode, int, width, d0, int, height, d1, int, bpp, d2, Uint32, flags, d3, \ + , SDL_BASE_NAME) + +#define SDL_ShowCursor(toggle) \ + LP1(0x294, int, SDL_ShowCursor, int, toggle, d0, \ + , SDL_BASE_NAME) + +#define SDL_SoftStretch(src, srcrect, dest, dstrect) \ + LP4(0x32a, int, SDL_SoftStretch, SDL_Surface *, src, a0, SDL_Rect *, srcrect, a1, SDL_Surface *, dest, a2, SDL_Rect *, dstrect, a3, \ + , SDL_BASE_NAME) + +#define SDL_ThreadID() \ + LP0(0x30c, Uint32, SDL_ThreadID, \ + , SDL_BASE_NAME) + +#define SDL_UnlockAudio() \ + LP0NR(0x2fa, SDL_UnlockAudio, \ + , SDL_BASE_NAME) + +#define SDL_UnlockSurface(surface) \ + LP1NR(0xf6, SDL_UnlockSurface, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_UnlockYUVOverlay(overlay) \ + LP1NR(0x132, SDL_UnlockYUVOverlay, SDL_Overlay *, overlay, a0, \ + , SDL_BASE_NAME) + +#define SDL_UpdateRect(screen, x, y, w, h) \ + LP5NR(0x84, SDL_UpdateRect, SDL_Surface *, screen, a0, Sint32, x, d0, Sint32, y, d1, Uint32, w, d2, Uint32, h, d3, \ + , SDL_BASE_NAME) + +#define SDL_UpdateRects(screen, numrects, rects) \ + LP3NR(0x7e, SDL_UpdateRects, SDL_Surface *, screen, a0, int, numrects, d0, SDL_Rect *, rects, a1, \ + , SDL_BASE_NAME) + +#define SDL_UpperBlit(src, srcrect, dst, dstrect) \ + LP4(0x72, int, SDL_UpperBlit, SDL_Surface *, src, a0, SDL_Rect *, srcrect, d0, SDL_Surface *, dst, a1, SDL_Rect *, dstrect, d1, \ + , SDL_BASE_NAME) + +#define SDL_VideoDriverName(namebuf, maxlen) \ + LP2(0xa2, char *, SDL_VideoDriverName, char *, namebuf, a0, int, maxlen, d0, \ + , SDL_BASE_NAME) + +#define SDL_VideoModeOK(width, height, bpp, flags) \ + LP4(0xae, int, SDL_VideoModeOK, int, width, d0, int, height, d1, int, bpp, d2, Uint32, flags, d3, \ + , SDL_BASE_NAME) + +#define SDL_WM_GetCaption(title, icon) \ + LP2NR(0x17a, SDL_WM_GetCaption, char **, title, a0, char **, icon, a1, \ + , SDL_BASE_NAME) + +#define SDL_WM_GrabInput(mode) \ + LP1(0x192, SDL_GrabMode, SDL_WM_GrabInput, SDL_GrabMode, mode, d0, \ + , SDL_BASE_NAME) + +#define SDL_WM_IconifyWindow() \ + LP0(0x186, int, SDL_WM_IconifyWindow, \ + , SDL_BASE_NAME) + +#define SDL_WM_SetCaption(title, icon) \ + LP2NR(0x174, SDL_WM_SetCaption, const char *, title, a0, const char *, icon, a1, \ + , SDL_BASE_NAME) + +#define SDL_WM_SetIcon(icon, mask) \ + LP2NR(0x180, SDL_WM_SetIcon, SDL_Surface *, icon, a0, Uint8 *, mask, a1, \ + , SDL_BASE_NAME) + +#define SDL_WM_ToggleFullScreen(surface) \ + LP1(0x18c, int, SDL_WM_ToggleFullScreen, SDL_Surface *, surface, a0, \ + , SDL_BASE_NAME) + +#define SDL_WaitEvent(event) \ + LP1(0x1c2, int, SDL_WaitEvent, SDL_Event *, event, a0, \ + , SDL_BASE_NAME) + +#define SDL_WaitThread(thread, status) \ + LP2NR(0x318, SDL_WaitThread, SDL_Thread *, thread, a0, int *, status, a1, \ + , SDL_BASE_NAME) + +#define SDL_WarpMouse(x, y) \ + LP2NR(0x276, SDL_WarpMouse, Uint16, x, d0, Uint16, y, d1, \ + , SDL_BASE_NAME) + +#define SDL_WasInit(flags) \ + LP1(0x36, Uint32, SDL_WasInit, Uint32, flags, d0, \ + , SDL_BASE_NAME) + +#define SDL_free(src, srcrect, dest, dstrect) \ + LP2(0x330, int, SDL_SoftStretch, SDL_Surface *, src, a0, SDL_Rect *, srcrect, a1 \ + , SDL_BASE_NAME) + +#endif /* !_INLINE_SDL_H */ diff --git a/src/main/amigaos/SDL_lutstub.s b/src/main/amigaos/SDL_lutstub.s new file mode 100644 index 000000000..91ea314a5 --- /dev/null +++ b/src/main/amigaos/SDL_lutstub.s @@ -0,0 +1,28 @@ +#NO_APP +gcc2_compiled.: +___gnu_compiled_c: +.text + .even +.globl _WLUT + +_WLUT: + moveml #0x3f36,sp@- + movel sp@(48),a5 + movel sp@(52),a3 + movel sp@(56),d2 + movel sp@(64),a2 + movel sp@(68),d3 + movel sp@(72),d4 + movel sp@(76),d5 + movel sp@(80),d6 + movel sp@(84),d7 + movel _CyberGfxBase,a6 + movel sp@(44),a0 + movew a5,d0 + movew a3,d1 + movel sp@(60),a1 +#APP + jsr a6@(-0xc6:W) +#NO_APP + moveml sp@+,#0x6cfc + rts diff --git a/src/main/amigaos/SDL_lutstubrel.s b/src/main/amigaos/SDL_lutstubrel.s new file mode 100644 index 000000000..56ed8f03f --- /dev/null +++ b/src/main/amigaos/SDL_lutstubrel.s @@ -0,0 +1,33 @@ +gcc2_compiled.: +___gnu_compiled_c: +.text + .even +.globl _mygeta4 +.globl _WLUT + +_mygeta4: + movel a6@(40:W),a4 + lea a4@(_SysBase:W),a5 + rts + +_WLUT: + moveml #0x3f36,sp@- + movel sp@(48),a5 + movel sp@(52),a3 + movel sp@(56),d2 + movel sp@(64),a2 + movel sp@(68),d3 + movel sp@(72),d4 + movel sp@(76),d5 + movel sp@(80),d6 + movel sp@(84),d7 + movel a4@(_CyberGfxBase:W),a6 + movel sp@(44),a0 + movew a5,d0 + movew a3,d1 + movel sp@(60),a1 +#APP + jsr a6@(-0xc6:W) +#NO_APP + moveml sp@+,#0x6cfc + rts diff --git a/src/main/amigaos/SDLstub.c b/src/main/amigaos/SDLstub.c new file mode 100644 index 000000000..e82aac459 --- /dev/null +++ b/src/main/amigaos/SDLstub.c @@ -0,0 +1,26 @@ +#include +#include "SDL_types.h" +#include "SDL_inline.h" +#include +#include + +struct Library *SDLBase=NULL; +extern struct ExecBase *SysBase; + +int SDL_Init(unsigned long flags) +{ + if(!SDLBase) + if(!(SDLBase=OpenLibrary("SDL.library",0L))) + return -1; + + return SDL_RealInit(flags); +} + +void SDL_Quit(void) +{ + if(SDLBase) { + SDL_RealQuit(); + CloseLibrary(SDLBase); + SDLBase=NULL; + } +} diff --git a/src/main/amigaos/stabs.h b/src/main/amigaos/stabs.h new file mode 100644 index 000000000..a78168ff1 --- /dev/null +++ b/src/main/amigaos/stabs.h @@ -0,0 +1,164 @@ +#ifndef _STABS_H_ +#define _STABS_H_ + +/* These are some macros for handling of symboltable information + */ + +/* linker can use symbol b for symbol a if a is not defined */ +#define ALIAS(a,b) asm(".stabs \"_" #a "\",11,0,0,0\n.stabs \"_" #b "\",1,0,0,0") + +/* add symbol a to list b (type c (22=text 24=data 26=bss)) */ +#define ADD2LIST(a,b,c) asm(".stabs \"_" #b "\"," #c ",0,0,_" #a ) + +/* Install private constructors and destructors pri MUST be -127<=pri<=127 */ +#define ADD2INIT(a,pri) ADD2LIST(a,__INIT_LIST__,22); \ + asm(".stabs \"___INIT_LIST__\",20,0,0," #pri "+128") +#define ADD2EXIT(a,pri) ADD2LIST(a,__EXIT_LIST__,22); \ + asm(".stabs \"___EXIT_LIST__\",20,0,0," #pri "+128") + +/* Add to library list */ +#define ADD2LIB(a) ADD2LIST(a,__LIB_LIST__,24) + +/* This one does not really handle symbol tables + * it's just pointless to write a header file for one macro + * + * define a as a label for an absolute address b + */ +#define ABSDEF(a,b) asm("_" #a "=" #b ";.globl _" #a ) + +/* Generate assembler stub for a shared library entry + * and add it to the jump table + * ADDTABL_X(name,...) means function with X arguments + * ADDTABL_END() ends the list + * Usage: ADDTABL_2(AddHead,a0,a1); + * No more than 4 arguments supported, use structures! + */ + +#define _ADDTABL_START(name) \ +asm(".globl ___" #name); \ +asm("___" #name ":\tmovel a4,sp@-") + +#define _ADDTABL_ARG(arg) \ +asm("\tmovel " #arg ",sp@-") + +#define _ADDTABL_CALL(name) \ +asm("\tmovel a6@(40:W),a4"); \ +asm("\tjsr _" #name) + +// asm("\tbsr _" #name) + +#define _ADDTABL_END0(name,numargs) \ +asm("\tmovel sp@+,a4"); \ +asm("\trts"); \ +ADD2LIST(__##name,__FuncTable__,22) + +#define _ADDTABL_END2(name,numargs) \ +asm("\taddqw #4*" #numargs ",sp"); \ +asm("\tmovel sp@+,a4"); \ +asm("\trts"); \ +ADD2LIST(__##name,__FuncTable__,22) + +#define _ADDTABL_ENDN(name,numargs) \ +asm("\taddaw #4*" #numargs ",sp"); \ +asm("\tmovel sp@+,a4"); \ +asm("\trts"); \ +ADD2LIST(__##name,__FuncTable__,22) + +#define ADDTABL_0(name) \ +_ADDTABL_START(name); \ +_ADDTABL_CALL(name); \ +_ADDTABL_END0(name,0) + +#define ADDTABL_1(name,arg1) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_END2(name,1) + +#define ADDTABL_2(name,arg1,arg2) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_END2(name,2) + +#define ADDTABL_3(name,arg1,arg2,arg3) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,3) + +#define ADDTABL_4(name,arg1,arg2,arg3,arg4) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,4) + +#define ADDTABL_5(name,arg1,arg2,arg3,arg4,arg5) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg5); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,5) + +#define ADDTABL_6(name,arg1,arg2,arg3,arg4,arg5,arg6) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg6); \ +_ADDTABL_ARG(arg5); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,6) + +#define ADDTABL_7(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg7); \ +_ADDTABL_ARG(arg6); \ +_ADDTABL_ARG(arg5); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,7) + +#define ADDTABL_8(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg8); \ +_ADDTABL_ARG(arg7); \ +_ADDTABL_ARG(arg6); \ +_ADDTABL_ARG(arg5); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,8) + +#define ADDTABL_9(name,arg1,arg2,arg3,arg4,arg5,arg6,arg7,arg8,arg9) \ +_ADDTABL_START(name); \ +_ADDTABL_ARG(arg9); \ +_ADDTABL_ARG(arg8); \ +_ADDTABL_ARG(arg7); \ +_ADDTABL_ARG(arg6); \ +_ADDTABL_ARG(arg5); \ +_ADDTABL_ARG(arg4); \ +_ADDTABL_ARG(arg3); \ +_ADDTABL_ARG(arg2); \ +_ADDTABL_ARG(arg1); \ +_ADDTABL_CALL(name); \ +_ADDTABL_ENDN(name,9) + +#define ADDTABL_END() asm(".stabs \"___FuncTable__\",20,0,0,-1") + +#endif From 5ff6109c636cec641726f843bb5dcc54f83080d1 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 16:36:56 +0100 Subject: [PATCH 04/21] Fix joystick support --- CMakeLists.txt | 2 +- include/SDL_config_amiga.h | 2 +- src/joystick/amigaos/SDL_sysjoystick.c | 107 ++++++++++++++++++++----- 3 files changed, 90 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 56d586746..8fad6ed34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -139,7 +139,7 @@ add_library(${LIBNAME} # JOYSTICK ${PROJECT_SOURCE_DIR}/src/joystick/SDL_joystick.c - ${PROJECT_SOURCE_DIR}/src/joystick/SDL_sysjoystick.c + ${PROJECT_SOURCE_DIR}/src/joystick/amigaos/SDL_sysjoystick.c # EVENTS ${PROJECT_SOURCE_DIR}/src/events/SDL_quit.c diff --git a/include/SDL_config_amiga.h b/include/SDL_config_amiga.h index 0578a0767..bdac4ffd4 100644 --- a/include/SDL_config_amiga.h +++ b/include/SDL_config_amiga.h @@ -158,7 +158,7 @@ typedef unsigned long long uint64_t; //#define SDL_CDROM_AMIGA 1 /* Enable various input drivers */ -//#define SDL_JOYSTICK_AMIGA 1 +#define SDL_JOYSTICK_AMIGA 1 /* Enable various shared object loading systems */ //#define SDL_LOADSO_AMIGA 1 diff --git a/src/joystick/amigaos/SDL_sysjoystick.c b/src/joystick/amigaos/SDL_sysjoystick.c index 35e4ebe41..43f527933 100644 --- a/src/joystick/amigaos/SDL_sysjoystick.c +++ b/src/joystick/amigaos/SDL_sysjoystick.c @@ -26,24 +26,35 @@ /* This is the system specific header for the SDL joystick API */ #include -#if defined(__SASC) || defined(STORMC4_WOS) +#if defined(__SASC) || defined(WARPOS) || defined(AROS) #include #include #include #else +#ifdef MORPHOS +#include +#include +#include +#else +#include +#include #include #include #include #endif +#endif #include "mydebug.h" extern struct ExecBase *SysBase; extern struct GfxBase *GfxBase; -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" +#include +#include "SDL_error.h" +#include "SDL_joystick.h" +#include "SDL_sysjoystick.h" +#include "SDL_joystick_c.h" +#include /* 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. @@ -92,9 +103,9 @@ const char *SDL_SYS_JoystickName(int index) { switch(index) { - case 0: - return "Port 1 Amiga Joystick/Joypad"; case 1: + return "Port 1 Amiga Joystick/Joypad"; + case 0: return "Port 2 Amiga Joystick/Joypad"; } } @@ -118,11 +129,13 @@ int SDL_SYS_JoystickOpen(SDL_Joystick *joystick) return -1; /* This loop is to check if the controller is a joypad */ - for(i=0;i<20;i++) { - temp=ReadJoyPort(joystick->index^1); // fix to invert amiga joyports - WaitTOF(); + int index; + if (joystick->index == 0)index = 1; // include Port 0 should be amiga Port 2 + else index = 0; + temp=ReadJoyPort(index); + Delay(1); } if((temp&JP_TYPE_MASK)==JP_TYPE_GAMECTLR) @@ -150,45 +163,101 @@ void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick) if(joystick->index<2) { - data=ReadJoyPort(joystick->index); + int index; + if (joystick->index == 0)index = 1; + else index = 0; + data=ReadJoyPort(index); +#if 1 + if(data&JP_DIRECTION_MASK) + { + + if( data & (JPF_JOY_UP|JPF_JOY_DOWN) ) + { + + if(data&JPF_JOY_DOWN) + { + if(!(joystick->hwdata->joystate&JPF_JOY_DOWN)) + SDL_PrivateJoystickAxis(joystick,1,257); + } + else + { + if(!(joystick->hwdata->joystate&JPF_JOY_UP)) + SDL_PrivateJoystickAxis(joystick,1,-257); + } + } + else + if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) + SDL_PrivateJoystickAxis(joystick,1,0); + + if( data & (JPF_JOY_LEFT|JPF_JOY_RIGHT) ) + { + + if(data&JPF_JOY_LEFT) + { + if(!(joystick->hwdata->joystate&JPF_JOY_LEFT)) + SDL_PrivateJoystickAxis(joystick,0,-257); + } + else + { + if(!(joystick->hwdata->joystate&JPF_JOY_RIGHT)) + SDL_PrivateJoystickAxis(joystick,0,257); + } + } + else + if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) + SDL_PrivateJoystickAxis(joystick,0,0); + } + else + { + if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) + { + SDL_PrivateJoystickAxis(joystick,0,0); + } + if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) + { + SDL_PrivateJoystickAxis(joystick,1,0); + } + } +#else if(data&JP_DIRECTION_MASK) { if(data&JPF_JOY_DOWN) { + if(!(joystick->hwdata->joystate&JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis(joystick,0,127); + SDL_PrivateJoystickAxis(joystick,1,257); } else if(data&JPF_JOY_UP) { if(!(joystick->hwdata->joystate&JPF_JOY_UP)) - SDL_PrivateJoystickAxis(joystick,0,-127); + SDL_PrivateJoystickAxis(joystick,1,-257); } else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) - SDL_PrivateJoystickAxis(joystick,0,0); + SDL_PrivateJoystickAxis(joystick,1,0); if(data&JPF_JOY_LEFT) { if(!(joystick->hwdata->joystate&JPF_JOY_LEFT)) - SDL_PrivateJoystickAxis(joystick,1,-127); + SDL_PrivateJoystickAxis(joystick,0,-257); } else if(data&JPF_JOY_RIGHT) { if(!(joystick->hwdata->joystate&JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis(joystick,1,127); + SDL_PrivateJoystickAxis(joystick,0,257); } else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) - SDL_PrivateJoystickAxis(joystick,1,0); + SDL_PrivateJoystickAxis(joystick,0,0); } else if(joystick->hwdata->joystate&(JPF_JOY_LEFT|JPF_JOY_RIGHT)) { - SDL_PrivateJoystickAxis(joystick,1,0); + SDL_PrivateJoystickAxis(joystick,0,0); } else if(joystick->hwdata->joystate&(JPF_JOY_UP|JPF_JOY_DOWN)) { - SDL_PrivateJoystickAxis(joystick,0,0); + SDL_PrivateJoystickAxis(joystick,1,0); } - + #endif for(i=0;inbuttons;i++) { if( (data&joybut[i]) ) From 480ac6d74ad127becf065fcc7479e18b22ec9618 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 16:48:03 +0100 Subject: [PATCH 05/21] Add AmigaOS3 makefile Reintroduce __AMIGADATE__ for Makefile based $VER string --- Makefile.amigaos3 | 76 +++++++++++++++++++++++ amiga/makefile-support/SDL_amigaversion.h | 2 +- 2 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 Makefile.amigaos3 diff --git a/Makefile.amigaos3 b/Makefile.amigaos3 new file mode 100644 index 000000000..9d469b13e --- /dev/null +++ b/Makefile.amigaos3 @@ -0,0 +1,76 @@ +# Makefile for gcc version of SDL +# +# changes: +# 18-Apr: _ApolloKeyRGB565toRGB565: disabled AMMX version of ColorKeying (for now, storem is not working in Gold2) +# 17-Nov: - fixed Shadow Surfaces (hopefully), they were effectively impossible +# in the code base I got +# - fixed ARGB32 (CGX code was assuming RGBA all the time) +# 12-Feb: - deleted redundant includes, now only include/ directory remains (as it should) + +PREFX := /opt/m68k-amigaos + +CC := $(PREFX)/bin/m68k-amigaos-gcc +AS := $(PREFX)/bin/m68k-amigaos-as +AR := $(PREFX)/bin/m68k-amigaos-ar +LD := $(PREFX)/bin/m68k-amigaos-ld +RL := $(PREFX)/bin/m68k-amigaos-ranlib +VASM := $(PREFX)/bin/vasmm68k_mot +AMIGADATE := $(shell date +"%-d.%-m.%Y") + +CPU := 68030 + +GCCFLAGS = -I$(PREFX)/include -I. -Iinclude -Isrc/thread -Isrc/video -Isrc/main/amigaos -Isrc/timer -Isrc/events -Isrc/joystick -Iamiga/makefile-support \ + -Ofast -fomit-frame-pointer -m$(CPU) -mhard-float -ffast-math -noixemul \ + -DNOIXEMUL -D_HAVE_STDINT_H \ + -D__AMIGADATE__=\"$(AMIGADATE)\" +GLFLAGS = -DSHARED_LIB -lamiga +GCCFLAGS += -DNO_AMIGADEBUG +GLFLAGS += -DNO_AMIGADEBUG + +GOBJS = src/audio/SDL_audio.go src/audio/SDL_audiocvt.go src/audio/SDL_mixer.go src/audio/SDL_mixer_m68k.go src/audio/SDL_wave.go src/audio/amigaos/SDL_ahiaudio.go \ + src/SDL_error.go src/SDL_fatal.go src/video/SDL_RLEaccel.go src/video/SDL_blit.go src/video/SDL_blit_0.go \ + src/video/SDL_blit_1.go src/video/SDL_blit_A.go src/video/SDL_blit_N.go \ + src/video/SDL_bmp.go src/video/SDL_cursor.go src/video/SDL_pixels.go src/video/SDL_surface.go src/video/SDL_stretch.go \ + src/video/SDL_yuv.go src/video/SDL_yuv_sw.go src/video/SDL_video.go \ + src/timer/amigaos/SDL_systimer.go src/timer/SDL_timer.go src/joystick/SDL_joystick.go \ + src/joystick/amigaos/SDL_sysjoystick.go src/events/SDL_quit.go src/events/SDL_active.go \ + src/cpuinfo/SDL_cpuinfo.go src/events/SDL_keyboard.go src/events/SDL_mouse.go src/events/SDL_resize.go src/file/SDL_rwops.go src/SDL.go \ + src/events/SDL_events.go src/thread/amigaos/SDL_sysmutex.go src/thread/amigaos/SDL_syssem.go src/thread/amigaos/SDL_systhread.go src/thread/amigaos/SDL_thread.go \ + src/thread/amigaos/SDL_syscond.go src/video/cybergfx/SDL_cgxvideo.go src/video/cybergfx/SDL_cgxmodes.go src/video/cybergfx/SDL_cgximage.go src/video/cybergfx/SDL_amigaevents.go \ + src/video/cybergfx/SDL_amigamouse.go src/video/cybergfx/SDL_cgxgl.go src/video/cybergfx/SDL_cgxwm.go \ + src/video/cybergfx/SDL_cgxyuv.go src/video/cybergfx/SDL_cgxaccel.go src/video/cybergfx/SDL_cgxgl_wrapper.go \ + src/video/SDL_gamma.go src/main/amigaos/SDL_lutstub.ll src/stdlib/SDL_stdlib.go src/stdlib/SDL_string.go src/stdlib/SDL_malloc.go src/stdlib/SDL_getenv.go + +# Disabled modules +# src/cdrom/SDL_cdrom.go src/cdrom/amigaos/SDL_syscdrom.go + +# +# BEGIN APOLLO ASM SUPPORT +# ( build vasm: make CPU=m68k SYNTAX=mot ) +# +VFLAGS = -devpac -I$(PREFX)/m68k-amigaos/ndk-include -Fhunk +GCCFLAGS += -DAPOLLO_BLIT -Isrc/video/apollo +# -DAPOLLO_BLITDBG +GOBJS += src/video/apollo/blitapollo.ao src/video/apollo/apolloammxenable.ao src/video/apollo/colorkeyapollo.ao + +%.ao: %.asm + $(VASM) $(VFLAGS) -o $@ $*.asm +# +# END APOLLO ASM SUPPORT +# + +%.go: %.c + $(CC) $(GCCFLAGS) $(GCCDEFINES) -o $@ -c $*.c + +%.ll: %.s + $(AS) -m$(CPU) -o $@ $*.s + +all: libSDL.a + +libSDL.a: $(GOBJS) + -rm -f libSDL.a + $(AR) cru libSDL.a $(GOBJS) + $(RL) libSDL.a + +clean: + -rm -f $(GOBJS) diff --git a/amiga/makefile-support/SDL_amigaversion.h b/amiga/makefile-support/SDL_amigaversion.h index 1d48e039d..21dfe6a15 100644 --- a/amiga/makefile-support/SDL_amigaversion.h +++ b/amiga/makefile-support/SDL_amigaversion.h @@ -1,4 +1,4 @@ #ifndef SDL_AMIGAVERSION_H #define SDL_AMIGAVERSION_H -static const char __attribute((used)) amiga_ver[] = "$VER: SDL.library 12.16 (06.02.2020) Amiga port of SDL v1.2.16\0"; +static const char __attribute((used)) amiga_ver[] = "$VER: SDL.library 12.16 (" __AMIGADATE__ ") Amiga port of SDL v1.2.16\0"; #endif /* SDL_AMIGAVERSION_H */ From 5668d8a481afbc0361332c5b69739fdb254a9415 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 18:15:40 +0100 Subject: [PATCH 06/21] Cleanup add support for AmigaOS4 in CMakeLists.txt --- .gitignore | 1 + CMakeLists.txt | 174 +++++++++++++------ include/SDL_config.h | 2 +- include/SDL_config_amigaos4.h | 8 +- include/SDL_stdinc.h | 8 +- include/SDL_version.h | 91 ---------- src/SDL.c | 2 +- src/audio/SDL_audio.c | 5 +- src/audio/SDL_sysaudio.h | 4 +- src/audio/amigaos/SDL_ahiaudio.h | 2 +- src/joystick/amigaos/SDL_sysjoystick.c | 2 +- src/main/amigaos/SDL_amigasas.c | 2 +- src/main/amigaos/SDL_amigastub.c | 2 +- mydebug.h => src/main/amigaos/SDL_os3debug.h | 0 src/thread/amigaos/SDL_systhread.c | 2 +- src/thread/amigaos/SDL_systhread_c.h | 2 +- src/timer/amigaos/SDL_systimer.c | 2 +- src/video/SDL_video.c | 15 +- src/video/cybergfx/SDL_cgximage.c | 2 +- src/video/cybergfx/SDL_cgxmodes.c | 2 +- src/video/cybergfx/SDL_cgxvideo.c | 2 +- src/video/cybergfx/SDL_cgxvideo.h | 2 +- 22 files changed, 153 insertions(+), 179 deletions(-) delete mode 100644 include/SDL_version.h rename mydebug.h => src/main/amigaos/SDL_os3debug.h (100%) diff --git a/.gitignore b/.gitignore index 35ad8a9b6..d166167df 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ .idea/ build/ cmake-build-*/* +build-*/ diff --git a/CMakeLists.txt b/CMakeLists.txt index 8fad6ed34..325a58731 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,7 +54,7 @@ string(REGEX REPLACE "^0+" "" VER_DAY "${VER_DAY}") # Set Amiga version set(AMIGA_VERSION "${SDL_MAJOR_VERSION}${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}") -# Final build filename, for example "milkytracker-1.02.00-win32.zip" +# Final build filename, for example "SDL1.2-1.2.16-AmigaOS.zip" set(BUILD_FILENAME "SDL-${GIT_TAG}-${SYSTEM_NAME_LOWER}-${SYSTEM_ARCH_LOWER}") set(CPACK_GENERATOR ZIP) @@ -81,47 +81,90 @@ configure_file( set(CMAKE_CXX_STANDARD 14) +set(SOURCE_FILES + # MAIN + ${PROJECT_SOURCE_DIR}/src/SDL.c + ${PROJECT_SOURCE_DIR}/src/SDL_error.c + ${PROJECT_SOURCE_DIR}/src/SDL_fatal.c + + # CDROM + ${PROJECT_SOURCE_DIR}/src/cdrom/SDL_cdrom.c + + # CPUINFO + ${PROJECT_SOURCE_DIR}/src/cpuinfo/SDL_cpuinfo.c + + # AUDIO + ${PROJECT_SOURCE_DIR}/src/audio/SDL_audio.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_audiocvt.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer_m68k.c + ${PROJECT_SOURCE_DIR}/src/audio/SDL_wave.c + #${PROJECT_SOURCE_DIR}/src/audio/dummy/SDL_dummyaudio.c + #${PROJECT_SOURCE_DIR}/src/audio/disk/SDL_diskaudio.c + + # VIDEO + ${PROJECT_SOURCE_DIR}/src/video/SDL_RLEaccel.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_0.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_1.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_A.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_N.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_bmp.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_cursor.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_pixels.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_surface.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_stretch.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv_sw.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_video.c + ${PROJECT_SOURCE_DIR}/src/video/SDL_gamma.c + + # TIMER + ${PROJECT_SOURCE_DIR}/src/timer/SDL_timer.c + + # JOYSTICK + ${PROJECT_SOURCE_DIR}/src/joystick/SDL_joystick.c + + # EVENTS + ${PROJECT_SOURCE_DIR}/src/events/SDL_active.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_events.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_expose.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_keyboard.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_mouse.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_quit.c + ${PROJECT_SOURCE_DIR}/src/events/SDL_resize.c + + # FILE + ${PROJECT_SOURCE_DIR}/src/file/SDL_rwops.c + + # THREADS + ${PROJECT_SOURCE_DIR}/src/thread/SDL_thread.c + ${PROJECT_SOURCE_DIR}/src/thread/generic/SDL_syscond.c + + # STDLIB + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_getenv.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_iconv.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_malloc.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_qsort.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_stdlib.c + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c + + + ) - -add_library(${LIBNAME} - STATIC +if(AMIGA) + if(AMIGAOS3) + list(APPEND SOURCE_FILES # MAIN - ${PROJECT_SOURCE_DIR}/src/SDL.c - ${PROJECT_SOURCE_DIR}/src/SDL_error.c - ${PROJECT_SOURCE_DIR}/src/SDL_fatal.c ${PROJECT_SOURCE_DIR}/src/main/amigaos/SDL_lutstub.s - # CPUINFO - ${PROJECT_SOURCE_DIR}/src/cpuinfo/SDL_cpuinfo.c + # CDROM + #${PROJECT_SOURCE_DIR}/src/cdrom/amigaos/SDL_syscdrom.c # AUDIO - ${PROJECT_SOURCE_DIR}/src/audio/SDL_audio.c - ${PROJECT_SOURCE_DIR}/src/audio/SDL_audiocvt.c - ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer.c - ${PROJECT_SOURCE_DIR}/src/audio/SDL_mixer_m68k.c - ${PROJECT_SOURCE_DIR}/src/audio/SDL_wave.c - #${PROJECT_SOURCE_DIR}/src/audio/dummy/SDL_dummyaudio.c - #${PROJECT_SOURCE_DIR}/src/audio/disk/SDL_diskaudio.c ${PROJECT_SOURCE_DIR}/src/audio/amigaos/SDL_ahiaudio.c # VIDEO - ${PROJECT_SOURCE_DIR}/src/video/SDL_RLEaccel.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_blit.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_0.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_1.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_A.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_blit_N.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_bmp.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_cursor.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_pixels.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_surface.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_stretch.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_yuv_sw.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_video.c - ${PROJECT_SOURCE_DIR}/src/video/SDL_gamma.c - - # CYBERGRAPHICS ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxvideo.c ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgxmodes.c ${PROJECT_SOURCE_DIR}/src/video/cybergfx/SDL_cgximage.c @@ -135,23 +178,10 @@ add_library(${LIBNAME} # TIMER ${PROJECT_SOURCE_DIR}/src/timer/amigaos/SDL_systimer.c - ${PROJECT_SOURCE_DIR}/src/timer/SDL_timer.c # JOYSTICK - ${PROJECT_SOURCE_DIR}/src/joystick/SDL_joystick.c ${PROJECT_SOURCE_DIR}/src/joystick/amigaos/SDL_sysjoystick.c - # EVENTS - ${PROJECT_SOURCE_DIR}/src/events/SDL_quit.c - ${PROJECT_SOURCE_DIR}/src/events/SDL_active.c - ${PROJECT_SOURCE_DIR}/src/events/SDL_keyboard.c - ${PROJECT_SOURCE_DIR}/src/events/SDL_mouse.c - ${PROJECT_SOURCE_DIR}/src/events/SDL_resize.c - ${PROJECT_SOURCE_DIR}/src/events/SDL_events.c - - # FILE - ${PROJECT_SOURCE_DIR}/src/file/SDL_rwops.c - # THREADS ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_sysmutex.c ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syssem.c @@ -159,11 +189,51 @@ add_library(${LIBNAME} ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_thread.c ${PROJECT_SOURCE_DIR}/src/thread/amigaos/SDL_syscond.c - # STDLIB - ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_stdlib.c - ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c - ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_malloc.c - ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_getenv.c) + # LOADSO + ${PROJECT_SOURCE_DIR}/src/loadso/dummy/SDL_sysloadso.c + ) + elseif(AMIGAOS4) + list(APPEND SOURCE_FILES + # MAIN + ${PROJECT_SOURCE_DIR}/src/main/amigaos4/SDL_os4timer.c + + # CDROM + ${PROJECT_SOURCE_DIR}/src/cdrom/amigaos4/SDL_syscdrom.c + + # AUDIO + ${PROJECT_SOURCE_DIR}/src/audio/amigaos4/SDL_os4audio.c + + # VIDEO + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4_wrapper.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4blit.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4events.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4gl.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4surface.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4utils.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4video.c + ${PROJECT_SOURCE_DIR}/src/video/amigaos4/SDL_os4wm.c + + # TIMER + ${PROJECT_SOURCE_DIR}/src/timer/amigaos4/SDL_systimer.c + + # JOYSTICK + ${PROJECT_SOURCE_DIR}/src/joystick/amigaos4/SDL_sysjoystick.c + + # THREADS + ${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_sysmutex.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_syssem.c + ${PROJECT_SOURCE_DIR}/src/thread/amigaos4/SDL_systhread.c + + # LOADSO + ${PROJECT_SOURCE_DIR}/src/loadso/amigaos4/SDL_sysloadso.c + + ) + endif() +endif() + +add_library(${LIBNAME} + STATIC + ${SOURCE_FILES}) target_include_directories(${LIBNAME} PRIVATE @@ -199,7 +269,7 @@ if(AMIGA) target_compile_definitions(${LIBNAME} PRIVATE $<$:NO_AMIGADEBUG>) endif() - if(APOLLOBLIT) + if(APOLLOBLIT AND AMIGAOS3) target_compile_definitions(${LIBNAME} PRIVATE $<$:APOLLO_BLIT>) target_compile_options(${LIBNAME} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include) target_include_directories(${LIBNAME} PUBLIC video/apollo) diff --git a/include/SDL_config.h b/include/SDL_config.h index 9c90f946d..b093b1d34 100644 --- a/include/SDL_config.h +++ b/include/SDL_config.h @@ -40,7 +40,7 @@ #include "SDL_config_os2.h" #elif defined(__amigaos4__) #include "SDL_config_amigaos4.h" -#elif defined(__AMIGA__) +#elif defined(__AMIGA__) && !defined(__amigaos4__) #include "SDL_config_amiga.h" #else #include "SDL_config_minimal.h" diff --git a/include/SDL_config_amigaos4.h b/include/SDL_config_amigaos4.h index 998ae0bcb..28e542824 100644 --- a/include/SDL_config_amigaos4.h +++ b/include/SDL_config_amigaos4.h @@ -21,8 +21,8 @@ slouken@libsdl.org */ -#ifndef _SDL_config_h -#define _SDL_config_h +#ifndef _SDL_config_amigaos4_h +#define _SDL_config_amigaos4_h /* This is a set of defines to configure the SDL features */ @@ -297,7 +297,7 @@ /* #undef SDL_VIDEO_DRIVER_XBIOS */ /* Enable OpenGL support */ -#define SDL_VIDEO_OPENGL 1 +//#define SDL_VIDEO_OPENGL 1 /* #undef SDL_VIDEO_OPENGL_GLX */ /* #undef SDL_VIDEO_OPENGL_WGL */ /* #undef SDL_VIDEO_OPENGL_OSMESA */ @@ -308,4 +308,4 @@ /* #undef SDL_HERMES_BLITTERS */ /* #undef SDL_ALTIVEC_BLITTERS */ -#endif /* _SDL_config_h */ +#endif /* _SDL_config_amigaos4_h */ diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 0df464784..b1954ca52 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -37,9 +37,9 @@ #include #endif #if defined(STDC_HEADERS) -# include -# include -# include +#include +#include +#include #else # if defined(HAVE_STDLIB_H) # include @@ -588,7 +588,7 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char #endif /** @name SDL_ICONV Error Codes - * The SDL implementation of iconv() returns these error codes + * The SDL implementation of iconv() returns these error codes */ /*@{*/ #define SDL_ICONV_ERROR (size_t)-1 diff --git a/include/SDL_version.h b/include/SDL_version.h deleted file mode 100644 index 4385ebf0b..000000000 --- a/include/SDL_version.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2012 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/** @file SDL_version.h - * This header defines the current SDL version - */ - -#ifndef _SDL_version_h -#define _SDL_version_h - -#include "SDL_stdinc.h" - -#include "begin_code.h" -/* Set up for C function definitions, even when using C++ */ -#ifdef __cplusplus -extern "C" { -#endif - -/** @name Version Number - * Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL - */ -/*@{*/ -#define SDL_MAJOR_VERSION 1 -#define SDL_MINOR_VERSION 2 -#define SDL_PATCHLEVEL 16 -/*@}*/ - -typedef struct SDL_version { - 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 * SDLCALL SDL_Linked_Version(void); - -/* Ends C function definitions when using C++ */ -#ifdef __cplusplus -} -#endif -#include "close_code.h" - -#endif /* _SDL_version_h */ diff --git a/src/SDL.c b/src/SDL.c index a8cc0ad67..7e4caaee6 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -28,7 +28,7 @@ #if !SDL_VIDEO_DISABLED #include "video/SDL_leaks.h" #endif -#include "mydebug.h" +#include "SDL_os3debug.h" #if SDL_THREAD_PTH #include diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 571853f9f..f3970a5db 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -230,7 +230,7 @@ int SDLCALL SDL_RunAudio(void *audiop) #endif audio->WaitAudio(audio); } - + /* Fill the current buffer with sound */ if ( audio->convert.needed ) { if ( audio->convert.buf ) { @@ -272,7 +272,7 @@ int SDLCALL SDL_RunAudio(void *audiop) started++; #endif } - + } /* Wait for the audio to drain.. */ if ( audio->WaitDone ) { @@ -565,7 +565,6 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) audio->paused = 1; #ifndef SDL_AUDIO_DRIVER_AHI - D(bug("AHI OpenAudio\n")); /* AmigaOS opens audio inside the main loop */ audio->opened = audio->OpenAudio(audio, &audio->spec)+1; diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 08caf631b..8154efd80 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -27,7 +27,7 @@ #include "SDL_mutex.h" #include "SDL_thread.h" -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) #include #include #if defined(__SASC) || defined(WARPOS) @@ -45,8 +45,8 @@ #ifdef SDL_AUDIO_DRIVER_AHI #include #endif +#include "SDL_os3debug.h" #endif -#include "mydebug.h" /* The SDL audio driver */ typedef struct SDL_AudioDevice SDL_AudioDevice; diff --git a/src/audio/amigaos/SDL_ahiaudio.h b/src/audio/amigaos/SDL_ahiaudio.h index b3c286e9f..01fe34534 100644 --- a/src/audio/amigaos/SDL_ahiaudio.h +++ b/src/audio/amigaos/SDL_ahiaudio.h @@ -45,7 +45,7 @@ #include #include -#include "mydebug.h" +#include "SDL_os3debug.h" #include "../SDL_sysaudio.h" diff --git a/src/joystick/amigaos/SDL_sysjoystick.c b/src/joystick/amigaos/SDL_sysjoystick.c index 43f527933..8642b6f7e 100644 --- a/src/joystick/amigaos/SDL_sysjoystick.c +++ b/src/joystick/amigaos/SDL_sysjoystick.c @@ -43,7 +43,7 @@ #include #endif #endif -#include "mydebug.h" +#include "SDL_os3debug.h" extern struct ExecBase *SysBase; extern struct GfxBase *GfxBase; diff --git a/src/main/amigaos/SDL_amigasas.c b/src/main/amigaos/SDL_amigasas.c index 7a39fd68e..3c5886209 100644 --- a/src/main/amigaos/SDL_amigasas.c +++ b/src/main/amigaos/SDL_amigasas.c @@ -7,7 +7,7 @@ #include #include -#include "../../../mydebug.h" +#include "SDL_os3debug.h" /******************************************************************************/ /* */ diff --git a/src/main/amigaos/SDL_amigastub.c b/src/main/amigaos/SDL_amigastub.c index 4903b7852..0f6c83721 100644 --- a/src/main/amigaos/SDL_amigastub.c +++ b/src/main/amigaos/SDL_amigastub.c @@ -10,7 +10,7 @@ #include #include #include "stabs.h" -#include "../../../mydebug.h" +#include "SDL_os3debug.h" /******************************************************************************/ /* */ diff --git a/mydebug.h b/src/main/amigaos/SDL_os3debug.h similarity index 100% rename from mydebug.h rename to src/main/amigaos/SDL_os3debug.h diff --git a/src/thread/amigaos/SDL_systhread.c b/src/thread/amigaos/SDL_systhread.c index 394dc5be0..6658acba8 100644 --- a/src/thread/amigaos/SDL_systhread.c +++ b/src/thread/amigaos/SDL_systhread.c @@ -31,7 +31,7 @@ #include "SDL_thread.h" #include "SDL_thread_c.h" #include "SDL_systhread.h" -#include "mydebug.h" +#include "SDL_os3debug.h" #ifdef APOLLO_BLIT #include "apolloammxenable.h" diff --git a/src/thread/amigaos/SDL_systhread_c.h b/src/thread/amigaos/SDL_systhread_c.h index b20018c26..98d72d61c 100644 --- a/src/thread/amigaos/SDL_systhread_c.h +++ b/src/thread/amigaos/SDL_systhread_c.h @@ -49,7 +49,7 @@ #endif #include -#include "../../../mydebug.h" +#include "src/main/amigaos/SDL_os3debug.h" extern struct ExecBase *SysBase; extern struct DosLibrary *DOSBase; diff --git a/src/timer/amigaos/SDL_systimer.c b/src/timer/amigaos/SDL_systimer.c index 7c6191ac3..10b74c6fe 100644 --- a/src/timer/amigaos/SDL_systimer.c +++ b/src/timer/amigaos/SDL_systimer.c @@ -48,7 +48,7 @@ #endif -#include "../../mydebug.h" +#include "SDL_os3debug.h" #include "SDL_error.h" #include "SDL_timer.h" diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 2c93bc89e..c9b3b1b22 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -31,11 +31,11 @@ #include "../events/SDL_sysevents.h" #include "../events/SDL_events_c.h" -#ifdef __AMIGA__ +#if defined(APOLLO_BLIT) #include #include -#include "../mydebug.h" +#include "SDL_os3debug.h" extern struct ExecBase *SysBase; short ac68080 = 0; @@ -179,7 +179,7 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { int i; SDL_PixelFormat vformat; Uint32 video_flags; -#ifdef __AMIGA__ +#if defined(APOLLO_BLIT) ac68080 = is_vampire(); #endif /* Toggle the event thread flags, based on OS requirements */ @@ -468,7 +468,6 @@ static int SDL_GetVideoMode(int *w, int *h, int *BitsPerPixel, Uint32 flags) { /* Try the original video mode, get the closest depth */ native_bpp = SDL_VideoModeOK(*w, *h, *BitsPerPixel, flags); - D(bug("screen depth %ld\n", native_bpp)); if ( native_bpp == *BitsPerPixel ) { return (1); @@ -730,8 +729,6 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { */ SDL_VideoSurface = (mode != NULL) ? mode : prev_mode; - D(bug("surface depth of SDL_VideoSurface %ld \n", SDL_VideoSurface->format->BitsPerPixel)); - if ( (mode != NULL) && (!is_opengl) ) { /* Sanity check */ if ( (mode->w < width) || (mode->h < height) ) { @@ -925,7 +922,6 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { (SDL_VideoSurface->flags & SDL_HWSURFACE) && !(SDL_VideoSurface->flags & SDL_DOUBLEBUF)) )) { - D(bug("Create Shadow surface\n")); SDL_CreateShadowSurface(bpp); //mode->format->BitsPerPixel); @@ -935,14 +931,13 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { } SDL_PublicSurface = SDL_ShadowSurface; } else { - D(bug("Using no Shadowsurface \n")); SDL_PublicSurface = SDL_VideoSurface; } video->info.vfmt = SDL_VideoSurface->format; video->info.current_w = SDL_VideoSurface->w; video->info.current_h = SDL_VideoSurface->h; -#ifdef __AMIGA__ +#if defined(__AMIGA__) && defined(APOLLO_BLIT) if (!(flags&SDL_FULLSCREEN)) ac68080 = 0; #endif @@ -1196,7 +1191,7 @@ int SDL_Flip(SDL_Surface *screen) return(0); } -#ifdef __AMIGA__ +#if defined(__AMIGA__) && defined(APOLLO_BLIT) int SDL_Flip(SDL_Surface *screen) { if ( ac68080 ) { old_buffer = screen->pixels; diff --git a/src/video/cybergfx/SDL_cgximage.c b/src/video/cybergfx/SDL_cgximage.c index 8be24a0b2..c5a7887ee 100644 --- a/src/video/cybergfx/SDL_cgximage.c +++ b/src/video/cybergfx/SDL_cgximage.c @@ -41,7 +41,7 @@ #define RECTFMT_RAW (5UL) #endif -#include "mydebug.h" +#include "SDL_os3debug.h" // this is an undocumented feature of CGX, and recently of AROS // and P96, if it's not defined let define it ourselves. diff --git a/src/video/cybergfx/SDL_cgxmodes.c b/src/video/cybergfx/SDL_cgxmodes.c index 1b230001d..7cf3540ff 100644 --- a/src/video/cybergfx/SDL_cgxmodes.c +++ b/src/video/cybergfx/SDL_cgxmodes.c @@ -35,7 +35,7 @@ #include "SDL_cgxwm_c.h" #include "SDL_cgxmodes_c.h" -#include "mydebug.h" +#include "SDL_os3debug.h" #ifdef AROS #include "SDL_cgximage_c.h" diff --git a/src/video/cybergfx/SDL_cgxvideo.c b/src/video/cybergfx/SDL_cgxvideo.c index aafc8a2db..1fc2c6f0b 100644 --- a/src/video/cybergfx/SDL_cgxvideo.c +++ b/src/video/cybergfx/SDL_cgxvideo.c @@ -66,7 +66,7 @@ #include #endif -#include "mydebug.h" +#include "SDL_os3debug.h" #ifdef __cplusplus extern "C" { diff --git a/src/video/cybergfx/SDL_cgxvideo.h b/src/video/cybergfx/SDL_cgxvideo.h index 88f492109..674ce633a 100644 --- a/src/video/cybergfx/SDL_cgxvideo.h +++ b/src/video/cybergfx/SDL_cgxvideo.h @@ -64,7 +64,7 @@ #include "SDL_mouse.h" #include "../SDL_sysvideo.h" -#include "mydebug.h" +#include "SDL_os3debug.h" #define USE_CGX_WRITELUTPIXEL From 64ba3236be325f23e21a34bf55d1bd932939f333 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 18:18:27 +0100 Subject: [PATCH 07/21] Remove old conflicting ExecBase, OS4 version now compiles --- src/audio/SDL_sysaudio.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index 8154efd80..f7235637f 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -213,8 +213,4 @@ extern AudioBootStrap AmigaOS4_bootstrap; /* This is the current audio device */ extern SDL_AudioDevice *current_audio; -#if !defined(__SASC) && !defined(WARPOS) -extern struct ExecBase *SysBase; -#endif - #endif /* _SDL_sysaudio_h */ From d38b3f9199a30a76d0a1e0be44f5d84ac872ad99 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 18:41:18 +0100 Subject: [PATCH 08/21] OS4 build should now build with makefile again --- include/SDL_stdinc.h | 6 +++--- makefile.amigaos4 | 8 ++++---- src/SDL.c | 1 - src/audio/SDL_sysaudio.h | 2 ++ test/alphablit.c | 2 +- test/doublebuffer.c | 10 +++++----- test/toggling.c | 8 ++++---- 7 files changed, 19 insertions(+), 18 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index b1954ca52..62ed631e9 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -37,9 +37,9 @@ #include #endif #if defined(STDC_HEADERS) -#include -#include -#include +# include +# include +# include #else # if defined(HAVE_STDLIB_H) # include diff --git a/makefile.amigaos4 b/makefile.amigaos4 index 35535acac..4370dda75 100644 --- a/makefile.amigaos4 +++ b/makefile.amigaos4 @@ -17,16 +17,16 @@ SHELL = /bin/sh CC = ppc-amigaos-gcc -INCLUDE = -I./include +INCLUDE = -I./include -Iamiga/makefile-support CFLAGS = -gstabs -O2 -Wall -LDFLAGS = +LDFLAGS = AR = ppc-amigaos-ar RANLIB = ppc-amigaos-ranlib PIC_CFLAGS = -fPIC -DPIC DEBUG_CFLAGS = -DDEBUG AMIGADATE = $(shell date +"%-d.%-m.%Y") -### Sources and objects files, build directories ### +###�Sources and objects files, build directories ### SOURCES = $(wildcard src/*.c src/audio/*.c src/cdrom/*.c src/cpuinfo/*.c src/events/*.c src/file/*.c src/stdlib/*.c \ src/video/*.c src/joystick/*.c src/video/dummy/*.c src/audio/disk/*.c src/audio/dummy/*.c src/video/amigaos4/*.c src/audio/amigaos4/*.c \ @@ -51,7 +51,7 @@ SHARED_TESTS := $(patsubst %.c,%, $(addprefix $(SHARED_OBJDIR)/,$(TESTS_SOURCES) $(STATIC_OBJDIR)/%.o: %.c @mkdir -p $(dir $@) - $(CC) $(INCLUDE) $(CFLAGS) $(DEBUG_CFLAGS) -o $@ -c $< + $(CC) $(INCLUDE) $(CFLAGS) $(DEBUG_CFLAGS) -D__AMIGADATE__=\"$(AMIGADATE)\" -o $@ -c $< $(STATIC_OBJDIR)/test/%: $(STATIC_OBJDIR)/test/%.o @echo Link test $@ diff --git a/src/SDL.c b/src/SDL.c index 7e4caaee6..16220b2a0 100644 --- a/src/SDL.c +++ b/src/SDL.c @@ -28,7 +28,6 @@ #if !SDL_VIDEO_DISABLED #include "video/SDL_leaks.h" #endif -#include "SDL_os3debug.h" #if SDL_THREAD_PTH #include diff --git a/src/audio/SDL_sysaudio.h b/src/audio/SDL_sysaudio.h index f7235637f..b26d29f2c 100644 --- a/src/audio/SDL_sysaudio.h +++ b/src/audio/SDL_sysaudio.h @@ -46,6 +46,8 @@ #include #endif #include "SDL_os3debug.h" + +extern struct ExecBase *SysBase; #endif /* The SDL audio driver */ diff --git a/test/alphablit.c b/test/alphablit.c index c2a1f33b4..0755c8321 100644 --- a/test/alphablit.c +++ b/test/alphablit.c @@ -4,7 +4,7 @@ gcc alphablit.c -Isdk:local/common/include/SDL -use-dynld -lSDL -lauto -g -Wall */ -#include "SDL/SDL.h" +#include "SDL.h" #include #ifdef __amigaos4__ diff --git a/test/doublebuffer.c b/test/doublebuffer.c index fd550a4c7..3e1da75d3 100755 --- a/test/doublebuffer.c +++ b/test/doublebuffer.c @@ -1,4 +1,4 @@ -#include "SDL/SDL.h" +#include "SDL.h" #include static SDL_Surface *screen; @@ -32,9 +32,9 @@ static void draw(Uint32 t) r.y = 0; r.w = width; r.h = height; - + SDL_FillRect(screen, &r, black); - + r.y = height / 2; r.h = height / 2; @@ -59,10 +59,10 @@ int main(void) screen = SDL_SetVideoMode(width, height, depth, flags); draw(time); - + SDL_SetVideoMode(100, 100, 32, 0); - puts("Testing double-buffer HW surface - expecting NO flickering"); + puts("Testing double-buffer HW surface - expecting NO flickering"); countdown(3); screen = SDL_SetVideoMode(width, height, depth, flags | SDL_DOUBLEBUF); diff --git a/test/toggling.c b/test/toggling.c index e60d463a1..15bfca172 100755 --- a/test/toggling.c +++ b/test/toggling.c @@ -1,4 +1,4 @@ -#include "SDL/SDL.h" +#include "SDL.h" #include static SDL_Surface *screen; @@ -16,7 +16,7 @@ static void draw(Uint32 t, SDL_Surface *s) SDL_Rect r; r.x = rand() % width; r.y = rand() % height; - + SDL_BlitSurface(s, NULL, screen, &r); SDL_Flip(screen); @@ -63,8 +63,8 @@ int main(void) screen = SDL_SetVideoMode(width, height, depth, flags | SDL_FULLSCREEN); SDL_Surface *s = makeSurface(); - - draw(time, s); + + draw(time, s); #if 1 screen = SDL_SetVideoMode(width, height, depth, flags); From ad2cd1c1b2f1227e8f30764fb720fceef2b735f0 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 18:54:07 +0100 Subject: [PATCH 09/21] Delete SDL_main.h --- src/main/amigaos/SDL_main.h | 114 ------------------------------------ 1 file changed, 114 deletions(-) delete mode 100644 src/main/amigaos/SDL_main.h diff --git a/src/main/amigaos/SDL_main.h b/src/main/amigaos/SDL_main.h deleted file mode 100644 index ad6468ded..000000000 --- a/src/main/amigaos/SDL_main.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - include - Simple DirectMedia Layer - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Include the include main definition header */ - - -#ifdef SAVE_RCSID -static char rcsid = - "@(#) $Id: SDL_main.h,v 1.3 2003/09/07 17:09:23 gabry Exp $"; -#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(_WIN32) || \ - (defined(__MWERKS__) && !defined(__BEOS__)) || \ - defined(macintosh) || defined(__APPLE__) || \ - defined(__SYMBIAN32__) || defined(QWS) - -#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 include 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 void SDLCALL SDL_SetModuleHandle(void *hInst); -* This can also be called, but is no longer necessary */ -extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); - -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif - -* From the include 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 SDLCALL SDL_InitQuickDraw(struct QDGlobals *the_qd); - -#ifdef __cplusplus -} -#endif -#include "close_code.h" -#endif - -#endif /* Need to redefine main()? */ - -#endif /* _SDL_main_h */ From fe16bbf71df5225c556be6eed8f23a2650f0579d Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 19:00:03 +0100 Subject: [PATCH 10/21] Apply suggestions from code review --- include/SDL_stdinc.h | 2 +- src/main/amigaos/SDL_amigasas.c | 4 ++-- src/main/amigaos/SDL_amigasas2.c | 6 +++--- src/main/amigaos/SDL_amigastub.c | 11 ++++++----- src/thread/amigaos/SDL_systhread_c.h | 3 +-- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h index 62ed631e9..0df464784 100644 --- a/include/SDL_stdinc.h +++ b/include/SDL_stdinc.h @@ -588,7 +588,7 @@ extern DECLSPEC int SDLCALL SDL_vsnprintf(char *text, size_t maxlen, const char #endif /** @name SDL_ICONV Error Codes - * The SDL implementation of iconv() returns these error codes + * The SDL implementation of iconv() returns these error codes */ /*@{*/ #define SDL_ICONV_ERROR (size_t)-1 diff --git a/src/main/amigaos/SDL_amigasas.c b/src/main/amigaos/SDL_amigasas.c index 3c5886209..c93d5d9f2 100644 --- a/src/main/amigaos/SDL_amigasas.c +++ b/src/main/amigaos/SDL_amigasas.c @@ -60,7 +60,7 @@ __UserLibInit(register __a6 struct Library *libbase) { void __saveds __asm __UserLibCleanup(register __a6 struct Library *myLib) { - D(bug("***include.library cleanup\n")); + D(bug("***SDL.library cleanup\n")); CloseLibrary(UtilityBase); CloseLibrary((struct Library *)DOSBase); } @@ -172,7 +172,7 @@ ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2) // ADDTABL_END() void _XCEXIT(void) { - D(bug("Warning include.library attempted exit, sleeping forever!\n")); + D(bug("Warning SDL.library attempted exit, sleeping forever!\n")); Wait(0); // resto in wait forever } diff --git a/src/main/amigaos/SDL_amigasas2.c b/src/main/amigaos/SDL_amigasas2.c index 9ebcc6764..97b78f347 100644 --- a/src/main/amigaos/SDL_amigasas2.c +++ b/src/main/amigaos/SDL_amigasas2.c @@ -33,7 +33,7 @@ __UserLibInit(register __a6 struct Library *libbase) { /* required !!! */ SysBase = *(struct ExecBase **)4; - D(bug("***include.library init: %lx\n", libbase)); + D(bug("***SDL.library init: %lx\n", libbase)); if ( !(DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 39L))) { D(bug("unable to open dos.library\n")); @@ -60,7 +60,7 @@ __UserLibInit(register __a6 struct Library *libbase) { void __saveds __asm __UserLibCleanup(register __a6 struct Library *myLib) { - D(bug("***include.library cleanup\n")); + D(bug("***SDL.library cleanup\n")); CloseLibrary(UtilityBase); CloseLibrary((struct Library *)DOSBase); } @@ -149,7 +149,7 @@ ADDTABL_4(SDL_PeepEvents, a0, d0, d1, d2) // ADDTABL_END() void _XCEXIT(void) { - D(bug("Warning include.library attempted exit, sleeping forever!\n")); + D(bug("Warning SDL.library attempted exit, sleeping forever!\n")); Wait(0); // resto in wait forever } diff --git a/src/main/amigaos/SDL_amigastub.c b/src/main/amigaos/SDL_amigastub.c index 0f6c83721..038f2bda8 100644 --- a/src/main/amigaos/SDL_amigastub.c +++ b/src/main/amigaos/SDL_amigastub.c @@ -8,9 +8,10 @@ #include #include #include -#include +#include #include "stabs.h" #include "SDL_os3debug.h" +#include "SDL_version.h" /******************************************************************************/ /* */ @@ -18,11 +19,11 @@ /* */ /******************************************************************************/ -const BYTE LibName[] = "include.library"; +const BYTE LibName[] = "SDL.library"; #include "SDL_amigaversion.h" -const UWORD LibVersion = 12; -const UWORD LibRevision = 6; +const UWORD LibVersion = SDL_MAJOR_VERSION "" SDL_MINOR_VERSION; +const UWORD LibRevision = SDL_PATCHLEVEL; /******************************************************************************/ /* */ @@ -109,7 +110,7 @@ int __UserLibInit(struct Library *myLib) { /******************************************************************************/ void __UserLibCleanup() { - D(bug("***include.library cleanup\n")); + D(bug("***SDL.library cleanup\n")); __exitmalloc(); __exitstdio(); diff --git a/src/thread/amigaos/SDL_systhread_c.h b/src/thread/amigaos/SDL_systhread_c.h index 98d72d61c..1a5696d5b 100644 --- a/src/thread/amigaos/SDL_systhread_c.h +++ b/src/thread/amigaos/SDL_systhread_c.h @@ -49,7 +49,7 @@ #endif #include -#include "src/main/amigaos/SDL_os3debug.h" +#include "SDL_os3debug.h" extern struct ExecBase *SysBase; extern struct DosLibrary *DOSBase; @@ -75,4 +75,3 @@ extern struct DosLibrary *DOSBase; #define SYS_ThreadHandle struct Task * #endif /* WARPOS */ - From 9a0ce1afd77e47598b075cad660fccf0c26df097 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Mon, 17 Feb 2020 19:11:37 +0100 Subject: [PATCH 11/21] Re-enable OpenGL for AmigaOS4 Add dummy cdrom driver --- CMakeLists.txt | 1 + include/SDL_config_amiga.h | 5 ++++- include/SDL_config_amigaos4.h | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 325a58731..3a1a6f506 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -159,6 +159,7 @@ if(AMIGA) ${PROJECT_SOURCE_DIR}/src/main/amigaos/SDL_lutstub.s # CDROM + ${PROJECT_SOURCE_DIR}/src/cdrom/dummy/SDL_syscdrom.c #${PROJECT_SOURCE_DIR}/src/cdrom/amigaos/SDL_syscdrom.c # AUDIO diff --git a/include/SDL_config_amiga.h b/include/SDL_config_amiga.h index bdac4ffd4..8ac6b14b6 100644 --- a/include/SDL_config_amiga.h +++ b/include/SDL_config_amiga.h @@ -154,8 +154,9 @@ typedef unsigned long long uint64_t; //#define SDL_AUDIO_DRIVER_DUMMY 1 /* Enable various cdrom drivers */ -#define SDL_CDROM_DISABLED 1 +//#define SDL_CDROM_DISABLED 1 //#define SDL_CDROM_AMIGA 1 +#define SDL_CDROM_DUMMY 1 /* Enable various input drivers */ #define SDL_JOYSTICK_AMIGA 1 @@ -179,7 +180,9 @@ typedef unsigned long long uint64_t; /* Enable assembly routines where available */ #define SDL_ASSEMBLY_ROUTINES 1 + #define SDL_AMIGA_NOWINDOW 0x10000 + #ifdef __cplusplus extern "C" { #endif diff --git a/include/SDL_config_amigaos4.h b/include/SDL_config_amigaos4.h index 28e542824..a21b2aef3 100644 --- a/include/SDL_config_amigaos4.h +++ b/include/SDL_config_amigaos4.h @@ -297,7 +297,7 @@ /* #undef SDL_VIDEO_DRIVER_XBIOS */ /* Enable OpenGL support */ -//#define SDL_VIDEO_OPENGL 1 +#define SDL_VIDEO_OPENGL 1 /* #undef SDL_VIDEO_OPENGL_GLX */ /* #undef SDL_VIDEO_OPENGL_WGL */ /* #undef SDL_VIDEO_OPENGL_OSMESA */ From a72e4d9d3c91ad3ab1ede3ab5d15814199eda87f Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Tue, 18 Feb 2020 16:22:54 +0100 Subject: [PATCH 12/21] Add support for shared libs, as AmigaOS4 supports them --- CMakeLists.txt | 112 ++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a1a6f506..444889265 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,9 @@ set(CPACK_PACKAGE_VERSION_PATCH ${SDL_PATCHLEVEL}) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "SDL1.2") include(CPack) +# SET COMPILE TARGETS +set(LIB_TARGET "STATIC") + # Generate version header from the above configure_file( ${PROJECT_SOURCE_DIR}/include/SDL_version.h.in @@ -147,10 +150,29 @@ set(SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_malloc.c ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_qsort.c ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_stdlib.c - ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c - - - ) + ${PROJECT_SOURCE_DIR}/src/stdlib/SDL_string.c) + +set(INCLUDE_PATHS + ${PROJECT_SOURCE_DIR}/ + ${PROJECT_SOURCE_DIR}/include + ${PROJECT_BINARY_DIR}/include + ${PROJECT_SOURCE_DIR}/include-GL + ${PROJECT_SOURCE_DIR}/src/audio + ${PROJECT_SOURCE_DIR}/src/audio/dummy + ${PROJECT_SOURCE_DIR}/src/audio/disk + ${PROJECT_SOURCE_DIR}/src/audio/amigaos + ${PROJECT_SOURCE_DIR}/src/events + ${PROJECT_SOURCE_DIR}/src/joystick + ${PROJECT_SOURCE_DIR}/src/main/amigaos + ${PROJECT_SOURCE_DIR}/src/thread + ${PROJECT_SOURCE_DIR}/src/thread/amigaos + ${PROJECT_SOURCE_DIR}/src/thread/pth + ${PROJECT_SOURCE_DIR}/src/thread/pthread + ${PROJECT_SOURCE_DIR}/src/timer + ${PROJECT_SOURCE_DIR}/src/video + ${PROJECT_SOURCE_DIR}/src/video/cybergfx + ${PROJECT_SOURCE_DIR}/src/video/apollo + ${PROJECT_SOURCE_DIR}/src/video/dummy) if(AMIGA) if(AMIGAOS3) @@ -194,6 +216,8 @@ if(AMIGA) ${PROJECT_SOURCE_DIR}/src/loadso/dummy/SDL_sysloadso.c ) elseif(AMIGAOS4) + set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS TRUE) + list(APPEND LIB_TARGET "SHARED") list(APPEND SOURCE_FILES # MAIN ${PROJECT_SOURCE_DIR}/src/main/amigaos4/SDL_os4timer.c @@ -232,59 +256,40 @@ if(AMIGA) endif() endif() -add_library(${LIBNAME} - STATIC - ${SOURCE_FILES}) - -target_include_directories(${LIBNAME} - PRIVATE - ${PROJECT_SOURCE_DIR}/ - ${PROJECT_SOURCE_DIR}/include - ${PROJECT_BINARY_DIR}/include - ${PROJECT_SOURCE_DIR}/include-GL - ${PROJECT_SOURCE_DIR}/src/audio - ${PROJECT_SOURCE_DIR}/src/audio/dummy - ${PROJECT_SOURCE_DIR}/src/audio/disk - ${PROJECT_SOURCE_DIR}/src/audio/amigaos - ${PROJECT_SOURCE_DIR}/src/events - ${PROJECT_SOURCE_DIR}/src/joystick - ${PROJECT_SOURCE_DIR}/src/main/amigaos - ${PROJECT_SOURCE_DIR}/src/thread - ${PROJECT_SOURCE_DIR}/src/thread/amigaos - ${PROJECT_SOURCE_DIR}/src/thread/pth - ${PROJECT_SOURCE_DIR}/src/thread/pthread - ${PROJECT_SOURCE_DIR}/src/timer - ${PROJECT_SOURCE_DIR}/src/video - ${PROJECT_SOURCE_DIR}/src/video/cybergfx - ${PROJECT_SOURCE_DIR}/src/video/apollo - ${PROJECT_SOURCE_DIR}/src/video/dummy) - -target_compile_definitions(${LIBNAME} PRIVATE $<$:NOIXEMUL _HAVE_STDINT_H>) - -if(NOT DEBUG) - target_compile_options(${LIBNAME} PUBLIC $<$:-O3 -ffast-math>) -endif() +foreach(target ${LIB_TARGET}) + add_library(${target} + ${target} + ${SOURCE_FILES}) + target_include_directories(${target} + PRIVATE + ${INCLUDE_PATHS}) + set_target_properties(${target} PROPERTIES OUTPUT_NAME ${LIBNAME}) + + target_compile_definitions(${target} PRIVATE $<$:NOIXEMUL _HAVE_STDINT_H>) -if(AMIGA) if(NOT DEBUG) - target_compile_definitions(${LIBNAME} PRIVATE $<$:NO_AMIGADEBUG>) + target_compile_options(${target} PUBLIC $<$:-O3 -ffast-math>) endif() - if(APOLLOBLIT AND AMIGAOS3) - target_compile_definitions(${LIBNAME} PRIVATE $<$:APOLLO_BLIT>) - target_compile_options(${LIBNAME} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include) - target_include_directories(${LIBNAME} PUBLIC video/apollo) - enable_language(ASM-VASM) - target_sources(${LIBNAME} - PRIVATE - # APOLLO AMMX - src/video/apollo/blitapollo.asm - src/video/apollo/apolloammxenable.asm - src/video/apollo/colorkeyapollo.asm) - + if(AMIGA) + if(NOT DEBUG) + target_compile_definitions(${target} PRIVATE $<$:NO_AMIGADEBUG>) + endif() + + if(APOLLOBLIT AND AMIGAOS3) + target_compile_definitions(${target} PRIVATE $<$:APOLLO_BLIT>) + target_compile_options(${target} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include) + target_include_directories(${target} PUBLIC video/apollo) + enable_language(ASM-VASM) + target_sources(${target} + PRIVATE + # APOLLO AMMX + src/video/apollo/blitapollo.asm + src/video/apollo/apolloammxenable.asm + src/video/apollo/colorkeyapollo.asm) + endif() endif() -endif() - +endforeach(target) file(GLOB INCLUDE_FILES ${PROJECT_SOURCE_DIR}/include/*.h) file(GLOB BIN_INCLUDE_FILES ${PROJECT_BINARY_DIR}/include/*.h) @@ -293,6 +298,9 @@ list(APPEND INCLUDE_FILES ${BIN_INCLUDE_FILES}) file(GLOB GL_INCLUDE_FILES include-GL/*.h) install(FILES ${PROJECT_BINARY_DIR}/libSDL.a DESTINATION "lib${LIB_SUFFIX}") + +install(FILES ${PROJECT_BINARY_DIR}/libSDL.so DESTINATION "lib${LIB_SUFFIX}") + install(FILES ${INCLUDE_FILES} DESTINATION include/SDL) install(FILES ${GL_INCLUDE_FILES} DESTINATION include/GL) From 4ab302cfc8081a98c8f41340367982c9c001087a Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Wed, 19 Feb 2020 01:14:40 +0100 Subject: [PATCH 13/21] Only install shared object if SHARED is built --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 444889265..897daa590 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -299,7 +299,9 @@ file(GLOB GL_INCLUDE_FILES include-GL/*.h) install(FILES ${PROJECT_BINARY_DIR}/libSDL.a DESTINATION "lib${LIB_SUFFIX}") -install(FILES ${PROJECT_BINARY_DIR}/libSDL.so DESTINATION "lib${LIB_SUFFIX}") +if("SHARED" IN_LIST LIB_TARGET) + install(FILES ${PROJECT_BINARY_DIR}/libSDL.so DESTINATION "lib${LIB_SUFFIX}") +endif() install(FILES ${INCLUDE_FILES} DESTINATION include/SDL) install(FILES ${GL_INCLUDE_FILES} DESTINATION include/GL) @@ -308,7 +310,6 @@ install(FILES README README-SDL.txt README.AmigaOS - LICENSE CREDITS COPYING BUGS From a139e60a00faf6233844963672335c7edfa9b59f Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Wed, 19 Feb 2020 17:06:27 +0100 Subject: [PATCH 14/21] Remove Vampire SDL_flip hack --- src/video/SDL_video.c | 42 +----------------------------------------- 1 file changed, 1 insertion(+), 41 deletions(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index c9b3b1b22..7db7d38d1 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -31,24 +31,6 @@ #include "../events/SDL_sysevents.h" #include "../events/SDL_events_c.h" -#if defined(APOLLO_BLIT) -#include -#include - -#include "SDL_os3debug.h" - -extern struct ExecBase *SysBase; -short ac68080 = 0; -void *old_buffer; - -static int is_vampire() { - if ( SysBase->AttnFlags & (1 << 10)) { - printf("Vampire accelerator detected, using SAGA Direct Draw\n"); - return 1; - } else - return 0; -} -#endif /* Available video drivers */ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_QUARTZ @@ -179,9 +161,7 @@ int SDL_VideoInit(const char *driver_name, Uint32 flags) { int i; SDL_PixelFormat vformat; Uint32 video_flags; -#if defined(APOLLO_BLIT) - ac68080 = is_vampire(); -#endif + /* Toggle the event thread flags, based on OS requirements */ #if defined(MUST_THREAD_EVENTS) flags |= SDL_INIT_EVENTTHREAD; @@ -937,10 +917,6 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { video->info.current_w = SDL_VideoSurface->w; video->info.current_h = SDL_VideoSurface->h; -#if defined(__AMIGA__) && defined(APOLLO_BLIT) - if (!(flags&SDL_FULLSCREEN)) - ac68080 = 0; -#endif /* We're done! */ return(SDL_PublicSurface); } @@ -1123,11 +1099,7 @@ void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { /* * Performs hardware double buffering, if possible, or a full update if not. */ -#if defined(__AMIGA__) -int SDL_Flip_m68k(SDL_Surface *screen) -#else int SDL_Flip(SDL_Surface *screen) -#endif { #ifdef __AMIGA__ extern int skipframe,toggle; @@ -1191,18 +1163,6 @@ int SDL_Flip(SDL_Surface *screen) return(0); } -#if defined(__AMIGA__) && defined(APOLLO_BLIT) -int SDL_Flip(SDL_Surface *screen) { - if ( ac68080 ) { - old_buffer = screen->pixels; - screen->pixels = (void *)(~31 & (31 + (Uint32)old_buffer)); - *(volatile Uint32 *)0xDFF1EC = (Uint32)screen->pixels; - return (0); - } else - return SDL_Flip_m68k(screen); -} -#endif - static void SetPalette_logical(SDL_Surface *screen, SDL_Color *colors, int firstcolor, int ncolors) { SDL_Palette *pal = screen->format->palette; SDL_Palette *vidpal; From 62baa83ede89d25c69d4ca7ac0230eef6a4cd0ca Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sat, 22 Feb 2020 16:08:41 +0100 Subject: [PATCH 15/21] Update src/video/SDL_video.c Co-Authored-By: capehill --- src/video/SDL_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 7db7d38d1..04a455b9f 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -589,7 +589,7 @@ SDL_Surface *SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { sysevents_mouse_pressed = 0; #endif -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) #ifndef APOLLO_BLIT flags &= ~SDL_DOUBLEBUF; #endif From 55f1a21bcec30b4c91137fded5c297c6dc89033e Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sat, 22 Feb 2020 16:14:48 +0100 Subject: [PATCH 16/21] Apply suggestions from code review Co-Authored-By: capehill --- src/video/SDL_surface.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c index a4925645b..39859f9f2 100644 --- a/src/video/SDL_surface.c +++ b/src/video/SDL_surface.c @@ -425,7 +425,7 @@ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, SDL_blit do_blit; SDL_Rect hw_srcrect; SDL_Rect hw_dstrect; -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) int skipflag = 0; /* applies to software blitting only */ @@ -450,7 +450,7 @@ int SDL_LowerBlit (SDL_Surface *src, SDL_Rect *srcrect, return(-1); } } -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) } #endif @@ -481,7 +481,7 @@ int SDL_UpperBlit (SDL_Surface *src, SDL_Rect *srcrect, { SDL_Rect fulldst; int srcx, srcy, w, h; -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) extern int toggle,skipframe; #endif /* Make sure the surfaces aren't locked */ From 4a54350be481000237bae88f31534e6409d023cc Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sat, 22 Feb 2020 16:16:31 +0100 Subject: [PATCH 17/21] Update src/video/SDL_video.c --- src/video/SDL_video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/video/SDL_video.c b/src/video/SDL_video.c index 04a455b9f..35e66c3bb 100644 --- a/src/video/SDL_video.c +++ b/src/video/SDL_video.c @@ -1101,7 +1101,7 @@ void SDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { */ int SDL_Flip(SDL_Surface *screen) { -#ifdef __AMIGA__ +#if defined(__AMIGA__) && !defined(__amigaos4__) extern int skipframe,toggle; if (skipframe) { From dcb3a4b84223b55366238d17106fe3f75a035113 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sat, 30 May 2020 00:14:06 +0200 Subject: [PATCH 18/21] ASM-VASM is now ASM_VASM in updated OS3 toolchain --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 897daa590..928f75ef9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -280,7 +280,7 @@ foreach(target ${LIB_TARGET}) target_compile_definitions(${target} PRIVATE $<$:APOLLO_BLIT>) target_compile_options(${target} PRIVATE -I${CMAKE_SYSROOT}/m68k-amigaos/ndk-include) target_include_directories(${target} PUBLIC video/apollo) - enable_language(ASM-VASM) + enable_language(ASM_VASM) target_sources(${target} PRIVATE # APOLLO AMMX From 0d3f5e378c0a099ae5ee537478854896f0c73f12 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sun, 21 Jun 2020 18:07:24 +0200 Subject: [PATCH 19/21] Enable -Wall in CMake builds --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 928f75ef9..e0b5a5c02 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -268,7 +268,7 @@ foreach(target ${LIB_TARGET}) target_compile_definitions(${target} PRIVATE $<$:NOIXEMUL _HAVE_STDINT_H>) if(NOT DEBUG) - target_compile_options(${target} PUBLIC $<$:-O3 -ffast-math>) + target_compile_options(${target} PUBLIC $<$:-O3 -ffast-math -Wall>) endif() if(AMIGA) From c59f10275ca6d8b76f1570f91c4ef4df64bab051 Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sun, 21 Jun 2020 18:08:01 +0200 Subject: [PATCH 20/21] Backport OS4 AHI driver to OS3 --- src/audio/SDL_audio.c | 86 +---- src/audio/amigaos/SDL_ahiaudio.c | 551 +++++++++++++++++-------------- src/audio/amigaos/SDL_ahiaudio.h | 27 +- 3 files changed, 314 insertions(+), 350 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index f3970a5db..bb559a128 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -130,10 +130,6 @@ SDL_AudioDevice *current_audio = NULL; int SDL_AudioInit(const char *driver_name); void SDL_AudioQuit(void); -#if SDL_AUDIO_DRIVER_AHI -static int audio_configured = 0; -#endif - /* The general mixing thread function */ int SDLCALL SDL_RunAudio(void *audiop) { @@ -143,42 +139,17 @@ int SDLCALL SDL_RunAudio(void *audiop) void *udata; void (SDLCALL *fill)(void *userdata,Uint8 *stream, int len); int silence; -#if SDL_AUDIO_DRIVER_AHI - int started = 0; - -/* AmigaOS NEEDS that the audio driver is opened in the thread that uses it! */ - - D(bug("Task audio started audio struct:<%lx>...\n",audiop)); - - D(bug("Before Openaudio...")); - if(audio->OpenAudio(audio, &audio->spec)==-1) - { - D(bug("Open audio failed...\n")); - return(-1); - } - D(bug("OpenAudio...OK\n")); -#endif /* Perform any thread setup */ if ( audio->ThreadInit ) { audio->ThreadInit(audio); } audio->threadid = SDL_ThreadID(); -#if SDL_AUDIO_DRIVER_AHI - SetTaskPri(audio->threadid,11); -#endif + /* Set up the mixing function */ fill = audio->spec.callback; udata = audio->spec.userdata; -#if SDL_AUDIO_DRIVER_AHI - audio_configured = 1; - - D(bug("Audio configured... Checking for conversion\n")); - SDL_mutexP(audio->mixer_lock); - D(bug("Semaphore obtained...\n")); -#endif - if ( audio->convert.needed ) { if ( audio->convert.src_format == AUDIO_U8 ) { silence = 0x80; @@ -191,12 +162,6 @@ int SDLCALL SDL_RunAudio(void *audiop) stream_len = audio->spec.size; } -#if SDL_AUDIO_DRIVER_AHI - - SDL_mutexV(audio->mixer_lock); - D(bug("Entering audio loop...\n")); -#endif - #ifdef __OS2__ /* Increase the priority of this thread to make sure that the audio will be continuous all the time! */ @@ -221,16 +186,6 @@ int SDLCALL SDL_RunAudio(void *audiop) /* 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 SDL_AUDIO_DRIVER_AHI - if ( started > 1 ) -#endif - audio->WaitAudio(audio); - } - /* Fill the current buffer with sound */ if ( audio->convert.needed ) { if ( audio->convert.buf ) { @@ -267,10 +222,6 @@ int SDLCALL SDL_RunAudio(void *audiop) /* Ready current buffer for play and change current buffer */ if ( stream != audio->fake_stream ) { audio->PlayAudio(audio); -#if SDL_AUDIO_DRIVER_AHI -/* AmigaOS don't have to wait the first time audio is played! */ - started++; -#endif } } @@ -279,15 +230,6 @@ int SDLCALL SDL_RunAudio(void *audiop) audio->WaitDone(audio); } -#if SDL_AUDIO_DRIVER_AHI - D(bug("WaitAudio...Done\n")); - - audio->CloseAudio(audio); - - D(bug("CloseAudio..Done, subtask exiting...\n")); - audio_configured = 0; -#endif - #ifdef __OS2__ #ifdef DEBUG_BUILD printf("[SDL_RunAudio] : Task exiting. (TID%d)\n", SDL_ThreadID()); @@ -564,31 +506,12 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) audio->enabled = 1; audio->paused = 1; -#ifndef SDL_AUDIO_DRIVER_AHI - /* AmigaOS opens audio inside the main loop */ audio->opened = audio->OpenAudio(audio, &audio->spec)+1; if ( ! audio->opened ) { SDL_CloseAudio(); return(-1); } -#else - D(bug("Locking semaphore...")); - SDL_mutexP(audio->mixer_lock); - - audio->thread = SDL_CreateThread(SDL_RunAudio, audio); - D(bug("Created thread...\n")); - - if ( audio->thread == NULL ) { - SDL_mutexV(audio->mixer_lock); - SDL_CloseAudio(); - SDL_SetError("Couldn't create audio thread"); - return(-1); - } - - while(!audio_configured) - SDL_Delay(100); -#endif /* If the audio driver changes the buffer size, accept it */ if ( audio->spec.samples != desired->samples ) { @@ -632,7 +555,6 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) } } -#ifndef SDL_AUDIO_DRIVER_AHI /* Start the audio thread if necessary */ switch (audio->opened) { case 1: @@ -654,10 +576,6 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained) /* The audio is now playing */ break; } -#else - SDL_mutexV(audio->mixer_lock); - D(bug("SDL_OpenAudio USCITA...\n")); -#endif return(0); } @@ -731,12 +649,10 @@ void SDL_AudioQuit(void) SDL_FreeAudioMem(audio->convert.buf); } -#ifndef SDL_AUDIO_DRIVER_AHI if ( audio->opened ) { audio->CloseAudio(audio); audio->opened = 0; } -#endif /* Free the driver data */ audio->free(audio); current_audio = NULL; diff --git a/src/audio/amigaos/SDL_ahiaudio.c b/src/audio/amigaos/SDL_ahiaudio.c index 4c2ec1604..ba66f8d9d 100644 --- a/src/audio/amigaos/SDL_ahiaudio.c +++ b/src/audio/amigaos/SDL_ahiaudio.c @@ -24,8 +24,9 @@ /* Allow access to a raw mixing buffer (for AmigaOS) */ #include "SDL_endian.h" #include "SDL_audio.h" -#include "../SDL_audiomem.h" #include "../SDL_audio_c.h" +#include "../SDL_audiomem.h" +#include "../SDL_sysaudio.h" #include "SDL_ahiaudio.h" /* Audio driver init fuctions */ @@ -39,290 +40,330 @@ static int AHI_OpenAudio(SDL_AudioDevice *self, SDL_AudioSpec *spec); static void AHI_CloseAudio(SDL_AudioDevice *self); /* thread functions */ +static void AHI_ThreadInit(SDL_AudioDevice *self); +static void AHI_WaitDone(SDL_AudioDevice *self); static void AHI_WaitAudio(SDL_AudioDevice *self); static void AHI_PlayAudio(SDL_AudioDevice *self); static Uint8 *AHI_GetAudioBuf(SDL_AudioDevice *self); -/* Audio driver bootstrap functions */ -static int AHI_AudioAvailable(void) { - int ok = 0; - struct MsgPort *p; - struct AHIRequest *req; - - if ( p = CreateMsgPort() ) { - if ( req = (struct AHIRequest *)CreateIORequest(p, sizeof(struct AHIRequest))) { - req->ahir_Version = 4; - - if ( !OpenDevice(AHINAME, 0, (struct IORequest *)req, NULL) ) { - D(bug("AHI available.\n")); - ok = 1; - CloseDevice((struct IORequest *)req); - } - DeleteIORequest((struct IORequest *)req); - } - DeleteMsgPort(p); - } - - D(if ( !ok ) bug("AHI not available\n")); - return ok; -} - -static void AHI_DeleteDevice(SDL_AudioDevice *device) { - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_AudioDevice *AHI_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 ) { - SDL_memset(this, 0, sizeof(SDL_AudioDevice)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc(sizeof(struct SDL_PrivateAudioData)); - } - if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory(); - if ( this ) { - SDL_free(this); - } - return (0); - } - SDL_memset(this->hidden, 0, sizeof(struct SDL_PrivateAudioData)); - - /* 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 = AHI_DeleteDevice; - - return this; -} - +/* The tag name used by the AmigaOS audio driver */ #define DRIVER_NAME "amigaos" AudioBootStrap AHI_bootstrap = { - DRIVER_NAME,"AmigaOS3 AHI audio", - AHI_AudioAvailable, AHI_CreateDevice + DRIVER_NAME,"AmigaOS3 AHI audio", + AHI_AudioAvailable, AHI_CreateDevice }; -void static AHI_WaitAudio(SDL_AudioDevice *self) { - OS3AudioData * data = self->hidden; - - if ( !CheckIO((struct IORequest *)audio_req[current_buffer]) ) { - WaitIO((struct IORequest *)audio_req[current_buffer]); - //AbortIO((struct IORequest *)audio_req[current_buffer]); - } +/* ------------------------------------------ */ +/* Audio driver init functions implementation */ +/* ------------------------------------------ */ + +static int AHI_OpenAhiDevice(OS3AudioData *os3data) +{ + int ahi_open = 0; + + /* create our reply port */ + os3data->ahi_ReplyPort = (struct MsgPort*)CreateMsgPort(); + if (os3data->ahi_ReplyPort) + { + /* create a iorequest for the device */ + os3data->ahi_IORequest[0] = (struct AHIRequest*)CreateIORequest(os3data->ahi_ReplyPort, sizeof( struct AHIRequest )); + if (os3data->ahi_IORequest[0]) + { + /* open the device */ + os3data->ahi_IORequest[0]->ahir_Version = 4; + if (!OpenDevice(AHINAME, 0, (struct IORequest *)os3data->ahi_IORequest[0], 0)) + { + /* Create a copy */ + os3data->ahi_IORequest[1] = (struct AHIRequest *)CreateIORequest(os3data->ahi_ReplyPort, sizeof( struct AHIRequest )); + if (os3data->ahi_IORequest[1]) + { + CopyMem(os3data->ahi_IORequest[0], os3data->ahi_IORequest[1], sizeof(struct AHIRequest)); + + D(bug("AHI available.\n")); + ahi_open = 1; + os3data->currentBuffer = 0; + os3data->link = 0; + } + } + } + } + + return ahi_open; } -static void AHI_PlayAudio(SDL_AudioDevice *self) { - OS3AudioData * data = self->hidden; - - 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 = data->size; - 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 = data->freq; - audio_req[current_buffer]->ahir_Volume = 0x10000; - audio_req[current_buffer]->ahir_Type = data->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 void AHI_CloseAhiDevice(OS3AudioData *os3data) +{ + + if (os3data->ahi_IORequest[0]) + { + if (os3data->link) + { + AbortIO((struct IORequest *)os3data->link); + WaitIO((struct IORequest *)os3data->link); + } + + D(bug("Closing device\n")); + CloseDevice((struct IORequest *)os3data->ahi_IORequest[0]); + + D(bug("Deleting I/O request\n")); + DeleteIORequest( os3data->ahi_IORequest[0] ); + os3data->ahi_IORequest[0] = NULL; + DeleteIORequest( os3data->ahi_IORequest[1] ); + os3data->ahi_IORequest[1] = NULL; + } + + if (os3data->ahi_ReplyPort) + { + D(bug("Deleting message port\n")); + DeleteMsgPort( os3data->ahi_ReplyPort ); + os3data->ahi_ReplyPort = NULL; + } + + D(bug("done closing\n")); } -static Uint8 *AHI_GetAudioBuf(SDL_AudioDevice *self) { - OS3AudioData * data = self->hidden; - - return (mixbuf[current_buffer]); +static int AHI_AudioAvailable(void) +{ + OS3AudioData data; + int is_available = AHI_OpenAhiDevice(&data); + if (is_available) + { + AHI_CloseAhiDevice(&data); + } + D(bug("AHI is %savailable\n", is_available ? "" : "not ")); + return is_available; } -static void AHI_CloseAudio(SDL_AudioDevice *self) { - D(bug("Closing audio...\n")); - OS3AudioData * data = self->hidden; - - if(audio_req[0]) - { - if(audio_req[1] && playing>1) - { - D(bug("Break req[1]...\n")); +static void AHI_DeleteDevice(SDL_AudioDevice *device) +{ + if (device) + { + if (device->hidden) + { + SDL_free(device->hidden); + } + SDL_free(device); + } +} - AbortIO((struct IORequest *)audio_req[1]); - WaitIO((struct IORequest *)audio_req[1]); - } +static SDL_AudioDevice *AHI_CreateDevice(int devindex) +{ + SDL_AudioDevice *device; + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice)); + if ( device ) + { + SDL_memset(device, 0, sizeof(SDL_AudioDevice)); + device->hidden = (OS3AudioData *)SDL_malloc(sizeof(OS3AudioData)); + if (device->hidden) + { + SDL_memset(device->hidden, 0, sizeof(OS3AudioData)); + + /* no AHI device access, global process context */ + device->OpenAudio = AHI_OpenAudio; + device->CloseAudio = AHI_CloseAudio; + + /* AHI access allowed, audio thread context */ + device->ThreadInit = AHI_ThreadInit; /* thread enter (open device) */ + device->WaitAudio = AHI_WaitAudio; + device->PlayAudio = AHI_PlayAudio; + device->GetAudioBuf = AHI_GetAudioBuf; + device->WaitDone = AHI_WaitDone; /* thread exit (close device) */ + + device->free = AHI_DeleteDevice; + } + else + { + /* error on allocating private data */ + SDL_OutOfMemory(); + /* clean up on error */ + SDL_free(device); + device = NULL; + D(bug("Can't allocate private data\n")); + } + } + else + { + /* error on allocating device structure */ + SDL_OutOfMemory(); + D(bug("Can't allocate device\n")); + } + + return device; +} - D(bug("Break req[0]...\n")); +/* ---------------------------------------------- */ +/* Audio driver exported functions implementation */ +/* ---------------------------------------------- */ + +static int AHI_OpenAudio(SDL_AudioDevice *self, SDL_AudioSpec *spec) +{ + int result = 0; + OS3AudioData * os3data = self->hidden; + + /* 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; + if ( spec->channels < 2 ) + os3data->ahi_Type = AHIST_M8S; + else + os3data->ahi_Type = AHIST_S8S; + } + break; + + case 16: { /* Signed 16 bit audio data */ + D(bug("Samples a 16 bit...\n")); + spec->format = AUDIO_S16MSB; + if ( spec->channels < 2 ) + os3data->ahi_Type = AHIST_M16S; + else + os3data->ahi_Type = AHIST_S16S; + } + break; + + default: { + SDL_SetError("Unsupported audio format"); + return (-1); + } + } + + if ( spec->channels != 1 && spec->channels != 2 ) { + D(bug("Wrong channel number!\n")); + SDL_SetError("Channel number non supported"); + return -1; + } + + /* Calculate the final parameters for this audio specification */ + SDL_CalculateAudioSpec(spec); + + /* Allocate mixing buffer */ + os3data->audio_MixBufferSize = spec->size; + os3data->audio_MixBuffer[0] = (Uint8 *)SDL_AllocAudioMem(spec->size); + os3data->audio_MixBuffer[1] = (Uint8 *)SDL_AllocAudioMem(spec->size); + if ( os3data->audio_MixBuffer[0] == NULL || os3data->audio_MixBuffer[1] == NULL ) + { + AHI_CloseAudio(self); + D(bug("No memory for audio buffer\n")); + return -1; + } + SDL_memset(os3data->audio_MixBuffer[0], spec->silence, spec->size); + SDL_memset(os3data->audio_MixBuffer[1], spec->silence, spec->size); + + os3data->audio_IsOpen = 1; + + return result; +} - AbortIO((struct IORequest *)audio_req[0]); - WaitIO((struct IORequest *)audio_req[0]); +static void AHI_CloseAudio(SDL_AudioDevice *self) +{ + OS3AudioData * os3data = self->hidden; + + if (os3data->audio_MixBuffer[0]) + { + SDL_FreeAudioMem(os3data->audio_MixBuffer[0]); + os3data->audio_MixBuffer[0] = NULL; + } + + if (os3data->audio_MixBuffer[1]) + { + SDL_FreeAudioMem(os3data->audio_MixBuffer[1]); + os3data->audio_MixBuffer[1] = NULL; + } + os3data->audio_IsOpen = 0; +} - // Abort again to be sure to break the dbuffering process. - if(audio_req[1] && playing>1) - { - D(bug("Break AGAIN req[1]...\n")); - AbortIO((struct IORequest *)audio_req[1]); - WaitIO((struct IORequest *)audio_req[1]); +static void AHI_ThreadInit(SDL_AudioDevice *self) +{ + OS3AudioData *os3data = self->hidden; + SDL_AudioSpec *spec = &self->spec; + + if (os3data->audio_IsOpen) + { + // Open ahi.device + AHI_OpenAhiDevice(os3data); + switch( spec->format ) + { + case AUDIO_S8: + case AUDIO_U8: + os3data->ahi_Type = (spec->channels<2) ? AHIST_M8S : AHIST_S8S; + break; + + default: + os3data->ahi_Type = (spec->channels<2) ? AHIST_M16S : AHIST_S16S; + break; } + SetTaskPri(FindTask(0), 15); + } +} - D(bug("Reqs breaked, closing device...\n")); - CloseDevice((struct IORequest *)audio_req[0]); - D(bug("Device closed, freeing memory...\n")); - SDL_free(audio_req[1]); - D(bug("Memory freed, deleting IOReq...\n")); - DeleteIORequest((struct IORequest *)audio_req[0]); - audio_req[0]=audio_req[1]=NULL; - - Delay(3); // wait 60 ms to be safe - } - - playing=0; - - D(bug("Freeing mixbuf[0]...\n")); - if ( mixbuf[0] != NULL ) { - SDL_FreeAudioMem(mixbuf[0]); - mixbuf[0] = NULL; - } - - D(bug("Freeing mixbuf[1]...\n")); - if ( mixbuf[1] != NULL ) { - SDL_FreeAudioMem(mixbuf[1]); - mixbuf[1] = NULL; - } - - D(bug("Freeing audio_port...\n")); - - if ( audio_port != NULL ) { - DeleteMsgPort(audio_port); - audio_port = NULL; - } - - D(bug("...done!\n")); +static void AHI_WaitDone(SDL_AudioDevice *self) +{ + AHI_CloseAhiDevice(self->hidden); } -static int AHI_OpenAudio(SDL_AudioDevice *self, SDL_AudioSpec *spec) { - D(bug("AHI opening...\n")); - OS3AudioData * data = self->hidden; - - /* 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; - data->bytespersample = 1; - if ( spec->channels < 2 ) - data->type = AHIST_M8S; - else - data->type = AHIST_S8S; - } - break; - - case 16: { /* Signed 16 bit audio data */ - D(bug("Samples a 16 bit...\n")); - spec->format = AUDIO_S16MSB; - data->bytespersample = 2; - if ( spec->channels < 2 ) - data->type = AHIST_M16S; - else - data->type = AHIST_S16S; - } - break; +static void AHI_WaitAudio(SDL_AudioDevice *self) +{ + /* Dummy - AHI_PlayAudio handles the waiting */ +} - default: { - SDL_SetError("Unsupported audio format"); - return (-1); +static void AHI_PlayAudio(SDL_AudioDevice *self) +{ + struct AHIRequest *ahi_IORequest; + SDL_AudioSpec *spec = &self->spec; + OS3AudioData *os3data = self->hidden; + + ahi_IORequest = os3data->ahi_IORequest[os3data->currentBuffer]; + + ahi_IORequest->ahir_Std.io_Message.mn_Node.ln_Pri = 60; + ahi_IORequest->ahir_Std.io_Data = os3data->audio_MixBuffer[os3data->currentBuffer]; + ahi_IORequest->ahir_Std.io_Length = os3data->audio_MixBufferSize; + ahi_IORequest->ahir_Std.io_Offset = 0; + ahi_IORequest->ahir_Std.io_Command = CMD_WRITE; + ahi_IORequest->ahir_Volume = 0x10000; + ahi_IORequest->ahir_Position = 0x8000; + ahi_IORequest->ahir_Link = os3data->link; + ahi_IORequest->ahir_Frequency = spec->freq; + ahi_IORequest->ahir_Type = os3data->ahi_Type; + + // Convert to signed? + if( spec->format == AUDIO_U8 ) + { +#if POSSIBLY_DANGEROUS_OPTIMISATION + int i, n; + uint32 *mixbuf = (uint32 *)os3data->audio_MixBuffer[os3data->currentBuffer]; + n = os3data->audio_MixBufferSize/4; // let the gcc optimiser decide the best way to divide by 4 + for( i=0; iaudio_MixBufferSize & 3)) + { + uint8 *mixbuf8 = (uint8*)mixbuf; + for( i=0; iaudio_MixBufferSize; i++ ) + os3data->audio_MixBuffer[os3data->currentBuffer][i] -= 128; +#endif } - if ( spec->channels != 1 && spec->channels != 2 ) { - D(bug("Wrong channel number!\n")); - SDL_SetError("Channel number non supported"); - 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 and size */ - data->freq = spec->freq; - data->size = spec->size; - - D(bug("Before buffer allocation\n")); - - /* Allocate mixing buffer */ - mixbuf[0] = (Uint8 *)SDL_malloc(spec->size); - mixbuf[1] = (Uint8 *)SDL_malloc(spec->size); - - D(bug("Before audio_req allocation\n")); - - if ( !(audio_req[1] = SDL_malloc(sizeof(struct AHIRequest)))) { - SDL_OutOfMemory(); - return (-1); - } - - D(bug("Before audio_req memcpy\n")); - - SDL_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")); + SendIO((struct IORequest*)ahi_IORequest); - SDL_memset(mixbuf[0], spec->silence, spec->size); - SDL_memset(mixbuf[1], spec->silence, spec->size); + if (os3data->link) + WaitIO((struct IORequest*)os3data->link); - current_buffer = 0; - playing = 0; + os3data->link = ahi_IORequest; - D(bug("AHI opened: freq:%ld mixbuf:%lx/%lx buflen:%ld bits:%ld channels:%ld\n", spec->freq, mixbuf[0], mixbuf[1], spec->size, this->hidden->bytespersample * 8, spec->channels)); + os3data->currentBuffer = 1-os3data->currentBuffer; +} - /* We're ready to rock and roll. :-) */ - return (0); +static Uint8 *AHI_GetAudioBuf(SDL_AudioDevice *self) +{ + return self->hidden->audio_MixBuffer[self->hidden->currentBuffer]; } diff --git a/src/audio/amigaos/SDL_ahiaudio.h b/src/audio/amigaos/SDL_ahiaudio.h index 01fe34534..34877518b 100644 --- a/src/audio/amigaos/SDL_ahiaudio.h +++ b/src/audio/amigaos/SDL_ahiaudio.h @@ -50,16 +50,23 @@ #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 */ - struct AHIRequest *ahi_IORequest[2]; - struct MsgPort *ahi_ReplyPort; - Sint32 freq, type, bytespersample, size; - Uint8 *audio_MixBuffer[2]; /* The app mixing buffer */ - int current_buffer; - Uint32 playing; +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + struct MsgPort *ahi_ReplyPort; + struct AHIRequest *ahi_IORequest[2]; + + struct AHIAudioCtrl *ahi_AudioCtrl; + Uint32 ahi_Type; + int currentBuffer; // buffer number to fill + struct AHIRequest *link; // point to previous I/O request sent + + int audio_IsOpen; + Uint32 audio_MixBufferSize; + Uint8 *audio_MixBuffer[2]; + + APTR audio_Mutex; }; /* Old variable names */ From eb484f4a1b70257f962c295647ad262c8257c1dd Mon Sep 17 00:00:00 2001 From: Marlon Beijer Date: Sun, 21 Jun 2020 18:10:54 +0200 Subject: [PATCH 21/21] Re add wrongfully removed part of SDL_audio.c --- src/audio/SDL_audio.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index bb559a128..dfb4d5dac 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -224,7 +224,14 @@ int SDLCALL SDL_RunAudio(void *audiop) audio->PlayAudio(audio); } + /* Wait for an audio buffer to become available */ + if ( stream == audio->fake_stream ) { + SDL_Delay((audio->spec.samples*1000)/audio->spec.freq); + } else { + audio->WaitAudio(audio); + } } + /* Wait for the audio to drain.. */ if ( audio->WaitDone ) { audio->WaitDone(audio);