Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
Sylvain PILLOT | 8a209c1084 | |
Sylvain PILLOT | a2693e2f35 | |
Sylvain PILLOT | e0f611e3b9 | |
Sylvain PILLOT | 5ecf100c20 | |
Sylvain PILLOT | f8674ae41e | |
Sylvain PILLOT | 2f899e9935 | |
Sylvain PILLOT | 05c3e3d81b | |
Sylvain PILLOT | 6bb0866e04 | |
Sylvain PILLOT | de4776e7de | |
Sylvain PILLOT | 96e71f5395 | |
Sylvain PILLOT | 88fb489ee3 | |
Sylvain PILLOT | 57a084f989 |
|
@ -0,0 +1,3 @@
|
|||
/build-fx
|
||||
/build-cg
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
# libSDL: build system
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
project(cSDL VERSION 1.2.15 LANGUAGES C)
|
||||
find_package(Gint 2.9.0 REQUIRED)
|
||||
|
||||
configure_file(./include/SDL_config.h.in include/SDL/SDL_config.h)
|
||||
|
||||
set(SOURCES
|
||||
src/SDL.c
|
||||
src/SDL_error.c
|
||||
src/SDL_fatal.c
|
||||
src/audio/SDL_audio.c
|
||||
src/audio/SDL_audiocvt.c
|
||||
src/cpuinfo/SDL_cpuinfo.c
|
||||
src/events/SDL_active.c
|
||||
src/events/SDL_events.c
|
||||
src/events/SDL_expose.c
|
||||
src/events/SDL_keyboard.c
|
||||
src/events/SDL_mouse.c
|
||||
src/events/SDL_quit.c
|
||||
src/events/SDL_resize.c
|
||||
src/file/SDL_rwops.c
|
||||
src/joystick/SDL_joystick.c
|
||||
src/stdlib/SDL_getenv.c
|
||||
src/stdlib/SDL_iconv.c
|
||||
src/stdlib/SDL_malloc.c
|
||||
src/stdlib/SDL_qsort.c
|
||||
src/stdlib/SDL_stdlib.c
|
||||
src/stdlib/SDL_string.c
|
||||
src/thread/SDL_thread.c
|
||||
src/thread/generic/SDL_syscond.c
|
||||
src/thread/generic/SDL_sysmutex.c
|
||||
src/thread/generic/SDL_syssem.c
|
||||
src/thread/generic/SDL_systhread.c
|
||||
src/timer/SDL_timer.c
|
||||
src/timer/prizm/SDL_systimer.c
|
||||
src/video/SDL_blit.c
|
||||
src/video/SDL_blit_0.c
|
||||
src/video/SDL_blit_1.c
|
||||
src/video/SDL_blit_A.c
|
||||
src/video/SDL_blit_N.c
|
||||
src/video/SDL_bmp.c
|
||||
src/video/SDL_cursor.c
|
||||
src/video/SDL_gamma.c
|
||||
src/video/SDL_pixels.c
|
||||
src/video/SDL_RLEaccel.c
|
||||
src/video/SDL_stretch.c
|
||||
src/video/SDL_surface.c
|
||||
src/video/SDL_video.c
|
||||
src/video/SDL_yuv.c
|
||||
src/video/SDL_yuv_mmx.c
|
||||
src/video/SDL_yuv_sw.c
|
||||
src/video/prizm/SDL_prizmevents.c
|
||||
src/video/prizm/SDL_prizmfonts.c
|
||||
src/video/prizm/SDL_prizmnti.c
|
||||
src/video/prizm/SDL_prizmutils.c
|
||||
src/video/prizm/SDL_prizmvideo.c
|
||||
src/gfx/SDL_framerate.c
|
||||
src/gfx/SDL_gfxBlitFunc.c
|
||||
src/gfx/SDL_gfxPrimitives.c
|
||||
src/gfx/SDL_imageFilter.c
|
||||
src/gfx/SDL_rotozoom.c
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${PROJECT_SOURCE_DIR}/include"
|
||||
"${PROJECT_SOURCE_DIR}/include/SDL")
|
||||
|
||||
# Target name is "cSDL", output file is "libcSDL.a" (by default)
|
||||
add_library(cSDL STATIC ${SOURCES})
|
||||
target_compile_options(cSDL PRIVATE -Os -std=c11)
|
||||
|
||||
# After building, install the target (that is, libSDL_prizm.a) in the compiler
|
||||
install(TARGETS cSDL
|
||||
DESTINATION "${FXSDK_LIB}")
|
||||
|
||||
# Also install the headers (our include folder gets merged with the existing
|
||||
# one in the compiler's install folder). Only install files matching *.h to
|
||||
# exclude config.h.in.
|
||||
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/SDL"
|
||||
DESTINATION "${FXSDK_INCLUDE}"
|
||||
FILES_MATCHING PATTERN "*.h")
|
||||
# Slyvtt : replaced "*.h" with "*" as some headers are in the C++ style, without .h extension
|
||||
|
||||
# Install config.h from the build dir
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/include/SDL/SDL_config.h"
|
||||
DESTINATION "${FXSDK_INCLUDE}/SDL")
|
||||
|
||||
# Install FindcSDL.cmake so that users can do find_package(LibcSDL)
|
||||
install(FILES cmake/FindcSDL.cmake
|
||||
DESTINATION "${FXSDK_CMAKE_MODULE_PATH}")
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
# Makefile to build the SDL library
|
||||
|
||||
INCLUDE = -I./include
|
||||
CFLAGS = -O2 $(INCLUDE) -m4-nofpu -mb -ffreestanding -nostdlib -Wa,--dsp
|
||||
AR = sh-elf-gcc-ar
|
||||
RANLIB = sh-elf-gcc-ranlib
|
||||
CC = sh-elf-gcc
|
||||
|
||||
CONFIG_H = include/SDL_config.h
|
||||
TARGET = libSDL_prizm.a
|
||||
SOURCES = \
|
||||
src/*.c \
|
||||
src/audio/*.c \
|
||||
src/cdrom/*.c \
|
||||
src/cpuinfo/*.c \
|
||||
src/events/*.c \
|
||||
src/file/*.c \
|
||||
src/joystick/*.c \
|
||||
src/stdlib/*.c \
|
||||
src/thread/*.c \
|
||||
src/timer/*.c \
|
||||
src/video/*.c \
|
||||
src/audio/dummy/*.c \
|
||||
src/video/dummy/*.c \
|
||||
src/joystick/dummy/*.c \
|
||||
src/cdrom/dummy/*.c \
|
||||
src/thread/generic/*.c \
|
||||
src/timer/dummy/*.c \
|
||||
src/loadso/dummy/*.c \
|
||||
|
||||
OBJECTS = $(shell echo $(SOURCES) | sed -e 's,\.c,\.o,g')
|
||||
|
||||
all: $(TARGET)
|
||||
|
||||
$(TARGET): $(CONFIG_H) $(OBJECTS)
|
||||
$(AR) crv $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
$(CONFIG_H):
|
||||
cp $(CONFIG_H).default $(CONFIG_H)
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJECTS)
|
63
README.md
63
README.md
|
@ -0,0 +1,63 @@
|
|||
# Simple DirectMedia Layer SDL 1.2.15 sources for Casio Graph 90+E and Prizm CG10/20
|
||||
|
||||
Need to have a fully working gcc toolchain for SH3/SH4 architecture.
|
||||
|
||||
You can use the `giteapc install Slyvtt/cSDL` command to get an automatic install
|
||||
|
||||
|
||||
## Using in a program
|
||||
|
||||
With CMake
|
||||
|
||||
```cmake
|
||||
find_package(cSDL 1.2.15 REQUIRED)
|
||||
target_link_libraries(<TARGET> PRIVATE cSDL::cSDL)
|
||||
```
|
||||
|
||||
With make, the following steps are not automatically done, so please proceed with the following manipulations :
|
||||
* copy the library `libcSDL.a` into your SH3/SH4 compiler lib folder
|
||||
* copy all header files `*.h` in the include folder `include/SDL` of the SH3/SH4 compiler
|
||||
* link with `-lcSDL`
|
||||
|
||||
In the C/C++ sources `#include <SDL/SDL.h>`
|
||||
|
||||
|
||||
## Typical CMakeLists.txt
|
||||
|
||||
Below is the typical minimum `CMakeLists.txt` file to be used for a fxSDK project aiming at using the cSDL library :
|
||||
|
||||
```cmake
|
||||
cmake_minimum_required(VERSION 3.15)
|
||||
project(MyAddin)
|
||||
|
||||
include(GenerateG3A)
|
||||
include(Fxconv)
|
||||
find_package(Gint 2.7.1 REQUIRED)
|
||||
find_package(cSDL 1.2.15 REQUIRED)
|
||||
|
||||
set(SOURCES
|
||||
src/main.c
|
||||
# ...
|
||||
)
|
||||
# Shared assets, fx-9860G-only assets and fx-CG-50-only assets
|
||||
set(ASSETS
|
||||
# ...
|
||||
)
|
||||
|
||||
set(ASSETS_cg
|
||||
assets-cg/example.png
|
||||
# ...
|
||||
)
|
||||
|
||||
fxconv_declare_assets(${ASSETS} ${ASSETS_cg} WITH_METADATA)
|
||||
|
||||
add_executable(myaddin ${SOURCES} ${ASSETS} ${ASSETS_${FXSDK_PLATFORM}})
|
||||
target_compile_options(myaddin PRIVATE -Wall -Wextra -Os)
|
||||
target_link_libraries(myaddin Gint::Gint cSDL::cSDL)
|
||||
|
||||
if("${FXSDK_PLATFORM_LONG}" STREQUAL fxCG50)
|
||||
generate_g3a(TARGET myaddin OUTPUT "SDL_App.g3a"
|
||||
NAME "SDL_App" ICONS assets-cg/icon-uns.png assets-cg/icon-sel.png)
|
||||
endif()
|
||||
```
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
timers : src/timer/prizm/SDL_systimer.c
|
||||
|
||||
implement :
|
||||
void SDL_StartTicks(void);
|
||||
Uint32 SDL_GetTicks (void);
|
||||
void SDL_Delay (Uint32 ms)
|
||||
|
||||
check if :
|
||||
#include "SDL_thread.h" is working or not
|
||||
|
||||
|
||||
video :
|
||||
|
277
cSDL1_2_15.cbp
277
cSDL1_2_15.cbp
|
@ -1,277 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6" />
|
||||
<Project>
|
||||
<Option title="cSDL1_2_15" />
|
||||
<Option pch_mode="2" />
|
||||
<Option compiler="null" />
|
||||
<Build>
|
||||
<Target title="Release">
|
||||
<Option output="bin/Release/cSDL1_2_15" prefix_auto="1" extension_auto="1" />
|
||||
<Option object_output="obj/Release/" />
|
||||
<Option type="1" />
|
||||
<Option compiler="null" />
|
||||
</Target>
|
||||
</Build>
|
||||
<Unit filename="Makefile.prizm" />
|
||||
<Unit filename="README.md" />
|
||||
<Unit filename="include/SDL.h" />
|
||||
<Unit filename="include/SDL_active.h" />
|
||||
<Unit filename="include/SDL_audio.h" />
|
||||
<Unit filename="include/SDL_byteorder.h" />
|
||||
<Unit filename="include/SDL_cdrom.h" />
|
||||
<Unit filename="include/SDL_config.h" />
|
||||
<Unit filename="include/SDL_config_minimal.h" />
|
||||
<Unit filename="include/SDL_config_prizm.h" />
|
||||
<Unit filename="include/SDL_copying.h" />
|
||||
<Unit filename="include/SDL_cpuinfo.h" />
|
||||
<Unit filename="include/SDL_endian.h" />
|
||||
<Unit filename="include/SDL_error.h" />
|
||||
<Unit filename="include/SDL_events.h" />
|
||||
<Unit filename="include/SDL_getenv.h" />
|
||||
<Unit filename="include/SDL_joystick.h" />
|
||||
<Unit filename="include/SDL_keyboard.h" />
|
||||
<Unit filename="include/SDL_keysym.h" />
|
||||
<Unit filename="include/SDL_loadso.h" />
|
||||
<Unit filename="include/SDL_main.h" />
|
||||
<Unit filename="include/SDL_mouse.h" />
|
||||
<Unit filename="include/SDL_mutex.h" />
|
||||
<Unit filename="include/SDL_name.h" />
|
||||
<Unit filename="include/SDL_opengl.h" />
|
||||
<Unit filename="include/SDL_platform.h" />
|
||||
<Unit filename="include/SDL_quit.h" />
|
||||
<Unit filename="include/SDL_rwops.h" />
|
||||
<Unit filename="include/SDL_stdinc.h" />
|
||||
<Unit filename="include/SDL_syswm.h" />
|
||||
<Unit filename="include/SDL_thread.h" />
|
||||
<Unit filename="include/SDL_timer.h" />
|
||||
<Unit filename="include/SDL_types.h" />
|
||||
<Unit filename="include/SDL_version.h" />
|
||||
<Unit filename="include/SDL_video.h" />
|
||||
<Unit filename="include/begin_code.h" />
|
||||
<Unit filename="include/close_code.h" />
|
||||
<Unit filename="include/doxyfile" />
|
||||
<Unit filename="src/SDL.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/SDL_error.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/SDL_error_c.h" />
|
||||
<Unit filename="src/SDL_fatal.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/SDL_fatal.h" />
|
||||
<Unit filename="src/audio/SDL_audio.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_audio_c.h" />
|
||||
<Unit filename="src/audio/SDL_audiocvt.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_audiodev.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_audiodev_c.h" />
|
||||
<Unit filename="src/audio/SDL_audiomem.h" />
|
||||
<Unit filename="src/audio/SDL_mixer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_mixer_MMX.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_mixer_MMX.h" />
|
||||
<Unit filename="src/audio/SDL_mixer_MMX_VC.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_mixer_MMX_VC.h" />
|
||||
<Unit filename="src/audio/SDL_mixer_m68k.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_mixer_m68k.h" />
|
||||
<Unit filename="src/audio/SDL_sysaudio.h" />
|
||||
<Unit filename="src/audio/SDL_wave.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/SDL_wave.h" />
|
||||
<Unit filename="src/audio/dummy/SDL_dummyaudio.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/audio/dummy/SDL_dummyaudio.h" />
|
||||
<Unit filename="src/cdrom/SDL_cdrom.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/cdrom/SDL_syscdrom.h" />
|
||||
<Unit filename="src/cdrom/dummy/SDL_syscdrom.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/cpuinfo/SDL_cpuinfo.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_active.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_events.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_events_c.h" />
|
||||
<Unit filename="src/events/SDL_expose.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_keyboard.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_mouse.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_quit.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_resize.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/events/SDL_sysevents.h" />
|
||||
<Unit filename="src/file/SDL_rwops.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/joystick/SDL_joystick.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/joystick/SDL_joystick_c.h" />
|
||||
<Unit filename="src/joystick/SDL_sysjoystick.h" />
|
||||
<Unit filename="src/joystick/dummy/SDL_sysjoystick.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/loadso/dummy/SDL_sysloadso.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/main/dummy/SDL_dummy_main.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_getenv.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_iconv.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_malloc.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_qsort.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_stdlib.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/stdlib/SDL_string.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/SDL_systhread.h" />
|
||||
<Unit filename="src/thread/SDL_thread.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/SDL_thread_c.h" />
|
||||
<Unit filename="src/thread/generic/SDL_syscond.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/generic/SDL_sysmutex.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/generic/SDL_sysmutex_c.h" />
|
||||
<Unit filename="src/thread/generic/SDL_syssem.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/generic/SDL_systhread.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/thread/generic/SDL_systhread_c.h" />
|
||||
<Unit filename="src/timer/SDL_systimer.h" />
|
||||
<Unit filename="src/timer/SDL_timer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/timer/SDL_timer_c.h" />
|
||||
<Unit filename="src/timer/dummy/SDL_systimer.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_RLEaccel.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_RLEaccel_c.h" />
|
||||
<Unit filename="src/video/SDL_blit.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_blit.h" />
|
||||
<Unit filename="src/video/SDL_blit_0.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_blit_1.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_blit_A.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_blit_N.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_bmp.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_cursor.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_cursor_c.h" />
|
||||
<Unit filename="src/video/SDL_gamma.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_glfuncs.h" />
|
||||
<Unit filename="src/video/SDL_leaks.h" />
|
||||
<Unit filename="src/video/SDL_pixels.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_pixels_c.h" />
|
||||
<Unit filename="src/video/SDL_stretch.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_stretch_c.h" />
|
||||
<Unit filename="src/video/SDL_surface.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_sysvideo.h" />
|
||||
<Unit filename="src/video/SDL_video.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_yuv.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_yuv_mmx.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_yuv_sw.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/SDL_yuv_sw_c.h" />
|
||||
<Unit filename="src/video/SDL_yuvfuncs.h" />
|
||||
<Unit filename="src/video/blank_cursor.h" />
|
||||
<Unit filename="src/video/default_cursor.h" />
|
||||
<Unit filename="src/video/dummy/SDL_nullevents.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/dummy/SDL_nullevents_c.h" />
|
||||
<Unit filename="src/video/dummy/SDL_nullmouse.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/dummy/SDL_nullmouse_c.h" />
|
||||
<Unit filename="src/video/dummy/SDL_nullvideo.c">
|
||||
<Option compilerVar="CC" />
|
||||
</Unit>
|
||||
<Unit filename="src/video/dummy/SDL_nullvideo.h" />
|
||||
<Unit filename="src/video/e_log.h" />
|
||||
<Unit filename="src/video/e_pow.h" />
|
||||
<Unit filename="src/video/e_sqrt.h" />
|
||||
<Unit filename="src/video/math_private.h" />
|
||||
<Unit filename="src/video/mmx.h" />
|
||||
<Extensions>
|
||||
<lib_finder disable_auto="1" />
|
||||
</Extensions>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
|
||||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="include/SDL_config.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1297" topLine="15" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="Makefile.prizm" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="69" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="include/SDL_config_prizm.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1675" topLine="48" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
|
@ -0,0 +1,19 @@
|
|||
include(FindSimpleLibrary)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
find_simple_library(libcSDL.a SDL/SDL_version.h _
|
||||
PATH_VAR CSDL_PATH
|
||||
OTHER_MACROS SDL_MAJOR_VERSION SDL_MINOR_VERSION SDL_PATCHLEVEL)
|
||||
|
||||
set(CSDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_PATCHLEVEL}")
|
||||
|
||||
find_package_handle_standard_args(cSDL
|
||||
REQUIRED_VARS CSDL_PATH
|
||||
VERSION_VAR CSDL_VERSION)
|
||||
|
||||
if(cSDL_FOUND)
|
||||
add_library(cSDL::cSDL UNKNOWN IMPORTED)
|
||||
set_target_properties(cSDL::cSDL PROPERTIES
|
||||
IMPORTED_LOCATION "${CSDL_PATH}"
|
||||
INTERFACE_LINK_OPTIONS -lcSDL)
|
||||
endif()
|
|
@ -0,0 +1,20 @@
|
|||
# giteapc: version=1 depends=Lephenixnoir/gint,Lephenixnoir/sh-elf-gcc,Lephenixnoir/fxsdk,Lephenixnoir/OpenLibm,Vhex-Kernel-Core/fxlibc
|
||||
-include giteapc-config.make
|
||||
|
||||
|
||||
configure:
|
||||
@ fxsdk build-cg -c
|
||||
|
||||
build:
|
||||
@ fxsdk build-cg
|
||||
|
||||
install:
|
||||
@ fxsdk build-cg install
|
||||
|
||||
uninstall:
|
||||
@ if [ -e build-cg/install_manifest.txt ]; then \
|
||||
xargs rm -f < build-cg/install_manifest.txt; \
|
||||
fi
|
||||
|
||||
.PHONY: configure build install uninstall
|
||||
|
|
@ -87,6 +87,8 @@ extern DECLSPEC void SDLCALL SDL_QuitSubSystem(Uint32 flags);
|
|||
*/
|
||||
extern DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags);
|
||||
|
||||
extern DECLSPEC void SDLCALL cSDL_LogToFile(const char *fmt, ... );
|
||||
|
||||
/** This function cleans up all initialized subsystems and unloads the
|
||||
* dynamically linked library. You should call it upon all exit conditions.
|
||||
*/
|
|
@ -29,6 +29,23 @@
|
|||
|
||||
#include <gint/gint.h>
|
||||
|
||||
|
||||
#define PRZ_DEBUG_BUILD 1
|
||||
//#define DEBUG_BUILD 1
|
||||
//#define DEBUG_VIDEO 1
|
||||
//#define DEBUG_ERROR 1
|
||||
|
||||
|
||||
#define PRZ_WARNING(s) fprintf(stderr, "[nSDL] Warning: %s\n", s)
|
||||
|
||||
#if PRZ_DEBUG_BUILD
|
||||
#define PRZ_DEBUG(fmt, args...) \
|
||||
fprintf(stderr, "[nSDL] %s(): " fmt "\n", __FUNCTION__, ## args)
|
||||
#else
|
||||
#define PRZ_DEBUG(fmt, args...) (void)0
|
||||
#endif
|
||||
|
||||
|
||||
#define SDL_HAS_64BIT_TYPE 1
|
||||
|
||||
/* Endianness */
|
||||
|
@ -72,12 +89,32 @@
|
|||
#define SDL_THREADS_DISABLED 1
|
||||
|
||||
|
||||
#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
//#define SDL_AUDIO_DRIVER_DUMMY 1
|
||||
//#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||
#define SDL_CDROM_DUMMY 1
|
||||
#define SDL_JOYSTICK_DUMMY 1
|
||||
#define SDL_LOADSO_DUMMY 1
|
||||
#define SDL_TIMER_DUMMY 1
|
||||
//#define SDL_TIMER_DUMMY 1
|
||||
|
||||
|
||||
/* Enable various timer systems */
|
||||
#define SDL_TIMER_PRIZM 1
|
||||
|
||||
/* Enable various video drivers */
|
||||
#define SDL_VIDEO_DRIVER_PRIZM 1
|
||||
|
||||
/* Enable assembly routines */
|
||||
#define SDL_ASSEMBLY_ROUTINES 1
|
||||
|
||||
/* Fonts; needs to match nsp_font_charmaps in SDL_tinspirefonts.c */
|
||||
enum {
|
||||
cSDL_FONT_THIN = 0,
|
||||
cSDL_FONT_SPACE,
|
||||
cSDL_FONT_VGA,
|
||||
cSDL_FONT_FANTASY,
|
||||
cSDL_FONT_TINYTYPE,
|
||||
PRZ_NUMFONTS
|
||||
};
|
||||
|
||||
|
||||
#endif /* _SDL_config_prizm_h */
|
|
@ -0,0 +1,100 @@
|
|||
/*
|
||||
|
||||
SDL_framerate.h: framerate manager
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_framerate_h
|
||||
#define _SDL_framerate_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* --- */
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* --------- Definitions */
|
||||
|
||||
/*!
|
||||
\brief Highest possible rate supported by framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_UPPER_LIMIT 200
|
||||
|
||||
/*!
|
||||
\brief Lowest possible rate supported by framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_LOWER_LIMIT 1
|
||||
|
||||
/*!
|
||||
\brief Default rate of framerate controller in Hz (1/s).
|
||||
*/
|
||||
#define FPS_DEFAULT 30
|
||||
|
||||
/*!
|
||||
\brief Structure holding the state and timing information of the framerate controller.
|
||||
*/
|
||||
typedef struct {
|
||||
Uint32 framecount;
|
||||
float rateticks;
|
||||
Uint32 baseticks;
|
||||
Uint32 lastticks;
|
||||
Uint32 rate;
|
||||
} FPSmanager;
|
||||
|
||||
/* ---- Function Prototypes */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
|
||||
# define SDL_FRAMERATE_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_FRAMERATE_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_FRAMERATE_SCOPE
|
||||
# define SDL_FRAMERATE_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* Functions return 0 or value for sucess and -1 for error */
|
||||
|
||||
SDL_FRAMERATE_SCOPE void SDL_initFramerate(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE int SDL_setFramerate(FPSmanager * manager, Uint32 rate);
|
||||
SDL_FRAMERATE_SCOPE int SDL_getFramerate(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE int SDL_getFramecount(FPSmanager * manager);
|
||||
SDL_FRAMERATE_SCOPE Uint32 SDL_framerateDelay(FPSmanager * manager);
|
||||
|
||||
/* --- */
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_framerate_h */
|
|
@ -0,0 +1,168 @@
|
|||
/*
|
||||
|
||||
SDL_gfxBlitFunc.h: custom blitters
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gfxBlitFunc_h
|
||||
#define _SDL_gfxBlitFunc_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL_video.h"
|
||||
|
||||
|
||||
extern const unsigned int GFX_ALPHA_ADJUST_ARRAY[256];
|
||||
|
||||
/* ---- Function Prototypes */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
|
||||
# define SDL_GFXBLITFUNC_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_GFXBLITFUNC_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_GFXBLITFUNC_SCOPE
|
||||
# define SDL_GFXBLITFUNC_SCOPE extern
|
||||
#endif
|
||||
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect);
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxSetAlpha(SDL_Surface * src, Uint8 a);
|
||||
|
||||
SDL_GFXBLITFUNC_SCOPE int SDL_gfxMultiplyAlpha(SDL_Surface * src, Uint8 a);
|
||||
|
||||
/* -------- Macros */
|
||||
|
||||
/* Define SDL macros locally as a substitute for an #include "SDL_blit.h", */
|
||||
/* which doesn't work since the include file doesn't get installed. */
|
||||
|
||||
/*!
|
||||
\brief The structure passed to the low level blit functions.
|
||||
*/
|
||||
typedef struct {
|
||||
Uint8 *s_pixels;
|
||||
int s_width;
|
||||
int s_height;
|
||||
int s_skip;
|
||||
Uint8 *d_pixels;
|
||||
int d_width;
|
||||
int d_height;
|
||||
int d_skip;
|
||||
void *aux_data;
|
||||
SDL_PixelFormat *src;
|
||||
Uint8 *table;
|
||||
SDL_PixelFormat *dst;
|
||||
} SDL_gfxBlitInfo;
|
||||
|
||||
/*!
|
||||
\brief Unwrap RGBA values from a pixel using mask, shift and loss for surface.
|
||||
*/
|
||||
#define GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
r = ((pixel&fmt->Rmask)>>fmt->Rshift)<<fmt->Rloss; \
|
||||
g = ((pixel&fmt->Gmask)>>fmt->Gshift)<<fmt->Gloss; \
|
||||
b = ((pixel&fmt->Bmask)>>fmt->Bshift)<<fmt->Bloss; \
|
||||
a = ((pixel&fmt->Amask)>>fmt->Ashift)<<fmt->Aloss; \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Disassemble buffer pointer into a pixel and separate RGBA values.
|
||||
*/
|
||||
#define GFX_DISASSEMBLE_RGBA(buf, bpp, fmt, pixel, r, g, b, a) \
|
||||
do { \
|
||||
pixel = *((Uint32 *)(buf)); \
|
||||
GFX_RGBA_FROM_PIXEL(pixel, fmt, r, g, b, a); \
|
||||
pixel &= ~fmt->Amask; \
|
||||
} while(0)
|
||||
|
||||
/*!
|
||||
\brief Wrap a pixel from RGBA values using mask, shift and loss for surface.
|
||||
*/
|
||||
#define GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a) \
|
||||
{ \
|
||||
pixel = ((r>>fmt->Rloss)<<fmt->Rshift)| \
|
||||
((g>>fmt->Gloss)<<fmt->Gshift)| \
|
||||
((b>>fmt->Bloss)<<fmt->Bshift)| \
|
||||
((a<<fmt->Aloss)<<fmt->Ashift); \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Assemble pixel into buffer pointer from separate RGBA values.
|
||||
*/
|
||||
#define GFX_ASSEMBLE_RGBA(buf, bpp, fmt, r, g, b, a) \
|
||||
{ \
|
||||
Uint32 pixel; \
|
||||
\
|
||||
GFX_PIXEL_FROM_RGBA(pixel, fmt, r, g, b, a); \
|
||||
*((Uint32 *)(buf)) = pixel; \
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Blend the RGB values of two pixels based on a source alpha value.
|
||||
*/
|
||||
#define GFX_ALPHA_BLEND(sR, sG, sB, A, dR, dG, dB) \
|
||||
do { \
|
||||
dR = (((sR-dR)*(A))/255)+dR; \
|
||||
dG = (((sG-dG)*(A))/255)+dG; \
|
||||
dB = (((sB-dB)*(A))/255)+dB; \
|
||||
} while(0)
|
||||
|
||||
/*!
|
||||
\brief 4-times unrolled DUFFs loop.
|
||||
|
||||
This is a very useful loop for optimizing blitters.
|
||||
*/
|
||||
#define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \
|
||||
{ int n = (width+3)/4; \
|
||||
switch (width & 3) { \
|
||||
case 0: do { pixel_copy_increment; \
|
||||
case 3: pixel_copy_increment; \
|
||||
case 2: pixel_copy_increment; \
|
||||
case 1: pixel_copy_increment; \
|
||||
} while ( --n > 0 ); \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_gfxBlitFunc_h */
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
|
||||
SDL_gfxPrimitives.h: graphics primitives for SDL
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_gfxPrimitives_h
|
||||
#define _SDL_gfxPrimitives_h
|
||||
|
||||
#include <math.h>
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.1415926535897932384626433832795
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ----- Versioning */
|
||||
|
||||
#define SDL_GFXPRIMITIVES_MAJOR 2
|
||||
#define SDL_GFXPRIMITIVES_MINOR 0
|
||||
#define SDL_GFXPRIMITIVES_MICRO 25
|
||||
|
||||
|
||||
/* ---- Function Prototypes */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
|
||||
# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_GFXPRIMITIVES_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_GFXPRIMITIVES_SCOPE
|
||||
# define SDL_GFXPRIMITIVES_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* Note: all ___Color routines expect the color to be in format 0xRRGGBBAA */
|
||||
|
||||
/* Pixel */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int pixelColor(SDL_Surface * dst, Sint16 x, Sint16 y, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int pixelRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Horizontal line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int hlineColor(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int hlineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 x2, Sint16 y, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Vertical line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int vlineColor(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int vlineRGBA(SDL_Surface * dst, Sint16 x, Sint16 y1, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Rectangle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int rectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int rectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Rounded-Corner Rectangle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int roundedRectangleColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int roundedRectangleRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled rectangle (Box) */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int boxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int boxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,
|
||||
Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Rounded-Corner Filled rectangle (Box) */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int roundedBoxColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int roundedBoxRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2,
|
||||
Sint16 y2, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int lineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int lineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Line */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aalineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aalineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1,
|
||||
Sint16 x2, Sint16 y2, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Thick Line */
|
||||
SDL_GFXPRIMITIVES_SCOPE int thickLineColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
|
||||
Uint8 width, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int thickLineRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2,
|
||||
Uint8 width, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int circleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int circleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Arc */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int arcColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int arcRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Sint16 start, Sint16 end,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aacircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aacircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Circle */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledCircleColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 r, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledCircleRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rad, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int ellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int ellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aaellipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aaellipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Ellipse */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledEllipseColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rx, Sint16 ry, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledEllipseRGBA(SDL_Surface * dst, Sint16 x, Sint16 y,
|
||||
Sint16 rx, Sint16 ry, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Pie */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int pieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int pieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Pie */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPieColor(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPieRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, Sint16 rad,
|
||||
Sint16 start, Sint16 end, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int trigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int trigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA-Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aatrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aatrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Trigon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledTrigonColor(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledTrigonRGBA(SDL_Surface * dst, Sint16 x1, Sint16 y1, Sint16 x2, Sint16 y2, Sint16 x3, Sint16 y3,
|
||||
Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int polygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int polygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* AA-Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int aapolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int aapolygonRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Filled Polygon */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBA(SDL_Surface * dst, const Sint16 * vx,
|
||||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
SDL_GFXPRIMITIVES_SCOPE int texturedPolygon(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy);
|
||||
|
||||
/* (Note: These MT versions are required for multi-threaded operation.) */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonColorMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, Uint32 color, int **polyInts, int *polyAllocated);
|
||||
SDL_GFXPRIMITIVES_SCOPE int filledPolygonRGBAMT(SDL_Surface * dst, const Sint16 * vx,
|
||||
const Sint16 * vy, int n, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
|
||||
int **polyInts, int *polyAllocated);
|
||||
SDL_GFXPRIMITIVES_SCOPE int texturedPolygonMT(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, SDL_Surface * texture,int texture_dx,int texture_dy, int **polyInts, int *polyAllocated);
|
||||
|
||||
/* Bezier */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE int bezierColor(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy, int n, int s, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int bezierRGBA(SDL_Surface * dst, const Sint16 * vx, const Sint16 * vy,
|
||||
int n, int s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Characters/Strings */
|
||||
|
||||
SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFont(const void *fontdata, Uint32 cw, Uint32 ch);
|
||||
SDL_GFXPRIMITIVES_SCOPE void gfxPrimitivesSetFontRotation(Uint32 rotation);
|
||||
SDL_GFXPRIMITIVES_SCOPE int characterColor(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int characterRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, char c, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
SDL_GFXPRIMITIVES_SCOPE int stringColor(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint32 color);
|
||||
SDL_GFXPRIMITIVES_SCOPE int stringRGBA(SDL_Surface * dst, Sint16 x, Sint16 y, const char *s, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_gfxPrimitives_h */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
|
||||
SDL_imageFilter.h: byte-image "filter" routines
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_imageFilter_h
|
||||
#define _SDL_imageFilter_h
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ---- Function Prototypes */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
|
||||
# define SDL_IMAGEFILTER_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_IMAGEFILTER_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_IMAGEFILTER_SCOPE
|
||||
# define SDL_IMAGEFILTER_SCOPE extern
|
||||
#endif
|
||||
|
||||
/* Comments: */
|
||||
/* 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. */
|
||||
/* 2.) Data that is not within an 8 byte boundary is processed using the C routine. */
|
||||
/* 3.) Convolution routines do not have C routines at this time. */
|
||||
|
||||
// Detect MMX capability in CPU
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMMXdetect(void);
|
||||
|
||||
// Force use of MMX off (or turn possible use back on)
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXoff(void);
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXon(void);
|
||||
|
||||
//
|
||||
// All routines return:
|
||||
// 0 OK
|
||||
// -1 Error (internal error, parameter error)
|
||||
//
|
||||
|
||||
// SDL_imageFilterAdd: D = saturation255(S1 + S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMean: D = S1/2 + S2/2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterSub: D = saturation0(S1 - S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterAbsDiff: D = | S1 - S2 |
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMult: D = saturation(S1 * S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
|
||||
unsigned int length);
|
||||
|
||||
// SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
|
||||
unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitAnd: D = S1 & S2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitOr: D = S1 | S2
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterBitNegation: D = !S
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length);
|
||||
|
||||
// SDL_imageFilterAddByte: D = saturation255(S + C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
|
||||
|
||||
// SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char C);
|
||||
|
||||
// SDL_imageFilterSubByte: D = saturation0(S - C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
|
||||
|
||||
// SDL_imageFilterShiftRight: D = saturation0(S >> N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterMultByByte: D = saturation255(S * C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
|
||||
|
||||
// SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N, unsigned char C);
|
||||
|
||||
// SDL_imageFilterShiftLeftByte: D = (S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char N);
|
||||
|
||||
// SDL_imageFilterShiftLeft: D = saturation255(S << N)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
|
||||
|
||||
// SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char T);
|
||||
|
||||
// SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length,
|
||||
unsigned char Tmin, unsigned char Tmax);
|
||||
|
||||
// SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin,
|
||||
int Cmax, int Nmin, int Nmax);
|
||||
|
||||
/* !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! */
|
||||
|
||||
// SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9Divide(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel, unsigned char Divisor);
|
||||
|
||||
// SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
|
||||
int columns, signed short *Kernel,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// SDL_imageFilterSobelX: Dij = saturation255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelX(unsigned char *Src, unsigned char *Dest, int rows, int columns);
|
||||
|
||||
// SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
|
||||
SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelXShiftRight(unsigned char *Src, unsigned char *Dest, int rows, int columns,
|
||||
unsigned char NRightShift);
|
||||
|
||||
// Align/restore stack to 32 byte boundary -- Functionality untested! --
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterAlignStack(void);
|
||||
SDL_IMAGEFILTER_SCOPE void SDL_imageFilterRestoreStack(void);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_imageFilter_h */
|
|
@ -0,0 +1,382 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keysym_h
|
||||
#define _SDL_keysym_h
|
||||
|
||||
/** What we really want is a mapping of every raw key on the keyboard.
|
||||
* To support international keyboards, we use the range 0xA1 - 0xFF
|
||||
* as international virtual keycodes. We'll follow in the footsteps of X11...
|
||||
* @brief The names of the keys
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/** @name ASCII mapped keysyms
|
||||
* The keyboard syms have been cleverly chosen to map to ASCII
|
||||
*/
|
||||
/*@{*/
|
||||
SDLK_UNKNOWN = 0,
|
||||
SDLK_FIRST = 0,
|
||||
SDLK_BACKSPACE = 8,
|
||||
SDLK_TAB = 9,
|
||||
SDLK_CLEAR = 12,
|
||||
SDLK_RETURN = 13,
|
||||
SDLK_PAUSE = 19,
|
||||
SDLK_ESCAPE = 27,
|
||||
SDLK_SPACE = 32,
|
||||
SDLK_EXCLAIM = 33,
|
||||
SDLK_QUOTEDBL = 34,
|
||||
SDLK_HASH = 35,
|
||||
SDLK_DOLLAR = 36,
|
||||
SDLK_AMPERSAND = 38,
|
||||
SDLK_QUOTE = 39,
|
||||
SDLK_LEFTPAREN = 40,
|
||||
SDLK_RIGHTPAREN = 41,
|
||||
SDLK_ASTERISK = 42,
|
||||
SDLK_PLUS = 43,
|
||||
SDLK_COMMA = 44,
|
||||
SDLK_MINUS = 45,
|
||||
SDLK_PERIOD = 46,
|
||||
SDLK_SLASH = 47,
|
||||
SDLK_0 = 48,
|
||||
SDLK_1 = 49,
|
||||
SDLK_2 = 50,
|
||||
SDLK_3 = 51,
|
||||
SDLK_4 = 52,
|
||||
SDLK_5 = 53,
|
||||
SDLK_6 = 54,
|
||||
SDLK_7 = 55,
|
||||
SDLK_8 = 56,
|
||||
SDLK_9 = 57,
|
||||
SDLK_COLON = 58,
|
||||
SDLK_SEMICOLON = 59,
|
||||
SDLK_LESS = 60,
|
||||
SDLK_EQUALS = 61,
|
||||
SDLK_GREATER = 62,
|
||||
SDLK_QUESTION = 63,
|
||||
SDLK_AT = 64,
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
SDLK_LEFTBRACKET = 91,
|
||||
SDLK_BACKSLASH = 92,
|
||||
SDLK_RIGHTBRACKET = 93,
|
||||
SDLK_CARET = 94,
|
||||
SDLK_UNDERSCORE = 95,
|
||||
SDLK_BACKQUOTE = 96,
|
||||
SDLK_a = 97,
|
||||
SDLK_b = 98,
|
||||
SDLK_c = 99,
|
||||
SDLK_d = 100,
|
||||
SDLK_e = 101,
|
||||
SDLK_f = 102,
|
||||
SDLK_g = 103,
|
||||
SDLK_h = 104,
|
||||
SDLK_i = 105,
|
||||
SDLK_j = 106,
|
||||
SDLK_k = 107,
|
||||
SDLK_l = 108,
|
||||
SDLK_m = 109,
|
||||
SDLK_n = 110,
|
||||
SDLK_o = 111,
|
||||
SDLK_p = 112,
|
||||
SDLK_q = 113,
|
||||
SDLK_r = 114,
|
||||
SDLK_s = 115,
|
||||
SDLK_t = 116,
|
||||
SDLK_u = 117,
|
||||
SDLK_v = 118,
|
||||
SDLK_w = 119,
|
||||
SDLK_x = 120,
|
||||
SDLK_y = 121,
|
||||
SDLK_z = 122,
|
||||
SDLK_DELETE = 127,
|
||||
/* End of ASCII mapped keysyms */
|
||||
/*@}*/
|
||||
|
||||
/** @name International keyboard syms */
|
||||
/*@{*/
|
||||
SDLK_WORLD_0 = 160, /* 0xA0 */
|
||||
SDLK_WORLD_1 = 161,
|
||||
SDLK_WORLD_2 = 162,
|
||||
SDLK_WORLD_3 = 163,
|
||||
SDLK_WORLD_4 = 164,
|
||||
SDLK_WORLD_5 = 165,
|
||||
SDLK_WORLD_6 = 166,
|
||||
SDLK_WORLD_7 = 167,
|
||||
SDLK_WORLD_8 = 168,
|
||||
SDLK_WORLD_9 = 169,
|
||||
SDLK_WORLD_10 = 170,
|
||||
SDLK_WORLD_11 = 171,
|
||||
SDLK_WORLD_12 = 172,
|
||||
SDLK_WORLD_13 = 173,
|
||||
SDLK_WORLD_14 = 174,
|
||||
SDLK_WORLD_15 = 175,
|
||||
SDLK_WORLD_16 = 176,
|
||||
SDLK_WORLD_17 = 177,
|
||||
SDLK_WORLD_18 = 178,
|
||||
SDLK_WORLD_19 = 179,
|
||||
SDLK_WORLD_20 = 180,
|
||||
SDLK_WORLD_21 = 181,
|
||||
SDLK_WORLD_22 = 182,
|
||||
SDLK_WORLD_23 = 183,
|
||||
SDLK_WORLD_24 = 184,
|
||||
SDLK_WORLD_25 = 185,
|
||||
SDLK_WORLD_26 = 186,
|
||||
SDLK_WORLD_27 = 187,
|
||||
SDLK_WORLD_28 = 188,
|
||||
SDLK_WORLD_29 = 189,
|
||||
SDLK_WORLD_30 = 190,
|
||||
SDLK_WORLD_31 = 191,
|
||||
SDLK_WORLD_32 = 192,
|
||||
SDLK_WORLD_33 = 193,
|
||||
SDLK_WORLD_34 = 194,
|
||||
SDLK_WORLD_35 = 195,
|
||||
SDLK_WORLD_36 = 196,
|
||||
SDLK_WORLD_37 = 197,
|
||||
SDLK_WORLD_38 = 198,
|
||||
SDLK_WORLD_39 = 199,
|
||||
SDLK_WORLD_40 = 200,
|
||||
SDLK_WORLD_41 = 201,
|
||||
SDLK_WORLD_42 = 202,
|
||||
SDLK_WORLD_43 = 203,
|
||||
SDLK_WORLD_44 = 204,
|
||||
SDLK_WORLD_45 = 205,
|
||||
SDLK_WORLD_46 = 206,
|
||||
SDLK_WORLD_47 = 207,
|
||||
SDLK_WORLD_48 = 208,
|
||||
SDLK_WORLD_49 = 209,
|
||||
SDLK_WORLD_50 = 210,
|
||||
SDLK_WORLD_51 = 211,
|
||||
SDLK_WORLD_52 = 212,
|
||||
SDLK_WORLD_53 = 213,
|
||||
SDLK_WORLD_54 = 214,
|
||||
SDLK_WORLD_55 = 215,
|
||||
SDLK_WORLD_56 = 216,
|
||||
SDLK_WORLD_57 = 217,
|
||||
SDLK_WORLD_58 = 218,
|
||||
SDLK_WORLD_59 = 219,
|
||||
SDLK_WORLD_60 = 220,
|
||||
SDLK_WORLD_61 = 221,
|
||||
SDLK_WORLD_62 = 222,
|
||||
SDLK_WORLD_63 = 223,
|
||||
SDLK_WORLD_64 = 224,
|
||||
SDLK_WORLD_65 = 225,
|
||||
SDLK_WORLD_66 = 226,
|
||||
SDLK_WORLD_67 = 227,
|
||||
SDLK_WORLD_68 = 228,
|
||||
SDLK_WORLD_69 = 229,
|
||||
SDLK_WORLD_70 = 230,
|
||||
SDLK_WORLD_71 = 231,
|
||||
SDLK_WORLD_72 = 232,
|
||||
SDLK_WORLD_73 = 233,
|
||||
SDLK_WORLD_74 = 234,
|
||||
SDLK_WORLD_75 = 235,
|
||||
SDLK_WORLD_76 = 236,
|
||||
SDLK_WORLD_77 = 237,
|
||||
SDLK_WORLD_78 = 238,
|
||||
SDLK_WORLD_79 = 239,
|
||||
SDLK_WORLD_80 = 240,
|
||||
SDLK_WORLD_81 = 241,
|
||||
SDLK_WORLD_82 = 242,
|
||||
SDLK_WORLD_83 = 243,
|
||||
SDLK_WORLD_84 = 244,
|
||||
SDLK_WORLD_85 = 245,
|
||||
SDLK_WORLD_86 = 246,
|
||||
SDLK_WORLD_87 = 247,
|
||||
SDLK_WORLD_88 = 248,
|
||||
SDLK_WORLD_89 = 249,
|
||||
SDLK_WORLD_90 = 250,
|
||||
SDLK_WORLD_91 = 251,
|
||||
SDLK_WORLD_92 = 252,
|
||||
SDLK_WORLD_93 = 253,
|
||||
SDLK_WORLD_94 = 254,
|
||||
SDLK_WORLD_95 = 255, /* 0xFF */
|
||||
/*@}*/
|
||||
|
||||
/** @name Numeric keypad */
|
||||
/*@{*/
|
||||
SDLK_KP0 = 256,
|
||||
SDLK_KP1 = 257,
|
||||
SDLK_KP2 = 258,
|
||||
SDLK_KP3 = 259,
|
||||
SDLK_KP4 = 260,
|
||||
SDLK_KP5 = 261,
|
||||
SDLK_KP6 = 262,
|
||||
SDLK_KP7 = 263,
|
||||
SDLK_KP8 = 264,
|
||||
SDLK_KP9 = 265,
|
||||
SDLK_KP_PERIOD = 266,
|
||||
SDLK_KP_DIVIDE = 267,
|
||||
SDLK_KP_MULTIPLY = 268,
|
||||
SDLK_KP_MINUS = 269,
|
||||
SDLK_KP_PLUS = 270,
|
||||
SDLK_KP_ENTER = 271,
|
||||
SDLK_KP_EQUALS = 272,
|
||||
/*@}*/
|
||||
|
||||
/** @name Arrows + Home/End pad */
|
||||
/*@{*/
|
||||
SDLK_UP = 273,
|
||||
SDLK_DOWN = 274,
|
||||
SDLK_RIGHT = 275,
|
||||
SDLK_LEFT = 276,
|
||||
SDLK_INSERT = 277,
|
||||
SDLK_HOME = 278,
|
||||
SDLK_END = 279,
|
||||
SDLK_PAGEUP = 280,
|
||||
SDLK_PAGEDOWN = 281,
|
||||
/*@}*/
|
||||
|
||||
/** @name Function keys */
|
||||
/*@{*/
|
||||
SDLK_F1 = 282,
|
||||
SDLK_F2 = 283,
|
||||
SDLK_F3 = 284,
|
||||
SDLK_F4 = 285,
|
||||
SDLK_F5 = 286,
|
||||
SDLK_F6 = 287,
|
||||
SDLK_F7 = 288,
|
||||
SDLK_F8 = 289,
|
||||
SDLK_F9 = 290,
|
||||
SDLK_F10 = 291,
|
||||
SDLK_F11 = 292,
|
||||
SDLK_F12 = 293,
|
||||
SDLK_F13 = 294,
|
||||
SDLK_F14 = 295,
|
||||
SDLK_F15 = 296,
|
||||
/*@}*/
|
||||
|
||||
/** @name Key state modifier keys */
|
||||
/*@{*/
|
||||
SDLK_NUMLOCK = 300,
|
||||
SDLK_CAPSLOCK = 301,
|
||||
SDLK_SCROLLOCK = 302,
|
||||
SDLK_RSHIFT = 303,
|
||||
SDLK_LSHIFT = 304,
|
||||
SDLK_RCTRL = 305,
|
||||
SDLK_LCTRL = 306,
|
||||
SDLK_RALT = 307,
|
||||
SDLK_LALT = 308,
|
||||
SDLK_RMETA = 309,
|
||||
SDLK_LMETA = 310,
|
||||
SDLK_LSUPER = 311, /**< Left "Windows" key */
|
||||
SDLK_RSUPER = 312, /**< Right "Windows" key */
|
||||
SDLK_MODE = 313, /**< "Alt Gr" key */
|
||||
SDLK_COMPOSE = 314, /**< Multi-key compose key */
|
||||
/*@}*/
|
||||
|
||||
/** @name Miscellaneous function keys */
|
||||
/*@{*/
|
||||
SDLK_HELP = 315,
|
||||
SDLK_PRINT = 316,
|
||||
SDLK_SYSREQ = 317,
|
||||
SDLK_BREAK = 318,
|
||||
SDLK_MENU = 319,
|
||||
SDLK_POWER = 320, /**< Power Macintosh power key */
|
||||
SDLK_EURO = 321, /**< Some european keyboards */
|
||||
SDLK_UNDO = 322, /**< Atari keyboard has Undo */
|
||||
/*@}*/
|
||||
|
||||
/* Add any other keys here */
|
||||
|
||||
///PRIZM KEYS
|
||||
|
||||
SDLK_PRZ_KEY_F1 = 360 ,
|
||||
SDLK_PRZ_KEY_F2 = 361 ,
|
||||
SDLK_PRZ_KEY_F3 = 362 ,
|
||||
SDLK_PRZ_KEY_F4 = 363 ,
|
||||
SDLK_PRZ_KEY_F5 = 364 ,
|
||||
SDLK_PRZ_KEY_F6 = 365 ,
|
||||
SDLK_PRZ_KEY_SHIFT = 366 ,
|
||||
SDLK_PRZ_KEY_OPTN = 367 ,
|
||||
SDLK_PRZ_KEY_VARS = 368 ,
|
||||
SDLK_PRZ_KEY_MENU = 369 ,
|
||||
SDLK_PRZ_KEY_LEFT = 370 ,
|
||||
SDLK_PRZ_KEY_UP = 371 ,
|
||||
SDLK_PRZ_KEY_ALPHA = 372 ,
|
||||
SDLK_PRZ_KEY_SQUARE = 373 ,
|
||||
SDLK_PRZ_KEY_POWER = 374 ,
|
||||
SDLK_PRZ_KEY_EXIT = 375 ,
|
||||
SDLK_PRZ_KEY_DOWN = 376 ,
|
||||
SDLK_PRZ_KEY_RIGHT = 377 ,
|
||||
SDLK_PRZ_KEY_XOT = 378 ,
|
||||
SDLK_PRZ_KEY_LOG = 379 ,
|
||||
SDLK_PRZ_KEY_LN = 380 ,
|
||||
SDLK_PRZ_KEY_SIN = 381 ,
|
||||
SDLK_PRZ_KEY_COS = 382 ,
|
||||
SDLK_PRZ_KEY_TAN = 383 ,
|
||||
SDLK_PRZ_KEY_FRAC = 384 ,
|
||||
SDLK_PRZ_KEY_FD = 385 ,
|
||||
SDLK_PRZ_KEY_LEFTP = 386 ,
|
||||
SDLK_PRZ_KEY_RIGHTP = 387 ,
|
||||
SDLK_PRZ_KEY_COMMA = 388 ,
|
||||
SDLK_PRZ_KEY_ARROW = 389 ,
|
||||
SDLK_PRZ_KEY_7 = 390 ,
|
||||
SDLK_PRZ_KEY_8 = 391 ,
|
||||
SDLK_PRZ_KEY_9 = 392 ,
|
||||
SDLK_PRZ_KEY_DEL = 393 ,
|
||||
SDLK_PRZ_KEY_4 = 394 ,
|
||||
SDLK_PRZ_KEY_5 = 395 ,
|
||||
SDLK_PRZ_KEY_6 = 396 ,
|
||||
SDLK_PRZ_KEY_MUL = 397 ,
|
||||
SDLK_PRZ_KEY_DIV = 398 ,
|
||||
SDLK_PRZ_KEY_1 = 399 ,
|
||||
SDLK_PRZ_KEY_2 = 400 ,
|
||||
SDLK_PRZ_KEY_3 = 401 ,
|
||||
SDLK_PRZ_KEY_ADD = 402 ,
|
||||
SDLK_PRZ_KEY_SUB = 403 ,
|
||||
SDLK_PRZ_KEY_0 = 404 ,
|
||||
SDLK_PRZ_KEY_DOT = 405 ,
|
||||
SDLK_PRZ_KEY_EXP = 406 ,
|
||||
SDLK_PRZ_KEY_NEG = 407 ,
|
||||
SDLK_PRZ_KEY_EXE = 408 ,
|
||||
SDLK_PRZ_KEY_ACON = 409 ,
|
||||
|
||||
|
||||
SDLK_LAST
|
||||
} SDLKey;
|
||||
|
||||
/** Enumeration of valid key mods (possibly OR'd together) */
|
||||
typedef enum
|
||||
{
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT= 0x0001,
|
||||
KMOD_RSHIFT= 0x0002,
|
||||
KMOD_LCTRL = 0x0040,
|
||||
KMOD_RCTRL = 0x0080,
|
||||
KMOD_LALT = 0x0100,
|
||||
KMOD_RALT = 0x0200,
|
||||
KMOD_LMETA = 0x0400,
|
||||
KMOD_RMETA = 0x0800,
|
||||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000
|
||||
} SDLMod;
|
||||
|
||||
#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
|
||||
#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
|
||||
#define KMOD_ALT (KMOD_LALT|KMOD_RALT)
|
||||
#define KMOD_META (KMOD_LMETA|KMOD_RMETA)
|
||||
|
||||
#endif /* _SDL_keysym_h */
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
|
||||
SDL_rotozoom.c: rotozoomer, zoomer and shrinker for 32bit or 8bit surfaces
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _SDL_rotozoom_h
|
||||
#define _SDL_rotozoom_h
|
||||
|
||||
#include <math.h>
|
||||
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.141592654
|
||||
#endif
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
/* ---- Defines */
|
||||
|
||||
/*!
|
||||
\brief Disable anti-aliasing (no smoothing).
|
||||
*/
|
||||
#define SMOOTHING_OFF 0
|
||||
|
||||
/*!
|
||||
\brief Enable anti-aliasing (smoothing).
|
||||
*/
|
||||
#define SMOOTHING_ON 1
|
||||
|
||||
/* ---- Function Prototypes */
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
|
||||
# define SDL_ROTOZOOM_SCOPE __declspec(dllexport)
|
||||
# else
|
||||
# ifdef LIBSDL_GFX_DLL_IMPORT
|
||||
# define SDL_ROTOZOOM_SCOPE __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef SDL_ROTOZOOM_SCOPE
|
||||
# define SDL_ROTOZOOM_SCOPE extern
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
Rotozoom functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurface(SDL_Surface * src, double angle, double zoom, int smooth);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *rotozoomSurfaceXY
|
||||
(SDL_Surface * src, double angle, double zoomx, double zoomy, int smooth);
|
||||
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSize(int width, int height, double angle, double zoom, int *dstwidth,
|
||||
int *dstheight);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void rotozoomSurfaceSizeXY
|
||||
(int width, int height, double angle, double zoomx, double zoomy,
|
||||
int *dstwidth, int *dstheight);
|
||||
|
||||
/*
|
||||
|
||||
Zooming functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *zoomSurface(SDL_Surface * src, double zoomx, double zoomy, int smooth);
|
||||
|
||||
SDL_ROTOZOOM_SCOPE void zoomSurfaceSize(int width, int height, double zoomx, double zoomy, int *dstwidth, int *dstheight);
|
||||
|
||||
/*
|
||||
|
||||
Shrinking functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface *shrinkSurface(SDL_Surface * src, int factorx, int factory);
|
||||
|
||||
/*
|
||||
|
||||
Specialized rotation functions
|
||||
|
||||
*/
|
||||
|
||||
SDL_ROTOZOOM_SCOPE SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns);
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SDL_rotozoom_h */
|
|
@ -31,6 +31,10 @@
|
|||
#include "SDL_stdinc.h"
|
||||
#include "SDL_error.h"
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "begin_code.h"
|
||||
/* Set up for C function definitions, even when using C++ */
|
||||
#ifdef __cplusplus
|
||||
|
@ -74,7 +78,7 @@ typedef struct SDL_RWops {
|
|||
} buffer;
|
||||
} win32io;
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#ifdef HAVE_STDIO_H
|
||||
struct {
|
||||
int autoclose;
|
||||
FILE *fp;
|
||||
|
@ -112,18 +116,28 @@ extern DECLSPEC void SDLCALL SDL_FreeRW(SDL_RWops *area);
|
|||
|
||||
/** @name Seek Reference Points */
|
||||
/*@{*/
|
||||
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */
|
||||
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */
|
||||
#define RW_SEEK_END 2 /**< Seek relative to the end of data */
|
||||
|
||||
|
||||
#ifdef HAVE_STDIO_H
|
||||
#define RW_SEEK_SET SEEK_SET /**< Seek from the beginning of data */
|
||||
#define RW_SEEK_CUR SEEK_CUR /**< Seek relative to current read point */
|
||||
#define RW_SEEK_END SEEK_END /**< Seek relative to the end of data */
|
||||
#else
|
||||
#define RW_SEEK_SET 0 /**< Seek from the beginning of data */
|
||||
#define RW_SEEK_CUR 1 /**< Seek relative to current read point */
|
||||
#define RW_SEEK_END 2 /**< Seek relative to the end of data */
|
||||
#endif
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
||||
/** @name Macros to easily read and write from an SDL_RWops structure */
|
||||
/*@{*/
|
||||
#define SDL_RWseek(ctx, offset, whence) (ctx)->seek(ctx, offset, whence)
|
||||
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
|
||||
#define SDL_RWtell(ctx) (ctx)->seek(ctx, 0, RW_SEEK_CUR)
|
||||
#define SDL_RWread(ctx, ptr, size, n) (ctx)->read(ctx, ptr, size, n)
|
||||
#define SDL_RWwrite(ctx, ptr, size, n) (ctx)->write(ctx, ptr, size, n)
|
||||
#define SDL_RWclose(ctx) (ctx)->close(ctx)
|
||||
#define SDL_RWclose(ctx) (ctx)->close(ctx)
|
||||
/*@}*/
|
||||
|
||||
/** @name Read an item of the specified endianness and return in native format */
|
|
@ -253,6 +253,62 @@ typedef enum {
|
|||
#define SDL_PHYSPAL 0x02
|
||||
/*@}*/
|
||||
|
||||
/* Public Casio PRIZM-specific stuff */
|
||||
#ifdef __CASIOPRIZM__
|
||||
|
||||
#define PRZ_FONT_NUMCHARS 256
|
||||
#define PRZ_FONT_WIDTH 8
|
||||
#define PRZ_FONT_HEIGHT 8
|
||||
|
||||
typedef struct cSDL_Font {
|
||||
SDL_Surface *chars[PRZ_FONT_NUMCHARS];
|
||||
Uint8 char_width[PRZ_FONT_NUMCHARS];
|
||||
int hspacing, vspacing;
|
||||
SDL_bool monospaced;
|
||||
} cSDL_Font;
|
||||
|
||||
cSDL_Font *cSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b);
|
||||
void cSDL_SetFontSpacing(cSDL_Font *font, int hspacing, int vspacing);
|
||||
void cSDL_EnableFontMonospaced(cSDL_Font *font, SDL_bool toggle);
|
||||
void cSDL_FreeFont(cSDL_Font *font);
|
||||
int cSDL_DrawString(SDL_Surface *surface, cSDL_Font *font,
|
||||
int x, int y, const char *format, ...);
|
||||
int cSDL_GetStringWidth(cSDL_Font *font, const char *s);
|
||||
int cSDL_GetStringHeight(cSDL_Font *font, const char *s);
|
||||
SDL_Surface *cSDL_LoadImage(Uint16 *data);
|
||||
int cSDL_EnableRelativePaths(char **argv);
|
||||
|
||||
#define PRZ_PIXEL_ADDR(origin, x, y, pitch, bpp) ((Uint8 *)origin + ((x) * (bpp)) + ((y) * (pitch)))
|
||||
|
||||
#define PXL(bpp) PRZ_PIXEL_ADDR(surface->pixels, x, y, surface->pitch, bpp)
|
||||
|
||||
static __inline__ __attribute__((always_inline))
|
||||
Uint32 cSDL_GetPixel(SDL_Surface *surface, int x, int y)
|
||||
{
|
||||
switch ( surface->format->BytesPerPixel ) {
|
||||
case 2: return(*(Uint16 *)PXL(2));
|
||||
case 1: return(*PXL(1));
|
||||
case 4: return(*(Uint32 *)PXL(4));
|
||||
case 3: SDL_Unsupported();
|
||||
default: return(0);
|
||||
}
|
||||
}
|
||||
|
||||
static __inline__ __attribute__((always_inline))
|
||||
void cSDL_SetPixel(SDL_Surface *surface, int x, int y, Uint32 color)
|
||||
{
|
||||
switch ( surface->format->BytesPerPixel ) {
|
||||
case 2: *(Uint16 *)PXL(2) = (Uint16)color; return;
|
||||
case 1: *PXL(1) = (Uint8)color; return;
|
||||
case 4: *(Uint32 *)PXL(4) = (Uint32)color; return;
|
||||
case 3: SDL_Unsupported();
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
|
||||
/**
|
||||
|
@ -314,11 +370,11 @@ extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, int bpp, Uint
|
|||
|
||||
/**
|
||||
* Return a pointer to an array of available screen dimensions for the
|
||||
* given format and video flags, sorted largest to smallest. Returns
|
||||
* NULL if there are no dimensions available for a particular format,
|
||||
* given format and video flags, sorted largest to smallest. Returns
|
||||
* NULL if there are no dimensions available for a particular format,
|
||||
* or (SDL_Rect **)-1 if any dimension is okay for the given format.
|
||||
*
|
||||
* If 'format' is NULL, the mode list will be for the format given
|
||||
* If 'format' is NULL, the mode list will be for the format given
|
||||
* by SDL_GetVideoInfo()->vfmt
|
||||
*/
|
||||
extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint32 flags);
|
||||
|
@ -347,21 +403,21 @@ extern DECLSPEC SDL_Rect ** SDLCALL SDL_ListModes(SDL_PixelFormat *format, Uint3
|
|||
* Otherwise, in 8-bit mode, SDL_SetColors() may not be able to set all
|
||||
* of the colors exactly the way they are requested, and you should look
|
||||
* at the video surface structure to determine the actual palette.
|
||||
* If SDL cannot guarantee that the colors you request can be set,
|
||||
* If SDL cannot guarantee that the colors you request can be set,
|
||||
* i.e. if the colormap is shared, then the video surface may be created
|
||||
* under emulation in system memory, overriding the SDL_HWSURFACE flag.
|
||||
*
|
||||
* If SDL_FULLSCREEN is set in 'flags', the SDL library will try to set
|
||||
* a fullscreen video mode. The default is to create a windowed mode
|
||||
* if the current graphics system has a window manager.
|
||||
* If the SDL library is able to set a fullscreen video mode, this flag
|
||||
* If the SDL library is able to set a fullscreen video mode, this flag
|
||||
* will be set in the surface that is returned.
|
||||
*
|
||||
* If SDL_DOUBLEBUF is set in 'flags', the SDL library will try to set up
|
||||
* two surfaces in video memory and swap between them when you call
|
||||
* two surfaces in video memory and swap between them when you call
|
||||
* SDL_Flip(). This is usually slower than the normal single-buffering
|
||||
* scheme, but prevents "tearing" artifacts caused by modifying video
|
||||
* memory while the monitor is refreshing. It should only be used by
|
||||
* scheme, but prevents "tearing" artifacts caused by modifying video
|
||||
* memory while the monitor is refreshing. It should only be used by
|
||||
* applications that redraw the entire screen on every update.
|
||||
*
|
||||
* If SDL_RESIZABLE is set in 'flags', the SDL library will allow the
|
||||
|
@ -416,7 +472,7 @@ extern DECLSPEC int SDLCALL SDL_Flip(SDL_Surface *screen);
|
|||
/**
|
||||
* Set the gamma correction for each of the color channels.
|
||||
* The gamma values range (approximately) between 0.1 and 10.0
|
||||
*
|
||||
*
|
||||
* If this function isn't supported directly by the hardware, it will
|
||||
* be emulated using gamma ramps, if available. If successful, this
|
||||
* function returns 0, otherwise it returns -1.
|
||||
|
@ -429,7 +485,7 @@ extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue);
|
|||
* representing a mapping between the input and output for that channel.
|
||||
* The input is the index into the array, and the output is the 16-bit
|
||||
* gamma value at that index, scaled to the output color precision.
|
||||
*
|
||||
*
|
||||
* You may pass NULL for any of the channels to leave it unchanged.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
* hardware does not support gamma translation, or otherwise fails,
|
||||
|
@ -439,7 +495,7 @@ extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 *red, const Uint16 *gr
|
|||
|
||||
/**
|
||||
* Retrieve the current values of the gamma translation tables.
|
||||
*
|
||||
*
|
||||
* You must pass in valid pointers to arrays of 256 16-bit quantities.
|
||||
* Any of the pointers may be NULL to ignore that channel.
|
||||
* If the call succeeds, it will return 0. If the display driver or
|
||||
|
@ -457,13 +513,13 @@ extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 *red, Uint16 *green, Uint16
|
|||
* determine the actual color palette.
|
||||
*
|
||||
* When 'surface' is the surface associated with the current display, the
|
||||
* display colormap will be updated with the requested colors. If
|
||||
* display colormap will be updated with the requested colors. If
|
||||
* SDL_HWPALETTE was set in SDL_SetVideoMode() flags, SDL_SetColors()
|
||||
* will always return 1, and the palette is guaranteed to be set the way
|
||||
* you desire, even if the window colormap has to be warped or run under
|
||||
* emulation.
|
||||
*/
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
|
||||
extern DECLSPEC int SDLCALL SDL_SetColors(SDL_Surface *surface,
|
||||
SDL_Color *colors, int firstcolor, int ncolors);
|
||||
|
||||
/**
|
||||
|
@ -537,7 +593,7 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|||
* two surfaces in video memory, SDL will try to place the surface in
|
||||
* video memory. If this isn't possible or if there is no hardware
|
||||
* acceleration available, the surface will be placed in system memory.
|
||||
* SDL_SRCALPHA means that the surface will be used for alpha blits and
|
||||
* SDL_SRCALPHA means that the surface will be used for alpha blits and
|
||||
* if the hardware supports hardware acceleration of alpha blits between
|
||||
* two surfaces in video memory, to place the surface in video memory
|
||||
* if possible, otherwise it will be placed in system memory.
|
||||
|
@ -551,7 +607,7 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel,
|
|||
* the SDL_HWSURFACE flag set, and will be created in system memory instead.
|
||||
*/
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurface
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
(Uint32 flags, int width, int height, int depth,
|
||||
Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask);
|
||||
/** @sa SDL_CreateRGBSurface */
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels,
|
||||
|
@ -562,8 +618,8 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
|||
/**
|
||||
* SDL_LockSurface() sets up a surface for directly accessing the pixels.
|
||||
* Between calls to SDL_LockSurface()/SDL_UnlockSurface(), you can write
|
||||
* to and read from 'surface->pixels', using the pixel format stored in
|
||||
* 'surface->format'. Once you are done accessing the surface, you should
|
||||
* to and read from 'surface->pixels', using the pixel format stored in
|
||||
* 'surface->format'. Once you are done accessing the surface, you should
|
||||
* use SDL_UnlockSurface() to release it.
|
||||
*
|
||||
* Not all surfaces require locking. If SDL_MUSTLOCK(surface) evaluates
|
||||
|
@ -571,7 +627,7 @@ extern DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface);
|
|||
* pixel format of the surface will not change. In particular, if the
|
||||
* SDL_HWSURFACE flag is not given when calling SDL_SetVideoMode(), you
|
||||
* will not need to lock the display surface before accessing it.
|
||||
*
|
||||
*
|
||||
* No operating system or library calls should be made between lock/unlock
|
||||
* pairs, as critical system locks may be held during this time.
|
||||
*
|
||||
|
@ -589,7 +645,9 @@ extern DECLSPEC void SDLCALL SDL_UnlockSurface(SDL_Surface *surface);
|
|||
extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP_RW(SDL_RWops *src, int freesrc);
|
||||
|
||||
/** Convenience macro -- load a surface from a file */
|
||||
#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
|
||||
//#define SDL_LoadBMP(file) SDL_LoadBMP_RW(SDL_RWFromFile(file, "rb"), 1)
|
||||
|
||||
extern DECLSPEC SDL_Surface * SDLCALL SDL_LoadBMP(const char *filename );
|
||||
|
||||
/**
|
||||
* Save a surface to a seekable SDL data source (memory or file.)
|
||||
|
@ -605,7 +663,7 @@ extern DECLSPEC int SDLCALL SDL_SaveBMP_RW
|
|||
|
||||
/**
|
||||
* Sets the color key (transparent pixel) in a blittable surface.
|
||||
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
|
||||
* If 'flag' is SDL_SRCCOLORKEY (optionally OR'd with SDL_RLEACCEL),
|
||||
* 'key' will be the transparent pixel in the source image of a blit.
|
||||
* SDL_RLEACCEL requests RLE acceleration for the surface if present,
|
||||
* and removes RLE acceleration if absent.
|
||||
|
@ -654,11 +712,11 @@ extern DECLSPEC SDL_bool SDLCALL SDL_SetClipRect(SDL_Surface *surface, const SDL
|
|||
extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface *surface, SDL_Rect *rect);
|
||||
|
||||
/**
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* Creates a new surface of the specified format, and then copies and maps
|
||||
* the given surface to it so the blit of the converted surface will be as
|
||||
* fast as possible. If this function fails, it returns NULL.
|
||||
*
|
||||
* The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* The 'flags' parameter is passed to SDL_CreateRGBSurface() and has those
|
||||
* semantics. You can also pass SDL_RLEACCEL in the flags parameter and
|
||||
* SDL will try to RLE accelerate colorkey and alpha blits in the resulting
|
||||
* surface.
|
||||
|
@ -690,7 +748,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
*
|
||||
* RGB->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value);
|
||||
|
@ -700,7 +758,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* both:
|
||||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* source colour key.
|
||||
*
|
||||
*
|
||||
* RGBA->RGBA:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source alpha channel) the RGB values;
|
||||
|
@ -711,8 +769,8 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* if SDL_SRCCOLORKEY set, only copy the pixels matching the
|
||||
* RGB values of the source colour key, ignoring alpha in the
|
||||
* comparison.
|
||||
*
|
||||
* RGB->RGB:
|
||||
*
|
||||
* RGB->RGB:
|
||||
* SDL_SRCALPHA set:
|
||||
* alpha-blend (using the source per-surface alpha value).
|
||||
* SDL_SRCALPHA not set:
|
||||
|
@ -722,7 +780,7 @@ extern DECLSPEC SDL_Surface * SDLCALL SDL_ConvertSurface
|
|||
* source colour key.
|
||||
*
|
||||
* If either of the surfaces were in video memory, and the blit returns -2,
|
||||
* the video memory was lost, so it should be reloaded with artwork and
|
||||
* the video memory was lost, so it should be reloaded with artwork and
|
||||
* re-blitted:
|
||||
* @code
|
||||
* while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) {
|
||||
|
@ -760,7 +818,7 @@ extern DECLSPEC int SDLCALL SDL_LowerBlit
|
|||
* The given rectangle is clipped to the destination surface clip area
|
||||
* and the final fill rectangle is saved in the passed in pointer.
|
||||
* If 'dstrect' is NULL, the whole surface will be filled with 'color'
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* The color should be a pixel of the format used by the surface, and
|
||||
* can be generated by the SDL_MapRGB() function.
|
||||
* This function returns 0 on success, or -1 on error.
|
||||
*/
|
||||
|
@ -813,7 +871,7 @@ extern DECLSPEC void SDLCALL SDL_UnlockYUVOverlay(SDL_Overlay *overlay);
|
|||
|
||||
/** Blit a video overlay to the display surface.
|
||||
* The contents of the video surface underneath the blit destination are
|
||||
* not defined.
|
||||
* not defined.
|
||||
* The width and height of the destination rectangle may be different from
|
||||
* that of the overlay, but currently only 2x scaling is supported.
|
||||
*/
|
||||
|
@ -908,7 +966,7 @@ extern DECLSPEC int SDLCALL SDL_WM_IconifyWindow(void);
|
|||
* If the display surface does not require locking before accessing
|
||||
* the pixel information, then the memory pointers will not change.
|
||||
*
|
||||
* If this function was able to toggle fullscreen mode (change from
|
||||
* If this function was able to toggle fullscreen mode (change from
|
||||
* running in a window to fullscreen, or vice-versa), it will return 1.
|
||||
* If it is not implemented, or fails, it returns 0.
|
||||
*
|
||||
|
@ -941,7 +999,7 @@ extern DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode);
|
|||
/** @internal Not in public API at the moment - do not use! */
|
||||
extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface *src, SDL_Rect *srcrect,
|
||||
SDL_Surface *dst, SDL_Rect *dstrect);
|
||||
|
||||
|
||||
/* Ends C function definitions when using C++ */
|
||||
#ifdef __cplusplus
|
||||
}
|
|
@ -23,7 +23,11 @@
|
|||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
#include "SDL_platform.h"
|
||||
#define FXCG50 1
|
||||
|
||||
#include "SDL/SDL_platform.h"
|
||||
|
||||
|
||||
|
||||
/* Add any platform that doesn't build using the configure system */
|
||||
#if defined(__DREAMCAST__)
|
||||
|
@ -41,11 +45,10 @@
|
|||
|
||||
/// Added a config_file for Casio fx-CG10/20/50/PRIZM/Graph 90+E
|
||||
#elif defined(__CASIOPRIZM__)
|
||||
#include "SDL_config_prizm.h"
|
||||
#include "SDL/SDL_config_prizm.h"
|
||||
|
||||
#else
|
||||
//#include "SDL_config_minimal.h"
|
||||
#include "SDL_config_prizm.h"
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
#endif /* _SDL_config_h */
|
||||
|
|
|
@ -19,22 +19,36 @@
|
|||
Sam Lantinga
|
||||
slouken@libsdl.org
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_nullvideo_h
|
||||
#define _SDL_nullvideo_h
|
||||
#ifndef _SDL_config_h
|
||||
#define _SDL_config_h
|
||||
|
||||
#include "../SDL_sysvideo.h"
|
||||
#define FXCG50 1
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_VideoDevice *this
|
||||
#include "SDL_platform.h"
|
||||
|
||||
|
||||
/* Private display data */
|
||||
|
||||
struct SDL_PrivateVideoData {
|
||||
int w, h;
|
||||
void *buffer;
|
||||
};
|
||||
/* 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"
|
||||
|
||||
#endif /* _SDL_nullvideo_h */
|
||||
/// Added a config_file for Casio fx-CG10/20/50/PRIZM/Graph 90+E
|
||||
#elif defined(__CASIOPRIZM__)
|
||||
#include "SDL_config_prizm.h"
|
||||
|
||||
#else
|
||||
#include "SDL_config_minimal.h"
|
||||
#endif /* platform config */
|
||||
|
||||
#endif /* _SDL_config_h */
|
|
@ -1,326 +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
|
||||
*/
|
||||
|
||||
#ifndef _SDL_keysym_h
|
||||
#define _SDL_keysym_h
|
||||
|
||||
/** What we really want is a mapping of every raw key on the keyboard.
|
||||
* To support international keyboards, we use the range 0xA1 - 0xFF
|
||||
* as international virtual keycodes. We'll follow in the footsteps of X11...
|
||||
* @brief The names of the keys
|
||||
*/
|
||||
typedef enum {
|
||||
/** @name ASCII mapped keysyms
|
||||
* The keyboard syms have been cleverly chosen to map to ASCII
|
||||
*/
|
||||
/*@{*/
|
||||
SDLK_UNKNOWN = 0,
|
||||
SDLK_FIRST = 0,
|
||||
SDLK_BACKSPACE = 8,
|
||||
SDLK_TAB = 9,
|
||||
SDLK_CLEAR = 12,
|
||||
SDLK_RETURN = 13,
|
||||
SDLK_PAUSE = 19,
|
||||
SDLK_ESCAPE = 27,
|
||||
SDLK_SPACE = 32,
|
||||
SDLK_EXCLAIM = 33,
|
||||
SDLK_QUOTEDBL = 34,
|
||||
SDLK_HASH = 35,
|
||||
SDLK_DOLLAR = 36,
|
||||
SDLK_AMPERSAND = 38,
|
||||
SDLK_QUOTE = 39,
|
||||
SDLK_LEFTPAREN = 40,
|
||||
SDLK_RIGHTPAREN = 41,
|
||||
SDLK_ASTERISK = 42,
|
||||
SDLK_PLUS = 43,
|
||||
SDLK_COMMA = 44,
|
||||
SDLK_MINUS = 45,
|
||||
SDLK_PERIOD = 46,
|
||||
SDLK_SLASH = 47,
|
||||
SDLK_0 = 48,
|
||||
SDLK_1 = 49,
|
||||
SDLK_2 = 50,
|
||||
SDLK_3 = 51,
|
||||
SDLK_4 = 52,
|
||||
SDLK_5 = 53,
|
||||
SDLK_6 = 54,
|
||||
SDLK_7 = 55,
|
||||
SDLK_8 = 56,
|
||||
SDLK_9 = 57,
|
||||
SDLK_COLON = 58,
|
||||
SDLK_SEMICOLON = 59,
|
||||
SDLK_LESS = 60,
|
||||
SDLK_EQUALS = 61,
|
||||
SDLK_GREATER = 62,
|
||||
SDLK_QUESTION = 63,
|
||||
SDLK_AT = 64,
|
||||
/*
|
||||
Skip uppercase letters
|
||||
*/
|
||||
SDLK_LEFTBRACKET = 91,
|
||||
SDLK_BACKSLASH = 92,
|
||||
SDLK_RIGHTBRACKET = 93,
|
||||
SDLK_CARET = 94,
|
||||
SDLK_UNDERSCORE = 95,
|
||||
SDLK_BACKQUOTE = 96,
|
||||
SDLK_a = 97,
|
||||
SDLK_b = 98,
|
||||
SDLK_c = 99,
|
||||
SDLK_d = 100,
|
||||
SDLK_e = 101,
|
||||
SDLK_f = 102,
|
||||
SDLK_g = 103,
|
||||
SDLK_h = 104,
|
||||
SDLK_i = 105,
|
||||
SDLK_j = 106,
|
||||
SDLK_k = 107,
|
||||
SDLK_l = 108,
|
||||
SDLK_m = 109,
|
||||
SDLK_n = 110,
|
||||
SDLK_o = 111,
|
||||
SDLK_p = 112,
|
||||
SDLK_q = 113,
|
||||
SDLK_r = 114,
|
||||
SDLK_s = 115,
|
||||
SDLK_t = 116,
|
||||
SDLK_u = 117,
|
||||
SDLK_v = 118,
|
||||
SDLK_w = 119,
|
||||
SDLK_x = 120,
|
||||
SDLK_y = 121,
|
||||
SDLK_z = 122,
|
||||
SDLK_DELETE = 127,
|
||||
/* End of ASCII mapped keysyms */
|
||||
/*@}*/
|
||||
|
||||
/** @name International keyboard syms */
|
||||
/*@{*/
|
||||
SDLK_WORLD_0 = 160, /* 0xA0 */
|
||||
SDLK_WORLD_1 = 161,
|
||||
SDLK_WORLD_2 = 162,
|
||||
SDLK_WORLD_3 = 163,
|
||||
SDLK_WORLD_4 = 164,
|
||||
SDLK_WORLD_5 = 165,
|
||||
SDLK_WORLD_6 = 166,
|
||||
SDLK_WORLD_7 = 167,
|
||||
SDLK_WORLD_8 = 168,
|
||||
SDLK_WORLD_9 = 169,
|
||||
SDLK_WORLD_10 = 170,
|
||||
SDLK_WORLD_11 = 171,
|
||||
SDLK_WORLD_12 = 172,
|
||||
SDLK_WORLD_13 = 173,
|
||||
SDLK_WORLD_14 = 174,
|
||||
SDLK_WORLD_15 = 175,
|
||||
SDLK_WORLD_16 = 176,
|
||||
SDLK_WORLD_17 = 177,
|
||||
SDLK_WORLD_18 = 178,
|
||||
SDLK_WORLD_19 = 179,
|
||||
SDLK_WORLD_20 = 180,
|
||||
SDLK_WORLD_21 = 181,
|
||||
SDLK_WORLD_22 = 182,
|
||||
SDLK_WORLD_23 = 183,
|
||||
SDLK_WORLD_24 = 184,
|
||||
SDLK_WORLD_25 = 185,
|
||||
SDLK_WORLD_26 = 186,
|
||||
SDLK_WORLD_27 = 187,
|
||||
SDLK_WORLD_28 = 188,
|
||||
SDLK_WORLD_29 = 189,
|
||||
SDLK_WORLD_30 = 190,
|
||||
SDLK_WORLD_31 = 191,
|
||||
SDLK_WORLD_32 = 192,
|
||||
SDLK_WORLD_33 = 193,
|
||||
SDLK_WORLD_34 = 194,
|
||||
SDLK_WORLD_35 = 195,
|
||||
SDLK_WORLD_36 = 196,
|
||||
SDLK_WORLD_37 = 197,
|
||||
SDLK_WORLD_38 = 198,
|
||||
SDLK_WORLD_39 = 199,
|
||||
SDLK_WORLD_40 = 200,
|
||||
SDLK_WORLD_41 = 201,
|
||||
SDLK_WORLD_42 = 202,
|
||||
SDLK_WORLD_43 = 203,
|
||||
SDLK_WORLD_44 = 204,
|
||||
SDLK_WORLD_45 = 205,
|
||||
SDLK_WORLD_46 = 206,
|
||||
SDLK_WORLD_47 = 207,
|
||||
SDLK_WORLD_48 = 208,
|
||||
SDLK_WORLD_49 = 209,
|
||||
SDLK_WORLD_50 = 210,
|
||||
SDLK_WORLD_51 = 211,
|
||||
SDLK_WORLD_52 = 212,
|
||||
SDLK_WORLD_53 = 213,
|
||||
SDLK_WORLD_54 = 214,
|
||||
SDLK_WORLD_55 = 215,
|
||||
SDLK_WORLD_56 = 216,
|
||||
SDLK_WORLD_57 = 217,
|
||||
SDLK_WORLD_58 = 218,
|
||||
SDLK_WORLD_59 = 219,
|
||||
SDLK_WORLD_60 = 220,
|
||||
SDLK_WORLD_61 = 221,
|
||||
SDLK_WORLD_62 = 222,
|
||||
SDLK_WORLD_63 = 223,
|
||||
SDLK_WORLD_64 = 224,
|
||||
SDLK_WORLD_65 = 225,
|
||||
SDLK_WORLD_66 = 226,
|
||||
SDLK_WORLD_67 = 227,
|
||||
SDLK_WORLD_68 = 228,
|
||||
SDLK_WORLD_69 = 229,
|
||||
SDLK_WORLD_70 = 230,
|
||||
SDLK_WORLD_71 = 231,
|
||||
SDLK_WORLD_72 = 232,
|
||||
SDLK_WORLD_73 = 233,
|
||||
SDLK_WORLD_74 = 234,
|
||||
SDLK_WORLD_75 = 235,
|
||||
SDLK_WORLD_76 = 236,
|
||||
SDLK_WORLD_77 = 237,
|
||||
SDLK_WORLD_78 = 238,
|
||||
SDLK_WORLD_79 = 239,
|
||||
SDLK_WORLD_80 = 240,
|
||||
SDLK_WORLD_81 = 241,
|
||||
SDLK_WORLD_82 = 242,
|
||||
SDLK_WORLD_83 = 243,
|
||||
SDLK_WORLD_84 = 244,
|
||||
SDLK_WORLD_85 = 245,
|
||||
SDLK_WORLD_86 = 246,
|
||||
SDLK_WORLD_87 = 247,
|
||||
SDLK_WORLD_88 = 248,
|
||||
SDLK_WORLD_89 = 249,
|
||||
SDLK_WORLD_90 = 250,
|
||||
SDLK_WORLD_91 = 251,
|
||||
SDLK_WORLD_92 = 252,
|
||||
SDLK_WORLD_93 = 253,
|
||||
SDLK_WORLD_94 = 254,
|
||||
SDLK_WORLD_95 = 255, /* 0xFF */
|
||||
/*@}*/
|
||||
|
||||
/** @name Numeric keypad */
|
||||
/*@{*/
|
||||
SDLK_KP0 = 256,
|
||||
SDLK_KP1 = 257,
|
||||
SDLK_KP2 = 258,
|
||||
SDLK_KP3 = 259,
|
||||
SDLK_KP4 = 260,
|
||||
SDLK_KP5 = 261,
|
||||
SDLK_KP6 = 262,
|
||||
SDLK_KP7 = 263,
|
||||
SDLK_KP8 = 264,
|
||||
SDLK_KP9 = 265,
|
||||
SDLK_KP_PERIOD = 266,
|
||||
SDLK_KP_DIVIDE = 267,
|
||||
SDLK_KP_MULTIPLY = 268,
|
||||
SDLK_KP_MINUS = 269,
|
||||
SDLK_KP_PLUS = 270,
|
||||
SDLK_KP_ENTER = 271,
|
||||
SDLK_KP_EQUALS = 272,
|
||||
/*@}*/
|
||||
|
||||
/** @name Arrows + Home/End pad */
|
||||
/*@{*/
|
||||
SDLK_UP = 273,
|
||||
SDLK_DOWN = 274,
|
||||
SDLK_RIGHT = 275,
|
||||
SDLK_LEFT = 276,
|
||||
SDLK_INSERT = 277,
|
||||
SDLK_HOME = 278,
|
||||
SDLK_END = 279,
|
||||
SDLK_PAGEUP = 280,
|
||||
SDLK_PAGEDOWN = 281,
|
||||
/*@}*/
|
||||
|
||||
/** @name Function keys */
|
||||
/*@{*/
|
||||
SDLK_F1 = 282,
|
||||
SDLK_F2 = 283,
|
||||
SDLK_F3 = 284,
|
||||
SDLK_F4 = 285,
|
||||
SDLK_F5 = 286,
|
||||
SDLK_F6 = 287,
|
||||
SDLK_F7 = 288,
|
||||
SDLK_F8 = 289,
|
||||
SDLK_F9 = 290,
|
||||
SDLK_F10 = 291,
|
||||
SDLK_F11 = 292,
|
||||
SDLK_F12 = 293,
|
||||
SDLK_F13 = 294,
|
||||
SDLK_F14 = 295,
|
||||
SDLK_F15 = 296,
|
||||
/*@}*/
|
||||
|
||||
/** @name Key state modifier keys */
|
||||
/*@{*/
|
||||
SDLK_NUMLOCK = 300,
|
||||
SDLK_CAPSLOCK = 301,
|
||||
SDLK_SCROLLOCK = 302,
|
||||
SDLK_RSHIFT = 303,
|
||||
SDLK_LSHIFT = 304,
|
||||
SDLK_RCTRL = 305,
|
||||
SDLK_LCTRL = 306,
|
||||
SDLK_RALT = 307,
|
||||
SDLK_LALT = 308,
|
||||
SDLK_RMETA = 309,
|
||||
SDLK_LMETA = 310,
|
||||
SDLK_LSUPER = 311, /**< Left "Windows" key */
|
||||
SDLK_RSUPER = 312, /**< Right "Windows" key */
|
||||
SDLK_MODE = 313, /**< "Alt Gr" key */
|
||||
SDLK_COMPOSE = 314, /**< Multi-key compose key */
|
||||
/*@}*/
|
||||
|
||||
/** @name Miscellaneous function keys */
|
||||
/*@{*/
|
||||
SDLK_HELP = 315,
|
||||
SDLK_PRINT = 316,
|
||||
SDLK_SYSREQ = 317,
|
||||
SDLK_BREAK = 318,
|
||||
SDLK_MENU = 319,
|
||||
SDLK_POWER = 320, /**< Power Macintosh power key */
|
||||
SDLK_EURO = 321, /**< Some european keyboards */
|
||||
SDLK_UNDO = 322, /**< Atari keyboard has Undo */
|
||||
/*@}*/
|
||||
|
||||
/* Add any other keys here */
|
||||
|
||||
SDLK_LAST
|
||||
} SDLKey;
|
||||
|
||||
/** Enumeration of valid key mods (possibly OR'd together) */
|
||||
typedef enum {
|
||||
KMOD_NONE = 0x0000,
|
||||
KMOD_LSHIFT= 0x0001,
|
||||
KMOD_RSHIFT= 0x0002,
|
||||
KMOD_LCTRL = 0x0040,
|
||||
KMOD_RCTRL = 0x0080,
|
||||
KMOD_LALT = 0x0100,
|
||||
KMOD_RALT = 0x0200,
|
||||
KMOD_LMETA = 0x0400,
|
||||
KMOD_RMETA = 0x0800,
|
||||
KMOD_NUM = 0x1000,
|
||||
KMOD_CAPS = 0x2000,
|
||||
KMOD_MODE = 0x4000,
|
||||
KMOD_RESERVED = 0x8000
|
||||
} SDLMod;
|
||||
|
||||
#define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL)
|
||||
#define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT)
|
||||
#define KMOD_ALT (KMOD_LALT|KMOD_RALT)
|
||||
#define KMOD_META (KMOD_LMETA|KMOD_RMETA)
|
||||
|
||||
#endif /* _SDL_keysym_h */
|
BIN
libSDL_prizm.a
BIN
libSDL_prizm.a
Binary file not shown.
31
src/SDL.c
31
src/SDL.c
|
@ -23,7 +23,7 @@
|
|||
|
||||
/* Initialization code for SDL */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "SDL/SDL.h"
|
||||
#include "SDL_fatal.h"
|
||||
#if !SDL_VIDEO_DISABLED
|
||||
#include "video/SDL_leaks.h"
|
||||
|
@ -33,6 +33,27 @@
|
|||
#include <pth.h>
|
||||
#endif
|
||||
|
||||
#include <gint/gint.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
void cSDL_LogToFile(const char *fmt, ... )
|
||||
{
|
||||
FILE * fp = fopen( "OutLog.txt", "a" );
|
||||
if (fp==NULL) return;
|
||||
|
||||
va_list args;
|
||||
va_start( args, fmt );
|
||||
|
||||
vfprintf( fp, fmt, args );
|
||||
fprintf( fp, "\n");
|
||||
|
||||
va_end( args );
|
||||
fclose( fp );
|
||||
}
|
||||
|
||||
|
||||
/* Initialization/Cleanup routines */
|
||||
#if !SDL_JOYSTICK_DISABLED
|
||||
extern int SDL_JoystickInit(void);
|
||||
|
@ -49,7 +70,7 @@ extern void SDL_TimerQuit(void);
|
|||
#endif
|
||||
|
||||
/* The current SDL version */
|
||||
static SDL_version version =
|
||||
static SDL_version version =
|
||||
{ SDL_MAJOR_VERSION, SDL_MINOR_VERSION, SDL_PATCHLEVEL };
|
||||
|
||||
/* The initialized subsystems */
|
||||
|
@ -228,7 +249,7 @@ void SDL_Quit(void)
|
|||
|
||||
/* Print the number of surfaces not freed */
|
||||
if ( surfaces_allocated != 0 ) {
|
||||
fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
|
||||
fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n",
|
||||
surfaces_allocated);
|
||||
}
|
||||
#endif
|
||||
|
@ -332,8 +353,8 @@ unsigned _System LibMain(unsigned hmod, unsigned termination)
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
BOOL APIENTRY _DllMainCRTStartup( HANDLE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved )
|
||||
{
|
||||
switch (ul_reason_for_call) {
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
/* Simple error handling in SDL */
|
||||
|
||||
#include "SDL_error.h"
|
||||
#include "SDL/SDL_error.h"
|
||||
#include "SDL_error_c.h"
|
||||
|
||||
/* Routine to get the thread-specific error variable */
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,179 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Get the name of the audio device we use for output */
|
||||
|
||||
#if SDL_AUDIO_DRIVER_BSD || SDL_AUDIO_DRIVER_OSS || SDL_AUDIO_DRIVER_SUNAUDIO
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
#ifndef _PATH_DEV_DSP
|
||||
#if defined(__NETBSD__) || defined(__OPENBSD__)
|
||||
#define _PATH_DEV_DSP "/dev/audio"
|
||||
#else
|
||||
#define _PATH_DEV_DSP "/dev/dsp"
|
||||
#endif
|
||||
#endif
|
||||
#ifndef _PATH_DEV_DSP24
|
||||
#define _PATH_DEV_DSP24 "/dev/sound/dsp"
|
||||
#endif
|
||||
#ifndef _PATH_DEV_AUDIO
|
||||
#define _PATH_DEV_AUDIO "/dev/audio"
|
||||
#endif
|
||||
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
char audiopath[1024];
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if ( ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) &&
|
||||
((audiodev=SDL_getenv("AUDIODEV")) == NULL) ) {
|
||||
if ( classic ) {
|
||||
audiodev = _PATH_DEV_AUDIO;
|
||||
} else {
|
||||
struct stat sb;
|
||||
|
||||
/* Added support for /dev/sound/\* in Linux 2.4 */
|
||||
if ( ((stat("/dev/sound", &sb) == 0) && S_ISDIR(sb.st_mode)) &&
|
||||
((stat(_PATH_DEV_DSP24, &sb) == 0) && S_ISCHR(sb.st_mode)) ) {
|
||||
audiodev = _PATH_DEV_DSP24;
|
||||
} else {
|
||||
audiodev = _PATH_DEV_DSP;
|
||||
}
|
||||
}
|
||||
}
|
||||
audio_fd = open(audiodev, flags, 0);
|
||||
|
||||
/* If the first open fails, look for other devices */
|
||||
if ( (audio_fd < 0) && (SDL_strlen(audiodev) < (sizeof(audiopath)-3)) ) {
|
||||
int exists, instance;
|
||||
struct stat sb;
|
||||
|
||||
instance = 1;
|
||||
do { /* Don't use errno ENOENT - it may not be thread-safe */
|
||||
SDL_snprintf(audiopath, SDL_arraysize(audiopath),
|
||||
"%s%d", audiodev, instance++);
|
||||
exists = 0;
|
||||
if ( stat(audiopath, &sb) == 0 ) {
|
||||
exists = 1;
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
}
|
||||
} while ( exists && (audio_fd < 0) );
|
||||
audiodev = audiopath;
|
||||
}
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy(path, audiodev, maxlen);
|
||||
path[maxlen-1] = '\0';
|
||||
}
|
||||
return(audio_fd);
|
||||
}
|
||||
|
||||
#elif SDL_AUDIO_DRIVER_PAUD
|
||||
|
||||
/* Get the name of the audio device we use for output */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
#include "SDL_audiodev_c.h"
|
||||
|
||||
#ifndef _PATH_DEV_DSP
|
||||
#define _PATH_DEV_DSP "/dev/%caud%c/%c"
|
||||
#endif
|
||||
|
||||
char devsettings[][3] =
|
||||
{
|
||||
{ 'p', '0', '1' }, { 'p', '0', '2' }, { 'p', '0', '3' }, { 'p', '0', '4' },
|
||||
{ 'p', '1', '1' }, { 'p', '1', '2' }, { 'p', '1', '3' }, { 'p', '1', '4' },
|
||||
{ 'p', '2', '1' }, { 'p', '2', '2' }, { 'p', '2', '3' }, { 'p', '2', '4' },
|
||||
{ 'p', '3', '1' }, { 'p', '3', '2' }, { 'p', '3', '3' }, { 'p', '3', '4' },
|
||||
{ 'b', '0', '1' }, { 'b', '0', '2' }, { 'b', '0', '3' }, { 'b', '0', '4' },
|
||||
{ 'b', '1', '1' }, { 'b', '1', '2' }, { 'b', '1', '3' }, { 'b', '1', '4' },
|
||||
{ 'b', '2', '1' }, { 'b', '2', '2' }, { 'b', '2', '3' }, { 'b', '2', '4' },
|
||||
{ 'b', '3', '1' }, { 'b', '3', '2' }, { 'b', '3', '3' }, { 'b', '3', '4' },
|
||||
{ '\0', '\0', '\0' }
|
||||
};
|
||||
|
||||
static int OpenUserDefinedDevice(char *path, int maxlen, int flags)
|
||||
{
|
||||
const char *audiodev;
|
||||
int audio_fd;
|
||||
|
||||
/* Figure out what our audio device is */
|
||||
if ((audiodev=SDL_getenv("SDL_PATH_DSP")) == NULL) {
|
||||
audiodev=SDL_getenv("AUDIODEV");
|
||||
}
|
||||
if ( audiodev == NULL ) {
|
||||
return -1;
|
||||
}
|
||||
audio_fd = open(audiodev, flags, 0);
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy(path, audiodev, maxlen);
|
||||
path[maxlen-1] = '\0';
|
||||
}
|
||||
return audio_fd;
|
||||
}
|
||||
|
||||
int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic)
|
||||
{
|
||||
struct stat sb;
|
||||
int audio_fd;
|
||||
char audiopath[1024];
|
||||
int cycle;
|
||||
|
||||
audio_fd = OpenUserDefinedDevice(path,maxlen,flags);
|
||||
if ( audio_fd != -1 ) {
|
||||
return audio_fd;
|
||||
}
|
||||
|
||||
cycle = 0;
|
||||
while( devsettings[cycle][0] != '\0' ) {
|
||||
SDL_snprintf( audiopath, SDL_arraysize(audiopath),
|
||||
_PATH_DEV_DSP,
|
||||
devsettings[cycle][0],
|
||||
devsettings[cycle][1],
|
||||
devsettings[cycle][2]);
|
||||
|
||||
if ( stat(audiopath, &sb) == 0 ) {
|
||||
audio_fd = open(audiopath, flags, 0);
|
||||
if ( audio_fd > 0 ) {
|
||||
if ( path != NULL ) {
|
||||
SDL_strlcpy( path, audiopath, maxlen );
|
||||
}
|
||||
return audio_fd;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif /* Audio driver selection */
|
|
@ -1,26 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Open the audio device, storing the pathname in 'path' */
|
||||
extern int SDL_OpenAudioPath(char *path, int maxlen, int flags, int classic);
|
||||
|
|
@ -1,264 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This provides the default mixing callback for the SDL audio routines */
|
||||
|
||||
#include "SDL_cpuinfo.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_sysaudio.h"
|
||||
#include "SDL_mixer_MMX.h"
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
#include "SDL_mixer_m68k.h"
|
||||
|
||||
/* This table is used to add two sound values together and pin
|
||||
* the value to avoid overflow. (used with permission from ARDI)
|
||||
* Changed to use 0xFE instead of 0xFF for better sound quality.
|
||||
*/
|
||||
static const Uint8 mix8[] =
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03,
|
||||
0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E,
|
||||
0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19,
|
||||
0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x2C, 0x2D, 0x2E, 0x2F,
|
||||
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A,
|
||||
0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45,
|
||||
0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
|
||||
0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B,
|
||||
0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66,
|
||||
0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
|
||||
0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C,
|
||||
0x7D, 0x7E, 0x7F, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
|
||||
0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F, 0x90, 0x91, 0x92,
|
||||
0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
|
||||
0x9E, 0x9F, 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8,
|
||||
0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB0, 0xB1, 0xB2, 0xB3,
|
||||
0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xBB, 0xBC, 0xBD, 0xBE,
|
||||
0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9,
|
||||
0xCA, 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4,
|
||||
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF,
|
||||
0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
|
||||
0xEB, 0xEC, 0xED, 0xEE, 0xEF, 0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5,
|
||||
0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE,
|
||||
0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE
|
||||
};
|
||||
|
||||
/* The volume ranges from 0 - 128 */
|
||||
#define ADJUST_VOLUME(s, v) (s = (s*v)/SDL_MIX_MAXVOLUME)
|
||||
#define ADJUST_VOLUME_U8(s, v) (s = (((s-128)*v)/SDL_MIX_MAXVOLUME)+128)
|
||||
|
||||
void SDL_MixAudio (Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
||||
{
|
||||
Uint16 format;
|
||||
|
||||
if ( volume == 0 ) {
|
||||
return;
|
||||
}
|
||||
/* Mix the user-level audio format */
|
||||
if ( current_audio ) {
|
||||
if ( current_audio->convert.needed ) {
|
||||
format = current_audio->convert.src_format;
|
||||
} else {
|
||||
format = current_audio->spec.format;
|
||||
}
|
||||
} else {
|
||||
/* HACK HACK HACK */
|
||||
format = AUDIO_S16;
|
||||
}
|
||||
switch (format) {
|
||||
|
||||
case AUDIO_U8: {
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_U8((char*)dst,(char*)src,(unsigned long)len,(long)volume,(char *)mix8);
|
||||
#else
|
||||
Uint8 src_sample;
|
||||
|
||||
while ( len-- ) {
|
||||
src_sample = *src;
|
||||
ADJUST_VOLUME_U8(src_sample, volume);
|
||||
*dst = mix8[*dst+src_sample];
|
||||
++dst;
|
||||
++src;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S8: {
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S8_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S8((char*)dst,(char*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
{
|
||||
Sint8 *dst8, *src8;
|
||||
Sint8 src_sample;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(8-1))-1);
|
||||
const int min_audioval = -(1<<(8-1));
|
||||
|
||||
src8 = (Sint8 *)src;
|
||||
dst8 = (Sint8 *)dst;
|
||||
while ( len-- ) {
|
||||
src_sample = *src8;
|
||||
ADJUST_VOLUME(src_sample, volume);
|
||||
dst_sample = *dst8 + src_sample;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
*dst8 = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
*dst8 = min_audioval;
|
||||
} else {
|
||||
*dst8 = dst_sample;
|
||||
}
|
||||
++dst8;
|
||||
++src8;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16LSB: {
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
if (SDL_HasMMX())
|
||||
{
|
||||
SDL_MixAudio_MMX_S16_VC((char*)dst,(char*)src,(unsigned int)len,(int)volume);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16LSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
{
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[1])<<8|src[0]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[1])<<8|dst[0]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIO_S16MSB: {
|
||||
#if defined(__GNUC__) && (defined(__m68k__) && !defined(__mcoldfire__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
SDL_MixAudio_m68k_S16MSB((short*)dst,(short*)src,(unsigned long)len,(long)volume);
|
||||
#else
|
||||
Sint16 src1, src2;
|
||||
int dst_sample;
|
||||
const int max_audioval = ((1<<(16-1))-1);
|
||||
const int min_audioval = -(1<<(16-1));
|
||||
|
||||
len /= 2;
|
||||
while ( len-- ) {
|
||||
src1 = ((src[0])<<8|src[1]);
|
||||
ADJUST_VOLUME(src1, volume);
|
||||
src2 = ((dst[0])<<8|dst[1]);
|
||||
src += 2;
|
||||
dst_sample = src1+src2;
|
||||
if ( dst_sample > max_audioval ) {
|
||||
dst_sample = max_audioval;
|
||||
} else
|
||||
if ( dst_sample < min_audioval ) {
|
||||
dst_sample = min_audioval;
|
||||
}
|
||||
dst[1] = dst_sample&0xFF;
|
||||
dst_sample >>= 8;
|
||||
dst[0] = dst_sample&0xFF;
|
||||
dst += 2;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
default: /* If this happens... FIXME! */
|
||||
SDL_SetError("SDL_MixAudio(): unknown audio format");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,207 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
|
||||
|
||||
/***********************************************
|
||||
* Mixing for 16 bit signed buffers
|
||||
***********************************************/
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char* dst,char* src,unsigned int size,int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
|
||||
" shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */
|
||||
|
||||
" jz .endS16\n"
|
||||
|
||||
" pxor %%mm0,%%mm0\n"
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS16:\n"
|
||||
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d */
|
||||
|
||||
" movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */
|
||||
|
||||
" movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */
|
||||
|
||||
/* pré charger le buffer dst dans mm7 */
|
||||
" movq (%0),%%mm7\n" /* mm7 = dst[0] */
|
||||
|
||||
/* multiplier par le volume */
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */
|
||||
" movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */
|
||||
|
||||
" pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
|
||||
" pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */
|
||||
|
||||
" punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */
|
||||
|
||||
" movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */
|
||||
" punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */
|
||||
|
||||
" punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */
|
||||
|
||||
" punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */
|
||||
|
||||
/* pré charger le buffer dst dans mm5 */
|
||||
" movq 8(%0),%%mm5\n" /* mm5 = dst[1] */
|
||||
|
||||
/* diviser par 128 */
|
||||
" psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */
|
||||
" add $16,%1\n"
|
||||
|
||||
" psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */
|
||||
|
||||
" psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */
|
||||
|
||||
/* mm1 = le sample avec le volume modifié */
|
||||
" packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */
|
||||
|
||||
" psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */
|
||||
" paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */
|
||||
|
||||
/* mm4 = le sample avec le volume modifié */
|
||||
" packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */
|
||||
" movq %%mm3,(%0)\n"
|
||||
|
||||
" paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */
|
||||
|
||||
" movq %%mm6,8(%0)\n"
|
||||
|
||||
" add $16,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS16\n"
|
||||
|
||||
" emms\n"
|
||||
|
||||
".endS16:\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////// */
|
||||
/* Mixing for 8 bit signed buffers */
|
||||
/*////////////////////////////////////////////// */
|
||||
|
||||
void SDL_MixAudio_MMX_S8(char* dst,char* src,unsigned int size,int volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
" movl %3,%%eax\n" /* eax = volume */
|
||||
|
||||
" movd %%eax,%%mm0\n"
|
||||
" movq %%mm0,%%mm1\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
" psllq $16,%%mm0\n"
|
||||
" por %%mm1,%%mm0\n"
|
||||
|
||||
" movl %2,%%edx\n" /* edx = size */
|
||||
" shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */
|
||||
|
||||
" cmp $0,%%edx\n"
|
||||
" je .endS8\n"
|
||||
|
||||
".align 8\n"
|
||||
" .mixloopS8:\n"
|
||||
|
||||
" pxor %%mm2,%%mm2\n" /* mm2 = 0 */
|
||||
" movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */
|
||||
|
||||
" movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */
|
||||
|
||||
/* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */
|
||||
" pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */
|
||||
|
||||
" punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */
|
||||
|
||||
" punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */
|
||||
" movq (%0),%%mm2\n" /* mm2 = destination */
|
||||
|
||||
" pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */
|
||||
" add $8,%1\n"
|
||||
|
||||
" pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */
|
||||
" psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */
|
||||
|
||||
" psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */
|
||||
|
||||
" paddsb %%mm2,%%mm3\n" /* add to destination buffer */
|
||||
|
||||
" movq %%mm3,(%0)\n" /* store back to ram */
|
||||
" add $8,%0\n"
|
||||
|
||||
" dec %%edx\n"
|
||||
|
||||
" jnz .mixloopS8\n"
|
||||
|
||||
".endS8:\n"
|
||||
" emms\n"
|
||||
:
|
||||
: "r" (dst), "r"(src),"m"(size),
|
||||
"m"(volume)
|
||||
: "eax","edx","memory"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,17 +0,0 @@
|
|||
/*
|
||||
headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
void SDL_MixAudio_MMX_S16(char* ,char* ,unsigned int ,int );
|
||||
void SDL_MixAudio_MMX_S8(char* ,char* ,unsigned int ,int );
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -1,183 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_mixer_MMX_VC.h"
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples
|
||||
// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
// Converted to Intel ASM notation by Cth
|
||||
// This code is licensed under the LGPL (see COPYING for details)
|
||||
//
|
||||
// Assumes buffer size in bytes is a multiple of 16
|
||||
// Assumes SDL_MIX_MAXVOLUME = 128
|
||||
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 16 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S16_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
{
|
||||
__asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst // edi = dst
|
||||
mov esi, src // esi = src
|
||||
mov eax, volume // eax = volume
|
||||
mov ebx, nSize // ebx = size
|
||||
shr ebx, 4 // process 16 bytes per iteration = 8 samples
|
||||
jz endS16
|
||||
|
||||
pxor mm0, mm0
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0 // mm0 = vol|vol|vol|vol
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS16:
|
||||
movq mm1, [esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d
|
||||
movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d
|
||||
movq mm4, [esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h
|
||||
// pre charger le buffer dst dans mm7
|
||||
movq mm7, [edi] //(%%edi),%%mm7\n" // mm7 = dst[0]"
|
||||
// multiplier par le volume
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v)
|
||||
movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h
|
||||
pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
pmulhw mm5, mm0 //%%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v)
|
||||
movq mm3, mm1 //%%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v)
|
||||
punpckhwd mm1, mm2 //%%mm2,%%mm1\n" // mm1 = a*v|b*v
|
||||
movq mm6, mm4 //%%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v)
|
||||
punpcklwd mm3, mm2 //%%mm2,%%mm3\n" // mm3 = c*v|d*v
|
||||
punpckhwd mm4, mm5 //%%mm5,%%mm4\n" // mm4 = e*f|f*v
|
||||
punpcklwd mm6, mm5 //%%mm5,%%mm6\n" // mm6 = g*v|h*v
|
||||
// pre charger le buffer dst dans mm5
|
||||
movq mm5, [edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1]
|
||||
// diviser par 128
|
||||
psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME
|
||||
add esi, 16 //$16,%%esi\n"
|
||||
psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128
|
||||
psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128
|
||||
// mm1 = le sample avec le volume modifie
|
||||
packssdw mm3, mm1 //%%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v)
|
||||
psrad mm6, 7 //$7,%%mm6\n" // mm6= g*v/128|h*v/128
|
||||
paddsw mm3, mm7 //%%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst
|
||||
// mm4 = le sample avec le volume modifie
|
||||
packssdw mm6, mm4 //%%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v)
|
||||
movq [edi], mm3 //%%mm3,(%%edi)\n"
|
||||
paddsw mm6, mm5 //%%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst
|
||||
movq [edi + 8], mm6 //%%mm6,8(%%edi)\n"
|
||||
add edi, 16 //$16,%%edi\n"
|
||||
dec ebx //%%ebx\n"
|
||||
jnz mixloopS16
|
||||
|
||||
endS16:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////
|
||||
// Mixing for 8 bit signed buffers
|
||||
////////////////////////////////////////////////
|
||||
|
||||
void SDL_MixAudio_MMX_S8_VC(char* dst,char* src,unsigned int nSize,int volume)
|
||||
{
|
||||
_asm
|
||||
{
|
||||
|
||||
push edi
|
||||
push esi
|
||||
push ebx
|
||||
|
||||
mov edi, dst //movl %0,%%edi // edi = dst
|
||||
mov esi, src //%1,%%esi // esi = src
|
||||
mov eax, volume //%3,%%eax // eax = volume
|
||||
|
||||
movd mm0, eax //%%eax,%%mm0
|
||||
movq mm1, mm0 //%%mm0,%%mm1
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
psllq mm0, 16 //$16,%%mm0
|
||||
por mm0, mm1 //%%mm1,%%mm0
|
||||
|
||||
mov ebx, nSize //%2,%%ebx // ebx = size
|
||||
shr ebx, 3 //$3,%%ebx // process 8 bytes per iteration = 8 samples
|
||||
cmp ebx, 0 //$0,%%ebx
|
||||
je endS8
|
||||
|
||||
#ifndef __WATCOMC__
|
||||
align 16
|
||||
#endif
|
||||
mixloopS8:
|
||||
pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0
|
||||
movq mm1, [esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h
|
||||
movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h
|
||||
// on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0
|
||||
pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000....
|
||||
punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d
|
||||
punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h
|
||||
movq mm2, [edi] //(%%edi),%%mm2 // mm2 = destination
|
||||
pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d
|
||||
add esi, 8 //$8,%%esi
|
||||
pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h
|
||||
psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128
|
||||
psraw mm3, 7 //$7,%%mm3 // mm3 = v*e/128|v*f/128|v*g/128|v*h/128
|
||||
packsswb mm3, mm1 //%%mm1,%%mm3 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128
|
||||
paddsb mm3, mm2 //%%mm2,%%mm3 // add to destination buffer
|
||||
movq [edi], mm3 //%%mm3,(%%edi) // store back to ram
|
||||
add edi, 8 //$8,%%edi
|
||||
dec ebx //%%ebx
|
||||
jnz mixloopS8
|
||||
|
||||
endS8:
|
||||
emms
|
||||
|
||||
pop ebx
|
||||
pop esi
|
||||
pop edi
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SDL_ASSEMBLY_ROUTINES */
|
||||
#endif /* SDL_BUGGY_MMX_MIXERS */
|
|
@ -1,38 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
|
||||
#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */
|
||||
#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES)
|
||||
/* headers for MMX assembler version of SDL_MixAudio
|
||||
Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr)
|
||||
Converted to Intel ASM notation by Cth
|
||||
This code is licensed under the LGPL (see COPYING for details)
|
||||
|
||||
Assumes buffer size in bytes is a multiple of 16
|
||||
Assumes SDL_MIX_MAXVOLUME = 128
|
||||
*/
|
||||
void SDL_MixAudio_MMX_S16_VC(char* ,char* ,unsigned int ,int );
|
||||
void SDL_MixAudio_MMX_S8_VC(char* ,char* ,unsigned int ,int );
|
||||
#endif
|
||||
#endif
|
|
@ -1,210 +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 Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along 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 "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst, char* src, long len, long volume, char* mix8)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_u8\n"
|
||||
"mixloop_u8:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" sub #128,%%d0\n" /* d0 -= 128 */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
" add #128,%%d0\n" /* d0 += 128 */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" moveb %4@(%%d0:w),%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_u8\n"
|
||||
"stoploop_u8:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S8(char* dst, char* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s8\n"
|
||||
" moveq #-128,%%d2\n"
|
||||
" moveq #127,%%d3\n"
|
||||
"mixloop_s8:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" moveq #0,%%d0\n"
|
||||
" moveq #0,%%d1\n"
|
||||
|
||||
" moveb %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" moveb %0@,%%d1\n" /* d1 = *dst */
|
||||
" asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" add %%d1,%%d0\n"
|
||||
|
||||
" cmp %%d2,%%d0\n"
|
||||
" bges lower_limit_s8\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s8:\n"
|
||||
|
||||
" cmp %%d3,%%d0\n"
|
||||
" bles upper_limit_s8\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s8:\n"
|
||||
" moveb %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s8\n"
|
||||
"stoploop_s8:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short* dst, short* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s16msb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16msb:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16msb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16msb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16msb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16msb:\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16msb\n"
|
||||
"stoploop_s16msb:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void SDL_MixAudio_m68k_S16LSB(short* dst, short* src, long len, long volume)
|
||||
{
|
||||
__asm__ __volatile__ (
|
||||
|
||||
"tstl %2\n"
|
||||
" beqs stoploop_s16lsb\n"
|
||||
" movel #-32768,%%d2\n"
|
||||
" movel #32767,%%d3\n"
|
||||
" lsrl #1,%2\n"
|
||||
"mixloop_s16lsb:\n"
|
||||
|
||||
/* Mix a sample */
|
||||
|
||||
" move %1@+,%%d0\n" /* d0 = *src++ */
|
||||
" rorw #8,%%d0\n"
|
||||
" muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */
|
||||
" move %0@,%%d1\n" /* d1 = *dst */
|
||||
" rorw #8,%%d1\n"
|
||||
" extl %%d1\n" /* extend d1 to 32 bits */
|
||||
" asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */
|
||||
|
||||
" addl %%d1,%%d0\n"
|
||||
|
||||
" cmpl %%d2,%%d0\n"
|
||||
" bges lower_limit_s16lsb\n"
|
||||
" move %%d2,%%d0\n"
|
||||
"lower_limit_s16lsb:\n"
|
||||
|
||||
" cmpl %%d3,%%d0\n"
|
||||
" bles upper_limit_s16lsb\n"
|
||||
" move %%d3,%%d0\n"
|
||||
"upper_limit_s16lsb:\n"
|
||||
" rorw #8,%%d0\n"
|
||||
" move %%d0,%0@+\n"
|
||||
|
||||
/* Loop till done */
|
||||
|
||||
" subql #1,%2\n"
|
||||
" bhis mixloop_s16lsb\n"
|
||||
"stoploop_s16lsb:\n"
|
||||
|
||||
: /* no return value */
|
||||
: /* input */
|
||||
"a"(dst), "a"(src), "d"(len), "d"(volume)
|
||||
: /* clobbered registers */
|
||||
"d0", "d1", "d2", "d3", "cc", "memory"
|
||||
);
|
||||
}
|
||||
#endif
|
|
@ -1,36 +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 Library General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Library General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Library General Public
|
||||
License along 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 "SDL_config.h"
|
||||
|
||||
/*
|
||||
m68k assembly mix routines
|
||||
|
||||
Patrice Mandin
|
||||
*/
|
||||
|
||||
#if (defined(__m68k__) && !defined(__mcoldfire__)) && defined(__GNUC__)
|
||||
void SDL_MixAudio_m68k_U8(char* dst,char* src, long len, long volume, char* mix8);
|
||||
void SDL_MixAudio_m68k_S8(char* dst,char* src, long len, long volume);
|
||||
|
||||
void SDL_MixAudio_m68k_S16MSB(short* dst,short* src, long len, long volume);
|
||||
void SDL_MixAudio_m68k_S16LSB(short* dst,short* src, long len, long volume);
|
||||
#endif
|
|
@ -1,596 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Microsoft WAVE file loading routines */
|
||||
|
||||
#include "SDL_audio.h"
|
||||
#include "SDL_wave.h"
|
||||
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk);
|
||||
|
||||
struct MS_ADPCM_decodestate {
|
||||
Uint8 hPredictor;
|
||||
Uint16 iDelta;
|
||||
Sint16 iSamp1;
|
||||
Sint16 iSamp2;
|
||||
};
|
||||
static struct MS_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
Uint16 wNumCoef;
|
||||
Sint16 aCoeff[7][2];
|
||||
/* * * */
|
||||
struct MS_ADPCM_decodestate state[2];
|
||||
} MS_ADPCM_state;
|
||||
|
||||
static int InitMS_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
int i;
|
||||
|
||||
/* Set the rogue pointer to the MS_ADPCM specific data */
|
||||
MS_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
MS_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
MS_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
MS_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
MS_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
MS_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
MS_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.wNumCoef = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
if ( MS_ADPCM_state.wNumCoef != 7 ) {
|
||||
SDL_SetError("Unknown set of MS_ADPCM coefficients");
|
||||
return(-1);
|
||||
}
|
||||
for ( i=0; i<MS_ADPCM_state.wNumCoef; ++i ) {
|
||||
MS_ADPCM_state.aCoeff[i][0] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
MS_ADPCM_state.aCoeff[i][1] = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 MS_ADPCM_nibble(struct MS_ADPCM_decodestate *state,
|
||||
Uint8 nybble, Sint16 *coeff)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const Sint32 adaptive[] = {
|
||||
230, 230, 230, 230, 307, 409, 512, 614,
|
||||
768, 614, 512, 409, 307, 230, 230, 230
|
||||
};
|
||||
Sint32 new_sample, delta;
|
||||
|
||||
new_sample = ((state->iSamp1 * coeff[0]) +
|
||||
(state->iSamp2 * coeff[1]))/256;
|
||||
if ( nybble & 0x08 ) {
|
||||
new_sample += state->iDelta * (nybble-0x10);
|
||||
} else {
|
||||
new_sample += state->iDelta * nybble;
|
||||
}
|
||||
if ( new_sample < min_audioval ) {
|
||||
new_sample = min_audioval;
|
||||
} else
|
||||
if ( new_sample > max_audioval ) {
|
||||
new_sample = max_audioval;
|
||||
}
|
||||
delta = ((Sint32)state->iDelta * adaptive[nybble])/256;
|
||||
if ( delta < 16 ) {
|
||||
delta = 16;
|
||||
}
|
||||
state->iDelta = (Uint16)delta;
|
||||
state->iSamp2 = state->iSamp1;
|
||||
state->iSamp1 = (Sint16)new_sample;
|
||||
return(new_sample);
|
||||
}
|
||||
|
||||
static int MS_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct MS_ADPCM_decodestate *state[2];
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
Sint8 nybble, stereo;
|
||||
Sint16 *coeff[2];
|
||||
Sint32 new_sample;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/MS_ADPCM_state.wavefmt.blockalign) *
|
||||
MS_ADPCM_state.wSamplesPerBlock*
|
||||
MS_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
stereo = (MS_ADPCM_state.wavefmt.channels == 2);
|
||||
state[0] = &MS_ADPCM_state.state[0];
|
||||
state[1] = &MS_ADPCM_state.state[stereo];
|
||||
while ( encoded_len >= MS_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
state[0]->hPredictor = *encoded++;
|
||||
if ( stereo ) {
|
||||
state[1]->hPredictor = *encoded++;
|
||||
}
|
||||
state[0]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iDelta = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp1 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
state[0]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
if ( stereo ) {
|
||||
state[1]->iSamp2 = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += sizeof(Sint16);
|
||||
}
|
||||
coeff[0] = MS_ADPCM_state.aCoeff[state[0]->hPredictor];
|
||||
coeff[1] = MS_ADPCM_state.aCoeff[state[1]->hPredictor];
|
||||
|
||||
/* Store the two initial samples we start with */
|
||||
decoded[0] = state[0]->iSamp2&0xFF;
|
||||
decoded[1] = state[0]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp2&0xFF;
|
||||
decoded[1] = state[1]->iSamp2>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
decoded[0] = state[0]->iSamp1&0xFF;
|
||||
decoded[1] = state[0]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
if ( stereo ) {
|
||||
decoded[0] = state[1]->iSamp1&0xFF;
|
||||
decoded[1] = state[1]->iSamp1>>8;
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (MS_ADPCM_state.wSamplesPerBlock-2)*
|
||||
MS_ADPCM_state.wavefmt.channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = MS_ADPCM_nibble(state[0],nybble,coeff[0]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = MS_ADPCM_nibble(state[1],nybble,coeff[1]);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2;
|
||||
|
||||
++encoded;
|
||||
samplesleft -= 2;
|
||||
}
|
||||
encoded_len -= MS_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
struct IMA_ADPCM_decodestate {
|
||||
Sint32 sample;
|
||||
Sint8 index;
|
||||
};
|
||||
static struct IMA_ADPCM_decoder {
|
||||
WaveFMT wavefmt;
|
||||
Uint16 wSamplesPerBlock;
|
||||
/* * * */
|
||||
struct IMA_ADPCM_decodestate state[2];
|
||||
} IMA_ADPCM_state;
|
||||
|
||||
static int InitIMA_ADPCM(WaveFMT *format)
|
||||
{
|
||||
Uint8 *rogue_feel;
|
||||
|
||||
/* Set the rogue pointer to the IMA_ADPCM specific data */
|
||||
IMA_ADPCM_state.wavefmt.encoding = SDL_SwapLE16(format->encoding);
|
||||
IMA_ADPCM_state.wavefmt.channels = SDL_SwapLE16(format->channels);
|
||||
IMA_ADPCM_state.wavefmt.frequency = SDL_SwapLE32(format->frequency);
|
||||
IMA_ADPCM_state.wavefmt.byterate = SDL_SwapLE32(format->byterate);
|
||||
IMA_ADPCM_state.wavefmt.blockalign = SDL_SwapLE16(format->blockalign);
|
||||
IMA_ADPCM_state.wavefmt.bitspersample =
|
||||
SDL_SwapLE16(format->bitspersample);
|
||||
rogue_feel = (Uint8 *)format+sizeof(*format);
|
||||
if ( sizeof(*format) == 16 ) {
|
||||
rogue_feel += sizeof(Uint16);
|
||||
}
|
||||
IMA_ADPCM_state.wSamplesPerBlock = ((rogue_feel[1]<<8)|rogue_feel[0]);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static Sint32 IMA_ADPCM_nibble(struct IMA_ADPCM_decodestate *state,Uint8 nybble)
|
||||
{
|
||||
const Sint32 max_audioval = ((1<<(16-1))-1);
|
||||
const Sint32 min_audioval = -(1<<(16-1));
|
||||
const int index_table[16] = {
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8,
|
||||
-1, -1, -1, -1,
|
||||
2, 4, 6, 8
|
||||
};
|
||||
const Sint32 step_table[89] = {
|
||||
7, 8, 9, 10, 11, 12, 13, 14, 16, 17, 19, 21, 23, 25, 28, 31,
|
||||
34, 37, 41, 45, 50, 55, 60, 66, 73, 80, 88, 97, 107, 118, 130,
|
||||
143, 157, 173, 190, 209, 230, 253, 279, 307, 337, 371, 408,
|
||||
449, 494, 544, 598, 658, 724, 796, 876, 963, 1060, 1166, 1282,
|
||||
1411, 1552, 1707, 1878, 2066, 2272, 2499, 2749, 3024, 3327,
|
||||
3660, 4026, 4428, 4871, 5358, 5894, 6484, 7132, 7845, 8630,
|
||||
9493, 10442, 11487, 12635, 13899, 15289, 16818, 18500, 20350,
|
||||
22385, 24623, 27086, 29794, 32767
|
||||
};
|
||||
Sint32 delta, step;
|
||||
|
||||
/* Compute difference and new sample value */
|
||||
step = step_table[state->index];
|
||||
delta = step >> 3;
|
||||
if ( nybble & 0x04 ) delta += step;
|
||||
if ( nybble & 0x02 ) delta += (step >> 1);
|
||||
if ( nybble & 0x01 ) delta += (step >> 2);
|
||||
if ( nybble & 0x08 ) delta = -delta;
|
||||
state->sample += delta;
|
||||
|
||||
/* Update index value */
|
||||
state->index += index_table[nybble];
|
||||
if ( state->index > 88 ) {
|
||||
state->index = 88;
|
||||
} else
|
||||
if ( state->index < 0 ) {
|
||||
state->index = 0;
|
||||
}
|
||||
|
||||
/* Clamp output sample */
|
||||
if ( state->sample > max_audioval ) {
|
||||
state->sample = max_audioval;
|
||||
} else
|
||||
if ( state->sample < min_audioval ) {
|
||||
state->sample = min_audioval;
|
||||
}
|
||||
return(state->sample);
|
||||
}
|
||||
|
||||
/* Fill the decode buffer with a channel block of data (8 samples) */
|
||||
static void Fill_IMA_ADPCM_block(Uint8 *decoded, Uint8 *encoded,
|
||||
int channel, int numchannels, struct IMA_ADPCM_decodestate *state)
|
||||
{
|
||||
int i;
|
||||
Sint8 nybble;
|
||||
Sint32 new_sample;
|
||||
|
||||
decoded += (channel * 2);
|
||||
for ( i=0; i<4; ++i ) {
|
||||
nybble = (*encoded)&0x0F;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
nybble = (*encoded)>>4;
|
||||
new_sample = IMA_ADPCM_nibble(state, nybble);
|
||||
decoded[0] = new_sample&0xFF;
|
||||
new_sample >>= 8;
|
||||
decoded[1] = new_sample&0xFF;
|
||||
decoded += 2 * numchannels;
|
||||
|
||||
++encoded;
|
||||
}
|
||||
}
|
||||
|
||||
static int IMA_ADPCM_decode(Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
struct IMA_ADPCM_decodestate *state;
|
||||
Uint8 *freeable, *encoded, *decoded;
|
||||
Sint32 encoded_len, samplesleft;
|
||||
unsigned int c, channels;
|
||||
|
||||
/* Check to make sure we have enough variables in the state array */
|
||||
channels = IMA_ADPCM_state.wavefmt.channels;
|
||||
if ( channels > SDL_arraysize(IMA_ADPCM_state.state) ) {
|
||||
SDL_SetError("IMA ADPCM decoder can only handle %d channels",
|
||||
SDL_arraysize(IMA_ADPCM_state.state));
|
||||
return(-1);
|
||||
}
|
||||
state = IMA_ADPCM_state.state;
|
||||
|
||||
/* Allocate the proper sized output buffer */
|
||||
encoded_len = *audio_len;
|
||||
encoded = *audio_buf;
|
||||
freeable = *audio_buf;
|
||||
*audio_len = (encoded_len/IMA_ADPCM_state.wavefmt.blockalign) *
|
||||
IMA_ADPCM_state.wSamplesPerBlock*
|
||||
IMA_ADPCM_state.wavefmt.channels*sizeof(Sint16);
|
||||
*audio_buf = (Uint8 *)SDL_malloc(*audio_len);
|
||||
if ( *audio_buf == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
decoded = *audio_buf;
|
||||
|
||||
/* Get ready... Go! */
|
||||
while ( encoded_len >= IMA_ADPCM_state.wavefmt.blockalign ) {
|
||||
/* Grab the initial information for this block */
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
/* Fill the state information for this block */
|
||||
state[c].sample = ((encoded[1]<<8)|encoded[0]);
|
||||
encoded += 2;
|
||||
if ( state[c].sample & 0x8000 ) {
|
||||
state[c].sample -= 0x10000;
|
||||
}
|
||||
state[c].index = *encoded++;
|
||||
/* Reserved byte in buffer header, should be 0 */
|
||||
if ( *encoded++ != 0 ) {
|
||||
/* Uh oh, corrupt data? Buggy code? */;
|
||||
}
|
||||
|
||||
/* Store the initial sample we start with */
|
||||
decoded[0] = (Uint8)(state[c].sample&0xFF);
|
||||
decoded[1] = (Uint8)(state[c].sample>>8);
|
||||
decoded += 2;
|
||||
}
|
||||
|
||||
/* Decode and store the other samples in this block */
|
||||
samplesleft = (IMA_ADPCM_state.wSamplesPerBlock-1)*channels;
|
||||
while ( samplesleft > 0 ) {
|
||||
for ( c=0; c<channels; ++c ) {
|
||||
Fill_IMA_ADPCM_block(decoded, encoded,
|
||||
c, channels, &state[c]);
|
||||
encoded += 4;
|
||||
samplesleft -= 8;
|
||||
}
|
||||
decoded += (channels * 8 * 2);
|
||||
}
|
||||
encoded_len -= IMA_ADPCM_state.wavefmt.blockalign;
|
||||
}
|
||||
SDL_free(freeable);
|
||||
return(0);
|
||||
}
|
||||
|
||||
SDL_AudioSpec * SDL_LoadWAV_RW (SDL_RWops *src, int freesrc,
|
||||
SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
|
||||
{
|
||||
int was_error;
|
||||
Chunk chunk;
|
||||
int lenread;
|
||||
int MS_ADPCM_encoded, IMA_ADPCM_encoded;
|
||||
int samplesize;
|
||||
|
||||
/* WAV magic header */
|
||||
Uint32 RIFFchunk;
|
||||
Uint32 wavelen = 0;
|
||||
Uint32 WAVEmagic;
|
||||
Uint32 headerDiff = 0;
|
||||
|
||||
/* FMT chunk */
|
||||
WaveFMT *format = NULL;
|
||||
|
||||
/* Make sure we are passed a valid data source */
|
||||
was_error = 0;
|
||||
if ( src == NULL ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Check the magic header */
|
||||
RIFFchunk = SDL_ReadLE32(src);
|
||||
wavelen = SDL_ReadLE32(src);
|
||||
if ( wavelen == WAVE ) { /* The RIFFchunk has already been read */
|
||||
WAVEmagic = wavelen;
|
||||
wavelen = RIFFchunk;
|
||||
RIFFchunk = RIFF;
|
||||
} else {
|
||||
WAVEmagic = SDL_ReadLE32(src);
|
||||
}
|
||||
if ( (RIFFchunk != RIFF) || (WAVEmagic != WAVE) ) {
|
||||
SDL_SetError("Unrecognized file type (not WAVE)");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
headerDiff += sizeof(Uint32); /* for WAVE */
|
||||
|
||||
/* Read the audio data format chunk */
|
||||
chunk.data = NULL;
|
||||
do {
|
||||
if ( chunk.data != NULL ) {
|
||||
SDL_free(chunk.data);
|
||||
chunk.data = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
/* 2 Uint32's for chunk header+len, plus the lenread */
|
||||
headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( (chunk.magic == FACT) || (chunk.magic == LIST) );
|
||||
|
||||
/* Decode the audio data format */
|
||||
format = (WaveFMT *)chunk.data;
|
||||
if ( chunk.magic != FMT ) {
|
||||
SDL_SetError("Complex WAVE files not supported");
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = IMA_ADPCM_encoded = 0;
|
||||
switch (SDL_SwapLE16(format->encoding)) {
|
||||
case PCM_CODE:
|
||||
/* We can understand this */
|
||||
break;
|
||||
case MS_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitMS_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
MS_ADPCM_encoded = 1;
|
||||
break;
|
||||
case IMA_ADPCM_CODE:
|
||||
/* Try to understand this */
|
||||
if ( InitIMA_ADPCM(format) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
IMA_ADPCM_encoded = 1;
|
||||
break;
|
||||
case MP3_CODE:
|
||||
SDL_SetError("MPEG Layer 3 data not supported",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
default:
|
||||
SDL_SetError("Unknown WAVE data format: 0x%.4x",
|
||||
SDL_SwapLE16(format->encoding));
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
SDL_memset(spec, 0, (sizeof *spec));
|
||||
spec->freq = SDL_SwapLE32(format->frequency);
|
||||
switch (SDL_SwapLE16(format->bitspersample)) {
|
||||
case 4:
|
||||
if ( MS_ADPCM_encoded || IMA_ADPCM_encoded ) {
|
||||
spec->format = AUDIO_S16;
|
||||
} else {
|
||||
was_error = 1;
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
spec->format = AUDIO_U8;
|
||||
break;
|
||||
case 16:
|
||||
spec->format = AUDIO_S16;
|
||||
break;
|
||||
default:
|
||||
was_error = 1;
|
||||
break;
|
||||
}
|
||||
if ( was_error ) {
|
||||
SDL_SetError("Unknown %d-bit PCM data format",
|
||||
SDL_SwapLE16(format->bitspersample));
|
||||
goto done;
|
||||
}
|
||||
spec->channels = (Uint8)SDL_SwapLE16(format->channels);
|
||||
spec->samples = 4096; /* Good default buffer size */
|
||||
|
||||
/* Read the audio data chunk */
|
||||
*audio_buf = NULL;
|
||||
do {
|
||||
if ( *audio_buf != NULL ) {
|
||||
SDL_free(*audio_buf);
|
||||
*audio_buf = NULL;
|
||||
}
|
||||
lenread = ReadChunk(src, &chunk);
|
||||
if ( lenread < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
*audio_len = lenread;
|
||||
*audio_buf = chunk.data;
|
||||
if(chunk.magic != DATA) headerDiff += lenread + 2 * sizeof(Uint32);
|
||||
} while ( chunk.magic != DATA );
|
||||
headerDiff += 2 * sizeof(Uint32); /* for the data chunk and len */
|
||||
|
||||
if ( MS_ADPCM_encoded ) {
|
||||
if ( MS_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if ( IMA_ADPCM_encoded ) {
|
||||
if ( IMA_ADPCM_decode(audio_buf, audio_len) < 0 ) {
|
||||
was_error = 1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
/* Don't return a buffer that isn't a multiple of samplesize */
|
||||
samplesize = ((spec->format & 0xFF)/8)*spec->channels;
|
||||
*audio_len &= ~(samplesize-1);
|
||||
|
||||
done:
|
||||
if ( format != NULL ) {
|
||||
SDL_free(format);
|
||||
}
|
||||
if ( src ) {
|
||||
if ( freesrc ) {
|
||||
SDL_RWclose(src);
|
||||
} else {
|
||||
/* seek to the end of the file (given by the RIFF chunk) */
|
||||
SDL_RWseek(src, wavelen - chunk.length - headerDiff, RW_SEEK_CUR);
|
||||
}
|
||||
}
|
||||
if ( was_error ) {
|
||||
spec = NULL;
|
||||
}
|
||||
return(spec);
|
||||
}
|
||||
|
||||
/* Since the WAV memory is allocated in the shared library, it must also
|
||||
be freed here. (Necessary under Win32, VC++)
|
||||
*/
|
||||
void SDL_FreeWAV(Uint8 *audio_buf)
|
||||
{
|
||||
if ( audio_buf != NULL ) {
|
||||
SDL_free(audio_buf);
|
||||
}
|
||||
}
|
||||
|
||||
static int ReadChunk(SDL_RWops *src, Chunk *chunk)
|
||||
{
|
||||
chunk->magic = SDL_ReadLE32(src);
|
||||
chunk->length = SDL_ReadLE32(src);
|
||||
chunk->data = (Uint8 *)SDL_malloc(chunk->length);
|
||||
if ( chunk->data == NULL ) {
|
||||
SDL_Error(SDL_ENOMEM);
|
||||
return(-1);
|
||||
}
|
||||
if ( SDL_RWread(src, chunk->data, chunk->length, 1) != 1 ) {
|
||||
SDL_Error(SDL_EFREAD);
|
||||
SDL_free(chunk->data);
|
||||
chunk->data = NULL;
|
||||
return(-1);
|
||||
}
|
||||
return(chunk->length);
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is SDL_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"
|
||||
|
||||
/* WAVE files are little-endian */
|
||||
|
||||
/*******************************************/
|
||||
/* Define values for Microsoft WAVE format */
|
||||
/*******************************************/
|
||||
#define RIFF 0x46464952 /* "RIFF" */
|
||||
#define WAVE 0x45564157 /* "WAVE" */
|
||||
#define FACT 0x74636166 /* "fact" */
|
||||
#define LIST 0x5453494c /* "LIST" */
|
||||
#define FMT 0x20746D66 /* "fmt " */
|
||||
#define DATA 0x61746164 /* "data" */
|
||||
#define PCM_CODE 0x0001
|
||||
#define MS_ADPCM_CODE 0x0002
|
||||
#define IMA_ADPCM_CODE 0x0011
|
||||
#define MP3_CODE 0x0055
|
||||
#define WAVE_MONO 1
|
||||
#define WAVE_STEREO 2
|
||||
|
||||
/* Normally, these three chunks come consecutively in a WAVE file */
|
||||
typedef struct WaveFMT {
|
||||
/* Not saved in the chunk we read:
|
||||
Uint32 FMTchunk;
|
||||
Uint32 fmtlen;
|
||||
*/
|
||||
Uint16 encoding;
|
||||
Uint16 channels; /* 1 = mono, 2 = stereo */
|
||||
Uint32 frequency; /* One of 11025, 22050, or 44100 Hz */
|
||||
Uint32 byterate; /* Average bytes per second */
|
||||
Uint16 blockalign; /* Bytes per sample block */
|
||||
Uint16 bitspersample; /* One of 8, 12, 16, or 4 for ADPCM */
|
||||
} WaveFMT;
|
||||
|
||||
/* The general chunk found in the WAVE file */
|
||||
typedef struct Chunk {
|
||||
Uint32 magic;
|
||||
Uint32 length;
|
||||
Uint8 *data;
|
||||
} Chunk;
|
||||
|
|
@ -1,156 +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
|
||||
|
||||
This file written by Ryan C. Gordon (icculus@icculus.org)
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Output audio to nowhere... */
|
||||
|
||||
#include "SDL_rwops.h"
|
||||
#include "SDL_timer.h"
|
||||
#include "SDL_audio.h"
|
||||
#include "../SDL_audiomem.h"
|
||||
#include "../SDL_audio_c.h"
|
||||
#include "../SDL_audiodev_c.h"
|
||||
#include "SDL_dummyaudio.h"
|
||||
|
||||
/* The tag name used by DUMMY audio */
|
||||
#define DUMMYAUD_DRIVER_NAME "dummy"
|
||||
|
||||
/* Audio driver functions */
|
||||
static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec);
|
||||
static void DUMMYAUD_WaitAudio(_THIS);
|
||||
static void DUMMYAUD_PlayAudio(_THIS);
|
||||
static Uint8 *DUMMYAUD_GetAudioBuf(_THIS);
|
||||
static void DUMMYAUD_CloseAudio(_THIS);
|
||||
|
||||
/* Audio driver bootstrap functions */
|
||||
static int DUMMYAUD_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_AUDIODRIVER");
|
||||
if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
|
||||
return(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_DeleteDevice(SDL_AudioDevice *device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_AudioDevice *DUMMYAUD_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_AudioDevice *this;
|
||||
|
||||
/* Initialize all variables that we clean on shutdown */
|
||||
this = (SDL_AudioDevice *)SDL_malloc(sizeof(SDL_AudioDevice));
|
||||
if ( this ) {
|
||||
SDL_memset(this, 0, (sizeof *this));
|
||||
this->hidden = (struct SDL_PrivateAudioData *)
|
||||
SDL_malloc((sizeof *this->hidden));
|
||||
}
|
||||
if ( (this == NULL) || (this->hidden == NULL) ) {
|
||||
SDL_OutOfMemory();
|
||||
if ( this ) {
|
||||
SDL_free(this);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
SDL_memset(this->hidden, 0, (sizeof *this->hidden));
|
||||
|
||||
/* Set the function pointers */
|
||||
this->OpenAudio = DUMMYAUD_OpenAudio;
|
||||
this->WaitAudio = DUMMYAUD_WaitAudio;
|
||||
this->PlayAudio = DUMMYAUD_PlayAudio;
|
||||
this->GetAudioBuf = DUMMYAUD_GetAudioBuf;
|
||||
this->CloseAudio = DUMMYAUD_CloseAudio;
|
||||
|
||||
this->free = DUMMYAUD_DeleteDevice;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
AudioBootStrap DUMMYAUD_bootstrap = {
|
||||
DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
|
||||
DUMMYAUD_Available, DUMMYAUD_CreateDevice
|
||||
};
|
||||
|
||||
/* This function waits until it is possible to write a full sound buffer */
|
||||
static void DUMMYAUD_WaitAudio(_THIS)
|
||||
{
|
||||
/* Don't block on first calls to simulate initial fragment filling. */
|
||||
if (this->hidden->initial_calls)
|
||||
this->hidden->initial_calls--;
|
||||
else
|
||||
SDL_Delay(this->hidden->write_delay);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_PlayAudio(_THIS)
|
||||
{
|
||||
/* no-op...this is a null driver. */
|
||||
}
|
||||
|
||||
static Uint8 *DUMMYAUD_GetAudioBuf(_THIS)
|
||||
{
|
||||
return(this->hidden->mixbuf);
|
||||
}
|
||||
|
||||
static void DUMMYAUD_CloseAudio(_THIS)
|
||||
{
|
||||
if ( this->hidden->mixbuf != NULL ) {
|
||||
SDL_FreeAudioMem(this->hidden->mixbuf);
|
||||
this->hidden->mixbuf = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static int DUMMYAUD_OpenAudio(_THIS, SDL_AudioSpec *spec)
|
||||
{
|
||||
float bytes_per_sec = 0.0f;
|
||||
|
||||
/* Allocate mixing buffer */
|
||||
this->hidden->mixlen = spec->size;
|
||||
this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
|
||||
if ( this->hidden->mixbuf == NULL ) {
|
||||
return(-1);
|
||||
}
|
||||
SDL_memset(this->hidden->mixbuf, spec->silence, spec->size);
|
||||
|
||||
bytes_per_sec = (float) (((spec->format & 0xFF) / 8) *
|
||||
spec->channels * spec->freq);
|
||||
|
||||
/*
|
||||
* We try to make this request more audio at the correct rate for
|
||||
* a given audio spec, so timing stays fairly faithful.
|
||||
* Also, we have it not block at all for the first two calls, so
|
||||
* it seems like we're filling two audio fragments right out of the
|
||||
* gate, like other SDL drivers tend to do.
|
||||
*/
|
||||
this->hidden->initial_calls = 2;
|
||||
this->hidden->write_delay =
|
||||
(Uint32) ((((float) spec->size) / bytes_per_sec) * 1000.0f);
|
||||
|
||||
/* We're ready to rock and roll. :-) */
|
||||
return(0);
|
||||
}
|
||||
|
|
@ -1,40 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifndef _SDL_dummyaudio_h
|
||||
#define _SDL_dummyaudio_h
|
||||
|
||||
#include "../SDL_sysaudio.h"
|
||||
|
||||
/* Hidden "this" pointer for the video functions */
|
||||
#define _THIS SDL_AudioDevice *this
|
||||
|
||||
struct SDL_PrivateAudioData {
|
||||
/* The file descriptor for the audio device */
|
||||
Uint8 *mixbuf;
|
||||
Uint32 mixlen;
|
||||
Uint32 write_delay;
|
||||
Uint32 initial_calls;
|
||||
};
|
||||
|
||||
#endif /* _SDL_dummyaudio_h */
|
|
@ -1,341 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* This is the CD-audio control API for Simple DirectMedia Layer */
|
||||
|
||||
#include "SDL_cdrom.h"
|
||||
#include "SDL_syscdrom.h"
|
||||
|
||||
#if !defined(__MACOS__)
|
||||
#define CLIP_FRAMES 10 /* Some CD-ROMs won't go all the way */
|
||||
#endif
|
||||
|
||||
static int SDL_cdinitted = 0;
|
||||
static SDL_CD *default_cdrom;
|
||||
|
||||
/* The system level CD-ROM control functions */
|
||||
struct CDcaps SDL_CDcaps = {
|
||||
NULL, /* Name */
|
||||
NULL, /* Open */
|
||||
NULL, /* GetTOC */
|
||||
NULL, /* Status */
|
||||
NULL, /* Play */
|
||||
NULL, /* Pause */
|
||||
NULL, /* Resume */
|
||||
NULL, /* Stop */
|
||||
NULL, /* Eject */
|
||||
NULL, /* Close */
|
||||
};
|
||||
int SDL_numcds;
|
||||
|
||||
int SDL_CDROMInit(void)
|
||||
{
|
||||
int retval;
|
||||
|
||||
SDL_numcds = 0;
|
||||
retval = SDL_SYS_CDInit();
|
||||
if ( retval == 0 ) {
|
||||
SDL_cdinitted = 1;
|
||||
}
|
||||
default_cdrom = NULL;
|
||||
return(retval);
|
||||
}
|
||||
|
||||
/* Check to see if the CD-ROM subsystem has been initialized */
|
||||
static int CheckInit(int check_cdrom, SDL_CD **cdrom)
|
||||
{
|
||||
int okay;
|
||||
|
||||
okay = SDL_cdinitted;
|
||||
if ( check_cdrom && (*cdrom == NULL) ) {
|
||||
*cdrom = default_cdrom;
|
||||
if ( *cdrom == NULL ) {
|
||||
SDL_SetError("CD-ROM not opened");
|
||||
okay = 0;
|
||||
}
|
||||
}
|
||||
if ( ! SDL_cdinitted ) {
|
||||
SDL_SetError("CD-ROM subsystem not initialized");
|
||||
}
|
||||
return(okay);
|
||||
}
|
||||
|
||||
int SDL_CDNumDrives(void)
|
||||
{
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(-1);
|
||||
}
|
||||
return(SDL_numcds);
|
||||
}
|
||||
|
||||
const char *SDL_CDName(int drive)
|
||||
{
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(NULL);
|
||||
}
|
||||
if ( drive >= SDL_numcds ) {
|
||||
SDL_SetError("Invalid CD-ROM drive index");
|
||||
return(NULL);
|
||||
}
|
||||
if ( SDL_CDcaps.Name ) {
|
||||
return(SDL_CDcaps.Name(drive));
|
||||
} else {
|
||||
return("");
|
||||
}
|
||||
}
|
||||
|
||||
SDL_CD *SDL_CDOpen(int drive)
|
||||
{
|
||||
struct SDL_CD *cdrom;
|
||||
|
||||
if ( ! CheckInit(0, NULL) ) {
|
||||
return(NULL);
|
||||
}
|
||||
if ( drive >= SDL_numcds ) {
|
||||
SDL_SetError("Invalid CD-ROM drive index");
|
||||
return(NULL);
|
||||
}
|
||||
cdrom = (SDL_CD *)SDL_malloc(sizeof(*cdrom));
|
||||
if ( cdrom == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
SDL_memset(cdrom, 0, sizeof(*cdrom));
|
||||
cdrom->id = SDL_CDcaps.Open(drive);
|
||||
if ( cdrom->id < 0 ) {
|
||||
SDL_free(cdrom);
|
||||
return(NULL);
|
||||
}
|
||||
default_cdrom = cdrom;
|
||||
return(cdrom);
|
||||
}
|
||||
|
||||
CDstatus SDL_CDStatus(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int i;
|
||||
Uint32 position;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Get the current status of the drive */
|
||||
cdrom->numtracks = 0;
|
||||
cdrom->cur_track = 0;
|
||||
cdrom->cur_frame = 0;
|
||||
status = SDL_CDcaps.Status(cdrom, &i);
|
||||
position = (Uint32)i;
|
||||
cdrom->status = status;
|
||||
|
||||
/* Get the table of contents, if there's a CD available */
|
||||
if ( CD_INDRIVE(status) ) {
|
||||
if ( SDL_CDcaps.GetTOC(cdrom) < 0 ) {
|
||||
status = CD_ERROR;
|
||||
}
|
||||
/* If the drive is playing, get current play position */
|
||||
if ( (status == CD_PLAYING) || (status == CD_PAUSED) ) {
|
||||
for ( i=1; cdrom->track[i].offset <= position; ++i ) {
|
||||
/* Keep looking */;
|
||||
}
|
||||
#ifdef DEBUG_CDROM
|
||||
fprintf(stderr, "Current position: %d, track = %d (offset is %d)\n",
|
||||
position, i-1, cdrom->track[i-1].offset);
|
||||
#endif
|
||||
cdrom->cur_track = i-1;
|
||||
position -= cdrom->track[cdrom->cur_track].offset;
|
||||
cdrom->cur_frame = position;
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
}
|
||||
|
||||
int SDL_CDPlayTracks(SDL_CD *cdrom,
|
||||
int strack, int sframe, int ntracks, int nframes)
|
||||
{
|
||||
int etrack, eframe;
|
||||
int start, length;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Determine the starting and ending tracks */
|
||||
if ( (strack < 0) || (strack >= cdrom->numtracks) ) {
|
||||
SDL_SetError("Invalid starting track");
|
||||
return(CD_ERROR);
|
||||
}
|
||||
if ( ! ntracks && ! nframes ) {
|
||||
etrack = cdrom->numtracks;
|
||||
eframe = 0;
|
||||
} else {
|
||||
etrack = strack+ntracks;
|
||||
if ( etrack == strack ) {
|
||||
eframe = sframe + nframes;
|
||||
} else {
|
||||
eframe = nframes;
|
||||
}
|
||||
}
|
||||
if ( etrack > cdrom->numtracks ) {
|
||||
SDL_SetError("Invalid play length");
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Skip data tracks and verify frame offsets */
|
||||
while ( (strack <= etrack) &&
|
||||
(cdrom->track[strack].type == SDL_DATA_TRACK) ) {
|
||||
++strack;
|
||||
}
|
||||
if ( sframe >= (int)cdrom->track[strack].length ) {
|
||||
SDL_SetError("Invalid starting frame for track %d", strack);
|
||||
return(CD_ERROR);
|
||||
}
|
||||
while ( (etrack > strack) &&
|
||||
(cdrom->track[etrack-1].type == SDL_DATA_TRACK) ) {
|
||||
--etrack;
|
||||
}
|
||||
if ( eframe > (int)cdrom->track[etrack].length ) {
|
||||
SDL_SetError("Invalid ending frame for track %d", etrack);
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
/* Determine start frame and play length */
|
||||
start = (cdrom->track[strack].offset+sframe);
|
||||
length = (cdrom->track[etrack].offset+eframe)-start;
|
||||
#ifdef CLIP_FRAMES
|
||||
/* I've never seen this necessary, but xmcd does it.. */
|
||||
length -= CLIP_FRAMES; /* CLIP_FRAMES == 10 */
|
||||
#endif
|
||||
if ( length < 0 ) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Play! */
|
||||
#ifdef DEBUG_CDROM
|
||||
fprintf(stderr, "Playing %d frames at offset %d\n", length, start);
|
||||
#endif
|
||||
return(SDL_CDcaps.Play(cdrom, start, length));
|
||||
}
|
||||
|
||||
int SDL_CDPlay(SDL_CD *cdrom, int sframe, int length)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
return(SDL_CDcaps.Play(cdrom, sframe, length));
|
||||
}
|
||||
|
||||
int SDL_CDPause(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PLAYING:
|
||||
retval = SDL_CDcaps.Pause(cdrom);
|
||||
break;
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDResume(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PAUSED:
|
||||
retval = SDL_CDcaps.Resume(cdrom);
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDStop(SDL_CD *cdrom)
|
||||
{
|
||||
CDstatus status;
|
||||
int retval;
|
||||
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
|
||||
status = SDL_CDcaps.Status(cdrom, NULL);
|
||||
switch (status) {
|
||||
case CD_PLAYING:
|
||||
case CD_PAUSED:
|
||||
retval = SDL_CDcaps.Stop(cdrom);
|
||||
default:
|
||||
retval = 0;
|
||||
break;
|
||||
}
|
||||
return(retval);
|
||||
}
|
||||
|
||||
int SDL_CDEject(SDL_CD *cdrom)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return(CD_ERROR);
|
||||
}
|
||||
return(SDL_CDcaps.Eject(cdrom));
|
||||
}
|
||||
|
||||
void SDL_CDClose(SDL_CD *cdrom)
|
||||
{
|
||||
/* Check if the CD-ROM subsystem has been initialized */
|
||||
if ( ! CheckInit(1, &cdrom) ) {
|
||||
return;
|
||||
}
|
||||
SDL_CDcaps.Close(cdrom);
|
||||
SDL_free(cdrom);
|
||||
default_cdrom = NULL;
|
||||
}
|
||||
|
||||
void SDL_CDROMQuit(void)
|
||||
{
|
||||
SDL_SYS_CDQuit();
|
||||
SDL_cdinitted = 0;
|
||||
}
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
SDL - Simple DirectMedia Layer
|
||||
Copyright (C) 1997-2012 Sam Lantinga
|
||||
|
||||
This library is SDL_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"
|
||||
|
||||
/* This is the system specific header for the SDL CD-ROM API */
|
||||
|
||||
/* Structure of CD audio control functions */
|
||||
extern struct CDcaps {
|
||||
/* Get the name of the specified drive */
|
||||
const char *(*Name)(int drive);
|
||||
|
||||
/* Open the specified drive, returning a drive id, or -1 on error */
|
||||
int (*Open)(int drive);
|
||||
|
||||
/* Get table-of-contents (number of tracks + track info) for disk.
|
||||
The TOC information should be stored in the cdrom structure.
|
||||
This function should return 0 on success, or -1 on error.
|
||||
*/
|
||||
int (*GetTOC)(SDL_CD *cdrom);
|
||||
|
||||
/* Return the current status and play position, in frames, of the
|
||||
drive. 'position' may be NULL, and if so, should be ignored.
|
||||
*/
|
||||
CDstatus (*Status)(SDL_CD *cdrom, int *position);
|
||||
|
||||
/* Play from frame 'start' to 'start+len' */
|
||||
int (*Play)(SDL_CD *cdrom, int start, int len);
|
||||
|
||||
/* Pause play */
|
||||
int (*Pause)(SDL_CD *cdrom);
|
||||
|
||||
/* Resume play */
|
||||
int (*Resume)(SDL_CD *cdrom);
|
||||
|
||||
/* Stop play */
|
||||
int (*Stop)(SDL_CD *cdrom);
|
||||
|
||||
/* Eject the current disk */
|
||||
int (*Eject)(SDL_CD *cdrom);
|
||||
|
||||
/* Close the specified drive */
|
||||
void (*Close)(SDL_CD *cdrom);
|
||||
} SDL_CDcaps;
|
||||
|
||||
/* The number of available CD-ROM drives on the system */
|
||||
extern int SDL_numcds;
|
||||
|
||||
/* Function to scan the system for CD-ROM drives and fill SDL_CDcaps.
|
||||
* This function should set SDL_numcds to the number of available CD
|
||||
* drives. Drive 0 should be the system default CD-ROM.
|
||||
* It should return 0, or -1 on an unrecoverable fatal error.
|
||||
*/
|
||||
extern int SDL_SYS_CDInit(void);
|
||||
|
||||
/* Function to perform any system-specific CD-ROM related cleanup */
|
||||
extern void SDL_SYS_CDQuit(void);
|
||||
|
|
@ -1,41 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_CDROM_DUMMY) || defined(SDL_CDROM_DISABLED)
|
||||
|
||||
/* Stub functions for system-level CD-ROM audio control */
|
||||
|
||||
#include "SDL_cdrom.h"
|
||||
#include "../SDL_syscdrom.h"
|
||||
|
||||
int SDL_SYS_CDInit(void)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
void SDL_SYS_CDQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_CDROM_DUMMY || SDL_CDROM_DISABLED */
|
|
@ -27,13 +27,13 @@
|
|||
|
||||
#include "SDL_endian.h"
|
||||
#include "SDL_rwops.h"
|
||||
|
||||
#include "SDL/SDL.h"
|
||||
|
||||
#if defined(__WIN32__) && !defined(__SYMBIAN32__)
|
||||
|
||||
/* Functions to read/write Win32 API file pointers */
|
||||
/* Will not use it on WinCE because stdio is buffered, it means
|
||||
faster, and all stdio functions anyway are embedded in coredll.dll -
|
||||
faster, and all stdio functions anyway are embedded in coredll.dll -
|
||||
the main wince dll*/
|
||||
|
||||
#define WINDOWS_LEAN_AND_MEAN
|
||||
|
@ -57,7 +57,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
|
|||
|
||||
if (!context)
|
||||
return -1; /* failed (invalid call) */
|
||||
|
||||
|
||||
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */
|
||||
context->hidden.win32io.buffer.data = NULL;
|
||||
context->hidden.win32io.buffer.size = 0;
|
||||
|
@ -69,7 +69,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
|
|||
/* "a" = writing, append file may not exist */
|
||||
/* "a+"= append + read, file may not exist */
|
||||
/* "w+" = read, write, truncate. file may not exist */
|
||||
|
||||
|
||||
must_exist = ( SDL_strchr(mode,'r') != NULL ) ? OPEN_EXISTING : 0;
|
||||
truncate = ( SDL_strchr(mode,'w') != NULL ) ? CREATE_ALWAYS : 0;
|
||||
r_right = ( SDL_strchr(mode,'+') != NULL || must_exist ) ? GENERIC_READ : 0;
|
||||
|
@ -97,7 +97,7 @@ static int SDLCALL win32_file_open(SDL_RWops *context, const char *filename, con
|
|||
SDL_SetError("Unable to convert filename to Unicode");
|
||||
return -1;
|
||||
}
|
||||
h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ,
|
||||
h = CreateFile(filenameW, (w_right|r_right), (w_right)? 0 : FILE_SHARE_READ,
|
||||
NULL, (must_exist|truncate|a_mode), FILE_ATTRIBUTE_NORMAL,NULL);
|
||||
SDL_stack_free(filenameW);
|
||||
}
|
||||
|
@ -187,7 +187,7 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
|
|||
{
|
||||
DWORD win32whence;
|
||||
int file_pos;
|
||||
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) {
|
||||
SDL_SetError("win32_file_seek: invalid context/file not opened");
|
||||
return -1;
|
||||
|
@ -200,14 +200,14 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
|
|||
context->hidden.win32io.buffer.left = 0;
|
||||
|
||||
switch (whence) {
|
||||
case RW_SEEK_SET:
|
||||
case RW_SEEK_SET:
|
||||
win32whence = FILE_BEGIN; break;
|
||||
case RW_SEEK_CUR:
|
||||
win32whence = FILE_CURRENT; break;
|
||||
case RW_SEEK_END:
|
||||
win32whence = FILE_END; break;
|
||||
default:
|
||||
SDL_SetError("win32_file_seek: Unknown value for 'whence'");
|
||||
SDL_SetError("win32_file_seek: Unknown value for 'whence'");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -215,27 +215,27 @@ static int SDLCALL win32_file_seek(SDL_RWops *context, int offset, int whence)
|
|||
|
||||
if ( file_pos != INVALID_SET_FILE_POINTER )
|
||||
return file_pos; /* success */
|
||||
|
||||
|
||||
SDL_Error(SDL_EFSEEK);
|
||||
return -1; /* error */
|
||||
}
|
||||
static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int maxnum)
|
||||
{
|
||||
int total_need;
|
||||
int total_read = 0;
|
||||
int total_need;
|
||||
int total_read = 0;
|
||||
int read_ahead;
|
||||
DWORD byte_read;
|
||||
|
||||
|
||||
total_need = size*maxnum;
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE || total_need<=0 || !size)
|
||||
|
||||
if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE || total_need<=0 || !size)
|
||||
return 0;
|
||||
|
||||
if (context->hidden.win32io.buffer.left > 0) {
|
||||
void *data = (char *)context->hidden.win32io.buffer.data +
|
||||
context->hidden.win32io.buffer.size -
|
||||
context->hidden.win32io.buffer.left;
|
||||
read_ahead = SDL_min(total_need, context->hidden.win32io.buffer.left);
|
||||
read_ahead = SDL_min(total_need, context->hidden.win32io.buffer.left);
|
||||
SDL_memcpy(ptr, data, read_ahead);
|
||||
context->hidden.win32io.buffer.left -= read_ahead;
|
||||
|
||||
|
@ -243,7 +243,7 @@ static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int
|
|||
return maxnum;
|
||||
}
|
||||
ptr = (char *)ptr + read_ahead;
|
||||
total_need -= read_ahead;
|
||||
total_need -= read_ahead;
|
||||
total_read += read_ahead;
|
||||
}
|
||||
|
||||
|
@ -268,13 +268,13 @@ static int SDLCALL win32_file_read(SDL_RWops *context, void *ptr, int size, int
|
|||
}
|
||||
static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int size, int num)
|
||||
{
|
||||
|
||||
int total_bytes;
|
||||
|
||||
int total_bytes;
|
||||
DWORD byte_written,nwritten;
|
||||
|
||||
|
||||
total_bytes = size*num;
|
||||
|
||||
if (!context || context->hidden.win32io.h==INVALID_HANDLE_VALUE || total_bytes<=0 || !size)
|
||||
if (!context || context->hidden.win32io.h==INVALID_HANDLE_VALUE || total_bytes<=0 || !size)
|
||||
return 0;
|
||||
|
||||
if (context->hidden.win32io.buffer.left) {
|
||||
|
@ -289,19 +289,19 @@ static int SDLCALL win32_file_write(SDL_RWops *context, const void *ptr, int siz
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!WriteFile(context->hidden.win32io.h,ptr,total_bytes,&byte_written,NULL)) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
nwritten = byte_written/size;
|
||||
return nwritten;
|
||||
}
|
||||
static int SDLCALL win32_file_close(SDL_RWops *context)
|
||||
{
|
||||
|
||||
if ( context ) {
|
||||
|
||||
if ( context ) {
|
||||
if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) {
|
||||
CloseHandle(context->hidden.win32io.h);
|
||||
context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */
|
||||
|
@ -322,6 +322,8 @@ static int SDLCALL win32_file_close(SDL_RWops *context)
|
|||
|
||||
static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
|
||||
{
|
||||
///cSDL_LogToFile( "je suis dans stdio_seek" );
|
||||
|
||||
if ( fseek(context->hidden.stdio.fp, offset, whence) == 0 ) {
|
||||
return(ftell(context->hidden.stdio.fp));
|
||||
} else {
|
||||
|
@ -331,26 +333,36 @@ static int SDLCALL stdio_seek(SDL_RWops *context, int offset, int whence)
|
|||
}
|
||||
static int SDLCALL stdio_read(SDL_RWops *context, void *ptr, int size, int maxnum)
|
||||
{
|
||||
///cSDL_LogToFile( "je suis dans stdio_read" );
|
||||
|
||||
size_t nread;
|
||||
|
||||
nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
|
||||
nread = fread(ptr, size, maxnum, context->hidden.stdio.fp);
|
||||
if ( nread == 0 && ferror(context->hidden.stdio.fp) ) {
|
||||
///cSDL_LogToFile( "error SDL_EFREAD" );
|
||||
SDL_Error(SDL_EFREAD);
|
||||
}
|
||||
///cSDL_LogToFile( "nread is equal to %d", (int) nread );
|
||||
return(nread);
|
||||
}
|
||||
static int SDLCALL stdio_write(SDL_RWops *context, const void *ptr, int size, int num)
|
||||
{
|
||||
size_t nwrote;
|
||||
|
||||
///cSDL_LogToFile( "je suis dans stdio_write" );
|
||||
|
||||
nwrote = fwrite(ptr, size, num, context->hidden.stdio.fp);
|
||||
if ( nwrote == 0 && ferror(context->hidden.stdio.fp) ) {
|
||||
SDL_Error(SDL_EFWRITE);
|
||||
}
|
||||
return(nwrote);
|
||||
}
|
||||
|
||||
static int SDLCALL stdio_close(SDL_RWops *context)
|
||||
{
|
||||
|
||||
///cSDL_LogToFile( "je suis dans stdio_close" );
|
||||
|
||||
if ( context ) {
|
||||
if ( context->hidden.stdio.autoclose ) {
|
||||
/* WARNING: Check the return value here! */
|
||||
|
@ -499,7 +511,7 @@ SDL_RWops *SDL_RWFromFile(const char *file, const char *mode)
|
|||
if (win32_file_open(rwops,file,mode) < 0) {
|
||||
SDL_FreeRW(rwops);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
rwops->seek = win32_file_seek;
|
||||
rwops->read = win32_file_read;
|
||||
rwops->write = win32_file_write;
|
||||
|
|
|
@ -0,0 +1,189 @@
|
|||
/*
|
||||
|
||||
SDL_framerate.c: framerate manager
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#include "SDL_framerate.h"
|
||||
|
||||
/*!
|
||||
\brief Internal wrapper to SDL_GetTicks that ensures a non-zero return value.
|
||||
|
||||
\return The tick count.
|
||||
*/
|
||||
Uint32 _getTicks()
|
||||
{
|
||||
Uint32 ticks = SDL_GetTicks();
|
||||
|
||||
/*
|
||||
* Since baseticks!=0 is used to track initialization
|
||||
* we need to ensure that the tick count is always >0
|
||||
* since SDL_GetTicks may not have incremented yet and
|
||||
* return 0 depending on the timing of the calls.
|
||||
*/
|
||||
if (ticks == 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return ticks;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Initialize the framerate manager.
|
||||
|
||||
Initialize the framerate manager, set default framerate of 30Hz and
|
||||
reset delay interpolation.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
*/
|
||||
void SDL_initFramerate(FPSmanager * manager)
|
||||
{
|
||||
/*
|
||||
* Store some sane values
|
||||
*/
|
||||
manager->framecount = 0;
|
||||
manager->rate = FPS_DEFAULT;
|
||||
manager->rateticks = (1000.0f / (float) FPS_DEFAULT);
|
||||
manager->baseticks = _getTicks();
|
||||
manager->lastticks = manager->baseticks;
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Set the framerate in Hz
|
||||
|
||||
Sets a new framerate for the manager and reset delay interpolation.
|
||||
Rate values must be between FPS_LOWER_LIMIT and FPS_UPPER_LIMIT inclusive to be accepted.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
\param rate The new framerate in Hz (frames per second).
|
||||
|
||||
\return 0 for sucess and -1 for error.
|
||||
*/
|
||||
int SDL_setFramerate(FPSmanager * manager, Uint32 rate)
|
||||
{
|
||||
if ((rate >= FPS_LOWER_LIMIT) && (rate <= FPS_UPPER_LIMIT)) {
|
||||
manager->framecount = 0;
|
||||
manager->rate = rate;
|
||||
manager->rateticks = (1000.0f / (float) rate);
|
||||
return (0);
|
||||
} else {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Return the current target framerate in Hz
|
||||
|
||||
Get the currently set framerate of the manager.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
|
||||
\return Current framerate in Hz or -1 for error.
|
||||
*/
|
||||
int SDL_getFramerate(FPSmanager * manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return (-1);
|
||||
} else {
|
||||
return ((int)manager->rate);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Return the current framecount.
|
||||
|
||||
Get the current framecount from the framerate manager.
|
||||
A frame is counted each time SDL_framerateDelay is called.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
|
||||
\return Current frame count or -1 for error.
|
||||
*/
|
||||
int SDL_getFramecount(FPSmanager * manager)
|
||||
{
|
||||
if (manager == NULL) {
|
||||
return (-1);
|
||||
} else {
|
||||
return ((int)manager->framecount);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Delay execution to maintain a constant framerate and calculate fps.
|
||||
|
||||
Generate a delay to accomodate currently set framerate. Call once in the
|
||||
graphics/rendering loop. If the computer cannot keep up with the rate (i.e.
|
||||
drawing too slow), the delay is zero and the delay interpolation is reset.
|
||||
|
||||
\param manager Pointer to the framerate manager.
|
||||
|
||||
\return The time that passed since the last call to the function in ms. May return 0.
|
||||
*/
|
||||
Uint32 SDL_framerateDelay(FPSmanager * manager)
|
||||
{
|
||||
Uint32 current_ticks;
|
||||
Uint32 target_ticks;
|
||||
Uint32 the_delay;
|
||||
Uint32 time_passed = 0;
|
||||
|
||||
/*
|
||||
* No manager, no delay
|
||||
*/
|
||||
if (manager == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize uninitialized manager
|
||||
*/
|
||||
if (manager->baseticks == 0) {
|
||||
SDL_initFramerate(manager);
|
||||
}
|
||||
|
||||
/*
|
||||
* Next frame
|
||||
*/
|
||||
manager->framecount++;
|
||||
|
||||
/*
|
||||
* Get/calc ticks
|
||||
*/
|
||||
current_ticks = _getTicks();
|
||||
time_passed = current_ticks - manager->lastticks;
|
||||
manager->lastticks = current_ticks;
|
||||
target_ticks = manager->baseticks + (Uint32) ((float) manager->framecount * manager->rateticks);
|
||||
|
||||
if (current_ticks <= target_ticks) {
|
||||
the_delay = target_ticks - current_ticks;
|
||||
SDL_Delay(the_delay);
|
||||
} else {
|
||||
manager->framecount = 0;
|
||||
manager->baseticks = _getTicks();
|
||||
}
|
||||
|
||||
return time_passed;
|
||||
}
|
|
@ -0,0 +1,639 @@
|
|||
/*
|
||||
|
||||
SDL_gfxBlitFunc.c: custom blitters
|
||||
|
||||
Copyright (C) 2001-2012 Andreas Schiffler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source
|
||||
distribution.
|
||||
|
||||
Andreas Schiffler -- aschiffler at ferzkopp dot net
|
||||
|
||||
*/
|
||||
|
||||
#include "SDL_gfxBlitFunc.h"
|
||||
|
||||
/*!
|
||||
\brief Alpha adjustment table for custom blitter.
|
||||
|
||||
The table provides values for a modified, non-linear
|
||||
transfer function which maintain brightness.
|
||||
|
||||
*/
|
||||
const unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = {
|
||||
0, /* 0 */
|
||||
15, /* 1 */
|
||||
22, /* 2 */
|
||||
27, /* 3 */
|
||||
31, /* 4 */
|
||||
35, /* 5 */
|
||||
39, /* 6 */
|
||||
42, /* 7 */
|
||||
45, /* 8 */
|
||||
47, /* 9 */
|
||||
50, /* 10 */
|
||||
52, /* 11 */
|
||||
55, /* 12 */
|
||||
57, /* 13 */
|
||||
59, /* 14 */
|
||||
61, /* 15 */
|
||||
63, /* 16 */
|
||||
65, /* 17 */
|
||||
67, /* 18 */
|
||||
69, /* 19 */
|
||||
71, /* 20 */
|
||||
73, /* 21 */
|
||||
74, /* 22 */
|
||||
76, /* 23 */
|
||||
78, /* 24 */
|
||||
79, /* 25 */
|
||||
81, /* 26 */
|
||||
82, /* 27 */
|
||||
84, /* 28 */
|
||||
85, /* 29 */
|
||||
87, /* 30 */
|
||||
88, /* 31 */
|
||||
90, /* 32 */
|
||||
91, /* 33 */
|
||||
93, /* 34 */
|
||||
94, /* 35 */
|
||||
95, /* 36 */
|
||||
97, /* 37 */
|
||||
98, /* 38 */
|
||||
99, /* 39 */
|
||||
100, /* 40 */
|
||||
102, /* 41 */
|
||||
103, /* 42 */
|
||||
104, /* 43 */
|
||||
105, /* 44 */
|
||||
107, /* 45 */
|
||||
108, /* 46 */
|
||||
109, /* 47 */
|
||||
110, /* 48 */
|
||||
111, /* 49 */
|
||||
112, /* 50 */
|
||||
114, /* 51 */
|
||||
115, /* 52 */
|
||||
116, /* 53 */
|
||||
117, /* 54 */
|
||||
118, /* 55 */
|
||||
119, /* 56 */
|
||||
120, /* 57 */
|
||||
121, /* 58 */
|
||||
122, /* 59 */
|
||||
123, /* 60 */
|
||||
124, /* 61 */
|
||||
125, /* 62 */
|
||||
126, /* 63 */
|
||||
127, /* 64 */
|
||||
128, /* 65 */
|
||||
129, /* 66 */
|
||||
130, /* 67 */
|
||||
131, /* 68 */
|
||||
132, /* 69 */
|
||||
133, /* 70 */
|
||||
134, /* 71 */
|
||||
135, /* 72 */
|
||||
136, /* 73 */
|
||||
137, /* 74 */
|
||||
138, /* 75 */
|
||||
139, /* 76 */
|
||||
140, /* 77 */
|
||||
141, /* 78 */
|
||||
141, /* 79 */
|
||||
142, /* 80 */
|
||||
143, /* 81 */
|
||||
144, /* 82 */
|
||||
145, /* 83 */
|
||||
146, /* 84 */
|
||||
147, /* 85 */
|
||||
148, /* 86 */
|
||||
148, /* 87 */
|
||||
149, /* 88 */
|
||||
150, /* 89 */
|
||||
151, /* 90 */
|
||||
152, /* 91 */
|
||||
153, /* 92 */
|
||||
153, /* 93 */
|
||||
154, /* 94 */
|
||||
155, /* 95 */
|
||||
156, /* 96 */
|
||||
157, /* 97 */
|
||||
158, /* 98 */
|
||||
158, /* 99 */
|
||||
159, /* 100 */
|
||||
160, /* 101 */
|
||||
161, /* 102 */
|
||||
162, /* 103 */
|
||||
162, /* 104 */
|
||||
163, /* 105 */
|
||||
164, /* 106 */
|
||||
165, /* 107 */
|
||||
165, /* 108 */
|
||||
166, /* 109 */
|
||||
167, /* 110 */
|
||||
168, /* 111 */
|
||||
168, /* 112 */
|
||||
169, /* 113 */
|
||||
170, /* 114 */
|
||||
171, /* 115 */
|
||||
171, /* 116 */
|
||||
172, /* 117 */
|
||||
173, /* 118 */
|
||||
174, /* 119 */
|
||||
174, /* 120 */
|
||||
175, /* 121 */
|
||||
176, /* 122 */
|
||||
177, /* 123 */
|
||||
177, /* 124 */
|
||||
178, /* 125 */
|
||||
179, /* 126 */
|
||||
179, /* 127 */
|
||||
180, /* 128 */
|
||||
181, /* 129 */
|
||||
182, /* 130 */
|
||||
182, /* 131 */
|
||||
183, /* 132 */
|
||||
184, /* 133 */
|
||||
184, /* 134 */
|
||||
185, /* 135 */
|
||||
186, /* 136 */
|
||||
186, /* 137 */
|
||||
187, /* 138 */
|
||||
188, /* 139 */
|
||||
188, /* 140 */
|
||||
189, /* 141 */
|
||||
190, /* 142 */
|
||||
190, /* 143 */
|
||||
191, /* 144 */
|
||||
192, /* 145 */
|
||||
192, /* 146 */
|
||||
193, /* 147 */
|
||||
194, /* 148 */
|
||||
194, /* 149 */
|
||||
195, /* 150 */
|
||||
196, /* 151 */
|
||||
196, /* 152 */
|
||||
197, /* 153 */
|
||||
198, /* 154 */
|
||||
198, /* 155 */
|
||||
199, /* 156 */
|
||||
200, /* 157 */
|
||||
200, /* 158 */
|
||||
201, /* 159 */
|
||||
201, /* 160 */
|
||||
202, /* 161 */
|
||||
203, /* 162 */
|
||||
203, /* 163 */
|
||||
204, /* 164 */
|
||||
205, /* 165 */
|
||||
205, /* 166 */
|
||||
206, /* 167 */
|
||||
206, /* 168 */
|
||||
207, /* 169 */
|
||||
208, /* 170 */
|
||||
208, /* 171 */
|
||||
209, /* 172 */
|
||||
210, /* 173 */
|
||||
210, /* 174 */
|
||||
211, /* 175 */
|
||||
211, /* 176 */
|
||||
212, /* 177 */
|
||||
213, /* 178 */
|
||||
213, /* 179 */
|
||||
214, /* 180 */
|
||||
214, /* 181 */
|
||||
215, /* 182 */
|
||||
216, /* 183 */
|
||||
216, /* 184 */
|
||||
217, /* 185 */
|
||||
217, /* 186 */
|
||||
218, /* 187 */
|
||||
218, /* 188 */
|
||||
219, /* 189 */
|
||||
220, /* 190 */
|
||||
220, /* 191 */
|
||||
221, /* 192 */
|
||||
221, /* 193 */
|
||||
222, /* 194 */
|
||||
222, /* 195 */
|
||||
223, /* 196 */
|
||||
224, /* 197 */
|
||||
224, /* 198 */
|
||||
225, /* 199 */
|
||||
225, /* 200 */
|
||||
226, /* 201 */
|
||||
226, /* 202 */
|
||||
227, /* 203 */
|
||||
228, /* 204 */
|
||||
228, /* 205 */
|
||||
229, /* 206 */
|
||||
229, /* 207 */
|
||||
230, /* 208 */
|
||||
230, /* 209 */
|
||||
231, /* 210 */
|
||||
231, /* 211 */
|
||||
232, /* 212 */
|
||||
233, /* 213 */
|
||||
233, /* 214 */
|
||||
234, /* 215 */
|
||||
234, /* 216 */
|
||||
235, /* 217 */
|
||||
235, /* 218 */
|
||||
236, /* 219 */
|
||||
236, /* 220 */
|
||||
237, /* 221 */
|
||||
237, /* 222 */
|
||||
238, /* 223 */
|
||||
238, /* 224 */
|
||||
239, /* 225 */
|
||||
240, /* 226 */
|
||||
240, /* 227 */
|
||||
241, /* 228 */
|
||||
241, /* 229 */
|
||||
242, /* 230 */
|
||||
242, /* 231 */
|
||||
243, /* 232 */
|
||||
243, /* 233 */
|
||||
244, /* 234 */
|
||||
244, /* 235 */
|
||||
245, /* 236 */
|
||||
245, /* 237 */
|
||||
246, /* 238 */
|
||||
246, /* 239 */
|
||||
247, /* 240 */
|
||||
247, /* 241 */
|
||||
248, /* 242 */
|
||||
248, /* 243 */
|
||||
249, /* 244 */
|
||||
249, /* 245 */
|
||||
250, /* 246 */
|
||||
250, /* 247 */
|
||||
251, /* 248 */
|
||||
251, /* 249 */
|
||||
252, /* 250 */
|
||||
252, /* 251 */
|
||||
253, /* 252 */
|
||||
253, /* 253 */
|
||||
254, /* 254 */
|
||||
255 /* 255 */
|
||||
};
|
||||
|
||||
/*!
|
||||
\brief Internal blitter using adjusted destination alpha during RGBA->RGBA blits.
|
||||
|
||||
Performs the blit based on the 'info' structure and applies the transfer function
|
||||
to the destination 'a' values.
|
||||
|
||||
\param info The blit info to use.
|
||||
*/
|
||||
void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo * info)
|
||||
{
|
||||
int width = info->d_width;
|
||||
int height = info->d_height;
|
||||
Uint8 *src = info->s_pixels;
|
||||
int srcskip = info->s_skip;
|
||||
Uint8 *dst = info->d_pixels;
|
||||
int dstskip = info->d_skip;
|
||||
SDL_PixelFormat *srcfmt = info->src;
|
||||
SDL_PixelFormat *dstfmt = info->dst;
|
||||
Uint8 srcbpp = srcfmt->BytesPerPixel;
|
||||
Uint8 dstbpp = dstfmt->BytesPerPixel;
|
||||
|
||||
while (height--) {
|
||||
GFX_DUFFS_LOOP4( {
|
||||
Uint32 pixel;
|
||||
unsigned sR;
|
||||
unsigned sG;
|
||||
unsigned sB;
|
||||
unsigned sA;
|
||||
unsigned dR;
|
||||
unsigned dG;
|
||||
unsigned dB;
|
||||
unsigned dA;
|
||||
unsigned sAA;
|
||||
GFX_DISASSEMBLE_RGBA(src, srcbpp, srcfmt, pixel, sR, sG, sB, sA);
|
||||
GFX_DISASSEMBLE_RGBA(dst, dstbpp, dstfmt, pixel, dR, dG, dB, dA);
|
||||
sAA=GFX_ALPHA_ADJUST_ARRAY[sA & 255];
|
||||
GFX_ALPHA_BLEND(sR, sG, sB, sAA, dR, dG, dB);
|
||||
dA |= sAA;
|
||||
GFX_ASSEMBLE_RGBA(dst, dstbpp, dstfmt, dR, dG, dB, dA);
|
||||
src += srcbpp; dst += dstbpp;
|
||||
}, width);
|
||||
src += srcskip;
|
||||
dst += dstskip;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Internal blitter setup wrapper for RGBA->RGBA blits.
|
||||
|
||||
Sets up the blitter info based on the 'src' and 'dst' surfaces and rectangles.
|
||||
|
||||
\param src The source surface.
|
||||
\param srcrect The source rectangle.
|
||||
\param dst The destination surface.
|
||||
\param dstrect The destination rectangle.
|
||||
|
||||
\returns Returns 1 if blit was performed, 0 otherwise.
|
||||
*/
|
||||
int _SDL_gfxBlitRGBACall(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
/*
|
||||
* Set up source and destination buffer pointers, then blit
|
||||
*/
|
||||
if (srcrect->w && srcrect->h) {
|
||||
SDL_gfxBlitInfo info;
|
||||
|
||||
/*
|
||||
* Set up the blit information
|
||||
*/
|
||||
#if (SDL_MINOR_VERSION == 3)
|
||||
info.s_pixels = (Uint8 *) src->pixels + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel;
|
||||
#else
|
||||
info.s_pixels = (Uint8 *) src->pixels + src->offset + (Uint16) srcrect->y * src->pitch + (Uint16) srcrect->x * src->format->BytesPerPixel;
|
||||
#endif
|
||||
info.s_width = srcrect->w;
|
||||
info.s_height = srcrect->h;
|
||||
info.s_skip = (int)(src->pitch - info.s_width * src->format->BytesPerPixel);
|
||||
#if (SDL_MINOR_VERSION == 3)
|
||||
info.d_pixels = (Uint8 *) dst->pixels + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel;
|
||||
#else
|
||||
info.d_pixels = (Uint8 *) dst->pixels + dst->offset + (Uint16) dstrect->y * dst->pitch + (Uint16) dstrect->x * dst->format->BytesPerPixel;
|
||||
#endif
|
||||
info.d_width = dstrect->w;
|
||||
info.d_height = dstrect->h;
|
||||
info.d_skip = (int)(dst->pitch - info.d_width * dst->format->BytesPerPixel);
|
||||
info.aux_data = NULL;
|
||||
info.src = src->format;
|
||||
info.table = NULL;
|
||||
info.dst = dst->format;
|
||||
|
||||
/*
|
||||
* Run the actual software blitter
|
||||
*/
|
||||
_SDL_gfxBlitBlitterRGBA(&info);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Blitter for RGBA->RGBA blits with alpha adjustment.
|
||||
|
||||
Verifies the input 'src' and 'dst' surfaces and rectangles and performs blit.
|
||||
The destination clip rectangle is honored.
|
||||
|
||||
\param src The source surface.
|
||||
\param srcrect The source rectangle.
|
||||
\param dst The destination surface.
|
||||
\param dstrect The destination rectangle.
|
||||
|
||||
\returns Returns 1 if blit was performed, 0 otherwise, or -1 if an error occured.
|
||||
*/
|
||||
int SDL_gfxBlitRGBA(SDL_Surface * src, SDL_Rect * srcrect, SDL_Surface * dst, SDL_Rect * dstrect)
|
||||
{
|
||||
SDL_Rect sr, dr;
|
||||
int srcx, srcy, w, h;
|
||||
|
||||
/*
|
||||
* Make sure the surfaces aren't locked
|
||||
*/
|
||||
if (!src || !dst) {
|
||||
SDL_SetError("SDL_UpperBlit: passed a NULL surface");
|
||||
return (-1);
|
||||
}
|
||||
if ((src->locked) || (dst->locked)) {
|
||||
SDL_SetError("Surfaces must not be locked during blit");
|
||||
return (-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* If the destination rectangle is NULL, use the entire dest surface
|
||||
*/
|
||||
if (dstrect == NULL) {
|
||||
dr.x = dr.y = 0;
|
||||
dr.w = dst->w;
|
||||
dr.h = dst->h;
|
||||
} else {
|
||||
dr = *dstrect;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clip the source rectangle to the source surface
|
||||
*/
|
||||
if (srcrect) {
|
||||
int maxw, maxh;
|
||||
|
||||
srcx = srcrect->x;
|
||||
w = srcrect->w;
|
||||
if (srcx < 0) {
|
||||
w += srcx;
|
||||
dr.x -= srcx;
|
||||
srcx = 0;
|
||||
}
|
||||
maxw = src->w - srcx;
|
||||
if (maxw < w)
|
||||
w = maxw;
|
||||
|
||||
srcy = srcrect->y;
|
||||
h = srcrect->h;
|
||||
if (srcy < 0) {
|
||||
h += srcy;
|
||||
dr.y -= srcy;
|
||||
srcy = 0;
|
||||
}
|
||||
maxh = src->h - srcy;
|
||||
if (maxh < h)
|
||||
h = maxh;
|
||||
|
||||
} else {
|
||||
srcx = srcy = 0;
|
||||
w = src->w;
|
||||
h = src->h;
|
||||
}
|
||||
|
||||
/*
|
||||
* Clip the destination rectangle against the clip rectangle
|
||||
*/
|
||||
{
|
||||
SDL_Rect *clip = &dst->clip_rect;
|
||||
int dx, dy;
|
||||
|
||||
dx = clip->x - dr.x;
|
||||
if (dx > 0) {
|
||||
w -= dx;
|
||||
dr.x += dx;
|
||||
srcx += dx;
|
||||
}
|
||||
dx = dr.x + w - clip->x - clip->w;
|
||||
if (dx > 0)
|
||||
w -= dx;
|
||||
|
||||
dy = clip->y - dr.y;
|
||||
if (dy > 0) {
|
||||
h -= dy;
|
||||
dr.y += dy;
|
||||
srcy += dy;
|
||||
}
|
||||
dy = dr.y + h - clip->y - clip->h;
|
||||
if (dy > 0)
|
||||
h -= dy;
|
||||
}
|
||||
|
||||
if (w > 0 && h > 0) {
|
||||
sr.x = srcx;
|
||||
sr.y = srcy;
|
||||
sr.w = dr.w = w;
|
||||
sr.h = dr.h = h;
|
||||
return (_SDL_gfxBlitRGBACall(src, &sr, dst, &dr));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Sets the alpha channel in a 32 bit surface.
|
||||
|
||||
Helper function that sets the alpha channel in a 32 bit surface
|
||||
to a constant value.
|
||||
Only 32 bit surfaces can be used with this function.
|
||||
|
||||
\param src Pointer to the target surface to change.
|
||||
\param a The alpha value to set.
|
||||
|
||||
\return Returns 1 if alpha was changed, -1 otherwise.
|
||||
*/
|
||||
int SDL_gfxSetAlpha(SDL_Surface *src, Uint8 a)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
const int alpha_offset = 0;
|
||||
#else
|
||||
const int alpha_offset = 3;
|
||||
#endif
|
||||
int i, j, row_skip;
|
||||
Uint8 *pixels;
|
||||
|
||||
/* Check if we have a 32bit surface */
|
||||
if ( (src==NULL) ||
|
||||
(src->format==NULL) ||
|
||||
(src->format->BytesPerPixel!=4) ) {
|
||||
SDL_SetError("SDL_gfxSetAlpha: Invalid input surface.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock the surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
pixels = (Uint8 *)src->pixels;
|
||||
row_skip = (src->pitch - (4*src->w));
|
||||
pixels += alpha_offset;
|
||||
for ( i=0; i<src->h; i++ ) {
|
||||
for ( j=0; j<src->w; j++ ) {
|
||||
*pixels = a;
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += row_skip;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlock surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*!
|
||||
\brief Multiply the alpha channel in a 32bit surface.
|
||||
|
||||
Helper function that multiplies the alpha channel in a 32 bit surface
|
||||
with a constant value. The final alpha is always scaled to the range
|
||||
0-255 (i.e. the factor is a/256).
|
||||
|
||||
Only 32 bit surfaces can be used with this function.
|
||||
|
||||
\param src Pointer to the target surface to change.
|
||||
\param a The alpha value to multiply with. When a is 255, this function is a NoOp.
|
||||
|
||||
\return Returns 1 if alpha was changed, 0 otherwise. Returns -1 if input surface is invalid.
|
||||
*/
|
||||
int SDL_gfxMultiplyAlpha(SDL_Surface *src, Uint8 a)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
const int alpha_offset = 0;
|
||||
#else
|
||||
const int alpha_offset = 3;
|
||||
#endif
|
||||
int i, j, row_skip;
|
||||
Uint8 *pixels;
|
||||
|
||||
/* Check if we have a 32bit surface */
|
||||
if ( (src==NULL) ||
|
||||
(src->format==NULL) ||
|
||||
(src->format->BytesPerPixel!=4) ) {
|
||||
SDL_SetError("SDL_gfxMultiplyAlpha: Invalid input surface.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Check if multiplication is needed */
|
||||
if (a==255) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Lock the surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
if (SDL_LockSurface(src) < 0) {
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
|
||||
/* Process */
|
||||
pixels = (Uint8 *)src->pixels;
|
||||
row_skip = (src->pitch - (4*src->w));
|
||||
pixels += alpha_offset;
|
||||
for ( i=0; i<src->h; i++ ) {
|
||||
for ( j=0; j<src->w; j++ ) {
|
||||
*pixels = (Uint8)(((int)(*pixels)*a)>>8);
|
||||
pixels += 4;
|
||||
}
|
||||
pixels += row_skip;
|
||||
}
|
||||
|
||||
/*
|
||||
* Unlock surface
|
||||
*/
|
||||
if (SDL_MUSTLOCK(src)) {
|
||||
SDL_UnlockSurface(src);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1,83 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_JOYSTICK_DUMMY) || defined(SDL_JOYSTICK_DISABLED)
|
||||
|
||||
/* This is the system specific header for the SDL joystick API */
|
||||
|
||||
#include "SDL_joystick.h"
|
||||
#include "../SDL_sysjoystick.h"
|
||||
#include "../SDL_joystick_c.h"
|
||||
|
||||
/* Function to scan the system for joysticks.
|
||||
* This function should set SDL_numjoysticks to the number of available
|
||||
* joysticks. Joystick 0 should be the system default joystick.
|
||||
* It should return 0, or -1 on an unrecoverable fatal error.
|
||||
*/
|
||||
int SDL_SYS_JoystickInit(void)
|
||||
{
|
||||
SDL_numjoysticks = 0;
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* Function to get the device-dependent name of a joystick */
|
||||
const char *SDL_SYS_JoystickName(int index)
|
||||
{
|
||||
SDL_SetError("Logic error: No joysticks available");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Function to open a joystick for use.
|
||||
The joystick to open is specified by the index field of the joystick.
|
||||
This should fill the nbuttons and naxes fields of the joystick structure.
|
||||
It returns 0, or -1 if there is an error.
|
||||
*/
|
||||
int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
|
||||
{
|
||||
SDL_SetError("Logic error: No joysticks available");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/* Function to update the state of a joystick - called as a device poll.
|
||||
* This function shouldn't update the joystick structure directly,
|
||||
* but instead should call SDL_PrivateJoystick*() to deliver events
|
||||
* and update joystick device state.
|
||||
*/
|
||||
void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Function to close a joystick after use */
|
||||
void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Function to perform any system-specific joystick related cleanup */
|
||||
void SDL_SYS_JoystickQuit(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_JOYSTICK_DUMMY || SDL_JOYSTICK_DISABLED */
|
|
@ -1,50 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_LOADSO_DUMMY) || defined(SDL_LOADSO_DISABLED)
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
/* System dependent library loading routines */
|
||||
|
||||
#include "SDL_loadso.h"
|
||||
|
||||
void *SDL_LoadObject(const char *sofile)
|
||||
{
|
||||
const char *loaderror = "SDL_LoadObject() not implemented";
|
||||
SDL_SetError("Failed loading %s: %s", sofile, loaderror);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void *SDL_LoadFunction(void *handle, const char *name)
|
||||
{
|
||||
const char *loaderror = "SDL_LoadFunction() not implemented";
|
||||
SDL_SetError("Failed loading %s: %s", name, loaderror);
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
void SDL_UnloadObject(void *handle)
|
||||
{
|
||||
/* no-op. */
|
||||
}
|
||||
|
||||
#endif /* SDL_LOADSO_DUMMY || SDL_LOADSO_DISABLED */
|
|
@ -1,13 +0,0 @@
|
|||
|
||||
/* Include the SDL main definition header */
|
||||
#include "SDL_main.h"
|
||||
|
||||
#ifdef main
|
||||
#undef main
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
return(SDL_main(argc, argv));
|
||||
}
|
||||
#else
|
||||
/* Nothing to do on this platform */
|
||||
#endif
|
|
@ -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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
}
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
SDL_Unsupported();
|
||||
}
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static SDL_Thread *timer = NULL;
|
||||
|
||||
static int RunTimer(void *unused)
|
||||
{
|
||||
while ( timer_alive ) {
|
||||
if ( SDL_timer_running ) {
|
||||
SDL_ThreadedTimerCheck();
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer = SDL_CreateThread(RunTimer, NULL);
|
||||
if ( timer == NULL )
|
||||
return(-1);
|
||||
return(SDL_SetTimerThreaded(1));
|
||||
}
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
timer_alive = 0;
|
||||
if ( timer ) {
|
||||
SDL_WaitThread(timer, NULL);
|
||||
timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
SDL_SetError("Internal logic error: threaded timer in use");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
|
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
|
||||
#include <gint/gint.h>
|
||||
#include <gint/timer.h>
|
||||
#include <gint/mpu/tmu.h>
|
||||
|
||||
#include "SDL_config.h"
|
||||
|
||||
#ifdef SDL_TIMER_PRIZM
|
||||
|
||||
#include "SDL_timer.h"
|
||||
#include "../SDL_timer_c.h"
|
||||
|
||||
|
||||
int timerID = -1;
|
||||
uint32_t timerTick = 0;
|
||||
uint32_t timerStart = 0;
|
||||
uint32_t volatile *Tcnt = NULL;
|
||||
|
||||
static int callback(void)
|
||||
{
|
||||
return TIMER_CONTINUE;
|
||||
}
|
||||
|
||||
|
||||
void SDL_StartTicks(void)
|
||||
{
|
||||
timerID = timer_configure( TIMER_ETMU, 0xFFFFFFFF, GINT_CALL(callback));
|
||||
if (timerID!=-1)
|
||||
{
|
||||
timer_start(timerID);
|
||||
Tcnt = &SH7305_ETMU[timerID-3].TCNT;
|
||||
timerStart = *Tcnt;
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 SDL_GetTicks (void)
|
||||
{
|
||||
|
||||
if (timerID!=-1)
|
||||
{
|
||||
timerTick = timerStart - *Tcnt;
|
||||
return (timerTick >> 5);
|
||||
}
|
||||
else return 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
void SDL_Delay (Uint32 ms)
|
||||
{
|
||||
if (timerID!=-1)
|
||||
{
|
||||
uint32_t timerTempStart = SDL_GetTicks();
|
||||
uint32_t currentTCNT;
|
||||
|
||||
do
|
||||
{
|
||||
currentTCNT = SDL_GetTicks() - timerTempStart;
|
||||
}
|
||||
while(currentTCNT <= ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#include "SDL_thread.h"
|
||||
|
||||
/* Data to handle a single periodic alarm */
|
||||
static int timer_alive = 0;
|
||||
static SDL_Thread *timer = NULL;
|
||||
|
||||
static int RunTimer(void *unused)
|
||||
{
|
||||
while ( timer_alive ) {
|
||||
if ( SDL_timer_running ) {
|
||||
SDL_ThreadedTimerCheck();
|
||||
}
|
||||
SDL_Delay(1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
/* This is only called if the event thread is not running */
|
||||
int SDL_SYS_TimerInit(void)
|
||||
{
|
||||
timer_alive = 1;
|
||||
timer = SDL_CreateThread(RunTimer, NULL);
|
||||
if ( timer == NULL )
|
||||
return(-1);
|
||||
return(SDL_SetTimerThreaded(1));
|
||||
}
|
||||
|
||||
void SDL_SYS_TimerQuit(void)
|
||||
{
|
||||
timer_alive = 0;
|
||||
if ( timer ) {
|
||||
SDL_WaitThread(timer, NULL);
|
||||
timer = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int SDL_SYS_StartTimer(void)
|
||||
{
|
||||
//SDL_SetError("Timers not implemented on the TI-Nspire");
|
||||
return(-1);
|
||||
}
|
||||
|
||||
void SDL_SYS_StopTimer(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif /* SDL_TIMER_PRIZM */
|
|
@ -21,14 +21,14 @@
|
|||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/*
|
||||
/*
|
||||
Code to load and save surfaces in Windows BMP format.
|
||||
|
||||
Why support BMP format? Well, it's a native format for Windows, and
|
||||
most image processing programs can read and write it. It would be nice
|
||||
to be able to have at least one image format that we can natively load
|
||||
and save, and since PNG is so complex that it would bloat the library,
|
||||
BMP is a good alternative.
|
||||
BMP is a good alternative.
|
||||
|
||||
This code currently supports Win32 DIBs in uncompressed 8 and 24 bpp.
|
||||
*/
|
||||
|
@ -44,6 +44,61 @@
|
|||
#define BI_BITFIELDS 3
|
||||
#endif
|
||||
|
||||
/*
|
||||
SDL_Surface * SDL_LoadBMP( const char* filename )
|
||||
{
|
||||
return SDL_LoadBMP_RW(SDL_RWFromFile(filename, "rb"), 1);
|
||||
}
|
||||
*/
|
||||
|
||||
SDL_Surface * SDL_LoadBMP( const char* filename )
|
||||
{
|
||||
FILE* f = fopen(filename, "rb");
|
||||
|
||||
if(f == NULL)
|
||||
return NULL;
|
||||
|
||||
unsigned char info[54];
|
||||
fread(info, sizeof(unsigned char), 54, f); // read the 54-byte header
|
||||
|
||||
int32_t width = (int32_t)info[18] | (int32_t)info[19]<<8 | (int32_t)info[20]<<16 | (int32_t)info[21]<<24;
|
||||
int32_t height = (int32_t)info[22] | (int32_t)info[23]<<8 | (int32_t)info[24]<<16 | (int32_t)info[25]<<24;
|
||||
|
||||
SDL_Surface *bmp = SDL_CreateRGBSurface( 0, width, height, 16, 0, 0, 0, 0 );
|
||||
|
||||
int row_padded = (width*3 + 3) & (~3);
|
||||
unsigned char* data = (unsigned char*) malloc(row_padded);
|
||||
char R,G,B;
|
||||
|
||||
//----------------------------
|
||||
int32_t offsetdata = (int32_t)info[10] | (int32_t)info[11]<<8 | (int32_t)info[12]<<16 | (int32_t)info[13]<<24;
|
||||
int delta;
|
||||
|
||||
|
||||
if (offsetdata>54)
|
||||
{
|
||||
delta = offsetdata-54;
|
||||
fread(data, sizeof(unsigned char), delta, f );
|
||||
}
|
||||
|
||||
for(int i = 0; i < height; i++)
|
||||
{
|
||||
fread(data, sizeof(unsigned char), row_padded, f);
|
||||
for(int j = 0; j < width*3; j += 3)
|
||||
{
|
||||
B=data[j];
|
||||
G=data[j+1];
|
||||
R=data[j+2];
|
||||
uint16_t color = ((R & 0xf8) << 8) | ((G & 0xfc) << 3) | ((B & 0xf8) >> 3);
|
||||
cSDL_SetPixel( bmp, j/3, (height-1)-i, color );
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
fclose(f);
|
||||
|
||||
return bmp;
|
||||
}
|
||||
|
||||
|
||||
SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
|
||||
{
|
||||
|
@ -240,14 +295,14 @@ SDL_Surface * SDL_LoadBMP_RW (SDL_RWops *src, int freesrc)
|
|||
SDL_RWread(src, &palette->colors[i].g, 1, 1);
|
||||
SDL_RWread(src, &palette->colors[i].r, 1, 1);
|
||||
palette->colors[i].unused = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for ( i = 0; i < (int)biClrUsed; ++i ) {
|
||||
SDL_RWread(src, &palette->colors[i].b, 1, 1);
|
||||
SDL_RWread(src, &palette->colors[i].g, 1, 1);
|
||||
SDL_RWread(src, &palette->colors[i].r, 1, 1);
|
||||
SDL_RWread(src, &palette->colors[i].unused, 1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
palette->ncolors = biClrUsed;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ struct SDL_VideoDevice {
|
|||
/* * * */
|
||||
/* Initialization/Query functions */
|
||||
|
||||
/* Initialize the native video subsystem, filling 'vformat' with the
|
||||
/* Initialize the native video subsystem, filling 'vformat' with the
|
||||
"best" display pixel format, returning 0 or -1 if there's an error.
|
||||
*/
|
||||
int (*VideoInit)(_THIS, SDL_PixelFormat *vformat);
|
||||
|
@ -119,7 +119,7 @@ struct SDL_VideoDevice {
|
|||
|
||||
/* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
|
||||
SDL_PixelFormat* displayformatalphapixel;
|
||||
|
||||
|
||||
/* Allocates a surface in video memory */
|
||||
int (*AllocHWSurface)(_THIS, SDL_Surface *surface);
|
||||
|
||||
|
@ -195,7 +195,7 @@ struct SDL_VideoDevice {
|
|||
GLuint texture;
|
||||
#endif
|
||||
int is_32bit;
|
||||
|
||||
|
||||
/* * * */
|
||||
/* Window manager functions */
|
||||
|
||||
|
@ -410,6 +410,9 @@ extern VideoBootStrap AALIB_bootstrap;
|
|||
#if SDL_VIDEO_DRIVER_CACA
|
||||
extern VideoBootStrap CACA_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PRIZME
|
||||
extern VideoBootStrap PRZ_bootstrap;
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
extern VideoBootStrap DUMMY_bootstrap;
|
||||
#endif
|
||||
|
|
|
@ -31,6 +31,8 @@
|
|||
#include "../events/SDL_sysevents.h"
|
||||
#include "../events/SDL_events_c.h"
|
||||
|
||||
extern VideoBootStrap PRZ_bootstrap;
|
||||
|
||||
/* Available video drivers */
|
||||
static VideoBootStrap *bootstrap[] = {
|
||||
#if SDL_VIDEO_DRIVER_QUARTZ
|
||||
|
@ -128,6 +130,9 @@ static VideoBootStrap *bootstrap[] = {
|
|||
#endif
|
||||
#if SDL_VIDEO_DRIVER_DUMMY
|
||||
&DUMMY_bootstrap,
|
||||
#endif
|
||||
#if SDL_VIDEO_DRIVER_PRIZM
|
||||
&PRZ_bootstrap,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@ -217,7 +222,7 @@ int SDL_VideoInit (const char *driver_name, Uint32 flags)
|
|||
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 */
|
||||
|
@ -240,7 +245,7 @@ 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 ) {
|
||||
|
@ -397,7 +402,7 @@ 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
|
||||
} else
|
||||
if (sizes == (SDL_Rect **)NEGATIVE_ONE) {
|
||||
/* Any size supported at this bit-depth */
|
||||
supported = 1;
|
||||
|
@ -788,7 +793,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
#endif /* __SDL_NOGETPROCADDR__ */
|
||||
|
||||
#include "SDL_glfuncs.h"
|
||||
#undef SDL_PROC
|
||||
#undef SDL_PROC
|
||||
}
|
||||
#endif /* SDL_VIDEO_OPENGL */
|
||||
|
||||
|
@ -817,9 +822,9 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
) {
|
||||
video->is_32bit = 0;
|
||||
SDL_VideoSurface = SDL_CreateRGBSurface(
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
flags,
|
||||
width,
|
||||
height,
|
||||
16,
|
||||
31 << 11,
|
||||
63 << 5,
|
||||
|
@ -832,10 +837,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,
|
||||
|
@ -893,7 +898,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
(
|
||||
( !(flags&SDL_ANYFORMAT) &&
|
||||
(SDL_VideoSurface->format->BitsPerPixel != bpp)) ||
|
||||
( (flags&SDL_HWPALETTE) &&
|
||||
( (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
|
||||
|
@ -921,7 +926,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
|
|||
return(SDL_PublicSurface);
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Convert a surface into the video pixel format.
|
||||
*/
|
||||
SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
|
||||
|
@ -935,7 +940,7 @@ SDL_Surface * SDL_DisplayFormat (SDL_Surface *surface)
|
|||
/* Set the flags appropriate for copying to display surface */
|
||||
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));
|
||||
|
@ -1063,14 +1068,14 @@ void SDL_UpdateRects (SDL_Surface *screen, int numrects, SDL_Rect *rects)
|
|||
SDL_LockCursor();
|
||||
SDL_DrawCursor(SDL_ShadowSurface);
|
||||
for ( i=0; i<numrects; ++i ) {
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_VideoSurface, &rects[i]);
|
||||
}
|
||||
SDL_EraseCursor(SDL_ShadowSurface);
|
||||
SDL_UnlockCursor();
|
||||
} else {
|
||||
for ( i=0; i<numrects; ++i ) {
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_LowerBlit(SDL_ShadowSurface, &rects[i],
|
||||
SDL_VideoSurface, &rects[i]);
|
||||
}
|
||||
}
|
||||
|
@ -1576,42 +1581,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;
|
||||
}
|
||||
|
@ -1641,7 +1646,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);
|
||||
|
||||
|
|
|
@ -1,45 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Being a null driver, there's no event stream. We just define stubs for
|
||||
most of the API. */
|
||||
|
||||
#include "SDL.h"
|
||||
#include "../../events/SDL_sysevents.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
#include "SDL_nullevents_c.h"
|
||||
|
||||
void DUMMY_PumpEvents(_THIS)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
void DUMMY_InitOSKeymap(_THIS)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
/* end of SDL_nullevents.c ... */
|
||||
|
|
@ -1,33 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
|
||||
/* Variables and functions exported by SDL_sysevents.c to other parts
|
||||
of the native video subsystem (SDL_sysvideo.c)
|
||||
*/
|
||||
extern void DUMMY_InitOSKeymap(_THIS);
|
||||
extern void DUMMY_PumpEvents(_THIS);
|
||||
|
||||
/* end of SDL_nullevents_c.h ... */
|
||||
|
|
@ -1,33 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_mouse.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
|
||||
#include "SDL_nullmouse_c.h"
|
||||
|
||||
|
||||
/* The implementation dependent data for the window manager cursor */
|
||||
struct WMcursor {
|
||||
int unused;
|
||||
};
|
|
@ -1,26 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_nullvideo.h"
|
||||
|
||||
/* Functions to be exported */
|
|
@ -1,239 +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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
/* Dummy SDL video driver implementation; this is just enough to make an
|
||||
* SDL-based application THINK it's got a working video driver, for
|
||||
* applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it,
|
||||
* and also for use as a collection of stubs when porting SDL to a new
|
||||
* platform for which you haven't yet written a valid video driver.
|
||||
*
|
||||
* This is also a great way to determine bottlenecks: if you think that SDL
|
||||
* is a performance problem for a given platform, enable this driver, and
|
||||
* then see if your application runs faster without video overhead.
|
||||
*
|
||||
* Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion
|
||||
* of this was cut-and-pasted from Stephane Peter's work in the AAlib
|
||||
* SDL video driver. Renamed to "DUMMY" by Sam Lantinga.
|
||||
*/
|
||||
|
||||
#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_nullvideo.h"
|
||||
#include "SDL_nullevents_c.h"
|
||||
#include "SDL_nullmouse_c.h"
|
||||
|
||||
#define DUMMYVID_DRIVER_NAME "dummy"
|
||||
|
||||
/* Initialization/Query functions */
|
||||
static int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat);
|
||||
static SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
|
||||
static SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
|
||||
static int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
|
||||
static void DUMMY_VideoQuit(_THIS);
|
||||
|
||||
/* Hardware surface functions */
|
||||
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface);
|
||||
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface);
|
||||
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface);
|
||||
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface);
|
||||
|
||||
/* etc. */
|
||||
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
|
||||
|
||||
/* DUMMY driver bootstrap functions */
|
||||
|
||||
static int DUMMY_Available(void)
|
||||
{
|
||||
const char *envr = SDL_getenv("SDL_VIDEODRIVER");
|
||||
if ((envr) && (SDL_strcmp(envr, DUMMYVID_DRIVER_NAME) == 0)) {
|
||||
return(1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMY_DeleteDevice(SDL_VideoDevice *device)
|
||||
{
|
||||
SDL_free(device->hidden);
|
||||
SDL_free(device);
|
||||
}
|
||||
|
||||
static SDL_VideoDevice *DUMMY_CreateDevice(int devindex)
|
||||
{
|
||||
SDL_VideoDevice *device;
|
||||
|
||||
/* 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 = DUMMY_VideoInit;
|
||||
device->ListModes = DUMMY_ListModes;
|
||||
device->SetVideoMode = DUMMY_SetVideoMode;
|
||||
device->CreateYUVOverlay = NULL;
|
||||
device->SetColors = DUMMY_SetColors;
|
||||
device->UpdateRects = DUMMY_UpdateRects;
|
||||
device->VideoQuit = DUMMY_VideoQuit;
|
||||
device->AllocHWSurface = DUMMY_AllocHWSurface;
|
||||
device->CheckHWBlit = NULL;
|
||||
device->FillHWRect = NULL;
|
||||
device->SetHWColorKey = NULL;
|
||||
device->SetHWAlpha = NULL;
|
||||
device->LockHWSurface = DUMMY_LockHWSurface;
|
||||
device->UnlockHWSurface = DUMMY_UnlockHWSurface;
|
||||
device->FlipHWSurface = NULL;
|
||||
device->FreeHWSurface = DUMMY_FreeHWSurface;
|
||||
device->SetCaption = NULL;
|
||||
device->SetIcon = NULL;
|
||||
device->IconifyWindow = NULL;
|
||||
device->GrabInput = NULL;
|
||||
device->GetWMInfo = NULL;
|
||||
device->InitOSKeymap = DUMMY_InitOSKeymap;
|
||||
device->PumpEvents = DUMMY_PumpEvents;
|
||||
|
||||
device->free = DUMMY_DeleteDevice;
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
VideoBootStrap DUMMY_bootstrap = {
|
||||
DUMMYVID_DRIVER_NAME, "SDL dummy video driver",
|
||||
DUMMY_Available, DUMMY_CreateDevice
|
||||
};
|
||||
|
||||
|
||||
int DUMMY_VideoInit(_THIS, SDL_PixelFormat *vformat)
|
||||
{
|
||||
/*
|
||||
fprintf(stderr, "WARNING: You are using the SDL dummy video driver!\n");
|
||||
*/
|
||||
|
||||
/* Determine the screen depth (use default 8-bit depth) */
|
||||
/* we change this during the SDL_SetVideoMode implementation... */
|
||||
vformat->BitsPerPixel = 8;
|
||||
vformat->BytesPerPixel = 1;
|
||||
|
||||
/* We're done! */
|
||||
return(0);
|
||||
}
|
||||
|
||||
SDL_Rect **DUMMY_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
|
||||
{
|
||||
return (SDL_Rect **) -1;
|
||||
}
|
||||
|
||||
SDL_Surface *DUMMY_SetVideoMode(_THIS, SDL_Surface *current,
|
||||
int width, int height, int bpp, Uint32 flags)
|
||||
{
|
||||
if ( this->hidden->buffer ) {
|
||||
SDL_free( this->hidden->buffer );
|
||||
}
|
||||
|
||||
this->hidden->buffer = SDL_malloc(width * height * (bpp / 8));
|
||||
if ( ! this->hidden->buffer ) {
|
||||
SDL_SetError("Couldn't allocate buffer for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* printf("Setting mode %dx%d\n", width, height); */
|
||||
|
||||
SDL_memset(this->hidden->buffer, 0, width * height * (bpp / 8));
|
||||
|
||||
/* Allocate the new pixel format for the screen */
|
||||
if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
|
||||
SDL_free(this->hidden->buffer);
|
||||
this->hidden->buffer = NULL;
|
||||
SDL_SetError("Couldn't allocate new pixel format for requested mode");
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
/* Set up the new mode framebuffer */
|
||||
current->flags = flags & SDL_FULLSCREEN;
|
||||
this->hidden->w = current->w = width;
|
||||
this->hidden->h = current->h = height;
|
||||
current->pitch = current->w * (bpp / 8);
|
||||
current->pixels = this->hidden->buffer;
|
||||
|
||||
/* We're done */
|
||||
return(current);
|
||||
}
|
||||
|
||||
/* We don't actually allow hardware surfaces other than the main one */
|
||||
static int DUMMY_AllocHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return(-1);
|
||||
}
|
||||
static void DUMMY_FreeHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* We need to wait for vertical retrace on page flipped displays */
|
||||
static int DUMMY_LockHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void DUMMY_UnlockHWSurface(_THIS, SDL_Surface *surface)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
static void DUMMY_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
|
||||
{
|
||||
/* do nothing. */
|
||||
}
|
||||
|
||||
int DUMMY_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
|
||||
{
|
||||
/* do nothing of note. */
|
||||
return(1);
|
||||
}
|
||||
|
||||
/* Note: If we are terminated, this could be called in the middle of
|
||||
another SDL video routine -- notably UpdateRects.
|
||||
*/
|
||||
void DUMMY_VideoQuit(_THIS)
|
||||
{
|
||||
if (this->screen->pixels != NULL)
|
||||
{
|
||||
SDL_free(this->screen->pixels);
|
||||
this->screen->pixels = NULL;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,246 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL.h"
|
||||
#include "../../events/SDL_sysevents.h"
|
||||
#include "../../events/SDL_events_c.h"
|
||||
#include "../SDL_cursor_c.h"
|
||||
|
||||
#include <gint/keyboard.h>
|
||||
|
||||
#include "SDL_prizmvideo.h"
|
||||
#include "SDL_prizmevents_c.h"
|
||||
|
||||
static int przk_keymap[PRZ_NUMKEYS];
|
||||
static SDLKey sdlk_keymap[PRZ_NUMKEYS];
|
||||
static Uint8 key_state[PRZ_NUMKEYS];
|
||||
|
||||
static SDLKey sdlak_keymap[4] = {SDLK_UP, SDLK_RIGHT, SDLK_DOWN, SDLK_LEFT};
|
||||
static Uint8 arrow_key_state[4];
|
||||
|
||||
|
||||
bool keystatus( int keycode )
|
||||
{
|
||||
if (keydown( keycode) !=0 ) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
static void PRZ_update_keyboard(void)
|
||||
{
|
||||
clearevents();
|
||||
|
||||
bool key_pressed[PRZ_NUMKEYS];
|
||||
|
||||
for ( int i = 0; i < PRZ_NUMKEYS; ++i )
|
||||
{
|
||||
key_pressed[i] = keystatus( przk_keymap[i] );
|
||||
|
||||
if ( sdlk_keymap[i] != SDLK_UNKNOWN )
|
||||
PRZ_UPDATE_KEY_EVENT(sdlk_keymap[i], i, key_state[i], key_pressed[i]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
static void PRZ_update_arrow_keys(void)
|
||||
{
|
||||
clearevents();
|
||||
|
||||
bool arrow_key_pressed[4] = { keystatus(KEY_UP), keystatus(KEY_RIGHT), keystatus(KEY_DOWN), keystatus(KEY_LEFT) };
|
||||
|
||||
for ( int i = 0; i < 4; ++i )
|
||||
PRZ_UPDATE_KEY_EVENT(sdlak_keymap[i], i, arrow_key_state[i], arrow_key_pressed[i]);
|
||||
}
|
||||
|
||||
void PRZ_PumpEvents(_THIS)
|
||||
{
|
||||
PRZ_update_keyboard();
|
||||
//PRZ_update_arrow_keys();
|
||||
}
|
||||
|
||||
void PRZ_InitOSKeymap(_THIS)
|
||||
{
|
||||
/* Enum value -> KEY_NSPIRE_* */
|
||||
|
||||
|
||||
przk_keymap[ PRZ_KEY_F1 ]= KEY_F1 ;
|
||||
przk_keymap[ PRZ_KEY_F2 ]= KEY_F2 ;
|
||||
przk_keymap[ PRZ_KEY_F3 ]= KEY_F3 ;
|
||||
przk_keymap[ PRZ_KEY_F4 ]= KEY_F4 ;
|
||||
przk_keymap[ PRZ_KEY_F5 ]= KEY_F5 ;
|
||||
przk_keymap[ PRZ_KEY_F6 ]= KEY_F6 ;
|
||||
przk_keymap[ PRZ_KEY_SHIFT ]= KEY_SHIFT ;
|
||||
przk_keymap[ PRZ_KEY_OPTN ]= KEY_OPTN ;
|
||||
przk_keymap[ PRZ_KEY_VARS ]= KEY_VARS ;
|
||||
przk_keymap[ PRZ_KEY_MENU ]= KEY_MENU ;
|
||||
przk_keymap[ PRZ_KEY_LEFT ]= KEY_LEFT ;
|
||||
przk_keymap[ PRZ_KEY_UP ]= KEY_UP ;
|
||||
przk_keymap[ PRZ_KEY_ALPHA ]= KEY_ALPHA ;
|
||||
przk_keymap[ PRZ_KEY_SQUARE ]= KEY_SQUARE ;
|
||||
przk_keymap[ PRZ_KEY_POWER ]= KEY_POWER ;
|
||||
przk_keymap[ PRZ_KEY_EXIT ]= KEY_EXIT ;
|
||||
przk_keymap[ PRZ_KEY_DOWN ]= KEY_DOWN ;
|
||||
przk_keymap[ PRZ_KEY_RIGHT ]= KEY_RIGHT ;
|
||||
przk_keymap[ PRZ_KEY_XOT ]= KEY_XOT ;
|
||||
przk_keymap[ PRZ_KEY_LOG ]= KEY_LOG ;
|
||||
przk_keymap[ PRZ_KEY_LN ]= KEY_LN ;
|
||||
przk_keymap[ PRZ_KEY_SIN ]= KEY_SIN ;
|
||||
przk_keymap[ PRZ_KEY_COS ]= KEY_COS ;
|
||||
przk_keymap[ PRZ_KEY_TAN ]= KEY_TAN ;
|
||||
przk_keymap[ PRZ_KEY_FRAC ]= KEY_FRAC ;
|
||||
przk_keymap[ PRZ_KEY_FD ]= KEY_FD ;
|
||||
przk_keymap[ PRZ_KEY_LEFTP ]= KEY_LEFTP ;
|
||||
przk_keymap[ PRZ_KEY_RIGHTP ]= KEY_RIGHTP ;
|
||||
przk_keymap[ PRZ_KEY_COMMA ]= KEY_COMMA ;
|
||||
przk_keymap[ PRZ_KEY_ARROW ]= KEY_ARROW ;
|
||||
przk_keymap[ PRZ_KEY_7 ]= KEY_7 ;
|
||||
przk_keymap[ PRZ_KEY_8 ]= KEY_8 ;
|
||||
przk_keymap[ PRZ_KEY_9 ]= KEY_9 ;
|
||||
przk_keymap[ PRZ_KEY_DEL ]= KEY_DEL ;
|
||||
przk_keymap[ PRZ_KEY_4 ]= KEY_4 ;
|
||||
przk_keymap[ PRZ_KEY_5 ]= KEY_5 ;
|
||||
przk_keymap[ PRZ_KEY_6 ]= KEY_6 ;
|
||||
przk_keymap[ PRZ_KEY_MUL ]= KEY_MUL ;
|
||||
przk_keymap[ PRZ_KEY_DIV ]= KEY_DIV ;
|
||||
przk_keymap[ PRZ_KEY_1 ]= KEY_1 ;
|
||||
przk_keymap[ PRZ_KEY_2 ]= KEY_2 ;
|
||||
przk_keymap[ PRZ_KEY_3 ]= KEY_3 ;
|
||||
przk_keymap[ PRZ_KEY_ADD ]= KEY_ADD ;
|
||||
przk_keymap[ PRZ_KEY_SUB ]= KEY_SUB ;
|
||||
przk_keymap[ PRZ_KEY_0 ]= KEY_0 ;
|
||||
przk_keymap[ PRZ_KEY_DOT ]= KEY_DOT ;
|
||||
przk_keymap[ PRZ_KEY_EXP ]= KEY_EXP ;
|
||||
przk_keymap[ PRZ_KEY_NEG ]= KEY_NEG ;
|
||||
przk_keymap[ PRZ_KEY_EXE ]= KEY_EXE ;
|
||||
przk_keymap[ PRZ_KEY_ACON ]= KEY_ACON ;
|
||||
|
||||
|
||||
/* Enum value -> SDLK_*
|
||||
This is the actual key mapping part. */
|
||||
/*sdlk_keymap[ PRZ_KEY_F1 ]= SDLK_F1 ;
|
||||
sdlk_keymap[ PRZ_KEY_F2 ]= SDLK_F2 ;
|
||||
sdlk_keymap[ PRZ_KEY_F3 ]= SDLK_F3 ;
|
||||
sdlk_keymap[ PRZ_KEY_F4 ]= SDLK_F4 ;
|
||||
sdlk_keymap[ PRZ_KEY_F5 ]= SDLK_F5 ;
|
||||
sdlk_keymap[ PRZ_KEY_F6 ]= SDLK_F6 ;
|
||||
sdlk_keymap[ PRZ_KEY_SHIFT ]= SDLK_LSHIFT ;
|
||||
sdlk_keymap[ PRZ_KEY_OPTN ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_VARS ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_MENU ]= SDLK_MENU ;
|
||||
sdlk_keymap[ PRZ_KEY_LEFT ]= SDLK_LEFT ;
|
||||
sdlk_keymap[ PRZ_KEY_UP ]= SDLK_UP ;
|
||||
sdlk_keymap[ PRZ_KEY_ALPHA ]= SDLK_CAPSLOCK ;
|
||||
sdlk_keymap[ PRZ_KEY_SQUARE ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_POWER ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_EXIT ]= SDLK_ESCAPE ;
|
||||
sdlk_keymap[ PRZ_KEY_DOWN ]= SDLK_DOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_RIGHT ]= SDLK_RIGHT ;
|
||||
sdlk_keymap[ PRZ_KEY_XOT ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_LOG ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_LN ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_SIN ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_COS ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_TAN ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_FRAC ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_FD ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_LEFTP ]= SDLK_LEFTPAREN ;
|
||||
sdlk_keymap[ PRZ_KEY_RIGHTP ]= SDLK_RIGHTPAREN ;
|
||||
sdlk_keymap[ PRZ_KEY_COMMA ]= SDLK_COMMA ;
|
||||
sdlk_keymap[ PRZ_KEY_ARROW ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_7 ]= SDLK_KP7 ;
|
||||
sdlk_keymap[ PRZ_KEY_8 ]= SDLK_KP8 ;
|
||||
sdlk_keymap[ PRZ_KEY_9 ]= SDLK_KP9 ;
|
||||
sdlk_keymap[ PRZ_KEY_DEL ]= SDLK_DELETE ;
|
||||
sdlk_keymap[ PRZ_KEY_4 ]= SDLK_KP4 ;
|
||||
sdlk_keymap[ PRZ_KEY_5 ]= SDLK_KP5 ;
|
||||
sdlk_keymap[ PRZ_KEY_6 ]= SDLK_KP6 ;
|
||||
sdlk_keymap[ PRZ_KEY_MUL ]= SDLK_KP_MULTIPLY ;
|
||||
sdlk_keymap[ PRZ_KEY_DIV ]= SDLK_KP_DIVIDE ;
|
||||
sdlk_keymap[ PRZ_KEY_1 ]= SDLK_KP1 ;
|
||||
sdlk_keymap[ PRZ_KEY_2 ]= SDLK_KP2 ;
|
||||
sdlk_keymap[ PRZ_KEY_3 ]= SDLK_KP3 ;
|
||||
sdlk_keymap[ PRZ_KEY_ADD ]= SDLK_KP_PLUS ;
|
||||
sdlk_keymap[ PRZ_KEY_SUB ]= SDLK_KP_MINUS ;
|
||||
sdlk_keymap[ PRZ_KEY_0 ]= SDLK_KP0 ;
|
||||
sdlk_keymap[ PRZ_KEY_DOT ]= SDLK_KP_PERIOD ;
|
||||
sdlk_keymap[ PRZ_KEY_EXP ]= SDLK_UNKNOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_NEG ]= SDLK_MINUS ;
|
||||
sdlk_keymap[ PRZ_KEY_EXE ]= SDLK_RETURN ;
|
||||
sdlk_keymap[ PRZ_KEY_ACON ]= SDLK_POWER ;
|
||||
*/
|
||||
|
||||
sdlk_keymap[ PRZ_KEY_F1 ]=SDLK_PRZ_KEY_F1 ;
|
||||
sdlk_keymap[ PRZ_KEY_F2 ]=SDLK_PRZ_KEY_F2 ;
|
||||
sdlk_keymap[ PRZ_KEY_F3 ]=SDLK_PRZ_KEY_F3 ;
|
||||
sdlk_keymap[ PRZ_KEY_F4 ]=SDLK_PRZ_KEY_F4 ;
|
||||
sdlk_keymap[ PRZ_KEY_F5 ]=SDLK_PRZ_KEY_F5 ;
|
||||
sdlk_keymap[ PRZ_KEY_F6 ]=SDLK_PRZ_KEY_F6 ;
|
||||
sdlk_keymap[ PRZ_KEY_SHIFT ]=SDLK_PRZ_KEY_SHIFT ;
|
||||
sdlk_keymap[ PRZ_KEY_OPTN ]=SDLK_PRZ_KEY_OPTN ;
|
||||
sdlk_keymap[ PRZ_KEY_VARS ]=SDLK_PRZ_KEY_VARS ;
|
||||
sdlk_keymap[ PRZ_KEY_MENU ]=SDLK_PRZ_KEY_MENU ;
|
||||
sdlk_keymap[ PRZ_KEY_LEFT ]=SDLK_PRZ_KEY_LEFT ;
|
||||
sdlk_keymap[ PRZ_KEY_UP ]=SDLK_PRZ_KEY_UP ;
|
||||
sdlk_keymap[ PRZ_KEY_ALPHA ]=SDLK_PRZ_KEY_ALPHA ;
|
||||
sdlk_keymap[ PRZ_KEY_SQUARE ]=SDLK_PRZ_KEY_SQUARE ;
|
||||
sdlk_keymap[ PRZ_KEY_POWER ]=SDLK_PRZ_KEY_POWER ;
|
||||
sdlk_keymap[ PRZ_KEY_EXIT ]=SDLK_PRZ_KEY_EXIT ;
|
||||
sdlk_keymap[ PRZ_KEY_DOWN ]=SDLK_PRZ_KEY_DOWN ;
|
||||
sdlk_keymap[ PRZ_KEY_RIGHT ]=SDLK_PRZ_KEY_RIGHT ;
|
||||
sdlk_keymap[ PRZ_KEY_XOT ]=SDLK_PRZ_KEY_XOT ;
|
||||
sdlk_keymap[ PRZ_KEY_LOG ]=SDLK_PRZ_KEY_LOG ;
|
||||
sdlk_keymap[ PRZ_KEY_LN ]=SDLK_PRZ_KEY_LN ;
|
||||
sdlk_keymap[ PRZ_KEY_SIN ]=SDLK_PRZ_KEY_SIN ;
|
||||
sdlk_keymap[ PRZ_KEY_COS ]=SDLK_PRZ_KEY_COS ;
|
||||
sdlk_keymap[ PRZ_KEY_TAN ]=SDLK_PRZ_KEY_TAN ;
|
||||
sdlk_keymap[ PRZ_KEY_FRAC ]=SDLK_PRZ_KEY_FRAC ;
|
||||
sdlk_keymap[ PRZ_KEY_FD ]=SDLK_PRZ_KEY_FD ;
|
||||
sdlk_keymap[ PRZ_KEY_LEFTP ]=SDLK_PRZ_KEY_LEFTP ;
|
||||
sdlk_keymap[ PRZ_KEY_RIGHTP ]=SDLK_PRZ_KEY_RIGHTP ;
|
||||
sdlk_keymap[ PRZ_KEY_COMMA ]=SDLK_PRZ_KEY_COMMA ;
|
||||
sdlk_keymap[ PRZ_KEY_ARROW ]=SDLK_PRZ_KEY_ARROW ;
|
||||
sdlk_keymap[ PRZ_KEY_7 ]=SDLK_PRZ_KEY_7 ;
|
||||
sdlk_keymap[ PRZ_KEY_8 ]=SDLK_PRZ_KEY_8 ;
|
||||
sdlk_keymap[ PRZ_KEY_9 ]=SDLK_PRZ_KEY_9 ;
|
||||
sdlk_keymap[ PRZ_KEY_DEL ]=SDLK_PRZ_KEY_DEL ;
|
||||
sdlk_keymap[ PRZ_KEY_4 ]=SDLK_PRZ_KEY_4 ;
|
||||
sdlk_keymap[ PRZ_KEY_5 ]=SDLK_PRZ_KEY_5 ;
|
||||
sdlk_keymap[ PRZ_KEY_6 ]=SDLK_PRZ_KEY_6 ;
|
||||
sdlk_keymap[ PRZ_KEY_MUL ]=SDLK_PRZ_KEY_MUL ;
|
||||
sdlk_keymap[ PRZ_KEY_DIV ]=SDLK_PRZ_KEY_DIV ;
|
||||
sdlk_keymap[ PRZ_KEY_1 ]=SDLK_PRZ_KEY_1 ;
|
||||
sdlk_keymap[ PRZ_KEY_2 ]=SDLK_PRZ_KEY_2 ;
|
||||
sdlk_keymap[ PRZ_KEY_3 ]=SDLK_PRZ_KEY_3 ;
|
||||
sdlk_keymap[ PRZ_KEY_ADD ]=SDLK_PRZ_KEY_ADD ;
|
||||
sdlk_keymap[ PRZ_KEY_SUB ]=SDLK_PRZ_KEY_SUB ;
|
||||
sdlk_keymap[ PRZ_KEY_0 ]=SDLK_PRZ_KEY_0 ;
|
||||
sdlk_keymap[ PRZ_KEY_DOT ]=SDLK_PRZ_KEY_DOT ;
|
||||
sdlk_keymap[ PRZ_KEY_EXP ]=SDLK_PRZ_KEY_EXP ;
|
||||
sdlk_keymap[ PRZ_KEY_NEG ]=SDLK_PRZ_KEY_NEG ;
|
||||
sdlk_keymap[ PRZ_KEY_EXE ]=SDLK_PRZ_KEY_EXE ;
|
||||
sdlk_keymap[ PRZ_KEY_ACON ]=SDLK_PRZ_KEY_ACON ;
|
||||
|
||||
}
|
||||
|
||||
/* end of SDL_tinspireevents.c ... */
|
||||
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
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
|
||||
*/
|
||||
#include "SDL_config.h"
|
||||
|
||||
#include "SDL_prizmvideo.h"
|
||||
|
||||
#define PRZ_UPDATE_KEY_EVENT(s, sc, ks, kp) do { \
|
||||
SDL_keysym keysym; \
|
||||
keysym.scancode = sc; \
|
||||
keysym.sym = s; \
|
||||
if ( ks == SDL_RELEASED ) { \
|
||||
if ( kp ) { \
|
||||
SDL_PrivateKeyboard(SDL_PRESSED, &keysym); \
|
||||
ks = SDL_PRESSED; \
|
||||
} \
|
||||
} else if ( ! kp ) { \
|
||||
SDL_PrivateKeyboard(SDL_RELEASED, &keysym); \
|
||||
ks = SDL_RELEASED; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
/* Keys */
|
||||
enum {
|
||||
PRZ_KEY_F1,
|
||||
PRZ_KEY_F2,
|
||||
PRZ_KEY_F3,
|
||||
PRZ_KEY_F4,
|
||||
PRZ_KEY_F5,
|
||||
PRZ_KEY_F6,
|
||||
PRZ_KEY_SHIFT,
|
||||
PRZ_KEY_OPTN,
|
||||
PRZ_KEY_VARS,
|
||||
PRZ_KEY_MENU,
|
||||
PRZ_KEY_LEFT,
|
||||
PRZ_KEY_UP,
|
||||
PRZ_KEY_ALPHA,
|
||||
PRZ_KEY_SQUARE,
|
||||
PRZ_KEY_POWER,
|
||||
PRZ_KEY_EXIT,
|
||||
PRZ_KEY_DOWN,
|
||||
PRZ_KEY_RIGHT,
|
||||
PRZ_KEY_XOT,
|
||||
PRZ_KEY_LOG,
|
||||
PRZ_KEY_LN,
|
||||
PRZ_KEY_SIN,
|
||||
PRZ_KEY_COS,
|
||||
PRZ_KEY_TAN,
|
||||
PRZ_KEY_FRAC,
|
||||
PRZ_KEY_FD,
|
||||
PRZ_KEY_LEFTP,
|
||||
PRZ_KEY_RIGHTP,
|
||||
PRZ_KEY_COMMA,
|
||||
PRZ_KEY_ARROW,
|
||||
PRZ_KEY_7,
|
||||
PRZ_KEY_8,
|
||||
PRZ_KEY_9,
|
||||
PRZ_KEY_DEL,
|
||||
PRZ_KEY_4,
|
||||
PRZ_KEY_5,
|
||||
PRZ_KEY_6,
|
||||
PRZ_KEY_MUL,
|
||||
PRZ_KEY_DIV,
|
||||
PRZ_KEY_1,
|
||||
PRZ_KEY_2,
|
||||
PRZ_KEY_3,
|
||||
PRZ_KEY_ADD,
|
||||
PRZ_KEY_SUB,
|
||||
PRZ_KEY_0,
|
||||
PRZ_KEY_DOT,
|
||||
PRZ_KEY_EXP,
|
||||
PRZ_KEY_NEG,
|
||||
PRZ_KEY_EXE,
|
||||
PRZ_KEY_ACON,
|
||||
// PRZ_KEY_LEFTUP,
|
||||
// PRZ_KEY_LEFTDOWN,
|
||||
// PRZ_KEY_RIGHTUP,
|
||||
// PRZ_KEY_RIGHTDOWN,
|
||||
PRZ_NUMKEYS
|
||||
};
|
||||
|
||||
/* Variables and functions exported by SDL_sysevents.c to other parts
|
||||
of the native video subsystem (SDL_sysvideo.c)
|
||||
*/
|
||||
extern void PRZ_InitOSKeymap(_THIS);
|
||||
extern void PRZ_PumpEvents(_THIS);
|
||||
|
||||
/* end of SDL_tinspireevents_c.h ... */
|
|
@ -0,0 +1,133 @@
|
|||
#include "SDL_config.h"
|
||||
#include "../SDL_sysvideo.h"
|
||||
#include "SDL_prizmvideo.h"
|
||||
#include "SDL_prizmfonts.h"
|
||||
|
||||
cSDL_Font *cSDL_LoadFont(int font_index, Uint8 r, Uint8 g, Uint8 b)
|
||||
{
|
||||
cSDL_Font *font;
|
||||
int i, j, k;
|
||||
|
||||
font = SDL_malloc(sizeof(*font));
|
||||
if ( font == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
for ( i = 0; i < PRZ_FONT_NUMCHARS; ++i ) {
|
||||
int offset = 8 * i;
|
||||
int max_width = 0;
|
||||
Uint32 color;
|
||||
SDL_Surface *tmp = SDL_CreateRGBSurface(SDL_SWSURFACE, PRZ_FONT_WIDTH, PRZ_FONT_HEIGHT,
|
||||
16, PRZ_RMASK16, PRZ_GMASK16, PRZ_BMASK16, 0);
|
||||
if ( tmp == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
color = SDL_MapRGB(tmp->format, r, g, b);
|
||||
SDL_FillRect(tmp, NULL, ! color);
|
||||
SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, ! color);
|
||||
font->char_width[i] = PRZ_FONT_WIDTH;
|
||||
SDL_LockSurface(tmp);
|
||||
for ( j = 0; j < PRZ_FONT_HEIGHT; ++j )
|
||||
for ( k = 0; k < PRZ_FONT_WIDTH; ++k ) {
|
||||
if ( prz_font_charmaps[font_index][offset + j] & (1 << (PRZ_FONT_WIDTH - k - 1)) ) { /* "Pixel" set */
|
||||
if ( k > max_width ) {
|
||||
font->char_width[i] = k + 1;
|
||||
max_width = k;
|
||||
}
|
||||
cSDL_SetPixel(tmp, k, j, color);
|
||||
}
|
||||
}
|
||||
SDL_UnlockSurface(tmp);
|
||||
font->chars[i] = SDL_DisplayFormat(tmp);
|
||||
SDL_FreeSurface(tmp);
|
||||
font->hspacing = font->vspacing = 0;
|
||||
font->monospaced = SDL_FALSE;
|
||||
}
|
||||
|
||||
return(font);
|
||||
}
|
||||
|
||||
void cSDL_SetFontSpacing(cSDL_Font *font, int hspacing, int vspacing)
|
||||
{
|
||||
font->hspacing = hspacing;
|
||||
font->vspacing = vspacing;
|
||||
}
|
||||
|
||||
void cSDL_EnableFontMonospaced(cSDL_Font *font, SDL_bool toggle)
|
||||
{
|
||||
font->monospaced = toggle;
|
||||
}
|
||||
|
||||
void cSDL_FreeFont(cSDL_Font *font)
|
||||
{
|
||||
int i;
|
||||
if ( font == NULL )
|
||||
return;
|
||||
for ( i = 0; i < PRZ_FONT_NUMCHARS; ++i )
|
||||
SDL_FreeSurface(font->chars[i]);
|
||||
SDL_free(font);
|
||||
}
|
||||
|
||||
int cSDL_DrawString(SDL_Surface *surface, cSDL_Font *font,
|
||||
int x, int y, const char *format, ...)
|
||||
{
|
||||
char buf[PRZ_BUF_SIZE];
|
||||
int length;
|
||||
SDL_Rect pos;
|
||||
va_list args;
|
||||
int i;
|
||||
|
||||
va_start(args, format);
|
||||
if ( vsprintf(buf, format, args) < 0 )
|
||||
return(-1);
|
||||
va_end(args);
|
||||
length = (int)strlen(buf);
|
||||
pos.x = x;
|
||||
pos.y = y;
|
||||
PRZ_DEBUG("\"%s\" at (%d, %d)", buf, pos.x, pos.y);
|
||||
|
||||
for ( i = 0; i < length; ++i ) {
|
||||
int c = buf[i];
|
||||
if ( c == '\n' ) {
|
||||
pos.x = x;
|
||||
pos.y += PRZ_FONT_HEIGHT + font->vspacing;
|
||||
} else {
|
||||
SDL_Rect rect;
|
||||
rect.x = rect.y = 0;
|
||||
rect.w = font->char_width[c];
|
||||
rect.h = PRZ_FONT_HEIGHT;
|
||||
if ( SDL_BlitSurface(font->chars[c], &rect, surface, &pos) == -1 )
|
||||
return(-1);
|
||||
pos.x += PRZ_CHAR_WIDTH(font, c) + font->hspacing;
|
||||
}
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int cSDL_GetStringWidth(cSDL_Font *font, const char *s)
|
||||
{
|
||||
int width = 0;
|
||||
int max_width = 0;
|
||||
do {
|
||||
if ( *s == '\n' || *s == '\0' ) {
|
||||
if ( width > max_width )
|
||||
max_width = width;
|
||||
width = 0;
|
||||
} else
|
||||
width += PRZ_CHAR_WIDTH(font, *s) + font->hspacing;
|
||||
} while ( *s++ );
|
||||
return(max_width - font->hspacing);
|
||||
}
|
||||
|
||||
int cSDL_GetStringHeight(cSDL_Font *font, const char *s)
|
||||
{
|
||||
int height = 0;
|
||||
do {
|
||||
if ( *s == '\n' || *s == '\0' )
|
||||
height += PRZ_FONT_HEIGHT + font->vspacing;
|
||||
} while ( *s++ );
|
||||
return(height - font->vspacing);
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,38 @@
|
|||
#include "SDL_video.h"
|
||||
#include "SDL_prizmvideo.h"
|
||||
#include "SDL_prizmnti.h"
|
||||
|
||||
static void nti_get_info(nti_info_t *nti_info, Uint16 *data)
|
||||
{
|
||||
nti_info->magic = data[0] >> 8;
|
||||
nti_info->version = data[0] & 0x00ff;
|
||||
nti_info->width = data[1];
|
||||
nti_info->height = data[2];
|
||||
nti_info->reserved = data[3];
|
||||
}
|
||||
|
||||
SDL_Surface *nSDL_LoadImage(Uint16 *data)
|
||||
{
|
||||
SDL_Surface *image;
|
||||
nti_info_t nti_info;
|
||||
int i, j;
|
||||
nti_get_info(&nti_info, data);
|
||||
if ( nti_info.magic != 42 ) {
|
||||
SDL_SetError("[PRZ] Invalid NTI image");
|
||||
return(NULL);
|
||||
}
|
||||
PRZ_DEBUG("Loading NTI v%d (%dx%d)", nti_info.version, nti_info.width, nti_info.height);
|
||||
image = SDL_CreateRGBSurface(SDL_SWSURFACE, nti_info.width, nti_info.height,
|
||||
16, PRZ_RMASK16, PRZ_GMASK16, PRZ_BMASK16, 0);
|
||||
if ( image == NULL ) {
|
||||
SDL_OutOfMemory();
|
||||
return(NULL);
|
||||
}
|
||||
data = (Uint16 *)(data + 4);
|
||||
SDL_LockSurface(image);
|
||||
for ( i = 0; i < nti_info.height; ++i )
|
||||
for( j = 0; j < nti_info.width; ++j)
|
||||
cSDL_SetPixel(image, j, i, data[j + (nti_info.width * i)]);
|
||||
SDL_UnlockSurface(image);
|
||||
return(image);
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
#ifndef _SDL_tinspirenti_h
|
||||
#define _SDL_tinspirenti_h
|
||||
|
||||
#include "SDL_stdinc.h"
|
||||
|
||||
/* NTI specification: https://github.com/Hoffa/nSDL/wiki/NTI-specification */
|
||||
|
||||
typedef struct nti_info_t {
|
||||
Uint8 magic;
|
||||
Uint8 version;
|
||||
Uint16 width, height;
|
||||
Uint16 reserved;
|
||||
} nti_info_t;
|
||||
|
||||
#endif /* _SDL_tinspirenti_h */
|
|
@ -0,0 +1,17 @@
|
|||
#include <gint/gint.h>
|
||||
#include "SDL_video.h"
|
||||
#include "SDL_prizmvideo.h"
|
||||
|
||||
int nSDL_EnableRelativePaths(char **argv)
|
||||
{
|
||||
/*
|
||||
char buf[NSP_BUF_SIZE], *p;
|
||||
strcpy(buf, argv[0]);
|
||||
p = strrchr(buf, '/');
|
||||
if ( ! p )
|
||||
return(-1);
|
||||
*p = '\0';
|
||||
return(NU_Set_Current_Dir(buf) ? -1 : 0);
|
||||
*/
|
||||
return(0);
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue