KoboDeluxe-0.5.1/0002777000175000001440000000000010734700735010567 500000000000000KoboDeluxe-0.5.1/README0000666000175000001440000002457310734534557011407 00000000000000(This document was generated from the kobodl.6 'man' file.) Kobo Deluxe ----------- v0.5.1 An enhanced port of the scrolling video game XKobo DESCRIPTION Kobo Deluxe is a 3'rd person scrolling 2D shooter with a simple and responsive control system - which you'll need to tackle the tons of enemy ships that shoot at you, chase you, circle around you shooting, or even launch other ships at you, while you're trying to destroy the labyrinth shaped bases. There are 50 action packed levels with smoothly increasing difficulty, and different combinations of enemies that require different tactics to be dealt with successfully. Kobo Deluxe has an improved graphics engine that delivers smoother ani- mation, while keeping the game logic totally accurate and predictable regardless of frame rate. It also adds sound effects, new graphics, fullscreen mode, four extra skill levels with smoother gameplay and various other features expected from a modern game. (There is still a "Clasic" mode that plays exactly like the original XKobo.) Kobo Deluxe uses SDL for sound, graphics and input, and builds and runs on all major operating systems, as well as some more unusual platforms. It can also use OpenGL for accelerated rendering, through glSDL. In short, Kobo Deluxe is loads of classical arcade style fun for just about any machine with graphics and sound! CONTROLS The ship can be controlled with the keyboard, or optionally a mouse or joystick. With the keyboard, the arrow keys move the ship (two keys for diagonals), and the shift and ctrl keys shoots. The numeric key pad can also be used; the usual 2/4/6/8 (arrows), and also 1/3/7/9 for single key diagonals. Escape enters the meny system, from where it is possi- ble to change settings, start a new game or exit the game. OPTIONS Note that all relevant options can be also configured in the config file, which can be edited directly, or using the options menus in the game. -[no]logfile Log To File. Default: Off. -logformat Log File Format. Default: 0. -logverbosity Log Verbosity Level. Default: 2. -[no]joystick Use Joystick. Default: Off. -joystick_no Joystick Number. Default: 0. -[no]mouse Use Mouse. Default: Off. -mousemode Mouse Control Mode. Default: 1. -[no]broken_numdia Broken NumPad Diagonals. Default: Off. -dia_emphasis Diagonals Emphasis Filter. Default: 0. -[no]always_fire Always Fire. Default: Off. -[no]mousecapture In-game Mouse Capture. Default: On. -scrollradar Radar Scroll Mode. Default: 2. -[no]filter Enable/disable motion interpolation. Interpolation is what makes animation smooth at high frame rates despite the game logic run- ning at 33.33 fps. However, it also adds some input latency! Default: On. -timefilter Time filter, for smoothing out timing jitter induced by the operating system. Default: 50. -countdown Get Ready Countdown. Default: 5. -starfield Starfield Style. Default: 2. -stars Number of Parallax Stars. Default: 500. -overheatloud Overheat Warning Loudness. Default: 100. -cannonloud Player Cannons Loudness. Default: 100. -[no]sound Enable Sound. Default: On. -[no]music Enable Music. Default: On. -[no]cached_sounds Use Cached Sounds. Default: Off. -[no]oss Use OSS Sound Driver. Default: Off. -samplerate Sample Rate. Default: 44100. -latency Sound Latency. Default: 50. -mixquality Mixing Quality. Default: 3. -vol Master Volume. Default: 100. -intro_vol Intro Music Volume. Default: 100. -sfx_vol Sound Effects Volume. Default: 100. -music_vol In-Game Music Volume. Default: 50. -reverb Reverb Level. Default: 100. -vol_boost Volume Boost. Default: 0. -[no]fullscreen Fullscreen Display. Default: Off. -videodriver Display Driver. Default: 0. -width Horizontal Resolution. Default: 640. -height Vertical Resolution. Default: 480. -aspect Pixel Aspect Ratio. Default: 1000. -depth Display Depth. Default: 0. -maxfps Limit the framerate (fps). Saves power on laptops (75 works well), and can also avoid long stalls due to timesharing and background processes. Default: 100. -maxfpsstrict Strictly Regulated fps. Default: 0. -buffer Display Buffer Mode. Default: 1. -[no]shadow Use Software Shadow Buffer. Default: On. -videomode Video Mode. Default: 17200. -[no]vsync Enable Vertical Sync. Default: On. -videopages Number of Video Pages. Default: -1. -scalemode Scaling Filter Mode. Default: 1. -[no]dither Use Dithering. Default: On. -dither_type Dither Type. Default: 0. -[no]broken_rgba8 Broken RGBA (OpenGL). Default: Off. -[no]alpha Use Alpha Blending. Default: On. -brightness Brightness. Default: 100. -contrast Contrast. Default: 100. -files Specify the root path of the game. Default: "" -gfx Specify the path to the game's graphics data. Default: "" -sfx Specify the path to the game's sound data. Default: "" -scores Specify the path to the game's score files. Default: "" -size (Not saved!) Screen Size (Obsolete). Default: 0. -wait Game Speed (Obsolete). Default: 30. -bgm (Not saved!) Background Music File (Obsolete). Default: "" -threshold (Not saved!) Limiter Gain. Default: 200. -release (Not saved!) Limiter Speed. Default: 50. -internalres (Not saved!) Texture Resolution. Default: 1. -last_profile Last used player profile. Default: 0. -number_of_joysticks Number of Connected Joysticks. Default: 0. -[no]showcfg (Not saved!) Show Configuration. Default: Off. -[no]hiscores (Not saved!) List High Scores. Default: Off. -[no]highscores (Not saved!) List High Scores. Default: Off. -[no]override (Not saved!) Ignore Configuration File. Default: Off. -[no]debug (Not saved!) Enable Debug Features. Default: Off. -[no]fps (Not saved!) Display frames per second in game screen. Default: Off. -[no]noframe (Not saved!) Do not render rounded corners on the playfield. Default: Off. -[no]midi (Not saved!) Enable MIDI Input. Default: Off. -[no]cheat (Not saved!) Enable/disable cheat mode. Cheat mode allows any level to be played, but highscores are not saved! Default: Off. -[no]indicator (Not saved!) Enable Collision Indicator Mode. Default: Off. -[no]pushmove (Not saved!) Enable Push Move Mode. Default: Off. -[no]noparachute (Not saved!) Disable SDL Parachute. Default: Off. -[no]pollaudio (Not saved!) Use Polling Audio Output. Default: Off. -[no]autoshot (Not saved!) Ingame screenshots/movie. Default: Off. -[no]help (Not saved!) Print usage info and exit. Default: Off. -[no]options_man (Not saved!) Print options for 'man'. Default: Off. FILES ~/.kobodlrc The per-user configuration file for Kobo Deluxe. AUTHORS Originally written by Akira Higuchi (a-higuti@math.hokudai.ac.jp), XKobo was turned into Kobo Deluxe by David Olofson THANKS Thanks, in no particular order, to... Akira Higuchi Author of the Original XKobo. Masanao Izumo Sound effects and original sound engine. Torsten Giebl Slackware. David Andersson Various Good Ideas. Max Horn Mac OS X & Build Script Patches. Jeremy Sheeley Player Profiles. Tsuyoshi Iguchi FreeBSD, NetBSD. Samuel Hart Joystick Support. G. Low Solaris. Gerry Jo Trick Jellestad Testing and ideas. Riki Intel Compiler. Andreas Spaangberg Sun Compiler & Bug Spotting. SixK Amiga Port. Joey Hess Debian. Martijn van Oosterhout FPS limiter. Antonio Messina Stage 1601+ difficulty wrap, Always Fire option. Hans de Goede Audio buffer handling bug. Marianne Ibbotson "Autopause" idea. Sam Palmer MS Windows testing. Michael Sterrett glSDL issues. Sam Lantinga & Others SDL, the Simple DirectMedia library. Members of the SDL mailing list Testing and ideas. COPYRIGHT Copyright (c) 1995, 1996 Akira Higuchi Copyright (C) 1997 Masanao Izumo Copyright (C) 1999-2001 Simon Peter Copyright (C) 2002 Florian Schulze Copyright (C) 2002 Jeremy Sheeley Copyright (C) 2005 Erik Auerswald Copyright (c) 1999-2007 David Olofson Kobo Deluxe is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. KoboDeluxe-0.5.1/configure.in0000664000175000001440000002200710731615505013012 00000000000000dnl Process this file with autoconf to produce a configure script. dnl---------------------------------------------------------- dnl configure.in for Kobo Deluxe - David Olofson, 2001-2007 dnl Some tests stolen from SDL (http://www.libsdl.org) dnl---------------------------------------------------------- AC_INIT(Makefile.am) AC_CONFIG_SRCDIR([Makefile.am]) AM_CONFIG_HEADER(aconfig.h) AC_CANONICAL_HOST AC_CANONICAL_TARGET AM_INIT_AUTOMAKE(KoboDeluxe, 0.5.1) dnl (For Extreme Pickyness Mode) LOCALCFLAGS='' dnl------------------------------------------------------- dnl Look for X dnl------------------------------------------------------- dnl *MUST* be out here! Pretty much everything breaks on dnl some targets if they're inside the case statement... AC_PATH_X AC_PATH_XTRA dnl------------------------------------------------------- dnl Detect target platform and build style dnl------------------------------------------------------- AC_MSG_CHECKING(target platform and install style); build_macosx_bundle=no build_simple_bundle=no unix_scoredir=yes DATADIR='$(datadir)/kobo-deluxe' SCOREDIR='$(sharedstatedir)/kobo-deluxe/scores' CONFIGDIR='HOME>>' CONFIGFILE='.kobodlrc' EXEFILE=kobodl case "$target_os" in linux*) AC_MSG_RESULT(GNU/Linux; Un*x style) MATHLIB="-lm" if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; beos) AC_MSG_RESULT(BeOS; Un*x style install) MATHLIB="" ;; mingw32*) AC_MSG_RESULT(Win32 (mingw32); Simple bundle) build_simple_bundle=yes unix_scoredir=no DATADIR='EXE>>' SCOREDIR='EXE>>scores' CONFIGDIR='EXE>>' CONFIGFILE='kobodl.cfg' EXEFILE=kobodl.exe MATHLIB="" ;; cygwin*) AC_MSG_RESULT(Win32 (cygwin); Simple bundle) build_simple_bundle=yes unix_scoredir=no DATADIR='EXE>>' SCOREDIR='EXE>>scores' CONFIGDIR='EXE>>' CONFIGFILE='kobodl.cfg' EXEFILE=kobodl.exe MATHLIB="" ;; darwin*) AC_MSG_RESULT(Mac OS X/Darwin; Mac OS X bundle) build_macosx_bundle=yes DATADIR='EXE>>../Resources' SCOREDIR='/Library/Preferences/KoboDeluxe/scores' CONFIGDIR='HOME>>Library/Preferences' CONFIGFILE='KoboDeluxe Preferences' MATHLIB="" ;; aix*) AC_MSG_RESULT(AIX; Un*x style) if test x$ac_cv_c_compiler_gnu = xyes; then CFLAGS="-mthreads" fi if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; solaris*) AC_MSG_RESULT(Solaris SPARC; Un*x style) MATHLIB="-lm" CFLAGS="$CFLAGS $X_CFLAGS" ;; *) AC_MSG_RESULT(Unknown (assuming Un*x-like); Un*x style) MATHLIB="-lm" if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; esac AM_CONDITIONAL(BUILD_MACOSX_BUNDLE, test x$build_macosx_bundle = xyes) AM_CONDITIONAL(BUILD_SIMPLE_BUNDLE, test x$build_simple_bundle = xyes) AM_CONDITIONAL(UNIX_SCOREDIR, test x$unix_scoredir = xyes) AC_SUBST(DATADIR) AC_SUBST(SCOREDIR) AC_SUBST(CONFIGDIR) AC_SUBST(CONFIGFILE) AC_SUBST(EXEFILE) AC_SUBST(MATHLIB) dnl------------------------------------------------------- dnl Checks for debug mode dnl------------------------------------------------------- AC_ARG_ENABLE(debug, [ --enable-debug Build with debug switches and defines [default=no]], , enable_debug=no) AC_MSG_CHECKING(for debug build) if test x$enable_debug = xyes; then CFLAGS="$CFLAGS -g -DDEBUG" CXXFLAGS="$CXXFLAGS -g -DDEBUG" fi AC_MSG_RESULT($enable_debug) dnl------------------------------------------------------- dnl Checks for programs. dnl------------------------------------------------------- AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL AC_PROG_AWK AC_PROG_RANLIB dnl------------------------------------------------------- dnl Checks for SDL dnl------------------------------------------------------- SDL_VERSION=1.2.0 AM_PATH_SDL($SDL_VERSION,:, AC_MSG_ERROR([*** SDL version $SDL_VERSION required!]) ) CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" dnl------------------------------------------------------- dnl Checks for SDL_image dnl------------------------------------------------------- AC_CHECK_LIB(SDL_image, IMG_Load,, AC_MSG_ERROR([You need the SDL_image library to compile this software. Get it at http://www.libsdl.org/projects/SDL_image/]), -lSDL ) LIBS="$LIBS -lSDL_image" dnl------------------------------------------------------- dnl Checks for OpenGL dnl------------------------------------------------------- AC_MSG_CHECKING(for OpenGL support) have_opengl=no AC_TRY_COMPILE([ #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif ],[ ],[ have_opengl=yes ]) AC_ARG_ENABLE(opengl, [ --enable-opengl use OpenGL rendering layer [default=yes]], , enable_opengl=yes) if test x$enable_opengl = xyes; then AC_MSG_RESULT($have_opengl) else have_opengl=no AC_MSG_RESULT(Disabled) fi if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" CXXFLAGS="$CXXFLAGS -DHAVE_OPENGL" fi dnl------------------------------------------------------- dnl Checks for header files. dnl------------------------------------------------------- AC_HEADER_DIRENT AC_HEADER_STDC AC_HEADER_TIME AC_CHECK_HEADERS(errno.h fcntl.h stdlib.h string.h) AC_CHECK_HEADERS(sys/ioctl.h sys/time.h unistd.h) AC_CHECK_HEADERS(SDL/SDL_opengl.h) dnl------------------------------------------------------- dnl Checks for typedefs, structures, and compiler characteristics. dnl------------------------------------------------------- AC_C_CONST AC_C_INLINE AC_TYPE_SIGNAL dnl------------------------------------------------------- dnl Checks for library functions. dnl------------------------------------------------------- AC_CHECK_FUNCS(strdup strstr strchr strrchr) AC_CHECK_FUNCS(snprintf _snprintf vsnprintf _vsnprintf) AC_CHECK_FUNCS(pow sqrt) AC_CHECK_FUNCS(munmap mkdir select stat) AC_CHECK_FUNCS(atexit floor memmove memset memcmp) AC_CHECK_FUNCS(gettimeofday) AC_CHECK_FUNCS(getegid setgid) AC_FUNC_MEMCMP AC_FUNC_STRTOD AC_FUNC_VPRINTF AC_FUNC_MMAP dnl AC_FUNC_MALLOC AC_FUNC_STAT AC_PROG_GCC_TRADITIONAL dnl------------------------------------------------------- dnl See if the OSS audio interface is supported (from SDL) dnl------------------------------------------------------- AC_MSG_CHECKING(for OSS audio support) if test x$enable_oss = xyes; then have_oss=no if test x$have_oss != xyes; then AC_TRY_COMPILE([ #include ],[ int arg = SNDCTL_DSP_SETFRAGMENT; ++arg; ],[ have_oss=yes ]) fi if test x$have_oss != xyes; then AC_TRY_COMPILE([ #include ],[ int arg = SNDCTL_DSP_SETFRAGMENT; ],[ have_oss=yes CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H" CXXFLAGS="$CXXFLAGS -DOSS_USE_SOUNDCARD_H" ]) fi fi AC_ARG_ENABLE(oss, [ --enable-oss support the OSS audio API [default=no]], , enable_oss=no) if test x$enable_oss = xyes; then AC_MSG_RESULT($have_oss) else have_oss=no AC_MSG_RESULT(Disabled) fi if test x$have_oss = xyes; then CFLAGS="$CFLAGS -DHAVE_OSS" CXXFLAGS="$CXXFLAGS -DHAVE_OSS" fi dnl------------------------------------------------------- dnl See if the ALSA audio interface is supported (from SDL) dnl------------------------------------------------------- AC_CHECK_HEADER(sys/asoundlib.h, have_alsa_hdr=yes) AC_CHECK_LIB(asound, snd_pcm_open, have_alsa_lib=yes) AC_MSG_CHECKING(for ALSA audio support) have_alsa=no if test x$have_alsa_hdr = xyes -a x$have_alsa_lib = xyes; then have_alsa=yes fi AC_ARG_ENABLE(alsa, [ --enable-alsa support the ALSA audio API [default=no]], , enable_alsa=no) if test x$enable_alsa = xyes; then AC_MSG_RESULT($have_alsa) else have_alsa=no AC_MSG_RESULT(Disabled) fi if test x$have_alsa = xyes; then CFLAGS="$CFLAGS -DHAVE_ALSA" CXXFLAGS="$CXXFLAGS -DHAVE_ALSA" AUDIO_LIBS="-lasound" else AUDIO_LIBS="" fi AC_SUBST(AUDIO_LIBS) dnl------------------------------------------------------- dnl Checks for Extreme Pickyness Mode dnl We have to put this here, as throwing -Werror dnl into C(XX)FLAGS will cause lots of autoconf dnl tests to fail on some systems. dnl------------------------------------------------------- AC_ARG_ENABLE(epm, [ --enable-epm Compile with extremely picky settings [default=no]], , enable_epm=no) AC_MSG_CHECKING(for Extreme Pickyness Mode) if test x$enable_epm = xyes; then LOCALCFLAGS="$LOCALCFLAGS -Wall -Werror -Wwrite-strings -fno-builtin" fi AC_MSG_RESULT($enable_epm) AC_SUBST(LOCALCFLAGS) dnl------------------------------------------------------- dnl Check if we should use ElectricFence dnl------------------------------------------------------- AC_ARG_ENABLE(efence, [ --enable-efence Link with ElectricFence [default=no]], , enable_efence=no) AC_MSG_CHECKING(if we should use ElectricFence) if test x$enable_efence = xyes; then LIBS="$LIBS -lefence" fi AC_MSG_RESULT($enable_efence) AC_SUBST(LOCALCFLAGS) dnl------------------------------------------------------- dnl Generate output files dnl------------------------------------------------------- AC_OUTPUT([Makefile Info.plist graphics/Makefile sound/Makefile data/Makefile data/sfx/Makefile data/gfx/Makefile eel/Makefile ]) KoboDeluxe-0.5.1/aclocal.m40000666000175000001440000011206710731616144012351 00000000000000# generated automatically by aclocal 1.9.6 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, # 2005 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. # Configure paths for SDL # Sam Lantinga 9/21/99 # stolen from Manish Singh # stolen back from Frank Belew # stolen from Manish Singh # Shamelessly stolen from Owen Taylor dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS dnl AC_DEFUN([AM_PATH_SDL], [dnl dnl Get the cflags and libraries from the sdl-config script dnl AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)], sdl_prefix="$withval", sdl_prefix="") AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)], sdl_exec_prefix="$withval", sdl_exec_prefix="") AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program], , enable_sdltest=yes) if test x$sdl_exec_prefix != x ; then sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config fi fi if test x$sdl_prefix != x ; then sdl_args="$sdl_args --prefix=$sdl_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_prefix/bin/sdl-config fi fi if test "x$prefix" != xNONE; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH]) min_sdl_version=ifelse([$1], ,0.11.0,$1) AC_MSG_CHECKING(for SDL - version >= $min_sdl_version) no_sdl="" if test "$SDL_CONFIG" = "no" ; then no_sdl=yes else SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_CXXFLAGS="$CXXFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" dnl dnl Now check if the installed SDL is sufficiently new. (Also sanity dnl checks the results of sdl-config to some extent dnl rm -f conf.sdltest AC_TRY_RUN([ #include #include #include #include "SDL.h" char* my_strdup (char *str) { char *new_str; if (str) { new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main (int argc, char *argv[]) { int major, minor, micro; char *tmp_version; /* This hangs on some systems (?) system ("touch conf.sdltest"); */ { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup("$min_sdl_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } if (($sdl_major_version > major) || (($sdl_major_version == major) && ($sdl_minor_version > minor)) || (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) { return 0; } else { printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); printf("*** to point to the correct copy of sdl-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_sdl" = x ; then AC_MSG_RESULT(yes) ifelse([$2], , :, [$2]) else AC_MSG_RESULT(no) if test "$SDL_CONFIG" = "no" ; then echo "*** The sdl-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the SDL_CONFIG environment variable to the" echo "*** full path to sdl-config." else if test -f conf.sdltest ; then : else echo "*** Could not run SDL test program, checking why..." CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" AC_TRY_LINK([ #include #include "SDL.h" int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main ], [ return 0; ], [ echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], [ echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ]) CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi SDL_CFLAGS="" SDL_LIBS="" ifelse([$3], , :, [$3]) fi AC_SUBST(SDL_CFLAGS) AC_SUBST(SDL_LIBS) rm -f conf.sdltest ]) # Copyright (C) 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version="1.9"]) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION so it can be traced. # This function is AC_REQUIREd by AC_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.9.6])]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to # `$srcdir', `$srcdir/..', or `$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is `.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 7 # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ(2.52)dnl ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE]) AC_SUBST([$1_FALSE]) if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # There are a few dirty hacks below to avoid letting `AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "GCJ", or "OBJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl ifelse([$1], CC, [depcc="$CC" am_compiler_list=], [$1], CXX, [depcc="$CXX" am_compiler_list=], [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE(dependency-tracking, [ --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH]) ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. #serial 3 # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [for mf in $CONFIG_FILES; do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each `.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 8 # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 12 # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.58])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) AM_MISSING_PROG(AUTOCONF, autoconf) AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) AM_MISSING_PROG(AUTOHEADER, autoheader) AM_MISSING_PROG(MAKEINFO, makeinfo) AM_PROG_INSTALL_SH AM_PROG_INSTALL_STRIP AC_REQUIRE([AM_PROG_MKDIR_P])dnl # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES(CC)], [define([AC_PROG_CC], defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES(CXX)], [define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl ]) ]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $1 | $1:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl install_sh=${install_sh-"$am_aux_dir/install-sh"} AC_SUBST(install_sh)]) # Copyright (C) 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it supports --run. # If it does, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= AC_MSG_WARN([`missing' script is too old or missing]) fi ]) # Copyright (C) 2003, 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_MKDIR_P # --------------- # Check whether `mkdir -p' is supported, fallback to mkinstalldirs otherwise. # # Automake 1.8 used `mkdir -m 0755 -p --' to ensure that directories # created by `make install' are always world readable, even if the # installer happens to have an overly restrictive umask (e.g. 077). # This was a mistake. There are at least two reasons why we must not # use `-m 0755': # - it causes special bits like SGID to be ignored, # - it may be too restrictive (some setups expect 775 directories). # # Do not use -m 0755 and let people choose whatever they expect by # setting umask. # # We cannot accept any implementation of `mkdir' that recognizes `-p'. # Some implementations (such as Solaris 8's) are not thread-safe: if a # parallel make tries to run `mkdir -p a/b' and `mkdir -p a/c' # concurrently, both version can detect that a/ is missing, but only # one can create it and the other will error out. Consequently we # restrict ourselves to GNU make (using the --version option ensures # this.) AC_DEFUN([AM_PROG_MKDIR_P], [if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then # We used to keeping the `.' as first argument, in order to # allow $(mkdir_p) to be used without argument. As in # $(mkdir_p) $(somedir) # where $(somedir) is conditionally defined. However this is wrong # for two reasons: # 1. if the package is installed by a user who cannot write `.' # make install will fail, # 2. the above comment should most certainly read # $(mkdir_p) $(DESTDIR)$(somedir) # so it does not work when $(somedir) is undefined and # $(DESTDIR) is not. # To support the latter case, we have to write # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), # so the `.' trick is pointless. mkdir_p='mkdir -p --' else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. for d in ./-p ./--version; do test -d $d && rmdir $d done # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. if test -f "$ac_aux_dir/mkinstalldirs"; then mkdir_p='$(mkinstalldirs)' else mkdir_p='$(install_sh) -d' fi fi AC_SUBST([mkdir_p])]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 3 # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # ------------------------------ # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) # _AM_SET_OPTIONS(OPTIONS) # ---------------------------------- # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [AC_FOREACH([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 4 # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT(yes)]) # Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor `install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in `make install-strip', and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be `maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004, 2005 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # serial 2 # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of `v7', `ustar', or `pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. AM_MISSING_PROG([AMTAR], [tar]) m4_if([$1], [v7], [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'], [m4_case([$1], [ustar],, [pax],, [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' _am_tools=${am_cv_prog_tar_$1-$_am_tools} # Do not fold the above two line into one, because Tru64 sh and # Solaris sh will not grok spaces in the rhs of `-'. for _am_tool in $_am_tools do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR KoboDeluxe-0.5.1/Info.plist.in0000666000175000001440000000164107351662135013066 00000000000000 CFBundleDevelopmentRegion English CFBundleExecutable @EXEFILE@ CFBundleGetInfoString @VERSION@, Copyright 2001 David Olofson CFBundleInfoDictionaryVersion 6.0 CFBundleName @PACKAGE@ CFBundlePackageType APPL CFBundleShortVersionString @VERSION@ CFBundleSignature ???? CFBundleVersion @VERSION@ NSMainNibFile SDLMain.nib NSPrincipalClass NSApplication NSHumanReadableCopyright Copyright 2001 David Olofson KoboDeluxe-0.5.1/Makefile.am0000644000175000001440000000513410730756237012544 00000000000000if BUILD_MACOSX_BUNDLE bundle_contents = @PACKAGE@.app/Contents else if BUILD_SIMPLE_BUNDLE bundle_contents = @PACKAGE@ endif endif kobo_scoredir=@SCOREDIR@ INCLUDES = -DKOBO_DATA_DIR=\""@DATADIR@"\" \ -DKOBO_SCORE_DIR=\""$(kobo_scoredir)"\" \ -DKOBO_CONFIG_DIR=\""@CONFIGDIR@"\" \ -DKOBO_CONFIG_FILE=\""@CONFIGFILE@"\" \ -DSYSCONF_DIR=\""$(sysconfdir)"\" \ -Isound -Igraphics -Ieel -Idata/sfx @LOCALCFLAGS@ SUBDIRS = graphics sound data eel bin_PROGRAMS = kobodl GRAPHICS_LIB = graphics/libgraphics.a @MATHLIB@ SOUND_LIB = sound/libsound.a @AUDIO_LIBS@ EEL_LIB = eel/libeel.a kobodl_SOURCES = enemies.cpp enemy.cpp pfile.cpp gamectl.cpp manage.cpp map.cpp \ myship.cpp radar.cpp random.cpp scenes.cpp score.cpp screen.cpp \ filemap.cpp prefs.cpp cfgform.cpp options.cpp gamestate.cpp \ states.cpp form.cpp cfgparse.cpp game.cpp kobo.cpp logger.c \ dashboard.cpp sound.cpp kobodl_LDADD = $(GRAPHICS_LIB) $(SOUND_LIB) $(EEL_LIB) kobodl_LDFLAGS = -o $(EXEFILE) man_MANS = kobodl.6 CLEANFILES = $(EXEFILE) Info.plist log.html AUTOMAKE_OPTIONS = foreign EXTRA_DIST = *.h Info.plist.in KoboPlayer COPYING.LIB *.txt \ README.jp README.sfont README.xkobo README.xkobo.jp README.osx \ README.html \ cfg-work cfg-beta cfg-release cfg-profile cfg-cross-release \ cfg-work-opt buildpkg.sh kobodl.6 icons.tar.gz if BUILD_MACOSX_BUNDLE @PACKAGE@_bundle: ${EXEFILE} mkdir -p $(bundle_contents)/MacOS echo "APPL????" > $(bundle_contents)/PkgInfo $(INSTALL_DATA) Info.plist $(bundle_contents) $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/MacOS/ install-exec-hook: @PACKAGE@_bundle rm -rf $(DESTDIR)$(prefix)/@PACKAGE@.app mkdir -p $(DESTDIR)$(prefix)/ cp -r @PACKAGE@.app $(DESTDIR)$(prefix)/ clean-local: rm -rf $(bundle_contents) else if BUILD_SIMPLE_BUNDLE @PACKAGE@_bundle: ${EXEFILE} $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/ install-exec-hook: @PACKAGE@_bundle rm -rf $(DESTDIR)/$(prefix)/@PACKAGE@ mkdir -p $(DESTDIR)/$(prefix)/ cp COPYING @PACKAGE@/COPYING.txt cp COPYING.LIB @PACKAGE@/COPYING_LIB.txt cp ChangeLog @PACKAGE@/ChangeLog.txt cp TODO @PACKAGE@/TODO.txt cp README @PACKAGE@/README.txt cp README.jp @PACKAGE@/README_jp.txt cp README.sfont @PACKAGE@/sfont.txt cp README.xkobo @PACKAGE@/xkobo.txt cp README.xkobo.jp @PACKAGE@/xkobo_jp.txt cp KoboPlayer @PACKAGE@/scores/42 cp -r @PACKAGE@ $(DESTDIR)/$(prefix)/ clean-local: rm -rf $(bundle_contents) else @PACKAGE@_bundle: install-exec-hook: clean-local: endif endif if UNIX_SCOREDIR install-data-hook: $(DESTDIR)$(kobo_scoredir) chmod a+w $(DESTDIR)$(kobo_scoredir) else install-data-hook: endif KoboDeluxe-0.5.1/Makefile.in0000644000175000001440000007641010731616147012556 00000000000000# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = . am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ bin_PROGRAMS = kobodl$(EXEEXT) DIST_COMMON = README $(am__configure_deps) $(srcdir)/Info.plist.in \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/aconfig.h.in $(top_srcdir)/configure COPYING \ COPYING.LIB ChangeLog TODO acconfig.h compile config.guess \ config.sub depcomp install-sh missing mkinstalldirs subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ configure.lineno configure.status.lineno mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = aconfig.h CONFIG_CLEAN_FILES = Info.plist am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_kobodl_OBJECTS = enemies.$(OBJEXT) enemy.$(OBJEXT) pfile.$(OBJEXT) \ gamectl.$(OBJEXT) manage.$(OBJEXT) map.$(OBJEXT) \ myship.$(OBJEXT) radar.$(OBJEXT) random.$(OBJEXT) \ scenes.$(OBJEXT) score.$(OBJEXT) screen.$(OBJEXT) \ filemap.$(OBJEXT) prefs.$(OBJEXT) cfgform.$(OBJEXT) \ options.$(OBJEXT) gamestate.$(OBJEXT) states.$(OBJEXT) \ form.$(OBJEXT) cfgparse.$(OBJEXT) game.$(OBJEXT) \ kobo.$(OBJEXT) logger.$(OBJEXT) dashboard.$(OBJEXT) \ sound.$(OBJEXT) kobodl_OBJECTS = $(am_kobodl_OBJECTS) am__DEPENDENCIES_1 = graphics/libgraphics.a am__DEPENDENCIES_2 = sound/libsound.a am__DEPENDENCIES_3 = eel/libeel.a kobodl_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \ $(am__DEPENDENCIES_3) DEFAULT_INCLUDES = -I. -I$(srcdir) -I. depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(kobodl_SOURCES) DIST_SOURCES = $(kobodl_SOURCES) RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-exec-recursive install-info-recursive \ install-recursive installcheck-recursive installdirs-recursive \ pdf-recursive ps-recursive uninstall-info-recursive \ uninstall-recursive man6dir = $(mandir)/man6 NROFF = nroff MANS = $(man_MANS) ETAGS = etags CTAGS = ctags DIST_SUBDIRS = $(SUBDIRS) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) distdir = $(PACKAGE)-$(VERSION) top_distdir = $(distdir) am__remove_distdir = \ { test ! -d $(distdir) \ || { find $(distdir) -type d ! -perm -200 -exec chmod u+w {} ';' \ && rm -fr $(distdir); }; } DIST_ARCHIVES = $(distdir).tar.gz GZIP_ENV = --best distuninstallcheck_listfiles = find . -type f -print distcleancheck_listfiles = find . -type f -print ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUDIO_LIBS = @AUDIO_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFIGDIR = @CONFIGDIR@ CONFIGFILE = @CONFIGFILE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIR = @DATADIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXEFILE = @EXEFILE@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LOCALCFLAGS = @LOCALCFLAGS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATHLIB = @MATHLIB@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ POW_LIB = @POW_LIB@ RANLIB = @RANLIB@ SCOREDIR = @SCOREDIR@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ VERSION = @VERSION@ XMKMF = @XMKMF@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@bundle_contents = @PACKAGE@ @BUILD_MACOSX_BUNDLE_TRUE@bundle_contents = @PACKAGE@.app/Contents kobo_scoredir = @SCOREDIR@ INCLUDES = -DKOBO_DATA_DIR=\""@DATADIR@"\" \ -DKOBO_SCORE_DIR=\""$(kobo_scoredir)"\" \ -DKOBO_CONFIG_DIR=\""@CONFIGDIR@"\" \ -DKOBO_CONFIG_FILE=\""@CONFIGFILE@"\" \ -DSYSCONF_DIR=\""$(sysconfdir)"\" \ -Isound -Igraphics -Ieel -Idata/sfx @LOCALCFLAGS@ SUBDIRS = graphics sound data eel GRAPHICS_LIB = graphics/libgraphics.a @MATHLIB@ SOUND_LIB = sound/libsound.a @AUDIO_LIBS@ EEL_LIB = eel/libeel.a kobodl_SOURCES = enemies.cpp enemy.cpp pfile.cpp gamectl.cpp manage.cpp map.cpp \ myship.cpp radar.cpp random.cpp scenes.cpp score.cpp screen.cpp \ filemap.cpp prefs.cpp cfgform.cpp options.cpp gamestate.cpp \ states.cpp form.cpp cfgparse.cpp game.cpp kobo.cpp logger.c \ dashboard.cpp sound.cpp kobodl_LDADD = $(GRAPHICS_LIB) $(SOUND_LIB) $(EEL_LIB) kobodl_LDFLAGS = -o $(EXEFILE) man_MANS = kobodl.6 CLEANFILES = $(EXEFILE) Info.plist log.html AUTOMAKE_OPTIONS = foreign EXTRA_DIST = *.h Info.plist.in KoboPlayer COPYING.LIB *.txt \ README.jp README.sfont README.xkobo README.xkobo.jp README.osx \ README.html \ cfg-work cfg-beta cfg-release cfg-profile cfg-cross-release \ cfg-work-opt buildpkg.sh kobodl.6 icons.tar.gz all: aconfig.h $(MAKE) $(AM_MAKEFLAGS) all-recursive .SUFFIXES: .SUFFIXES: .c .cpp .o .obj am--refresh: @: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ echo ' cd $(srcdir) && $(AUTOMAKE) --foreign '; \ cd $(srcdir) && $(AUTOMAKE) --foreign \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ echo ' $(SHELL) ./config.status'; \ $(SHELL) ./config.status;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) $(SHELL) ./config.status --recheck $(top_srcdir)/configure: $(am__configure_deps) cd $(srcdir) && $(AUTOCONF) $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) aconfig.h: stamp-h1 @if test ! -f $@; then \ rm -f stamp-h1; \ $(MAKE) stamp-h1; \ else :; fi stamp-h1: $(srcdir)/aconfig.h.in $(top_builddir)/config.status @rm -f stamp-h1 cd $(top_builddir) && $(SHELL) ./config.status aconfig.h $(srcdir)/aconfig.h.in: $(am__configure_deps) $(top_srcdir)/acconfig.h cd $(top_srcdir) && $(AUTOHEADER) rm -f stamp-h1 touch $@ distclean-hdr: -rm -f aconfig.h stamp-h1 Info.plist: $(top_builddir)/config.status $(srcdir)/Info.plist.in cd $(top_builddir) && $(SHELL) ./config.status $@ install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(mkdir_p) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; for p in $$list; do \ p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \ if test -f $$p \ ; then \ f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \ echo " $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) '$$p' '$(DESTDIR)$(bindir)/$$f'"; \ $(INSTALL_PROGRAM_ENV) $(binPROGRAMS_INSTALL) "$$p" "$(DESTDIR)$(bindir)/$$f" || exit 1; \ else :; fi; \ done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; for p in $$list; do \ f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \ echo " rm -f '$(DESTDIR)$(bindir)/$$f'"; \ rm -f "$(DESTDIR)$(bindir)/$$f"; \ done clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) kobodl$(EXEEXT): $(kobodl_OBJECTS) $(kobodl_DEPENDENCIES) @rm -f kobodl$(EXEEXT) $(CXXLINK) $(kobodl_LDFLAGS) $(kobodl_OBJECTS) $(kobodl_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cfgparse.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dashboard.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enemies.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enemy.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filemap.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/form.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamectl.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gamestate.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kobo.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logger.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/manage.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/map.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/myship.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/options.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pfile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prefs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/radar.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/random.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scenes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/score.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/screen.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sound.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/states.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` uninstall-info-am: install-man6: $(man6_MANS) $(man_MANS) @$(NORMAL_INSTALL) test -z "$(man6dir)" || $(mkdir_p) "$(DESTDIR)$(man6dir)" @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.6*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ if test -f $(srcdir)/$$i; then file=$(srcdir)/$$i; \ else file=$$i; fi; \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ case "$$ext" in \ 6*) ;; \ *) ext='6' ;; \ esac; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man6dir)/$$inst'"; \ $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man6dir)/$$inst"; \ done uninstall-man6: @$(NORMAL_UNINSTALL) @list='$(man6_MANS) $(dist_man6_MANS) $(nodist_man6_MANS)'; \ l2='$(man_MANS) $(dist_man_MANS) $(nodist_man_MANS)'; \ for i in $$l2; do \ case "$$i" in \ *.6*) list="$$list $$i" ;; \ esac; \ done; \ for i in $$list; do \ ext=`echo $$i | sed -e 's/^.*\\.//'`; \ case "$$ext" in \ 6*) ;; \ *) ext='6' ;; \ esac; \ inst=`echo $$i | sed -e 's/\\.[0-9a-z]*$$//'`; \ inst=`echo $$inst | sed -e 's/^.*\///'`; \ inst=`echo $$inst | sed '$(transform)'`.$$ext; \ echo " rm -f '$(DESTDIR)$(man6dir)/$$inst'"; \ rm -f "$(DESTDIR)$(man6dir)/$$inst"; \ done # This directory's subdirectories are mostly independent; you can cd # into them and run `make' without going through this Makefile. # To change the values of `make' variables: instead of editing Makefiles, # (1) if the variable is set in `config.status', edit `config.status' # (which will cause the Makefiles to be regenerated when you run `make'); # (2) otherwise, pass the desired values on the `make' command line. $(RECURSIVE_TARGETS): @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ target=`echo $@ | sed s/-recursive//`; \ list='$(SUBDIRS)'; for subdir in $$list; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ dot_seen=yes; \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done; \ if test "$$dot_seen" = "no"; then \ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ fi; test -z "$$fail" mostlyclean-recursive clean-recursive distclean-recursive \ maintainer-clean-recursive: @failcom='exit 1'; \ for f in x $$MAKEFLAGS; do \ case $$f in \ *=* | --[!k]*);; \ *k*) failcom='fail=yes';; \ esac; \ done; \ dot_seen=no; \ case "$@" in \ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ *) list='$(SUBDIRS)' ;; \ esac; \ rev=''; for subdir in $$list; do \ if test "$$subdir" = "."; then :; else \ rev="$$subdir $$rev"; \ fi; \ done; \ rev="$$rev ."; \ target=`echo $@ | sed s/-recursive//`; \ for subdir in $$rev; do \ echo "Making $$target in $$subdir"; \ if test "$$subdir" = "."; then \ local_target="$$target-am"; \ else \ local_target="$$target"; \ fi; \ (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ || eval $$failcom; \ done && test -z "$$fail" tags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ done ctags-recursive: list='$(SUBDIRS)'; for subdir in $$list; do \ test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ done ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: tags-recursive $(HEADERS) $(SOURCES) aconfig.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ include_option=--etags-include; \ empty_fix=.; \ else \ include_option=--include; \ empty_fix=; \ fi; \ list='$(SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test ! -f $$subdir/TAGS || \ tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \ fi; \ done; \ list='$(SOURCES) $(HEADERS) aconfig.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: ctags-recursive $(HEADERS) $(SOURCES) aconfig.h.in $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) aconfig.h.in $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) $(am__remove_distdir) mkdir $(distdir) $(mkdir_p) $(distdir)/. @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ if test "$$subdir" = .; then :; else \ test -d "$(distdir)/$$subdir" \ || $(mkdir_p) "$(distdir)/$$subdir" \ || exit 1; \ distdir=`$(am__cd) $(distdir) && pwd`; \ top_distdir=`$(am__cd) $(top_distdir) && pwd`; \ (cd $$subdir && \ $(MAKE) $(AM_MAKEFLAGS) \ top_distdir="$$top_distdir" \ distdir="$$distdir/$$subdir" \ distdir) \ || exit 1; \ fi; \ done -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ || chmod -R a+r $(distdir) dist-gzip: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) dist-bzip2: distdir tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 $(am__remove_distdir) dist-tarZ: distdir tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z $(am__remove_distdir) dist-shar: distdir shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz $(am__remove_distdir) dist-zip: distdir -rm -f $(distdir).zip zip -rq $(distdir).zip $(distdir) $(am__remove_distdir) dist dist-all: distdir tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz $(am__remove_distdir) # This target untars the dist file and tries a VPATH configuration. Then # it guarantees that the distribution is self-contained by making another # tarfile. distcheck: dist case '$(DIST_ARCHIVES)' in \ *.tar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ *.tar.bz2*) \ bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ *.tar.Z*) \ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ *.shar.gz*) \ GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\ *.zip*) \ unzip $(distdir).zip ;;\ esac chmod -R a-w $(distdir); chmod a+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ && cd $(distdir)/_build \ && ../configure --srcdir=.. --prefix="$$dc_install_base" \ $(DISTCHECK_CONFIGURE_FLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) \ && $(MAKE) $(AM_MAKEFLAGS) dvi \ && $(MAKE) $(AM_MAKEFLAGS) check \ && $(MAKE) $(AM_MAKEFLAGS) install \ && $(MAKE) $(AM_MAKEFLAGS) installcheck \ && $(MAKE) $(AM_MAKEFLAGS) uninstall \ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ distuninstallcheck \ && chmod -R a-w "$$dc_install_base" \ && ({ \ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ } || { rm -rf "$$dc_destdir"; exit 1; }) \ && rm -rf "$$dc_destdir" \ && $(MAKE) $(AM_MAKEFLAGS) dist \ && rm -rf $(DIST_ARCHIVES) \ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck $(am__remove_distdir) @(echo "$(distdir) archives ready for distribution: "; \ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ sed -e '1{h;s/./=/g;p;x;}' -e '$${p;x;}' distuninstallcheck: @cd $(distuninstallcheck_dir) \ && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \ || { echo "ERROR: files left after uninstall:" ; \ if test -n "$(DESTDIR)"; then \ echo " (check DESTDIR support)"; \ fi ; \ $(distuninstallcheck_listfiles) ; \ exit 1; } >&2 distcleancheck: distclean @if test '$(srcdir)' = . ; then \ echo "ERROR: distcleancheck can only run from a VPATH build" ; \ exit 1 ; \ fi @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ || { echo "ERROR: files left in build directory after distclean:" ; \ $(distcleancheck_listfiles) ; \ exit 1; } >&2 check-am: all-am check: check-recursive all-am: Makefile $(PROGRAMS) $(MANS) aconfig.h installdirs: installdirs-recursive installdirs-am: for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man6dir)"; do \ test -z "$$dir" || $(mkdir_p) "$$dir"; \ done install: install-recursive install-exec: install-exec-recursive install-data: install-data-recursive uninstall: uninstall-recursive install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-recursive install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-recursive clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-hdr distclean-tags dvi: dvi-recursive dvi-am: html: html-recursive info: info-recursive info-am: install-data-am: install-man @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-data-hook install-exec-am: install-binPROGRAMS @$(NORMAL_INSTALL) $(MAKE) $(AM_MAKEFLAGS) install-exec-hook install-info: install-info-recursive install-man: install-man6 installcheck-am: maintainer-clean: maintainer-clean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) -rm -rf $(top_srcdir)/autom4te.cache -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-recursive mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-recursive pdf-am: ps: ps-recursive ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-info-am uninstall-man uninstall-info: uninstall-info-recursive uninstall-man: uninstall-man6 .PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am am--refresh check \ check-am clean clean-binPROGRAMS clean-generic clean-local \ clean-recursive ctags ctags-recursive dist dist-all dist-bzip2 \ dist-gzip dist-shar dist-tarZ dist-zip distcheck distclean \ distclean-compile distclean-generic distclean-hdr \ distclean-recursive distclean-tags distcleancheck distdir \ distuninstallcheck dvi dvi-am html html-am info info-am \ install install-am install-binPROGRAMS install-data \ install-data-am install-data-hook install-exec install-exec-am \ install-exec-hook install-info install-info-am install-man \ install-man6 install-strip installcheck installcheck-am \ installdirs installdirs-am maintainer-clean \ maintainer-clean-generic maintainer-clean-recursive \ mostlyclean mostlyclean-compile mostlyclean-generic \ mostlyclean-recursive pdf pdf-am ps ps-am tags tags-recursive \ uninstall uninstall-am uninstall-binPROGRAMS uninstall-info-am \ uninstall-man uninstall-man6 @BUILD_MACOSX_BUNDLE_TRUE@@PACKAGE@_bundle: ${EXEFILE} @BUILD_MACOSX_BUNDLE_TRUE@ mkdir -p $(bundle_contents)/MacOS @BUILD_MACOSX_BUNDLE_TRUE@ echo "APPL????" > $(bundle_contents)/PkgInfo @BUILD_MACOSX_BUNDLE_TRUE@ $(INSTALL_DATA) Info.plist $(bundle_contents) @BUILD_MACOSX_BUNDLE_TRUE@ $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/MacOS/ @BUILD_MACOSX_BUNDLE_TRUE@install-exec-hook: @PACKAGE@_bundle @BUILD_MACOSX_BUNDLE_TRUE@ rm -rf $(DESTDIR)$(prefix)/@PACKAGE@.app @BUILD_MACOSX_BUNDLE_TRUE@ mkdir -p $(DESTDIR)$(prefix)/ @BUILD_MACOSX_BUNDLE_TRUE@ cp -r @PACKAGE@.app $(DESTDIR)$(prefix)/ @BUILD_MACOSX_BUNDLE_TRUE@clean-local: @BUILD_MACOSX_BUNDLE_TRUE@ rm -rf $(bundle_contents) @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@@PACKAGE@_bundle: ${EXEFILE} @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ $(INSTALL_PROGRAM) ${EXEFILE} $(bundle_contents)/ @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@install-exec-hook: @PACKAGE@_bundle @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ rm -rf $(DESTDIR)/$(prefix)/@PACKAGE@ @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ mkdir -p $(DESTDIR)/$(prefix)/ @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp COPYING @PACKAGE@/COPYING.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp COPYING.LIB @PACKAGE@/COPYING_LIB.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp ChangeLog @PACKAGE@/ChangeLog.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp TODO @PACKAGE@/TODO.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README @PACKAGE@/README.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.jp @PACKAGE@/README_jp.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.sfont @PACKAGE@/sfont.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.xkobo @PACKAGE@/xkobo.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp README.xkobo.jp @PACKAGE@/xkobo_jp.txt @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp KoboPlayer @PACKAGE@/scores/42 @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ cp -r @PACKAGE@ $(DESTDIR)/$(prefix)/ @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@clean-local: @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_TRUE@ rm -rf $(bundle_contents) @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@@PACKAGE@_bundle: @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@install-exec-hook: @BUILD_MACOSX_BUNDLE_FALSE@@BUILD_SIMPLE_BUNDLE_FALSE@clean-local: @UNIX_SCOREDIR_TRUE@install-data-hook: $(DESTDIR)$(kobo_scoredir) @UNIX_SCOREDIR_TRUE@ chmod a+w $(DESTDIR)$(kobo_scoredir) @UNIX_SCOREDIR_FALSE@install-data-hook: # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: KoboDeluxe-0.5.1/aconfig.h.in0000644000175000001440000001173110731616170012664 00000000000000/* aconfig.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if you have the `atexit' function. */ #undef HAVE_ATEXIT /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_DIRENT_H /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ #undef HAVE_DOPRNT /* Define to 1 if you have the header file. */ #undef HAVE_ERRNO_H /* Define to 1 if you have the header file. */ #undef HAVE_FCNTL_H /* Define to 1 if you have the `floor' function. */ #undef HAVE_FLOOR /* Define to 1 if you have the `getegid' function. */ #undef HAVE_GETEGID /* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ #undef HAVE_LIBSDL_IMAGE /* Define to 1 if you have the `memcmp' function. */ #undef HAVE_MEMCMP /* Define to 1 if you have the `memmove' function. */ #undef HAVE_MEMMOVE /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 if you have the `memset' function. */ #undef HAVE_MEMSET /* Define to 1 if you have the `mkdir' function. */ #undef HAVE_MKDIR /* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP /* Define to 1 if you have the `munmap' function. */ #undef HAVE_MUNMAP /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H /* Define to 1 if you have the `pow' function. */ #undef HAVE_POW /* Define to 1 if you have the header file. */ #undef HAVE_SDL_SDL_OPENGL_H /* Define to 1 if you have the `select' function. */ #undef HAVE_SELECT /* Define to 1 if you have the `setgid' function. */ #undef HAVE_SETGID /* Define to 1 if you have the `snprintf' function. */ #undef HAVE_SNPRINTF /* Define to 1 if you have the `sqrt' function. */ #undef HAVE_SQRT /* Define to 1 if you have the `stat' function. */ #undef HAVE_STAT /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ #undef HAVE_STAT_EMPTY_STRING_BUG /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the `strchr' function. */ #undef HAVE_STRCHR /* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the `strrchr' function. */ #undef HAVE_STRRCHR /* Define to 1 if you have the `strstr' function. */ #undef HAVE_STRSTR /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_DIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_IOCTL_H /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_SYS_NDIR_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TIME_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 if you have the `vprintf' function. */ #undef HAVE_VPRINTF /* Define to 1 if you have the `vsnprintf' function. */ #undef HAVE_VSNPRINTF /* Define to 1 if you have the `_snprintf' function. */ #undef HAVE__SNPRINTF /* Define to 1 if you have the `_vsnprintf' function. */ #undef HAVE__VSNPRINTF /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #undef LSTAT_FOLLOWS_SLASHED_SYMLINK /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define as the return type of signal handlers (`int' or `void'). */ #undef RETSIGTYPE /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME /* Version number of package */ #undef VERSION /* Define to 1 if the X Window System is missing or not being used. */ #undef X_DISPLAY_MISSING /* Define to empty if `const' does not conform to ANSI C. */ #undef const /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus #undef inline #endif KoboDeluxe-0.5.1/configure0000755000175000001440000124475510731616147012432 00000000000000#! /bin/sh # Guess values for system-dependent variables and create Makefiles. # Generated by GNU Autoconf 2.61. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH if test "x$CONFIG_SHELL" = x; then if (eval ":") 2>/dev/null; then as_have_required=yes else as_have_required=no fi if test $as_have_required = yes && (eval ": (as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=\$LINENO as_lineno_2=\$LINENO test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } ") 2> /dev/null; then : else as_candidate_shells= as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. case $as_dir in /*) for as_base in sh bash ksh sh5; do as_candidate_shells="$as_candidate_shells $as_dir/$as_base" done;; esac done IFS=$as_save_IFS for as_shell in $as_candidate_shells $SHELL; do # Try only shells that exist, to save several forks. if { test -f "$as_shell" || test -f "$as_shell.exe"; } && { ("$as_shell") 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : _ASEOF }; then CONFIG_SHELL=$as_shell as_have_required=yes if { "$as_shell" 2> /dev/null <<\_ASEOF if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi : (as_func_return () { (exit $1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = "$1" ); then : else exitcode=1 echo positional parameters were not saved. fi test $exitcode = 0) || { (exit 1); exit 1; } ( as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } _ASEOF }; then break fi fi done if test "x$CONFIG_SHELL" != x; then for as_var in BASH_ENV ENV do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done export CONFIG_SHELL exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} fi if test $as_have_required = no; then echo This script requires a shell more modern than all the echo shells that I found on your system. Please install a echo modern shell, or manually run the script under such a echo shell if you do have one. { (exit 1); exit 1; } fi fi fi (eval "as_func_return () { (exit \$1) } as_func_success () { as_func_return 0 } as_func_failure () { as_func_return 1 } as_func_ret_success () { return 0 } as_func_ret_failure () { return 1 } exitcode=0 if as_func_success; then : else exitcode=1 echo as_func_success failed. fi if as_func_failure; then exitcode=1 echo as_func_failure succeeded. fi if as_func_ret_success; then : else exitcode=1 echo as_func_ret_success failed. fi if as_func_ret_failure; then exitcode=1 echo as_func_ret_failure succeeded. fi if ( set x; as_func_ret_success y && test x = \"\$1\" ); then : else exitcode=1 echo positional parameters were not saved. fi test \$exitcode = 0") || { echo No shell found that supports shell functions. echo Please tell autoconf@gnu.org about your system, echo including any error possibly output before this echo message } as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 7<&0 &1 # Name of the host. # hostname on some systems (SVR3.2, Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` # # Initializations. # ac_default_prefix=/usr/local ac_clean_files= ac_config_libobj_dir=. LIBOBJS= cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME= PACKAGE_TARNAME= PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= ac_unique_file="Makefile.am" ac_unique_file="Makefile.am" # Factoring default headers for most tests. ac_includes_default="\ #include #ifdef HAVE_SYS_TYPES_H # include #endif #ifdef HAVE_SYS_STAT_H # include #endif #ifdef STDC_HEADERS # include # include #else # ifdef HAVE_STDLIB_H # include # endif #endif #ifdef HAVE_STRING_H # if !defined STDC_HEADERS && defined HAVE_MEMORY_H # include # endif # include #endif #ifdef HAVE_STRINGS_H # include #endif #ifdef HAVE_INTTYPES_H # include #endif #ifdef HAVE_STDINT_H # include #endif #ifdef HAVE_UNISTD_H # include #endif" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datarootdir datadir sysconfdir sharedstatedir localstatedir includedir oldincludedir docdir infodir htmldir dvidir pdfdir psdir libdir localedir mandir DEFS ECHO_C ECHO_N ECHO_T LIBS build_alias host_alias target_alias build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CYGPATH_W PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO install_sh STRIP INSTALL_STRIP_PROGRAM mkdir_p AWK SET_MAKE am__leading_dot AMTAR am__tar am__untar XMKMF CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE CPP X_CFLAGS X_PRE_LIBS X_LIBS X_EXTRA_LIBS BUILD_MACOSX_BUNDLE_TRUE BUILD_MACOSX_BUNDLE_FALSE BUILD_SIMPLE_BUNDLE_TRUE BUILD_SIMPLE_BUNDLE_FALSE UNIX_SCOREDIR_TRUE UNIX_SCOREDIR_FALSE DATADIR SCOREDIR CONFIGDIR CONFIGFILE EXEFILE MATHLIB CXX CXXFLAGS ac_ct_CXX CXXDEPMODE am__fastdepCXX_TRUE am__fastdepCXX_FALSE RANLIB SDL_CONFIG SDL_CFLAGS SDL_LIBS GREP EGREP LIBOBJS POW_LIB AUDIO_LIBS LOCALCFLAGS LTLIBOBJS' ac_subst_files='' ac_precious_vars='build_alias host_alias target_alias XMKMF CC CFLAGS LDFLAGS LIBS CPPFLAGS CPP CXX CXXFLAGS CCC' # Initialize some variables set by options. ac_init_help= ac_init_version=false # The variables have the same names as the options, with # dashes changed to underlines. cache_file=/dev/null exec_prefix=NONE no_create= no_recursion= prefix=NONE program_prefix=NONE program_suffix=NONE program_transform_name=s,x,x, silent= site= srcdir= verbose= x_includes=NONE x_libraries=NONE # Installation directory options. # These are left unexpanded so users can "make install exec_prefix=/foo" # and all the variables that are supposed to be based on exec_prefix # by default will actually change. # Use braces instead of parens because sh, perl, etc. also accept them. # (The list follows the same order as the GNU Coding Standards.) bindir='${exec_prefix}/bin' sbindir='${exec_prefix}/sbin' libexecdir='${exec_prefix}/libexec' datarootdir='${prefix}/share' datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE}' infodir='${datarootdir}/info' htmldir='${docdir}' dvidir='${docdir}' pdfdir='${docdir}' psdir='${docdir}' libdir='${exec_prefix}/lib' localedir='${datarootdir}/locale' mandir='${datarootdir}/man' ac_prev= ac_dashdash= for ac_option do # If the previous option needs an argument, assign it. if test -n "$ac_prev"; then eval $ac_prev=\$ac_option ac_prev= continue fi case $ac_option in *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. case $ac_dashdash$ac_option in --) ac_dashdash=yes ;; -bindir | --bindir | --bindi | --bind | --bin | --bi) ac_prev=bindir ;; -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) bindir=$ac_optarg ;; -build | --build | --buil | --bui | --bu) ac_prev=build_alias ;; -build=* | --build=* | --buil=* | --bui=* | --bu=*) build_alias=$ac_optarg ;; -cache-file | --cache-file | --cache-fil | --cache-fi \ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) ac_prev=cache_file ;; -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) cache_file=$ac_optarg ;; --config-cache | -C) cache_file=config.cache ;; -datadir | --datadir | --datadi | --datad) ac_prev=datadir ;; -datadir=* | --datadir=* | --datadi=* | --datad=*) datadir=$ac_optarg ;; -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ | --dataroo | --dataro | --datar) ac_prev=datarootdir ;; -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) datarootdir=$ac_optarg ;; -disable-* | --disable-*) ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=no ;; -docdir | --docdir | --docdi | --doc | --do) ac_prev=docdir ;; -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) docdir=$ac_optarg ;; -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) ac_prev=dvidir ;; -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) dvidir=$ac_optarg ;; -enable-* | --enable-*) ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid feature name: $ac_feature" >&2 { (exit 1); exit 1; }; } ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` eval enable_$ac_feature=\$ac_optarg ;; -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ | --exec | --exe | --ex) ac_prev=exec_prefix ;; -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ | --exec=* | --exe=* | --ex=*) exec_prefix=$ac_optarg ;; -gas | --gas | --ga | --g) # Obsolete; use --with-gas. with_gas=yes ;; -help | --help | --hel | --he | -h) ac_init_help=long ;; -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) ac_init_help=recursive ;; -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) ac_init_help=short ;; -host | --host | --hos | --ho) ac_prev=host_alias ;; -host=* | --host=* | --hos=* | --ho=*) host_alias=$ac_optarg ;; -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) ac_prev=htmldir ;; -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ | --ht=*) htmldir=$ac_optarg ;; -includedir | --includedir | --includedi | --included | --include \ | --includ | --inclu | --incl | --inc) ac_prev=includedir ;; -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ | --includ=* | --inclu=* | --incl=* | --inc=*) includedir=$ac_optarg ;; -infodir | --infodir | --infodi | --infod | --info | --inf) ac_prev=infodir ;; -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) infodir=$ac_optarg ;; -libdir | --libdir | --libdi | --libd) ac_prev=libdir ;; -libdir=* | --libdir=* | --libdi=* | --libd=*) libdir=$ac_optarg ;; -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ | --libexe | --libex | --libe) ac_prev=libexecdir ;; -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ | --libexe=* | --libex=* | --libe=*) libexecdir=$ac_optarg ;; -localedir | --localedir | --localedi | --localed | --locale) ac_prev=localedir ;; -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) localedir=$ac_optarg ;; -localstatedir | --localstatedir | --localstatedi | --localstated \ | --localstate | --localstat | --localsta | --localst | --locals) ac_prev=localstatedir ;; -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) localstatedir=$ac_optarg ;; -mandir | --mandir | --mandi | --mand | --man | --ma | --m) ac_prev=mandir ;; -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) mandir=$ac_optarg ;; -nfp | --nfp | --nf) # Obsolete; use --without-fp. with_fp=no ;; -no-create | --no-create | --no-creat | --no-crea | --no-cre \ | --no-cr | --no-c | -n) no_create=yes ;; -no-recursion | --no-recursion | --no-recursio | --no-recursi \ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) no_recursion=yes ;; -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ | --oldin | --oldi | --old | --ol | --o) ac_prev=oldincludedir ;; -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) oldincludedir=$ac_optarg ;; -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) ac_prev=prefix ;; -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) prefix=$ac_optarg ;; -program-prefix | --program-prefix | --program-prefi | --program-pref \ | --program-pre | --program-pr | --program-p) ac_prev=program_prefix ;; -program-prefix=* | --program-prefix=* | --program-prefi=* \ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) program_prefix=$ac_optarg ;; -program-suffix | --program-suffix | --program-suffi | --program-suff \ | --program-suf | --program-su | --program-s) ac_prev=program_suffix ;; -program-suffix=* | --program-suffix=* | --program-suffi=* \ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) program_suffix=$ac_optarg ;; -program-transform-name | --program-transform-name \ | --program-transform-nam | --program-transform-na \ | --program-transform-n | --program-transform- \ | --program-transform | --program-transfor \ | --program-transfo | --program-transf \ | --program-trans | --program-tran \ | --progr-tra | --program-tr | --program-t) ac_prev=program_transform_name ;; -program-transform-name=* | --program-transform-name=* \ | --program-transform-nam=* | --program-transform-na=* \ | --program-transform-n=* | --program-transform-=* \ | --program-transform=* | --program-transfor=* \ | --program-transfo=* | --program-transf=* \ | --program-trans=* | --program-tran=* \ | --progr-tra=* | --program-tr=* | --program-t=*) program_transform_name=$ac_optarg ;; -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) ac_prev=pdfdir ;; -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) pdfdir=$ac_optarg ;; -psdir | --psdir | --psdi | --psd | --ps) ac_prev=psdir ;; -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) psdir=$ac_optarg ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) silent=yes ;; -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ | --sbi=* | --sb=*) sbindir=$ac_optarg ;; -sharedstatedir | --sharedstatedir | --sharedstatedi \ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ | --sharedst | --shareds | --shared | --share | --shar \ | --sha | --sh) ac_prev=sharedstatedir ;; -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ | --sha=* | --sh=*) sharedstatedir=$ac_optarg ;; -site | --site | --sit) ac_prev=site ;; -site=* | --site=* | --sit=*) site=$ac_optarg ;; -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) ac_prev=srcdir ;; -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) srcdir=$ac_optarg ;; -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ | --syscon | --sysco | --sysc | --sys | --sy) ac_prev=sysconfdir ;; -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) sysconfdir=$ac_optarg ;; -target | --target | --targe | --targ | --tar | --ta | --t) ac_prev=target_alias ;; -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) target_alias=$ac_optarg ;; -v | -verbose | --verbose | --verbos | --verbo | --verb) verbose=yes ;; -version | --version | --versio | --versi | --vers | -V) ac_init_version=: ;; -with-* | --with-*) ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=\$ac_optarg ;; -without-* | --without-*) ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid package name: $ac_package" >&2 { (exit 1); exit 1; }; } ac_package=`echo $ac_package | sed 's/[-.]/_/g'` eval with_$ac_package=no ;; --x) # Obsolete; use --with-x. with_x=yes ;; -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ | --x-incl | --x-inc | --x-in | --x-i) ac_prev=x_includes ;; -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) x_includes=$ac_optarg ;; -x-libraries | --x-libraries | --x-librarie | --x-librari \ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) ac_prev=x_libraries ;; -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; -*) { echo "$as_me: error: unrecognized option: $ac_option Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 { (exit 1); exit 1; }; } eval $ac_envvar=\$ac_optarg export $ac_envvar ;; *) # FIXME: should be removed in autoconf 3.0. echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && echo "$as_me: WARNING: invalid host type: $ac_option" >&2 : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} ;; esac done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` { echo "$as_me: error: missing argument to $ac_option" >&2 { (exit 1); exit 1; }; } fi # Be sure to have absolute directory names. for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ libdir localedir mandir do eval ac_val=\$$ac_var case $ac_val in [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 { (exit 1); exit 1; }; } done # There might be people who depend on the old broken behavior: `$host' # used to hold the argument of --host etc. # FIXME: To remove some day. build=$build_alias host=$host_alias target=$target_alias # FIXME: To remove some day. if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi fi ac_tool_prefix= test -n "$host_alias" && ac_tool_prefix=$host_alias- test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || { echo "$as_me: error: Working directory cannot be determined" >&2 { (exit 1); exit 1; }; } test "X$ac_ls_di" = "X$ac_pwd_ls_di" || { echo "$as_me: error: pwd does not report name of working directory" >&2 { (exit 1); exit 1; }; } # Find the source files, if location was not specified. if test -z "$srcdir"; then ac_srcdir_defaulted=yes # Try the directory containing this script, then the parent directory. ac_confdir=`$as_dirname -- "$0" || $as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$0" : 'X\(//\)[^/]' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X"$0" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` srcdir=$ac_confdir if test ! -r "$srcdir/$ac_unique_file"; then srcdir=.. fi else ac_srcdir_defaulted=no fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 { (exit 1); exit 1; }; } fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 { (exit 1); exit 1; }; } pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then srcdir=. fi # Remove unnecessary trailing slashes from srcdir. # Double slashes in file names in object file debugging info # mess up M-x gdb in Emacs. case $srcdir in */) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; esac for ac_var in $ac_precious_vars; do eval ac_env_${ac_var}_set=\${${ac_var}+set} eval ac_env_${ac_var}_value=\$${ac_var} eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} eval ac_cv_env_${ac_var}_value=\$${ac_var} done # # Report the --help message. # if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF \`configure' configures this package to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... To assign environment variables (e.g., CC, CFLAGS...), specify them as VAR=VALUE. See below for descriptions of some of the useful variables. Defaults for the options are specified in brackets. Configuration: -h, --help display this help and exit --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit -q, --quiet, --silent do not print \`checking...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files --srcdir=DIR find the sources in DIR [configure dir or \`..'] Installation directories: --prefix=PREFIX install architecture-independent files in PREFIX [$ac_default_prefix] --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX [PREFIX] By default, \`make install' will install all the files in \`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify an installation prefix other than \`$ac_default_prefix' using \`--prefix', for instance \`--prefix=\$HOME'. For better control, use the options below. Fine tuning of the installation directories: --bindir=DIR user executables [EPREFIX/bin] --sbindir=DIR system admin executables [EPREFIX/sbin] --libexecdir=DIR program executables [EPREFIX/libexec] --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] --datadir=DIR read-only architecture-independent data [DATAROOTDIR] --infodir=DIR info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [DATAROOTDIR/man] --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] --htmldir=DIR html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [DOCDIR] --psdir=DIR ps documentation [DOCDIR] _ACEOF cat <<\_ACEOF Program names: --program-prefix=PREFIX prepend PREFIX to installed program names --program-suffix=SUFFIX append SUFFIX to installed program names --program-transform-name=PROGRAM run sed PROGRAM on installed program names X features: --x-includes=DIR X include files are in DIR --x-libraries=DIR X library files are in DIR System types: --build=BUILD configure for building on BUILD [guessed] --host=HOST cross-compile to build programs to run on HOST [BUILD] --target=TARGET configure for building compilers for TARGET [HOST] _ACEOF fi if test -n "$ac_init_help"; then cat <<\_ACEOF Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking speeds up one-time build --enable-dependency-tracking do not reject slow dependency extractors --enable-debug Build with debug switches and defines default=no --disable-sdltest Do not try to compile and run a test SDL program --enable-opengl use OpenGL rendering layer default=yes --enable-oss support the OSS audio API default=no --enable-alsa support the ALSA audio API default=no --enable-epm Compile with extremely picky settings default=no --enable-efence Link with ElectricFence default=no Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-x use the X Window System --with-sdl-prefix=PFX Prefix where SDL is installed (optional) --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional) Some influential environment variables: XMKMF Path to xmkmf, Makefile generator for X Window System CC C compiler command CFLAGS C compiler flags LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor CXX C++ compiler command CXXFLAGS C++ compiler flags Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. _ACEOF ac_status=$? fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d "$ac_dir" || continue ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix cd "$ac_dir" || { ac_status=$?; continue; } # Check for guested configure. if test -f "$ac_srcdir/configure.gnu"; then echo && $SHELL "$ac_srcdir/configure.gnu" --help=recursive elif test -f "$ac_srcdir/configure"; then echo && $SHELL "$ac_srcdir/configure" --help=recursive else echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 fi || ac_status=$? cd "$ac_pwd" || { ac_status=$?; break; } done fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF configure generated by GNU Autoconf 2.61 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. It was created by $as_me, which was generated by GNU Autoconf 2.61. Invocation command line was $ $0 $@ _ACEOF exec 5>>config.log { cat <<_ASUNAME ## --------- ## ## Platform. ## ## --------- ## hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` /bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` /bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` /usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` /bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` /bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` _ASUNAME as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. echo "PATH: $as_dir" done IFS=$as_save_IFS } >&5 cat >&5 <<_ACEOF ## ----------- ## ## Core tests. ## ## ----------- ## _ACEOF # Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. # Make two passes to allow for proper duplicate-argument suppression. ac_configure_args= ac_configure_args0= ac_configure_args1= ac_must_keep_next=false for ac_pass in 1 2 do for ac_arg do case $ac_arg in -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil) continue ;; *\'*) ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; 2) ac_configure_args1="$ac_configure_args1 '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else case $ac_arg in *=* | --config-cache | -C | -disable-* | --disable-* \ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ | -with-* | --with-* | -without-* | --without-* | --x) case "$ac_configure_args0 " in "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; esac ;; -* ) ac_must_keep_next=true ;; esac fi ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac done done $as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } $as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there # would cause problems or look ugly. # WARNING: Use '\'' to represent an apostrophe within the trap. # WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. trap 'exit_status=$? # Save into config.log some information that might help in debugging. { echo cat <<\_ASBOX ## ---------------- ## ## Cache variables. ## ## ---------------- ## _ASBOX echo # The following way of writing the cache mishandles newlines in values, ( for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( *${as_nl}ac_space=\ *) sed -n \ "s/'\''/'\''\\\\'\'''\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" ;; #( *) sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) echo cat <<\_ASBOX ## ----------------- ## ## Output variables. ## ## ----------------- ## _ASBOX echo for ac_var in $ac_subst_vars do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo if test -n "$ac_subst_files"; then cat <<\_ASBOX ## ------------------- ## ## File substitutions. ## ## ------------------- ## _ASBOX echo for ac_var in $ac_subst_files do eval ac_val=\$$ac_var case $ac_val in *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; esac echo "$ac_var='\''$ac_val'\''" done | sort echo fi if test -s confdefs.h; then cat <<\_ASBOX ## ----------- ## ## confdefs.h. ## ## ----------- ## _ASBOX echo cat confdefs.h echo fi test "$ac_signal" != 0 && echo "$as_me: caught signal $ac_signal" echo "$as_me: exit $exit_status" } >&5 rm -f core *.core core.conftest.* && rm -f -r conftest* confdefs* conf$$* $ac_clean_files && exit $exit_status ' 0 for ac_signal in 1 2 13 15; do trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF # Let the site file select an alternate cache file if it wants to. # Prefer explicitly selected file to automatically selected ones. if test -n "$CONFIG_SITE"; then set x "$CONFIG_SITE" elif test "x$prefix" != xNONE; then set x "$prefix/share/config.site" "$prefix/etc/config.site" else set x "$ac_default_prefix/share/config.site" \ "$ac_default_prefix/etc/config.site" fi shift for ac_site_file do if test -r "$ac_site_file"; then { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 . "$ac_site_file" fi done if test -r "$cache_file"; then # Some versions of bash will fail to source /dev/null (special # files actually), so we avoid doing that. if test -f "$cache_file"; then { echo "$as_me:$LINENO: loading cache $cache_file" >&5 echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; *) . "./$cache_file";; esac fi else { echo "$as_me:$LINENO: creating cache $cache_file" >&5 echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi # Check that the precious variables saved in the cache have kept the same # value. ac_cache_corrupted=false for ac_var in $ac_precious_vars; do eval ac_old_set=\$ac_cv_env_${ac_var}_set eval ac_new_set=\$ac_env_${ac_var}_set eval ac_old_val=\$ac_cv_env_${ac_var}_value eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; *) if test "x$ac_old_val" != "x$ac_new_val"; then { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 echo "$as_me: former value: $ac_old_val" >&2;} { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 echo "$as_me: current value: $ac_new_val" >&2;} ac_cache_corrupted=: fi;; esac # Pass precious variables to config.status. if test "$ac_new_set" = set; then case $ac_new_val in *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; *) ac_arg=$ac_var=$ac_new_val ;; esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 echo "$as_me: error: changes in the environment can compromise the build" >&2;} { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu ac_config_headers="$ac_config_headers aconfig.h" ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do if test -f "$ac_dir/install-sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install-sh -c" break elif test -f "$ac_dir/install.sh"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/install.sh -c" break elif test -f "$ac_dir/shtool"; then ac_aux_dir=$ac_dir ac_install_sh="$ac_aux_dir/shtool install -c" break fi done if test -z "$ac_aux_dir"; then { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} { (exit 1); exit 1; }; } fi # These three variables are undocumented and unsupported, # and are intended to be withdrawn in a future Autoconf release. # They can cause serious problems if a builder's source tree is in a directory # whose full name contains unusual characters. ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || { { echo "$as_me:$LINENO: error: cannot run $SHELL $ac_aux_dir/config.sub" >&5 echo "$as_me: error: cannot run $SHELL $ac_aux_dir/config.sub" >&2;} { (exit 1); exit 1; }; } { echo "$as_me:$LINENO: checking build system type" >&5 echo $ECHO_N "checking build system type... $ECHO_C" >&6; } if test "${ac_cv_build+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_build_alias=$build_alias test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && { { echo "$as_me:$LINENO: error: cannot guess build type; you must specify one" >&5 echo "$as_me: error: cannot guess build type; you must specify one" >&2;} { (exit 1); exit 1; }; } ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $ac_build_alias failed" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: $ac_cv_build" >&5 echo "${ECHO_T}$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical build" >&5 echo "$as_me: error: invalid value of canonical build" >&2;} { (exit 1); exit 1; }; };; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' set x $ac_cv_build shift build_cpu=$1 build_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: build_os=$* IFS=$ac_save_IFS case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking host system type" >&5 echo $ECHO_N "checking host system type... $ECHO_C" >&6; } if test "${ac_cv_host+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$host_alias" = x; then ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $host_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_host" >&5 echo "${ECHO_T}$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical host" >&5 echo "$as_me: error: invalid value of canonical host" >&2;} { (exit 1); exit 1; }; };; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' set x $ac_cv_host shift host_cpu=$1 host_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: host_os=$* IFS=$ac_save_IFS case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac { echo "$as_me:$LINENO: checking target system type" >&5 echo $ECHO_N "checking target system type... $ECHO_C" >&6; } if test "${ac_cv_target+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "x$target_alias" = x; then ac_cv_target=$ac_cv_host else ac_cv_target=`$SHELL "$ac_aux_dir/config.sub" $target_alias` || { { echo "$as_me:$LINENO: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&5 echo "$as_me: error: $SHELL $ac_aux_dir/config.sub $target_alias failed" >&2;} { (exit 1); exit 1; }; } fi fi { echo "$as_me:$LINENO: result: $ac_cv_target" >&5 echo "${ECHO_T}$ac_cv_target" >&6; } case $ac_cv_target in *-*-*) ;; *) { { echo "$as_me:$LINENO: error: invalid value of canonical target" >&5 echo "$as_me: error: invalid value of canonical target" >&2;} { (exit 1); exit 1; }; };; esac target=$ac_cv_target ac_save_IFS=$IFS; IFS='-' set x $ac_cv_target shift target_cpu=$1 target_vendor=$2 shift; shift # Remember, the first character of IFS is used to create $*, # except with old shells: target_os=$* IFS=$ac_save_IFS case $target_os in *\ *) target_os=`echo "$target_os" | sed 's/ /-/g'`;; esac # The aliases save the names the user supplied, while $host etc. # will get canonicalized. test -n "$target_alias" && test "$program_prefix$program_suffix$program_transform_name" = \ NONENONEs,x,x, && program_prefix=${target_alias}- am__api_version="1.9" # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' { echo "$as_me:$LINENO: checking whether build environment is sane" >&5 echo $ECHO_N "checking whether build environment is sane... $ECHO_C" >&6; } # Just in case sleep 1 echo timestamp > conftest.file # Do `set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null` if test "$*" = "X"; then # -L didn't work. set X `ls -t $srcdir/configure conftest.file` fi rm -f conftest.file if test "$*" != "X $srcdir/configure conftest.file" \ && test "$*" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". { { echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&5 echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken alias in your environment" >&2;} { (exit 1); exit 1; }; } fi test "$2" = conftest.file ) then # Ok. : else { { echo "$as_me:$LINENO: error: newly created file is older than distributed files! Check your system clock" >&5 echo "$as_me: error: newly created file is older than distributed files! Check your system clock" >&2;} { (exit 1); exit 1; }; } fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && program_transform_name="s&\$&$program_suffix&;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed s/[\\$]/&&/g;s/;s,x,x,$// _ACEOF program_transform_name=`echo $program_transform_name | sed -f conftest.sed` rm -f conftest.sed # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing" # Use eval to expand $SHELL if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= { echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then # We used to keeping the `.' as first argument, in order to # allow $(mkdir_p) to be used without argument. As in # $(mkdir_p) $(somedir) # where $(somedir) is conditionally defined. However this is wrong # for two reasons: # 1. if the package is installed by a user who cannot write `.' # make install will fail, # 2. the above comment should most certainly read # $(mkdir_p) $(DESTDIR)$(somedir) # so it does not work when $(somedir) is undefined and # $(DESTDIR) is not. # To support the latter case, we have to write # test -z "$(somedir)" || $(mkdir_p) $(DESTDIR)$(somedir), # so the `.' trick is pointless. mkdir_p='mkdir -p --' else # On NextStep and OpenStep, the `mkdir' command does not # recognize any option. It will interpret all options as # directories to create, and then abort because `.' already # exists. for d in ./-p ./--version; do test -d $d && rmdir $d done # $(mkinstalldirs) is defined by Automake if mkinstalldirs exists. if test -f "$ac_aux_dir/mkinstalldirs"; then mkdir_p='$(mkinstalldirs)' else mkdir_p='$(install_sh) -d' fi fi for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$AWK" && break done { echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 echo $ECHO_N "checking whether ${MAKE-make} sets \$(MAKE)... $ECHO_C" >&6; } set x ${MAKE-make}; ac_make=`echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.make <<\_ACEOF SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF # GNU make sometimes prints "make[1]: Entering...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; *) eval ac_cv_prog_make_${ac_make}_set=no;; esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } SET_MAKE= else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { { echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} { (exit 1); exit 1; }; } fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi # Define the identity of the package. PACKAGE=KoboDeluxe VERSION=0.5.1 cat >>confdefs.h <<_ACEOF #define PACKAGE "$PACKAGE" _ACEOF cat >>confdefs.h <<_ACEOF #define VERSION "$VERSION" _ACEOF # Some tools Automake needs. ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"} AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"} AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"} AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"} MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"} install_sh=${install_sh-"$am_aux_dir/install-sh"} # Installed binaries are usually stripped using `strip' when the user # run `make install-strip'. However `strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the `STRIP' environment variable to overrule this program. if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$STRIP"; then ac_cv_prog_STRIP="$STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then { echo "$as_me:$LINENO: result: $STRIP" >&5 echo "${ECHO_T}$STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_STRIP"; then ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_STRIP="strip" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then { echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 echo "${ECHO_T}$ac_ct_STRIP" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_STRIP" = x; then STRIP=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac STRIP=$ac_ct_STRIP fi else STRIP="$ac_cv_prog_STRIP" fi fi INSTALL_STRIP_PROGRAM="\${SHELL} \$(install_sh) -c -s" # We need awk for the "check" target. The system "awk" is bad on # some platforms. # Always define AMTAR for backward compatibility. AMTAR=${AMTAR-"${am_missing_run}tar"} am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -' LOCALCFLAGS='' DEPDIR="${am__leading_dot}deps" ac_config_commands="$ac_config_commands depfiles" am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo done .PHONY: am__doit END # If we don't find an include directive, just comment out the code. { echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 echo $ECHO_N "checking for style of include used by $am_make... $ECHO_C" >&6; } am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # We grep out `Entering directory' and `Leaving directory' # messages which can occur if `w' ends up in MAKEFLAGS. # In particular we don't look at `^make:' because GNU make might # be invoked under some other name (usually "gmake"), in which # case it prints its new name instead of `make'. if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then am__include=include am__quote= _am_result=GNU fi # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then am__include=.include am__quote="\"" _am_result=BSD fi fi { echo "$as_me:$LINENO: result: $_am_result" >&5 echo "${ECHO_T}$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. if test "${enable_dependency_tracking+set}" = set; then enableval=$enable_dependency_tracking; fi if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' fi if test "x$enable_dependency_tracking" != xno; then AMDEP_TRUE= AMDEP_FALSE='#' else AMDEP_TRUE='#' AMDEP_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files a.out a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. { echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # # List of possible output files, starting from the most likely. # The algorithm is not robust to junk in `.', hence go to wildcards (a.*) # only as a last resort. b.out is created by i960 compilers. ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' # # The IRIX 6 linker writes into existing files which may not be # executable, retaining their permissions. Remove them first so a # subsequent execution test works. ac_rmfiles= for ac_file in $ac_files do case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; * ) ac_rmfiles="$ac_rmfiles $ac_file";; esac done rm -f $ac_rmfiles if { (ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link_default") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, # so that the user can short-circuit this test for compilers unknown to # Autoconf. for ac_file in $ac_files '' do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; [ab].out ) # We found the default executable, but exeext='' is most # certainly right. break;; *.* ) if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi # We set ac_cv_exeext here because the later test for it is not # safe: cross compilers may not add the suffix if given an `-o' # argument, so we may need to know it at that point already. # Even if this section looks crufty: it has the advantage of # actually working. break;; * ) break;; esac done test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi { echo "$as_me:$LINENO: result: $ac_file" >&5 echo "${ECHO_T}$ac_file" >&6; } if test -z "$ac_file"; then echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: C compiler cannot create executables See \`config.log' for more details." >&5 echo "$as_me: error: C compiler cannot create executables See \`config.log' for more details." >&2;} { (exit 77); exit 77; }; } fi ac_exeext=$ac_cv_exeext # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether the C compiler works" >&5 echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # If not cross compiling, check that we can run a simple program. if test "$cross_compiling" != yes; then if { ac_try='./$ac_file' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then cross_compiling=no else if test "$cross_compiling" = maybe; then cross_compiling=yes else { { echo "$as_me:$LINENO: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&5 echo "$as_me: error: cannot run C compiled programs. If you meant to cross compile, use \`--host'. See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi fi fi { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } rm -f a.out a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save # Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. { echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } { echo "$as_me:$LINENO: result: $cross_compiling" >&5 echo "${ECHO_T}$cross_compiling" >&6; } { echo "$as_me:$LINENO: checking for suffix of executables" >&5 echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with # `rm'. for ac_file in conftest.exe conftest conftest.*; do test -f "$ac_file" || continue case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` break;; * ) break;; esac done else { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of executables: cannot compile and link See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest$ac_cv_exeext { echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 echo "${ECHO_T}$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT { echo "$as_me:$LINENO: checking for suffix of object files" >&5 echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } if test "${ac_cv_objext+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.o conftest.obj if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; then for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` break;; esac done else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&5 echo "$as_me: error: cannot compute suffix of object files: cannot compile See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 echo "${ECHO_T}$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then if test "${ac_cv_prog_CPP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Double quotes because CPP needs to be expanded for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" do ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then break fi done ac_cv_prog_CPP=$CPP fi CPP=$ac_cv_prog_CPP else ac_cv_prog_CPP=$CPP fi { echo "$as_me:$LINENO: result: $CPP" >&5 echo "${ECHO_T}$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes do # Use a header file that comes with gcc, so configuring glibc # with a fresh cross-compiler works. # Prefer to if __STDC__ is defined, since # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifdef __STDC__ # include #else # include #endif Syntax error _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Broken: fails on valid input. continue fi rm -f conftest.err conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # Broken: success on invalid input. continue else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 # Passes both tests. ac_preproc_ok=: break fi rm -f conftest.err conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. rm -f conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&5 echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu { echo "$as_me:$LINENO: checking for X" >&5 echo $ECHO_N "checking for X... $ECHO_C" >&6; } # Check whether --with-x was given. if test "${with_x+set}" = set; then withval=$with_x; fi # $have_x is `yes', `no', `disabled', or empty when we do not yet know. if test "x$with_x" = xno; then # The user explicitly disabled X. have_x=disabled else case $x_includes,$x_libraries in #( *\'*) { { echo "$as_me:$LINENO: error: Cannot use X directory names containing '" >&5 echo "$as_me: error: Cannot use X directory names containing '" >&2;} { (exit 1); exit 1; }; };; #( *,NONE | NONE,*) if test "${ac_cv_have_x+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # One or both of the vars are not set, and there is no cached value. ac_x_includes=no ac_x_libraries=no rm -f -r conftest.dir if mkdir conftest.dir; then cd conftest.dir cat >Imakefile <<'_ACEOF' incroot: @echo incroot='${INCROOT}' usrlibdir: @echo usrlibdir='${USRLIBDIR}' libdir: @echo libdir='${LIBDIR}' _ACEOF if (export CC; ${XMKMF-xmkmf}) >/dev/null 2>/dev/null && test -f Makefile; then # GNU make sometimes prints "make[1]: Entering...", which would confuse us. for ac_var in incroot usrlibdir libdir; do eval "ac_im_$ac_var=\`\${MAKE-make} $ac_var 2>/dev/null | sed -n 's/^$ac_var=//p'\`" done # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. for ac_extension in a so sl; do if test ! -f "$ac_im_usrlibdir/libX11.$ac_extension" && test -f "$ac_im_libdir/libX11.$ac_extension"; then ac_im_usrlibdir=$ac_im_libdir; break fi done # Screen out bogus values from the imake configuration. They are # bogus both because they are the default anyway, and because # using them would break gcc on systems where it needs fixed includes. case $ac_im_incroot in /usr/include) ac_x_includes= ;; *) test -f "$ac_im_incroot/X11/Xos.h" && ac_x_includes=$ac_im_incroot;; esac case $ac_im_usrlibdir in /usr/lib | /lib) ;; *) test -d "$ac_im_usrlibdir" && ac_x_libraries=$ac_im_usrlibdir ;; esac fi cd .. rm -f -r conftest.dir fi # Standard set of common directories for X headers. # Check X11 before X11Rn because it is often a symlink to the current release. ac_x_header_dirs=' /usr/X11/include /usr/X11R6/include /usr/X11R5/include /usr/X11R4/include /usr/include/X11 /usr/include/X11R6 /usr/include/X11R5 /usr/include/X11R4 /usr/local/X11/include /usr/local/X11R6/include /usr/local/X11R5/include /usr/local/X11R4/include /usr/local/include/X11 /usr/local/include/X11R6 /usr/local/include/X11R5 /usr/local/include/X11R4 /usr/X386/include /usr/x386/include /usr/XFree86/include/X11 /usr/include /usr/local/include /usr/unsupported/include /usr/athena/include /usr/local/x11r5/include /usr/lpp/Xamples/include /usr/openwin/include /usr/openwin/share/include' if test "$ac_x_includes" = no; then # Guess where to find include files, by looking for Xlib.h. # First, try using that file with no special directory specified. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then # We can compile using X headers with no special include directory. ac_x_includes= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 for ac_dir in $ac_x_header_dirs; do if test -r "$ac_dir/X11/Xlib.h"; then ac_x_includes=$ac_dir break fi done fi rm -f conftest.err conftest.$ac_ext fi # $ac_x_includes = no if test "$ac_x_libraries" = no; then # Check for the libraries. # See if we find them without any special options. # Don't add to $LIBS permanently. ac_save_LIBS=$LIBS LIBS="-lX11 $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { XrmInitialize () ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then LIBS=$ac_save_LIBS # We can link X programs with no special library path. ac_x_libraries= else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS=$ac_save_LIBS for ac_dir in `echo "$ac_x_includes $ac_x_header_dirs" | sed s/include/lib/g` do # Don't even attempt the hair of trying to link an X program! for ac_extension in a so sl; do if test -r "$ac_dir/libX11.$ac_extension"; then ac_x_libraries=$ac_dir break 2 fi done done fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi # $ac_x_libraries = no case $ac_x_includes,$ac_x_libraries in #( no,* | *,no | *\'*) # Didn't find X, or a directory has "'" in its name. ac_cv_have_x="have_x=no";; #( *) # Record where we found X for the cache. ac_cv_have_x="have_x=yes\ ac_x_includes='$ac_x_includes'\ ac_x_libraries='$ac_x_libraries'" esac fi ;; #( *) have_x=yes;; esac eval "$ac_cv_have_x" fi # $with_x != no if test "$have_x" != yes; then { echo "$as_me:$LINENO: result: $have_x" >&5 echo "${ECHO_T}$have_x" >&6; } no_x=yes else # If each of the values was on the command line, it overrides each guess. test "x$x_includes" = xNONE && x_includes=$ac_x_includes test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries # Update the cache value to reflect the command line values. ac_cv_have_x="have_x=yes\ ac_x_includes='$x_includes'\ ac_x_libraries='$x_libraries'" { echo "$as_me:$LINENO: result: libraries $x_libraries, headers $x_includes" >&5 echo "${ECHO_T}libraries $x_libraries, headers $x_includes" >&6; } fi if test "$no_x" = yes; then # Not all programs may use this symbol, but it does not hurt to define it. cat >>confdefs.h <<\_ACEOF #define X_DISPLAY_MISSING 1 _ACEOF X_CFLAGS= X_PRE_LIBS= X_LIBS= X_EXTRA_LIBS= else if test -n "$x_includes"; then X_CFLAGS="$X_CFLAGS -I$x_includes" fi # It would also be nice to do this for all -L options, not just this one. if test -n "$x_libraries"; then X_LIBS="$X_LIBS -L$x_libraries" # For Solaris; some versions of Sun CC require a space after -R and # others require no space. Words are not sufficient . . . . { echo "$as_me:$LINENO: checking whether -R must be followed by a space" >&5 echo $ECHO_N "checking whether -R must be followed by a space... $ECHO_C" >&6; } ac_xsave_LIBS=$LIBS; LIBS="$LIBS -R$x_libraries" ac_xsave_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } X_LIBS="$X_LIBS -R$x_libraries" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 LIBS="$ac_xsave_LIBS -R $x_libraries" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } X_LIBS="$X_LIBS -R $x_libraries" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: result: neither works" >&5 echo "${ECHO_T}neither works" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext ac_c_werror_flag=$ac_xsave_c_werror_flag LIBS=$ac_xsave_LIBS fi # Check for system-dependent libraries X programs must link with. # Do this before checking for the system-independent R6 libraries # (-lICE), since we may need -lsocket or whatever for X linking. if test "$ISC" = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" else # Martyn Johnson says this is needed for Ultrix, if the X # libraries were built with DECnet support. And Karl Berry says # the Alpha needs dnet_stub (dnet does not exist). ac_xsave_LIBS="$LIBS"; LIBS="$LIBS $X_LIBS -lX11" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char XOpenDisplay (); int main () { return XOpenDisplay (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet... $ECHO_C" >&6; } if test "${ac_cv_lib_dnet_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dnet_ntoa (); int main () { return dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_dnet_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_dnet_ntoa=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_dnet_ntoa" >&6; } if test $ac_cv_lib_dnet_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet" fi if test $ac_cv_lib_dnet_dnet_ntoa = no; then { echo "$as_me:$LINENO: checking for dnet_ntoa in -ldnet_stub" >&5 echo $ECHO_N "checking for dnet_ntoa in -ldnet_stub... $ECHO_C" >&6; } if test "${ac_cv_lib_dnet_stub_dnet_ntoa+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-ldnet_stub $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char dnet_ntoa (); int main () { return dnet_ntoa (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_dnet_stub_dnet_ntoa=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_dnet_stub_dnet_ntoa=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_dnet_stub_dnet_ntoa" >&5 echo "${ECHO_T}$ac_cv_lib_dnet_stub_dnet_ntoa" >&6; } if test $ac_cv_lib_dnet_stub_dnet_ntoa = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub" fi fi fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS="$ac_xsave_LIBS" # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, # to get the SysV transport functions. # Chad R. Larson says the Pyramis MIS-ES running DC/OSx (SVR4) # needs -lnsl. # The nsl library prevents programs from opening the X display # on Irix 5.2, according to T.E. Dickey. # The functions gethostbyname, getservbyname, and inet_addr are # in -lbsd on LynxOS 3.0.1/i386, according to Lars Hecking. { echo "$as_me:$LINENO: checking for gethostbyname" >&5 echo $ECHO_N "checking for gethostbyname... $ECHO_C" >&6; } if test "${ac_cv_func_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define gethostbyname to an innocuous variant, in case declares gethostbyname. For example, HP-UX 11i declares gettimeofday. */ #define gethostbyname innocuous_gethostbyname /* System header to define __stub macros and hopefully few prototypes, which can conflict with char gethostbyname (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef gethostbyname /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_gethostbyname || defined __stub___gethostbyname choke me #endif int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_func_gethostbyname" >&6; } if test $ac_cv_func_gethostbyname = no; then { echo "$as_me:$LINENO: checking for gethostbyname in -lnsl" >&5 echo $ECHO_N "checking for gethostbyname in -lnsl... $ECHO_C" >&6; } if test "${ac_cv_lib_nsl_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lnsl $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_nsl_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_nsl_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_nsl_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_nsl_gethostbyname" >&6; } if test $ac_cv_lib_nsl_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl" fi if test $ac_cv_lib_nsl_gethostbyname = no; then { echo "$as_me:$LINENO: checking for gethostbyname in -lbsd" >&5 echo $ECHO_N "checking for gethostbyname in -lbsd... $ECHO_C" >&6; } if test "${ac_cv_lib_bsd_gethostbyname+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lbsd $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char gethostbyname (); int main () { return gethostbyname (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_bsd_gethostbyname=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_bsd_gethostbyname=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_bsd_gethostbyname" >&5 echo "${ECHO_T}$ac_cv_lib_bsd_gethostbyname" >&6; } if test $ac_cv_lib_bsd_gethostbyname = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lbsd" fi fi fi # lieder@skyler.mavd.honeywell.com says without -lsocket, # socket/setsockopt and other routines are undefined under SCO ODT # 2.0. But -lsocket is broken on IRIX 5.2 (and is not necessary # on later versions), says Simon Leinen: it contains gethostby* # variants that don't use the name server (or something). -lsocket # must be given before -lnsl if both are needed. We assume that # if connect needs -lnsl, so does gethostbyname. { echo "$as_me:$LINENO: checking for connect" >&5 echo $ECHO_N "checking for connect... $ECHO_C" >&6; } if test "${ac_cv_func_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define connect to an innocuous variant, in case declares connect. For example, HP-UX 11i declares gettimeofday. */ #define connect innocuous_connect /* System header to define __stub macros and hopefully few prototypes, which can conflict with char connect (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef connect /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_connect || defined __stub___connect choke me #endif int main () { return connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_connect=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_connect" >&5 echo "${ECHO_T}$ac_cv_func_connect" >&6; } if test $ac_cv_func_connect = no; then { echo "$as_me:$LINENO: checking for connect in -lsocket" >&5 echo $ECHO_N "checking for connect in -lsocket... $ECHO_C" >&6; } if test "${ac_cv_lib_socket_connect+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lsocket $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char connect (); int main () { return connect (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_socket_connect=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_socket_connect=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_socket_connect" >&5 echo "${ECHO_T}$ac_cv_lib_socket_connect" >&6; } if test $ac_cv_lib_socket_connect = yes; then X_EXTRA_LIBS="-lsocket $X_EXTRA_LIBS" fi fi # Guillermo Gomez says -lposix is necessary on A/UX. { echo "$as_me:$LINENO: checking for remove" >&5 echo $ECHO_N "checking for remove... $ECHO_C" >&6; } if test "${ac_cv_func_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define remove to an innocuous variant, in case declares remove. For example, HP-UX 11i declares gettimeofday. */ #define remove innocuous_remove /* System header to define __stub macros and hopefully few prototypes, which can conflict with char remove (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef remove /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char remove (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_remove || defined __stub___remove choke me #endif int main () { return remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_remove=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_remove" >&5 echo "${ECHO_T}$ac_cv_func_remove" >&6; } if test $ac_cv_func_remove = no; then { echo "$as_me:$LINENO: checking for remove in -lposix" >&5 echo $ECHO_N "checking for remove in -lposix... $ECHO_C" >&6; } if test "${ac_cv_lib_posix_remove+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lposix $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char remove (); int main () { return remove (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_posix_remove=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_posix_remove=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_posix_remove" >&5 echo "${ECHO_T}$ac_cv_lib_posix_remove" >&6; } if test $ac_cv_lib_posix_remove = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lposix" fi fi # BSDI BSD/OS 2.1 needs -lipc for XOpenDisplay. { echo "$as_me:$LINENO: checking for shmat" >&5 echo $ECHO_N "checking for shmat... $ECHO_C" >&6; } if test "${ac_cv_func_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define shmat to an innocuous variant, in case declares shmat. For example, HP-UX 11i declares gettimeofday. */ #define shmat innocuous_shmat /* System header to define __stub macros and hopefully few prototypes, which can conflict with char shmat (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef shmat /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shmat (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_shmat || defined __stub___shmat choke me #endif int main () { return shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_shmat=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_shmat" >&5 echo "${ECHO_T}$ac_cv_func_shmat" >&6; } if test $ac_cv_func_shmat = no; then { echo "$as_me:$LINENO: checking for shmat in -lipc" >&5 echo $ECHO_N "checking for shmat in -lipc... $ECHO_C" >&6; } if test "${ac_cv_lib_ipc_shmat+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lipc $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char shmat (); int main () { return shmat (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_ipc_shmat=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ipc_shmat=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_ipc_shmat" >&5 echo "${ECHO_T}$ac_cv_lib_ipc_shmat" >&6; } if test $ac_cv_lib_ipc_shmat = yes; then X_EXTRA_LIBS="$X_EXTRA_LIBS -lipc" fi fi fi # Check for libraries that X11R6 Xt/Xaw programs need. ac_save_LDFLAGS=$LDFLAGS test -n "$x_libraries" && LDFLAGS="$LDFLAGS -L$x_libraries" # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to # check for ICE first), but we must link in the order -lSM -lICE or # we get undefined symbols. So assume we have SM if we have ICE. # These have to be linked with before -lX11, unlike the other # libraries we check for below, so use a different variable. # John Interrante, Karl Berry { echo "$as_me:$LINENO: checking for IceConnectionNumber in -lICE" >&5 echo $ECHO_N "checking for IceConnectionNumber in -lICE... $ECHO_C" >&6; } if test "${ac_cv_lib_ICE_IceConnectionNumber+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lICE $X_EXTRA_LIBS $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char IceConnectionNumber (); int main () { return IceConnectionNumber (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_ICE_IceConnectionNumber=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_ICE_IceConnectionNumber=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_ICE_IceConnectionNumber" >&5 echo "${ECHO_T}$ac_cv_lib_ICE_IceConnectionNumber" >&6; } if test $ac_cv_lib_ICE_IceConnectionNumber = yes; then X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE" fi LDFLAGS=$ac_save_LDFLAGS fi { echo "$as_me:$LINENO: checking target platform and install style" >&5 echo $ECHO_N "checking target platform and install style... $ECHO_C" >&6; }; build_macosx_bundle=no build_simple_bundle=no unix_scoredir=yes DATADIR='$(datadir)/kobo-deluxe' SCOREDIR='$(sharedstatedir)/kobo-deluxe/scores' CONFIGDIR='HOME>>' CONFIGFILE='.kobodlrc' EXEFILE=kobodl case "$target_os" in linux*) { echo "$as_me:$LINENO: result: GNU/Linux; Un*x style" >&5 echo "${ECHO_T}GNU/Linux; Un*x style" >&6; } MATHLIB="-lm" if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; beos) { echo "$as_me:$LINENO: result: BeOS; Un*x style install" >&5 echo "${ECHO_T}BeOS; Un*x style install" >&6; } MATHLIB="" ;; mingw32*) { echo "$as_me:$LINENO: result: Win32 (mingw32); Simple bundle" >&5 echo "${ECHO_T}Win32 (mingw32); Simple bundle" >&6; } build_simple_bundle=yes unix_scoredir=no DATADIR='EXE>>' SCOREDIR='EXE>>scores' CONFIGDIR='EXE>>' CONFIGFILE='kobodl.cfg' EXEFILE=kobodl.exe MATHLIB="" ;; cygwin*) { echo "$as_me:$LINENO: result: Win32 (cygwin); Simple bundle" >&5 echo "${ECHO_T}Win32 (cygwin); Simple bundle" >&6; } build_simple_bundle=yes unix_scoredir=no DATADIR='EXE>>' SCOREDIR='EXE>>scores' CONFIGDIR='EXE>>' CONFIGFILE='kobodl.cfg' EXEFILE=kobodl.exe MATHLIB="" ;; darwin*) { echo "$as_me:$LINENO: result: Mac OS X/Darwin; Mac OS X bundle" >&5 echo "${ECHO_T}Mac OS X/Darwin; Mac OS X bundle" >&6; } build_macosx_bundle=yes DATADIR='EXE>>../Resources' SCOREDIR='/Library/Preferences/KoboDeluxe/scores' CONFIGDIR='HOME>>Library/Preferences' CONFIGFILE='KoboDeluxe Preferences' MATHLIB="" ;; aix*) { echo "$as_me:$LINENO: result: AIX; Un*x style" >&5 echo "${ECHO_T}AIX; Un*x style" >&6; } if test x$ac_cv_c_compiler_gnu = xyes; then CFLAGS="-mthreads" fi if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; solaris*) { echo "$as_me:$LINENO: result: Solaris SPARC; Un*x style" >&5 echo "${ECHO_T}Solaris SPARC; Un*x style" >&6; } MATHLIB="-lm" CFLAGS="$CFLAGS $X_CFLAGS" ;; *) { echo "$as_me:$LINENO: result: Unknown (assuming Un*x-like); Un*x style" >&5 echo "${ECHO_T}Unknown (assuming Un*x-like); Un*x style" >&6; } MATHLIB="-lm" if test x$have_x = xyes; then CFLAGS="$CFLAGS $X_CFLAGS" fi ;; esac if test x$build_macosx_bundle = xyes; then BUILD_MACOSX_BUNDLE_TRUE= BUILD_MACOSX_BUNDLE_FALSE='#' else BUILD_MACOSX_BUNDLE_TRUE='#' BUILD_MACOSX_BUNDLE_FALSE= fi if test x$build_simple_bundle = xyes; then BUILD_SIMPLE_BUNDLE_TRUE= BUILD_SIMPLE_BUNDLE_FALSE='#' else BUILD_SIMPLE_BUNDLE_TRUE='#' BUILD_SIMPLE_BUNDLE_FALSE= fi if test x$unix_scoredir = xyes; then UNIX_SCOREDIR_TRUE= UNIX_SCOREDIR_FALSE='#' else UNIX_SCOREDIR_TRUE='#' UNIX_SCOREDIR_FALSE= fi # Check whether --enable-debug was given. if test "${enable_debug+set}" = set; then enableval=$enable_debug; else enable_debug=no fi { echo "$as_me:$LINENO: checking for debug build" >&5 echo $ECHO_N "checking for debug build... $ECHO_C" >&6; } if test x$enable_debug = xyes; then CFLAGS="$CFLAGS -g -DDEBUG" CXXFLAGS="$CXXFLAGS -g -DDEBUG" fi { echo "$as_me:$LINENO: result: $enable_debug" >&5 echo "${ECHO_T}$enable_debug" >&6; } ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="gcc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi else CC="$ac_cv_prog_CC" fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="${ac_tool_prefix}cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi fi if test -z "$CC"; then # Extract the first word of "cc", so it can be a program name with args. set dummy cc; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else ac_prog_rejected=no as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then # We found a bogon in the path, so make sure we never use it. set dummy $ac_cv_prog_CC shift if test $# != 0; then # We chose a different compiler from the bogus one. # However, it has the same basename, so the bogon will be chosen # first if we set CC to just the basename; use the full file name. shift ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" fi fi fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$CC"; then if test -n "$ac_tool_prefix"; then for ac_prog in cl.exe do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CC"; then ac_cv_prog_CC="$CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then { echo "$as_me:$LINENO: result: $CC" >&5 echo "${ECHO_T}$CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CC" && break done fi if test -z "$CC"; then ac_ct_CC=$CC for ac_prog in cl.exe do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CC+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CC"; then ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CC="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 echo "${ECHO_T}$ac_ct_CC" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CC" && break done if test "x$ac_ct_CC" = x; then CC="" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CC=$ac_ct_CC fi fi fi test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&5 echo "$as_me: error: no acceptable C compiler found in \$PATH See \`config.log' for more details." >&2;} { (exit 1); exit 1; }; } # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } if test "${ac_cv_c_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } GCC=`test $ac_compiler_gnu = yes && echo yes` ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS elif test $ac_cv_prog_cc_g = yes; then if test "$GCC" = yes; then CFLAGS="-g -O2" else CFLAGS="-g" fi else if test "$GCC" = yes; then CFLAGS="-O2" else CFLAGS= fi fi { echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } if test "${ac_cv_prog_cc_c89+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); static char *e (p, i) char **p; int i; { return p[i]; } static char *f (char * (*g) (char **, int), char **p, ...) { char *s; va_list v; va_start (v,p); s = g (p, va_arg (v,int)); va_end (v); return s; } /* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has function prototypes and stuff, but not '\xHH' hex character constants. These don't provoke an error unfortunately, instead are silently treated as 'x'. The following induces an error, until -std is added to get proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an array size at least. It's necessary to write '\x00'==0 to get something that's true only with -std. */ int osf4_cc_array ['\x00' == 0 ? 1 : -1]; /* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters inside strings and character constants. */ #define FOO(x) 'x' int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);}; int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); int argc; char **argv; int main () { return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; ; return 0; } _ACEOF for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cc_c89=$ac_arg else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done rm -f conftest.$ac_ext CC=$ac_save_CC fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) { echo "$as_me:$LINENO: result: none needed" >&5 echo "${ECHO_T}none needed" >&6; } ;; xno) { echo "$as_me:$LINENO: result: unsupported" >&5 echo "${ECHO_T}unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; esac ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CC" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CC_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CC_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CC_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then am__fastdepCC_TRUE= am__fastdepCC_FALSE='#' else am__fastdepCC_TRUE='#' am__fastdepCC_FALSE= fi ac_ext=cpp ac_cpp='$CXXCPP $CPPFLAGS' ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_cxx_compiler_gnu if test -z "$CXX"; then if test -n "$CCC"; then CXX=$CCC else if test -n "$ac_tool_prefix"; then for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$CXX"; then ac_cv_prog_CXX="$CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_CXX="$ac_tool_prefix$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi CXX=$ac_cv_prog_CXX if test -n "$CXX"; then { echo "$as_me:$LINENO: result: $CXX" >&5 echo "${ECHO_T}$CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$CXX" && break done fi if test -z "$CXX"; then ac_ct_CXX=$CXX for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_CXX+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_CXX"; then ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_CXX="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_CXX=$ac_cv_prog_ac_ct_CXX if test -n "$ac_ct_CXX"; then { echo "$as_me:$LINENO: result: $ac_ct_CXX" >&5 echo "${ECHO_T}$ac_ct_CXX" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$ac_ct_CXX" && break done if test "x$ac_ct_CXX" = x; then CXX="g++" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac CXX=$ac_ct_CXX fi fi fi fi # Provide some information about the compiler. echo "$as_me:$LINENO: checking for C++ compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (ac_try="$ac_compiler --version >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler --version >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -v >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -v >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { (ac_try="$ac_compiler -V >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compiler -V >&5") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } { echo "$as_me:$LINENO: checking whether we are using the GNU C++ compiler" >&5 echo $ECHO_N "checking whether we are using the GNU C++ compiler... $ECHO_C" >&6; } if test "${ac_cv_cxx_compiler_gnu+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { #ifndef __GNUC__ choke me #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_compiler_gnu=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_compiler_gnu=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_cxx_compiler_gnu=$ac_compiler_gnu fi { echo "$as_me:$LINENO: result: $ac_cv_cxx_compiler_gnu" >&5 echo "${ECHO_T}$ac_cv_cxx_compiler_gnu" >&6; } GXX=`test $ac_compiler_gnu = yes && echo yes` ac_test_CXXFLAGS=${CXXFLAGS+set} ac_save_CXXFLAGS=$CXXFLAGS { echo "$as_me:$LINENO: checking whether $CXX accepts -g" >&5 echo $ECHO_N "checking whether $CXX accepts -g... $ECHO_C" >&6; } if test "${ac_cv_prog_cxx_g+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_cv_prog_cxx_g=no CXXFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 CXXFLAGS="" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then : else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="-g" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_cxx_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_prog_cxx_g=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cxx_werror_flag=$ac_save_cxx_werror_flag fi { echo "$as_me:$LINENO: result: $ac_cv_prog_cxx_g" >&5 echo "${ECHO_T}$ac_cv_prog_cxx_g" >&6; } if test "$ac_test_CXXFLAGS" = set; then CXXFLAGS=$ac_save_CXXFLAGS elif test $ac_cv_prog_cxx_g = yes; then if test "$GXX" = yes; then CXXFLAGS="-g -O2" else CXXFLAGS="-g" fi else if test "$GXX" = yes; then CXXFLAGS="-O2" else CXXFLAGS= fi fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu depcc="$CXX" am_compiler_list= { echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 echo $ECHO_N "checking dependency style of $depcc... $ECHO_C" >&6; } if test "${am_cv_CXX_dependencies_compiler_type+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named `D' -- because `-MD' means `put the output # in D'. mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_CXX_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp` fi for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with # Solaris 8's {/usr,}/bin/sh. touch sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf case $depmode in nosideeffect) # after this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; none) break ;; esac # We check with `-c' and `-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle `-M -o', and we need to detect this. if depmode=$depmode \ source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_CXX_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_CXX_dependencies_compiler_type=none fi fi { echo "$as_me:$LINENO: result: $am_cv_CXX_dependencies_compiler_type" >&5 echo "${ECHO_T}$am_cv_CXX_dependencies_compiler_type" >&6; } CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type if test "x$enable_dependency_tracking" != xno \ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then am__fastdepCXX_TRUE= am__fastdepCXX_FALSE='#' else am__fastdepCXX_TRUE='#' am__fastdepCXX_FALSE= fi # Find a good install program. We prefer a C program (faster), # so one script is as good as another. But avoid the broken or # incompatible versions: # SysV /etc/install, /usr/sbin/install # SunOS /usr/etc/install # IRIX /sbin/install # AIX /bin/install # AmigaOS /C/install, which installs bootblocks on floppy discs # AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag # AFS /usr/afsws/bin/install, which mishandles nonexistent args # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. { echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; } if test -z "$INSTALL"; then if test "${ac_cv_path_install+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. # Account for people who put trailing slashes in PATH elements. case $as_dir/ in ./ | .// | /cC/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. # Don't use installbsd from OSF since it installs stuff as root # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. : elif test $ac_prog = install && grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # program-specific install script used by HP pwplus--don't use. : else ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" break 3 fi fi done done ;; esac done IFS=$as_save_IFS fi if test "${ac_cv_path_install+set}" = set; then INSTALL=$ac_cv_path_install else # As a last resort, use the slow shell script. Don't cache a # value for INSTALL within a source directory, because that will # break other packages using the cache if that directory is # removed, or if the value is a relative name. INSTALL=$ac_install_sh fi fi { echo "$as_me:$LINENO: result: $INSTALL" >&5 echo "${ECHO_T}$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. # It thinks the first close brace ends the variable substitution. test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_AWK+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$AWK"; then ac_cv_prog_AWK="$AWK" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_AWK="$ac_prog" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then { echo "$as_me:$LINENO: result: $AWK" >&5 echo "${ECHO_T}$AWK" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi test -n "$AWK" && break done if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. set dummy ${ac_tool_prefix}ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$RANLIB"; then ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi RANLIB=$ac_cv_prog_RANLIB if test -n "$RANLIB"; then { echo "$as_me:$LINENO: result: $RANLIB" >&5 echo "${ECHO_T}$RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi fi if test -z "$ac_cv_prog_RANLIB"; then ac_ct_RANLIB=$RANLIB # Extract the first word of "ranlib", so it can be a program name with args. set dummy ranlib; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test -n "$ac_ct_RANLIB"; then ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test. else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_prog_ac_ct_RANLIB="ranlib" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS fi fi ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB if test -n "$ac_ct_RANLIB"; then { echo "$as_me:$LINENO: result: $ac_ct_RANLIB" >&5 echo "${ECHO_T}$ac_ct_RANLIB" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi if test "x$ac_ct_RANLIB" = x; then RANLIB=":" else case $cross_compiling:$ac_tool_warned in yes:) { echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&5 echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools whose name does not start with the host triplet. If you think this configuration is useful to you, please write to autoconf@gnu.org." >&2;} ac_tool_warned=yes ;; esac RANLIB=$ac_ct_RANLIB fi else RANLIB="$ac_cv_prog_RANLIB" fi SDL_VERSION=1.2.0 # Check whether --with-sdl-prefix was given. if test "${with_sdl_prefix+set}" = set; then withval=$with_sdl_prefix; sdl_prefix="$withval" else sdl_prefix="" fi # Check whether --with-sdl-exec-prefix was given. if test "${with_sdl_exec_prefix+set}" = set; then withval=$with_sdl_exec_prefix; sdl_exec_prefix="$withval" else sdl_exec_prefix="" fi # Check whether --enable-sdltest was given. if test "${enable_sdltest+set}" = set; then enableval=$enable_sdltest; else enable_sdltest=yes fi if test x$sdl_exec_prefix != x ; then sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config fi fi if test x$sdl_prefix != x ; then sdl_args="$sdl_args --prefix=$sdl_prefix" if test x${SDL_CONFIG+set} != xset ; then SDL_CONFIG=$sdl_prefix/bin/sdl-config fi fi if test "x$prefix" != xNONE; then PATH="$prefix/bin:$prefix/usr/bin:$PATH" fi # Extract the first word of "sdl-config", so it can be a program name with args. set dummy sdl-config; ac_word=$2 { echo "$as_me:$LINENO: checking for $ac_word" >&5 echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } if test "${ac_cv_path_SDL_CONFIG+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else case $SDL_CONFIG in [\\/]* | ?:[\\/]*) ac_cv_path_SDL_CONFIG="$SDL_CONFIG" # Let the user override the test with a path. ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then ac_cv_path_SDL_CONFIG="$as_dir/$ac_word$ac_exec_ext" echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done done IFS=$as_save_IFS test -z "$ac_cv_path_SDL_CONFIG" && ac_cv_path_SDL_CONFIG="no" ;; esac fi SDL_CONFIG=$ac_cv_path_SDL_CONFIG if test -n "$SDL_CONFIG"; then { echo "$as_me:$LINENO: result: $SDL_CONFIG" >&5 echo "${ECHO_T}$SDL_CONFIG" >&6; } else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } fi min_sdl_version=$SDL_VERSION { echo "$as_me:$LINENO: checking for SDL - version >= $min_sdl_version" >&5 echo $ECHO_N "checking for SDL - version >= $min_sdl_version... $ECHO_C" >&6; } no_sdl="" if test "$SDL_CONFIG" = "no" ; then no_sdl=yes else SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags` SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs` sdl_major_version=`$SDL_CONFIG $sdl_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\1/'` sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\2/'` sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \ sed 's/\([0-9]*\).\([0-9]*\).\([0-9]*\)/\3/'` if test "x$enable_sdltest" = "xyes" ; then ac_save_CFLAGS="$CFLAGS" ac_save_CXXFLAGS="$CXXFLAGS" ac_save_LIBS="$LIBS" CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" rm -f conf.sdltest if test "$cross_compiling" = yes; then echo $ac_n "cross compiling; assumed OK... $ac_c" else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include "SDL.h" char* my_strdup (char *str) { char *new_str; if (str) { new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char)); strcpy (new_str, str); } else new_str = NULL; return new_str; } int main (int argc, char *argv[]) { int major, minor, micro; char *tmp_version; /* This hangs on some systems (?) system ("touch conf.sdltest"); */ { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); } /* HP/UX 9 (%@#!) writes to sscanf strings */ tmp_version = my_strdup("$min_sdl_version"); if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { printf("%s, bad version string\n", "$min_sdl_version"); exit(1); } if (($sdl_major_version > major) || (($sdl_major_version == major) && ($sdl_minor_version > minor)) || (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro))) { return 0; } else { printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version); printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro); printf("*** best to upgrade to the required version.\n"); printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n"); printf("*** to point to the correct copy of sdl-config, and remove the file\n"); printf("*** config.cache before re-running configure\n"); return 1; } } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) no_sdl=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi if test "x$no_sdl" = x ; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } : else { echo "$as_me:$LINENO: result: no" >&5 echo "${ECHO_T}no" >&6; } if test "$SDL_CONFIG" = "no" ; then echo "*** The sdl-config script installed by SDL could not be found" echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in" echo "*** your path, or set the SDL_CONFIG environment variable to the" echo "*** full path to sdl-config." else if test -f conf.sdltest ; then : else echo "*** Could not run SDL test program, checking why..." CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include "SDL.h" int main(int argc, char *argv[]) { return 0; } #undef main #define main K_and_R_C_main int main () { return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then echo "*** The test program compiled, but did not run. This usually means" echo "*** that the run-time linker is not finding SDL or finding the wrong" echo "*** version of SDL. If it is not finding SDL, you'll need to set your" echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" echo "*** to the installed location Also, make sure you have run ldconfig if that" echo "*** is required on your system" echo "***" echo "*** If you have an old version installed, it is best to remove it, although" echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 echo "*** The test program failed to compile or link. See the file config.log for the" echo "*** exact error that occured. This usually means SDL was incorrectly installed" echo "*** or that you have moved SDL since it was installed. In the latter case, you" echo "*** may want to edit the sdl-config script: $SDL_CONFIG" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext CFLAGS="$ac_save_CFLAGS" CXXFLAGS="$ac_save_CXXFLAGS" LIBS="$ac_save_LIBS" fi fi SDL_CFLAGS="" SDL_LIBS="" { { echo "$as_me:$LINENO: error: *** SDL version $SDL_VERSION required!" >&5 echo "$as_me: error: *** SDL version $SDL_VERSION required!" >&2;} { (exit 1); exit 1; }; } fi rm -f conf.sdltest CFLAGS="$CFLAGS $SDL_CFLAGS" CXXFLAGS="$CXXFLAGS $SDL_CFLAGS" LIBS="$LIBS $SDL_LIBS" { echo "$as_me:$LINENO: checking for IMG_Load in -lSDL_image" >&5 echo $ECHO_N "checking for IMG_Load in -lSDL_image... $ECHO_C" >&6; } if test "${ac_cv_lib_SDL_image_IMG_Load+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lSDL_image -lSDL $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char IMG_Load (); int main () { return IMG_Load (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_SDL_image_IMG_Load=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_SDL_image_IMG_Load=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_SDL_image_IMG_Load" >&5 echo "${ECHO_T}$ac_cv_lib_SDL_image_IMG_Load" >&6; } if test $ac_cv_lib_SDL_image_IMG_Load = yes; then cat >>confdefs.h <<_ACEOF #define HAVE_LIBSDL_IMAGE 1 _ACEOF LIBS="-lSDL_image $LIBS" else { { echo "$as_me:$LINENO: error: You need the SDL_image library to compile this software. Get it at http://www.libsdl.org/projects/SDL_image/" >&5 echo "$as_me: error: You need the SDL_image library to compile this software. Get it at http://www.libsdl.org/projects/SDL_image/" >&2;} { (exit 1); exit 1; }; } fi LIBS="$LIBS -lSDL_image" { echo "$as_me:$LINENO: checking for OpenGL support" >&5 echo $ECHO_N "checking for OpenGL support... $ECHO_C" >&6; } have_opengl=no cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then have_opengl=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext # Check whether --enable-opengl was given. if test "${enable_opengl+set}" = set; then enableval=$enable_opengl; else enable_opengl=yes fi if test x$enable_opengl = xyes; then { echo "$as_me:$LINENO: result: $have_opengl" >&5 echo "${ECHO_T}$have_opengl" >&6; } else have_opengl=no { echo "$as_me:$LINENO: result: Disabled" >&5 echo "${ECHO_T}Disabled" >&6; } fi if test x$have_opengl = xyes; then CFLAGS="$CFLAGS -DHAVE_OPENGL" CXXFLAGS="$CXXFLAGS -DHAVE_OPENGL" fi ac_header_dirent=no for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_hdr that defines DIR" >&5 echo $ECHO_N "checking for $ac_hdr that defines DIR... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include <$ac_hdr> int main () { if ((DIR *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF ac_header_dirent=$ac_hdr; break fi done # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. if test $ac_header_dirent = dirent.h; then { echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' dir; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi else { echo "$as_me:$LINENO: checking for library containing opendir" >&5 echo $ECHO_N "checking for library containing opendir... $ECHO_C" >&6; } if test "${ac_cv_search_opendir+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_func_search_save_LIBS=$LIBS cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char opendir (); int main () { return opendir (); ; return 0; } _ACEOF for ac_lib in '' x; do if test -z "$ac_lib"; then ac_res="none required" else ac_res=-l$ac_lib LIBS="-l$ac_lib $ac_func_search_save_LIBS" fi rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_search_opendir=$ac_res else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext if test "${ac_cv_search_opendir+set}" = set; then break fi done if test "${ac_cv_search_opendir+set}" = set; then : else ac_cv_search_opendir=no fi rm conftest.$ac_ext LIBS=$ac_func_search_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_search_opendir" >&5 echo "${ECHO_T}$ac_cv_search_opendir" >&6; } ac_res=$ac_cv_search_opendir if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" fi fi { echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else # Extract the first word of "grep ggrep" to use in msg output if test -z "$GREP"; then set dummy grep ggrep; ac_prog_name=$2 if test "${ac_cv_path_GREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_GREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in *GNU*) ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_GREP_found && break 3 done done done IFS=$as_save_IFS fi GREP="$ac_cv_path_GREP" if test -z "$GREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_GREP=$GREP fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 echo "${ECHO_T}$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" { echo "$as_me:$LINENO: checking for egrep" >&5 echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 then ac_cv_path_EGREP="$GREP -E" else # Extract the first word of "egrep" to use in msg output if test -z "$EGREP"; then set dummy egrep; ac_prog_name=$2 if test "${ac_cv_path_EGREP+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_path_EGREP_found=false # Loop through the user's path and test for each of PROGNAME-LIST as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in *GNU*) ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; *) ac_count=0 echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" while : do cat "conftest.in" "conftest.in" >"conftest.tmp" mv "conftest.tmp" "conftest.in" cp "conftest.in" "conftest.nl" echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break ac_count=`expr $ac_count + 1` if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_max=$ac_count fi # 10*(2^10) chars as input seems more than enough test $ac_count -gt 10 && break done rm -f conftest.in conftest.tmp conftest.nl conftest.out;; esac $ac_path_EGREP_found && break 3 done done done IFS=$as_save_IFS fi EGREP="$ac_cv_path_EGREP" if test -z "$EGREP"; then { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} { (exit 1); exit 1; }; } fi else ac_cv_path_EGREP=$EGREP fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" { echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } if test "${ac_cv_header_stdc+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include #include int main () { ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_stdc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_stdc=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "memchr" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "free" >/dev/null 2>&1; then : else ac_cv_header_stdc=no fi rm -f conftest* fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. if test "$cross_compiling" = yes; then : else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #if ((' ' & 0x0FF) == 0x020) # define ISLOWER(c) ('a' <= (c) && (c) <= 'z') # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) #else # define ISLOWER(c) \ (('a' <= (c) && (c) <= 'i') \ || ('j' <= (c) && (c) <= 'r') \ || ('s' <= (c) && (c) <= 'z')) # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) #endif #define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) int main () { int i; for (i = 0; i < 256; i++) if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) return 2; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then : else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_header_stdc=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi fi { echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 echo "${ECHO_T}$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then cat >>confdefs.h <<\_ACEOF #define STDC_HEADERS 1 _ACEOF fi { echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6; } if test "${ac_cv_header_time+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include #include int main () { if ((struct tm *) 0) return 0; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_header_time=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_header_time=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 echo "${ECHO_T}$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then cat >>confdefs.h <<\_ACEOF #define TIME_WITH_SYS_TIME 1 _ACEOF fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ inttypes.h stdint.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then eval "$as_ac_Header=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_Header=no" fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in errno.h fcntl.h stdlib.h string.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in sys/ioctl.h sys/time.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_header in SDL/SDL_opengl.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } if test "${ac_cv_c_const+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ int main () { /* FIXME: Include the comments suggested by Paul. */ #ifndef __cplusplus /* Ultrix mips cc rejects this. */ typedef int charset[2]; const charset cs; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; /* NEC SVR4.0.2 mips cc rejects this. */ struct point {int x, y;}; static struct point const zero = {0,0}; /* AIX XL C 1.02.0.0 rejects this. It does not let you subtract one const X* pointer from another in an arm of an if-expression whose if-part is not a constant expression */ const char *g = "string"; pcpcc = &g + (g ? g-g : 0); /* HPUX 7.0 cc rejects these. */ ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; { /* SCO 3.2v4 cc rejects this. */ char *t; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; if (s) return 0; } { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ int x[] = {25, 17}; const int *foo = &x[0]; ++foo; } { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ typedef const int *iptr; iptr p = 0; ++p; } { /* AIX XL C 1.02.0.0 rejects this saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ struct s { int j; const int *ap[3]; }; struct s *b; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; if (!foo) return 0; } return !cs[0] && !zero.x; #endif ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_const=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_c_const=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 echo "${ECHO_T}$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then cat >>confdefs.h <<\_ACEOF #define const _ACEOF fi { echo "$as_me:$LINENO: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6; } if test "${ac_cv_c_inline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; static $ac_kw foo_t static_foo () {return 0; } $ac_kw foo_t foo () {return 0; } #endif _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_c_inline=$ac_kw else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi { echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 echo "${ECHO_T}$ac_cv_c_inline" >&6; } case $ac_cv_c_inline in inline | yes) ;; *) case $ac_cv_c_inline in no) ac_val=;; *) ac_val=$ac_cv_c_inline;; esac cat >>confdefs.h <<_ACEOF #ifndef __cplusplus #define inline $ac_val #endif _ACEOF ;; esac { echo "$as_me:$LINENO: checking return type of signal handlers" >&5 echo $ECHO_N "checking return type of signal handlers... $ECHO_C" >&6; } if test "${ac_cv_type_signal+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include #include int main () { return *(signal (0, 0)) (0) == 1; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_cv_type_signal=int else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_type_signal=void fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 echo "${ECHO_T}$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF #define RETSIGTYPE $ac_cv_type_signal _ACEOF for ac_func in strdup strstr strchr strrchr do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in snprintf _snprintf vsnprintf _vsnprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in pow sqrt do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in munmap mkdir select stat do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in atexit floor memmove memset memcmp do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in gettimeofday do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getegid setgid do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for working memcmp" >&5 echo $ECHO_N "checking for working memcmp... $ECHO_C" >&6; } if test "${ac_cv_func_memcmp_working+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_memcmp_working=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { /* Some versions of memcmp are not 8-bit clean. */ char c0 = '\100', c1 = '\200', c2 = '\201'; if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0) return 1; /* The Next x86 OpenStep bug shows up only when comparing 16 bytes or more and with at least one buffer not starting on a 4-byte boundary. William Lewis provided this test program. */ { char foo[21]; char bar[21]; int i; for (i = 0; i < 4; i++) { char *a = foo + i; char *b = bar + i; strcpy (a, "--------01111111"); strcpy (b, "--------10000000"); if (memcmp (a, b, 16) >= 0) return 1; } return 0; } ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_memcmp_working=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_memcmp_working=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_memcmp_working" >&5 echo "${ECHO_T}$ac_cv_func_memcmp_working" >&6; } test $ac_cv_func_memcmp_working = no && case " $LIBOBJS " in *" memcmp.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS memcmp.$ac_objext" ;; esac { echo "$as_me:$LINENO: checking for working strtod" >&5 echo $ECHO_N "checking for working strtod... $ECHO_C" >&6; } if test "${ac_cv_func_strtod+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_strtod=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #ifndef strtod double strtod (); #endif int main() { { /* Some versions of Linux strtod mis-parse strings with leading '+'. */ char *string = " +69"; char *term; double value; value = strtod (string, &term); if (value != 69 || term != (string + 4)) return 1; } { /* Under Solaris 2.4, strtod returns the wrong value for the terminating character under some conditions. */ char *string = "NaN"; char *term; strtod (string, &term); if (term != string && *(term - 1) == 0) return 1; } return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_strtod=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_strtod=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_strtod" >&5 echo "${ECHO_T}$ac_cv_func_strtod" >&6; } if test $ac_cv_func_strtod = no; then case " $LIBOBJS " in *" strtod.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS strtod.$ac_objext" ;; esac { echo "$as_me:$LINENO: checking for pow" >&5 echo $ECHO_N "checking for pow... $ECHO_C" >&6; } if test "${ac_cv_func_pow+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define pow to an innocuous variant, in case declares pow. For example, HP-UX 11i declares gettimeofday. */ #define pow innocuous_pow /* System header to define __stub macros and hopefully few prototypes, which can conflict with char pow (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef pow /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pow (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_pow || defined __stub___pow choke me #endif int main () { return pow (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func_pow=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func_pow=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func_pow" >&5 echo "${ECHO_T}$ac_cv_func_pow" >&6; } if test $ac_cv_func_pow = no; then { echo "$as_me:$LINENO: checking for pow in -lm" >&5 echo $ECHO_N "checking for pow in -lm... $ECHO_C" >&6; } if test "${ac_cv_lib_m_pow+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lm $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char pow (); int main () { return pow (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_m_pow=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_m_pow=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_m_pow" >&5 echo "${ECHO_T}$ac_cv_lib_m_pow" >&6; } if test $ac_cv_lib_m_pow = yes; then POW_LIB=-lm else { echo "$as_me:$LINENO: WARNING: cannot find library containing definition of pow" >&5 echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} fi fi fi for ac_func in vprintf do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF { echo "$as_me:$LINENO: checking for _doprnt" >&5 echo $ECHO_N "checking for _doprnt... $ECHO_C" >&6; } if test "${ac_cv_func__doprnt+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define _doprnt to an innocuous variant, in case declares _doprnt. For example, HP-UX 11i declares gettimeofday. */ #define _doprnt innocuous__doprnt /* System header to define __stub macros and hopefully few prototypes, which can conflict with char _doprnt (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef _doprnt /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char _doprnt (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub__doprnt || defined __stub____doprnt choke me #endif int main () { return _doprnt (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_func__doprnt=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_func__doprnt=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi { echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 echo "${ECHO_T}$ac_cv_func__doprnt" >&6; } if test $ac_cv_func__doprnt = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_DOPRNT 1 _ACEOF fi fi done for ac_header in stdlib.h unistd.h do as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking $ac_header usability" >&5 echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include <$ac_header> _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking $ac_header presence" >&5 echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include <$ac_header> _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for $ac_header" >&5 echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else eval "$as_ac_Header=\$ac_header_preproc" fi ac_res=`eval echo '${'$as_ac_Header'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } fi if test `eval echo '${'$as_ac_Header'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF fi done for ac_func in getpagesize do as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` { echo "$as_me:$LINENO: checking for $ac_func" >&5 echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ #define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ #ifdef __STDC__ # include #else # include #endif #undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ #if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { return $ac_func (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi ac_res=`eval echo '${'$as_ac_var'}'` { echo "$as_me:$LINENO: result: $ac_res" >&5 echo "${ECHO_T}$ac_res" >&6; } if test `eval echo '${'$as_ac_var'}'` = yes; then cat >>confdefs.h <<_ACEOF #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi done { echo "$as_me:$LINENO: checking for working mmap" >&5 echo $ECHO_N "checking for working mmap... $ECHO_C" >&6; } if test "${ac_cv_func_mmap_fixed_mapped+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_mmap_fixed_mapped=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default /* malloc might have been renamed as rpl_malloc. */ #undef malloc /* Thanks to Mike Haertel and Jim Avera for this test. Here is a matrix of mmap possibilities: mmap private not fixed mmap private fixed at somewhere currently unmapped mmap private fixed at somewhere already mapped mmap shared not fixed mmap shared fixed at somewhere currently unmapped mmap shared fixed at somewhere already mapped For private mappings, we should verify that changes cannot be read() back from the file, nor mmap's back from the file at a different address. (There have been systems where private was not correctly implemented like the infamous i386 svr4.0, and systems where the VM page cache was not coherent with the file system buffer cache like early versions of FreeBSD and possibly contemporary NetBSD.) For shared mappings, we should conversely verify that changes get propagated back to all the places they're supposed to be. Grep wants private fixed already mapped. The main things grep needs to know about mmap are: * does it exist and is it safe to write into the mmap'd area * how to use it (BSD variants) */ #include #include #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H char *malloc (); #endif /* This mess was copied from the GNU getpagesize.h. */ #ifndef HAVE_GETPAGESIZE /* Assume that all systems that can run configure have sys/param.h. */ # ifndef HAVE_SYS_PARAM_H # define HAVE_SYS_PARAM_H 1 # endif # ifdef _SC_PAGESIZE # define getpagesize() sysconf(_SC_PAGESIZE) # else /* no _SC_PAGESIZE */ # ifdef HAVE_SYS_PARAM_H # include # ifdef EXEC_PAGESIZE # define getpagesize() EXEC_PAGESIZE # else /* no EXEC_PAGESIZE */ # ifdef NBPG # define getpagesize() NBPG * CLSIZE # ifndef CLSIZE # define CLSIZE 1 # endif /* no CLSIZE */ # else /* no NBPG */ # ifdef NBPC # define getpagesize() NBPC # else /* no NBPC */ # ifdef PAGESIZE # define getpagesize() PAGESIZE # endif /* PAGESIZE */ # endif /* no NBPC */ # endif /* no NBPG */ # endif /* no EXEC_PAGESIZE */ # else /* no HAVE_SYS_PARAM_H */ # define getpagesize() 8192 /* punt totally */ # endif /* no HAVE_SYS_PARAM_H */ # endif /* no _SC_PAGESIZE */ #endif /* no HAVE_GETPAGESIZE */ int main () { char *data, *data2, *data3; int i, pagesize; int fd; pagesize = getpagesize (); /* First, make a file with some known garbage in it. */ data = (char *) malloc (pagesize); if (!data) return 1; for (i = 0; i < pagesize; ++i) *(data + i) = rand (); umask (0); fd = creat ("conftest.mmap", 0600); if (fd < 0) return 1; if (write (fd, data, pagesize) != pagesize) return 1; close (fd); /* Next, try to mmap the file at a fixed address which already has something else allocated at it. If we can, also make sure that we see the same garbage. */ fd = open ("conftest.mmap", O_RDWR); if (fd < 0) return 1; data2 = (char *) malloc (2 * pagesize); if (!data2) return 1; data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1); if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, 0L)) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data2 + i)) return 1; /* Finally, make sure that changes to the mapped area do not percolate back to the file as seen by read(). (This is a bug on some variants of i386 svr4.0.) */ for (i = 0; i < pagesize; ++i) *(data2 + i) = *(data2 + i) + 1; data3 = (char *) malloc (pagesize); if (!data3) return 1; if (read (fd, data3, pagesize) != pagesize) return 1; for (i = 0; i < pagesize; ++i) if (*(data + i) != *(data3 + i)) return 1; close (fd); return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_mmap_fixed_mapped=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_mmap_fixed_mapped=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_mmap_fixed_mapped" >&5 echo "${ECHO_T}$ac_cv_func_mmap_fixed_mapped" >&6; } if test $ac_cv_func_mmap_fixed_mapped = yes; then cat >>confdefs.h <<\_ACEOF #define HAVE_MMAP 1 _ACEOF fi rm -f conftest.mmap { echo "$as_me:$LINENO: checking whether lstat dereferences a symlink specified with a trailing slash" >&5 echo $ECHO_N "checking whether lstat dereferences a symlink specified with a trailing slash... $ECHO_C" >&6; } if test "${ac_cv_func_lstat_dereferences_slashed_symlink+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else rm -f conftest.sym conftest.file echo >conftest.file if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then if test "$cross_compiling" = yes; then ac_cv_func_lstat_dereferences_slashed_symlink=no else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { struct stat sbuf; /* Linux will dereference the symlink and fail. That is better in the sense that it means we will not have to compile and use the lstat wrapper. */ return lstat ("conftest.sym/", &sbuf) == 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_lstat_dereferences_slashed_symlink=yes else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi else # If the `ln -s' command failed, then we probably don't even # have an lstat function. ac_cv_func_lstat_dereferences_slashed_symlink=no fi rm -f conftest.sym conftest.file fi { echo "$as_me:$LINENO: result: $ac_cv_func_lstat_dereferences_slashed_symlink" >&5 echo "${ECHO_T}$ac_cv_func_lstat_dereferences_slashed_symlink" >&6; } test $ac_cv_func_lstat_dereferences_slashed_symlink = yes && cat >>confdefs.h <<_ACEOF #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 _ACEOF if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then case " $LIBOBJS " in *" lstat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS lstat.$ac_objext" ;; esac fi { echo "$as_me:$LINENO: checking whether stat accepts an empty string" >&5 echo $ECHO_N "checking whether stat accepts an empty string... $ECHO_C" >&6; } if test "${ac_cv_func_stat_empty_string_bug+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else if test "$cross_compiling" = yes; then ac_cv_func_stat_empty_string_bug=yes else cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default int main () { struct stat sbuf; return stat ("", &sbuf) == 0; ; return 0; } _ACEOF rm -f conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { ac_try='./conftest$ac_exeext' { (case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_try") 2>&5 ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); }; }; then ac_cv_func_stat_empty_string_bug=no else echo "$as_me: program exited with status $ac_status" >&5 echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ( exit $ac_status ) ac_cv_func_stat_empty_string_bug=yes fi rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext fi fi { echo "$as_me:$LINENO: result: $ac_cv_func_stat_empty_string_bug" >&5 echo "${ECHO_T}$ac_cv_func_stat_empty_string_bug" >&6; } if test $ac_cv_func_stat_empty_string_bug = yes; then case " $LIBOBJS " in *" stat.$ac_objext "* ) ;; *) LIBOBJS="$LIBOBJS stat.$ac_objext" ;; esac cat >>confdefs.h <<_ACEOF #define HAVE_STAT_EMPTY_STRING_BUG 1 _ACEOF fi if test $ac_cv_c_compiler_gnu = yes; then { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } if test "${ac_cv_prog_gcc_traditional+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_pattern="Autoconf.*'x'" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TIOCGETP _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes else ac_cv_prog_gcc_traditional=no fi rm -f conftest* if test $ac_cv_prog_gcc_traditional = no; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include Autoconf TCGETA _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | $EGREP "$ac_pattern" >/dev/null 2>&1; then ac_cv_prog_gcc_traditional=yes fi rm -f conftest* fi fi { echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } if test $ac_cv_prog_gcc_traditional = yes; then CC="$CC -traditional" fi fi { echo "$as_me:$LINENO: checking for OSS audio support" >&5 echo $ECHO_N "checking for OSS audio support... $ECHO_C" >&6; } if test x$enable_oss = xyes; then have_oss=no if test x$have_oss != xyes; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { int arg = SNDCTL_DSP_SETFRAGMENT; ++arg; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then have_oss=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test x$have_oss != xyes; then cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include int main () { int arg = SNDCTL_DSP_SETFRAGMENT; ; return 0; } _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then have_oss=yes CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H" CXXFLAGS="$CXXFLAGS -DOSS_USE_SOUNDCARD_H" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi fi # Check whether --enable-oss was given. if test "${enable_oss+set}" = set; then enableval=$enable_oss; else enable_oss=no fi if test x$enable_oss = xyes; then { echo "$as_me:$LINENO: result: $have_oss" >&5 echo "${ECHO_T}$have_oss" >&6; } else have_oss=no { echo "$as_me:$LINENO: result: Disabled" >&5 echo "${ECHO_T}Disabled" >&6; } fi if test x$have_oss = xyes; then CFLAGS="$CFLAGS -DHAVE_OSS" CXXFLAGS="$CXXFLAGS -DHAVE_OSS" fi if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then { echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5 echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; } if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 fi { echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; } else # Is the header compilable? { echo "$as_me:$LINENO: checking sys/asoundlib.h usability" >&5 echo $ECHO_N "checking sys/asoundlib.h usability... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ $ac_includes_default #include _ACEOF rm -f conftest.$ac_objext if { (ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then ac_header_compiler=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_compiler=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 echo "${ECHO_T}$ac_header_compiler" >&6; } # Is the header present? { echo "$as_me:$LINENO: checking sys/asoundlib.h presence" >&5 echo $ECHO_N "checking sys/asoundlib.h presence... $ECHO_C" >&6; } cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ #include _ACEOF if { (ac_try="$ac_cpp conftest.$ac_ext" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } >/dev/null && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then ac_header_preproc=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_header_preproc=no fi rm -f conftest.err conftest.$ac_ext { echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 echo "${ECHO_T}$ac_header_preproc" >&6; } # So? What about this header? case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in yes:no: ) { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&5 echo "$as_me: WARNING: sys/asoundlib.h: accepted by the compiler, rejected by the preprocessor!" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&5 echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the compiler's result" >&2;} ac_header_preproc=yes ;; no:yes:* ) { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: present but cannot be compiled" >&5 echo "$as_me: WARNING: sys/asoundlib.h: present but cannot be compiled" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&5 echo "$as_me: WARNING: sys/asoundlib.h: check for missing prerequisite headers?" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&5 echo "$as_me: WARNING: sys/asoundlib.h: see the Autoconf documentation" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&5 echo "$as_me: WARNING: sys/asoundlib.h: section \"Present But Cannot Be Compiled\"" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&5 echo "$as_me: WARNING: sys/asoundlib.h: proceeding with the preprocessor's result" >&2;} { echo "$as_me:$LINENO: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&5 echo "$as_me: WARNING: sys/asoundlib.h: in the future, the compiler will take precedence" >&2;} ;; esac { echo "$as_me:$LINENO: checking for sys/asoundlib.h" >&5 echo $ECHO_N "checking for sys/asoundlib.h... $ECHO_C" >&6; } if test "${ac_cv_header_sys_asoundlib_h+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_cv_header_sys_asoundlib_h=$ac_header_preproc fi { echo "$as_me:$LINENO: result: $ac_cv_header_sys_asoundlib_h" >&5 echo "${ECHO_T}$ac_cv_header_sys_asoundlib_h" >&6; } fi if test $ac_cv_header_sys_asoundlib_h = yes; then have_alsa_hdr=yes fi { echo "$as_me:$LINENO: checking for snd_pcm_open in -lasound" >&5 echo $ECHO_N "checking for snd_pcm_open in -lasound... $ECHO_C" >&6; } if test "${ac_cv_lib_asound_snd_pcm_open+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 else ac_check_lib_save_LIBS=$LIBS LIBS="-lasound $LIBS" cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC builtin and then its argument prototype would still apply. */ #ifdef __cplusplus extern "C" #endif char snd_pcm_open (); int main () { return snd_pcm_open (); ; return 0; } _ACEOF rm -f conftest.$ac_objext conftest$ac_exeext if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 (eval "$ac_link") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 echo "$as_me:$LINENO: \$? = $ac_status" >&5 (exit $ac_status); } && { test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then ac_cv_lib_asound_snd_pcm_open=yes else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 ac_cv_lib_asound_snd_pcm_open=no fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext LIBS=$ac_check_lib_save_LIBS fi { echo "$as_me:$LINENO: result: $ac_cv_lib_asound_snd_pcm_open" >&5 echo "${ECHO_T}$ac_cv_lib_asound_snd_pcm_open" >&6; } if test $ac_cv_lib_asound_snd_pcm_open = yes; then have_alsa_lib=yes fi { echo "$as_me:$LINENO: checking for ALSA audio support" >&5 echo $ECHO_N "checking for ALSA audio support... $ECHO_C" >&6; } have_alsa=no if test x$have_alsa_hdr = xyes -a x$have_alsa_lib = xyes; then have_alsa=yes fi # Check whether --enable-alsa was given. if test "${enable_alsa+set}" = set; then enableval=$enable_alsa; else enable_alsa=no fi if test x$enable_alsa = xyes; then { echo "$as_me:$LINENO: result: $have_alsa" >&5 echo "${ECHO_T}$have_alsa" >&6; } else have_alsa=no { echo "$as_me:$LINENO: result: Disabled" >&5 echo "${ECHO_T}Disabled" >&6; } fi if test x$have_alsa = xyes; then CFLAGS="$CFLAGS -DHAVE_ALSA" CXXFLAGS="$CXXFLAGS -DHAVE_ALSA" AUDIO_LIBS="-lasound" else AUDIO_LIBS="" fi # Check whether --enable-epm was given. if test "${enable_epm+set}" = set; then enableval=$enable_epm; else enable_epm=no fi { echo "$as_me:$LINENO: checking for Extreme Pickyness Mode" >&5 echo $ECHO_N "checking for Extreme Pickyness Mode... $ECHO_C" >&6; } if test x$enable_epm = xyes; then LOCALCFLAGS="$LOCALCFLAGS -Wall -Werror -Wwrite-strings -fno-builtin" fi { echo "$as_me:$LINENO: result: $enable_epm" >&5 echo "${ECHO_T}$enable_epm" >&6; } # Check whether --enable-efence was given. if test "${enable_efence+set}" = set; then enableval=$enable_efence; else enable_efence=no fi { echo "$as_me:$LINENO: checking if we should use ElectricFence" >&5 echo $ECHO_N "checking if we should use ElectricFence... $ECHO_C" >&6; } if test x$enable_efence = xyes; then LIBS="$LIBS -lefence" fi { echo "$as_me:$LINENO: result: $enable_efence" >&5 echo "${ECHO_T}$enable_efence" >&6; } ac_config_files="$ac_config_files Makefile Info.plist graphics/Makefile sound/Makefile data/Makefile data/sfx/Makefile data/gfx/Makefile eel/Makefile" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure # tests run on this system so they can be shared between configure # scripts and configure runs, see configure's option --config-cache. # It is not useful on other systems. If it contains results you don't # want to keep, you may remove or edit it. # # config.status only pays attention to the cache file if you give it # the --recheck option to rerun configure. # # `ac_cv_env_foo' variables (set or unset) will be overridden when # loading this file, other *unset* `ac_cv_foo' will be assigned the # following values. _ACEOF # The following way of writing the cache mishandles newlines in values, # but we know of no workaround that is simple, portable, and efficient. # So, we kill variables containing newlines. # Ultrix sh set writes to stderr and can't be redirected directly, # and sets the high bit in the cache file unless we assign to the vars. ( for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do eval ac_val=\$$ac_var case $ac_val in #( *${as_nl}*) case $ac_var in #( *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( *) $as_unset $ac_var ;; esac ;; esac done (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) # `set' does not quote correctly, so add quotes (double-quote # substitution turns \\\\ into \\, and sed turns \\ into \). sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" ;; #( *) # `set' quotes correctly as required by POSIX, so do not add quotes. sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" ;; esac | sort ) | sed ' /^ac_cv_env_/b end t clear :clear s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ t end s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then test "x$cache_file" != "x/dev/null" && { echo "$as_me:$LINENO: updating cache $cache_file" >&5 echo "$as_me: updating cache $cache_file" >&6;} cat confcache >$cache_file else { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi rm -f confcache test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs LTLIBOBJS=$ac_ltlibobjs if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${BUILD_MACOSX_BUNDLE_TRUE}" && test -z "${BUILD_MACOSX_BUNDLE_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"BUILD_MACOSX_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"BUILD_MACOSX_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${BUILD_SIMPLE_BUNDLE_TRUE}" && test -z "${BUILD_SIMPLE_BUNDLE_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"BUILD_SIMPLE_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"BUILD_SIMPLE_BUNDLE\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${UNIX_SCOREDIR_TRUE}" && test -z "${UNIX_SCOREDIR_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"UNIX_SCOREDIR\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"UNIX_SCOREDIR\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then { { echo "$as_me:$LINENO: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&5 echo "$as_me: error: conditional \"am__fastdepCXX\" was never defined. Usually this means the macro was only invoked conditionally." >&2;} { (exit 1); exit 1; }; } fi : ${CONFIG_STATUS=./config.status} ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" { echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 echo "$as_me: creating $CONFIG_STATUS" >&6;} cat >$CONFIG_STATUS <<_ACEOF #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. # Compiler output produced by configure, useful for debugging # configure, is in config.log if it exists. debug=false ac_cs_recheck=false ac_cs_silent=false SHELL=\${CONFIG_SHELL-$SHELL} _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ## --------------------- ## ## M4sh Initialization. ## ## --------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then emulate sh NULLCMD=: # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which # is contrary to our usage. Disable this feature. alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac fi # PATH needs CR # Avoid depending upon Character Ranges. as_cr_letters='abcdefghijklmnopqrstuvwxyz' as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' as_cr_Letters=$as_cr_letters$as_cr_LETTERS as_cr_digits='0123456789' as_cr_alnum=$as_cr_Letters$as_cr_digits # The user is always right. if test "${PATH_SEPARATOR+set}" != set; then echo "#! /bin/sh" >conf$$.sh echo "exit 0" >>conf$$.sh chmod +x conf$$.sh if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then PATH_SEPARATOR=';' else PATH_SEPARATOR=: fi rm -f conf$$.sh fi # Support unset when possible. if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then as_unset=unset else as_unset=false fi # IFS # We need space, tab and new line, in precisely that order. Quoting is # there to prevent editors from complaining about space-tab. # (If _AS_PATH_WALK were called with IFS unset, it would disable word # splitting by setting IFS to empty value.) as_nl=' ' IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. case $0 in *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break done IFS=$as_save_IFS ;; esac # We did not find ourselves, most probably we were run as `sh COMMAND' # in which case we are not to be found in the path. if test "x$as_myself" = x; then as_myself=$0 fi if test ! -f "$as_myself"; then echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 { (exit 1); exit 1; } fi # Work around bugs in pre-3.0 UWIN ksh. for as_var in ENV MAIL MAILPATH do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var done PS1='$ ' PS2='> ' PS4='+ ' # NLS nuisances. for as_var in \ LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ LC_TELEPHONE LC_TIME do if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then eval $as_var=C; export $as_var else ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var fi done # Required to use basename. if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then as_basename=basename else as_basename=false fi # Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ X"$0" : 'X\(/\)' \| . 2>/dev/null || echo X/"$0" | sed '/^.*\/\([^/][^/]*\)\/*$/{ s//\1/ q } /^X\/\(\/\/\)$/{ s//\1/ q } /^X\/\(\/\).*/{ s//\1/ q } s/.*/./; q'` # CDPATH. $as_unset CDPATH as_lineno_1=$LINENO as_lineno_2=$LINENO test "x$as_lineno_1" != "x$as_lineno_2" && test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { # Create $as_me.lineno as a copy of $as_myself, but with $LINENO # uniformly replaced by the line number. The first 'sed' inserts a # line-number line after each line using $LINENO; the second 'sed' # does the real work. The second script uses 'N' to pair each # line-number line with the line containing $LINENO, and appends # trailing '-' during substitution so that $LINENO is not a special # case at line end. # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the # scripts with optimization help from Paolo Bonzini. Blame Lee # E. McMahon (1931-1989) for sed's syntax. :-) sed -n ' p /[$]LINENO/= ' <$as_myself | sed ' s/[$]LINENO.*/&-/ t lineno b :lineno N :loop s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ t loop s/-\n.*// ' >$as_me.lineno && chmod +x "$as_me.lineno" || { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 { (exit 1); exit 1; }; } # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). . "./$as_me.lineno" # Exit status is that of the last command. exit } if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then as_dirname=dirname else as_dirname=false fi ECHO_C= ECHO_N= ECHO_T= case `echo -n x` in -n*) case `echo 'x\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. *) ECHO_C='\c';; esac;; *) ECHO_N='-n';; esac if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr else as_expr=false fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then rm -f conf$$.dir/conf$$.file else rm -f conf$$.dir mkdir conf$$.dir fi echo >conf$$.file if ln -s conf$$.file conf$$ 2>/dev/null; then as_ln_s='ln -s' # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. # In both cases, we have to default to `cp -p'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || as_ln_s='cp -p' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else as_ln_s='cp -p' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null if mkdir -p . 2>/dev/null; then as_mkdir_p=: else test -d ./-p && rmdir ./-p as_mkdir_p=false fi if test -x / >/dev/null 2>&1; then as_test_x='test -x' else if ls -dL / >/dev/null 2>&1; then as_ls_L_option=L else as_ls_L_option= fi as_test_x=' eval sh -c '\'' if test -d "$1"; then test -d "$1/."; else case $1 in -*)set "./$1";; esac; case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in ???[sx]*):;;*)false;;esac;fi '\'' sh ' fi as_executable_p=$as_test_x # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" # Sed expression to map a string onto a valid variable name. as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 # Save the log message, to keep $[0] and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by $as_me, which was generated by GNU Autoconf 2.61. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS CONFIG_LINKS = $CONFIG_LINKS CONFIG_COMMANDS = $CONFIG_COMMANDS $ $0 $@ on `(hostname || uname -n) 2>/dev/null | sed 1q` " _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # Files that config.status was made for. config_files="$ac_config_files" config_headers="$ac_config_headers" config_commands="$ac_config_commands" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF ac_cs_usage="\ \`$as_me' instantiates files from templates according to the current configuration. Usage: $0 [OPTIONS] [FILE]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit -q, --quiet do not print progress messages -d, --debug don't remove temporary files --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE --header=FILE[:TEMPLATE] instantiate the configuration header FILE Configuration files: $config_files Configuration headers: $config_headers Configuration commands: $config_commands Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ config.status configured by $0, generated by GNU Autoconf 2.61, with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" Copyright (C) 2006 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." ac_pwd='$ac_pwd' srcdir='$srcdir' INSTALL='$INSTALL' _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If no file are specified by the user, then we need to provide default # value. By we need to know if files were specified by the user. ac_need_defaults=: while test $# != 0 do case $1 in --*=*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; *) ac_option=$1 ac_optarg=$2 ac_shift=shift ;; esac case $ac_option in # Handling of the options. -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) echo "$ac_cs_version"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift CONFIG_FILES="$CONFIG_FILES $ac_optarg" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header { echo "$as_me: error: ambiguous option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; };; --help | --hel | -h ) echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) ac_cs_silent=: ;; # This is an error. -*) { echo "$as_me: error: unrecognized option: $1 Try \`$0 --help' for more information." >&2 { (exit 1); exit 1; }; } ;; *) ac_config_targets="$ac_config_targets $1" ac_need_defaults=false ;; esac shift done ac_configure_extra_args= if $ac_cs_silent; then exec 6>/dev/null ac_configure_extra_args="$ac_configure_extra_args --silent" fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF if \$ac_cs_recheck; then echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 CONFIG_SHELL=$SHELL export CONFIG_SHELL exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion fi _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF exec 5>>config.log { echo sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX ## Running $as_me. ## _ASBOX echo "$ac_log" } >&5 _ACEOF cat >>$CONFIG_STATUS <<_ACEOF # # INIT-COMMANDS # AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir" _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # Handling of arguments. for ac_config_target in $ac_config_targets do case $ac_config_target in "aconfig.h") CONFIG_HEADERS="$CONFIG_HEADERS aconfig.h" ;; "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "Info.plist") CONFIG_FILES="$CONFIG_FILES Info.plist" ;; "graphics/Makefile") CONFIG_FILES="$CONFIG_FILES graphics/Makefile" ;; "sound/Makefile") CONFIG_FILES="$CONFIG_FILES sound/Makefile" ;; "data/Makefile") CONFIG_FILES="$CONFIG_FILES data/Makefile" ;; "data/sfx/Makefile") CONFIG_FILES="$CONFIG_FILES data/sfx/Makefile" ;; "data/gfx/Makefile") CONFIG_FILES="$CONFIG_FILES data/gfx/Makefile" ;; "eel/Makefile") CONFIG_FILES="$CONFIG_FILES eel/Makefile" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; esac done # If the user did not use the arguments to specify the items to instantiate, # then the envvar interface is used. Set only those that are not. # We use the long form for the default assignment because of an extremely # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands fi # Have a temporary directory for convenience. Make it in the build tree # simply because there is no reason against having it here, and in addition, # creating and moving files from /tmp can sometimes cause problems. # Hook for its removal unless debugging. # Note that there is a small window in which the directory will not be cleaned: # after its creation but before its name has been assigned to `$tmp'. $debug || { tmp= trap 'exit_status=$? { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status ' 0 trap '{ (exit 1); exit 1; }' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") } || { echo "$me: cannot create a temporary directory in ." >&2 { (exit 1); exit 1; } } # # Set up the sed scripts for CONFIG_FILES section. # # No need to generate the scripts if there are no CONFIG_FILES. # This happens for instance when ./config.status config.h if test -n "$CONFIG_FILES"; then _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF SHELL!$SHELL$ac_delim PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim PACKAGE_NAME!$PACKAGE_NAME$ac_delim PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim PACKAGE_STRING!$PACKAGE_STRING$ac_delim PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim exec_prefix!$exec_prefix$ac_delim prefix!$prefix$ac_delim program_transform_name!$program_transform_name$ac_delim bindir!$bindir$ac_delim sbindir!$sbindir$ac_delim libexecdir!$libexecdir$ac_delim datarootdir!$datarootdir$ac_delim datadir!$datadir$ac_delim sysconfdir!$sysconfdir$ac_delim sharedstatedir!$sharedstatedir$ac_delim localstatedir!$localstatedir$ac_delim includedir!$includedir$ac_delim oldincludedir!$oldincludedir$ac_delim docdir!$docdir$ac_delim infodir!$infodir$ac_delim htmldir!$htmldir$ac_delim dvidir!$dvidir$ac_delim pdfdir!$pdfdir$ac_delim psdir!$psdir$ac_delim libdir!$libdir$ac_delim localedir!$localedir$ac_delim mandir!$mandir$ac_delim DEFS!$DEFS$ac_delim ECHO_C!$ECHO_C$ac_delim ECHO_N!$ECHO_N$ac_delim ECHO_T!$ECHO_T$ac_delim LIBS!$LIBS$ac_delim build_alias!$build_alias$ac_delim host_alias!$host_alias$ac_delim target_alias!$target_alias$ac_delim build!$build$ac_delim build_cpu!$build_cpu$ac_delim build_vendor!$build_vendor$ac_delim build_os!$build_os$ac_delim host!$host$ac_delim host_cpu!$host_cpu$ac_delim host_vendor!$host_vendor$ac_delim host_os!$host_os$ac_delim target!$target$ac_delim target_cpu!$target_cpu$ac_delim target_vendor!$target_vendor$ac_delim target_os!$target_os$ac_delim INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim INSTALL_DATA!$INSTALL_DATA$ac_delim CYGPATH_W!$CYGPATH_W$ac_delim PACKAGE!$PACKAGE$ac_delim VERSION!$VERSION$ac_delim ACLOCAL!$ACLOCAL$ac_delim AUTOCONF!$AUTOCONF$ac_delim AUTOMAKE!$AUTOMAKE$ac_delim AUTOHEADER!$AUTOHEADER$ac_delim MAKEINFO!$MAKEINFO$ac_delim install_sh!$install_sh$ac_delim STRIP!$STRIP$ac_delim INSTALL_STRIP_PROGRAM!$INSTALL_STRIP_PROGRAM$ac_delim mkdir_p!$mkdir_p$ac_delim AWK!$AWK$ac_delim SET_MAKE!$SET_MAKE$ac_delim am__leading_dot!$am__leading_dot$ac_delim AMTAR!$AMTAR$ac_delim am__tar!$am__tar$ac_delim am__untar!$am__untar$ac_delim XMKMF!$XMKMF$ac_delim CC!$CC$ac_delim CFLAGS!$CFLAGS$ac_delim LDFLAGS!$LDFLAGS$ac_delim CPPFLAGS!$CPPFLAGS$ac_delim ac_ct_CC!$ac_ct_CC$ac_delim EXEEXT!$EXEEXT$ac_delim OBJEXT!$OBJEXT$ac_delim DEPDIR!$DEPDIR$ac_delim am__include!$am__include$ac_delim am__quote!$am__quote$ac_delim AMDEP_TRUE!$AMDEP_TRUE$ac_delim AMDEP_FALSE!$AMDEP_FALSE$ac_delim AMDEPBACKSLASH!$AMDEPBACKSLASH$ac_delim CCDEPMODE!$CCDEPMODE$ac_delim am__fastdepCC_TRUE!$am__fastdepCC_TRUE$ac_delim am__fastdepCC_FALSE!$am__fastdepCC_FALSE$ac_delim CPP!$CPP$ac_delim X_CFLAGS!$X_CFLAGS$ac_delim X_PRE_LIBS!$X_PRE_LIBS$ac_delim X_LIBS!$X_LIBS$ac_delim X_EXTRA_LIBS!$X_EXTRA_LIBS$ac_delim BUILD_MACOSX_BUNDLE_TRUE!$BUILD_MACOSX_BUNDLE_TRUE$ac_delim BUILD_MACOSX_BUNDLE_FALSE!$BUILD_MACOSX_BUNDLE_FALSE$ac_delim BUILD_SIMPLE_BUNDLE_TRUE!$BUILD_SIMPLE_BUNDLE_TRUE$ac_delim BUILD_SIMPLE_BUNDLE_FALSE!$BUILD_SIMPLE_BUNDLE_FALSE$ac_delim UNIX_SCOREDIR_TRUE!$UNIX_SCOREDIR_TRUE$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF CEOF$ac_eof _ACEOF ac_delim='%!_!# ' for ac_last_try in false false false false false :; do cat >conf$$subs.sed <<_ACEOF UNIX_SCOREDIR_FALSE!$UNIX_SCOREDIR_FALSE$ac_delim DATADIR!$DATADIR$ac_delim SCOREDIR!$SCOREDIR$ac_delim CONFIGDIR!$CONFIGDIR$ac_delim CONFIGFILE!$CONFIGFILE$ac_delim EXEFILE!$EXEFILE$ac_delim MATHLIB!$MATHLIB$ac_delim CXX!$CXX$ac_delim CXXFLAGS!$CXXFLAGS$ac_delim ac_ct_CXX!$ac_ct_CXX$ac_delim CXXDEPMODE!$CXXDEPMODE$ac_delim am__fastdepCXX_TRUE!$am__fastdepCXX_TRUE$ac_delim am__fastdepCXX_FALSE!$am__fastdepCXX_FALSE$ac_delim RANLIB!$RANLIB$ac_delim SDL_CONFIG!$SDL_CONFIG$ac_delim SDL_CFLAGS!$SDL_CFLAGS$ac_delim SDL_LIBS!$SDL_LIBS$ac_delim GREP!$GREP$ac_delim EGREP!$EGREP$ac_delim LIBOBJS!$LIBOBJS$ac_delim POW_LIB!$POW_LIB$ac_delim AUDIO_LIBS!$AUDIO_LIBS$ac_delim LOCALCFLAGS!$LOCALCFLAGS$ac_delim LTLIBOBJS!$LTLIBOBJS$ac_delim _ACEOF if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 24; then break elif $ac_last_try; then { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} { (exit 1); exit 1; }; } else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi done ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed` if test -n "$ac_eof"; then ac_eof=`echo "$ac_eof" | sort -nru | sed 1q` ac_eof=`expr $ac_eof + 1` fi cat >>$CONFIG_STATUS <<_ACEOF cat >"\$tmp/subs-2.sed" <<\CEOF$ac_eof /@[a-zA-Z_][a-zA-Z_0-9]*@/!b end _ACEOF sed ' s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g s/^/s,@/; s/!/@,|#_!!_#|/ :n t n s/'"$ac_delim"'$/,g/; t s/$/\\/; p N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n ' >>$CONFIG_STATUS >$CONFIG_STATUS <<_ACEOF :end s/|#_!!_#|//g CEOF$ac_eof _ACEOF # VPATH may cause trouble with some makes, so we remove $(srcdir), # ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then ac_vpsub='/^[ ]*VPATH[ ]*=/{ s/:*\$(srcdir):*/:/ s/:*\${srcdir}:*/:/ s/:*@srcdir@:*/:/ s/^\([^=]*=[ ]*\):*/\1/ s/:*$// s/^[^=]*=[ ]*$// }' fi cat >>$CONFIG_STATUS <<\_ACEOF fi # test -n "$CONFIG_FILES" for ac_tag in :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS do case $ac_tag in :[FHLC]) ac_mode=$ac_tag; continue;; esac case $ac_mode$ac_tag in :[FHL]*:*);; :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 echo "$as_me: error: Invalid tag $ac_tag." >&2;} { (exit 1); exit 1; }; };; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac ac_save_IFS=$IFS IFS=: set x $ac_tag IFS=$ac_save_IFS shift ac_file=$1 shift case $ac_mode in :L) ac_source=$1;; :[FH]) ac_file_inputs= for ac_f do case $ac_f in -) ac_f="$tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. test -f "$ac_f" || case $ac_f in [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 echo "$as_me: error: cannot find input file: $ac_f" >&2;} { (exit 1); exit 1; }; };; esac ac_file_inputs="$ac_file_inputs $ac_f" done # Let's still pretend it is `configure' which instantiates (i.e., don't # use $as_me), people would be surprised to read: # /* config.h. Generated by config.status. */ configure_input="Generated from "`IFS=: echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" { echo "$as_me:$LINENO: creating $ac_file" >&5 echo "$as_me: creating $ac_file" >&6;} fi case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin";; esac ;; esac ac_dir=`$as_dirname -- "$ac_file" || $as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$ac_file" : 'X\(//\)[^/]' \| \ X"$ac_file" : 'X\(//\)$' \| \ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || echo X"$ac_file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir="$ac_dir" case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } ac_builddir=. case "$ac_dir" in .) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` # A ".." for each directory in $ac_dir_suffix. ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` case $ac_top_builddir_sub in "") ac_top_builddir_sub=. ac_top_build_prefix= ;; *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; esac ;; esac ac_abs_top_builddir=$ac_pwd ac_abs_builddir=$ac_pwd$ac_dir_suffix # for backward compatibility: ac_top_builddir=$ac_top_build_prefix case $srcdir in .) # We are building in place. ac_srcdir=. ac_top_srcdir=$ac_top_builddir_sub ac_abs_top_srcdir=$ac_pwd ;; [\\/]* | ?:[\\/]* ) # Absolute name. ac_srcdir=$srcdir$ac_dir_suffix; ac_top_srcdir=$srcdir ac_abs_top_srcdir=$srcdir ;; *) # Relative name. ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix ac_top_srcdir=$ac_top_build_prefix$srcdir ac_abs_top_srcdir=$ac_pwd/$srcdir ;; esac ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix case $ac_mode in :F) # # CONFIG_FILE # case $INSTALL in [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; esac _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= case `sed -n '/datarootdir/ { p q } /@datadir@/p /@docdir@/p /@infodir@/p /@localedir@/p /@mandir@/p ' $ac_file_inputs` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_datarootdir_hack=' s&@datadir@&$datadir&g s&@docdir@&$docdir&g s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF # Neutralize VPATH when `$srcdir' = `.'. # Shell code in configure.ac might set extrasub. # FIXME: do we really want to maintain this feature? cat >>$CONFIG_STATUS <<_ACEOF sed "$ac_vpsub $extrasub _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t /@[a-zA-Z_][a-zA-Z_0-9]*@/!b s&@configure_input@&$configure_input&;t t s&@top_builddir@&$ac_top_builddir_sub&;t t s&@srcdir@&$ac_srcdir&;t t s&@abs_srcdir@&$ac_abs_srcdir&;t t s&@top_srcdir@&$ac_top_srcdir&;t t s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t s&@builddir@&$ac_builddir&;t t s&@abs_builddir@&$ac_abs_builddir&;t t s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" >$tmp/out test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&5 echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' which seems to be undefined. Please make sure it is defined." >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out"; rm -f "$tmp/out";; *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;; esac ;; :H) # # CONFIG_HEADER # _ACEOF # Transform confdefs.h into a sed script `conftest.defines', that # substitutes the proper values into config.h.in to produce config.h. rm -f conftest.defines conftest.tail # First, append a space to every undef/define line, to ease matching. echo 's/$/ /' >conftest.defines # Then, protect against being on the right side of a sed subst, or in # an unquoted here document, in config.status. If some macros were # called several times there might be several #defines for the same # symbol, which is useless. But do not sort them, since the last # AC_DEFINE must be honored. ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* # These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where # NAME is the cpp macro being defined, VALUE is the value it is being given. # PARAMS is the parameter list in the macro definition--in most cases, it's # just an empty string. ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' ac_dB='\\)[ (].*,\\1define\\2' ac_dC=' ' ac_dD=' ,' uniq confdefs.h | sed -n ' t rset :rset s/^[ ]*#[ ]*define[ ][ ]*// t ok d :ok s/[\\&,]/\\&/g s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p ' >>conftest.defines # Remove the space that was appended to ease matching. # Then replace #undef with comments. This is necessary, for # example, in the case of _POSIX_SOURCE, which is predefined and required # on some systems where configure will not decide to define it. # (The regexp can be short, since the line contains either #define or #undef.) echo 's/ $// s,^[ #]*u.*,/* & */,' >>conftest.defines # Break up conftest.defines: ac_max_sed_lines=50 # First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" # Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" # Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" # et cetera. ac_in='$ac_file_inputs' ac_out='"$tmp/out1"' ac_nxt='"$tmp/out2"' while : do # Write a here document: cat >>$CONFIG_STATUS <<_ACEOF # First, check the format of the line: cat >"\$tmp/defines.sed" <<\\CEOF /^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def /^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def b :def _ACEOF sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS echo 'CEOF sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail grep . conftest.tail >/dev/null || break rm -f conftest.defines mv conftest.tail conftest.defines done rm -f conftest.defines conftest.tail echo "ac_result=$ac_in" >>$CONFIG_STATUS cat >>$CONFIG_STATUS <<\_ACEOF if test x"$ac_file" != x-; then echo "/* $configure_input */" >"$tmp/config.h" cat "$ac_result" >>"$tmp/config.h" if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 echo "$as_me: $ac_file is unchanged" >&6;} else rm -f $ac_file mv "$tmp/config.h" $ac_file fi else echo "/* $configure_input */" cat "$ac_result" fi rm -f "$tmp/out12" # Compute $ac_file's index in $config_headers. _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $ac_file | $ac_file:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || $as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X$ac_file : 'X\(//\)[^/]' \| \ X$ac_file : 'X\(//\)$' \| \ X$ac_file : 'X\(/\)' \| . 2>/dev/null || echo X$ac_file | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'`/stamp-h$_am_stamp_count ;; :C) { echo "$as_me:$LINENO: executing $ac_file commands" >&5 echo "$as_me: executing $ac_file commands" >&6;} ;; esac case $ac_file$ac_mode in "depfiles":C) test x"$AMDEP_TRUE" != x"" || for mf in $CONFIG_FILES; do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named `Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # So let's grep whole file. if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then dirpart=`$as_dirname -- "$mf" || $as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$mf" : 'X\(//\)[^/]' \| \ X"$mf" : 'X\(//\)$' \| \ X"$mf" : 'X\(/\)' \| . 2>/dev/null || echo X"$mf" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running `make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # When using ansi2knr, U may be empty or an underscore; expand it U=`sed -n 's/^U = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`$as_dirname -- "$file" || $as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$file" : 'X\(//\)[^/]' \| \ X"$file" : 'X\(//\)$' \| \ X"$file" : 'X\(/\)' \| . 2>/dev/null || echo X"$file" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` { as_dir=$dirpart/$fdir case $as_dir in #( -*) as_dir=./$as_dir;; esac test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { as_dirs= while :; do case $as_dir in #( *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( *) as_qdir=$as_dir;; esac as_dirs="'$as_qdir' $as_dirs" as_dir=`$as_dirname -- "$as_dir" || $as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ X"$as_dir" : 'X\(//\)[^/]' \| \ X"$as_dir" : 'X\(//\)$' \| \ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || echo X"$as_dir" | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ s//\1/ q } /^X\(\/\/\)[^/].*/{ s//\1/ q } /^X\(\/\/\)$/{ s//\1/ q } /^X\(\/\).*/{ s//\1/ q } s/.*/./; q'` test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 echo "$as_me: error: cannot create directory $as_dir" >&2;} { (exit 1); exit 1; }; }; } # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done ;; esac done # for ac_tag { (exit 0); exit 0; } _ACEOF chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save # configure is writing to config.log, and then calls config.status. # config.status does its own redirection, appending to config.log. # Unfortunately, on DOS this fails, as config.log is still kept open # by configure, so config.status won't be able to write to it; its # output is simply discarded. So we exec the FD to /dev/null, # effectively closing config.log, so it can be properly (re)opened and # appended to by config.status. When coming back to configure, we # need to make the FD available again. if test "$no_create" != yes; then ac_cs_success=: ac_config_status_args= test "$silent" = yes && ac_config_status_args="$ac_config_status_args --quiet" exec 5>/dev/null $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. $ac_cs_success || { (exit 1); exit 1; } fi KoboDeluxe-0.5.1/COPYING0000666000175000001440000004307605763336324011557 00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. KoboDeluxe-0.5.1/COPYING.LIB0000644000175000001440000006215307412772024012147 00000000000000********************************************************************* * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! * * * * "Kobo Deluxe" is a game based on the work of many programmers, * * artists, porters, testers and devoted fans. * * * * In order to make the new code useful to more people, even in * * closed source productions, I am making it available under * * the terms of the GNU LGPL. * * * * However, note that the GNU LGPL only applies to * * *some* of the files in this distribution, not all of them! * * * * If you are going to reuse all or part of "Kobo Deluxe", please * * read the terms stated in the header of *each file* first. * * * * IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! IMPORTANT! * ********************************************************************* Below this line follows an unmodified copy of the GNU LGPL --------------------------------------------------------------------- GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS KoboDeluxe-0.5.1/ChangeLog0000666000175000001440000015052710734441471012270 00000000000000Kobo Deluxe v0.5.1 * Fixed segfault with weird audio buffer sizes. * *Maybe* clears the screen a bit sooner... (One could see a magnified desktop or garbage display for a moment on some systems.) * When there is no profile, the automatic New Player dialog sends you on to the main menu, rather than back to the intro. * Added a bunch of AGW explosion sounds. * Added new "big ship" launch and escape sound. * Fixed infinite loop bug in filemapper_t::get_next(). (Thanks Joey Hess!) * New "core destroyed" sound. * When compiled with PROFILE_AUDIO, the 'R' key reloads all sound effects. * Integer atan2() approximation for sprite rotation. * "Fixed" cubic resampler. (There will be a jump of one sample when switching to/from cubic interpolation.) * New player fire sounds, including overheat warning. * Tweaked various sounds and related logic. * 10% health award for core destroyed, and another 25% for stage cleared. (No more 100% for stage cleared!) * Health can now be up to 200%, but will decrease quickly towards 100%. * Destupified the bargraph_t value() interface... * Waveform info after loading with logverbosity >= 2. * Added pause sound. * Added "Safe video settings" message when "escape hammering" is detected. * Explosions can now actually show the first frame. * Explosion "random start frame" removed. * Initial white flash for explosions. * Fewer bonus lives! (We have the health bonus now...) * Default and rock explos assume half speed of objects. * Added player bolt impact fx. * Improved player explosion. * Bomb detonation fx directed at the player. * Fixed a positional audio wrap bug. * Configurable "Cannon Sound Suppression." * Configurable overheat warning buzzer. * Doubled rock health for Newbie skill. Kobo Deluxe v0.5.0 * Added 'autoshot' command line switch for grabbing ingame screenshot series. * Added animated rocks. * Added 88.2, 96, 176.4 and 192 kHz sample rates. * Default video mode changed to 640x480. * Option 'internalres' considered obsolete. (Was never implemented.) * s_filter_scale() fallback from Scale2x and Diamond2x for non 2x factor changed to bilinear. * Newbie mode changes: * Three alternating nose/wing guns. * Two alternating rearward wing guns. * Fixed nonsense values for the SDL_GL_DOUBLEBUFFER attribute. (Thanks, Sam Palmer!) * Fixed Y/N buttons in the requester dialogs. * Some new explosions, enemy bullets and other gfx. * Fixed segfault in myship.cpp in (the extremely unlikely) case of running out of sprite objects. * 'pushmove' now counts as a cheat. (No highscores.) * Added simple parallax starfield, along with none/ old/parallax starfield style switch. * Intro mode now sets it's own fixed logic rate. * Enemy definitions now have "death handlers". * Invisible enemies no longer allocate sprites. * Background color fade in damage noise flash and noise-out effects. * Map now marks cores as needed to select orientation specific core tiles. * Broken base branches are left as is. * No dithering for the logo mask! (Thanks again, Sam Palmer! :-) * Separated map tile index from map state bits. * Added alternate straight sections in bases. * OpenGL vsync is now optional. * Added 'S' key for screenshot. (PrintScreen is stolen by some desktop environments.) * Larger fps counter, for 1000+ rates... * Corrected cs_engine_t.time type. Animation should be smooth and reliable now! * Tweaked screen.png a little. (Contrast, AA, ...) * "Audio Options" renamed "Sound Options". * Rocks are now destructible again (255 hits in Classic mode; other values in new skill levels). They also have an explosion all of their own. * Special detonation animation for bombs. * Bullets, player, enemies etc in separate layers. * More firepower in the "Gamer" skill level. * Benchmark based progress bar. * Framework overlay now rendered as small tiles in the corners of the playfield window, to avoid full window impact on slow video cards in OpenGL mode. * glSDL: * Now compiles with OpenGL disabled. (Thanks, Michael Sterrett!) * Gamer mode changes: * Higher firing rate. * Added "videopages" option to make smart refresh work with triple buffered displays, and for disabling smart refresh if all else fails. * Fixed weird audio fragment sizes. * Fixed cubic interpolation -1 sample index bug in a_mixers.h. * Graphics loader refactored; gets parameters from a table, and provides more verbose error messages. * New "Boomerang" fighters with 16 rotations. * New fighter ship. (Replaces the teal missile.) * New gray, red and blue missiles. * Disabled colorkey filter in gfxengine. * New "loading" logo. * Slightly slower (more readable) scroll text. * Added window_t::textwidth_fxp(), to fix the unsmooth text scrolling. * Added "How to play" screen. * Added "Highscores only for Classic mode!" notice. * Added optional mouse capture when playing. Pause or abort game to release! * Added joystick selection. (Thanks, Erik Auerswald!) * Decided the substantial change in appearance calls for a minor version bump, so: 0.5.0. * The -help switch is now handled as a proper command, avoiding the stupid "unknown argument" error. * Added -options_man command to output option docs in Un*x man format. * Updated the Un*x man file, and replaced the README with a rendition of the man file. * Made a new README from the man file. * New counter font. * Fixed some minor compiler warnings. * Updated the TODO. Kobo Deluxe v0.4.1 * Got fed up with these "pre" version codes that don't fit into package versioning systems and look generally silly. * Implemented logic/audio timeline sync for constant sound effect latency. Events are no longer quantized to buffers. * Improved the latency selector a bit. * Latency calculations now assume 2 fragments for SDL. (We use 3 fragments for OSS.) * Latency calculation now picks the *closest* buffer size; not the biggest one with lower or equal latency. * Removed "games" from the install paths on Un*x systems, and moved the score files to the more correct $(sharedstatedir). The install target now works as expected for an autoconf build. * Reverb and limiter controls replaced with the simplified "Ambience" and "Volume Boost" controls. * Mega stoopid bug fixed: If video initialization failed after changing video settings from the options menu, the game would start back up anyway - without a display! * kobo.cpp now keeps a copy of the preferences, so safe settings can be restored should reinit inside the run/reinit loop fail. * LoadRAW_S8() became LoadRAW(), and can now load "raw" files with an 8 byte header containing "RAW" followed by the audio_formats_t format code, and a 32 bit sample rate in big endian format. The MSB of the format code byte is set if the waveform is looped. * Implemented SaveRAW(). (Always saves in the above format.) * Implemented quick hack sound caching by providing a script that saves all sounds to disk, and alternative loader scripts that use those instead of the AGW sounds. This currently generates 2 MB of raw audio data. * Added window_t::refresh() to enable the engine to correctly handle windows that aren't repainted every frame. * Added endian swapping code for 16 and 32 bit raw audio files. Files are in big endian, so this code is only compiled on little endian archs. * The mixers in a_tools.h now test for the zero samples in debug builds. * Removed in-game music pausing/restarting. * Game Over no longer stops the game logic. * Player profiles cannot be symlinks. (Security.) * When loading a "raw" file, audio_wave_load() takes looped/one-shot from the file. * AGW w_load() and w_save() now tells EEL about errors! (Kinda' handy... :-) * Replaced "fine.raw" with "breakdown1.agw". (The "fortress destroyed" sound.) * Replaced "shot.raw" with "missile1.agw". (The player fire sound.) * Fixed sound FX bug: _enemy::hit() used x and y fields of _enemy objects after release(). * Another sleeping bug: _myship::explode() generated lots of huge, nasty coordinates. * Removed "expl3.raw" completely, and removed "bomb.raw" from "core destroyed." * Added a logger with redirection capabilities. * Fixed mouse control bug; the crosshair hot-spot offset was wrong in some resolutions, because of the border that's put around the screen in certain resolutions and in windowed modes. * display_t refactored to use refresh(). * Added dashboard.(cpp|h) and refactored the health bar to use refresh(). * The framework is now rendered through refresh(). * Removed the pixel_* cruft in the _screen class. * The _radar class becomes radar_window_t, which is a window_t with callback driven rendering. * window_t gets offscreen window/surface support. * gfxengine now whines a little if it has to change the buffering mode from the requested one. * The health bar is only visible if there's more than one health point maximum. (So, it's no longer visible in Classic Mode.) * gfxengine_t should now initialize the dirtyrect management for page flipping properly. * Removed the odd "OpenGL" resolutions in the video options. * No buffering mode for OpenGL in video options. * Removed AC_FUNC_MALLOC. Who needs malloc(0)...? * Added logfile and logformat options. * Removed all extern "C" clauses around C includes. * Fixed the "selector tube" heights; the surfaces were much taller than the images. * Tweaked the cleanalpha filter parameters. * Optimized the dither filter; it doesn't *have* to touch all the data to just do nothing... :-) * Optimized the image processing filters. * Added "No Alpha Blending" feature. * Moved the sprite filters into filters.h. * loadrect() renamed copyrect() and is now applying scaling to coordinates like all other calls. * SemiTriple removed from buffering modes. You get the same setup with doublebuffer(1); shadow(1). * Old retrace sync cruft removed. * ESC from any "normal" state now gives you some version of the main menu. * Added brightness/contrast filter. * Moved less h/w related stuff from "Video Options" into a new "Graphics Options" section. * Added generic 'flags' field to filter arguments, and threw in a global s_filter_flags as well. * Removed window dependency from gamestate.(cpp|h) and changed the license to LGPL. * Upgraded to glSDL 0.7, w/ dynamic OpenGL loading. * Added "Random" and "4x4 Filter" dithering methods. * All graphics converted to PNG format. * Added support for scaling to (almost) arbitrary resolutions, including lower than the native resolution of the graphics. * The command line usage message now generates the list of recognized options from the prefs object. * Buffer overflow bug in new_player_t fixed. (?) (Thanks to Donny Viszneki for reporting it!) * Fixed a free()/delete bug in filemapper_t. * Rewrote most of the radar display code. * Removed unused scrolling cruft in window_t. * Changed version to 0.4.1. Too many 0.4something. * Made the player ship cursor flash slightly. * Fixed missing slash before the config file name. (Never noticed this before, as it apparently affects only Mac OS X.) * Fixed the title screen cheat mode indicator. * Thanks to Antonio Messina, who managed to break the game logic desipte a broken arm: * Fixed difficulty wrap at stage 1601. * Added option always_fire. * Fixed missing gamecontrol_t constructor. * Bilinear scaling without oversampling is now actually *without* oversampling. * Optimization: Scaling checks for clipping or clamping only near the edges of surfaces. * The SDL audio callback now deals with "evil" buffer sizes. (Thanks to Hans de Goede!) * Losing window focus now pauses the game. (Thanks, Marianne Ibbotson!) * Upgraded to glSDL 0.8. * gfxengine no longer shuts down the SDL video subsystem when hiding, as this causes problems with glSDL for no gain. * Implemented selectable Newbie, Oldie and Elite skill levels. * kobo_form_t:xoffs now also works for button(). * Added kobo_form_t:medium(). * Added "spread" fire for Newbie mode. * Lower rear fire rate for Elite mode. * Max number of saved scores per profile increased to 100. * Added cannon heat/cooling simulation. * Added Video Mode Manager vidmodes.[ch] * Some ships flying around in intro mode. * New screen layout. * Optimized and improved the video noise effect. * Menu highlight bar: * Faster movement. * Parallax "slime" effect. * Zoom-to-size effect. * Made more room for extreme scores in Hall of Fame. * Red noise to indicate damage. * Snappier health bar. * Added gun temperature bars. * Upgraded to glSDL 0.9. (Colorkey fix.) * Sound control cleanup; added sound.(h|cpp). * Changed to Classic mode + four "New Mode" skill levels; Newbie, Gamer, Elite and God. * maxfps default changed from disabled to 100. * Added CharOffset table to SoFont, to avoid mixing actual character positions up with source blitting extents. * Fixed rectangle size calculations and rounding in the graphics engine. (Improves rendering accuracy in "odd" resolutions.) * Fixed screen border refresh. * Added hotspot logic to the sprite engine. * New player "plasma bolts" and two new explosions. * Incomplete base destruction bug fixed (?) * Fractional frame times use double instead of float. * Added configurable time filter. * Default scale mode changed to Bilinear. * Bilinear+Oversampling removed from config menu. * Added "Strictly Regulated" frame rate limiter. * Options moved to "System Options": * Maximum Frame Rate * Strictly Regulated Frame Rate * Time Filter * Motion Interpolation * Removed some unimplemented video driver enums. * Current score and stage is now checked when quitting from within a game. * Image filters are now removed properly. * Added window centering for "some platforms". * Hammering on Escape is trapped and aborts the game when loading, or switches to a safe video mode when running. * Some refactoring to hunt down memory leaks and other issues. Most statically allocated objects gone. * Sped up the slow, annoying nibble effects. * "Weird characters" in New Player name editor fixed. * Proper Yes/No dialog for exit and abort game. * Unused song ballad1 + instruments removed. * "Dummy" score file (for WinZIP) is now minimal, no scores, no stages finished. Kobo Deluxe v0.4pre10 (Unofficial Debian/PPC fix release) * #include "config.h" was missing in e_getargs.c... * Applied security fix for saving the user config. * Added default case in glSDL's _print_glerror(), since I get flooded with warnings otherwise. (All GL_* are in an enum in my new GL.h.) * Added max_FPS feature, to restrict the frame rate. Useful on video drivers without retrace sync and/or when you want to reduce CPU load. (Thanks to Martijn van Oosterhout for the original patch!) * Added man page, contributed by Joey Hess. * Fixed some minor typos in the man page. * Added resolutions 1600x1200 and 1920x1440 and 2048x1536, for extreme/insane users. ;-) * Removed 57 unused AGW scripts. (These belong to Audiality, which is now a separate project.) * Updated and shortened the scroll text. * Added monitor noise effect with sound effect. * Fixed two related bugs in s_filter_scale() that would 1) cause NEAREST to be one pixel off vertically and 2) linear interpolation modes to be off by half a pixel horizontally. * Tweaked the death explosion, so it expands, decays and ends, instead of just rolling for as long as the player is dead, as it used to be. * Added Game Over sound effect. * Dead player no longer takes hits. (This avoids the hysterical thumping of bullets hitting the non-existent ship during the death sequence.) * Added README.osx, which points out that you may have to create the score-dir to make Kobo DL work. This applies to other archs as well, so perhaps I should put it in an FAQ or something? (Thanks to Adam Marks the the Mac OS X binary!) * Tweaked launch.agw. (More turbine; less noise.) * Added Get Ready sound effect. * Exiting pause mode now throws you right back in the game. (No "get ready" state.) * Added configurable "get ready" countdown. * "Get ready" countdown now ends by starting the game, rather than entering pause mode. * Controls are reset whenever you get a new ship. * Improved the loading status screen a bit. * Added shrinking and green->red fading bar during the last second of the "Get Ready" countdown. (0.7 s in "Quick Start" mode.) * Added a critical error state with a red flashing box and stuff. This shows up if a player profile cannot be created, or if starting a game fails for some reason. * The game now remembers the last map played until you quit, instead of resetting to the last completed map all the time. (Thanks to David Andersson for the idea!) * Fixes backported from Audiality: * midi_process() was called even if MIDI input was not enabled, resulting in the engine waiting for data on stdin once per buffer... *heh* Fixed. * OSS MIDI input fixed. (When soft through was disabled, the device would be opened write only! The drivers I used before obviously always opened RDWR...) * Poly and mono Patch Plugins now initialize the primary output and send busses for voices. (So *that's* why my mixes broke... Oops!) * New, properly working envelope generator backported from Audiality. * VE_ISET event eliminated - only IRAMP is used for ramped voice controls. * glSDL changes for glSDL-0.4: * "no TexInfo" changed from 0xffffffff to 0, since SDL 1.2.5 and up inits the unused1 field to that, specifically for glSDL. * Added compile time and runtime warnings for SDL versions prior to 1.2.5. Kobo Deluxe v0.4pre9 (Debian/PPC fix release; first try) * EEL changes: * Stole eel_get_argsv() from the not yet released Audiality 0.1.0. (Fixed some more va_list issues.) * glSDL changes for glSDL-0.4: * Added (gl)SDL_SaveBMP(). * "Fixed" OpenGL pixel format for glReadPixels. (Maybe I got the glSDL pixel format wrong? Dunno, and I'm on an ATI card and driver so I don't trust anything...) * Fixed _glSDL_BlitFromGL() (I think...) * Removed the "Intelligent Display Abstraction Layer" for now, as it's not yet usable. * Added screen() property to gfxengine_t, to have a standard way of rendering to the full screen area. * Added gfxengine_t::clear() method. * Added coarse clipping to SoFont. (The scroller made the coords wrap in 1280x1024. *heh*) Kobo Deluxe v0.4pre9 (unreleased) * Started hacking the "Intelligent Display Abstraction Layer". * glSDL changes for glSDL-0.4: * Fixed C++ issue with IMG_Load(). * Fixed stupid M$isms: Textures are now *uploaded* to the card. * SDL_OPENGLBLIT removed. (Used only to prevent certain unimplemented stuff from causing *really* Bad Things to happen.) * Depth buffer silliness fixed. (We don't use the depth buffer...) * "fake_screen" is now a real surface. * Implemented blitting from the screen. * Implemented blitting within the screen. * Implemented screen locking/unlocking. * Fixed prototype for glSDL_GetVideoSurface(). * EEL changes: * Added eel_load_from_mem(). (Thanks to Florian Schulze!) * Cleaned up the EEL script management code a little. * Using va_copy() in e_getargs.c, since assignments are not legal on all platforms. (Thanks, Andreas Heck!) Kobo Deluxe v0.4pre8 * Added Extreme Pickyness Mode (--enable-epm). (Unfortunately, this is not enough to ensure that stuff compiles on gcc 3.x. Guess I'll just have to install gcc3, or rely on gcc3 users reporting all warnings and errors.) * Some const string issues fixed. (Returning a const string as "char *" and the like.) * Removed all AdLib stuff and support for non- standard MIDI file variants. However cool it might be to play those files, I have no use for it and can't maintain it in this project. * Removed old bogus stuff from the comments in filemap.h. * Minor cleanups in filemap.cpp. * Some GCC3 fixes in score.cpp. (String copying...) * Scroll text updated. * Improved scroller "speed throttling". * Returning to the intro now restores the "demo" map. * Added Electric Fence to the Extreme Pickyness Mode. * Started cleaning up the C code using Splint. (Can someone please donate a FlexLint license...? :-) * load_sounds() in kobo.cpp fixed; it wouldn't load the music if the sound effects were loaded with a previous call. * Somewhere along the way, I managed to get the intro to generate a new demo map on every intro screen switch. Fixed. * Audio engine changes: * Added OSS 'pollaudio' for debugging. * Fixed index outside array in audio_wave_free()! * Tightened up the API - signs only where needed and things like that. * 0 dB peak amplitude for 32 bit waveforms changed to [-1.0, +1.0]. * ptab_init() now takes an integer argument. (No implicit float->fixp16:16 conversion.) * Ports and "clients" are now named for debugging/tracing, although client names exist only if AEV_TRACING is compiled in. * Cleaned up audio event system names. Everything is now aev_, and most names have been significantly shortened. * Added aev_init() macro for ports! (Aargh!) * Open/close of subsystems cleaned up. All subsystems now have audio_*_open/close() calls, and should (hopefully) clean up properly when closed. * Audio engine open/close API changed; the full sequence is now: audio_open() (optional) audio_start() audio_stop() (optional) audio_close() Note that the waveform and scripting subsystems will still initialize themselves automatically if used before calling audio_open(). ! The last two seem to have fixed the issues with restarting the engine on Linux! Remains to see if that was the whole problem... BENCHMARK: speed1.agw renders in 27.2 s. speed2.agw renders in 21.5 s. Total: 48.7 s. * Added block based processing framework. * Implemented block read, write and add. * Added block based envelope processing. * Using the new envelope interface - but still processing one sample at a time. (BENCHMARK: speed.agw renders in 34.2 s!) * Using 32 frame blocks in wca_filter() and wca_gain(). (BENCHMARK: speed.agw renders in 33.6 s. wca_filter() disabled: 31 s.) * Converted wca_osc() to block based processing, and made some minor optimizations. * WCA_SYNC for WCA_NOISE fixed. Each sync pulse now shifts in a new value through the S&H as well. * Fixed bug in spectrum oscillators: They would produce no output with a mod1 input of less than 1.0. They now produce pure sine, as originally intended. * HSPECTRUM and PHSPECTRUM fixed: They actually didn't separate roll-off control for odd and even harmonics at all! (Thus, they were basically just broken versions of SPECTRUM...) * SPECTRUM modulation mapping unified; MOD1 now always controls the overtone stepping. * The new AHSPECTRUM replaces PHSPECTRUM. * HSPECTRUM becomes a AHSPECTRUM with multiplicative overtone stepping control. BENCHMARK: speed1.agw: 10.2 s. 167% faster. speed2.agw: 17.7 s. 21% faster. Total: 27.9 s. 75% faster. Obviously, the optimizations worked out rather well. Next, we'll try to do something about those spectrum oscillators... Kobo Deluxe v0.4pre7 * Old samples boosted by 70%, to compensate for the lack of an illogical amplification factor in the new engine. :-) * The screwed up scroll position during the "Game Over" state fixed. * "Early bullets", flickering and other crap fixed. * gfxengine_t and sprite.[ch]: Added clampcolor() and s_clampcolor (for specifying what color and alpha to assume for areas outside images), and changed the color format to Uint8 in the range [0,255], to be consistent with the change in window_t. * manage: Selecting a starting stage before staring a game now preserves the actual map that is generated. You don't get a new version of the same level, but the exact map you're looking at before starting the game. * radar: Fixed potential color allocation bug when changing video mode; it used to initialize only once during the game life time... * radar: Tweaked colors, and made the the blue launcher nodes visible on the radar. * Options 'cheat' and 'indicator' are now commands rather than switches, so they cannot be saved in the configuration by accident. * Split the "push move" mode off from 'indicator' into a feature of it's own, activated with the 'pushmove' command. * Game and Control options moved to the top of the options main menu. * Scrolling radar implemented. Can be disabled in Game Options, to work like the old version. * gfxengine_t make slightly more robust WRT calls being made while the screen is closed. * Switching between fullscreen and windowed modes can now be done at any time with the usual ALT+ENTER shortcut. :-) Special case activates pause mode if it's done in the middle of a game. * Random number generator split in two; pubrand and gamerand, and get_seed() member added, as a preparation for demo recording and playback. * 'P' and the mighty strange Pause Key parsed and routed to the pause function. (This is also used internally, as a neat way of telling whatever state might be active to pause.) * Touched up the screen framework artwork a little. * Optimized background rendering some. (Occasional clipped extra row and column of tiles eliminated.) * Stupid bug in window_t::invalidate() found and killed: gfxengine_t clips invalidated rects, so we need to make sure our window is selected! * window_t now supports background images. clear() takes an optional SDL_Rect, and blits from the image, if there is one, or fills with the background color as in previous versions.) * Background graphics in the displays and the radar screen! :-) * Added dither plugin with hard-coded 2x2 filter. * Added options to turn dithering off. * Added kludge for OpenGL cards that can't handle RGBA8, but turns it into RGBA4, and a switch to enable it if required. * sprite: S_BLITMODE_NORMAL renamed S_BLITMODE_AUTO. (Makes more sense!) * Option broken_numdia (Broken NumPad Diagonals) added - I want to use the page up/down keys for other stuff, even if *some* systems can't decode the numpad correctly! :-/ * Added the algorithmically constructed sound effect "SOUND_LAUNCH". * Separated the AGW scripting engine core from the audio engine and made it the "Extensible Embeddable Language". (a_agw.[ch] now contain only the AGW extension to EEL.) * Added the algorithmically constructed sound effect "SOUND_LAUNCH2", for the "blue balls". * Fixed some bugs in filemapper_t. * Any jerking, flickering etc when entering a new stage should now be *completely* eliminated. I think... ;-) * Intro doesn't conflict with stage 100 any more. * Implemented 2D positional sound effects. :-) * Added screenshot feature. (OpenGL not implemented, as the current glSDL cannot read the screen surface.) Saves BMP only, and is connected to PrintScreen and SysReq. * EEL now uses the same callback prototype for all extensions, whether they are commands, operators or functions. * Ported Jeremy Sheeley's player profiles patch from 0.3, and tweaked the user interface a little. * Fixed double initialization of the manage object. * Extended the score file format into a more powerful, versionned "profile file format". * file.(h|cpp) and parts of score.(h|cpp) replaced with pfile.(h|cpp), which implements a generic, portable "toolkit" for platform independent binary data file access. * Added game.(h|cpp), which collects all configurable game parameters in one place. * The "speed" parameter is now considered a cheat, and is no more available from within the game. * Last player profile is remembered in the config. * Added optional "Diagonals Emphasis Filter". (I'd say it only makes control feel sluggish most of the time, but it might work for someone... I'm open to suggestions if anyone has an idea for a smarter filter.) * Eliminated extra calls to score_manager_t::record(). * Start level selection in intro mode removed. * Implemented collision/health system. When two "collidable" objects collide, the damage of each object is subtracted from the health of the other. (Object properties set so that the game will play exactly like the original with the single player default settings for the player ship.) * Turned the "shield = -1" feature into 'shootable'. * Added health bar. * Threw in detection and fix to read broken 73 byte scorefiles from older Win32 versions. (Seems like the new code works right on Win32 as well, BTW.) * Various fixes and additions to filemapper_t. (Scanning multiple directories, most importantly.) * Removed "./scores" from the SCORES path for now, as it's actually the same place as the default score dir on Win32. (You'd get all profiles and scores twice, that is.) * Removed "bgm.raw" as it's not used anymore. * No hyphen before the "pre" from now on! * glSDL changes: * Applications can now set the colorkey of of surface *after* SDL_DisplayFormat() - although it will just discard the TexInfo, resulting in the surface being converted before the first blit, and after every change in the surface. * Silly intermediate buffer eliminated in _DownloadTexture(). * glSDL automatically stretches resolutions below 640x480 using an integer factor. * Audio engine changes: * Benchmarking tries to use gettimeofday() if not compiled for x86 CPUs. * a_tools.h got some cleaning up, some new macros, and mixing functions optimized with a Duff's Device variant. * __mastervol() is obsoleted by the groups, and was killed to save some cycles. (It ate almost 1% of my P-III 933!) * Ditched the "Smart Stereo" Limiter - it's not loud enough, and should be replaced with something that drives the signal non-linear to squeeze more power in when the signal isn't panned center. * Dropped the saturating 32->16 bit converter, and fixed the limiter so that it reliably *limits* the signal the way it should. * Limiter does no longer invert the signal. * Added ACC_PRIORITY. * Added controls for Channel Inserts. * Channel default controls (used in DETACH mode) removed. Just expect channel controls to stay where you leave them, and everything should be fine - and faster! * Implemented dynamic voice allocation. * ACC_DETACH now effectively means "polyphonic mode". "Detached" voices are still owned by the channel that launched them - but just as before, channel controls don't affect voices directly after they're launched. (Even that may change eventually...) * Ripped mid.cpp and mid.h from the AdLib FM player AdPlug 1.1. Started stripping off the FM stuff and converting it to C and the "midisock" interface. * Added primitive VU-meter to the voice mixer. * Implemented audio_wave_convert(), using the voice mixer in interpolated 16x oversampled mode. * Added simple enhancer and noise gate functions to the init time wave API. * Hacked basic polyphony support into a_midicon. * ACC_RANDTRIG is now *really* a 16:16 fixp value, to allow finer control of the randomize depth. (Next, I'll make the section end marker fixed point, to allow sub sample accurate loop timing - as well as finer RETRIG and RANDTRIG control. :-) * Fabricated a nice 3'rd degree LUT for various MIDI -> Linear Control mapping. * Introduced a more solid scheme for keeping track of allocated voices. * audio_channel_play() now takes 16:16 linear pitch and 16:16 volume, instead of the bogus MIDI format arguments. * Added audio_wave_filter(). * DETACH mode split into ADM_POLY and ADM_FULL, to natively support the slightly different ways DETACH mode is used by midicon and for sound effects. * Added cubic (4-point) interpolation, based on a formula by Olli Niemitalo. Low freq sines sound *perfect* - no audible distortion whatsoever. It sounds great up to 1:1, but runs into trouble in the upper half of the octave above 1:1 - linear 2X+ sounds better from there and up. The best part is that the CPU usage is somewhere in between linear 2X and linear 4X on a P-III. * Volume ramping bug fixed: The "boot strap" values calculated when starting new voices were wrong, and resulted in an undesired fade in over one buffer. * "Playing" indicator below the per-voice VUs. * Waveform size restrictions eliminated! (Well, you'd probably have trouble with 2+ GB on 32 bit systems... ;-) * Dynamic voice allocation now always starts with voice 0 in the first pass, when looking for unused voices. (The other passes are still starting at the voice after the last voice allocated, to favor the "oldest" voice when there are multiple equivalent choices.) * Implemented MIDI CCs 120, 121, 123, 126 & 127. * Added SILENT and RESTING states to the plugin API, to deal with silent output efficiently. * Optimized bus handling; now, bus send buffer clearing and other stuff isn't even considered unless a bus actually is in use. * Implemented the Bus Control MIDI CCs. (39...55 on the first AUDIO_MAX_BUSSES channels.) * Reverb SNR improved. The internal precision is now 8 bits higher than that of the I/O, which produces "perfect" results down to the LSB in the final output. * Implemented CCs 88, 89 and 91; "primary bus", "send bus" and "send level". * Added SINEMORPH, SPECTRUM, and LSPECTRUM oscillators. * Changed ACC_PITCH to fixed point linear freq, where the integer bits correspond to MIDI pitch. That is, 60.0 now does what 1.0 used to do, and to step up one octave, add 12.0 instead of multiplying by 2.0. * Various oscillators and stuff added to the Waveform Construction API. * Added bandlimiting or oversampling to all Waveform Construction API oscillators. * Modulation API cleaned up. * Voice mixer code cleaned up a bit. * Voices now use timestamped events for control. * "Plugin style" API for patches separates the channel->voice bindings from the engine core. BENCHMARKING NOTE: Right now it takes 60 seconds to load and render the 72 AGW sounds I've created so far. Although most of the code is currently *very* inefficient, only the SPECTRUM oscillators are really so slow that it matters. * Audio Voice Mixer benchmark results, 20020111: (P-III 933, 48 kHz, 20 ms latency, playing an 8 kHz 8 bit stereo sample in 32 voices, compiler optimizations disabled. Unit is percent of total CPU time.) ----------------------------------------------- Very Low: 6.9% Low: 14.5% Normal: 10.1% High: 17.9% Very High: 136% (overload!) (Same, but with gcc/g++ -O3 optimization.) ----------------------------------------------- Very Low: 3.5% Low: 6.5% Normal: 4.6% High: 7.9% Very High: 78% (causes underruns) Obviously, on this machine, the "Normal" mode, which is using plain linear interpolation, is almost as fast as the "Very Low" mode, whereas the "Low" mode is more expensive. This is to be expected from CPUs with fast multiplications. * Audio Voice Mixer benchmark results, 20020503: (Same machine, same settings, same test, but with the new cubic interpolating mixer, internal fragment size limit, timestamped events etc. With -O3 optimizations.) ----------------------------------------------- Very Low: 4.5% Low: 6.8% Normal: 5.5% High: 8.2% Very High: 9.5% Higher loads occur only when pushing the pitch more than ~1.5 octaves above fs in "Very High" quality. (That results in linear interpolation w/ 4x+ oversampling, which is pretty slow.) *** The Audio Engine: Why the GPLed files? The sound code used in Kobo Deluxe was originally written by Masanao Izumo , for XKobo 1.11+. Masanao also added the sound effect samples that are still being used. You may have noticed that, while most, if not all of the current audio engine is new code, which is LGPLed, a few files (a_globals.[ch] and audio.[ch]) are GPLed, and contain a copyright notice mentioning Masanao Izumo. This effectively means that the whole audio engine has to be used under the terms of the GPL; not the LGPL. As this will probably be too restrective for many of the users the engine is targetting, I've contacted Masanao for a resolution, but have yet to receive a response. David Olofson Kobo Deluxe v0.4-pre6 * I've compiled with -Wall and nearly all of the additional warning switches (not activated by -Wall) to verify all code. Many things that non-gcc compilers could complain about should be fixed in this version. * "Video Driver" option not shown if there's only one choice. (Which is the case if you build w/o OpenGL.) * Exit with ESCAPE from config menues fixed - now cancels any changes and plays the appropriate sfx. * Solaris package building script 'buildpkg.sh' and required configure.in fix by Andreas Spĺngberg added. * String copy bug in cfgparse.cpp fixed. (Andreas Spĺngberg.) * Switching between windowed and fullscreen modes no more results the screen being offset. * Screen centering fixed. * Border in windowed mode fixed. * Cleaned up audio config menu, and added volume controls for sfx, (future) intro music and in-game music. (Note that the "Master Volume" is still there, and it's still digital...) * Icreased the number of volume levels available in the audio config menu. (Used to be 25% increments.) * Added redefined() and accept() to config_parser_t. * Non-interactive widgets handled correctly in menues. * Added headers to configuration menues. * Added 'unit' string to ct_spin_t. * window_t::select() now comes in a private flavor without checks. * Config menues now make use of OS_UPDATE_* flags in addition to the OS_CANCEL tag, to allow instant effect controls to cancel/undo properly. * config_form_t now has a virtual member undo_hook() that's called by undo(). (Used to make ESC exit work.) * Audio engine changes: * Channels are separated into voices (mixing) and channels (control abstraction) levels. * Groups added for easy channel management. * The API provides access to channels and groups, but not direct access to voices. * All fixed point values are now 16:16. * API variants with float arguments added. * AC_DETACH added. (Easy SFX control.) * Panning/balance control added. * Added "waves" to get rid of sample pointers. * AC_SPEED removed. (Obsoleted by the internal conversion to original wave sample rates.) * Fixed bug in reverb: Right input missing! * Another reverb bug: The delay buffer was too short for >=32000 kHz with the current taps. * Implemented AC_RETRIG and AC_RANDTRIG. * Improved resampling frequency accuracy. * Improved looping accuracy and quality. * Added MIDI input implementation for OSS and ALSA raw MIDI interfaces. * Fixed potential crash bug; mixing buffer size variable would be wrong if the desired buffer size couldn't be set! * Added higher quality voice resamplers. * sound.[ch] replaced by a_wave.[ch]. * Auto trig w/ timeout on the oscilloscope. * 8 & 16 bit mono + 16 bit stereo added. * Engine code restructured and modularized. * "Waveform Construction API" added. * Channel->bus->master mixing architecture. * FX plugin API added. (Internal, for now.) * Reverb LPF cutoff made configurable and independent of the sample rate. * Added generic "browsing" API to config_parser_t. * Added a copy of LGPL 2.1, and started sorting out which licence applies where. (Basically, the old code is GPL, while most of the new code I've written from scratch is LGPL.) * Added window_t::center_token[_fxp]() for nice columns. * Started documenting a little... * Added "Audio CPU Load" screen for gcc/x86. (Needs high resolution timestamping, and I'm using RDTSC for now.) * Added text alignment system for the ct_* widgets, to make use of the new center_token() methods. * Various tweaks and adjustments. * Credits updated. Kobo Deluxe v0.4-pre5 * New versioning rules introduced; * Any -preX suffix should *always* be included in AM_INIT_AUTOMAKE(). * No more development snapshots - every package released has a version number of it's own, with a -preX suffix if appropriate. * Surface leak when reloading graphics fixed. * gfxengine_t::unload() now takes -1 (default) for unloading all banks. * gfxengine_t::unload() also destroys SoFont objects! * Void pointer arithmetics and some bogus braces fixed. (Thanks, Riki!) * Moved sound effects out into files. (Raw format for now, as WAV doesn't support signed 8 bit data...) * Minor sound code cleanups. * bgmfile.[ch] removed. (Used to be Linux only anyway...) * config_parser_t created. (prefs_t is now derived from that class, and contains no parsing code whatsoever.) Also eliminates duplication of "command" decoding for non-config stuff like -showcfg, -debug and -fps. * SDL_VIDEOEXPOSE is *finally* at least handled! :-) * Removed gcc-only compiler flags and fixed other stuff that caused trouble with some compilers. (Thanks to Andreas Spĺngberg for the Solaris patch!) * Menu and state code cleaned up a little. * Configuration menu split up into Video, Audio, Controls and Game. * ct_list_t now interprets change(0) (ie button press or similar) as change(1), rather than just ignoring it. Kobo Deluxe v0.4-pre4 * Replaced corrupted README.jp. * Delayed fps printout to program exit, as some setups have serious trouble with output to the console while running the game. * Fixed a sleeping bug in the gl_blendfunc() wrapper. * It's now possible to quit gracefully while loading data. (Check when updating the progress bar.) * Old style mouse control is back. (Not that I understand how anyone could play with that... :-) * Bigger and more visible mouse crosshair. * Added 'mouse' switch and 'mousemode' variable to config. (MMD_RELATIVE not yet implemented!) * Video config cleaned up - unsupported OpenGL settings removed. * Radar window code cleaned up and simplified. * window_t::alloc_color renamed to map_rgb, which is more appropriate. The new version takes either three Uint8 components (rather than X style Uint16), or an Uint32 for "HTML style" hex codes. * Diagonal rocket sprites lined up with diagonal Kobo (the player's ship! :-) sprites. (The ship has an offset of +1 pixel in y in the gfx) * Added missing (8'th) frame to explosion animation. * glSDL: * Some tiling bugs fixed. * Single tile case optimized. * Vertical tiling implemented. * Horizontal and vertical tiling across multiple textures implemented! (Not both h & v, though.) * Off-screen blits are culled. * Benchmark results: P-III 933, Matrox G400, XFree86 4.1.0-17mdk: Resolution SDL 2D glSDL ratio ----------------------------------------------- 1280x1024 16 60 3.8 960x720 28 102 3.6 640x480 62 202 3.3 320x240 227 205 0.9 Note that OpenGL is pumping quite a bit more pixels than SDL's RLE blitter in this game, due to the alpha blended window frame. Here are the results with no frame: P-III 933, Matrox G400, XFree86 4.1.0-17mdk: Resolution SDL 2D glSDL ratio ----------------------------------------------- 1280x1024 18 93 5.2 960x720 32 163 5.1 640x480 70 205 2.9 320x240 256 205 0.8 Notice how glSDL appears to win even more in higher resolutions, while it loses a little to SDL 2D in the low end, where fill rate becomes next to insignificant to OpenGL. Kobo Deluxe v0.4-pre3 * Hitting the window close button now causes a "brutal" quit, just like hitting ctrl-C in the console. * Mac OS X OpenGL build script fix. * Now uses SDL_opengl.h if present. (Dunno if the check is totally portable, though - but if it fail, at least things shouldn't be worse than with the old way.) * Implemented tiling of wide surfaces. * Does *not* support multiple textures, so it won't help with wide *and* tall surfaces, that simply won't fit in one texture. (Sorry, 256x256 people! ;-) * The rendering loop for tall surface tiling is missing... (Mostly a matter of cut'n'paste + search'n'replace.) * Anyway, this means that Kobo Deluxe now RENDERS PERFECTLY ON OPENGL! :-) Kobo Deluxe v0.4-pre2 * The glSDL layer: * Now uses handles instead of pointers! * Various bugs and stability issues fixed. --> Still misses vital features. --> Leaks textures - or at least TexInfos. * Some double buffer compatibility issues fixed. * "Stall" when rebuilding menues fixed. Kobo Deluxe v0.4-pre1 * Build with OpenGL on X fixed - without breaking Win32 and Mac OS X! * Added dummy score file to keep stupid WinZip from removing 'scoredir'... * Added README.jp translated by Tsuyoshi Iguchi (?). Kobo Deluxe v0.3 * Name officially changed to 'Kobo Deluxe' * Upgraded to sfifo-1.2. * Various configure script fixes. * Added README file. * Updated logo. * Added filemapper_t, to handle paths on all platforms. * Rearranged main loop to handle re-initialization. * Fixed garbage after name in score files. * Rearranged score management code slightly. * Added prefs_t, which can parse, read and write options from/to command line args and files. * Kobo now tries to save a backup of the user score file in the user's home dir. * Cleaned up the game state system a bit, and added confirmation dialogs before aborting game or quitting Kobo. * Added various eye candy. * Added "Options" page. * Class myship now releases the player ship object as well when turned off. (myship, and a bunch of other objects, won't be destroyed and re-created when reinitializing.) * Moved graphics/ and audio/ from source to include path. * Added sound effects to the user interface. * Added Mac OS X fixes by Max Horn * Quits on window close event (Max Horn ) * Paths for Mac OS X bundles added. * Fixed +/- keys for selecting level. (Thanks Max!) * Automatic timed logo/highscore switch added. * Credits screen added. * Simple scroll text added. * Win32 and Mac OS X bundle install styles added. * Added feedback delay based reverb with LP filters. * Added limiter/AGC with threshold and release params. * Joystick support; Samuel Hart . * Filter plugin support added to "sprite". * Plugins added: rgb8, rgba8, cleanalpha, key2alpha, scale and displayformat. * Implemented the "size" feature with three different scaling filter modes. * Sprite and tile "palettes" separated for correct scaling. * Added various "fade out" effects. * Added "LOADING" screen. * Added "Screen Buffer Mode" setting with single, double, semi triple and half buffering modes. (Note that the game doesn't yet support all of them properly.) * Added FPS counter. (-fps switch) * Progress bar while loading and converting data. * gamestatemanager_t instead of those switch() statements... * Added "Get Ready" and "Game Over" states. * Improved filemapper_t and score_t portability. (I think...) * Removed annoying key state clearing. * SoFont: * CleanSurface() now only cleans the top row. * Fixed rounding when spacer width is odd. * No testing of '|' (for cursor) if the font doesn't have it. * CS engine: * Freeing free objects won't crash the engine. * Safer and (probably) faster wrapping code. * "width" and "height" replace "size" option. * Cleaned up config_form_t and added a "rebuild" action for dynamic configuration panels. * Added config options and gfxengine_t::driver(). (No OpenGL code yet. OpenGL options hidden in "options".) * Added a thin black border in windowed mode. * Proper clipping done by window_t::invalidate() and gfxengine_t::invalidate(). * Sprite and text calls for fixed point coordinates added. * Fixed gfxengine_t::loadrect() - it dropped the RLE! * Added contrast and offset parameters to cleanalpha plugin. * Audio engine: * Added "nearest sample" resampling support. * Improved sample looping accuracy. * Added "samplerate" option. * Random pitch effect on some sound effects. * Improved pause mode. (Switches to "get ready".) * BTN_FIRE can now be used to start game from intro. * Cleanup + fix: SHIPS display is now updated correctly. * Added quick hack OpenGL rendering layer. (64 bit broken!) * "Escape" in pause mode now sends you to "Abort Game?". * Added AdvanceMAME "Scale2x" scaling filter. * Gave up on Scale2x + fuzziness factor - it just won't work for 256+ color graphics. (It's still there, though.) * Added Diamond2x scaling filter - The Best so far! Also very fast, even without serious optimizations. * Various scaling filter bug fixes and cleanups. * C++ extension changed from '.C' to '.cpp'. * Linux/i586/VGA vidsync hack removed. * Added main menu with "Start Game!", "Options" etc. * sprite.c: Size check for loading sprite palettes. * Added rotating tube effect for menu highlighting. *** Name changed to "Kobo Deluxe". SKobo v0.2 * "sprite.c" now uses SDL_DisplayFormatAlpha(). * Various autoconf checks added and implemented. * Audio ported to SDL. (OSS support remains.) * "-latency XXX" argument to set maximum desired audio latency in milliseconds. Default is 50 ms. * Added control API to audio engine. (Moved looping there.) * Initial Win32 support: * Hacked temporary kludge in score.C * Added _snprintf define for snprintf() SKobo v0.1 update (forgot to mention this...) * GIMPed new "Kobo Next Generation" logo. * Added the display_t class, which inherits from window_t, and forms a display with a caption and text field. * Added GIMPed framework for the whole screen. * Re-implemented the "starfield" by grabbing 64 starry tiles from an XKobo screenshot. * Centered radar screen vertically, moving "stage" and "ships" down below the radar screen. * Added "HIGHSCORE" display. SKobo v0.1 * Removed all X specific code. * Added graphics and control system code from Project Spitfire. * Wrote gfxengine_t class. (Control system + video wrapper.) * Rearranged source tree and switched to autoconf/automake. * Wrote window_t class. (Clipping, scrolling etc.) * Fixed some bugs in sprite.c and cs.c. (*heh*) * Added text using the C++ version of SFont; SoFont. * Changed audiodev_t to open in nonblocking mode, to avoid the game going to sleep if the device is busy. SKobo disables sound FX if the audio device cannot be opened. * Pixeled new font and GIMPed a temorary logo. * Added alpha blended frame with rounded corners. * Added scrolling background (level 20) in intro mode. * Selecting starting level now shows the selected level in the radar display and intro screen background. * Enlarged the core diameter by two pixels. *** David Olofson forks from 'V1.11+-do3', and calls the new branch SKobo, with version numbers starting over at 0.1. V1.11+-do3 * Cleaned up audio code and API. * Added sample looping feature. * Changed mixed fp/integer mixer into integer-only. * Increased internal mixer level to avoid dropping bits. * Fixed silly bug from -do2: The original sound was indeed in stereo! <:*) V1.11+-do2 * Adjusted sound effects reference level. (Louder sfx.) V1.11+-do1 * Ported sound to OSS * Sound is enabled by default (use -nosound to disable) * Made audio run asynchronously with lock-free command FIFO *** David Olofson picks up XKobo 1.11+ from Izumo, adding '-doX' to the version code. V1.11+ * SGI sound added. * Triple size mode added. *** Masanao Izumo picks up XKobo 1.11, appending '+' to the version code. V1.11 * ?? V1.10 * fixed an endianness problem of score files * secure score files V1.9 * take measure against system calls interrupted by SIGALRM * '-hiscores' option * bonus ships V1.8 * add close() in file.C V1.7 * enabled to move on diagonals using the numeric keypad V1.6 * support for Solaris 2 V1.5 * ceased to use semaphores * fixed a strange usage of setitimer * '-wait' option V1.4 * '-cheat' option * enabled to play using a mouse * enabled to compile with gcc-2.7.0 V1.3 * fixed a bug about '-fit' option * enabled to select a stage to play V1.2 * support for TrueColor X server * '-fit' option * '-doublesize' option V1.1 * first uploaded to tsx-11.mit.edu KoboDeluxe-0.5.1/TODO0000666000175000001440000002241710734535131011177 00000000000000 Priority: * Cleaner gold fonts! (Poor AA in bigfont3, and goldfont is just a scaled and colorized version of icefont2.) * Sort the video modes! * Nodes and cores should have some sort of "spawn" effect when firing. * Logic object pool optimization: Use LIFO pool + lists! * Graphics scaling: * Remove or hide the advanced graphics options! * Graphics quality: * Fastest * Medium * Best (Default) * Custom (show old detailed settings) * At first startup, quality would be "Unknown". The game will start by testing the intro with no logo. The game picks a quality setting based on frame rate. If "Medium" or "Fastest" is picked, the game should warn and ask the user. * Specify in the loader what scaling methods should be used for each quality setting. (What about Custom?) * Disable alpha in Fastest quality. Medium...? * Better scaling! * Try SDL_resize!!! * Combine Scale2x and Diamond2x? * S-spline style enhancement filters? * Detail textures? * Indirectly changing the video mode (by changing one of the "Show" options) will not trigger a video restart. * Death sequence UI timing should not be governed by game logic time! Throw in a "state time" feature in the gamestate manager or something. Or perhaps just switch to a fixed logic frame rate when not actually in-game? (It does actually make sense to scale in-game effects with game speed!) * Quicker menu navigation with PgUp/Dn, Home, End etc. * 3D "rockfield" for highscore and/or credits? (2D parallax rocks + stars without glSDL.) glSDL should support texture filtering for nice scaling. * There should be some feedback from the sound engine, perhaps... As it is, you can't even see what sample rate it's actually using. Bugs: * Y scale factor f*cked up when switching to 2560x1600! Apparently happens only after "escape hammering"... * In-game music volume affects intro music! * Mouse crosshair can stick around after disabling mouse control! * Multiple keys and buttons bound to the same function results in up/down state confusion; if you release one of the keys, the "target" gets a release event, despite other keys with the same target being held down. * Nibble effect still doesn't like double buffering. * The sound engine is mixing up PAN events!!! * glSDL surface leak when taking screenshots! * Do we *really* wait for all bases to stop exploding after the player lost a ship...? * Noise fx glitches in some resolutions. * If a ctrl+enter fullscreen/windowed switch is made while the menu is shown, the text goes away! * Any playing game aborts after toggling windowed/ fullscreen! * VSync settings doesn't change as it should! Doesn't seem to be much I can do about this... * Leaving the game running for a few hours results in "hickups" at around 2 Hz, until the graphics is reloaded or similar. (Logic re-init?) * Downscaling (sub 320x240) breaks the radar and causes various other issues. (Pretty much expected...) * SIGSTOP kills the main thread... SDL/AMD64 bug...? * SIGSTOP/SIGCONT seems to confuse the game logic. (Already fixed...?) * SDL_GetAppState()! (Fixed...?) Internals: * Try to create a scoredir if missing! * Add doc() method to the config manager, for longer explanations of the options. * Structured documentation for values...? * Try reading back from the display buffer to autodetect how page flipping is handled! Mark pages with a few pixels in the corner (binary page numbers), and see if/when they come back. * Pause mode should not consume CPU or GPU power, at least not if the window is passive. * Multiple priority groups for sound effects! * glSDL and EEL should output errors to the logger. * Switch to PhysicsFS!? * WAV writer? (Just for "cache sounds on disk.") * Don't overwrite other windows when refreshing the in-game framework. * Convert text files to Win32 format in the Win32 install target! * Add source info to "key" codes, to tell joystick input from keyboard and the like, when desired. * Use custom keyboard repeat code. Should be used for joystick events as well. * Show a system dialog of some sort, instead of printing to stderr. (Critical errors only.) * Range checking on command line args and config. * Remove either gamecontrol or gsm event pushing calls from skobo_gfxengine_t::frame(). Don't know which one, but it can't be right the way it is now... * Rearrange the source tree so that all source is in an src subdir. * Put README, COPYING etc in binary distros. (Done for Win32 "simple bundles".) * Add CRC or simple "checksum" to score files, to prevent too easy modification. You must at least download the game source and hack it if you *really* want to cheat! ;-) Features: * Proper start-of-map savegames! * Instructions! (In the radar window...?) * Input configurator!!! * Game statistics! * Shots fired * Hits * Accuracy * Kills * Deaths * Damage * Adrenaline Mode: * Health/damage accounting * Powerups * Indestructible labyrinths * N bases or objects to destroy * Loads of aggressive enemies * "Forced speedrun" style gameplay * Throw in some *real* music. (The demo songs don't really have anything to do with Kobo Deluxe. I was basically just testing things when developing the audio engine.) * Implement "world snapshot" feature, to use for save game option, as well as internal temporary save game for changing video options in the middle of the game and the like. Needs to save score, lives etc, the current map, all objects, random number seed etc. * Implement multiplayer modes. (Deathmatch and Cooperative, for starters.) * Separate personal and global highscores. Where applicable, one could keep score for player/user, system local, local network and the internet, and/or maybe some kind user defined groups. * New "Instructions" solution. (New state...?) * "Sloppy Refresh" hack to improve frame rate for sprites and base tiles, while reducing it for the starry background tiles. * On targets with sync'ed flips, accept "close enough" refresh rates as time base, so that the video frame rate becomes an integer multiple of the engine frame rate. (Smoother scrolling.) Gameplay: * Elite and God modes should make enemies smarter (aim-ahead, at least). We want "tough" - not "stupid fast"! Radar: * Radar markings for death + respawn points when getting killed? * Show map borders in radar, for orientation? Base layout: * Prevent the map generator from building impossible bases! Possibly build a list of tested and approved random seeds for each level... * Don't make bases where you have to navigate into the base on the first few levels. * Simulation based base verification method: 1. Destroy all destructible nodes. 2. Figure out how many turns one would have to navigate into the base in order to get a shot at the core. * Provide a fixed set of maps for fair highscore, speedruns and the like! As it is, every game is truly unique, so scores cannot really be compared. (Well, that *could* be considered part of the game, of course...) * Import some extra maps from xkobo-1.11+w01? * Bonus levels...? * "Smooth chase" scroll in non Classic modes? Maybe even filtered player movement? * Fire to push rocks around? * "Milking" cores that fire enemies is a potential way of cheating for a higher score. Throw in an enemy_m* after some time as assassin to prevent this? (How to detect whether the player is doing something "sensible" or not...?) Trick suggested a nice and simple solution: Just lower the "price tag" on enemies spawned from nodes over time. No effect on gameplay, but if you fly around shooting defenseless enemies for too long, they'll eventually stop counting towards your score. The only remaining problem is figuring out when to start decreasing enemy scores, and how fast. Features: * Instant restart button? (Shouldn't really be needed if the "impossible base" bugs are fixed...) * Should be able to skip the death explosion sequence, if there are more ships! Maybe an option to remove it (and other effects) altogether? * Separate highscores for different skills. * Help texts (in the radar window?) for config options! * Add native OpenGL support with sub-pixel accurate rendering for ultra smooth animation. * Nice health bar flash effects. * Fine rotation adjustment when using OpenGL. (Needs a generic high resolution rotation field.) * Screen pixel accurate map scrolling. * "Stage cleared" screens with stats and stuff! * Demo recording and playback! (Nice feature and debugging tool.) * Implement waveshaper AGW command! * New master output processor: * Three bands with separate "boost" controls. * Non-linear audio output for high boost! * New limiter that programs a waveshaper based on input level? * Interesting soundscape while loading? * "Center Playfield" (as opposed to "center framework") video option * Default/Changed status indicators in the options. Web site and other stuff: * Find binary packages and maintainers! * Links to unrelated games sites. * Write a design paper! KoboDeluxe-0.5.1/acconfig.h0000666000175000001440000000000007411227403012407 00000000000000KoboDeluxe-0.5.1/compile0000755000175000001440000000532607366242630012067 00000000000000#! /bin/sh # Wrapper for compilers which do not understand `-c -o'. # Copyright 1999, 2000 Free Software Foundation, Inc. # Written by Tom Tromey . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Usage: # compile PROGRAM [ARGS]... # `-o FOO.o' is removed from the args passed to the actual compile. prog=$1 shift ofile= cfile= args= while test $# -gt 0; do case "$1" in -o) # configure might choose to run compile as `compile cc -o foo foo.c'. # So we do something ugly here. ofile=$2 shift case "$ofile" in *.o | *.obj) ;; *) args="$args -o $ofile" ofile= ;; esac ;; *.c) cfile=$1 args="$args $1" ;; *) args="$args $1" ;; esac shift done if test -z "$ofile" || test -z "$cfile"; then # If no `-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # `.c' file was seen then we are probably linking. That is also # ok. exec "$prog" $args fi # Name of file we expect compiler to create. cofile=`echo $cfile | sed -e 's|^.*/||' -e 's/\.c$/.o/'` # Create the lock directory. # Note: use `[/.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo $cofile | sed -e 's|[/.-]|_|g'`.d while true; do if mkdir $lockdir > /dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir $lockdir; exit 1" 1 2 15 # Run the compile. "$prog" $args status=$? if test -f "$cofile"; then mv "$cofile" "$ofile" fi rmdir $lockdir exit $status KoboDeluxe-0.5.1/config.guess0000755000175000001440000012075607662554460013044 00000000000000#! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-05-19' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Per Bothner . # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit build system type. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] Output the configuration name of the system \`$me' is run on. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" >&2 exit 1 ;; * ) break ;; esac done if test $# != 0; then echo "$me: too many arguments$help" >&2 exit 1 fi trap 'exit 1' 1 2 15 # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a # headache to deal with in a portable fashion. # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still # use `HOST_CC' if defined, but it is deprecated. # Portable tmp directory creation inspired by the Autoconf team. set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; dummy=$tmp/dummy ; tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; case $CC_FOR_BUILD,$HOST_CC,$CC in ,,) echo "int x;" > $dummy.c ; for c in cc gcc c89 c99 ; do if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then CC_FOR_BUILD="$c"; break ; fi ; done ; if test x"$CC_FOR_BUILD" = x ; then CC_FOR_BUILD=no_compiler_found ; fi ;; ,,*) CC_FOR_BUILD=$CC ;; ,*,*) CC_FOR_BUILD=$HOST_CC ;; esac ;' # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:NetBSD:*:*) # NetBSD (nbsd) targets should (where applicable) match one or # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*, # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently # switched to ELF, *-*-netbsd* would select the old # object file format. This provides both forward # compatibility and a consistent mechanism for selecting the # object file format. # # Note: NetBSD doesn't particularly care about the vendor # portion of the name. We always set it to "unknown". sysctl="sysctl -n hw.machine_arch" UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ /usr/sbin/$sysctl 2>/dev/null || echo unknown)` case "${UNAME_MACHINE_ARCH}" in armeb) machine=armeb-unknown ;; arm*) machine=arm-unknown ;; sh3el) machine=shl-unknown ;; sh3eb) machine=sh-unknown ;; *) machine=${UNAME_MACHINE_ARCH}-unknown ;; esac # The Operating System including object format, if it has switched # to ELF recently, or will in the future. case "${UNAME_MACHINE_ARCH}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep __ELF__ >/dev/null then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? os=netbsd else os=netbsdelf fi ;; *) os=netbsd ;; esac # The OS release # Debian GNU/NetBSD machines have a different userland, and # thus, need a distinct triplet. However, they do not need # kernel version information, so it can be replaced with a # suitable tag, in the style of linux-gnu. case "${UNAME_VERSION}" in Debian*) release='-gnu' ;; *) release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: # contains redundant information, the shorter form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; arc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; macppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvme88k:OpenBSD:*:*) echo m88k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; pmax:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sgi:OpenBSD:*:*) echo mipseb-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; wgrisc:OpenBSD:*:*) echo mipsel-unknown-openbsd${UNAME_RELEASE} exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; alpha:OSF1:*:*) if test $UNAME_RELEASE = "V4.0"; then UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` fi # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` case "$ALPHA_CPU_TYPE" in "EV4 (21064)") UNAME_MACHINE="alpha" ;; "EV4.5 (21064)") UNAME_MACHINE="alpha" ;; "LCA4 (21066/21068)") UNAME_MACHINE="alpha" ;; "EV5 (21164)") UNAME_MACHINE="alphaev5" ;; "EV5.6 (21164A)") UNAME_MACHINE="alphaev56" ;; "EV5.6 (21164PC)") UNAME_MACHINE="alphapca56" ;; "EV5.7 (21164PC)") UNAME_MACHINE="alphapca57" ;; "EV6 (21264)") UNAME_MACHINE="alphaev6" ;; "EV6.7 (21264A)") UNAME_MACHINE="alphaev67" ;; "EV6.8CB (21264C)") UNAME_MACHINE="alphaev68" ;; "EV6.8AL (21264B)") UNAME_MACHINE="alphaev68" ;; "EV6.8CX (21264D)") UNAME_MACHINE="alphaev68" ;; "EV6.9A (21264/EV69A)") UNAME_MACHINE="alphaev69" ;; "EV7 (21364)") UNAME_MACHINE="alphaev7" ;; "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # Should we change UNAME_MACHINE based on the output of uname instead # of the specific Alpha model? echo alpha-pc-interix exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-unknown-sysv4 exit 0;; *:[Aa]miga[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-amigaos exit 0 ;; *:[Mm]orph[Oo][Ss]:*:*) echo ${UNAME_MACHINE}-unknown-morphos exit 0 ;; *:OS/390:*:*) echo i370-ibm-openedition exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) echo hppa1.1-hitachi-hiuxmpp exit 0;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE*:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; DRS?6000:UNIX_SV:4.2*:7*) case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7 && exit 0 ;; esac ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; sun*:*:4.2BSD:*) UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 case "`/bin/arch`" in sun3) echo m68k-sun-sunos${UNAME_RELEASE} ;; sun4) echo sparc-sun-sunos${UNAME_RELEASE} ;; esac exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; # The situation for MiNT is a little confusing. The machine name # can be virtually everything (everything which is not # "atarist" or "atariste" at least should have a processor # > m68000). The system name ranges from "MiNT" over "FreeMiNT" # to the lowercase version "mint" (or "freemint"). Finally # the system name "TOS" denotes a system which is actually not # MiNT. But MiNT is downward compatible to TOS, so this should # be no problem. atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) echo m68k-atari-mint${UNAME_RELEASE} exit 0 ;; milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) echo m68k-milan-mint${UNAME_RELEASE} exit 0 ;; hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) echo m68k-hades-mint${UNAME_RELEASE} exit 0 ;; *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; 2020:CLIX:*:* | 2430:CLIX:*:*) echo clipper-intergraph-clix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #ifdef __cplusplus #include /* for printf() prototype */ int main (int argc, char *argv[]) { #else int main (argc, argv) int argc; char *argv[]; { #endif #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c \ && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && exit 0 echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Motorola:PowerMAX_OS:*:*) echo powerpc-motorola-powermax exit 0 ;; Motorola:*:4.3:PL8-*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) echo powerpc-harris-powermax exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ [ ${TARGET_BINARY_INTERFACE}x = x ] then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit 0 ;; ia64:AIX:*:*) if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:[45]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[34678]??:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/[678][0-9][0-9]) if [ -x /usr/bin/getconf ]; then sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` case "${sc_cpu_version}" in 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 532) # CPU_PA_RISC2_0 case "${sc_kernel_bits}" in 32) HP_ARCH="hppa2.0n" ;; 64) HP_ARCH="hppa2.0w" ;; '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 esac ;; esac fi if [ "${HP_ARCH}" = "" ]; then eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #define _HPUX_SOURCE #include #include int main () { #if defined(_SC_KERNEL_BITS) long bits = sysconf(_SC_KERNEL_BITS); #endif long cpu = sysconf (_SC_CPU_VERSION); switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0"); break; case CPU_PA_RISC1_1: puts ("hppa1.1"); break; case CPU_PA_RISC2_0: #if defined(_SC_KERNEL_BITS) switch (bits) { case 64: puts ("hppa2.0w"); break; case 32: puts ("hppa2.0n"); break; default: puts ("hppa2.0"); break; } break; #else /* !defined(_SC_KERNEL_BITS) */ puts ("hppa2.0"); break; #endif default: puts ("hppa1.0"); break; } exit (0); } EOF (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` test -z "$HP_ARCH" && HP_ARCH=hppa fi ;; esac if [ ${HP_ARCH} = "hppa2.0w" ] then # avoid double evaluation of $set_cc_for_build test -n "$CC_FOR_BUILD" || eval $set_cc_for_build if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null then HP_ARCH="hppa2.0w" else HP_ARCH="hppa64" fi fi echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; ia64:HP-UX:*:*) HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ia64-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF $CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0 echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) echo hppa1.0-hp-mpeix exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i*86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*T3E:*:*:*) echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; CRAY*SV1:*:*:*) echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; sparc*:BSD/OS:*:*) echo sparc-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:BSD/OS:*:*) echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*|*:GNU/FreeBSD:*:*) # Determine whether the default compiler uses glibc. eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #if __GLIBC__ >= 2 LIBC=gnu #else LIBC= #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin exit 0 ;; i*:MINGW*:*) echo ${UNAME_MACHINE}-pc-mingw32 exit 0 ;; i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit 0 ;; x86:Interix*:3*) echo i586-pc-interix3 exit 0 ;; [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit 0 ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we # UNAME_MACHINE based on the output of uname instead of i386? echo i586-pc-interix exit 0 ;; i*:UWIN*:*) echo ${UNAME_MACHINE}-pc-uwin exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit 0 ;; arm*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; cris:Linux:*:*) echo cris-axis-linux-gnu exit 0 ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; mips:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips #undef mipsel #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mipsel #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU #undef mips64 #undef mips64el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) CPU=mips64el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) CPU=mips64 #else CPU= #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=` test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0 ;; ppc:Linux:*:*) echo powerpc-unknown-linux-gnu exit 0 ;; ppc64:Linux:*:*) echo powerpc64-unknown-linux-gnu exit 0 ;; alpha:Linux:*:*) case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; PCA57) UNAME_MACHINE=alphapca56 ;; EV6) UNAME_MACHINE=alphaev6 ;; EV67) UNAME_MACHINE=alphaev67 ;; EV68*) UNAME_MACHINE=alphaev68 ;; esac objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} exit 0 ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in PA7*) echo hppa1.1-unknown-linux-gnu ;; PA8*) echo hppa2.0-unknown-linux-gnu ;; *) echo hppa-unknown-linux-gnu ;; esac exit 0 ;; parisc64:Linux:*:* | hppa64:Linux:*:*) echo hppa64-unknown-linux-gnu exit 0 ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux exit 0 ;; sh*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; x86_64:Linux:*:*) echo x86_64-unknown-linux-gnu exit 0 ;; i*86:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. cd to the root directory to prevent # problems with other programs or directories called `ld' in the path. # Set LC_ALL=C to ensure ld outputs messages in English. ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ | sed -ne '/supported targets:/!d s/[ ][ ]*/ /g s/.*supported targets: *// s/ .*// p'` case "$ld_supported_targets" in elf32-i386) TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" ;; a.out-i386-linux) echo "${UNAME_MACHINE}-pc-linux-gnuaout" exit 0 ;; coff-i386) echo "${UNAME_MACHINE}-pc-linux-gnucoff" exit 0 ;; "") # Either a pre-BFD a.out linker (linux-gnuoldld) or # one that does not give us useful --help. echo "${UNAME_MACHINE}-pc-linux-gnuoldld" exit 0 ;; esac # Determine whether the default compiler is a.out or elf eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #include #ifdef __ELF__ # ifdef __GLIBC__ # if __GLIBC__ >= 2 LIBC=gnu # else LIBC=gnulibc1 # endif # else LIBC=gnulibc1 # endif #else #ifdef __INTEL_COMPILER LIBC=gnu #else LIBC=gnuaout #endif #endif EOF eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0 test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0 ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both # sysname and nodename. echo i386-sequent-sysv4 exit 0 ;; i*86:UNIX_SV:4.2MP:2.*) # Unixware is an offshoot of SVR4, but it has its own version # number series starting with 2... # I am not positive that other SVR4 systems won't match this, # I just have to hope. -- rms. # Use sysv4.2uw... so that sysv4* matches it. echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} exit 0 ;; i*86:OS/2:*:*) # If we were able to find `uname', then EMX Unix compatibility # is probably installed. echo ${UNAME_MACHINE}-pc-os2-emx exit 0 ;; i*86:XTS-300:*:STOP) echo ${UNAME_MACHINE}-unknown-stop exit 0 ;; i*86:atheos:*:*) echo ${UNAME_MACHINE}-unknown-atheos exit 0 ;; i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; i*86:*DOS:*:*) echo ${UNAME_MACHINE}-pc-msdosdjgpp exit 0 ;; i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} fi exit 0 ;; i*86:*:5:[78]*) case `/bin/uname -X | grep "^Machine"` in *486*) UNAME_MACHINE=i486 ;; *Pentium) UNAME_MACHINE=i586 ;; *Pent*|*Celeron) UNAME_MACHINE=i686 ;; esac echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} exit 0 ;; i*86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ && UNAME_MACHINE=i686 (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ && UNAME_MACHINE=i686 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about # the processor, so we play safe by assuming i386. echo i386-pc-msdosdjgpp exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; mc68k:UNIX:SYSTEM5:3.51m) echo m68k-convergent-sysv exit 0 ;; M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:ReliantUNIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; *:VOS:*:*) # From Paul.Green@stratus.com. echo hppa1.1-stratus-vos exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; news*:NEWS-OS:6*:*) echo mips-sony-newsos6 exit 0 ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. echo powerpc-be-beos exit 0 ;; BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. echo powerpc-apple-beos exit 0 ;; BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit 0 ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit 0 ;; SX-5:SUPER-UX:*:*) echo sx5-nec-superux${UNAME_RELEASE} exit 0 ;; SX-6:SUPER-UX:*:*) echo sx6-nec-superux${UNAME_RELEASE} exit 0 ;; Power*:Rhapsody:*:*) echo powerpc-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Rhapsody:*:*) echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) case `uname -p` in *86) UNAME_PROCESSOR=i686 ;; powerpc) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) UNAME_PROCESSOR=`uname -p` if test "$UNAME_PROCESSOR" = "x86"; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc fi echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} exit 0 ;; *:QNX:*:4*) echo i386-pc-qnx exit 0 ;; NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*) echo nsr-tandem-nsk${UNAME_RELEASE} exit 0 ;; *:NonStop-UX:*:*) echo mips-compaq-nonstopux exit 0 ;; BS2000:POSIX*:*:*) echo bs2000-siemens-sysv exit 0 ;; DS/*:UNIX_System_V:*:*) echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} exit 0 ;; *:Plan9:*:*) # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. if test "$cputype" = "386"; then UNAME_MACHINE=i386 else UNAME_MACHINE="$cputype" fi echo ${UNAME_MACHINE}-unknown-plan9 exit 0 ;; *:TOPS-10:*:*) echo pdp10-unknown-tops10 exit 0 ;; *:TENEX:*:*) echo pdp10-unknown-tenex exit 0 ;; KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) echo pdp10-dec-tops20 exit 0 ;; XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) echo pdp10-xkl-tops20 exit 0 ;; *:TOPS-20:*:*) echo pdp10-unknown-tops20 exit 0 ;; *:ITS:*:*) echo pdp10-unknown-its exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 eval $set_cc_for_build cat >$dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; if (version < 4) printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); else printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) # if !defined (ultrix) # include # if defined (BSD) # if BSD == 43 printf ("vax-dec-bsd4.3\n"); exit (0); # else # if BSD == 199006 printf ("vax-dec-bsd4.3reno\n"); exit (0); # else printf ("vax-dec-bsd\n"); exit (0); # endif # endif # else printf ("vax-dec-bsd\n"); exit (0); # endif # else printf ("vax-dec-ultrix\n"); exit (0); # endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0 # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi cat >&2 < in order to provide the needed information to handle your system. config.guess timestamp = $timestamp uname -m = `(uname -m) 2>/dev/null || echo unknown` uname -r = `(uname -r) 2>/dev/null || echo unknown` uname -s = `(uname -s) 2>/dev/null || echo unknown` uname -v = `(uname -v) 2>/dev/null || echo unknown` /usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` /bin/uname -X = `(/bin/uname -X) 2>/dev/null` hostinfo = `(hostinfo) 2>/dev/null` /bin/universe = `(/bin/universe) 2>/dev/null` /usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` /bin/arch = `(/bin/arch) 2>/dev/null` /usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` UNAME_MACHINE = ${UNAME_MACHINE} UNAME_RELEASE = ${UNAME_RELEASE} UNAME_SYSTEM = ${UNAME_SYSTEM} UNAME_VERSION = ${UNAME_VERSION} EOF exit 1 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: KoboDeluxe-0.5.1/config.sub0000755000175000001440000007247407662554552012514 00000000000000#! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # 2000, 2001, 2002, 2003 Free Software Foundation, Inc. timestamp='2003-05-09' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Please send patches to . Submit a context # diff and a properly formatted ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. me=`echo "$0" | sed -e 's,.*/,,'` usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS $0 [OPTION] ALIAS Canonicalize a configuration name. Operation modes: -h, --help print this help, then exit -t, --time-stamp print date of last modification, then exit -v, --version print version number, then exit Report bugs and patches to ." version="\ GNU config.sub ($timestamp) Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." help=" Try \`$me --help' for more information." # Parse command line while test $# -gt 0 ; do case $1 in --time-stamp | --time* | -t ) echo "$timestamp" ; exit 0 ;; --version | -v ) echo "$version" ; exit 0 ;; --help | --h* | -h ) echo "$usage"; exit 0 ;; -- ) # Stop option processing shift; break ;; - ) # Use stdin as input. break ;; -* ) echo "$me: invalid option $1$help" exit 1 ;; *local*) # First pass through any local machine types. echo $1 exit 0;; * ) break ;; esac done case $# in 0) echo "$me: missing argument$help" >&2 exit 1;; 1) ;; *) echo "$me: too many arguments$help" >&2 exit 1;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu* | freebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple | -axis) os= basic_machine=$1 ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 ;; -scout) ;; -wrs) os=-vxworks basic_machine=$1 ;; -chorusos*) os=-chorusos basic_machine=$1 ;; -chorusrdb) os=-chorusrdb basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=-sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -udk*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; -mint | -mint[0-9]*) basic_machine=m68k-atari os=-mint ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. 1750a | 580 \ | a29k \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | clipper \ | d10v | d30v | dlx | dsp16xx \ | fr30 | frv \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k \ | m32r | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ | mips64vr | mips64vrel \ | mips64orion | mips64orionel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ | mipsisa32 | mipsisa32el \ | mipsisa32r2 | mipsisa32r2el \ | mipsisa64 | mipsisa64el \ | mipsisa64sb1 | mipsisa64sb1el \ | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ | msp430 \ | ns16k | ns32k \ | openrisc | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic80 | tron \ | v850 | v850e \ | we32k \ | x86 | xscale | xstormy16 | xtensa \ | z8k) basic_machine=$basic_machine-unknown ;; m6811 | m68hc11 | m6812 | m68hc12) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none ;; m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i*86 | x86_64) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. 580-* \ | a29k-* \ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | clipper-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | h8300-* | h8500-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* \ | m32r-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ | mips64vr-* | mips64vrel-* \ | mips64orion-* | mips64orionel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ | mipsisa32-* | mipsisa32el-* \ | mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa64-* | mipsisa64el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ | msp430-* \ | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ | romp-* | rs6000-* \ | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | xtensa-* \ | ymp-* \ | z8k-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 386bsd) basic_machine=i386-unknown os=-bsd ;; 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; a29khif) basic_machine=a29k-amd os=-udi ;; adobe68k) basic_machine=m68010-adobe os=-scout ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amd64) basic_machine=x86_64-pc ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-unknown ;; amigaos | amigados) basic_machine=m68k-unknown os=-amigaos ;; amigaunix | amix) basic_machine=m68k-unknown os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; apollo68bsd) basic_machine=m68k-apollo os=-bsd ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; c90) basic_machine=c90-cray os=-unicos ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | j90) basic_machine=j90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; decsystem10* | dec10*) basic_machine=pdp10-dec os=-tops10 ;; decsystem20* | dec20*) basic_machine=pdp10-dec os=-tops20 ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; es1800 | OSE68k | ose68k | ose | OSE) basic_machine=m68k-ericsson os=-ose ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; go32) basic_machine=i386-pc os=-go32 ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; h8300xray) basic_machine=h8300-hitachi os=-xray ;; h8500hms) basic_machine=h8500-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp3k9[0-9][0-9] | hp9[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k6[0-9][0-9] | hp6[0-9][0-9]) basic_machine=hppa1.0-hp ;; hp9k7[0-79][0-9] | hp7[0-79][0-9]) basic_machine=hppa1.1-hp ;; hp9k78[0-9] | hp78[0-9]) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) # FIXME: really hppa2.0-hp basic_machine=hppa1.1-hp ;; hp9k8[0-9][13679] | hp8[0-9][13679]) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; hppaosf) basic_machine=hppa1.1-hp os=-osf ;; hppro) basic_machine=hppa1.1-hp os=-proelf ;; i370-ibm* | ibm*) basic_machine=i370-ibm ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i*86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i*86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i*86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i*86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; i386mach) basic_machine=i386-mach os=-mach ;; i386-vsta | vsta) basic_machine=i386-unknown os=-vsta ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; mingw32) basic_machine=i386-pc os=-mingw32 ;; miniframe) basic_machine=m68000-convergent ;; *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) basic_machine=m68k-atari os=-mint ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; mmix*) basic_machine=mmix-knuth os=-mmixware ;; monitor) basic_machine=m68k-rom68k os=-coff ;; morphos) basic_machine=powerpc-unknown os=-morphos ;; msdos) basic_machine=i386-pc os=-msdos ;; mvs) basic_machine=i370-ibm os=-mvs ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; netbsd386) basic_machine=i386-unknown os=-netbsd ;; netwinder) basic_machine=armv4l-rebel os=-linux ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; necv70) basic_machine=v70-nec os=-sysv ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; mon960) basic_machine=i960-intel os=-mon960 ;; nonstopux) basic_machine=mips-compaq os=-nonstopux ;; np1) basic_machine=np1-gould ;; nv1) basic_machine=nv1-cray os=-unicosmp ;; nsr-tandem) basic_machine=nsr-tandem ;; op50n-* | op60c-*) basic_machine=hppa1.1-oki os=-proelf ;; or32 | or32-*) basic_machine=or32-unknown os=-coff ;; OSE68000 | ose68000) basic_machine=m68000-ericsson os=-ose ;; os68k) basic_machine=m68k-none os=-os68k ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5 | k5 | k6 | nexgen | viac3) basic_machine=i586-pc ;; pentiumpro | p6 | 6x86 | athlon | athlon_*) basic_machine=i686-pc ;; pentiumii | pentium2) basic_machine=i686-pc ;; pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-* | 6x86-* | athlon-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumii-* | pentium2-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pn) basic_machine=pn-gould ;; power) basic_machine=power-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64) basic_machine=powerpc64-unknown ;; ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppc64le | powerpc64little | ppc64-le | powerpc64-little) basic_machine=powerpc64le-unknown ;; ppc64le-* | powerpc64little-*) basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; pw32) basic_machine=i586-unknown os=-pw32 ;; rom68k) basic_machine=m68k-rom68k os=-coff ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; s390 | s390-*) basic_machine=s390-ibm ;; s390x | s390x-*) basic_machine=s390x-ibm ;; sa29200) basic_machine=a29k-amd os=-udi ;; sb1) basic_machine=mipsisa64sb1-unknown ;; sb1el) basic_machine=mipsisa64sb1el-unknown ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sparclite-wrs | simso-wrs) basic_machine=sparclite-wrs os=-vxworks ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; st2000) basic_machine=m68k-tandem ;; stratus) basic_machine=i860-stratus os=-sysv4 ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; sv1) basic_machine=sv1-cray os=-unicos ;; symmetry) basic_machine=i386-sequent os=-dynix ;; t3e) basic_machine=alphaev5-cray os=-unicos ;; t90) basic_machine=t90-cray os=-unicos ;; tic4x | c4x*) basic_machine=tic4x-unknown os=-coff ;; tic54x | c54x*) basic_machine=tic54x-unknown os=-coff ;; tic55x | c55x*) basic_machine=tic55x-unknown os=-coff ;; tic6x | c6x*) basic_machine=tic6x-unknown os=-coff ;; tx39) basic_machine=mipstx39-unknown ;; tx39el) basic_machine=mipstx39el-unknown ;; toad1) basic_machine=pdp10-xkl os=-tops20 ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; v810 | necv810) basic_machine=v810-nec os=-none ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; w65*) basic_machine=w65-wdc os=-none ;; w89k-*) basic_machine=hppa1.1-winbond os=-proelf ;; xps | xps100) basic_machine=xps100-honeywell ;; ymp) basic_machine=ymp-cray os=-unicos ;; z8k-*-coff) basic_machine=z8k-unknown os=-sim ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. w89k) basic_machine=hppa1.1-winbond ;; op50n) basic_machine=hppa1.1-oki ;; op60c) basic_machine=hppa1.1-oki ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp10) # there are many clones, so DEC is not a safe bet basic_machine=pdp10-unknown ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sh64) basic_machine=sh64-unknown ;; sparc | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; mac | mpw | mac-mpw) basic_machine=m68k-apple ;; pmac | pmac-mpw) basic_machine=powerpc-apple ;; *-unknown) # Make sure to match an already-canonicalized machine name. ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -svr4*) os=-sysv4 ;; -unixware*) os=-sysv4.2uw ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i*86-*) ;; *) os=-nto$os ;; esac ;; -nto-qnx*) ;; -nto*) os=`echo $os | sed -e 's|nto|nto-qnx|'` ;; -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) ;; -mac*) os=`echo $os | sed -e 's|mac|macos|'` ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -opened*) os=-openedition ;; -wince*) os=-wince ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -atheos*) os=-atheos ;; -386bsd) os=-bsd ;; -ctix* | -uts*) os=-sysv ;; -nova*) os=-rtmk-nova ;; -ns2 ) os=-nextstep2 ;; -nsk*) os=-nsk ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -ose*) os=-ose ;; -es1800*) os=-ose ;; -xenix) os=-xenix ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) os=-mint ;; -aros*) os=-aros ;; -kaos*) os=-kaos ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-rebel) os=-linux ;; arm*-semi) os=-aout ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; m68*-cisco) os=-aout ;; mips*-cisco) os=-elf ;; mips*-*) os=-elf ;; or32-*) os=-coff ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-be) os=-beos ;; *-ibm) os=-aix ;; *-wec) os=-proelf ;; *-winbond) os=-proelf ;; *-oki) os=-proelf ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigaos ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f30[01]-fujitsu | f700-fujitsu) os=-uxpv ;; *-rom68k) os=-coff ;; *-*bug) os=-coff ;; *-apple) os=-macos ;; *-atari*) os=-mint ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -beos*) vendor=be ;; -hpux*) vendor=hp ;; -mpeix*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs* | -opened*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks* | -windiss*) vendor=wrs ;; -aux*) vendor=apple ;; -hms*) vendor=hitachi ;; -mpw* | -macos*) vendor=apple ;; -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) vendor=atari ;; -vos*) vendor=stratus ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "timestamp='" # time-stamp-format: "%:y-%02m-%02d" # time-stamp-end: "'" # End: KoboDeluxe-0.5.1/depcomp0000755000175000001440000002752507366242630012073 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects # Copyright 1999, 2000 Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # `libtool' can also be set to `yes' or `no'. depfile=${depfile-`echo "$object" | sed 's,\([^/]*\)$,.deps/\1,;s/\.\([^.]*\)$/.P\1/'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> $depfile echo >> $depfile # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> $depfile else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. This file always lives in the current directory. # Also, the AIX compiler puts `$object:' at the start of each line; # $object doesn't have directory information. stripped=`echo "$object" | sed -e 's,^.*/,,' -e 's/\(.*\)\..*$/\1/'` tmpdepfile="$stripped.u" outname="$stripped.o" if test "$libtool" = yes; then "$@" -Wc,-M else "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; tru64) # The Tru64 AIX compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. tmpdepfile1="$object.d" tmpdepfile2=`echo "$object" | sed -e 's/.o$/.d/'` if test "$libtool" = yes; then "$@" -Wc,-MD else "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi if test -f "$tmpdepfile1"; then tmpdepfile="$tmpdepfile1" else tmpdepfile="$tmpdepfile2" fi if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a space and a tab in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. test -z "$dashmflag" && dashmflag=-M ( IFS=" " case " $* " in *" --mode=compile "*) # this is libtool, let us make it quiet for arg do # cycle over the arguments case "$arg" in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" $dashmflag | sed 's:^[^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) # X makedepend ( shift cleared=no for arg in "$@"; do case $cleared in no) set ""; shift cleared=yes esac case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift;; -*) ;; *) set fnord "$@" "$arg"; shift;; esac done obj_suffix="`echo $object | sed 's/^.*\././'`" touch "$tmpdepfile" ${MAKEDEPEND-makedepend} 2>/dev/null -o"$obj_suffix" -f"$tmpdepfile" "$@" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tail +3 "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the proprocessed file to stdout, regardless of -o, # because we must use -o when running libtool. ( IFS=" " case " $* " in *" --mode=compile "*) for arg do # cycle over the arguments case $arg in "--mode=compile") # insert --quiet before "--mode=compile" set fnord "$@" --quiet shift # fnord ;; esac set fnord "$@" "$arg" shift # fnord shift # "$arg" done ;; esac "$@" -E | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" ) & proc=$! "$@" stat=$? wait "$proc" if test "$stat" != 0; then exit $stat; fi rm -f "$depfile" echo "$object : \\" > "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 KoboDeluxe-0.5.1/install-sh0000755000175000001440000001273607366242627012526 00000000000000#!/bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: chmodcmd="" else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 KoboDeluxe-0.5.1/missing0000755000175000001440000002123107366242627012107 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. # Copyright 1996, 1997, 1999, 2000 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2, or (at your option) # any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi case "$1" in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case "$1" in -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file tar try tar, gnutar, gtar, then tar without non-portable flags yacc create \`y.tab.[ch]', if possible, from existing .[ch]" ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing 0.3 - GNU automake" ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; aclocal) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case "$f" in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; bison|yacc) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" y.tab.h fi ;; esac fi if [ ! -f y.tab.h ]; then echo >y.tab.h fi if [ ! -f y.tab.c ]; then echo 'main() { return 0; }' >y.tab.c fi ;; lex|flex) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if [ $# -ne 1 ]; then eval LASTARG="\${$#}" case "$LASTARG" in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if [ -f "$SRCFILE" ]; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if [ ! -f lex.yy.c ]; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man) echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` fi if [ -f "$file" ]; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit 1 fi ;; makeinfo) if test -z "$run" && (makeinfo --version) > /dev/null 2>&1; then # We have makeinfo, but it failed. exit 1 fi echo 1>&2 "\ WARNING: \`$1' is missing on your system. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` if test -z "$file"; then file=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $file` fi touch $file ;; tar) shift if test -n "$run"; then echo 1>&2 "ERROR: \`tar' requires --run" exit 1 fi # We have already tried tar in the generic part. # Look for gnutar/gtar before invocation to avoid ugly error # messages. if (gnutar --version > /dev/null 2>&1); then gnutar ${1+"$@"} && exit 0 fi if (gtar --version > /dev/null 2>&1); then gtar ${1+"$@"} && exit 0 fi firstarg="$1" if shift; then case "$firstarg" in *o*) firstarg=`echo "$firstarg" | sed s/o//` tar "$firstarg" ${1+"$@"} && exit 0 ;; esac case "$firstarg" in *h*) firstarg=`echo "$firstarg" | sed s/h//` tar "$firstarg" ${1+"$@"} && exit 0 ;; esac fi echo 1>&2 "\ WARNING: I can't seem to be able to run \`tar' with the given arguments. You may want to install GNU tar or Free paxutils, or check the command line arguments." exit 1 ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and you do not seem to have it handy on your system. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequirements for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 KoboDeluxe-0.5.1/mkinstalldirs0000755000175000001440000000132207366242627013315 00000000000000#! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.13 1999/01/05 03:18:55 bje Exp $ errstatus=0 for file do set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here KoboDeluxe-0.5.1/enemies.cpp0000666000175000001440000000755210733636272012652 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001, 2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "enemies.h" #include "random.h" #include "radar.h" _enemy _enemies::enemy[ENEMY_MAX]; _enemy *_enemies::enemy_max; const enemy_kind *_enemies::ekind_to_generate_1; const enemy_kind *_enemies::ekind_to_generate_2; int _enemies::e1_interval; int _enemies::e2_interval; int _enemies::explocount = 0; int _enemies::is_intro = 0; _enemy::_enemy() { object = NULL; _state = notuse; } void _enemy::state(_state_t s) { switch(s) { case notuse: if(object) { gengine->free_obj(object); object = NULL; } break; case reserved: case moving: if(bank >= 0) { if(!object) object = gengine->get_obj(ek->layer); if(!object) break; if(s == moving) cs_obj_show(object); else cs_obj_hide(object); } else if(object) { gengine->free_obj(object); object = NULL; } break; } _state = s; } void _enemies::off() { _enemy *enemyp; for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) enemyp->release(); } int _enemies::init() { _enemy *enemyp; for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) enemyp->init(); enemy_max = enemy; ekind_to_generate_1 = NULL; ekind_to_generate_2 = NULL; e1_interval = 1; e2_interval = 1; return 0; } void _enemies::move() { _enemy *enemyp; /* realize reserved enemies */ for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) { if(enemyp->realize()) enemy_max = enemyp; } for(enemyp = enemy; enemyp <= enemy_max; enemyp++) enemyp->move(); } void _enemies::move_intro() { _enemy *enemyp; is_intro = 1; /* realize reserved enemies */ for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) { if(enemyp->realize()) enemy_max = enemyp; } for(enemyp = enemy; enemyp <= enemy_max; enemyp++) enemyp->move_intro(); is_intro = 0; } void _enemies::put() { _enemy *enemyp; for(enemyp = enemy; enemyp <= enemy_max; enemyp++) enemyp->put(); } int _enemies::make(const enemy_kind * ek, int x, int y, int h, int v, int di) { _enemy *enemyp; for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) if(!enemyp->make(ek, x, y, h, v, di)) return 0; return 1; } const enemy_kind *_enemies::randexp() { explocount += 1 + pubrand.get(1); switch(explocount & 3) { case 0: return &explosion; case 1: return &explosion3; case 2: return &explosion4; default: return &explosion5; } } int _enemies::erase_cannon(int x, int y) { int count = 0; _enemy *enemyp; for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) count += enemyp->erase_cannon(x, y); if(count) wradar->update(x, y); return count; } int _enemies::exist_pipe() { int count = 0; _enemy *enemyp; for(enemyp = enemy; enemyp < enemy + ENEMY_MAX; enemyp++) if(enemyp->is_pipe()) count++; return count; } void _enemies::set_ekind_to_generate(const enemy_kind * e1, int i1, const enemy_kind * e2, int i2) { ekind_to_generate_1 = e1; ekind_to_generate_2 = e2; e1_interval = i1; e2_interval = i2; } KoboDeluxe-0.5.1/enemy.cpp0000666000175000001440000006652110733705676012350 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "screen.h" #include "manage.h" #include "enemies.h" #include "myship.h" #include "random.h" #include /////////////////////////////////////////////////////////////////////////////// // Fast integer atan() approximation. Input is 24:8 fixed point. // Output is 0..64 for 0..45 deg, accurate accurate down to LSB. // In: q = 256 * minv / maxv (0..256 <==> 0..1) // Out: atan(q / 256) * 256 (0..64 <==> 0..45 deg) /////////////////////////////////////////////////////////////////////////////// // atan() approximations for 0..9 deg: // a = 83 * q / 256 - q*q / 2844 (+/- 2.1%) // a = 82 * q / 256 - k*k / 8500 - x*x*x / 1600000 (+/- 0.6%) /////////////////////////////////////////////////////////////////////////////// static inline int fastatan(int q) { int q2 = q * q; int q3 = q2 * q; return (82 * q >> 8) - (62 * q2 >> 19) - (10 * q3 >> 24); } static int speed2dir(int sx, int sy, int frames) { if(!sx && !sy) return 0; int at2; if(sx > 0) { // Right if(sy < 0) { // Top-right quadrant sy = -sy; if(sy > sx) at2 = fastatan(sx * 256 / sy); else at2 = 128 - fastatan(sy * 256 / sx); } else { // Bottom-right quadrant if(sx > sy) at2 = 128 + fastatan(sy * 256 / sx); else at2 = 256 - fastatan(sx * 256 / sy); } } else { // Left sx = -sx; if(sy > 0) { // Bottom-left quadrant if(sy > sx) at2 = 256 + fastatan(sx * 256 / sy); else at2 = 384 - fastatan(sy * 256 / sx); } else { // Top-left quadrant sy = -sy; if(sx > sy) at2 = 384 + fastatan(sy * 256 / sx); else at2 = 512 - fastatan(sx * 256 / sy); } } at2 = (at2 * frames + 256) >> 9; return at2 > frames - 1 ? 1 : at2 + 1; } /* * =========================================================================== * (template) * =========================================================================== */ inline void _enemy::move_enemy_m(int quick, int maxspeed) { if(diffx > 0) { if(h > -maxspeed) h -= quick; } else if(diffx < 0) { if(h < maxspeed) h += quick; } if(diffy > 0) { if(v > -maxspeed) v -= quick; } else if(diffy < 0) { if(v < maxspeed) v += quick; } } inline void _enemy::move_enemy_template(int quick, int maxspeed) { if(diffx > 0) { if(h > -maxspeed) h -= quick; } else if(diffx < 0) { if(h < maxspeed) h += quick; } if(diffy > 0) { if(v > -maxspeed) v -= quick; } else if(diffy < 0) { if(v < maxspeed) v += quick; } int ndi = speed2dir(h, v, 16); if(ndi > 0) di = ndi; } inline void _enemy::move_enemy_template_2(int quick, int maxspeed) { h = -PIXEL2CS(diffy) / (1< 0) { if(h > -maxspeed) h -= quick; } else if(diffx < 0) { if(h < maxspeed) h += quick; } if(diffy > 0) { if(v > -maxspeed) v -= quick; } else if(diffy < 0) { if(v < maxspeed) v += quick; } int ndi = speed2dir(h, v, 16); if(ndi > 0) di = ndi; } inline void _enemy::move_enemy_template_3(int quick, int maxspeed) { h = PIXEL2CS(diffy) / (1< 0) { if(h > -maxspeed) h -= quick; } else if(diffx < 0) { if(h < maxspeed) h += quick; } if(diffy > 0) { if(v > -maxspeed) v -= quick; } else if(diffy < 0) { if(v < maxspeed) v += quick; } int ndi = speed2dir(h, v, 16); if(ndi > 0) di = ndi; } inline void _enemy::shot_template(const enemy_kind * ekp, int shift, int rnd, int maxspeed) { int vx = -diffx; int vy = -diffy; if(rnd) { vx += gamerand.get() & (rnd - 1) - (rnd >> 1); vy += gamerand.get() & (rnd - 1) - (rnd >> 1); } vx = PIXEL2CS(vx) / (1< 0) { if(vx > maxspeed) vx = maxspeed; else if(vx < -maxspeed) vx = -maxspeed; if(vy > maxspeed) vy = maxspeed; else if(vy < -maxspeed) vy = -maxspeed; } enemies.make(ekp, CS2PIXEL(x + vx), CS2PIXEL(y + vy), vx, vy); if(enemies.is_intro) return; if(&ring == ekp) sound.g_launch_ring(x, y); else if(&beam == ekp) sound.g_launch_beam(x, y); else if(&bomb1 == ekp || &bomb2 == ekp) sound.g_launch_bomb(x, y); else sound.g_launch(x, y); } void _enemy::shot_template_8_dir(const enemy_kind * ekp) { static int vx[] = { 0, 200, 300, 200, 0, -200, -300, -200 }; static int vy[] = { -300, -200, 0, 200, 300, 200, 0, -200 }; int i; for(i = 0; i < 8; i++) enemies.make(ekp, CS2PIXEL(x), CS2PIXEL(y), vx[i], vy[i]); if(&ring == ekp) sound.g_m_launch_ring(x, y); else if(&beam == ekp) sound.g_m_launch_beam(x, y); else if(&bomb1 == ekp || &bomb2 == ekp) sound.g_m_launch_bomb(x, y); else sound.g_m_launch(x, y); } void _enemy::kill_default() { enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), h >> 1, v >> 1); sound.g_enemy_explo(x, y); release(); } /* * =========================================================================== * beam * =========================================================================== */ void _enemy::make_beam() { di = 1 + pubrand.get(4); health = 1; shootable = 0; damage = 20; } void _enemy::move_beam() { if(norm >= ((VIEWLIMIT >> 1) + 32)) release(); di += pubrand.get(1) + 1; if(di > 16) di = 1; } void _enemy::kill_beam() { enemies.make(&beamexpl, CS2PIXEL(x), CS2PIXEL(y)); release(); } const enemy_kind beam = { 0, &_enemy::make_beam, &_enemy::move_beam, &_enemy::kill_beam, 2, B_BULLETS, 0, LAYER_BULLETS }; /* * =========================================================================== * rock * =========================================================================== */ void _enemy::make_rock() { count = 500; health = game.rock_health; damage = game.rock_damage; di = gamerand.get(5) + 1; a = gamerand.get(1) ? 1 : -1; switch(gamerand.get() % 3) { case 0: bank = B_ROCK1; break; case 1: bank = B_ROCK2; break; case 2: bank = B_ROCK3; break; } } void _enemy::move_rock() { if(bank == B_ROCK3) { di += a; if(di < 1) di += 48; else if(di > 48) di -= 48; } else di = ((di + a - 1) & 31) + 1; } void _enemy::kill_rock() { enemies.make(&rockexpl, CS2PIXEL(x), CS2PIXEL(y), h >> 1, v >> 1); sound.g_rock_explo(x, y); release(); } const enemy_kind rock = { 10, &_enemy::make_rock, &_enemy::move_rock, &_enemy::kill_rock, 4, B_ROCK1, 0, LAYER_ENEMIES }; /* * =========================================================================== * ring * =========================================================================== */ void _enemy::make_ring() { count = 500; health = 20; damage = 30; di = 1; } void _enemy::move_ring() { di += 1 + pubrand.get(1); if(di > 16) di = 1; } void _enemy::kill_ring() { enemies.make(&ringexpl, CS2PIXEL(x), CS2PIXEL(y), h >> 1, v >> 1); sound.g_ring_explo(x, y); release(); } const enemy_kind ring = { 1, &_enemy::make_ring, &_enemy::move_ring, &_enemy::kill_ring, 4, B_RING, 0, LAYER_BULLETS }; /* * =========================================================================== * bomb * =========================================================================== */ void _enemy::make_bomb() { count = 500; health = 20; damage = 70; di = 1; } void _enemy::move_bomb1() { int h1 = ABS(diffx); int v1 = ABS(diffy); if(((h1 < 100) && (v1 < 30)) || (h1 < 30) && (v1 < 100)) { int vx1 = PIXEL2CS(-diffx) / (3*8); int vy1 = PIXEL2CS(-diffy) / (3*8); int vx2 = vx1, vx3 = vx1; int vy2 = vy1, vy3 = vy1; int i; for(i = 0; i < 4; i++) { int tmp = vx2; vx2 += (vy2 >> 4); vy2 -= (tmp >> 4); tmp = vx3; vx3 -= (vy3 >> 4); vy3 += (tmp >> 4); } enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx2, vy2); enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx3, vy3); enemies.make(&bombdeto, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); sound.g_bomb_deto(x, y); release(); } if(++di > 16) di = 1; } const enemy_kind bomb1 = { 5, &_enemy::make_bomb, &_enemy::move_bomb1, &_enemy::kill_default, 5, B_BOMB, 0, LAYER_ENEMIES }; /* * =========================================================================== * bomb2 * =========================================================================== */ void _enemy::move_bomb2() { int h1 = ABS(diffx); int v1 = ABS(diffy); if(((h1 < 100) && (v1 < 20)) || (h1 < 20) && (v1 < 100)) { int vx1 = PIXEL2CS(-diffx) / (3*8); int vy1 = PIXEL2CS(-diffy) / (3*8); int vx2 = vx1, vx3 = vx1; int vy2 = vy1, vy3 = vy1; int i; for(i = 0; i < 6; i++) { int tmp = vx2; vx2 += (vy2 >> 4); vy2 -= (tmp >> 4); tmp = vx3; vx3 -= (vy3 >> 4); vy3 += (tmp >> 4); } int vx4 = vx2, vx5 = vx3; int vy4 = vy2, vy5 = vy3; for(i = 0; i < 6; i++) { int tmp = vx2; vx2 += (vy2 >> 4); vy2 -= (tmp >> 4); tmp = vx3; vx3 -= (vy3 >> 4); vy3 += (tmp >> 4); } enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx2, vy2); enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx3, vy3); enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx4, vy4); enemies.make(&beam, CS2PIXEL(x), CS2PIXEL(y), vx5, vy5); enemies.make(&bombdeto, CS2PIXEL(x), CS2PIXEL(y), vx1, vy1); sound.g_bomb_deto(x, y); release(); } if(--di < 1) di = 16; } const enemy_kind bomb2 = { 20, &_enemy::make_bomb, &_enemy::move_bomb2, &_enemy::kill_default, 5, B_BOMB, 0, LAYER_ENEMIES }; /* * =========================================================================== * explosionX * Various explosions * =========================================================================== */ void _enemy::make_expl() { health = 1; damage = 0; shootable = 0; switch(bank) { case B_EXPLO1: case B_BOMBDETO: a = 8; break; case B_EXPLO3: case B_EXPLO4: case B_EXPLO5: case B_ROCKEXPL: a = 12; break; case B_RINGEXPL: frame = 8 * pubrand.get(1); a = 8; break; case B_BULLETEXPL: a = 6; break; case B_BOLTEXPL: frame = 6 * pubrand.get(1); di = pubrand.get(2); a = 6; break; } } void _enemy::move_expl() { if(++di > a) release(); } const enemy_kind explosion = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_EXPLO1, 0, LAYER_FX }; const enemy_kind explosion3 = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_EXPLO3, 0, LAYER_FX }; const enemy_kind explosion4 = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_EXPLO4, 0, LAYER_FX }; const enemy_kind explosion5 = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_EXPLO5, 0, LAYER_FX }; /* * =========================================================================== * ringexpl * Ring dies in a flash * =========================================================================== */ const enemy_kind ringexpl = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_RINGEXPL, 0, LAYER_FX }; /* * =========================================================================== * beamexpl * Enemy "bullet" discharges * =========================================================================== */ const enemy_kind beamexpl = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_BULLETEXPL, 0, LAYER_FX }; /* * =========================================================================== * boltexpl * Player bolt discharges * =========================================================================== */ const enemy_kind boltexpl = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_BOLTEXPL, 0, LAYER_FX }; /* * =========================================================================== * rockexpl * Rock *finally* explodes * =========================================================================== */ const enemy_kind rockexpl = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_ROCKEXPL, 0, LAYER_FX }; /* * =========================================================================== * bombdeto * Bomb detonation (not really an explosion!) * =========================================================================== */ const enemy_kind bombdeto = { 0, &_enemy::make_expl, &_enemy::move_expl, &_enemy::kill_default, -1, B_BOMBDETO, 0, LAYER_ENEMIES }; /* * =========================================================================== * cannon * =========================================================================== */ void _enemy::make_cannon() { count = 0; health = 20; damage = 75; b = enemies.eint1() - 1; a = gamerand.get() & b; } void _enemy::move_cannon() { (count)++; (count) &= (b); if(count == a && norm < ((VIEWLIMIT >> 1) + 8)) { int shift = (enemies.ek1() == &beam) ? 6 : 5; this->shot_template(enemies.ek1(), shift, 32, 0); } } void _enemy::kill_cannon() { enemies.make(&pipe1, CS2PIXEL(x), CS2PIXEL(y)); sound.g_base_node_explo(x, y); release(); } const enemy_kind cannon = { 10, &_enemy::make_cannon, &_enemy::move_cannon, &_enemy::kill_cannon, 4, -1, 0, LAYER_BASES }; /* * =========================================================================== * core * =========================================================================== */ void _enemy::make_core() { count = 0; health = 20; damage = 150; b = enemies.eint2() - 1; a = gamerand.get() & b; } void _enemy::move_core() { (count)++; (count) &= (b); if(count == a && norm < ((VIEWLIMIT >> 1) + 8)) { int shift = (enemies.ek2() == &beam) ? 6 : 5; this->shot_template(enemies.ek2(), shift, 0, 0); } } void _enemy::kill_core() { enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 3); enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 7); enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 5); enemies.make(&explosion4, CS2PIXEL(x), CS2PIXEL(y)); sound.g_base_core_explo(x, y); release(); manage.destroyed_a_core(); } const enemy_kind core = { 200, &_enemy::make_core, &_enemy::move_core, &_enemy::kill_core, 4, -1, 0, LAYER_BASES }; /* * =========================================================================== * pipe1 * =========================================================================== */ void _enemy::make_pipe1() { health = 1; damage = 0; shootable = 0; count = 4; a = 0; b = 0; } void _enemy::move_pipe1() { sound.g_pipe_rumble(x, y); if((norm < ((VIEWLIMIT >> 1) + 32)) && (count == 1)) enemies.make(&explosion, CS2PIXEL(x) + pubrand.get(4) - 8, CS2PIXEL(y) + pubrand.get(4) - 8, 0, 0, 1); if(++count < 4) return; count = 0; int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; int a_next = 0; int x_next = 0; int y_next = 0; int m = screen.get_map(x1, y1); int p = MAP_BITS(m); if(IS_SPACE(p)) { release(); return; } if(norm < ((VIEWLIMIT >> 1) + 32)) enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), 0, 0, b); b = 1; if((p ^ a) == U_MASK) { a_next = D_MASK; y_next = -PIXEL2CS(16); } if((p ^ a) == R_MASK) { a_next = L_MASK; x_next = PIXEL2CS(16); } if((p ^ a) == D_MASK) { a_next = U_MASK; y_next = PIXEL2CS(16); } if((p ^ a) == L_MASK) { a_next = R_MASK; x_next = -PIXEL2CS(16); } if(a_next) { screen.set_map(x1, y1, 0); x += x_next; y += y_next; a = a_next; return; } if(!(p & CORE)) screen.set_map(x1, y1, m ^ a); release(); } const enemy_kind pipe1 = { 0, &_enemy::make_pipe1, &_enemy::move_pipe1, &_enemy::kill_default, -1, -1, 0, LAYER_BASES }; /* * =========================================================================== * pipe2 * =========================================================================== */ void _enemy::make_pipe2() { int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; screen.set_map(x1, y1, 0); health = 1; damage = 0; shootable = 0; count = 4; switch (di) { case 1: a = D_MASK; y -= PIXEL2CS(16); break; case 3: a = L_MASK; x += PIXEL2CS(16); break; case 5: a = U_MASK; y += PIXEL2CS(16); break; case 7: a = R_MASK; x -= PIXEL2CS(16); break; } } void _enemy::move_pipe2() { if((norm < ((VIEWLIMIT >> 1) + 32)) && (count == 1)) enemies.make(&explosion, CS2PIXEL(x) + pubrand.get(4) - 8, CS2PIXEL(y) + pubrand.get(4) - 8, 0, 0, 1); if(++count < 4) { sound.g_pipe_rumble(x, y); return; } count = 0; int x1 = (CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4; int y1 = (CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4; int a_next = 0; int x_next = 0; int y_next = 0; int p = MAP_BITS(screen.get_map(x1, y1)); if(IS_SPACE(p)) { release(); return; } if((p ^ a) == 0) { manage.add_score(30); release(); enemies.erase_cannon(x1, y1); screen.set_map(x1, y1, 0); sound.g_base_node_explo(x, y); if(norm < ((VIEWLIMIT >> 1) + 32)) enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y)); return; } if((p ^ a) == HARD) { release(); screen.set_map(x1, y1, 0); sound.g_pipe_rumble(x, y); if(norm < ((VIEWLIMIT >> 1) + 32)) enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); return; } if((p ^ a) == U_MASK) { a_next = D_MASK; y_next = -PIXEL2CS(16); } if((p ^ a) == R_MASK) { a_next = L_MASK; x_next = PIXEL2CS(16); } if((p ^ a) == D_MASK) { a_next = U_MASK; y_next = PIXEL2CS(16); } if((p ^ a) == L_MASK) { a_next = R_MASK; x_next = -PIXEL2CS(16); } screen.set_map(x1, y1, 0); sound.g_pipe_rumble(x, y); if(norm < ((VIEWLIMIT >> 1) + 32)) enemies.make(enemies.randexp(), CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); if(a_next) { x += x_next; y += y_next; a = a_next; return; } p ^= a; if(p & U_MASK) enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 1); if(p & R_MASK) enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 3); if(p & D_MASK) enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 5); if(p & L_MASK) enemies.make(&pipe2, CS2PIXEL(x), CS2PIXEL(y), 0, 0, 7); manage.add_score(10); release(); } const enemy_kind pipe2 = { 0, &_enemy::make_pipe2, &_enemy::move_pipe2, &_enemy::kill_default, -1, -1, 0, LAYER_BASES }; /* * =========================================================================== * enemy1 * Gray Dumb Missile * =========================================================================== */ void _enemy::make_enemy1() { di = 1; health = 20; } void _enemy::move_enemy1() { this->move_enemy_template(2, 256); } const enemy_kind enemy1 = { 2, &_enemy::make_enemy1, &_enemy::move_enemy1, &_enemy::kill_default, 6, B_MISSILE1, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy2 * Teal Firing Fighter * =========================================================================== */ void _enemy::make_enemy2() { di = 1; health = 20; count = gamerand.get() & 63; } void _enemy::move_enemy2() { this->move_enemy_template(4, 192); if(--(count) <= 0) { if(norm < ((VIEWLIMIT >> 1) + 8)) { this->shot_template(&beam, 5, 0, 0); } count = 32; } } const enemy_kind enemy2 = { 10, &_enemy::make_enemy2, &_enemy::move_enemy2, &_enemy::kill_default, 6, B_FIGHTER, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy3 * Maroon Homing Missile * =========================================================================== */ void _enemy::make_enemy3() { di = 1; health = 20; } void _enemy::move_enemy3() { this->move_enemy_template(32, 96); } const enemy_kind enemy3 = { 1, &_enemy::make_enemy3, &_enemy::move_enemy3, &_enemy::kill_default, 6, B_MISSILE2, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy4 * Blue Homing Missile * =========================================================================== */ void _enemy::make_enemy4() { di = 1; health = 20; } void _enemy::move_enemy4() { this->move_enemy_template(4, 96); } const enemy_kind enemy4 = { 1, &_enemy::make_enemy4, &_enemy::move_enemy4, &_enemy::kill_default, 6, B_MISSILE3, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy5 * Green Boomerang Fighter * =========================================================================== */ void _enemy::make_enemy() { count = gamerand.get() & 127; di = 1; health = 20; a = 0; } void _enemy::move_enemy5() { if(a == 0) { if(norm > ((VIEWLIMIT >> 1) - 32)) this->move_enemy_template(6, 192); else a = 1; } else { if(norm < VIEWLIMIT) this->move_enemy_template_2(4, 192); else a = 0; } if(enemies.is_intro) { if(gamerand.get(7) > 110) hit(1); } else if((--count) <= 0) { count = 8; if(norm > ((VIEWLIMIT >> 1) - 32)) this->shot_template(&beam, 6, 0, 0); } } const enemy_kind enemy5 = { 5, &_enemy::make_enemy, &_enemy::move_enemy5, &_enemy::kill_default, 6, B_BMR_GREEN, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy6 * Purple Boomerang Fighter * =========================================================================== */ void _enemy::move_enemy6() { if(a == 0) { if(norm > ((VIEWLIMIT >> 1) - 0)) this->move_enemy_template(6, 192); else a = 1; } else { if(norm < VIEWLIMIT) this->move_enemy_template_2(5, 192); else a = 0; } if((--count) <= 0) { count = 128; if(norm > ((VIEWLIMIT >> 1) - 32)) this->shot_template(&beam, 6, 0, 0); } } const enemy_kind enemy6 = { 2, &_enemy::make_enemy, &_enemy::move_enemy6, &_enemy::kill_default, 6, B_BMR_PURPLE, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy7 * Pink Boomerang Fighter * =========================================================================== */ void _enemy::move_enemy7() { if(a == 0) { if(norm > ((VIEWLIMIT >> 1) - 32)) this->move_enemy_template(6, 192); else a = 1; } else { if(norm < VIEWLIMIT) this->move_enemy_template_3(4, 192); else a = 0; } if(enemies.is_intro) { if(gamerand.get(7) > 110) hit(1); } else if((--count) <= 0) { count = 8; if(norm > ((VIEWLIMIT >> 1) - 32)) this->shot_template(&beam, 6, 0, 0); } } const enemy_kind enemy7 = { 5, &_enemy::make_enemy, &_enemy::move_enemy7, &_enemy::kill_default, 6, B_BMR_PINK, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy_m1 * =========================================================================== */ void _enemy::make_enemy_m1() { di = 1; health = 20 * 26; count = gamerand.get() & 15; } void _enemy::move_enemy_m1() { this->move_enemy_m(3, 128); if(++di > 16) di = 1; if((count--) <= 0) { count = 4; if(norm < ((VIEWLIMIT >> 1) - 16)) { this->shot_template(&enemy1, 4, 0, 0); } } if(health < 200) { this->shot_template_8_dir(&enemy2); release(); } } const enemy_kind enemy_m1 = { 50, &_enemy::make_enemy_m1, &_enemy::move_enemy_m1, &_enemy::kill_default, 12, B_BIGSHIP, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy_m2 * =========================================================================== */ void _enemy::make_enemy_m2() { di = 1; health = 20 * 26; count = gamerand.get() & 15; } void _enemy::move_enemy_m2() { this->move_enemy_m(3, 128); if(++di > 16) di = 1; if((count--) <= 0) { count = 8; if(norm < ((VIEWLIMIT >> 1) + 8)) { this->shot_template(&enemy2, 4, 128, 192); } } if(health < 200) { this->shot_template_8_dir(&bomb2); release(); } } const enemy_kind enemy_m2 = { 50, &_enemy::make_enemy_m2, &_enemy::move_enemy_m2, &_enemy::kill_default, 12, B_BIGSHIP, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy_m3 * =========================================================================== */ void _enemy::make_enemy_m3() { di = 1; health = 20 * 26; count = gamerand.get() & 15; } void _enemy::move_enemy_m3() { this->move_enemy_m(3, 128); if(--di < 1) di = 16; if((count--) <= 0) { count = 64; if(norm < ((VIEWLIMIT >> 1) + 8)) { this->shot_template_8_dir(&bomb2); } } if(health < 200) { this->shot_template_8_dir(&rock); release(); } } const enemy_kind enemy_m3 = { 50, &_enemy::make_enemy_m3, &_enemy::move_enemy_m3, &_enemy::kill_default, 12, B_BIGSHIP, 0, LAYER_ENEMIES }; /* * =========================================================================== * enemy_m4 * =========================================================================== */ void _enemy::make_enemy_m4() { di = 1; health = 20 * 26; count = gamerand.get() & 15; } void _enemy::move_enemy_m4() { this->move_enemy_m(2, 96); if(--di < 1) di = 16; static const enemy_kind *shot[8] = { &enemy1, &enemy2, &bomb2, &ring, &enemy1, &enemy2, &ring, &enemy1 }; if((count--) <= 0) { count = 64; if(norm < ((VIEWLIMIT >> 1) + 8)) { this->shot_template_8_dir(shot[gamerand.get() & 7]); } } if(health < 200) { this->shot_template_8_dir(&rock); release(); } } const enemy_kind enemy_m4 = { 100, &_enemy::make_enemy_m4, &_enemy::move_enemy_m4, &_enemy::kill_default, 12, B_BIGSHIP, 0, LAYER_ENEMIES }; /*---------------------------------------------------------------------------*/ /* void _enemy::make_xxxx(){} * void _enemy::move_xxxx(){} * void _enemy::die_xxxx(){} * enemy_kind xxxxx = { * score, * make_xxxx, move_xxxx, die_xxx, * hitsize, * bank, frame, tilesize * }; */ KoboDeluxe-0.5.1/pfile.cpp0000644000175000001440000001220607736672164012321 00000000000000/*(LGPL) --------------------------------------------------------------------------- pfile.cpp - Portable File Access Toolkit --------------------------------------------------------------------------- * Copyright (C) 2002, 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #include #include #include #include "kobolog.h" #include "pfile.h" /*---------------------------------------------------------- Constructor/Destructor ----------------------------------------------------------*/ pfile_t::pfile_t(FILE *file) { f = file; _status = 0; bufsize = bufused = bufpos = 0; buffer = NULL; } pfile_t::~pfile_t() { buffer_close(); } /*---------------------------------------------------------- Internal buffer control ----------------------------------------------------------*/ int pfile_t::buffer_init() { buffer_close(); bufsize = 1024; buffer = (char *)malloc(bufsize); if(!buffer) return status(-1); bufused = bufpos = 0; return _status; } int pfile_t::buffer_write() { DBG(log_printf(D3LOG, "pfile_t::buffer_write() %d bytes\n", bufused);) if(fwrite(buffer, bufused, 1, f) != 1) return status(-1); bufused = bufpos = 0; return _status; } int pfile_t::buffer_read(int len) { buffer_close(); bufsize = len; buffer = (char *)malloc(bufsize); if(!buffer) return status(-1); if(fread(buffer, bufsize, 1, f) != 1) { buffer_close(); return status(-1); } bufused = bufsize; bufpos = 0; return status(len); } void pfile_t::buffer_close() { free(buffer); buffer = NULL; bufsize = bufused = bufpos = 0; } int pfile_t::read(void *data, int len) { if(_status < 0) return _status; if(buffer) { if(bufpos + len > bufused) return -1; memcpy(data, buffer + bufpos, len); bufpos += len; return len; } else { if(fread(data, len, 1, f) != 1) return status(-1); return len; } } int pfile_t::write(void *data, int len) { if(_status < 0) return _status; DBG(log_printf(D3LOG, "pfile_t::write(block of %d bytes)\n", len);) if(bufused + len > bufsize) { int nbs = (bufused + len) * 3 / 2; char *nb = (char *)realloc(buffer, nbs); if(!nb) return -1; buffer = nb; bufsize = nbs; } memcpy(buffer + bufused, data, len); bufused += len; return len; } /*---------------------------------------------------------- Status ----------------------------------------------------------*/ int pfile_t::status() { int os = _status; _status = 0; return os; } int pfile_t::status(int new_status) { if(_status >= 0) _status = new_status; return _status; } /*---------------------------------------------------------- Little endian read/write API ----------------------------------------------------------*/ int pfile_t::read(unsigned int &x) { unsigned char b[4]; int result = read(&b, 4); if(4 == result) x = b[0] | (b[1] << 8) | (b[2] << 16) | (b[3] << 24); return result; } int pfile_t::read(int &x) { unsigned int ux; int result = read(ux); if(4 == result) x = (int)ux; return result; } int pfile_t::write(unsigned int x) { DBG(log_printf(D3LOG, "pfile_t::write(int)\n");) unsigned char b[4]; b[0] = x & 0xff; b[1] = (x >> 8) & 0xff; b[2] = (x >> 16) & 0xff; b[3] = (x >> 24) & 0xff; return status(write(&b, 4)); } int pfile_t::write(int x) { return status(write((unsigned int)x)); } /*---------------------------------------------------------- Unbuffered Write API ----------------------------------------------------------*/ int pfile_t::write_ub(void *data, int len) { DBG(log_printf(D3LOG, "pfile_t::write_ub(block of %d bytes)\n", len);) if(fwrite(data, len, 1, f) != 1) return status(-1); return _status; } int pfile_t::write_ub(unsigned int x) { unsigned char b[4]; b[0] = x & 0xff; b[1] = (x >> 8) & 0xff; b[2] = (x >> 16) & 0xff; b[3] = (x >> 24) & 0xff; return status(write_ub(&b, 4)); } int pfile_t::write_ub(int x) { return status(write_ub((unsigned int)x)); } /*---------------------------------------------------------- RIFF style chunk API ----------------------------------------------------------*/ int pfile_t::chunk_read() { unsigned int size; chunk_writing = 0; if(read(chunk_id) != 4) return _status; if(read(size) != 4) return _status; return buffer_read(size); } int pfile_t::chunk_write(int id) { chunk_writing = 1; chunk_id = id; buffer_init(); return _status; } int pfile_t::chunk_end() { if(chunk_writing) { write_ub(chunk_id); write_ub(bufused); buffer_write(); } buffer_close(); return _status; } KoboDeluxe-0.5.1/gamectl.cpp0000666000175000001440000001553510710762644012637 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001 - 2003, 2006, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "manage.h" #include "kobo.h" #include "gamectl.h" #include "myship.h" int gamecontrol_t::afire; int gamecontrol_t::r_delay = 250; int gamecontrol_t::r_interval = 40; int gamecontrol_t::space; int gamecontrol_t::left; int gamecontrol_t::up; int gamecontrol_t::down; int gamecontrol_t::right; int gamecontrol_t::dl; int gamecontrol_t::dr; int gamecontrol_t::ul; int gamecontrol_t::ur; int gamecontrol_t::shot; int gamecontrol_t::direction = 1; int gamecontrol_t::new_direction = 0; int gamecontrol_t::latch_timer = 0; int gamecontrol_t::movekey_pressed; void gamecontrol_t::init(int always_fire) { afire = always_fire; left = 0; right = 0; up = 0; down = 0; shot = 0; movekey_pressed = 0; SDL_EnableKeyRepeat(r_delay, r_interval); } gamecontrol_t::gamecontrol_t() { init(0); } void gamecontrol_t::repeat(int delay, int interval) { r_delay = delay; r_interval = interval; //Temporary kludge - should apply repeat to //all switch inputs, not just the keyboard! SDL_EnableKeyRepeat(delay, interval); } void gamecontrol_t::clear() { direction = 1; } int gamecontrol_t::map(SDLKey sym) { /* FIXME: This should be replaced by a configurable mapping system. */ switch(sym) { case KEY_KP_LEFT: case SDLK_LEFT: return BTN_LEFT; case KEY_KP_RIGHT: case SDLK_RIGHT: return BTN_RIGHT; case KEY_KP_UP: case SDLK_UP: return BTN_UP; case KEY_KP_DOWN: case SDLK_DOWN: return BTN_DOWN; case KEY_KP_DL: return BTN_DL; case KEY_KP_DR: return BTN_DR; case KEY_KP_UL: return BTN_UL; case KEY_KP_UR: return BTN_UR; case SDLK_PAGEUP: if(prefs->broken_numdia) return BTN_UR; else return BTN_NEXT; case SDLK_PAGEDOWN: if(prefs->broken_numdia) return BTN_DR; else return BTN_PREV; case SDLK_HOME: if(prefs->broken_numdia) return BTN_UL; else return -1; case SDLK_END: if(prefs->broken_numdia) return BTN_UL; else return -1; case SDLK_LSHIFT: case SDLK_RSHIFT: case SDLK_LCTRL: case SDLK_RCTRL: return BTN_FIRE; case SDLK_ESCAPE: return BTN_EXIT; case SDLK_PAUSE: case SDLK_p: return BTN_PAUSE; case SDLK_SPACE: return BTN_START; case SDLK_KP_ENTER: case SDLK_RETURN: return BTN_SELECT; case SDLK_KP_PLUS: return BTN_INC; case SDLK_KP_MINUS: return BTN_DEC; case SDLK_y: return BTN_YES; case SDLK_n: return BTN_NO; case SDLK_BACKSPACE: return BTN_BACK; case SDLK_F1: return BTN_F1; case SDLK_F2: return BTN_F2; case SDLK_F3: return BTN_F3; case SDLK_F4: return BTN_F4; case SDLK_F5: return BTN_F5; case SDLK_F6: return BTN_F6; case SDLK_F7: return BTN_F7; case SDLK_F8: return BTN_F8; case SDLK_F9: return BTN_F9; case SDLK_F10: return BTN_F10; case SDLK_F11: return BTN_F11; case SDLK_F12: return BTN_F12; default: return -1; } } void gamecontrol_t::press(int k) { switch(k) { case BTN_LEFT: left = 1; break; case BTN_RIGHT: right = 1; break; case BTN_UP: up = 1; break; case BTN_DOWN: down = 1; break; case BTN_UL: ul = 1; break; case BTN_UR: ur = 1; break; case BTN_DL: dl = 1; break; case BTN_DR: dr = 1; break; case BTN_FIRE: shot = 1; break; } gamecontrol_t::change(); } void gamecontrol_t::release(int k) { switch(k) { case BTN_LEFT: left = 0; break; case BTN_RIGHT: right = 0; break; case BTN_UP: up = 0; break; case BTN_DOWN: down = 0; break; case BTN_UL: ul = 0; break; case BTN_UR: ur = 0; break; case BTN_DL: dl = 0; break; case BTN_DR: dr = 0; break; case BTN_FIRE: shot = 0; break; } gamecontrol_t::change(); } void gamecontrol_t::mouse_press(int n) { if(n == 1) shot = 1; // else if(n == 3) // manage.key_down(KEY_START); gamecontrol_t::change(); } void gamecontrol_t::mouse_release(int n) { if(n == 1) shot = 0; gamecontrol_t::change(); } void gamecontrol_t::mouse_position(int h, int v) { switch(prefs->mousemode) { case MMD_OFF: return; case MMD_CROSSHAIR: myship.put_crosshair(); break; case MMD_RELATIVE: /* Insert delta pos sensitivity filter here */ break; } if(h > 0) { if(v > 0) { if(h > (v << 1)) direction = 3; else if(v > (h << 1)) direction = 5; else direction = 4; } else if(v <= 0) { if(h > ((-v) << 1)) direction = 3; else if((-v) > (h << 1)) direction = 1; else direction = 2; } else direction = 3; } else if(h <= 0) { if(v > 0) { if((-h) > (v << 1)) direction = 7; else if(v > ((-h) << 1)) direction = 5; else direction = 6; } else if(v <= 0) { if((-h) > ((-v) << 1)) direction = 7; else if((-v) > ((-h) << 1)) direction = 1; else direction = 8; } else direction = 7; } } void gamecontrol_t::change() { int lr = left - right + ul - ur + dl - dr; int ud = up - down + ul + ur - dl - dr; if(lr > 0) { if(ud > 0) new_direction = 8; else if(ud < 0) new_direction = 6; else new_direction = 7; } else if(lr < 0) { if(ud > 0) new_direction = 2; else if(ud < 0) new_direction = 4; else new_direction = 3; } else { if(ud > 0) new_direction = 1; else if(ud < 0) new_direction = 5; else new_direction = 0; } if(prefs->dia_emphasis) { if(!new_direction) { //Change to neutral. Cancel delayed latch! latch_timer = 0; } else if(!movekey_pressed) { //Change from neutral - latch immediately. direction = new_direction; latch_timer = 0; } else if(new_direction & 1) { //Change from diagonal! latch_timer = prefs->dia_emphasis; } else { //Change to diagonal - latch immediately. direction = new_direction; latch_timer = 0; } } else if(new_direction) direction = new_direction; movekey_pressed = (new_direction != 0); mouse_x = 0; mouse_y = 0; } void gamecontrol_t::process() { if(latch_timer) if(!--latch_timer) direction = new_direction; } KoboDeluxe-0.5.1/manage.cpp0000666000175000001440000003221710733147654012452 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ // Define to get time and ships lost printed out per finished stage // NOTE: Also disables bonus ships! #undef PLAYSTATS #include "config.h" #include #include #include #include #include #include #ifndef M_PI # define M_PI 3.14159265358979323846 /* pi */ #endif #include "kobo.h" #include "screen.h" #include "manage.h" #include "options.h" #include "scenes.h" #include "score.h" #include "enemies.h" #include "myship.h" #include "radar.h" #include "gamectl.h" #include "states.h" #include "audio.h" #include "random.h" #define GIGA 1000000000 int _manage::blank = 0; int _manage::next_state_out; int _manage::next_state_next; int _manage::game_seed; int _manage::scene_num; int _manage::ships; int _manage::score; float _manage::disp_health; float _manage::disp_temp; int _manage::score_changed = 1; int _manage::ships_changed = 1; int _manage::bonus_next; int _manage::flush_score_count = 0; int _manage::flush_ships_count = 0; int _manage::scroll_jump = 0; int _manage::delay_count; int _manage::rest_cores; int _manage::introtime = 0; int _manage::exit_manage = 0; int _manage::playing = 0; int _manage::_get_ready = 0; int _manage::_game_over = 0; s_hiscore_t _manage::hi; int _manage::noise_duration = 0; int _manage::noise_timer = 0; int _manage::noise_flash = 500; float _manage::noise_level = 0.0f; int _manage::intro_x = CHIP_SIZEX * (64-18); int _manage::intro_y = CHIP_SIZEY * (64-7); int _manage::show_bars = 0; #ifdef PLAYSTATS static Uint32 start_time = 0; static int start_ships = 0; #endif void _manage::set_bars() { whealth->enable(show_bars); wtemp->enable(show_bars); wttemp->enable(show_bars); } // NOTE: // After a noise out has faded out the sound effects, it's the // noise/interfecence effect when the playfield is reinitialized // that "accidentally" restores volume! // void _manage::run_noise() { if(noise_flash == -2) { // Damage flash noise_timer -= game.speed; if(noise_timer <= 0) noise_timer = 0; screen.noise(noise_timer); float t = (float)noise_timer / noise_duration; wmain->background(wmain->map_rgb(wmain->fadergb(0xff0000, (int)(t * noise_level * 64)))); screen.set_noise(B_HITNOISE, t * noise_level, t * noise_level, 0.0f); return; } else if(noise_flash == -1) { // Noise-out noise_timer -= game.speed; if(noise_timer <= 0) noise_timer = 0; float t = (float)noise_timer / noise_duration; float a = t * 2.0f * M_PI; wmain->background(wmain->map_rgb(wmain->fadergb(0x00ff99, (int)(sin(a * 0.5f) * 0.3f * 64)))); screen.set_noise(B_NOISE, 1.0f - t, sin(a * 0.5f) * 0.3f, 0.3f + t * 0.5f); sound.sfx_volume(t); return; } wmain->background(wmain->map_rgb(0x00000)); // Noise/interference int noise; if(noise_timer > noise_flash) { noise_timer -= game.speed; noise = 1; } else if(noise_timer > 0) { unsigned prob = noise_flash - noise_timer; prob <<= 8; prob /= noise_flash; noise_timer -= game.speed; noise = pubrand.get(8) > prob; } else { noise_timer = 0; noise = 0; } noise_level += (noise - noise_level) * 0.3f; screen.set_noise(B_NOISE, noise_level, 0.0f, noise_level); screen.noise(noise_level > 0.1f); sound.ui_noise(noise); } void _manage::noise(int duration, int flash) { noise_flash = flash; noise_duration = noise_timer = duration; sound.ui_noise(-1); screen.set_noise(B_NOISE, 1.0f, 0.0f, 1.0f); noise_level = 1.0f; } void _manage::noise_out(int duration) { noise_flash = -1; noise_duration = noise_timer = duration; screen.noise(1); } void _manage::noise_damage(float amt) { noise_flash = -2; noise_duration = noise_timer = (int)(300.0f + 1500.0f * amt); noise_level = 0.3f + 0.3f * amt; } void _manage::game_start() { _game_over = 0; hi.clear(); game.set(GAME_SINGLE, (skill_levels_t)scorefile.profile()->skill); #ifdef PLAYSTATS ships = 100; #else ships = game.lives; #endif disp_health = 0; disp_temp = 0; score = 0; flush_score_count = 0; bonus_next = game.bonus_first; gengine->period(game.speed); sound.period(game.speed); screen.init_scene(scene_num); init_resources_to_play(1); gamecontrol.clear(); gamecontrol.repeat(0, 0); playing = 1; _get_ready = 1; hi.skill = game.skill; hi.playtime = 0; hi.gametype = game.type; #if 1 // The new skill levels are under development! // We want to mark highscores so they're not mistaken // for official scores from a future finalized version. if(game.skill != SKILL_CLASSIC) hi.gametype |= GAME_EXPERIMENTAL; #endif hi.saves = 0; hi.loads = 0; hi.start_scene = scene_num; hi.end_lives = ships; sound.g_music(SOUND_BGM); #ifdef PLAYSTATS start_time = SDL_GetTicks(); start_ships = ships; #endif } void _manage::game_stop() { if(!prefs->cmd_cheat && !prefs->cmd_pushmove) { hi.score = score; hi.end_scene = scene_num; hi.end_health = myship.health(); scorefile.record(&hi); } ships = 0; ships_changed = 1; audio_channel_stop(0, -1); playing = 0; } void _manage::next_scene() { #ifdef PLAYSTATS printf("stage %d:\n", scene_num); Uint32 nst = SDL_GetTicks(); printf(" time: %d s\n", (nst - start_time) / 1000); printf(" deaths: %d\n", start_ships - ships); start_time = nst; start_ships = ships; #endif scene_num++; if(scene_num >= GIGA - 1) scene_num = GIGA - 2; screen.init_scene(scene_num); scroll_jump = 1; _get_ready = 1; } void _manage::retry() { if(!prefs->cmd_cheat) { ships--; ships_changed = 1; } if(ships <= 0) { if(!_game_over) { game_stop(); _game_over = 1; } } else _get_ready = 1; gamecontrol.clear(); } void _manage::init_resources_title() { noise(1000, 800); screen.init_scene(INTRO_SCENE); gengine->period(30); sound.period(30); gamerand.init(); enemies.init(); myship.init(); myship.off(); screen.prepare(); screen.generate_fixed_enemies(); put_info(); put_score(); put_ships(); put_health(1); put_temp(1); run_intro(); gengine->force_scroll(); gamecontrol.repeat(KOBO_KEY_DELAY, KOBO_KEY_REPEAT); show_bars = 0; set_bars(); } void _manage::init_resources_to_play(int newship) { noise(400, 300); delay_count = 0; flush_score_count = (flush_score_count) ? -1 : 0; flush_ships_count = 0; score_changed = 0; next_state_out = 0; next_state_next = 0; gamerand.init(); game_seed = gamerand.get_seed(); enemies.init(); myship.init(); if(newship) myship.health(game.health); rest_cores = screen.prepare(); scroll_jump = 1; screen.generate_fixed_enemies(); put_info(); put_score(); put_ships(); switch(game.skill) { case SKILL_CLASSIC: show_bars = 0; break; case SKILL_NEWBIE: case SKILL_GAMER: case SKILL_ELITE: case SKILL_GOD: default: show_bars = 1; break; } set_bars(); put_health(1); put_temp(1); myship.put(); gengine->scroll(PIXEL2CS(myship.get_virtx()), PIXEL2CS(myship.get_virty())); gengine->force_scroll(); } void _manage::put_health(int force) { int h = myship.health(); if(h > disp_health) { disp_health += (float)game.health * .05; if(disp_health > h) disp_health = h; // whealth->background(whealth->map_rgb(0, 100, 0)); } else if(h < disp_health) { disp_health -= (float)game.health * .1; if(disp_health < h) disp_health = h; // whealth->background(whealth->map_rgb(128, 0, 0)); } // else // whealth->background(whealth->map_rgb(0, 0, 0)); whealth->value((float)disp_health / game.health); if(force) whealth->invalidate(); } void _manage::put_temp(int force) { wtemp->value(myship.get_nose_temp() / 256.0f); wttemp->value(myship.get_tail_temp() / 256.0f); if(force) { wtemp->invalidate(); wttemp->invalidate(); } } void _manage::put_info() { static char s[16]; snprintf(s, 16, "%010d", scorefile.highscore()); dhigh->text(s); dhigh->on(); snprintf(s, 16, "%03d", scene_num + 1); dstage->text(s); dstage->on(); score_changed = 1; ships_changed = 1; } void _manage::put_score() { if(score_changed) { static char s[32]; snprintf(s, 16, "%010d", score); dscore->text(s); dscore->on(); if(score > scorefile.highscore()) { dhigh->text(s); dhigh->on(); } score_changed = 0; } if(flush_score_count > 0) flush_score(); } void _manage::put_ships() { if(ships_changed) { static char s[32]; if(!prefs->cmd_cheat) snprintf(s, 16, "%03d", ships); else snprintf(s, 16, "999"); dships->text(s); dships->on(); ships_changed = 0; } if(flush_ships_count > 0) flush_ships(); } void _manage::flush_score() { flush_score_count--; if(flush_score_count & 1) return; if(flush_score_count & 2) dscore->off(); else dscore->on(); if(flush_score_count == 0) flush_score_count = -1; } void _manage::flush_ships() { flush_ships_count--; if(flush_ships_count & 1) return; if(flush_ships_count & 2) dships->off(); else dships->on(); if(flush_ships_count == 0) flush_ships_count = -1; } /****************************************************************************/ void _manage::init() { scorefile.init(); ships = 0; exit_manage = 0; scene_num = -1; flush_ships_count = 0; flush_score_count = 0; delay_count = 0; screen.init(); init_resources_title(); } void _manage::run_intro() { double t = SDL_GetTicks() * 0.001f; gengine->scroll(PIXEL2CS(intro_x), PIXEL2CS(intro_y)); intro_y -= 3; intro_x &= MAP_SIZEX*CHIP_SIZEX-1; intro_y &= MAP_SIZEY*CHIP_SIZEY-1; sound.g_position(intro_x + (WSIZE >> 1), intro_y + (WSIZE >> 1)); myship.set_position(intro_x + (WSIZE >> 1) + (int)(WSIZE * 0.3f * sin(t)), intro_y + (WSIZE >> 1) + (int)(WSIZE * 0.3f * sin(t * 1.73))); enemies.move_intro(); enemies.put(); put_health(); put_temp(); put_score(); put_ships(); run_noise(); } void _manage::update() { myship.put(); enemies.put(); put_score(); put_ships(); gengine->scroll(PIXEL2CS(myship.get_virtx()), PIXEL2CS(myship.get_virty())); if(scroll_jump) { gengine->force_scroll(); scroll_jump = 0; } run_noise(); } void _manage::run_pause() { put_health(); put_temp(); update(); } void _manage::run_game() { put_health(); put_temp(); if(delay_count) delay_count--; if(delay_count == 1) { if(enemies.exist_pipe()) delay_count = 2; else { int newship = next_state_out; put_info(); if(next_state_out) { retry(); if(ships <= 0) return; } if(next_state_next) next_scene(); init_resources_to_play(newship); return; } } myship.move(); enemies.move(); myship.hit_structure(); update(); ++hi.playtime; } void _manage::lost_myship() { if(delay_count == 0) delay_count = 100; next_state_out = 1; } void _manage::destroyed_a_core() { // Award 10% health bonus for destroyed core! myship.health_bonus(10); rest_cores--; if(rest_cores == 0) { next_state_next = 1; delay_count = 50; // Award another 25% health bonus for stage cleared! myship.health_bonus(25); } screen.generate_fixed_enemies(); } void _manage::add_score(int sc) { score += sc; if(score >= GIGA) //This *could* happen... Or maybe not. :-) score = GIGA - 1; else if(!prefs->cmd_cheat) { #ifndef PLAYSTATS if(score >= bonus_next) { bonus_next += game.bonus_every; ships++; ships_changed = 1; flush_ships_count = 50; sound.ui_oneup(); } #endif if(score >= scorefile.highscore()) { if(flush_score_count == 0) flush_score_count = 50; } } score_changed = 1; } void _manage::select_next(int redraw_map) { if((scene_num < scorefile.last_scene()) || prefs->cmd_cheat) { sound.ui_tick(); scene_num++; } else sound.ui_error(); select_scene(scene_num); } void _manage::select_prev(int redraw_map) { scene_num--; if(scene_num < 0) { sound.ui_error(); scene_num = 0; } else sound.ui_tick(); select_scene(scene_num); } void _manage::regenerate() { sound.ui_tick(); select_scene(scene_num, 1); } void _manage::select_scene(int scene, int redraw_map) { scene_num = scene; put_info(); if(redraw_map) screen.init_scene(-scene_num - 1); noise(150, 0); } void _manage::abort() { if(!exit_manage) { game_stop(); exit_manage = 1; } } void _manage::freeze_abort() { exit_manage = 1; } void _manage::reenter() { exit_manage = 0; put_health(1); put_temp(1); put_info(); put_score(); put_ships(); } int _manage::get_ready() { if(_get_ready) { _get_ready = 0; return 1; } return 0; } int _manage::game_over() { return _game_over; } KoboDeluxe-0.5.1/map.cpp0000666000175000001440000001156510723076331011772 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2002, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include "map.h" #include "random.h" void _map::init() { int i, j; for(i = 0; i < MAP_SIZEX; i++) for(j = 0; j < MAP_SIZEY; j++) pos(i, j) = SPACE; } void _map::make_maze(int x, int y, int difx, int dify) { int i, j; int vx, vy; /* clear */ for(i = x - difx; i <= x + difx; i++) for(j = y - dify; j <= y + dify; j++) pos(i, j) = SPACE; /* push initial sites */ site_max = 0; if(gamerand.get(8) < 128) { pos(x, y) = CORE | R_MASK | L_MASK; maze_push(x - 1, y); maze_push(x + 1, y); } else { pos(x, y) = CORE | U_MASK | D_MASK; maze_push(x, y - 1); maze_push(x, y + 1); } for(;;) { /* get one */ if(maze_pop()) break; vx = sitex[site_max]; vy = sitey[site_max]; int dirs[4]; for(i = 0; i < 4; i++) dirs[i] = 0; int dirs_max = 0; if(maze_judge(x, y, difx, dify, vx + 2, vy + 0)) dirs[dirs_max++] = 1; if(maze_judge(x, y, difx, dify, vx + 0, vy + 2)) dirs[dirs_max++] = 2; if(maze_judge(x, y, difx, dify, vx - 2, vy + 0)) dirs[dirs_max++] = 3; if(maze_judge(x, y, difx, dify, vx + 0, vy - 2)) dirs[dirs_max++] = 4; if(dirs_max == 0) continue; /* there are no places to go */ i = gamerand.get() % dirs_max; maze_move_and_push(vx, vy, dirs[i]); maze_push(vx, vy); } } int _map::maze_pop() { if(site_max == 0) return 1; int i = gamerand.get() % site_max; site_max--; if(i != site_max) { int tmpx = sitex[site_max]; int tmpy = sitey[site_max]; sitex[site_max] = sitex[i]; sitey[site_max] = sitey[i]; sitex[i] = tmpx; sitey[i] = tmpy; } return 0; } void _map::maze_push(int x, int y) { sitex[site_max] = x; sitey[site_max++] = y; pos(x, y) = WALL; } void _map::maze_move_and_push(int x, int y, int d) { int x1 = x; int y1 = y; switch (d) { case 1: { x1 += 2; break; } case 2: { y1 += 2; break; } case 3: { x1 -= 2; break; } case 4: { y1 -= 2; break; } } maze_push(x1, y1); pos((x + x1) / 2, (y + y1) / 2) = WALL; } int _map::maze_judge(int cx, int cy, int dx, int dy, int x, int y) { if((x < cx - dx) || (x > cx + dx) || (y < cy - dy) || (y > cy + dy)) return 0; if(pos(x, y) == WALL) return 0; return 1; } // Translate map "tile state bits" into tile index // // The hard end nodes need some special treatment here. There are 16 direction // mask combinations, but only 4 are valid in this case. So, we use a 16 x 2 // bit lookup "table" (packed into an 'int') to get the right tile index. // // 00 01 10 11 <-- mask bits 1 (right) and 0 (up) // ----------------------------------------------------- // 00 -- 00 01 -- // 01 10 -- -- -- <-- Tile indices // 10 11 -- -- -- // 11 -- -- -- -- // ^ // '- mask bits 3 (left) and 2 (down) // // Thus, our table is 00000000 00000011 00000010 00010000 == 0x00030210 // static inline int bits2tile(int n) { if(n & CORE) // Core return n & (U_MASK | D_MASK) ? 6 : 7; else if(n & HARD) // One of the 4 indestructible end nodes return (0x00030210 >> ((n & 15) << 1)) & 3; else if(n == 5) // Vertical pipe return pubrand.get(2) ? 13 : 4; else if(n == 10) // Vertical pipe return pubrand.get(2) ? 18 : 5; else // Other pipe parts or normal end nodes return n + 8; } void _map::convert(unsigned ratio) { int i, j; int p = 0; for(i = 0; i < MAP_SIZEX; i++) for(j = 0; j < MAP_SIZEY; j++) { p = pos(i, j) & CORE; if(IS_SPACE(pos(i, j))) { clearpos(i, j); continue; } if((j > 0) && !IS_SPACE(pos(i, j - 1))) p |= U_MASK; if((i < MAP_SIZEX - 1) && !IS_SPACE(pos(i + 1, j))) p |= R_MASK; if((j < MAP_SIZEY - 1) && !IS_SPACE(pos(i, j + 1))) p |= D_MASK; if((i > 0) && !IS_SPACE(pos(i - 1, j))) p |= L_MASK; if((p == U_MASK) || (p == R_MASK) || (p == D_MASK) || (p == L_MASK)) { if(gamerand.get(8) < ratio) p |= HARD; } pos(i, j) = (bits2tile(p) << 8) | p; } } void _map::clearpos(int x, int y) { pos(x, y) = (gamerand.get(6) << 8) | SPACE; } KoboDeluxe-0.5.1/myship.cpp0000666000175000001440000003005210733674461012527 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kobo.h" #include "screen.h" #include "myship.h" #include "enemies.h" #include "gamectl.h" #include "manage.h" #include "random.h" #include "sound.h" #define WING_GUN_OFFSET 4 _myship_state _myship::_state; int _myship::di; int _myship::virtx; int _myship::virty; int _myship::x; int _myship::y; int _myship::_health; int _myship::health_time; int _myship::explo_time; int _myship::nose_reload_timer; int _myship::nose_temperature; int _myship::nose_alt = 0; int _myship::tail_reload_timer; int _myship::tail_temperature; int _myship::tail_alt = WING_GUN_OFFSET; int _myship::lapx; int _myship::lapy; int _myship::boltx[MAX_BOLTS]; int _myship::bolty[MAX_BOLTS]; int _myship::boltdx[MAX_BOLTS]; int _myship::boltdy[MAX_BOLTS]; int _myship::boltst[MAX_BOLTS]; cs_obj_t *_myship::object; cs_obj_t *_myship::bolt_objects[MAX_BOLTS]; cs_obj_t *_myship::crosshair; _myship::_myship() { object = NULL; memset(bolt_objects, 0, sizeof(bolt_objects)); crosshair = NULL; } void _myship::state(_myship_state s) { switch (s) { case dead: if(object) gengine->free_obj(object); object = NULL; if(crosshair) gengine->free_obj(crosshair); crosshair = NULL; break; case normal: if(!object) object = gengine->get_obj(LAYER_PLAYER); if(object) cs_obj_show(object); break; } _state = s; } void _myship::off() { state(dead); int i; for(i = 0; i < MAX_BOLTS; i++) if(bolt_objects[i]) { gengine->free_obj(bolt_objects[i]); bolt_objects[i] = NULL; } } int _myship::init() { nose_reload_timer = 0; nose_temperature = 0; tail_reload_timer = 0; tail_temperature = 0; x = WORLD_SIZEX >> 1; y = (WORLD_SIZEY >> 2) * 3; virtx = x - (WSIZE >> 1); virty = y - (WSIZE >> 1); lapx = 0; lapy = 0; di = 1; state(normal); apply_position(); int i; for(i = 0; i < MAX_BOLTS; i++) { boltx[i] = 0; bolty[i] = 0; boltdx[i] = 0; boltdy[i] = 0; boltst[i] = 0; if(bolt_objects[i]) gengine->free_obj(bolt_objects[i]); bolt_objects[i] = NULL; } return 0; } void _myship::explode(int x, int y) { if(explo_time == 56) manage.noise_out(1000); else if(explo_time > 64) return; int d = 4096 - (64 - explo_time)*(64 - explo_time); int i; for(i = 0; i < 2; ++i) { int dx = (int)(pubrand.get(6)) - 32; int dy = (int)(pubrand.get(6)) - 32; int vx = dx * (4096 - d) >> 8; int vy = dy * (4096 - d) >> 8; dx = dx * d >> 12; dy = dy * d >> 12; enemies.make(enemies.randexp(), x + dx, y + dy, vx, vy, explo_time >> 4); } ++explo_time; } #define BEAMV1 12 #define BEAMV2 (BEAMV1*2/3) int _myship::move() { int i; di = gamecontrol.dir(); if(++health_time >= game.health_fade) { health_time = 0; if(_health > game.health) --_health; } virtx = x - (WSIZE >> 1); virty = y - (WSIZE >> 1); if(_state == normal) { int vd, vo; if(!prefs->cmd_pushmove) { vd = 2; vo = 3; } else if(gamecontrol.dir_push()) { vd = 1; vo = 1; } else { vd = 0; vo = 0; } switch (di) { case 1: virty -= vo; break; case 2: virty -= vd; virtx += vd; break; case 3: virtx += vo; break; case 4: virtx += vd; virty += vd; break; case 5: virty += vo; break; case 6: virty += vd; virtx -= vd; break; case 7: virtx -= vo; break; case 8: virtx -= vd; virty -= vd; break; } explo_time = 0; } else if(_state == dead) explode(x, y); lapx = 0; lapy = 0; if(virtx < 0) { virtx += WORLD_SIZEX; lapx = WORLD_SIZEX; } if(virtx >= WORLD_SIZEX) { virtx -= WORLD_SIZEX; lapx = -WORLD_SIZEX; } if(virty < 0) { virty += WORLD_SIZEY; lapy = WORLD_SIZEY; } if(virty >= WORLD_SIZEY) { virty -= WORLD_SIZEY; lapy = -WORLD_SIZEY; } x = virtx + (WSIZE >> 1); y = virty + (WSIZE >> 1); nose_temperature -= game.nosecooling; if(nose_temperature < 0) nose_temperature = 0; tail_temperature -= game.tailcooling; if(tail_temperature < 0) tail_temperature = 0; if((_state == normal) && gamecontrol.get_shot()) { if(game.skill == SKILL_CLASSIC) { if(nose_reload_timer > 0) --nose_reload_timer; else { _myship::xkobo_shot(); nose_reload_timer = game.noseloadtime - 1; } } else { int fired = 0; if(tail_reload_timer > 0) --tail_reload_timer; else if(!_myship::tail_fire()) fired = 1; // Ok! else fired = 2; // Overheat! if(nose_reload_timer > 0) --nose_reload_timer; else if(!_myship::nose_fire()) fired = 1; // Ok! else fired = 2; // Overheat! if(fired == 1) sound.g_player_fire(); else if(fired == 2) sound.g_player_overheat(); } } else { if(!gamecontrol.get_shot()) { nose_alt = 1; sound.g_player_fire_off(); } if(nose_reload_timer > 0) --nose_reload_timer; if(tail_reload_timer > 0) --tail_reload_timer; } const char animtab[8] = { 3, 2, 1, 0, 1, 2, 1, 2 }; for(i = 0; i < MAX_BOLTS; i++) { if(!boltst[i]) continue; ++boltst[i]; boltx[i] += lapx; bolty[i] += lapy; boltx[i] += boltdx[i]; bolty[i] += boltdy[i]; if((ABS(boltx[i] - x) >= (VIEWLIMIT >> 1) + 16) || (ABS(bolty[i] - y) >= (VIEWLIMIT >> 1) + 16)) { boltst[i] = 0; if(bolt_objects[i]) gengine->free_obj(bolt_objects[i]); bolt_objects[i] = NULL; } else if(bolt_objects[i]) cs_obj_image(bolt_objects[i], B_BOLT, (bolt_objects[i]->anim.frame & 0xfffffffc) + animtab[boltst[i] & 7]); } return 0; } void _myship::hit(int dmg) { if(_state != normal) return; if(!dmg) dmg = 1000; if(_health && (dmg < _health)) manage.noise_damage((float)dmg / _health); else manage.noise_damage(1.0f); _health -= dmg; if(_health > 0) sound.g_player_damage(); else { _health = 0; manage.lost_myship(); state(dead); sound.g_player_explo_start(); } } void _myship::health_bonus(int h) { if(game.skill == SKILL_CLASSIC) return; _health += game.health * h / 100; health_time = 0; if(_health > game.health * 2) _health = game.health * 2; } int _myship::hit_structure() { int x1, y1; int i, ch; // Check bolts/objects for(i = 0; i < MAX_BOLTS; i++) { if(!boltst[i]) continue; x1 = (boltx[i] & (WORLD_SIZEX - 1)) >> 4; y1 = (bolty[i] & (WORLD_SIZEY - 1)) >> 4; ch = screen.get_map(x1, y1); if(!IS_SPACE(ch) && (ch & HIT_MASK)) { sound.g_bolt_hit(x1<<12, y1<<12); enemies.make(&boltexpl, boltx[i], bolty[i]); boltst[i] = 0; if(bolt_objects[i]) gengine->free_obj(bolt_objects[i]); bolt_objects[i] = NULL; } } // Check player/bases x1 = (x & (WORLD_SIZEX - 1)) >> 4; y1 = (y & (WORLD_SIZEY - 1)) >> 4; ch = screen.get_map(x1, y1); if(!IS_SPACE(ch) && (ch & HIT_MASK)) { if(prefs->cmd_indicator) sound.g_player_damage(); else _myship::hit(1000); } return 0; } int _myship::hit_bolt(int ex, int ey, int hitsize, int health) { int dmg = 0; int i; for(i = 0; i < MAX_BOLTS; i++) { if(boltst[i] == 0) continue; if(ABS(ex - boltx[i]) >= hitsize) continue; if(ABS(ey - bolty[i]) >= hitsize) continue; if(!prefs->cmd_cheat) { boltst[i] = 0; if(bolt_objects[i]) gengine->free_obj(bolt_objects[i]); bolt_objects[i] = NULL; } enemies.make(&boltexpl, boltx[i], bolty[i]); dmg += game.bolt_damage; if(dmg >= health) break; } return dmg; } void _myship::put_crosshair() { if(_state != normal) return; if(!crosshair) { crosshair = gengine->get_obj(LAYER_OVERLAY); if(crosshair) cs_obj_show(crosshair); } if(crosshair) { cs_obj_image(crosshair, B_CROSSHAIR, 0); crosshair->point.v.x = PIXEL2CS(mouse_x - 8 - MARGIN); crosshair->point.v.y = PIXEL2CS(mouse_y - MARGIN); } } int _myship::put() { /* Player */ apply_position(); if(object) cs_obj_image(object, B_PLAYER, (di - 1) * 2); /* Bullets */ int i; for(i = 0; i < MAX_BOLTS; i++) { if(!bolt_objects[i]) continue; if(boltst[i]) { bolt_objects[i]->point.v.x = PIXEL2CS(boltx[i]); bolt_objects[i]->point.v.y = PIXEL2CS(bolty[i]); } } return 0; } void _myship::shot_single(int i, int dir, int offset) { int doffset = (offset * 7071 + (offset > 0 ? 5000 : -5000)) / 10000; boltst[i] = 1; boltx[i] = x; bolty[i] = y; switch((dir + 1) % 8 + 1) { case 1: bolty[i] -= offset; break; case 2: bolty[i] -= doffset; boltx[i] += doffset; break; case 3: boltx[i] += offset; break; case 4: boltx[i] += doffset; bolty[i] += doffset; break; case 5: bolty[i] += offset; break; case 6: bolty[i] += doffset; boltx[i] -= doffset; break; case 7: boltx[i] -= offset; break; case 8: boltx[i] -= doffset; bolty[i] -= doffset; break; } switch(dir) { case 1: boltdx[i] = 0; boltdy[i] = -BEAMV1; break; case 2: boltdy[i] = -BEAMV2; boltdx[i] = BEAMV2; break; case 3: boltdx[i] = BEAMV1; boltdy[i] = 0; break; case 4: boltdx[i] = BEAMV2; boltdy[i] = BEAMV2; break; case 5: boltdx[i] = 0; boltdy[i] = BEAMV1; break; case 6: boltdy[i] = BEAMV2; boltdx[i] = -BEAMV2; break; case 7: boltdx[i] = -BEAMV1; boltdy[i] = 0; break; case 8: boltdx[i] = -BEAMV2; boltdy[i] = -BEAMV2; break; } if(!bolt_objects[i]) bolt_objects[i] = gengine->get_obj(LAYER_PLAYER); if(bolt_objects[i]) { bolt_objects[i]->point.v.x = PIXEL2CS(boltx[i]); bolt_objects[i]->point.v.y = PIXEL2CS(bolty[i]); cs_obj_image(bolt_objects[i], B_BOLT, (((dir - 1) & 0x3) << 2) + 3); cs_obj_show(bolt_objects[i]); } } int _myship::xkobo_shot() { int i, j; for(i = 0; i < game.bolts && boltst[i]; i++) ; for(j = i + 1; j < game.bolts && boltst[j]; j++) ; if(j >= game.bolts) { sound.g_player_overheat(1); return 1; } shot_single(i, di, 0); shot_single(j, (di > 4) ? (di - 4) : (di + 4), 0); sound.g_player_fire(); return 0; } int _myship::nose_fire() { int i, j; // Logic: If firing would cause overheat, wait! if(255 - nose_temperature < game.noseheatup) return 1; for(i = 0; i < game.bolts && boltst[i]; i++) ; if(!game.altfire) { if(i >= game.bolts) return 1; shot_single(i, di, 0); nose_temperature += game.noseheatup; nose_reload_timer = game.noseloadtime; return 0; } for(j = i + 1; j < game.bolts && boltst[j]; j++) ; if(j >= game.bolts) return 1; if(++nose_alt > 2) nose_alt = 0; shot_single(i, di, (nose_alt - 1) * WING_GUN_OFFSET); if(++nose_alt > 2) nose_alt = 0; shot_single(j, di, (nose_alt - 1) * WING_GUN_OFFSET); nose_temperature += game.noseheatup; nose_reload_timer = game.noseloadtime; return 0; } int _myship::tail_fire() { int i; if(255 - tail_temperature < game.tailheatup) return 1; for(i = 0; i < game.bolts && boltst[i]; i++) ; if(i >= game.bolts) return 1; if(game.altfire) { tail_alt = -tail_alt; shot_single(i, (di > 4) ? (di - 4) : (di + 4), tail_alt); } else shot_single(i, (di > 4) ? (di - 4) : (di + 4), 0); tail_temperature += game.tailheatup; tail_reload_timer = game.tailloadtime; return 0; } void _myship::set_position(int px, int py) { x = px; y = py; virtx = x - (WSIZE >> 1); virty = y - (WSIZE >> 1); if(object) { apply_position(); cs_point_force(&object->point); } } void _myship::apply_position() { if(object) { object->point.v.x = PIXEL2CS(x); object->point.v.y = PIXEL2CS(y); } sound.g_position(x, y); } KoboDeluxe-0.5.1/radar.cpp0000666000175000001440000001450610723054421012300 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2005-2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "kobo.h" #include "kobolog.h" #include "screen.h" #include "myship.h" #include "radar.h" #include "prefs.h" #include "random.h" /*--------------------------------------------------------------------- radar_map_t ---------------------------------------------------------------------*/ radar_map_t::radar_map_t() { w = MAP_SIZEX; h = MAP_SIZEY; pixel_core = 0; pixel_launcher = 0; pixel_hard = 0; pixel_bg = 0; } void radar_map_t::update(int x, int y, int force) { int a = MAP_BITS(screen.get_map(x, y)); if(IS_SPACE(a)) { if(!force) return; foreground(pixel_bg); } else if(a & CORE) foreground(pixel_core); else if((a == U_MASK) || (a == R_MASK) || (a == D_MASK) || (a == L_MASK)) foreground(pixel_launcher); else if((a & HIT_MASK)) foreground(pixel_hard); point(x, y); } void radar_map_t::refresh(SDL_Rect *r) { clear(r); SDL_Rect nr; if(!r) { nr.x = 0; nr.y = 0; nr.w = w; nr.h = h; r = &nr; } int i, j; for(i = r->x; i < r->w; i++) for(j = r->y; j < r->h; j++) update(i, j, 0); } /*--------------------------------------------------------------------- radar_window_t ---------------------------------------------------------------------*/ radar_window_t::radar_window_t() { _mode = RM_OFF; old_scrollradar = -1; xpos = -1; ypos = -1; xoffs = 0; yoffs = 0; time = 0; refresh_pos = 0; } void radar_window_t::update(int mx, int my) { wmap->update(mx, my, 1); if(prefs->scrollradar == 1) return; /* No instant updates in sweep mode! */ SDL_Rect r; r.x = (mx - xoffs) & (MAP_SIZEX-1); r.y = (my - yoffs) & (MAP_SIZEY-1); r.w = r.h = 1; invalidate(&r); } void radar_window_t::update_player(int px, int py) { SDL_Rect r; r.x = (px - pxoffs) & (MAP_SIZEX-1); r.y = (py - pyoffs) & (MAP_SIZEY-1); r.w = r.h = 1; invalidate(&r); } void radar_window_t::refresh(SDL_Rect *r) { int t = SDL_GetTicks(); clear(r); switch(_mode) { case RM__REINIT: case RM_OFF: case RM_NOISE: case RM_INFO: break; case RM_SHOW: blit(0, 0, wmap); break; case RM_RADAR: switch(prefs->scrollradar) { case 0: blit(0, 0, wmap); break; case 1: foreground(map_rgb(48, 192, 160)); fillrect(0, refresh_pos - 1, wmap->w, 1); foreground(map_rgb(40, 160, 128)); fillrect(0, refresh_pos - 2, wmap->w, 1); foreground(map_rgb(32, 128, 96)); fillrect(0, refresh_pos - 3, wmap->w, 1); // Fallthrough! case 2: blit(-xoffs, MAP_SIZEY - yoffs, wmap); blit(-xoffs, -yoffs, wmap); blit(MAP_SIZEX - xoffs, MAP_SIZEY - yoffs, wmap); blit(MAP_SIZEX - xoffs, -yoffs, wmap); break; } if(_mode != RM_SHOW) { foreground(map_rgb((t >> 1) & 255, 120 + ((t >> 2) & 127), 120 + ((t >> 2) & 127))); point((xpos - pxoffs) & (MAP_SIZEX - 1), (ypos - pyoffs) & (MAP_SIZEY - 1)); } break; } } void radar_window_t::mode(radar_modes_t newmode) { if(newmode == RM__REINIT) newmode = _mode; wmap->offscreen(); wmap->pixel_core = wmap->map_rgb(255, 255, 128); wmap->pixel_hard = wmap->map_rgb(64, 128, 128); wmap->pixel_launcher = wmap->map_rgb(64, 200, 240); wmap->pixel_bg = wmap->map_rgb(32, 48, 64); wmap->background(wmap->pixel_bg); wmap->colorkey(wmap->pixel_bg); _mode = newmode; refresh_pos = 0; time = SDL_GetTicks(); wmap->invalidate(); invalidate(); } void radar_window_t::set_scroll(int xs, int ys) { xoffs = (xs + MAP_SIZEX / 2) & (MAP_SIZEX - 1); yoffs = (ys + MAP_SIZEY / 2) & (MAP_SIZEY - 1); } void radar_window_t::sweep(void) { int start_y = refresh_pos; int ct = SDL_GetTicks(); int t = ct - time; int end_y = t / 8; if((t < 0) || (end_y >= wmap->h)) { end_y = wmap->h; time = ct; refresh_pos = 0; set_scroll(xpos, ypos); platched = 0; } else refresh_pos = end_y; if(!platched) if(refresh_pos > ((ypos - pyoffs) & (MAP_SIZEY - 1))) { pxoffs = xoffs; pyoffs = yoffs; platched = 1; } SDL_Rect r; r.x = 0; r.y = start_y >= 3 ? start_y - 3 : 0; r.w = wmap->w; r.h = end_y - start_y + 1; invalidate(&r); } void radar_window_t::radar() { int xpos_new = (myship.get_x() & (WORLD_SIZEX - 1)) >> 4; int ypos_new = (myship.get_y() & (WORLD_SIZEY - 1)) >> 4; switch(prefs->scrollradar) { case 0: /* No scrolling */ // Note this first one just invalidates the *area* // that the player is in! That is, if the player // has moved, the player will be somewhere else // when the rendering is performed, and no player // cursor is rendered. update_player(xpos, ypos); if((xpos_new == xpos) && (ypos_new == ypos)) break; xpos = xpos_new; ypos = ypos_new; pxoffs = pyoffs = xoffs = yoffs = 0; update_player(xpos, ypos); break; case 1: /* Radar screen sweep */ update_player(xpos, ypos); xpos = xpos_new; ypos = ypos_new; sweep(); update_player(xpos, ypos); break; case 2: /* Plain scrolling */ if((xpos_new == xpos) && (ypos_new == ypos)) break; xpos = xpos_new; ypos = ypos_new; set_scroll(xpos, ypos); pxoffs = xoffs; pyoffs = yoffs; invalidate(); break; } } void radar_window_t::frame() { if(prefs->scrollradar != old_scrollradar) { old_scrollradar = prefs->scrollradar; refresh_pos = 0; time = SDL_GetTicks(); pxoffs = pyoffs = xoffs = yoffs = 0; invalidate(); } switch(_mode) { case RM__REINIT: case RM_OFF: break; case RM_RADAR: radar(); break; case RM_SHOW: break; case RM_NOISE: case RM_INFO: invalidate(); break; } } KoboDeluxe-0.5.1/random.cpp0000666000175000001440000000200307421710267012464 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2002, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "random.h" rand_num_t gamerand; rand_num_t pubrand; KoboDeluxe-0.5.1/scenes.cpp0000666000175000001440000007130010734154044012466 00000000000000 /* * XKOBO, a video-oriented game * Copyright (C) 1995,1996 Akira Higuchi * a-higuti@math.hokudai.ac.jp * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * */ #include "scenes.h" const _scene scene[] = { #if 0 /* Test map */ { 0, 32, 0, &enemy_m1, 128, &beam, 16, 1,{ {&enemy_m4, 1, 5}, // {&enemy4, 10, 5}, }, 1,{ // {32, 64, 31, 62}, {48, 64, 4, 4}, }, }, #endif /* 1 */ { 0, 32, 96, &beam, 128, &beam, 16, 1,{ {&enemy4, 10, 5}, }, 2,{ {48, 64, 4, 4}, {24, 80, 4, 4}, }, }, /* 2 */ { 0, 32, 96, &beam, 64, &beam, 64, 3,{ {&enemy4, 10, 5}, {&enemy4, 10, 5}, {&enemy1, 10, 5}, }, 4,{ {16, 48, 6, 6}, {48, 48, 6, 6}, {16, 64, 6, 6}, {48, 64, 6, 6}, }, }, /* 3 */ { 64, 32, 64, &beam, 64, &beam, 16, 1,{ {&rock, 20, 3}, }, 6,{ {16, 40, 4, 4}, {16, 60, 4, 4}, {16, 80, 4, 4}, {48, 40, 4, 4}, {48, 60, 4, 4}, {48, 80, 4, 4}, }, }, /* 4 */ { 0, 32, 96, &beam, 32, &beam, 8, 1,{ {&enemy4, 10, 5}, }, 3,{ {14, 55, 6, 6}, {55, 14, 6, 6}, {35, 70, 6, 6}, }, }, /* 5 */ { 0, 32, 96, &beam, 128, &beam, 128, 3,{ {&enemy6, 10, 5}, {&enemy6, 10, 5}, {&enemy4, 10, 5}, }, 2,{ {32, 32, 6, 6}, {32, 64, 6, 6}, }, }, /* 6 */ { 0, 32, 96, &enemy1, 32, &enemy1, 8, 0,{ {&enemy1, 40, 10}, }, 1,{ {32, 64, 8, 8}, }, }, /* 7 */ { 0, 32, 64, &ring, 64, &enemy1, 32, 2,{ {&enemy3, 30, 5}, {&enemy6, 20, 5}, }, 8,{ {32, 54, 3, 3}, {42, 54, 3, 3}, {42, 64, 3, 3}, {42, 74, 3, 3}, {32, 74, 3, 3}, {22, 74, 3, 3}, {22, 64, 3, 3}, {22, 54, 3, 3}, }, }, /* 8 */ { 0, 32, 64, &enemy4, 64, &enemy1, 8, 3,{ {&ring , 20, 5}, {&ring , 20, 5}, {&ring , 20, 5}, }, 8,{ {48, 64, 4, 4}, {16, 64, 4, 4}, {32, 80, 4, 4}, {32, 48, 4, 4}, {44, 76, 4, 4}, {20, 76, 4, 4}, {44, 52, 4, 4}, {20, 52, 4, 4}, }, }, /* 9 */ { 0, 32, 96, &beam, 16, &beam, 8, 1,{ {&bomb2, 20, 5}, }, 1,{ {32, 32, 7, 7}, }, }, /* 10 */ { 0, 32, 96, &bomb1, 128, &bomb1, 4, 1,{ {&rock, 100, 5}, }, 1,{ {32, 64, 12, 12}, }, }, /* 11 */ { 0, 32, 96, &enemy2, 128, &enemy1, 32, 5,{ {&rock, 30, 5}, {&enemy3, 50, 5}, {&enemy6, 20, 5}, {&enemy7, 10, 5}, {&bomb1, 20, 5}, }, 6,{ { 5, 64, 3, 3}, {15, 64, 3, 3}, {25, 64, 3, 3}, {35, 64, 3, 3}, {45, 64, 3, 3}, {55, 64, 3, 3}, }, }, /* 12 */ { 0, 47, 33, &beam, 128, &beam, 16, 3,{ {&enemy6, 10, 5}, {&enemy6, 10, 5}, {&rock, 100, 5}, }, 3,{ { 15, 88, 12, 12}, { 21, 20, 12, 12}, { 50, 70, 12, 12}, }, }, /* 13 */ { 0, 32, 64, &bomb2, 128, &enemy1, 32, 2,{ {&bomb1, 30, 5}, {&bomb1, 20, 5}, }, 5,{ { 24, 66, 3, 3}, { 23, 80, 3, 3}, { 44, 50, 3, 3}, { 39, 102, 3, 3}, { 15, 43, 3, 3}, }, }, /* 14 */ { 0, 24, 107, &enemy2, 128, &beam, 8, 4,{ {&enemy3, 10, 5}, {&enemy6, 10, 5}, {&rock, 100, 5}, {&enemy2, 10, 5}, }, 3,{ { 9, 36, 5, 5}, { 44, 19, 5, 5}, { 46, 79, 5, 5}, }, }, /* 15 */ { 0, 36, 94, &enemy4, 64, &bomb1, 32, 2,{ {&enemy6, 10, 5}, {&rock, 50, 5}, }, 5,{ { 16, 54, 4, 4}, { 47, 56, 4, 4}, { 24, 70, 4, 4}, { 31, 14, 4, 4}, { 27, 31, 4, 4}, }, }, /* 16 */ { 0, 31, 37, &enemy6, 64, &enemy6, 8, 3,{ {&enemy1, 20, 5}, {&enemy3, 10, 5}, {&rock, 100, 5}, }, 5,{ { 41, 84, 6, 10}, { 12, 115, 6, 5}, { 22, 92, 6, 10}, { 11, 26, 8, 8}, { 51, 65, 9, 7}, }, }, /* 17 */ { 0, 53, 17, &beam, 32, &enemy1, 32, 1,{ {&enemy3, 10, 5}, }, 10,{ { 14, 99, 6, 6}, { 37, 18, 6, 6}, { 13, 67, 6, 6}, { 19, 46, 6, 6}, { 41, 59, 6, 6}, { 39, 97, 6, 6}, { 47, 32, 6, 6}, { 56, 100, 6, 6}, { 19, 25, 6, 6}, { 54, 76, 6, 6}, }, }, /* 18 */ { 0, 32, 80, &enemy1, 32, &ring, 8, 4,{ {&rock, 40, 2}, {&enemy1, 20, 5}, {&rock, 40, 5}, {&enemy1, 20, 5}, }, 3,{ { 27, 104, 5, 5}, { 49, 105, 5, 5}, { 32, 90, 5, 5}, }, }, /* 19 */ { 0, 32, 64, &ring, 128, &enemy1, 8, 0,{ {&enemy1, 30, 5}, }, 16,{ { 32, 91, 3, 3}, { 42, 89, 3, 3}, { 51, 83, 3, 3}, { 57, 74, 3, 3}, { 59, 64, 3, 3}, { 57, 54, 3, 3}, { 51, 45, 3, 3}, { 42, 39, 3, 3}, { 32, 37, 3, 3}, { 22, 39, 3, 3}, { 13, 45, 3, 3}, { 7, 54, 3, 3}, { 5, 64, 3, 3}, { 7, 74, 3, 3}, { 13, 83, 3, 3}, { 22, 89, 3, 3}, }, }, /* 20 */ { 0, 7, 84, &enemy7, 128, &enemy5, 16, 0,{ {&bomb2, 30, 5}, }, 20,{ { 37, 82, 6, 6}, { 13, 99, 6, 6}, { 30, 44, 6, 6}, { 19, 14, 6, 6}, { 55, 85, 6, 6}, { 23, 69, 6, 6}, { 16, 35, 6, 6}, { 11, 52, 6, 6}, { 36, 116, 6, 6}, { 39, 97, 6, 6}, { 50, 114, 6, 6}, { 39, 22, 6, 6}, { 55, 43, 6, 6}, { 52, 71, 6, 6}, { 56, 100, 6, 6}, { 54, 25, 6, 6}, { 51, 57, 6, 6}, { 7, 115, 6, 6}, { 47, 8, 6, 6}, { 8, 70, 6, 6}, }, }, /* 21 */ { 0, 26, 30, &enemy1, 128, &beam, 16, 2,{ {&enemy3, 20, 5}, {&rock, 50, 5}, }, 6,{ { 27, 79, 5, 5}, { 6, 105, 5, 5}, { 11, 50, 5, 5}, { 11, 23, 5, 5}, { 56, 57, 5, 5}, { 7, 70, 5, 5}, }, }, /* 22 */ { 0, 38, 120, &ring, 128, &beam, 16, 6,{ {&ring, 10, 5}, {&ring, 10, 5}, {&ring, 10, 5}, {&ring, 10, 5}, {&ring, 10, 5}, {&enemy_m1, 1, 5}, }, 30,{ { 55, 25, 4, 4}, { 49, 12, 4, 4}, { 30, 84, 4, 4}, { 33, 97, 4, 4}, { 24, 21, 4, 4}, { 28, 52, 4, 4}, { 50, 117, 4, 4}, { 22, 95, 4, 4}, { 46, 56, 4, 4}, { 36, 10, 4, 4}, { 15, 77, 4, 4}, { 32, 74, 4, 4}, { 7, 15, 4, 4}, { 13, 107, 4, 4}, { 6, 51, 4, 4}, { 11, 62, 4, 4}, { 57, 76, 4, 4}, { 57, 95, 4, 4}, { 11, 90, 4, 4}, { 46, 93, 4, 4}, { 34, 27, 4, 4}, { 58, 56, 4, 4}, { 40, 45, 4, 4}, { 10, 31, 4, 4}, { 44, 35, 4, 4}, { 25, 122, 4, 4}, { 24, 62, 4, 4}, { 51, 107, 4, 4}, { 16, 50, 4, 4}, { 25, 110, 4, 4}, }, }, /* 23 */ { 0, 13, 92, &bomb1, 64, &bomb1, 32, 4,{ {&enemy1, 20, 5}, {&enemy2, 10, 5}, {&enemy7, 10, 5}, {&enemy6, 20, 5}, }, 5,{ { 40, 95, 15, 15}, { 44, 28, 13, 18}, { 15, 16, 12, 15}, { 14, 50, 13, 12}, { 49, 62, 12, 11}, }, }, /* 24 */ { 127, 32, 41, &enemy1, 128, &beam, 16, 3,{ {&rock, 50, 5}, {&enemy2, 20, 5}, {&bomb2, 30, 5}, }, 8,{ { 38, 73, 4, 4}, { 27, 98, 4, 4}, { 27, 71, 4, 4}, { 56, 89, 4, 4}, { 39, 6, 4, 4}, { 12, 67, 4, 4}, { 58, 14, 4, 4}, { 14, 21, 4, 4}, }, }, /* 25 */ { 256, 32, 96, &beam, 32, &enemy1, 32, 2,{ {&enemy6, 50, 5}, {&rock, 100, 5}, }, 2,{ {25, 53, 7, 6}, {40, 70, 5, 4}, }, }, /* 26 */ { 0, 32, 64, &ring, 64, &ring, 16, 0,{ {&enemy1, 40, 10}, }, 32,{ { 8, 8, 5, 5}, {24, 8, 5, 5}, {40, 8, 5, 5}, {56, 8, 5, 5}, { 8, 24, 5, 5}, {24, 24, 5, 5}, {40, 24, 5, 5}, {56, 24, 5, 5}, { 8, 40, 5, 5}, {24, 40, 5, 5}, {40, 40, 5, 5}, {56, 40, 5, 5}, { 8, 56, 5, 5}, {24, 56, 5, 5}, {40, 56, 5, 5}, {56, 56, 5, 5}, { 8, 72, 5, 5}, {24, 72, 5, 5}, {40, 72, 5, 5}, {56, 72, 5, 5}, { 8, 88, 5, 5}, {24, 88, 5, 5}, {40, 88, 5, 5}, {56, 88, 5, 5}, { 8, 104, 5, 5}, {24, 104, 5, 5}, {40, 104, 5, 5}, {56, 104, 5, 5}, { 8, 120, 5, 5}, {24, 120, 5, 5}, {40, 120, 5, 5}, {56, 120, 5, 5}, }, }, /* 27 */ { 0, 32, 64, &beam, 32, &enemy5, 32, 3,{ {&enemy1, 20, 5}, {&bomb1, 50, 5}, {&enemy_m2, 1, 5}, }, 4,{ { 49, 64, 6, 10}, { 40, 40, 11, 4}, { 36, 95, 13, 4}, { 13, 74, 8, 10}, }, }, /* 28 */ { 4, 45, 107, &enemy1, 32, &enemy5, 16, 1,{ {&rock, 50, 5}, }, 4,{ { 15, 108, 11, 18}, { 13, 62, 12, 19}, { 46, 42, 11, 41}, { 16, 23, 13, 13}, }, }, /* 29 */ { 0, 32, 60, &enemy2, 128, &beam, 4, 5,{ {&enemy5, 20, 5}, {&bomb2, 10, 5}, {&rock, 50, 5}, {&enemy_m1, 1, 5}, {&enemy7, 10, 5}, }, 5,{ { 40, 46, 13, 9}, { 20, 74, 12, 8}, { 24, 106, 11, 6}, { 29, 120, 14, 6}, { 54, 90, 5, 8}, }, }, /* 30 */ { 0, 23, 71, &enemy5, 64, &beam, 16, 3,{ {&enemy6, 2, 5}, {&enemy6, 2, 5}, {&enemy_m4, 1, 5}, }, 20,{ { 38, 120, 5, 5}, { 43, 64, 5, 5}, { 32, 106, 5, 5}, { 14, 52, 5, 5}, { 48, 76, 5, 5}, { 9, 110, 5, 5}, { 12, 34, 5, 5}, { 40, 90, 5, 5}, { 38, 33, 5, 5}, { 23, 9, 5, 5}, { 22, 120, 5, 5}, { 9, 90, 5, 5}, { 6, 15, 5, 5}, { 41, 46, 5, 5}, { 43, 13, 5, 5}, { 25, 88, 5, 5}, { 8, 65, 5, 5}, { 57, 49, 5, 5}, { 52, 108, 5, 5}, { 6, 77, 5, 5}, }, }, /* 31 */ { 0, 32, 120, &ring, 64, &ring, 8, 0,{ {&enemy1, 10, 5}, }, 16,{ { 24, 8, 6, 6}, { 24, 24, 6, 6}, { 24, 40, 6, 6}, { 24, 56, 6, 6}, { 24, 72, 6, 6}, { 24, 88, 6, 6}, { 24, 104, 6, 6}, { 24, 120, 6, 6}, { 40, 8, 6, 6}, { 40, 24, 6, 6}, { 40, 40, 6, 6}, { 40, 56, 6, 6}, { 40, 72, 6, 6}, { 40, 88, 6, 6}, { 40, 104, 6, 6}, { 40, 120, 6, 6}, }, }, /* 32 */ { 0, 32, 96, &beam, 128, &beam, 16, 0,{ {&enemy1, 40, 10}, }, 1,{ {32, 64, 24, 24}, }, }, /* 33 */ { 0, 24, 113, &enemy4, 32, &enemy4, 16, 5,{ {&enemy5, 30, 5}, {&bomb1, 50, 5}, {&enemy_m2, 1, 5}, {&enemy2, 20, 5}, {&rock, 100, 5}, }, 5,{ { 17, 70, 13, 21}, { 46, 32, 10, 10}, { 49, 63, 10, 11}, { 18, 25, 14, 21}, { 45, 109, 10, 17}, }, }, /* 34 */ { 0, 54, 120, &enemy6, 64, &beam, 16, 1,{ {&bomb2, 10, 5}, }, 15,{ { 8, 87, 6, 15}, { 26, 72, 9, 12}, { 37, 110, 9, 6}, { 36, 31, 16, 5}, { 32, 11, 17, 9}, { 46, 51, 6, 12}, { 54, 96, 5, 10}, { 12, 39, 5, 11}, { 13, 116, 9, 9}, { 40, 93, 7, 6}, { 7, 64, 6, 6}, { 7, 10, 5, 8}, { 47, 77, 8, 5}, { 28, 46, 5, 6}, { 56, 14, 5, 5}, }, }, /* 35 */ { 0, 32, 64, &enemy3, 128, &ring, 32, 8,{ {&enemy1, 10, 5}, {&enemy_m1, 1, 5}, {&bomb2, 10, 5}, {&enemy2, 10, 5}, {&enemy_m2, 1, 5}, {&enemy4, 10, 5}, {&enemy5, 10, 5}, {&enemy7, 10, 5}, }, 8,{ {32, 48, 7, 7}, {48, 48, 7, 7}, {48, 64, 7, 7}, {48, 80, 7, 7}, {32, 80, 7, 7}, {16, 80, 7, 7}, {16, 64, 7, 7}, {16, 48, 7, 7}, }, }, /* 36 */ { 0, 32, 64, &beam, 16, &enemy2, 64, 5,{ {&enemy1, 10, 10}, {&enemy2, 10, 10}, {&bomb2, 10, 10}, {&enemy_m1, 1, 10}, {&enemy_m2, 1, 10}, }, 10,{ {16, 20, 4, 4}, {16, 40, 4, 4}, {16, 60, 4, 4}, {16, 80, 4, 4}, {16,100, 4, 4}, {48, 20, 4, 4}, {48, 40, 4, 4}, {48, 60, 4, 4}, {48, 80, 4, 4}, {48,100, 4, 4}, }, }, /* 37 */ { 256, 32, 96, &beam, 64, &ring, 64, 0,{ {&ring, 0, 5}, }, 1,{ {32, 58, 18, 18}, }, }, /* 38 */ { 0, 32, 72, &ring, 64, &bomb1, 4, 1,{ {&rock, 10, 5}, }, 20,{ {16, 48, 3, 3}, {24, 48, 3, 3}, {32, 48, 3, 3}, {40, 48, 3, 3}, {48, 48, 3, 3}, {16, 64, 3, 3}, {24, 64, 3, 3}, {32, 64, 3, 3}, {40, 64, 3, 3}, {48, 64, 3, 3}, {16, 80, 3, 3}, {24, 80, 3, 3}, {32, 80, 3, 3}, {40, 80, 3, 3}, {48, 80, 3, 3}, {16, 96, 3, 3}, {24, 96, 3, 3}, {32, 96, 3, 3}, {40, 96, 3, 3}, {48, 96, 3, 3}, }, }, /* 39 */ { 0, 32, 50, &enemy5, 32, &enemy2, 16, 6,{ {&enemy_m2, 1, 5}, {&rock , 50, 5}, {&rock , 50, 5}, {&rock , 50, 5}, {&enemy_m1, 1, 5}, {&rock , 50, 5}, }, 8,{ {34, 14, 4, 4}, {16, 22, 4, 4}, { 6, 35, 4, 4}, {22, 38, 4, 4}, {45, 40, 4, 4}, { 6, 52, 4, 4}, {46, 66, 4, 4}, {30, 70, 4, 4}, {15, 90, 4, 4}, }, }, /* 40 */ { 0, 28, 11, &bomb1, 128, &enemy1, 16, 1,{ {&enemy6, 10, 5}, }, 35,{ { 12, 48, 9, 9}, { 14, 80, 6, 5}, { 42, 14, 7, 3}, { 52, 112, 4, 9}, { 33, 103, 5, 6}, { 17, 12, 4, 3}, { 49, 78, 5, 4}, { 49, 50, 4, 5}, { 19, 32, 5, 5}, { 32, 77, 6, 4}, { 9, 113, 4, 9}, { 36, 38, 7, 6}, { 50, 96, 8, 3}, { 57, 7, 3, 5}, { 53, 34, 5, 7}, { 11, 94, 5, 3}, { 27, 63, 3, 6}, { 44, 4, 3, 3}, { 48, 63, 5, 6}, { 37, 51, 6, 3}, { 28, 116, 3, 3}, { 8, 31, 4, 5}, { 4, 18, 3, 3}, { 13, 69, 6, 4}, { 21, 96, 3, 3}, { 36, 114, 3, 3}, { 55, 87, 5, 3}, { 58, 63, 3, 7}, { 35, 87, 4, 4}, { 35, 25, 3, 4}, { 20, 107, 3, 5}, { 13, 4, 3, 3}, { 23, 21, 4, 4}, { 5, 8, 3, 5}, { 47, 22, 7, 3}, }, }, /* 41 */ { 0, 32, 96, &beam, 64, &beam, 16, 1,{ {&bomb2, 40, 10}, }, 1,{ {32, 64, 18, 18}, }, }, /* 42 */ { 0, 54, 46, &enemy7, 64, &enemy5, 32, 3,{ {&bomb2, 10, 5}, {&enemy1, 10, 5}, {&enemy6, 10, 5}, }, 20,{ { 8, 106, 5, 8}, { 7, 32, 5, 13}, { 39, 83, 9, 7}, { 54, 63, 8, 9}, { 28, 20, 6, 13}, { 16, 61, 14, 10}, { 55, 25, 6, 13}, { 53, 106, 8, 7}, { 38, 115, 5, 7}, { 22, 109, 7, 14}, { 12, 82, 7, 8}, { 39, 51, 5, 5}, { 57, 89, 5, 7}, { 41, 21, 5, 7}, { 10, 10, 9, 6}, { 20, 41, 5, 5}, { 38, 66, 5, 5}, { 54, 121, 7, 5}, { 37, 100, 5, 6}, { 41, 7, 5, 5}, }, }, /* 43 */ { 0, 22, 107, &enemy2, 64, &bomb1, 8, 7,{ {&enemy4, 20, 5}, {&bomb2, 30, 5}, {&enemy2, 20, 5}, {&enemy6, 20, 5}, {&bomb2, 30, 5}, {&enemy7, 30, 5}, {&enemy_m3, 1, 5}, }, 5,{ { 49, 38, 8, 14}, { 20, 86, 5, 10}, { 19, 28, 14, 16}, { 19, 57, 17, 8}, { 48, 86, 8, 18}, }, }, /* 44 */ { 0, 32, 64, &enemy2, 64, &ring, 8, 4,{ {&bomb2, 20, 7}, {&rock, 20, 8}, {&enemy_m1, 1, 5}, {&rock, 20, 8}, }, 24,{ { 46, 64, 3, 3}, { 18, 64, 3, 3}, { 32, 79, 3, 3}, { 32, 48, 3, 3}, { 43, 75, 3, 3}, { 21, 75, 3, 3}, { 43, 53, 3, 3}, { 21, 53, 3, 3}, { 32, 91, 3, 3}, { 42, 89, 3, 3}, { 51, 83, 3, 3}, { 57, 74, 3, 3}, { 59, 64, 3, 3}, { 57, 54, 3, 3}, { 51, 45, 3, 3}, { 42, 39, 3, 3}, { 32, 37, 3, 3}, { 22, 39, 3, 3}, { 13, 45, 3, 3}, { 7, 54, 3, 3}, { 5, 64, 3, 3}, { 7, 74, 3, 3}, { 13, 83, 3, 3}, { 22, 89, 3, 3}, }, }, /* 45 */ { 0, 31, 87, &bomb1, 64, &ring, 16, 1,{ {&bomb2, 20, 5}, }, 10,{ { 18, 66, 15, 15}, { 52, 59, 7, 54}, { 31, 101, 8, 7}, { 39, 41, 4, 30}, { 9, 97, 7, 13}, { 21, 44, 11, 5}, { 25, 118, 5, 5}, { 20, 16, 8, 14}, { 42, 122, 10, 4}, { 5, 16, 4, 4}, }, }, /* 46 */ { 0, 59, 34, &beam, 64, &beam, 16, 4,{ {&rock, 15, 5}, {&enemy_m3, 1, 5}, {&rock, 15, 5}, {&enemy_m1, 1, 5}, }, 35,{ { 46, 19, 9, 10}, { 45, 115, 10, 4}, { 14, 60, 5, 8}, { 48, 60, 5, 10}, { 21, 45, 8, 5}, { 11, 83, 5, 13}, { 39, 97, 13, 8}, { 36, 49, 4, 3}, { 18, 8, 5, 4}, { 40, 80, 9, 5}, { 54, 44, 8, 4}, { 13, 27, 9, 3}, { 15, 110, 3, 5}, { 9, 122, 5, 4}, { 28, 63, 6, 6}, { 35, 39, 3, 3}, { 6, 5, 5, 3}, { 6, 113, 4, 3}, { 6, 40, 4, 5}, { 29, 116, 3, 9}, { 29, 9, 4, 4}, { 59, 65, 3, 10}, { 21, 86, 3, 7}, { 4, 60, 3, 6}, { 6, 18, 5, 4}, { 29, 22, 5, 6}, { 52, 4, 10, 3}, { 18, 19, 4, 3}, { 46, 34, 5, 3}, { 57, 91, 3, 4}, { 59, 103, 3, 6}, { 25, 35, 4, 3}, { 19, 122, 3, 4}, { 54, 80, 3, 3}, { 5, 101, 3, 3}, }, }, /* 47 */ { 0, 24, 31, &enemy5, 64, &ring, 32, 5,{ {&enemy1, 10, 5}, {&enemy7, 10, 5}, {&enemy1, 10, 5}, {&enemy7, 10, 5}, {&bomb2, 10, 5}, }, 35,{ { 29, 37, 19, 2}, { 24, 109, 3, 11}, { 7, 62, 3, 4}, { 47, 92, 2, 4}, { 50, 112, 7, 12}, { 54, 22, 8, 10}, { 35, 104, 5, 7}, { 32, 69, 9, 5}, { 27, 46, 17, 5}, { 32, 14, 9, 10}, { 12, 28, 8, 4}, { 5, 94, 4, 18}, { 46, 57, 7, 2}, { 46, 83, 11, 3}, { 58, 76, 4, 2}, { 56, 94, 4, 4}, { 59, 63, 2, 3}, { 16, 120, 3, 4}, { 14, 75, 2, 11}, { 17, 18, 2, 2}, { 7, 6, 6, 4}, { 37, 28, 6, 2}, { 6, 47, 2, 3}, { 50, 72, 2, 2}, { 57, 44, 2, 9}, { 18, 8, 2, 6}, { 46, 8, 2, 2}, { 25, 90, 4, 2}, { 4, 37, 3, 3}, { 17, 98, 2, 2}, { 27, 58, 9, 2}, { 27, 81, 5, 3}, { 57, 7, 5, 2}, { 7, 120, 2, 6}, { 36, 92, 3, 3}, }, }, /* 48 */ { 0, 19, 92, &enemy1, 64, &enemy2, 128, 3,{ {&enemy1, 10, 5}, {&bomb2, 10, 5}, {&rock, 20, 5}, }, 38,{ { 16, 54, 3, 3}, { 47, 56, 3, 4}, { 24, 70, 4, 3}, { 31, 14, 3, 3}, { 27, 31, 4, 3}, { 36, 94, 4, 4}, { 21, 19, 3, 4}, { 36, 68, 4, 3}, { 53, 4, 3, 3}, { 36, 80, 4, 4}, { 17, 36, 4, 3}, { 34, 118, 4, 3}, { 40, 13, 3, 4}, { 55, 121, 4, 4}, { 43, 26, 4, 3}, { 12, 71, 4, 4}, { 58, 108, 3, 4}, { 51, 36, 4, 4}, { 23, 94, 3, 3}, { 46, 73, 4, 4}, { 9, 25, 4, 3}, { 27, 48, 3, 3}, { 50, 91, 3, 3}, { 14, 122, 3, 3}, { 17, 113, 3, 4}, { 16, 8, 3, 4}, { 36, 38, 3, 4}, { 25, 103, 4, 3}, { 55, 70, 3, 4}, { 28, 56, 3, 3}, { 23, 85, 3, 3}, { 50, 108, 3, 3}, { 25, 122, 3, 3}, { 14, 82, 4, 4}, { 50, 16, 4, 4}, { 38, 49, 4, 3}, { 4, 6, 3, 3}, { 7, 38, 3, 3}, }, }, /* 49 */ { 0, 38, 67, &beam, 32, &beam, 8, 6,{ {&enemy2, 10, 5}, {&bomb1, 50, 5}, {&enemy1, 20, 5}, {&enemy2, 10, 5}, {&enemy_m1, 1, 5}, {&enemy1, 20, 5}, }, 22,{ { 28, 104, 10, 6}, { 43, 28, 12, 7}, { 22, 72, 7, 10}, { 11, 16, 8, 6}, { 50, 102, 8, 4}, { 12, 40, 5, 6}, { 49, 80, 11, 5}, { 6, 95, 4, 13}, { 51, 61, 6, 10}, { 30, 14, 4, 4}, { 17, 118, 6, 6}, { 34, 52, 6, 7}, { 40, 119, 15, 6}, { 31, 91, 15, 4}, { 53, 10, 8, 9}, { 8, 61, 4, 7}, { 7, 28, 5, 4}, { 58, 92, 4, 4}, { 19, 55, 5, 5}, { 25, 29, 4, 5}, { 58, 44, 4, 4}, { 9, 76, 4, 4}, }, }, /* 50 */ { 0, 32, 120, &beam, 8, &enemy1, 8, 1,{ {&bomb2, 80, 5}, }, 1,{ {32, 60, 30, 45}, }, }, { /******************* dummy *************************/ -1, 0, 0, &enemy1, 0, &enemy1, 0, 0,{ {&enemy1, 0, 0}, }, 0,{ {0, 0, 0, 0}, }, }, }; KoboDeluxe-0.5.1/score.cpp0000666000175000001440000003763610711424222012330 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #define DBG2(x) #define DBG3(x) #include #include #include #include #include #include #if HAVE_DIRENT_H # include # define NAMLEN(dirent) strlen((dirent)->d_name) #else # define dirent direct # define NAMLEN(dirent) (dirent)->d_namlen # if HAVE_SYS_NDIR_H # include # endif # if HAVE_SYS_DIR_H # include # endif # if HAVE_NDIR_H # include # endif #endif #if !defined(WIN32) && !defined(MACOS) #include #endif #include "kobolog.h" #include "kobo.h" #include "score.h" score_manager_t scorefile; /*---------------------------------------------------------- s_hiscore_t ----------------------------------------------------------*/ s_hiscore_t::s_hiscore_t() { profile = NULL; name[0] = 0; clear(); } void s_hiscore_t::clear() { start_date = 0; end_date = 0; skill = -1; score = 0; start_scene = -1; end_scene = -1; end_lives = -1; end_health = -1; playtime = 0; saves = loads = -1; gametype = -1; } void s_hiscore_t::read(pfile_t &pf) { pf.read(start_date); pf.read(end_date); pf.read(skill); pf.read(score); pf.read(start_scene); pf.read(end_scene); pf.read(end_lives); pf.read(end_health); pf.read(playtime); pf.read(saves); pf.read(loads); pf.read(gametype); #if 0 log_printf(DLOG, "--------\n"); log_printf(DLOG, " start_date: %u\n", start_date); log_printf(DLOG, " end_date: %u\n", end_date); log_printf(DLOG, " skill: %d\n", skill); log_printf(DLOG, " gametype: %d\n", gametype); log_printf(DLOG, " score: %u\n", score); log_printf(DLOG, " start_scene: %d\n", start_scene); log_printf(DLOG, " end_scene: %d\n", end_scene); log_printf(DLOG, " end_lives: %d\n", end_lives); log_printf(DLOG, " end_health: %d\n", end_health); log_printf(DLOG, " playtime: %u\n", playtime); log_printf(DLOG, " saves: %d\n", saves); log_printf(DLOG, " loads: %d\n", loads); log_printf(DLOG, "--------\n"); #endif } void s_hiscore_t::write(pfile_t &pf) { pf.write(start_date); pf.write(end_date); pf.write(skill); pf.write(score); pf.write(start_scene); pf.write(end_scene); pf.write(end_lives); pf.write(end_health); pf.write(playtime); pf.write(saves); pf.write(loads); pf.write(gametype); } /*---------------------------------------------------------- s_profile_t ----------------------------------------------------------*/ s_profile_t::s_profile_t() { for(int i = 0; i < HISCORE_SAVE_MAX; ++i) hiscoretab[i].profile = this; filename = NULL; } s_profile_t::~s_profile_t() { free(filename); } void s_profile_t::clear() { best_score = 0; last_scene = 0; name[0] = 0; version = 0; skill = SKILL_CLASSIC; handicap = 0; color1 = -1; color2 = -1; hiscores = 0; for(int i = 0; i < HISCORE_SAVE_MAX; ++i) hiscoretab[i].clear(); } int s_profile_t::load(const char *fn) { log_printf(D3LOG, "s_profile_t::load('%s')\n", fn); free(filename); filename = strdup(fn); FILE *f = fopen(filename, "rb"); if(!f) { log_printf(ELOG, "Failed to open player profile '%s'!\n", fn); return -1; } pfile_t pf(f); clear(); // Check if this is an old broken 73 byte file written by a // previous version for Win32. If it is, skip the first byte. fseek(f, 0, SEEK_END); if(ftell(f) == 73) { log_printf(ELOG, "Broken score file '%s' detected and fixed.\n", fn); fseek(f, 1, SEEK_SET); } else fseek(f, 0, SEEK_SET); pf.read(best_score); pf.read(last_scene); pf.read(name, sizeof(name)); log_printf(DLOG, "name: %s\n", name); log_printf(DLOG, " best_score: %u\n", best_score); log_printf(DLOG, " last_scene: %u\n", last_scene); pf.buffer_close(); if(pf.status() < 0) { log_printf(ELOG, "Error reading player profile '%s'!\n", fn); fclose(f); return -1; } //Kobo Deluxe profile file format 1+ int chunks = 0; while(!feof(f)) { if(pf.chunk_read() < 0) { pf.status(); // Just EOF - no big deal... break; } switch(pf.chunk_type()) { case MAKE_4CC('P', 'R', 'O', 'F'): log_printf(D2LOG, "Chunk 'PROF'; %d bytes.\n", pf.chunk_size()); if(pf.chunk_size() >= 20) { pf.read(version); pf.read(skill); pf.read(handicap); pf.read(color1); pf.read(color2); } else { log_printf(WLOG, "WARNING: Truncated 'PROF' chunk" " in player profile '%s'!\n", fn); } break; case MAKE_4CC('H', 'I', 'S', 'C'): log_printf(D2LOG, "Chunk 'HISC'; %d bytes.\n", pf.chunk_size()); if(hiscores < HISCORE_SAVE_MAX) hiscoretab[hiscores++].read(pf); break; default: { char tp[5]; int t = pf.chunk_type(); tp[0] = (t >> 24) & 0xff; tp[1] = (t >> 16) & 0xff; tp[2] = (t >> 8) & 0xff; tp[3] = t & 0xff; tp[4] = 0; log_printf(D2LOG, "Unknown chunk '%s'; %d bytes.\n", tp, pf.chunk_size()); } break; } ++chunks; pf.chunk_end(); } if(!chunks) { log_printf(D2LOG, "Old scorefile.\n"); //Construct a "fake" highscore entry from the old data. hiscores = 1; hiscoretab[0].skill = SKILL_CLASSIC; //Can't tell speed. hiscoretab[0].gametype = GAME_SINGLE; //No others available. hiscoretab[0].score = best_score; hiscoretab[0].end_scene = last_scene; //Likely, but... hiscoretab[0].saves = 0; //Not implemented. hiscoretab[0].loads = 0; //Not implemented. } fclose(f); return pf.status(); } int s_profile_t::save() { log_printf(D3LOG, "s_profile_t::save('%s')\n", filename); #ifndef WIN32 umask(022); #endif if(!filename) { log_printf(ELOG, "Failed to save player profile - no file name!\n"); return -1; } //The "safe list"; platforms that do not have symlinks: #if !defined(WIN32) #ifdef HAVE_STAT // We will not write score files via symlinks! struct stat statbuf; if(lstat(filename, &statbuf) < 0) { log_printf(ELOG, "Cannot stat player profile '%s'! " "Could be a symlink - will NOT write.\n", filename); return -1; } if( (statbuf.st_mode & S_IFLNK) == S_IFLNK ) { log_printf(ELOG, "Player profile '%s' is a symlink! " "I will NOT write through symlinks.\n", filename); return -1; } #else #warning ================= SECURITY HAZARD ================= #warning If this platform has symlinks or similar, please #warning add an appropriate test. If not, add your platform #warning to the "safe list". Either way, if you read this, #warning post a bug report to the Kobo Deluxe maintainer. #warning ================= SECURITY HAZARD ================= #error (Remove this line to compile anyway.) #endif /* HAVE_STAT */ #endif /* "Safe list" */ FILE *f = fopen(filename, "wb"); if(!f) { log_printf(ELOG, "Failed to create player profile '%s'!\n", filename); return -1; } fseek(f, 0, SEEK_SET); pfile_t pf(f); // Write old XKobo stuff pf.write(best_score); pf.write(last_scene); pf.write(name, sizeof(name)); pf.buffer_write(); // Write profile header if(pf.chunk_write(MAKE_4CC('P', 'R', 'O', 'F')) < 0) { fclose(f); return pf.status(); } pf.write((unsigned int)PROFILE_VERSION); pf.write(skill); pf.write(handicap); pf.write(color1); pf.write(color2); pf.chunk_end(); // Write highscores for(unsigned int i = 0; i < hiscores; ++i) { if(pf.chunk_write(MAKE_4CC('H', 'I', 'S', 'C')) < 0) { fclose(f); return pf.status(); } hiscoretab[i].write(pf); pf.chunk_end(); } fclose(f); return pf.status(); } s_hiscore_t *s_profile_t::best_hiscore() { if(!hiscores) return NULL; s_hiscore_t *hs = hiscoretab; for(unsigned int i = 1; i < hiscores; ++i) if(hiscoretab[i].score > hs->score) hs = hiscoretab + i; return hs; } /*---------------------------------------------------------- score_manager_t ----------------------------------------------------------*/ score_manager_t::score_manager_t() { } score_manager_t::~score_manager_t() { } void score_manager_t::init() { const char *p; // The logic to this is: // 1. Check to see if they have an old score file. // If they do, rename it to follow the new naming format // which is X.UID. On Win32 (which doesn't have a UID), the // UID is set to 42. // 2. Load all of the X.UID scores into our array. // 3. Determine what the last used file was. // Change as of 0.4-pre7: "score files" are upgraded // to "player profile files", which contain IFF style // chunks beyond the 74 XKobo compatible bytes. #ifdef WIN32 /* FIXME: This should be properly implemented on Windoze - if we FIXME: decide that it's actually much point. (Users, security etc FIXME: are rather foreign matters to the average winuser...) */ int nUID = 42; #else uid_t nUID = getuid(); #endif // Now load all of the files. Start with trying to get the old // file name first. That file's information will become games[0], // and then the old file name will be deleted. int numberSaveGamesFound = 0; for(int i = 0; i < MAX_PROFILES; i++) profiles[i].clear(); char buf[1024]; snprintf(buf, sizeof(buf), "SCORES>>%u", nUID); p = fmap->get(buf); if(p) { if(profiles[numberSaveGamesFound].load(p) < 0) log_printf(WLOG, "WARNING: Can't read score file!\n"); else { numberSaveGamesFound = 1; log_printf(ULOG, "Old score file \"%s\" found" " and imported.\n", p); } } // Search through all registered score directories // for all of the files that end in .UID struct stat st_buffer; fmap->get_all("SCORES>>", FM_DIR); char UIDbuf[12]; snprintf(UIDbuf, sizeof(UIDbuf), ".%u", nUID); while(1) { const char *path = fmap->get_next(); if(!path) break; // if the last characters in the file name is the string // UIDbuf... char *tmpptr = strstr((char *)path, UIDbuf); if(tmpptr != NULL && (*(tmpptr + strlen(UIDbuf)) == '\0')) { if(stat(path, &st_buffer)) continue; if(!S_ISREG(st_buffer.st_mode)) continue; if(profiles[numberSaveGamesFound].load(path) < 0) continue; if((++numberSaveGamesFound) >= MAX_PROFILES) break; } } numProfiles = numberSaveGamesFound; // If there are no save files, introbase in states.cpp will take // them to the enter_name screen. gather_high_scores(); print_high_scores(); } int score_manager_t::addPlayer(const char *name) { log_printf(D3LOG, "creating profile %d\n", numProfiles); if(numProfiles == MAX_PROFILES) return -1; int ret = 0; #ifdef WIN32 int userid = 42; #else uid_t userid = getuid(); #endif profiles[numProfiles].clear(); strncpy(profiles[numProfiles].name, name, SCORE_NAME_LEN); // TODO: Somewhere around here would be a nice place to check if the // TODO: scoredir exists, and if not, try to create one. // This means that we always create new profiles in the first // scoredir registered. (Loaded score files are written back // where they were read from when changed.) char buf[1024]; snprintf(buf, sizeof(buf), "SCORES>>%s.%u", name, userid); const char *fn = fmap->get(buf, FM_FILE_CREATE); free(profiles[numProfiles].filename); if(fn) profiles[numProfiles].filename = strdup(fn); else { profiles[numProfiles].filename = NULL; log_printf(ELOG, "ERROR: Couldn't resolve player profile" " path '%s'!\n", buf); ret = -2; } log_printf(ULOG, "Created new player profile '%s' for player '%s'\n", fn ? fn : "", profiles[numProfiles].name); currentProfile = numProfiles; // Try to create the high score file. if(profiles[numProfiles].save() < 0) ret = -3; numProfiles++; return ret; } void score_manager_t::select_profile(int prof) { log_printf(D3LOG, "score_manager_t::select_profile(%d)\n", prof); currentProfile = prof; } // Rules: // * Highest score gets highest priority. // * If the maximum number of entries is // exceeded, the lowest score entry is // overwritten. // * best_score and last_scene of the // profile are bumped if exceeded. void score_manager_t::record(s_hiscore_t *entry, int force) { log_printf(D3LOG, "score_manager_t::record\n"); s_profile_t *p = profiles + currentProfile; int write; if(force) write = 1; else write = 0; if(entry->score > p->best_score) { p->best_score = entry->score; write = 1; } if(entry->end_scene > p->last_scene) { p->last_scene = entry->end_scene; write = 1; } int si = -1; if(p->hiscores < HISCORE_SAVE_MAX) { // Grab next free slot si = p->hiscores++; } else { // Find worst score //FIXME: Pick old or new when scores are equal? unsigned int worst_score = entry->score; for(int i = 0; i < HISCORE_SAVE_MAX; ++i) if(p->hiscoretab[i].score <= worst_score) { si = i; worst_score = p->hiscoretab[i].score; } } if(si >= 0) { // Copy and "fix" entry... log_printf(DLOG, "Saving in slot %d.\n", si); p->hiscoretab[si] = *entry; p->hiscoretab[si].profile = p; memcpy(p->hiscoretab[si].name, p->name, SCORE_NAME_LEN); write = 1; } else log_printf(DLOG, "Not saved.\n"); if(write) { log_printf(DLOG, "Writing file %s for player %s...\n", p->filename, p->name); p->save(); gather_high_scores(); print_high_scores(); log_printf(DLOG, " Done!\n"); } } int s_table_cmp(const void *_a, const void *_b) { s_hiscore_t *a = (s_hiscore_t *)_a; s_hiscore_t *b = (s_hiscore_t *)_b; #if 0 if(a->gametype < b->gametype) return 1; else if(a->gametype > b->gametype) return -1; else #endif if(a->score < b->score) return 1; else if(a->score > b->score) return -1; return 0; } void score_manager_t::gather_high_scores(int placeholders) { const int sc[] = { 10000, 9000, 8000, 7000, 6000, 5000, 4000, 3000, 2000, 1000, 0 }; const int st[] = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 }; const char *nm[] = { "DAVID OLOFSON", "AKIRA HIGUCHI", "MASANAO IZUMO", "MAX HORN", "SAMUEL HART", "ANDREAS", "TRICK", "RIKI", "GEORGIE", "JEREMY" }; for(int i = 0; i < MAX_HIGHSCORES; ++i) high_tbl[i].clear(); s_profile_t p; highs = 0; fmap->get_all("SCORES>>", FM_DIR); while(highs < MAX_HIGHSCORES) { const char *path = fmap->get_next(); if(!path) break; if(p.load(path) < 0) continue; s_hiscore_t *hs = p.best_hiscore(); if(!hs) continue; high_tbl[highs] = *hs; memcpy(high_tbl[highs].name, p.name, SCORE_NAME_LEN); high_tbl[highs].profile = NULL; ++highs; } if(placeholders) { //Throw some nice looking names in, if there's room. ;-) int i = 0; while(highs < MAX_HIGHSCORES) { if(!sc[i]) break; memcpy(high_tbl[highs].name, nm[i], SCORE_NAME_LEN); high_tbl[highs].skill = SKILL_CLASSIC; high_tbl[highs].gametype = GAME_SINGLE; high_tbl[highs].score = sc[i]; high_tbl[highs].start_scene = 0; high_tbl[highs].end_scene = st[i]; ++i; ++highs; } } qsort(high_tbl, highs, sizeof(high_tbl[0]), s_table_cmp); } int score_manager_t::highscore(int prof) { if(-1 == prof) return profiles[currentProfile].last_scene; else if(-2 == prof) return high_tbl[0].score; else return profiles[prof].best_score; } void score_manager_t::print_high_scores() { if(!highs) { log_printf(WLOG, "No hiscore entries found!\n"); return; } log_printf(ULOG, "Name Score Start End\n"); for(unsigned int j = 0; j < highs; j++) { log_printf(ULOG, "%-20s %9u %5d %3d\n", high_tbl[j].name, high_tbl[j].score, high_tbl[j].start_scene, high_tbl[j].end_scene); } } KoboDeluxe-0.5.1/screen.cpp0000666000175000001440000006253310730755421012477 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001-2003, 2005, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #ifndef M_PI # define M_PI 3.14159265358979323846 /* pi */ #endif #include "kobo.h" #include "screen.h" #include "manage.h" #include "options.h" #include "enemies.h" #include "myship.h" #include "radar.h" #include "scenes.h" #include "config.h" #include "random.h" #include "version.h" int _screen::scene_max; int _screen::scene_num; int _screen::level; int _screen::generate_count; _map _screen::map; int _screen::show_title = 0; int _screen::do_noise = 0; float _screen::_fps = 40; float _screen::scroller_speed = SCROLLER_SPEED; float _screen::target_speed = SCROLLER_SPEED; int _screen::noise_y = 0; int _screen::noise_h = WSIZE; int _screen::noise_source = B_NOISE; float _screen::noise_fade = 0.0f; float _screen::noise_bright = 0.0f; float _screen::noise_depth = 0.0f; int _screen::highlight_y = WSIZE / 2; int _screen::highlight_h = 0; int _screen::hi_sc[10]; int _screen::hi_st[10]; char _screen::hi_nm[10][20]; int _screen::nstars = 0; KOBO_Star *_screen::stars = NULL; Uint32 _screen::starcolors[STAR_COLORS]; int _screen::star_oxo = 0; int _screen::star_oyo = 0; radar_modes_t _screen::radar_mode = RM_OFF; _screen::~_screen() { free(stars); } void _screen::init() { scene_max = 0; while(scene[scene_max].ratio != -1) scene_max++; } void _screen::render_title_plasma(int t, float fade, int y, int h) { s_sprite_t *s = gengine->get_sprite(B_FOCUSFX, 0); if(!s || !s->surface) return; SDL_Surface *fx = s->surface; SDL_Rect sr; sr.x = 0; sr.w = fx->w; sr.h = 1; for(int ty = 0; ty < h; ++ty) { float sy = (float)ty / (h - 1); float shape = sin(M_PI * sy); float plasma = 0.5f + 0.5f * sin(t * 0.004f + sin(t * 0.00017f) * sy * 18.0f); float plasma2 = 0.5f + 0.5f * sin(t * 0.001f + sin(t * 0.00013f) * sy * 12.0f); int i = (int)((fx->h - 1) * (0.3f * plasma + 0.7f * shape) * fade); int xo = (int)(8192 * plasma2 * gengine->xscale() / 256); xo -= (int)(xo / fx->w) * fx->w; int xmax = wmain->phys_rect.x + wmain->phys_rect.w; for(int x = -xo; x < xmax; x += fx->w) { sr.y = i; RGN_Blit(fx, &sr, x, y + ty); } } } void _screen::render_title_noise(float fade, int y, int h, int bank, int frame) { for(int ty = 0; ty < h; ) { int xo = (int)(pubrand.get(16) * gengine->xscale()) / 256; s_sprite_t *s = gengine->get_sprite(bank, pubrand.get(4)); if(!s || !s->surface) continue; SDL_Surface *fx = s->surface; xo -= (int)(xo / fx->w) * fx->w; int xmax = wmain->phys_rect.x + wmain->phys_rect.w; for(int x = -xo; x < xmax; x += fx->w) RGN_Blit(fx, NULL, x, y + ty); ty += fx->h; } } static int flashin(int t) { if(t < 0) return 1; else if(t > 800) return 0; else return (t % 200) > 100; } void _screen::title(int t, float fade, int mode) { // Enclosed effect s_sprite_t *s = gengine->get_sprite(B_LOGO, 0); if(!s || !s->surface) return; float mf = (1.0f - fade); int h = s->surface->h; int y0 = wmain->phys_rect.y + (int)(60 * gengine->yscale() + 0.5f); int y = (int)(y0 - mf * mf * mf * (y0 + h) + 0.5f); wmain->select(); RGN_Target(gengine->surface()); RGN_SetRegion(logo_region, wmain->phys_rect.x + (int)((wmain->width() - 206) / 2 * gengine->xscale()), y); switch(mode) { case 0: render_title_plasma(t, fade, y, h); break; case 1: render_title_noise(fade, y, h, (int)B_NOISE, 0); break; case 2: render_title_noise(fade, y, h, (int)B_HITNOISE, 0); break; } // Outline wmain->sprite_fxp(PIXEL2CS((wmain->width() - 206) / 2), (int)((y * 256 + 255) / gengine->yscale()) - PIXEL2CS(wmain->y()), B_LOGO, 0); // "DELUXE" wmain->sprite_fxp(PIXEL2CS((wmain->width() - 139) / 2), PIXEL2CS(123) + (int)(PIXEL2CS(160) * mf * mf), B_LOGODELUXE, 0); // Version if(fade > 0.9) { wmain->font(B_NORMAL_FONT); wmain->center(132, KOBO_VERSION); } // Cheat mode warning if((prefs->cmd_cheat || prefs->cmd_pushmove) && (t % 1000 < 500)) { wmain->font(B_MEDIUM_FONT); wmain->center(145, "CHEAT MODE"); } #if 1 // WIP notice if(!flashin(t - 2000)) { wmain->font(B_MEDIUM_FONT); wmain->center(170, "This is a Work in Progress!"); wmain->center(180, "Check http://olofson.net/kobodl"); } #endif } void _screen::init_highscores() { for(unsigned int i = 0; i < 10; ++i) if(i < scorefile.highs) { hi_sc[i] = scorefile.high_tbl[i].score; hi_st[i] = scorefile.high_tbl[i].end_scene; strncpy(hi_nm[i], scorefile.high_tbl[i].name, 19); hi_nm[i][19] = 0; } else { hi_sc[i] = 0; hi_st[i] = 0; strcpy(hi_nm[i], "---"); } } void _screen::highscores(int t, float fade) { int i, y; float mf = (1.0f - fade); mf *= mf * mf * mf * mf; screen.set_highlight(0, 0); wmain->font(B_BIG_FONT); y = (int)(PIXEL2CS(100) * mf) - 256; if(y < 0) y = 0; wmain->center_fxp(PIXEL2CS(20) - y, "HALL OF FAME"); int xo = (int)(50 * 256 * mf); wmain->sprite_fxp(PIXEL2CS(32) - xo, PIXEL2CS(30), B_PLAYER, (t / 50) % 16); wmain->sprite_fxp(PIXEL2CS(wmain->width() - 32) + xo, PIXEL2CS(30), B_PLAYER, 15 - (t / 50) % 16); wmain->font(B_NORMAL_FONT); y = (int)(PIXEL2CS(75) * mf - 0.5f) - 256; if(y < 0) y = 0; wmain->center_fxp(PIXEL2CS(40) - y, "(Score/Stage/Name)"); wmain->font(B_MEDIUM_FONT); float yo = t * (11*18+100) * 256.0 / 12500.0 - PIXEL2CS(110); for(i = 0, y = 65; i < 10; ++i, y += 18) { static char s[20]; float xo, cy; int real_y = PIXEL2CS(y) - (int)yo; if(real_y < PIXEL2CS(55) || real_y > PIXEL2CS(165)) continue; cy = (PIXEL2CS(y) - yo) - PIXEL2CS(65 + 5*18/2); xo = cy*cy*cy*cy*cy * 1e-16; snprintf(s, 16, "%d", hi_sc[i]); wmain->center_token_fxp(PIXEL2CS(70)+(int)xo, real_y, s); snprintf(s, 16, "%d", hi_st[i]); wmain->center_token_fxp(PIXEL2CS((70+125)/2)+(int)xo, real_y, s, -1); wmain->string_fxp(PIXEL2CS(125)+(int)xo, real_y, hi_nm[i]); } #if 1 if(!flashin(t - 1000)) { wmain->font(B_MEDIUM_FONT); wmain->center(170, "NOTE: Highscores for \"Classic\" only!"); wmain->center(180, "The new skill levels are experimental."); } #endif } void _screen::credits(int t) { if((t % 4000 < 3600) && (t / 4000 <= 2)) screen.set_highlight(102, 70); else screen.set_highlight(0, 0); int t2 = 10 * (t % 4000) / 3700; if(t % 4000 < 3700) switch(t / 4000) { case 0: wmain->font(B_BIG_FONT); if(t2 > 0) wmain->center(80, "DAVID OLOFSON"); wmain->font(B_NORMAL_FONT); if(t2 > 2) wmain->center(105, "New SDL Audio & GFX Engines"); if(t2 > 3) wmain->center(115, "New Graphics, Sound & Music"); break; case 1: wmain->font(B_BIG_FONT); if(t2 > 0) wmain->center(80, "AKIRA HIGUCHI"); wmain->font(B_NORMAL_FONT); if(t2 > 2) wmain->center(110, "XKobo - The Original Game"); break; case 2: wmain->font(B_BIG_FONT); if(t2 > 0) wmain->center(80, "MASANAO IZUMO"); wmain->font(B_NORMAL_FONT); if(t2 > 2) wmain->center(105, "Original Sounds"); if(t2 > 3) wmain->center(115, "Original Sound Engine"); break; } if(!flashin(t - 11000)) { wmain->font(B_MEDIUM_FONT); wmain->center(170, "Additional Credits & Thanks"); wmain->center(180, "in the scroller below"); } } void _screen::help(int t) { wmain->font(B_BIG_FONT); wmain->center(53, "HOW TO PLAY"); // 0..3000: Control if(t < 200) screen.set_highlight(112, 80); else if(t < 2800) { if(t > 2700) screen.set_highlight(0, 0); wmain->font(B_MEDIUM_FONT); wmain->sprite(wmain->width() / 2, 105, B_PLAYER, (t / 50) % 16); wmain->center(125, "Use arrow keys or NumPad."); wmain->center(135, "to control the ship."); } else if(t < 3000) return; // 3000..6000: Fire else if(t < 3200) screen.set_highlight(112, 80); else if(t < 5800) { if(t > 5700) screen.set_highlight(0, 0); wmain->font(B_MEDIUM_FONT); int i; for(i = 0; i < 4; ++i) { int t2 = t + 153 * i; wmain->sprite(wmain->width() / 2 - (t2 / 5) % 120, 105, B_BOLT, 8 + (t2 / 50) % 4); wmain->sprite(wmain->width() / 2 + (t2 / 5) % 120, 105, B_BOLT, 8 + (t2 / 50) % 4); } wmain->sprite(wmain->width() / 2, 105, B_PLAYER, 4); wmain->center(135, "Use any SHIFT or CONTROL keys to fire."); } else if(t < 6000) return; // 6000..9000: Bases else if(t < 6200) screen.set_highlight(112, 80); else if(t < 8800) { if(t > 8700) screen.set_highlight(0, 0); wmain->font(B_MEDIUM_FONT); // TODO: Short demo of how to destroy a base int i; for(i = B_TILES1; i <= B_TILES5; ++i) { int xo = 24 * i - (5 * 24 / 2) + 4; wmain->sprite(wmain->width() / 2 + xo, 105 - 8, i, 7); } wmain->center(135, "Destroy bases by shooting their cores."); } else if(t < 9000) return; // 9000..14000: Shoot everything! else if(t < 9200) screen.set_highlight(112, 80); else if(t < 13800) { if(t > 13700) screen.set_highlight(0, 0); wmain->font(B_MEDIUM_FONT); // TODO: Short demo of intense battle wmain->sprite(50, 110, B_RING, (t / 30) % 16); wmain->sprite(65, 90, B_BOMB, (t / 40) % 16); wmain->sprite(80, 110, B_BMR_GREEN, (t / 80) % 16); wmain->sprite(95, 90, B_BMR_PURPLE, (t / 70) % 16); wmain->sprite(110, 110, B_BMR_PINK, (t / 60) % 16); wmain->sprite(125, 90, B_FIGHTER, (t / 50) % 16); wmain->sprite(140, 110, B_MISSILE1, (t / 45) % 16); wmain->sprite(155, 90, B_MISSILE2, (t / 40) % 16); wmain->sprite(170, 110, B_MISSILE3, (t / 55) % 16); wmain->center(125, "Shoot everything that moves,"); wmain->center(135, "but avoid getting hit!"); } else if(t < 14000) return; // 14000..20000: Indestructible else if(t < 14200) screen.set_highlight(112, 80); else if(t < 19800) { if(t > 19700) screen.set_highlight(0, 0); wmain->font(B_MEDIUM_FONT); // TODO: Demo destroying a rock in Gamer mode? int i; for(i = B_TILES1; i <= B_TILES5; ++i) { int xo = 24 * i - (5 * 24 / 2) + 4; wmain->sprite(wmain->width() / 2 + xo, 82 - 8, i, 0); } wmain->center(87, "Some objects are indestructible..."); wmain->sprite(65, 120, B_ROCK1, (t / 45) % 32); wmain->sprite(90, 115, B_ROCK2, (t / 40) % 32); wmain->sprite(115, 125, B_ROCK3, (t / 35) % 48); wmain->sprite(155, 120, B_BIGSHIP, (t / 40) % 16); wmain->center(135, "...or take many hits to destroy."); } } void _screen::scroller() { if(do_noise) return; /* * Adjust scroller speed according to * frame rate, for readability. */ if(_fps < 30) target_speed = SCROLLER_SPEED / 2; else if(_fps > 40) target_speed = SCROLLER_SPEED; scroller_speed += (target_speed - scroller_speed) * 0.05; static const char scrolltext[] = "Welcome to KOBO DELUXE, an enhanced version of " "Akira Higuchi's fabulous X-Window game XKOBO. " " " "KOBO DELUXE uses SDL, the Simple DirectMedia " "Layer (www.libsdl.org) for graphics and input, " "and Audiality (olofson.net/audiality) for sound " "and music. " " " "KOBO DELUXE has been known to hinder productivity on: " " " " - " "Windows 95/98/ME - " "Windows 2000/XP - " "Mac OS X (PPC) - " "BeOS (x86, PPC) - " "AmigaOS (68k, PPC) - " "Solaris (x86, SPARC) - " "QNX (x86) - " "GNU/Linux (x86, x86_64, PPC, PPC64) - " "OpenBSD (x86, PPC, SPARC, SPARC64) - " "FreeBSD (x86) - " "NetBSD (x86) - " "IRIX - " "OS/2 - " "PlayStation 2/PS2Linux - " "Xbox - " "Syllable - " "ITOS (Nokia internet tablets) - " " " "Any help in the Cause of Infiltrating Further " "Platforms is Greatly Appreciated! " " " "Additional Credits & Thanks to: " " Torsten Giebl (Slackware)" " David Andersson (Some Good Ideas)" " Samuel Hart (Joystick Support)" " Max Horn (Mac OS X)" " Jeremy Sheeley (Player Profiles)" " Tsuyoshi Iguchi (FreeBSD, NetBSD)" " G. Low (Solaris)" " Gerry Jo \"Trick\" Jellestad (Testing & Ideas)" " \"Riki\" (Intel Compiler)" " Andreas Spaangberg (Sun Compiler)" " \"SixK\" (Amiga Port)" " Joey Hess (Debian)" " Martijn van Oosterhout (FPS limiter)" " Antonio Messina (Stage 1601+, Always Fire)" " Hans de Goede (Audio bug)" " Marianne Ibbotson (\"Autopause\")" " Sam Palmer (Windows testing)" " Michael Sterrett (glSDL issues)" " Sam Lantinga & Others (SDL)" " Members of the SDL Mailing List" " " "Additional Thanks from Akira Higuchi Go To: " " Bruce Cheng" " Christoph Lameter" " Davide Rossi" " Eduard Martinescu" " Elan Feingold" " Helmut Hoenig" " Jeff Epler" " Joe Ramey" " Joey Hess" " Michael Sterrett" " Mihail Iotov" " Shoichi Nakayama" " Thomas Marsh" " Torsten Wolnik" " " "And as we said in the old days... " " " " "; // FIXME: Nasty static state variables... static const char *stp = scrolltext; static int pos = PIXEL2CS(SCREEN_WIDTH); static int t = 0; int nt = (int)SDL_GetTicks(); int dt = nt - t; t = nt; if(dt > 100) dt = 100; static int fdt = 0; fdt += ((dt<<8) - fdt) >> 3; pos -= (fdt * PIXEL2CS((int)scroller_speed) + 128000) / 256000; wmain->font(B_BIG_FONT); wmain->string_fxp(pos, PIXEL2CS(200), stp); /* * Chop away characters at the left edge */ char buf[2] = {*stp, 0}; int cw = wmain->textwidth_fxp(buf); if(-pos > cw) { pos += cw; ++stp; if(*stp == 0) { // Wrap! pos = PIXEL2CS(SCREEN_WIDTH); stp = scrolltext; } } } void _screen::init_scene(int sc) { map.init(); if(sc < 0) { /* * Intro mode */ show_title = 1; myship.off(); enemies.off(); if(sc == INTRO_SCENE) { /* * Plain intro - no map */ radar_mode = RM_OFF; /* Clear radar */ scene_num = 19; level = 0; } else { /* * Map selection - show current map */ radar_mode = RM_SHOW; scene_num = -(sc+1) % scene_max; level = -(sc+1) / scene_max; } } else { /* * In-game mode */ show_title = 0; scene_num = sc % scene_max; level = sc / scene_max; radar_mode = RM_RADAR; } gengine->period(game.speed); sound.period(game.speed); const _scene *s = &scene[scene_num]; int i; for(i = 0; i < s->base_max; i++) map.make_maze(s->base[i].x, s->base[i].y, s->base[i].h, s->base[i].v); map.convert(s->ratio); generate_count = 0; wradar->mode(radar_mode); } int _screen::prepare() { if(scene_num < 0) return 0; const _scene *s = &scene[scene_num]; int i, j; int count_core = 0; int c = 0; int lc = level > 31 ? 31 : level; int interval_1 = (s->ek1_interval) >> lc; int interval_2 = (s->ek2_interval) >> lc; if(interval_1 < 4) interval_1 = 4; if(interval_2 < 4) interval_2 = 4; enemies.set_ekind_to_generate(s->ek1, interval_1, s->ek2, interval_2); wmain->clear(); for(i = 0; i < MAP_SIZEX; i++) for(j = 0; j < MAP_SIZEY; j++) { int m = MAP_BITS(map.pos(i, j)); if(IS_SPACE(m)) continue; if((m == U_MASK) || (m == R_MASK) || (m == D_MASK) || (m == L_MASK)) { enemies.make(&cannon, i * 16 + 8, j * 16 + 8); c++; } else if(m & CORE) { enemies.make(&core, i * 16 + 8, j * 16 + 8); count_core++; c++; } } myship.set_position(s->startx << 4, s->starty << 4); return count_core; } void _screen::generate_fixed_enemies() { static int sint[16] = { 0, 12, 23, 30, 32, 30, 23, 12, 0, -12, -23, -30, -32, -30, -23, -12 }; static int cost[16] = { 32, 30, 23, 12, 0, -12, -23, -30, -32, -30, -23, -12, 0, 12, 23, 30 }; const _scene *s = &scene[scene_num]; if(generate_count < s->enemy_max) { int j; for(j = 0; j < s->enemy[generate_count].num; j++) { int sp = s->enemy[generate_count].speed; int x, y, h, v, t; x = gamerand.get() % (WORLD_SIZEX - VIEWLIMIT * 2); y = gamerand.get() % (WORLD_SIZEY - VIEWLIMIT * 2); x -= (WORLD_SIZEX / 2 - VIEWLIMIT); y -= (WORLD_SIZEY / 2 - VIEWLIMIT); if(x < 0) x -= VIEWLIMIT; else x += VIEWLIMIT; if(y < 0) y -= VIEWLIMIT; else y += VIEWLIMIT; x += myship.get_x(); y += myship.get_y(); t = gamerand.get(4); h = PIXEL2CS(sp * sint[t]) / 64; v = PIXEL2CS(sp * cost[t]) / 64; enemies.make(s->enemy[generate_count].kind, x, y, h, v); } generate_count++; } if(generate_count >= s->enemy_max) generate_count = 0; } void _screen::set_map(int x, int y, int n) { if(n == 0) map.clearpos(x, y); else map.pos(x, y) = n; wradar->update(x, y); } void _screen::render_noise(window_t *win) { if(!do_noise) return; if(noise_fade < 0.01f) return; int ymax = noise_y + noise_h; int np = pubrand.get(8); int dnp = pubrand.get(4) - 8; float ifade = 1.0f - noise_fade; float step = 1.0f + ifade*ifade*ifade * 5.0f; float rstep = (ifade + ifade*ifade*ifade * 10.0f) / 256.0f; if(step < 1.0f) step = 1.0f; if(rstep < 0.0f) rstep = 0.0f; for(float fy = noise_y + pubrand.get(8) * rstep; fy < ymax; fy += step + pubrand.get(8) * rstep) { int xo = PIXEL2CS(pubrand.get(NOISE_SIZEX_LOG2)); int xmax = ((WSIZE + CS2PIXEL(xo)) >> NOISE_SIZEX_LOG2) + 1; dnp += pubrand.get(3) - 4 + pubrand.get(1); np += dnp; if(np > 255) np = 255, dnp = -dnp / 2; else if(np < 0) np = 0, dnp = -dnp / 2; float level = np * noise_depth * (1.0f - noise_bright) / 255.0f + noise_bright; for(int x = 0; x < xmax; ++x) win->sprite_fxp(PIXEL2CS(x<height() / 2; static float ypos = -50; static float hf = 0; static int ot = 0; int t = (int)SDL_GetTicks(); int dt = t - ot; ot = t; if(dt > 1000) dt = 100; //Spring + friction style velocity component if(dt < 500) ypos += ((float)highlight_y - ypos) * (float)dt * 0.005f; else ypos = (float)highlight_y; //Constant velocity component float v = (float)dt * 0.2f; if((float)highlight_y - ypos > v) ypos += v; else if((float)highlight_y - ypos < -v) ypos -= v; else ypos = (float)highlight_y; // Scale to new height hf += ((float)highlight_h - hf) * (float)dt * 0.01f; // Render! int y = (int)((ypos - hf / 2.0f) * 256.0f); int h = (int)(hf * 256.0f); if(h < 128) return; for(int ty = -256; ty <= h; ty += h + 256) { int xo = PIXEL2CS(pubrand.get(NOISE_SIZEX_LOG2)); int xmax = ((WSIZE + CS2PIXEL(xo)) >> NOISE_SIZEX_LOG2) + 1; for(int x = 0; x < xmax; ++x) wmain->sprite_fxp(PIXEL2CS(x << NOISE_SIZEX_LOG2) - xo, ty + y, B_NOISE, 6); } int x0 = win->phys_rect.x; s_sprite_t *s = gengine->get_sprite(B_FOCUSFX, 0); if(!s || !s->surface) return; SDL_Surface *fx = s->surface; SDL_Surface *dst = gengine->surface(); y = (int)((y * gengine->yscale() + 128) / 256) + win->phys_rect.y; h = (int)(hf * gengine->yscale()); win->select(); for(int ty = 0; ty < h; ++ty) { float sy = (float)ty / (h - 1); float scy = sy * hf; float shape = 1.0f - sin(M_PI * sy); float edges = shape * shape * shape; float plasma = 0.5f + 0.5f * sin(t * 0.004f + sin(t * 0.00017f) * scy * 0.18f); float plasma2 = 0.5f + 0.5f * sin(t * .003 + sin(t * 0.0001f) * scy * 0.12f); int i = (int)((fx->h - 1) * ((.5f * plasma + .5f * plasma * shape) * (1.0f - edges) + edges)); int xo = (int)((t * 10 + 8192 * plasma2) * gengine->xscale() / 256); xo -= (int)(xo / fx->w) * fx->w; int xmax = (int)((WSIZE * gengine->xscale() + xo) / fx->w); for(int x = 0; x <= xmax; ++x) { SDL_Rect sr, dr; sr.x = 0; sr.y = i; sr.w = fx->w; sr.h = 1; dr.x = x0 + (int)(x * fx->w) - xo; dr.y = y + ty; SDL_BlitSurface(fx, &sr, dst, &dr); } } } void _screen::set_highlight(int y, int h) { highlight_y = y; highlight_h = h; } // This starfield implementation may seem a bit backwards. Instead of moving // around in a 3D point cloud, projecting by dividing x and y by z etc, we're // doing a plain orthogonal projection. That is, the z coordinates have no // direct impact on rendering! // What actually creates the parallax effect is that we scroll the *stars* // around at different speeds, depending on their distance from the screen, // which effectively replaces the usual (x/z, y/z) operation when projecting. // The interesting part is that stars wrap around the edges automatically as // a side effect of the integer arithmetics. Thus we can have a nice, dense // "3D" starfield covering the whole window - no nearby stars way off screen, // and no distant stars wrapping around in a small square in the middle of the // screen. No clipping is needed, and thus, no cycles are wasted animating off- // screen stars. // Of course, this design means we cannot move along the Z axis (well, not // trivially, at least), but we don't really need that here anyway. // #define WSX (WORLD_SIZEX << 8) #define WSY (WORLD_SIZEY << 8) void _screen::render_starfield(window_t *win, int xo, int yo) { int i; int w = win->width() * 256; int h = win->height() * 256; int xc = w / 2; int yc = h / 2; // Calculate delta from last position, dealing with map position wrap int dx = (xo - star_oxo) & (WSX - 1); star_oxo = xo; if(dx & (WSX >> 1)) dx |= 1 - (WSX - 1); int dy = (yo - star_oyo) & (WSY - 1); star_oyo = yo; if(dy & (WSY >> 1)) dy |= 1 - (WSY - 1); // Scale the deltas to compensate for window/starfield size mismatch // (Otherwise stars at zero distance won't sync up with the map as // intended!) dx = (dx << 16) / w; dy = (dy << 16) / h; /* (Re-)initialize starfield */ if(nstars != prefs->stars) { free(stars); nstars = prefs->stars; stars = (KOBO_Star *)malloc(nstars * sizeof(KOBO_Star)); if(!stars) { nstars = 0; return; // Out of memory!!! } for(i = 0; i < nstars; ++i) { stars[i].x = pubrand.get(); stars[i].y = pubrand.get(); int zz = 255 * i / nstars; stars[i].z = 65025 - zz * zz; } } // Map colors (Should be done elsewhere, but must be re-done after // restarting video!) for(i = 0; i < STAR_COLORS; i += 2) { int c = 64 + i * (255 - 64) / STAR_COLORS; starcolors[STAR_COLORS - i - 1] = win->map_rgb( win->fadergb(0x6699cc, c)); starcolors[STAR_COLORS - i - 2] = win->map_rgb( win->fadergb(0x999966, c)); } win->select(); for(i = 0; i < nstars; ++i) { int z = (int)stars[i].z >> (16 - STAR_ZBITS); // Move stars with deltas scaled by 'z' stars[i].x -= (dx << 8) / (z + STAR_Z0); stars[i].y -= (dy << 8) / (z + STAR_Z0); // Scale and center int x = (stars[i].x * (w >> 8) >> 8) + xc; int y = (stars[i].y * (h >> 8) >> 8) + yc; // Plot! win->foreground(starcolors[z * STAR_COLORS >> STAR_ZBITS]); int s = 256 - (z * 128 >> STAR_ZBITS); win->fillrect_fxp(x, y, s, s); } } void _screen::render_background(window_t *win) { if(!win) return; if(do_noise && (noise_fade >= 1.0f)) return; int vx, vy, xo, yo, x, y, xmax, ymax; int mx, my; vx = gengine->xoffs(LAYER_BASES); vy = gengine->yoffs(LAYER_BASES); /* * Start exactly at the top-left corner * of the tile visible in the top-left * corner of the display window. */ xo = vx & (PIXEL2CS(CHIP_SIZEX) - 1); yo = vy & (PIXEL2CS(CHIP_SIZEY) - 1); mx = CS2PIXEL(vx >> CHIP_SIZEX_LOG2); my = CS2PIXEL(vy >> CHIP_SIZEY_LOG2); ymax = ((WSIZE+CS2PIXEL(yo)) >> CHIP_SIZEY_LOG2) + 1; xmax = ((WSIZE+CS2PIXEL(xo)) >> CHIP_SIZEX_LOG2) + 1; /* * NOTE: * We need to clear regardless of starfield mode, as the new tiles * use alpha/colorkey. */ win->clear(); /* Render parallax starfield, if selected */ if(prefs->starfield == STARFIELD_PARALLAX) render_starfield(win, vx, vy); int tileset = B_TILES1 + (scene_num / 10) % 5; switch(prefs->starfield) { case STARFIELD_NONE: case STARFIELD_PARALLAX: /* Ignore star tiles */ for(y = 0; y < ymax; ++y) for(x = 0; x < xmax; ++x) { int n = map.pos(mx + x, my + y); if(IS_SPACE(n)) continue; win->sprite_fxp(PIXEL2CS(x<> 8); } break; case STARFIELD_OLD: /* Draw all tiles, XKobo style */ for(y = 0; y < ymax; ++y) for(x = 0; x < xmax; ++x) { int n = map.pos(mx + x, my + y); int b = IS_SPACE(n) ? B_OLDSTARS : tileset; win->sprite_fxp(PIXEL2CS(x<> 8); } break; } } void _screen::render_fx(window_t *win) { if(!win) return; render_noise(win); render_highlight(win); } void _screen::fps(float f) { _fps = f; } void _screen::noise(int on) { do_noise = on; } KoboDeluxe-0.5.1/filemap.cpp0000666000175000001440000003605210732334454012633 00000000000000/*(LGPL) ------------------------------------------------------------ filemap.cpp - Simple Portable File Path Mapper ------------------------------------------------------------ * Copyright (C) David Olofson, 2001, 2003, 2007 * This code is released under the terms of the GNU LGPL. */ #include "config.h" #include "kobolog.h" #include "filemap.h" #include #include #include #include #ifdef HAVE_STAT #include #include #endif fm_object_t::~fm_object_t() { free(path); } /* * Delete the 'count' first bytes of a string. * Does *not* realloc(), so it's safe to use * on static or local (stack) buffers. * * Returns new length of string. */ static int strdel(char *str, int count) { int len = strlen(str); memmove(str, str+count, len-count+1); return len-count; } /* * Inserts string 'ins' into 'str', starting at 'pos'. * Does *not* realloc(), so it's safe to use * on static or local (stack) buffers. * * Relies on FM_BUFFER_SIZE to prevent buffer overflow! * (In fact, it stops at (str + FM_BUFFER_SIZE - 1) to * ensure that the result is NULL terminated.) * * Returns new length of string. */ static int strins(char *str, const char *ins, int pos) { char *cpy = strdup(str+pos); if(!cpy) return strlen(str); //Silly but harmless... snprintf(str+pos, FM_BUFFER_SIZE-pos-1, "%s%s", ins, cpy); str[FM_BUFFER_SIZE - 1] = 0; free(cpy); return strlen(str); } filemapper_t::filemapper_t() { keys = NULL; app_path = strdup("."); next_buffer = 0; objects = NULL; current_obj = NULL; /* * I'll put this here for now. * Don't know if it's the perfect place... */ char *home = (char *)getenv("HOME"); if(home) addpath("HOME", home); } filemapper_t::~filemapper_t() { fm_key_t *k = keys; while(k) { fm_key_t *nk = k->next; free(k->path); delete k; k = nk; } while(objects) { fm_object_t *o = objects; objects = objects->next; delete o; } free(app_path); } char *filemapper_t::salloc() { char *b = buffers[next_buffer++]; if(next_buffer >= FM_BUFFERS) next_buffer = 0; return b; } void filemapper_t::no_double_slashes(char *buf) { /* * Clean slashes */ char *c = buf; while(c[0]) { if(c[0] == '/') { if(0 == c[1]) c[0] = 0; else while('/' == c[1]) strdel(c + 1, 1); } ++c; } } void filemapper_t::unix_slashes(char *buf) { /* * Convert "~/" into "HOME>>". */ if(strncmp(buf, "~/", 2) == 0) { strdel(buf, 2); strins(buf, "HOME" FM_DEREF_TOKEN, 0); } #if defined(WIN32) int len = strlen(buf); for(int i = 0; i < len; ++i) if(buf[i] == '\\') buf[i] = '/'; #elif defined(MACOS) int start = 0; int len = strlen(buf); for(int i = start; i < len; ++i) if(buf[i] == ':') buf[i] = '/'; #endif no_double_slashes(buf); } void filemapper_t::sys_slashes(char *buf) { no_double_slashes(buf); #if defined(WIN32) int len; if(strncmp(buf, "./", 2) == 0) len = strdel(buf, 2); else len = strlen(buf); for(int i = 0; i < len; ++i) if(buf[i] == '/') buf[i] = '\\'; #elif defined(MACOS) /* * Untested. */ int len; if(strncmp(buf, "./", 2) == 0) len = strdel(buf, 2); else len = strlen(buf); /* Fix absolute/relative */ if(buf[0] == '/') len = strdel(buf, 1); else { memmove(buf + 1, buf, len); ++len; buf[0] = ':'; } /* * '/' --> ':' */ for(int i = 0; i < len; ++i) if(buf[i] == '/') buf[i] = ':'; /* * "..:" --> "::" */ for(int i = 0; i < len; ++i) if(strncmp(buf + i, "..:", 3) == 0) { strdel(buf + i, 1); buf[i] = ':'; --len; } #endif } void filemapper_t::exepath(const char *appname) { free(app_path); app_path = strdup(sys2unix(appname)); if(app_path) { char *c = strrchr(app_path, '/'); if(c) c[0] = 0; else { free(app_path); app_path = strdup("."); } } else app_path = strdup("."); addpath("EXE", app_path); log_printf(DLOG, "Application path: '%s'\n", app_path); } void filemapper_t::addpath(const char *key, const char *path, int first) { fm_key_t *k, *insk; try { k = new fm_key_t; strncpy(k->key, key, 8); k->key[8] = 0; k->path = strdup(path); if(!k->path) { delete k; return; } if(first) { k->next = keys; keys = k; } else { k->next = NULL; if(keys) { insk = keys; while(insk->next) insk = insk->next; insk->next = k; } else keys = k; } } catch(...) { return; } } fm_key_t *filemapper_t::getkey(fm_key_t *key, const char *ref) { int all = ref ? 0 : (ref[0] == '*'); if(key) { if(!ref) ref = key->key; else if(all) return key->next; else key = key->next; } else { if(!ref || all) return keys; else key = keys; } while(key) { if(strcmp(key->key, ref) == 0) return key; key = key->next; } return NULL; } /* * Checks if an object exists, and if so, what kind it is. */ int filemapper_t::probe(const char *syspath) { #ifdef HAVE_STAT struct stat st; // log_printf(DLOG, "probe(\"%s\") (with stat())\n", syspath); if(::stat(syspath, &st) == 0) { if(S_ISDIR(st.st_mode)) return FM_DIR; else return FM_FILE; } #else #warning This platform lacks stat(). File/directory probing may be unreliable! // This is wrong and weird, but *does* in fact // work on Linux... where it isn't needed! *heh* // (Opening a dir with "r" will succeed on Linux, BTW...) FILE *f = ::fopen(syspath, "r+"); // log_printf(DLOG, "probe(\"%s\") (with fopen())\n", syspath); if(f) { ::fclose(f); return FM_FILE; } else if(errno == EISDIR) return FM_DIR; #endif return FM_ERROR; } /* * Create a file for writing, or if it exists, test if it * can be opened in write mode. * * Returns * FM_FILE if the file exists and is writable, * FM_FILE_CREATE if the file had to be created, * FM_DIR if the path leads to a directory, or * FM_ERROR if the object is not a writable file. */ int filemapper_t::test_file_create(const char *syspath) { int exists = (probe(syspath) == FM_FILE); FILE *f = ::fopen(syspath, "a"); if(f) { fclose(f); if(exists) { // log_printf(DLOG, " File is writable!\n"); return FM_FILE; } else { // log_printf(DLOG, " File created!\n"); return FM_FILE_CREATE; } } else { if(errno == EISDIR) { // log_printf(DLOG, " Is a directory.\n"); return FM_DIR; } // else // log_printf(DLOG, " Nope.\n"); } return FM_ERROR; } int filemapper_t::test_file_dir_any(const char *syspath, int kind) { int res = probe(syspath); switch (res) { case FM_ERROR: // log_printf(DLOG, " Nope.\n"); break; case FM_FILE: if((kind == FM_ANY) || (kind == FM_FILE)) { // log_printf(DLOG, " Found! (File)\n"); return 1; } break; case FM_DIR: if((kind == FM_ANY) || (kind == FM_DIR)) { // log_printf(DLOG, " Found! (Dir)\n"); return 1; } break; case FM_ANY: log_printf(ELOG, "INTERNAL ERROR: filemapper_t::probe()" " returned FM_ANY...\n"); break; } if(res != FM_ERROR) switch (kind) { case FM_FILE: // log_printf(DLOG, " Not a file.\n"); break; case FM_DIR: // log_printf(DLOG, " Not a directory.\n"); break; default: break; } return 0; } char *filemapper_t::sys2unix(const char *syspath) { char *buffer = salloc(); strncpy(buffer, syspath, FM_BUFFER_SIZE - 1); buffer[FM_BUFFER_SIZE - 1] = 0; unix_slashes(buffer); return buffer; } char *filemapper_t::unix2sys(const char *path) { char *buffer = salloc(); strncpy(buffer, path, FM_BUFFER_SIZE - 1); buffer[FM_BUFFER_SIZE - 1] = 0; sys_slashes(buffer); return buffer; } /* * Try the specified operation on a path. * The path must be in *system* format. */ int filemapper_t::try_get(const char *path, int kind) { switch (kind) { case FM_FILE: case FM_DIR: case FM_ANY: if(test_file_dir_any(path, kind)) return 1; break; case FM_FILE_CREATE: switch (test_file_create(path)) { case FM_FILE: case FM_FILE_CREATE: return 1; default: break; } break; default: break; } return 0; } void filemapper_t::add_object(const char *path, int kind) { try { fm_object_t *obj = new fm_object_t; obj->path = strdup(path); if(!obj->path) { delete obj; return; } obj->kind = kind; obj->next = NULL; if(objects) { fm_object_t *insobj = objects; while(insobj->next) insobj = insobj->next; insobj->next = obj; } else objects = obj; } catch(...) { return; } } /* * Parse the specified path, recurse through all possible * combinations, trying each terminal with try_get(). * * When the 'build' argument is 0, the function returns * the first valid hit. * * 'ref' must be in unix format, but 'result' will be in * system format. * * NEW MODE: * When the 'build' argument is non-zero, all * possible paths are generated and tested. All * valid objects are added to a linked list of * fm_object_t. * * Note that in this mode, 'result' is not used * or set! You may pass NULL. * TODO: Wildcards... * */ int filemapper_t::recurse_get(char *result, const char *ref, int kind, int level, int build) { // log_printf(DLOG, " [level %d]\n", level); char buffer[FM_BUFFER_SIZE]; strncpy(buffer, ref, FM_BUFFER_SIZE); // Check for the ">>" dereferencing token. char *obj = (char *)strstr(ref, FM_DEREF_TOKEN); // If there isn't one, the object path will // be tried as is. if(!obj) { int res; snprintf(buffer, FM_BUFFER_SIZE, "%s", ref); buffer[FM_BUFFER_SIZE-1] = 0; #if 0 { for(int s=0; s>" if(len > 8) len = 8; memcpy(kclass, ref, len); kclass[len] = 0; fm_key_t *k = NULL; int hits = 0; while( (k = getkey(k, kclass)) ) { ++hits; snprintf(buffer, FM_BUFFER_SIZE, "%s/%s", k->path, obj); buffer[FM_BUFFER_SIZE-1] = 0; #if 0 { for(int s=0; spath); if(dt[2] == '/') // No slash after ">>"! strdel(dt + 2, 1); res = recurse_get(buffer, buffer, kind, level + 1, build); } else { // log_printf(DLOG, "Trying '%s' -> '%s'...", k->key, // k->path); sys_slashes(buffer); res = try_get(buffer, kind); if(build && res) add_object(buffer, kind); } if(res && !build) { strncpy(result, buffer, FM_BUFFER_SIZE); return 1; } } #if 0 if(!hits) { for(int s=0; snext; delete obj; } if(kind == FM_FILE_CREATE) { // log_printf(ELOG, "filemapper_t: Tried to create files" // " in get_all()!\n"); return; } #if 0 else if(kind == FM_DIR) log_printf(DLOG, "get_all('%s', DIR)...", ref); else log_printf(DLOG, "get_all('%s')...", ref); #endif recurse_get(NULL, ref, kind, 1, 1); current_obj = objects; current_dir = NULL; } const char *filemapper_t::get_next() { while(1) { if(!current_dir) { // // Get next object! // if(!current_obj) return NULL; //All done. switch(probe(current_obj->path)) { case FM_FILE: { const char *res = current_obj->path; current_obj = current_obj->next; // log_printf(DLOG, "get_next() found file '%s'.\n", res); return res; } case FM_DIR: current_dir = ::opendir(current_obj->path); // log_printf(DLOG, "get_next() found dir '%s'.\n", // current_obj->path); if(!current_dir) { //Couldn't opendir()! Skip object... current_obj = current_obj->next; continue; } break; default: //Probing failed! Skip this object. // log_printf(DLOG, "get_next(): Object '%s' skipped!\n", // current_obj->path); current_obj = current_obj->next; continue; } } // // Get first/next dir entry! // struct dirent *d = readdir(current_dir); if(!d) { // Error or end-of-dir ==> try next object closedir(current_dir); current_dir = NULL; current_obj = current_obj->next; // log_printf(DLOG, "get_next(): end-of-dir\n"); continue; } // Get dir entry char *path = salloc(); if(!path) { log_printf(CELOG, "Out of memory in get_next()!\n", path); return NULL; } // Skip "parent dir" links! #ifdef MACOS if(!strcmp(d->d_name, "::")) //??? #else if(!strcmp(d->d_name, ".") || !strcmp(d->d_name, "..")) #endif continue; // Check dir entry! snprintf(path, FM_BUFFER_SIZE, #ifdef WIN32 "%s\\%s", #elif defined(MACOS) "%s:%s", #else "%s/%s", #endif current_obj->path, d->d_name); switch(probe(path)) { case FM_FILE: // log_printf(DLOG, "get_next() found file '%s'.\n", path); return path; case FM_DIR: //We don't do recursive, so skip subdirs... // log_printf(DLOG, "get_next() found dir '%s'.\n", path); continue; default: // log_printf(DLOG, "get_next() found crap in dir.\n"); continue; } } } FILE *filemapper_t::fopen(const char *ref, const char *mode) { const char *path = NULL; int md = 0; if(strchr(mode, 'r')) md = 1; else if(strchr(mode, 'w')) md = 3; else if(strchr(mode, 'a')) md = 5; if(md) if(strchr(mode, '+')) md += 1; switch(md) { case 0: //Error! return NULL; case 1: //r case 2: //r+ path = get(ref, FM_FILE); break; case 3: //w case 4: //w+ case 5: //a case 6: //a+ path = get(ref, FM_FILE_CREATE); break; } if(path) return ::fopen(path, mode); else return NULL; } DIR *filemapper_t::opendir(const char *ref) { const char *path = get(ref, FM_DIR); if(path) return ::opendir(path); else return NULL; } int filemapper_t::mkdir(const char *ref, int perm) { log_printf(ELOG, "filemapper_t::mkdir() not yet implemented!\n"); return -1; #if 0 const char *path = get(ref, FM_DIR_CREATE); // ::mkdir(path, perm); #endif } void filemapper_t::print(FILE *f, const char *ref) { char key[9]; key[8] = 0; char *obj = (char *)strstr(ref, FM_DEREF_TOKEN); if(!obj) strncpy(key, ref, 8); else { int len = obj - ref; strncpy(key, ref, 8); if(len > 8) len = 8; key[len] = 0; } int all = (key[0] == '*'); fm_key_t *k = keys; while(k) { if(strcmp(k->key, key) == 0 || all) fprintf(f, "%s"FM_DEREF_TOKEN" --> \"%s\"\n", k->key, k->path); k = k->next; } } KoboDeluxe-0.5.1/prefs.cpp0000666000175000001440000001667610734164121012341 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003, 2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kobolog.h" #include "prefs.h" #include "gfxengine.h" #include "gamectl.h" #include "a_types.h" #include "game.h" void prefs_t::init() { comment("--------------------------------------------"); comment(" Kobo Deluxe "VERSION" Configuration File"); comment("--------------------------------------------"); comment(" Switches - [no]"); comment(" Values - [|\"\"]"); comment("--------------------------------------------"); comment("--- System options --------------------------"); yesno("logfile", logfile, 0); desc("Log To File"); key("logformat", logformat, 0); desc("Log File Format"); key("logverbosity", logverbosity, 2); desc("Log Verbosity Level"); comment("--- Input options --------------------------"); yesno("joystick", use_joystick, 0); desc("Use Joystick"); key("joystick_no", joystick_no, 0); desc("Joystick Number"); yesno("mouse", use_mouse, 0); desc("Use Mouse"); key("mousemode", mousemode, MMD_CROSSHAIR); desc("Mouse Control Mode"); yesno("broken_numdia", broken_numdia, 0); desc("Broken NumPad Diagonals"); key("dia_emphasis", dia_emphasis, 0); desc("Diagonals Emphasis Filter"); yesno("always_fire", always_fire, 0); desc("Always Fire"); yesno("mousecapture", mousecapture, 1); desc("In-game Mouse Capture"); comment("--- Game options ---------------------------"); key("scrollradar", scrollradar, 2); desc("Radar Scroll Mode"); yesno("filter", filter, 1); desc("Motion Interpolation"); key("timefilter", timefilter, 50); desc("Time Filter"); key("countdown", countdown, 5); desc("Get Ready Countdown"); key("starfield", starfield, 2); desc("Starfield Style"); key("stars", stars, 500); desc("Number of Parallax Stars"); key("overheatloud", overheatloud, 100); desc("Overheat Warning Loudness"); key("cannonloud", cannonloud, 100); desc("Player Cannons Loudness"); comment("--- Sound settings -------------------------"); yesno("sound", use_sound, 1); desc("Enable Sound"); yesno("music", use_music, 1); desc("Enable Music"); yesno("cached_sounds", cached_sounds, 0); desc("Use Cached Sounds"); #ifdef HAVE_OSS yesno("oss", use_oss, 0); #else yesno("oss", use_oss, 0, 0); //Don't write! #endif desc("Use OSS Sound Driver"); key("samplerate", samplerate, 44100); desc("Sample Rate"); key("latency", latency, 50); desc("Sound Latency"); key("mixquality", mixquality, AQ_HIGH); desc("Mixing Quality"); key("vol", volume, 100); desc("Master Volume"); key("intro_vol", intro_vol, 100); desc("Intro Music Volume"); key("sfx_vol", sfx_vol, 100); desc("Sound Effects Volume"); key("music_vol", music_vol, 30); desc("In-Game Music Volume"); key("reverb", reverb, 100); desc("Reverb Level"); key("vol_boost", vol_boost, 0); desc("Volume Boost"); comment("--- Video settings -------------------------"); yesno("fullscreen", fullscreen, 0); desc("Fullscreen Display"); key("videodriver", videodriver, GFX_DRIVER_SDL2D); desc("Display Driver"); key("width", width, 640); desc("Horizontal Resolution"); key("height", height, 480); desc("Vertical Resolution"); key("aspect", aspect, 1000); desc("Pixel Aspect Ratio"); key("depth", depth, 0); desc("Display Depth"); key("maxfps", max_fps, 100); desc("Maximum fps"); key("maxfpsstrict", max_fps_strict, 0); desc("Strictly Regulated fps"); key("buffer", doublebuf, 1); desc("Display Buffer Mode"); yesno("shadow", shadow, 1); desc("Use Software Shadow Buffer"); key("videomode", videomode, 0x04330); desc("Video Mode"); yesno("vsync", vsync, 1); desc("Enable Vertical Sync"); key("videopages", pages, -1); desc("Number of Video Pages"); comment("--- Graphics settings ----------------------"); key("scalemode", scalemode, 1); desc("Scaling Filter Mode"); yesno("dither", use_dither, 1); desc("Use Dithering"); key("dither_type", dither_type, 0); desc("Dither Type"); yesno("broken_rgba8", broken_rgba8, 0); desc("Broken RGBA (OpenGL)"); yesno("alpha", alpha, 1); desc("Use Alpha Blending"); key("brightness", brightness, 100); desc("Brightness"); key("contrast", contrast, 100); desc("Contrast"); comment("--- File paths -----------------------------"); key("files", dir, ""); desc("Game Root Path"); key("gfx", gfxdir, ""); desc("Graphics Data Path"); key("sfx", sfxdir, ""); desc("Sound Data Path"); key("scores", scoredir, ""); desc("Score File Path"); // Obsolete stuff (not written into new files) key("size", o_size, 0, 0); desc("Screen Size (Obsolete)"); key("wait", o_wait_msec, 30); desc("Game Speed (Obsolete)"); key("bgm", o_bgm_indexfile, "", 0); desc("Background Music File (Obsolete)"); key("threshold", o_threshold, 200, 0); desc("Limiter Gain"); key("release", o_release, 50, 0); desc("Limiter Speed"); key("internalres", o_internalres, 1, 0); desc("Texture Resolution"); comment("--- Temporary variables --------------------"); key("last_profile", last_profile, 0); desc("Last used player profile"); key("number_of_joysticks", number_of_joysticks, 0); desc("Number of Connected Joysticks"); // "Commands" - never written to config files command("showcfg", cmd_showcfg); desc("Show Configuration"); command("hiscores", cmd_hiscores); desc("List High Scores"); command("highscores", cmd_hiscores); desc("List High Scores"); command("override", cmd_override); desc("Ignore Configuration File"); command("debug", cmd_debug); desc("Enable Debug Features"); command("fps", cmd_fps); desc("Show Frame Rate"); command("noframe", cmd_noframe); desc("Remove Window Frame"); command("midi", cmd_midi); desc("Enable MIDI Input"); command("cheat", cmd_cheat); desc("Enable Cheat Mode"); command("indicator", cmd_indicator); desc("Enable Collision Indicator Mode"); command("pushmove", cmd_pushmove); desc("Enable Push Move Mode"); command("noparachute", cmd_noparachute); desc("Disable SDL Parachute"); command("pollaudio", cmd_pollaudio); desc("Use Polling Audio Output"); command("autoshot", cmd_autoshot); desc("Ingame screenshots/movie"); command("help", cmd_help); desc("Print usage info and exit"); command("options_man", cmd_options_man); desc("Print options for 'man'"); } void prefs_t::postload() { if(redefined(o_size)) { //For pre 20011007 compatibility width = 320 * o_size; height = 240 * o_size; o_size = 0; accept(o_size); } if((o_wait_msec != 30) && !cmd_cheat) { log_printf(ELOG, "'wait' is only avaliable in cheat mode!\n"); o_wait_msec = 30; } if(scrollradar == 1) { log_printf(ELOG, "Radar sweep mode broken and disabled!\n"); scrollradar = 2; } // Some unimplemented enums were removed in 0.4.1 if(videodriver != GFX_DRIVER_SDL2D) videodriver = GFX_DRIVER_GLSDL; } KoboDeluxe-0.5.1/cfgform.cpp0000644000175000001440000000555710711212363012632 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003, 2006-2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kobolog.h" #include "config.h" #include "cfgform.h" #include "kobo.h" #include "sound.h" #include "vidmodes.h" int global_status = 0; config_form_t::config_form_t() { prf = NULL; stat = 0; } config_form_t::~config_form_t() { } void config_form_t::open(prefs_t *p) { init(gengine); place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); font(B_NORMAL_FONT); foreground(wmain->map_rgb(0xffffff)); background(wmain->map_rgb(0x000000)); prf = p; prfbak = *p; stat = global_status & (OS_RELOAD | OS_RESTART | OS_UPDATE); build_all(); } void config_form_t::close() { vmm_Close(); clean(); } void config_form_t::undo() { *prf = prfbak; undo_hook(); } int config_form_t::status() { return stat; } void config_form_t::clearstatus(int mask) { stat &= ~mask; global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); } void config_form_t::setstatus(int mask) { stat |= mask; global_status = stat & (OS_RELOAD | OS_RESTART | OS_UPDATE); } /*virtual*/ void config_form_t::change(int delta) { kobo_form_t::change(delta); if(!selected()) return; if(selected()->tag & OS_CLOSE) { if(delta == 0) { sound.ui_ok(); setstatus(OS_CLOSE); } } else if(selected()->tag & OS_CANCEL) { if(delta == 0) { sound.ui_cancel(); undo(); setstatus(OS_CLOSE); } } else sound.ui_tick(); if(selected()->user) prf->changed = 1; setstatus(selected()->tag & (OS_RELOAD | OS_RESTART | OS_UPDATE)); // If a video mode from the table is selected, get the parameters // from the video mode manager! if(prf->videomode) { VMM_Mode *m = vmm_FindMode(prf->videomode); if(m) { prf->width = m->width; prf->height = m->height; prf->aspect = (int)(m->aspect * 1000.0f + .5f); } } if(selected()->tag & OS_REBUILD) { int sel = selected_index(); build_all(); select(sel); } } /* virtual */void config_form_t::build() { } /* virtual */ void config_form_t::undo_hook() { stat = 0; global_status = 0; } KoboDeluxe-0.5.1/options.cpp0000666000175000001440000003047610734124561012713 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003, 2006-2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include "options.h" #include "gfxengine.h" #include "gamectl.h" #include "a_types.h" #include "kobo.h" void system_options_t::build() { medium(); label("System Options"); space(); small(); xoffs = 0.6; list("Maximum Frame Rate", &prf->max_fps, OS_REBUILD); { char buf[10]; item("OFF", 0); for(int i = 1; i < 25; i += 1) { snprintf((char *)&buf, sizeof(buf), "%d Hz", i); item(buf, i); } for(int i = 25; i < 100; i += 5) { snprintf((char *)&buf, sizeof(buf), "%d Hz", i); item(buf, i); } for(int i = 100; i <= 200; i += 10) { snprintf((char *)&buf, sizeof(buf), "%d Hz", i); item(buf, i); } } if(prf->max_fps) yesno("Strictly Regulated", &prf->max_fps_strict, 0); space(); xoffs = 0.6; list("Time Filter", &prf->timefilter, OS_UPDATE_ENGINE); item("Off", 100); item("Fast", 75); item("Normal", 50); item("Slow", 10); item("Logic/Video Lock", 0); onoff("Motion Interpolation", &prf->filter, OS_UPDATE_ENGINE); space(); xoffs = 0.6; yesno("Log Messages to File", &prf->logfile, OS_RESTART_LOGGER); list("Log Output Format", &prf->logformat, 0); item("Plain Text", 0); item("ANSI Coloring", 1); item("HTML", 2); xoffs = 0.45; list("Log Verbosity", &prf->logverbosity, 0); item("Critical Errors Only", 0); item("Errors Only", 1); item("Errors & Warnings", 2); item("Some Debug", 3); item("More Debug", 4); item("Everything", 5); big(); space(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL); } void video_options_t::build() { medium(); label("Video Options"); space(); small(); if(firstbuild) { vmm_Init(VMM_ALL, 0); VMM_Mode *vm = vmm_FindMode(prf->videomode); if(vm) { if(vm->flags & VMM_PC) showmodes = VMM_PC; else if(vm->flags & VMM_TV) showmodes = VMM_TV; else if(vm->flags & VMM_4_3) showmodes = VMM_4_3; else if(vm->flags & VMM_3_2) showmodes = VMM_3_2; else if(vm->flags & VMM_5_4) showmodes = VMM_5_4; else if(vm->flags & VMM_16_10) showmodes = VMM_16_10; else if(vm->flags & VMM_16_9) showmodes = VMM_16_9; else showmodes = VMM_ALL; if(vm->flags & VMM_LORES) showlow = 1; } else { showmodes = VMM_PC; showlow = 0; prf->videomode = -1; } firstbuild = 0; } xoffs = 0.35; list("Show Modes" , &showmodes, OS_REBUILD); item("Show All", VMM_ALL); item("Common PC/Mac Modes", VMM_PC); item("Common TV Modes", VMM_TV); item("4:3 (Standard CRT)", VMM_4_3); item("3:2 (NTSC TV)", VMM_3_2); item("5:4 (Some TFTs)", VMM_5_4); item("16:10 (PC/Mac Widescreen)", VMM_16_10); item("16:9 (TV Widescreen)", VMM_16_9); xoffs = 0.7; yesno("Show Odd Low Resolutions" , &showlow, OS_REBUILD); xoffs = 0.5; list("Display Mode", &prf->videomode, OS_RESTART_VIDEO | OS_REBUILD); vmm_Init(showmodes, showlow ? 0 : VMM_LORES); VMM_Mode *vm = vmm_First(); char buf[256]; buf[sizeof(buf) - 1] = 0; while(vm) { if(vm->name) snprintf(buf, sizeof(buf) - 1, "%dx%d (%s)", vm->width, vm->height, vm->name); else snprintf(buf, sizeof(buf) - 1, "%dx%d", vm->width, vm->height); item(buf, vm->id); vm = vmm_Next(vm); } item("Custom", -1); if(prf->videomode < 0) { spin("Width", &prf->width, 32, 4096, "pixels", OS_RESTART_VIDEO | OS_REBUILD); spin("Height", &prf->height, 32, 4096, "pixels", OS_RESTART_VIDEO | OS_REBUILD); } space(); yesno("Fullscreen Display", &prf->fullscreen, OS_RESTART_VIDEO); list("Display Depth", &prf->depth, OS_RESTART_VIDEO); item("Default", 0); item("8 bits", 8); item("15 bits", 15); item("16 bits", 16); item("24 bits", 24); item("32 bits", 32); #if defined(HAVE_OPENGL) && !defined(GLSDL_OFF) list("Display Driver", &prf->videodriver, OS_RESTART_VIDEO | OS_REBUILD); item("SDL 2D", GFX_DRIVER_SDL2D); item("OpenGL/glSDL", GFX_DRIVER_GLSDL); #else prf->videodriver = GFX_DRIVER_SDL2D; #endif space(); xoffs = 0.55; switch(prf->videodriver) { case GFX_DRIVER_SDL2D: list("Display Buffering Mode", &prf->doublebuf, OS_RESTART_VIDEO); item("Single", 0); item("Double", 1); yesno("Software Shadow Buffer", &prf->shadow, OS_RESTART_VIDEO); break; case GFX_DRIVER_GLSDL: yesno("Vertical Retrace Sync", &prf->vsync, OS_RESTART_VIDEO); break; } list("Display Buffer Pages", &prf->pages, OS_UPDATE_ENGINE); item("Assume Standard", -1); item("Always Repaint", 0); item("Single", 1); item("Double", 2); item("Triple", 3); big(); space(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL); } void graphics_options_t::build() { medium(); label("Graphics Options"); space(); small(); xoffs = 0.6; list("Scale Mode", &prf->scalemode, OS_RELOAD_GRAPHICS); item("Nearest", GFX_SCALE_NEAREST); item("Bilinear", GFX_SCALE_BILINEAR); // FIXME: Bilinear+Oversampling is unreliable and doesn't help much anyway // item("Bilinear+Oversampling", GFX_SCALE_BILIN_OVER); // FIXME: We need to specify a fallback chain for when filters do not support // FIXME: ratios. So, we have quality and image specific requirements, and we // FIXME: want a list of filters/modes in order of preference. // if((gengine->xscale() == 2.0f) && (gengine->yscale() == 2.0f)) // { item("Scale2x", GFX_SCALE_SCALE2X); item("Diamond2x", GFX_SCALE_DIAMOND); // } // else if(prf->scalemode >= GFX_SCALE_SCALE2X) // prf->scalemode = GFX_SCALE_BILINEAR; space(1); yesno("Dithering", &prf->use_dither, OS_RELOAD_GRAPHICS); list("Dither Type", &prf->dither_type, OS_RELOAD_GRAPHICS); item("2x2 Filter", 0); item("4x4 Filter", 1); item("Random", 2); switch(prf->videodriver) { case GFX_DRIVER_GLSDL: yesno("Broken RGBA8 (OpenGL)", &prf->broken_rgba8, OS_RELOAD_GRAPHICS); break; } space(); yesno("Alpha Blending", &prf->alpha, OS_RELOAD_GRAPHICS); space(); list("Brightness", &prf->brightness, OS_RELOAD_GRAPHICS); perc_list(50, 150, 10); list("Contrast", &prf->contrast, OS_RELOAD_GRAPHICS); perc_list(50, 150, 10); big(); space(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL); } void audio_options_t::build() { medium(); label("Sound Options"); small(); space(); xoffs = 0.57; yesno("Enable Sound", &prf->use_sound, OS_RESTART_AUDIO | OS_REBUILD); if(prf->use_sound) { yesno("Enable Music", &prf->use_music, OS_RESTART_AUDIO | OS_REBUILD); yesno("Cached Sounds", &prf->cached_sounds, OS_RELOAD_AUDIO_CACHE); //System space(); list("Sample Rate", &prf->samplerate, OS_RESTART_AUDIO); item("8 kHz", 8000); item("11025 Hz", 11025); item("16 kHz", 16000); item("22050", 22050); item("32 kHz", 32000); item("44.1 kHz", 44100); item("48 kHz", 48000); item("88.2 kHz", 88200); item("96 kHz", 96000); item("176.4 kHz", 176400); item("192 kHz", 192000); list("Mixing Quality", &prf->mixquality, OS_UPDATE_AUDIO); item("Very Low", AQ_VERY_LOW); item("Low", AQ_LOW); item("Normal", AQ_NORMAL); item("High", AQ_HIGH); item("Very High", AQ_VERY_HIGH); list("Sound Latency", &prf->latency, OS_RESTART_AUDIO); { char buf[10]; for(int i = 1; i < 20; i += 1) { snprintf((char *)&buf, sizeof(buf), "%d ms", i); item(buf, i); } for(int i = 20; i < 50; i += 5) { snprintf((char *)&buf, sizeof(buf), "%d ms", i); item(buf, i); } for(int i = 50; i < 100; i += 10) { snprintf((char *)&buf, sizeof(buf), "%d ms", i); item(buf, i); } for(int i = 100; i <= 500; i += 25) { snprintf((char *)&buf, sizeof(buf), "%d ms", i); item(buf, i); } } #ifdef HAVE_OSS yesno("Use OSS Sound Driver", &prf->use_oss, OS_RESTART_AUDIO); #else // We're running out of space here... :-/ space(); #endif //Mixer list("Sound Effects Level", &prf->sfx_vol, OS_UPDATE_AUDIO); item("OFF", 0); perc_list(10, 90, 10); perc_list(100, 200, 25); if(prf->use_music) { list("Intro Music Level", &prf->intro_vol, OS_UPDATE_AUDIO); item("OFF", 0); perc_list(10, 90, 10); perc_list(100, 200, 25); list("In-Game Music Level", &prf->music_vol, OS_UPDATE_AUDIO); item("OFF", 0); perc_list(10, 90, 10); perc_list(100, 200, 25); } //Master effects list("Ambience", &prf->reverb, OS_UPDATE_AUDIO); item("OFF", 0); item("Low", 50); item("Normal", 100); item("High", 175); item("Extreme", 250); list("Volume Boost", &prf->vol_boost, OS_UPDATE_AUDIO); item("OFF", 0); item("Low", 1); item("Moderate", 2); item("High", 3); item("Extreme", 4); } space(); big(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL | OS_UPDATE_AUDIO); } void audio_options_t::undo_hook() { clearstatus(OS_RELOAD | OS_RESTART | OS_UPDATE); setstatus(OS_UPDATE_AUDIO); } void control_options_t::build() { medium(); label("Control Options"); space(); small(); xoffs = 0.67; yesno("Always Fire", &prf->always_fire, OS_RESTART_INPUT); space(); yesno("Broken NumPad Diagonals", &prf->broken_numdia, 0); list("Diagonals Emphasis Filter", &prf->dia_emphasis, 0); item("OFF", 0); item("1 frame", 1); item("2 frames", 2); item("3 frames", 3); item("4 frames", 4); item("5 frames", 5); space(); if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) label("Could not initialize joysticks!"); else { prf->number_of_joysticks = SDL_NumJoysticks(); yesno("Use Joystick", &prf->use_joystick, OS_RESTART_INPUT | OS_REBUILD); if(prf->use_joystick) { if(prf->number_of_joysticks) { list("Joystick Number", &prf->joystick_no, OS_RESTART_INPUT); enum_list(0, prf->number_of_joysticks - 1); } else label("No Joysticks Found!"); } } space(); yesno("Use Mouse", &prf->use_mouse, OS_RESTART_INPUT | OS_REBUILD); if(prf->use_mouse) { list("Mouse Control Mode", &prf->mousemode, OS_RESTART_INPUT); item("Disabled", MMD_OFF); item("Crosshair", MMD_CROSSHAIR); } space(); yesno("In-game Mouse Capture", &prf->mousecapture, 0); big(); space(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL); } void game_options_t::build() { medium(); label("Game Options"); space(); small(); xoffs = 0.6; list("Radar Scroll Mode", &prf->scrollradar, 0); item("Off", 0); // FIXME: Radar sweep mode is broken! // item("Sweep", 1); item("Scroll", 2); space(); list("Get Ready Countdown", &prf->countdown, 0); item("Quick Start", 0); item("1 second", 1); item("2 seconds", 2); item("3 seconds", 3); item("4 seconds", 4); item("5 seconds", 5); item("6 seconds", 6); item("7 seconds", 7); item("8 seconds", 8); item("9 seconds", 9); item("Wait Forever", 10); space(); list("Starfield Mode", &prf->starfield, OS_REBUILD); item("None", STARFIELD_NONE); item("Old (Flat)", STARFIELD_OLD); item("Parallax", STARFIELD_PARALLAX); if(prf->starfield == STARFIELD_PARALLAX) { list("Starfield Density", &prf->stars, 0); item("Minimal", 50); item("Low", 250); item("Normal", 500); item("High", 1000); item("Massive", 2500); item("Insane", 8000); } space(); xoffs = 0.7; list("Cannon Overheat Warning", &prf->overheatloud, 0); item("Off", 0); item("Soft", 50); item("Normal", 100); item("Loud", 200); list("Cannon Sound Suppression", &prf->cannonloud, 0); item("Off", 200); item("Low", 100); item("High", 50); big(); space(); xoffs = 0.5; button("ACCEPT", OS_CLOSE); button("CANCEL", OS_CANCEL | OS_UPDATE_ENGINE); } void game_options_t::undo_hook() { clearstatus(OS_RELOAD | OS_RESTART | OS_UPDATE); setstatus(OS_UPDATE_ENGINE); } KoboDeluxe-0.5.1/gamestate.cpp0000644000175000001440000000736207744605735013202 00000000000000/*(LGPL) ------------------------------------------------------------ Game State Manager ------------------------------------------------------------ * Copyright (C) 2001-2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #include #include "logger.h" #include "gamestate.h" /*---------------------------------------------------------- gamestate_t ----------------------------------------------------------*/ gamestate_t::gamestate_t() { next = 0; manager = 0; unicode = 0; } gamestate_t::~gamestate_t() {} void gamestate_t::pop() { if(!manager) return; //This is far from fool-proof, but it should //handle the most common cases of "trying to //pop 'this' more than once"... if(manager->current() == this) manager->pop(); else log_printf(WLOG, "GameStateManager: " "WARNING: Tried to pop state more than once!\n"); } void gamestate_t::enter() {} void gamestate_t::leave() {} void gamestate_t::yield() {} void gamestate_t::reenter() {} void gamestate_t::press(int button) {} void gamestate_t::release(int button) {} void gamestate_t::pos(int x, int y) {} void gamestate_t::delta(int dx, int dy) {} void gamestate_t::frame() {} void gamestate_t::pre_render() {} void gamestate_t::post_render() {} /*---------------------------------------------------------- gamestatemanager_t ----------------------------------------------------------*/ gamestatemanager_t::gamestatemanager_t() { top = 0; } gamestatemanager_t::~gamestatemanager_t() { } void gamestatemanager_t::change(gamestate_t *gs) { gs->manager = this; gamestate_t *oldtop = top; if(top) top = top->next; gs->next = top; top = gs; if(oldtop) { oldtop->leave(); oldtop->manager = 0; } if(top) top->enter(); log_printf(DLOG, "GameStateManager: Switched to '%s'\n", gs->name); } void gamestatemanager_t::push(gamestate_t *gs) { gs->manager = this; gamestate_t *oldtop = top; gs->next = top; top = gs; if(oldtop) oldtop->yield(); if(top) top->enter(); log_printf(DLOG, "GameStateManager: Pushed state '%s'\n", gs->name); } void gamestatemanager_t::pop() { gamestate_t *oldtop = top; if(top) top = top->next; if(oldtop) { oldtop->leave(); oldtop->manager = 0; log_printf(DLOG, "GameStateManager: Popped state '%s'\n", oldtop->name); } if(top) top->reenter(); } gamestate_t *gamestatemanager_t::current() { return top; } gamestate_t *gamestatemanager_t::previous() { if(top) return top->next; else return NULL; } void gamestatemanager_t::press(int button, int unicode) { if(top) { top->unicode = unicode; top->press(button); } } void gamestatemanager_t::release(int button, int unicode) { if(top) { top->unicode = unicode; top->release(button); } } void gamestatemanager_t::pos(int x, int y) { if(top) top->pos(x, y); } void gamestatemanager_t::delta(int dx, int dy) { if(top) top->delta(dx, dy); } void gamestatemanager_t::frame() { if(top) top->frame(); } void gamestatemanager_t::pre_render() { if(top) top->pre_render(); } void gamestatemanager_t::post_render() { if(top) top->post_render(); } KoboDeluxe-0.5.1/states.cpp0000644000175000001440000010764010733215427012516 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003 David Olofson * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2005-2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "glSDL.h" #include #ifndef M_PI # define M_PI 3.14159265358979323846 /* pi */ #endif #include "kobolog.h" #include "config.h" #include "states.h" #include "kobo.h" #include "screen.h" #include "manage.h" #include "options.h" #include "sound.h" #include "radar.h" #include "random.h" gamestatemanager_t gsm; int run_intro = 0; int last_level = -1; kobo_basestate_t::kobo_basestate_t() { name = ""; } void kobo_basestate_t::frame() { } void kobo_basestate_t::pre_render() { screen.render_background(wmain); } void kobo_basestate_t::post_render() { screen.render_fx(wmain); DBG(if(prefs->cmd_debug) { wmain->font(B_NORMAL_FONT); wmain->string(30, 5, name); }) } /*---------------------------------------------------------- st_introbase ----------------------------------------------------------*/ st_introbase_t::st_introbase_t() { name = "intro"; inext = NULL; duration = 0; timer = 0; } void st_introbase_t::enter() { if(!run_intro) { manage.init_resources_title(); if(prefs->use_music) sound.ui_music(SOUND_TITLE); run_intro = 1; } start_time = (int)SDL_GetTicks() + INTRO_BLANK_TIME; timer = 0; } void st_introbase_t::reenter() { if(!run_intro) { manage.init_resources_title(); if(prefs->use_music) sound.ui_music(SOUND_TITLE); run_intro = 1; } gsm.change(&st_intro_title); } void st_introbase_t::press(int button) { switch (button) { case BTN_EXIT: case BTN_CLOSE: gsm.push(&st_main_menu); break; case BTN_START: case BTN_FIRE: case BTN_SELECT: run_intro = 0; gsm.push(&st_main_menu); if(scorefile.numProfiles <= 0) gsm.push(&st_new_player); break; case BTN_BACK: case BTN_UP: case BTN_LEFT: gsm.change(&st_intro_title); break; case BTN_DOWN: case BTN_RIGHT: if(inext) gsm.change(inext); break; #ifdef PROFILE_AUDIO case BTN_F9: run_intro = 0; gsm.push(&st_profile_audio); break; #endif default: break; } } void st_introbase_t::frame() { manage.run_intro(); if((timer > duration) && inext) gsm.change(inext); } void st_introbase_t::pre_render() { kobo_basestate_t::pre_render(); timer = (int)SDL_GetTicks() - start_time; } void st_introbase_t::post_render() { kobo_basestate_t::post_render(); screen.scroller(); } /*---------------------------------------------------------- st_intro_title ----------------------------------------------------------*/ st_intro_title_t::st_intro_title_t() { name = "intro_title"; } void st_intro_title_t::enter() { st_introbase_t::enter(); if(!duration) duration = INTRO_TITLE_TIME + 2000 - INTRO_BLANK_TIME; if(!inext) inext = &st_intro_instructions; screen.set_highlight(0, 0); } void st_intro_title_t::post_render() { if(exit_game) return; st_introbase_t::post_render(); if((timer >= 0) && (timer < duration)) { float nt = (float)timer / duration; float snt = 1.0f - sin(nt * M_PI); snt = 1.0f - snt * snt * snt; screen.title(timer, snt, mode); } } st_intro_title_t st_intro_title; /*---------------------------------------------------------- st_intro_instructions ----------------------------------------------------------*/ st_intro_instructions_t::st_intro_instructions_t() { name = "intro_instructions"; } void st_intro_instructions_t::enter() { st_introbase_t::enter(); duration = INTRO_INSTRUCTIONS_TIME; inext = &st_intro_title; st_intro_title.inext = &st_intro_highscores; st_intro_title.duration = INTRO_TITLE2_TIME - INTRO_BLANK_TIME; st_intro_title.mode = pubrand.get(1) + 1; } void st_intro_instructions_t::post_render() { if(exit_game) return; st_introbase_t::post_render(); if((timer >= 0) && (timer < duration)) screen.help(timer); else screen.set_highlight(0, 0); } st_intro_instructions_t st_intro_instructions; /*---------------------------------------------------------- st_intro_highshores ----------------------------------------------------------*/ st_intro_highscores_t::st_intro_highscores_t() { name = "intro_highscores"; } void st_intro_highscores_t::enter() { scorefile.gather_high_scores(1); screen.init_highscores(); st_introbase_t::enter(); duration = INTRO_HIGHSCORE_TIME; inext = &st_intro_title; st_intro_title.inext = &st_intro_credits; st_intro_title.duration = INTRO_TITLE2_TIME - INTRO_BLANK_TIME; st_intro_title.mode = pubrand.get(1) + 1; screen.set_highlight(0, 0); } void st_intro_highscores_t::post_render() { if(exit_game) return; st_introbase_t::post_render(); if((timer >= 0) && (timer < duration)) { float nt = (float)timer / duration; float snt = 1.0f - sin(nt * M_PI); snt = 1.0f - snt * snt * snt; screen.highscores(timer, snt); } } st_intro_highscores_t st_intro_highscores; /*---------------------------------------------------------- st_intro_credits ----------------------------------------------------------*/ st_intro_credits_t::st_intro_credits_t() { name = "intro_credits"; } void st_intro_credits_t::enter() { st_introbase_t::enter(); duration = INTRO_CREDITS_TIME; inext = &st_intro_title; st_intro_title.inext = &st_intro_instructions; st_intro_title.duration = INTRO_TITLE_TIME - INTRO_BLANK_TIME; st_intro_title.mode = 0; } void st_intro_credits_t::post_render() { if(exit_game) return; st_introbase_t::post_render(); if((timer >= 0) && (timer < duration)) screen.credits(timer); else screen.set_highlight(0, 0); } st_intro_credits_t st_intro_credits; /*---------------------------------------------------------- st_game ----------------------------------------------------------*/ st_game_t::st_game_t() { name = "game"; } void st_game_t::enter() { audio_channel_stop(0, -1); //Stop any music run_intro = 0; manage.game_start(); if(exit_game || manage.game_stopped()) { st_error.message("Could not start game!", "Please, check your installation."); gsm.change(&st_error); } if(prefs->mousecapture) if(SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON) SDL_WM_GrabInput(SDL_GRAB_ON); } void st_game_t::leave() { if(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON) SDL_WM_GrabInput(SDL_GRAB_OFF); st_intro_title.inext = &st_intro_instructions; st_intro_title.duration = INTRO_TITLE_TIME + 2000; st_intro_title.mode = 0; } void st_game_t::yield() { if(SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_ON) SDL_WM_GrabInput(SDL_GRAB_OFF); } void st_game_t::reenter() { if(prefs->mousecapture) if(SDL_WM_GrabInput(SDL_GRAB_QUERY) != SDL_GRAB_ON) SDL_WM_GrabInput(SDL_GRAB_ON); } void st_game_t::press(int button) { switch (button) { case BTN_EXIT: gsm.push(&st_main_menu); break; case BTN_CLOSE: gsm.push(&st_ask_exit); break; case BTN_SELECT: case BTN_START: case BTN_PAUSE: gsm.push(&st_pause_game); break; } } void st_game_t::frame() { if(manage.get_ready()) { gsm.push(&st_get_ready); return; } manage.run_game(); last_level = manage.scene(); if(manage.game_over()) gsm.change(&st_game_over); else if(exit_game || manage.game_stopped()) pop(); } void st_game_t::post_render() { kobo_basestate_t::post_render(); wradar->frame(); } st_game_t st_game; /*---------------------------------------------------------- st_pause_game ----------------------------------------------------------*/ st_pause_game_t::st_pause_game_t() { name = "pause_game"; } void st_pause_game_t::enter() { sound.ui_pause(); } void st_pause_game_t::press(int button) { switch (button) { case BTN_EXIT: gsm.change(&st_main_menu); break; default: sound.ui_play(); pop(); break; } } void st_pause_game_t::frame() { manage.run_pause(); } void st_pause_game_t::post_render() { kobo_basestate_t::post_render(); float ft = SDL_GetTicks() * 0.001; wmain->font(B_BIG_FONT); int y = PIXEL2CS(75) + (int)floor(PIXEL2CS(15)*sin(ft * 6)); wmain->center_fxp(y, "PAUSED"); wradar->frame(); } st_pause_game_t st_pause_game; /*---------------------------------------------------------- st_get_ready ----------------------------------------------------------*/ st_get_ready_t::st_get_ready_t() { name = "get_ready"; } void st_get_ready_t::enter() { manage.update(); sound.ui_ready(); start_time = (int)SDL_GetTicks(); frame_time = 0; countdown = prefs->countdown; } void st_get_ready_t::press(int button) { if(frame_time < 500) return; switch (button) { case BTN_EXIT: case BTN_NO: gsm.change(&st_main_menu); break; case BTN_LEFT: case BTN_RIGHT: case BTN_UP: case BTN_DOWN: case BTN_UL: case BTN_UR: case BTN_DL: case BTN_DR: case BTN_FIRE: case BTN_YES: sound.ui_play(); pop(); break; case BTN_SELECT: case BTN_START: case BTN_PAUSE: gsm.change(&st_pause_game); break; } } void st_get_ready_t::frame() { manage.run_pause(); if(exit_game || manage.game_stopped()) { pop(); return; } frame_time = (int)SDL_GetTicks() - start_time; if(0 == prefs->countdown) { if(frame_time > 700) { sound.ui_play(); pop(); } } else if(prefs->countdown <= 9) { int prevcount = countdown; countdown = prefs->countdown - frame_time/1000; if(prevcount != countdown) sound.ui_countdown(countdown); if(countdown < 1) { sound.ui_play(); pop(); } } } void st_get_ready_t::post_render() { kobo_basestate_t::post_render(); float ft = SDL_GetTicks() * 0.001; char counter[2] = "0"; wmain->font(B_BIG_FONT); int y = PIXEL2CS(70) + (int)floor(PIXEL2CS(15)*sin(ft * 6)); wmain->center_fxp(y, "GET READY!"); float z = (float)((int)SDL_GetTicks() - start_time); if(10 == prefs->countdown) z = -1; else if(prefs->countdown) z = prefs->countdown - z * 0.001; else z = 1.0 - z / 700.0; if((z > 0.0) && (z < 1.0)) { float x = wmain->width() / 2; wmain->foreground(wmain->map_rgb( 255 - (int)(z * 255.0), (int)(z * 255.0), 0)); wmain->fillrect_fxp(PIXEL2CS((int)(x - z * 50.0)), y + PIXEL2CS(76), PIXEL2CS((int)(z * 100.0)), PIXEL2CS(10)); } wmain->font(B_MEDIUM_FONT); if(10 == prefs->countdown) wmain->center_fxp(y + PIXEL2CS(70), "(Press FIRE)"); else if(prefs->countdown) { wmain->center_fxp(y + PIXEL2CS(100), "(Press FIRE)"); counter[0] = countdown + '0'; wmain->font(B_COUNTER_FONT); wmain->center_fxp(y + PIXEL2CS(60), counter); } wradar->frame(); } st_get_ready_t st_get_ready; /*---------------------------------------------------------- st_game_over ----------------------------------------------------------*/ st_game_over_t::st_game_over_t() { name = "game_over"; } void st_game_over_t::enter() { sound.ui_gameover(); manage.update(); start_time = (int)SDL_GetTicks(); } void st_game_over_t::press(int button) { if(frame_time < 500) return; switch (button) { case BTN_EXIT: case BTN_NO: case BTN_LEFT: case BTN_RIGHT: case BTN_UP: case BTN_DOWN: case BTN_UL: case BTN_UR: case BTN_DL: case BTN_DR: case BTN_FIRE: case BTN_START: case BTN_SELECT: case BTN_YES: sound.ui_ok(); pop(); break; } } void st_game_over_t::frame() { manage.run_game(); frame_time = (int)SDL_GetTicks() - start_time; if(frame_time > 5000) pop(); } void st_game_over_t::post_render() { kobo_basestate_t::post_render(); float ft = SDL_GetTicks() * 0.001; wmain->font(B_BIG_FONT); int y = PIXEL2CS(100) + (int)floor(PIXEL2CS(15)*sin(ft * 6)); wmain->center_fxp(y, "GAME OVER"); wradar->frame(); } st_game_over_t st_game_over; /*---------------------------------------------------------- Menu Base ----------------------------------------------------------*/ /* * menu_base_t */ void menu_base_t::open() { init(gengine); place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); font(B_NORMAL_FONT); foreground(wmain->map_rgb(0xffffff)); background(wmain->map_rgb(0x000000)); build_all(); } void menu_base_t::close() { clean(); } /* * st_menu_base_t */ st_menu_base_t::st_menu_base_t() { name = "(menu_base derivate)"; sounds = 1; form = NULL; } st_menu_base_t::~st_menu_base_t() { delete form; } void st_menu_base_t::enter() { form = open(); if(manage.game_stopped()) run_intro = 1; if(sounds) sound.ui_ok(); } // Because we may get back here after changing the configuration! void st_menu_base_t::reenter() { if(global_status & OS_RESTART_VIDEO) pop(); } void st_menu_base_t::leave() { screen.set_highlight(0, 0); close(); delete form; form = NULL; if(manage.game_stopped()) { manage.init_resources_title(); st_intro_title.inext = &st_intro_instructions; st_intro_title.duration = INTRO_TITLE_TIME + 2000; st_intro_title.mode = 0; } } void st_menu_base_t::frame() { if(manage.game_stopped()) manage.run_intro(); //(Game is paused when a menu is active.) } void st_menu_base_t::post_render() { kobo_basestate_t::post_render(); if(form) form->render(); if(!manage.game_stopped()) wradar->frame(); } int st_menu_base_t::translate(int tag, int button) { switch(button) { case BTN_INC: case BTN_RIGHT: case BTN_DEC: case BTN_LEFT: return -1; default: return tag; } } void st_menu_base_t::press(int button) { int selection; if(!form) return; do_default_action = 1; // Translate switch(button) { case BTN_EXIT: case BTN_CLOSE: selection = 0; break; case BTN_UP: case BTN_DOWN: selection = -1; break; case BTN_INC: case BTN_RIGHT: case BTN_DEC: case BTN_LEFT: case BTN_FIRE: case BTN_START: case BTN_SELECT: if(form->selected()) selection = translate(form->selected()->tag, button); else selection = -2; break; default: selection = -1; break; } // Default action if(do_default_action) switch(button) { case BTN_EXIT: escape(); break; case BTN_INC: case BTN_RIGHT: form->change(1); break; case BTN_DEC: case BTN_LEFT: form->change(-1); break; case BTN_FIRE: case BTN_START: case BTN_SELECT: form->change(0); break; case BTN_UP: form->prev(); break; case BTN_DOWN: form->next(); break; #ifdef PROFILE_AUDIO case BTN_F9: gsm.push(&st_profile_audio); break; #endif } switch(selection) { case -1: break; case 0: if(sounds) sound.ui_cancel(); select(0); pop(); break; default: select(selection); break; } } /*---------------------------------------------------------- st_new_player ----------------------------------------------------------*/ void new_player_t::open() { init(gengine); place(wmain->x(), wmain->y(), wmain->width(), wmain->height()); font(B_NORMAL_FONT); foreground(wmain->map_rgb(255, 255, 255)); background(wmain->map_rgb(0, 0, 0)); memset(name, 0, sizeof(name)); name[0] = 'A'; currentIndex = 0; editing = 1; build_all(); SDL_EnableUNICODE(1); } void new_player_t::close() { SDL_EnableUNICODE(0); clean(); } void new_player_t::change(int delta) { kobo_form_t::change(delta); if(!selected()) return; selection = selected()->tag; } void new_player_t::build() { medium(); space(2); label("Use arrows, joystick or keyboard"); label("to enter name"); big(); space(); button(name, 1); space(); button("Ok", MENU_TAG_OK); button("Cancel", MENU_TAG_CANCEL); } void new_player_t::rebuild() { int sel = selected_index(); build_all(); select(sel); } st_new_player_t::st_new_player_t() { name = "new_player"; } void st_new_player_t::frame() { manage.run_intro(); } void st_new_player_t::enter() { menu.open(); run_intro = 0; sound.ui_ok(); } void st_new_player_t::leave() { menu.close(); } void st_new_player_t::post_render() { kobo_basestate_t::post_render(); menu.render(); } void st_new_player_t::press(int button) { if(menu.editing) { switch(button) { case BTN_EXIT: sound.ui_ok(); menu.editing = 0; menu.next(); // Select the CANCEL option. menu.next(); break; case BTN_FIRE: if(!prefs->use_joystick) break; case BTN_START: case BTN_SELECT: sound.ui_ok(); menu.editing = 0; menu.next(); // Select the OK option. break; case BTN_UP: case BTN_INC: if(!menu.name[menu.currentIndex]) menu.name[menu.currentIndex] = 'A'; else if(menu.name[menu.currentIndex] == 'Z') menu.name[menu.currentIndex] = 'a'; else if(menu.name[menu.currentIndex] == 'z') menu.name[menu.currentIndex] = 'A'; else menu.name[menu.currentIndex]++; sound.ui_tick(); break; case BTN_DEC: case BTN_DOWN: if(!menu.name[menu.currentIndex]) menu.name[menu.currentIndex] = 'A'; else if(menu.name[menu.currentIndex] == 'A') menu.name[menu.currentIndex] = 'z'; else if(menu.name[menu.currentIndex] == 'a') menu.name[menu.currentIndex] = 'Z'; else menu.name[menu.currentIndex]--; sound.ui_tick(); break; case BTN_RIGHT: if(menu.currentIndex < sizeof(menu.name) - 2) { menu.currentIndex++; sound.ui_tick(); } else { sound.ui_error(); break; } if(menu.name[menu.currentIndex] == '\0') menu.name[menu.currentIndex] = 'A'; break; case BTN_LEFT: case BTN_BACK: if(menu.currentIndex > 0) { menu.name[menu.currentIndex] = '\0'; menu.currentIndex--; sound.ui_tick(); } else sound.ui_error(); break; default: if((unicode >= 'a') && (unicode <= 'z') || (unicode >= 'A') && (unicode <= 'Z')) { menu.name[menu.currentIndex] = (char)unicode; if(menu.currentIndex < sizeof(menu.name) - 2) { menu.currentIndex++; sound.ui_tick(); } else sound.ui_error(); } else sound.ui_error(); break; } menu.rebuild(); } else { menu.selection = -1; switch(button) { case BTN_EXIT: menu.selection = MENU_TAG_CANCEL; break; case BTN_CLOSE: menu.selection = MENU_TAG_OK; break; case BTN_FIRE: case BTN_START: case BTN_SELECT: menu.change(0); break; case BTN_INC: case BTN_UP: menu.prev(); break; case BTN_DEC: case BTN_DOWN: menu.next(); break; } switch(menu.selection) { case 1: if(button == BTN_START || button == BTN_SELECT || button == BTN_FIRE) { sound.ui_ok(); menu.editing = 1; } break; case MENU_TAG_OK: switch(scorefile.addPlayer(menu.name)) { case 0: sound.ui_ok(); prefs->last_profile = scorefile.current_profile(); prefs->changed = 1; pop(); break; case -1: sound.ui_error(); st_error.message("Cannot create Player Profile!", "Too many profiles!"); gsm.change(&st_error); break; case -2: case -3: prefs->last_profile = scorefile.current_profile(); sound.ui_error(); st_error.message("Cannot save Player Profile!", "Please, check your installation."); gsm.change(&st_error); break; default: sound.ui_error(); st_error.message("Cannot create Player Profile!", "Bug or internal error."); gsm.change(&st_error); break; } break; case MENU_TAG_CANCEL: sound.ui_cancel(); strcpy(menu.name, "A"); pop(); break; } } } st_new_player_t st_new_player; /*---------------------------------------------------------- st_error ----------------------------------------------------------*/ void st_error_t::message(const char *error, const char *hint) { msg[0] = error; msg[1] = hint; } st_error_t::st_error_t() { name = "error"; msg[0] = "No error!"; msg[1] = "(Why am I here...?)"; } void st_error_t::enter() { sound.ui_error(); manage.update(); start_time = (int)SDL_GetTicks(); } void st_error_t::press(int button) { if(frame_time < 500) return; switch (button) { case BTN_EXIT: case BTN_NO: case BTN_LEFT: case BTN_RIGHT: case BTN_UP: case BTN_DOWN: case BTN_UL: case BTN_UR: case BTN_DL: case BTN_DR: case BTN_FIRE: case BTN_START: case BTN_SELECT: case BTN_YES: sound.ui_ok(); pop(); break; } } void st_error_t::frame() { manage.run_intro(); frame_time = (int)SDL_GetTicks() - start_time; if(frame_time % 1000 < 500) sound.ui_error(); } void st_error_t::post_render() { kobo_basestate_t::post_render(); wmain->font(B_MEDIUM_FONT); wmain->center(95, msg[0]); wmain->font(B_NORMAL_FONT); wmain->center(123, msg[1]); if(frame_time % 1000 < 500) { int w = wmain->width(); int h = wmain->height(); wmain->foreground(wmain->map_rgb(0xff0000)); wmain->rectangle(20, 80, w - 40, h - 160); wmain->rectangle(22, 82, w - 44, h - 164); wmain->rectangle(24, 84, w - 48, h - 168); } } st_error_t st_error; /*---------------------------------------------------------- st_main_menu ----------------------------------------------------------*/ void main_menu_t::buildStartLevel(int profNum) { char buf[50]; int MaxStartLevel = scorefile.last_scene(profNum); start_level = manage.scene(); if(start_level > MaxStartLevel) start_level = MaxStartLevel; list("Start at Stage", &start_level, 5); for(int i = 0; i <= MaxStartLevel; ++i) { snprintf(buf, sizeof(buf), "%d", i + 1); item(buf, i); } } void main_menu_t::build() { if(manage.game_stopped()) { prefs->last_profile = scorefile.current_profile(); if(last_level < 0) manage.select_scene(scorefile.last_scene()); else manage.select_scene(last_level); } halign = ALIGN_CENTER; xoffs = 0.5; big(); if(manage.game_stopped()) { space(); if(scorefile.numProfiles > 0) { button("Start Game!", 1); space(); list("Player", &prefs->last_profile, 4); for(int i = 0; i < scorefile.numProfiles; ++i) item(scorefile.name(i), i); small(); buildStartLevel(prefs->last_profile); big(); } else space(2); button("New Player...", 3); } else { space(2); button("Return to Game", 0); } space(); button("Options", 2); space(); if(manage.game_stopped()) button("Return to Intro", 0); else button("Abort Current Game", 101); button("Quit Kobo Deluxe", MENU_TAG_CANCEL); } void main_menu_t::rebuild() { int sel = selected_index(); build_all(); select(sel); } kobo_form_t *st_main_menu_t::open() { if(manage.game_stopped()) { // Moved here, as we want to do it as late as // possible, but *not* as a result of rebuild(). if(prefs->last_profile >= scorefile.numProfiles) { prefs->last_profile = 0; prefs->changed = 1; } scorefile.select_profile(prefs->last_profile); } menu = new main_menu_t; menu->open(); return menu; } void st_main_menu_t::reenter() { menu->rebuild(); st_menu_base_t::reenter(); } // Custom translator to map inc/dec on certain widgets int st_main_menu_t::translate(int tag, int button) { switch(tag) { case 4: // The default translate() filters out the // inc/dec events, and performs the default // action for fire/start/select... switch(button) { case BTN_FIRE: case BTN_START: case BTN_SELECT: do_default_action = 0; return tag + 10; default: return tag; } case 5: return tag; default: return st_menu_base_t::translate(tag, button); } } void st_main_menu_t::select(int tag) { switch(tag) { case 1: gsm.change(&st_skill_menu); break; case 2: gsm.push(&st_options_main); break; case 3: gsm.push(&st_new_player); break; case 4: // Player: Inc/Dec sound.ui_tick(); prefs->changed = 1; scorefile.select_profile(prefs->last_profile); menu->rebuild(); break; case 14: // Player: Select // Edit player profile! // menu->rebuild(); break; case 5: // Start level: Inc/Dec sound.ui_tick(); manage.select_scene(menu->start_level); break; case MENU_TAG_CANCEL: gsm.change(&st_ask_exit); break; case 101: gsm.change(&st_ask_abort_game); break; case 0: if(!manage.game_stopped()) gsm.change(&st_pause_game); break; } } st_main_menu_t st_main_menu; /*---------------------------------------------------------- st_skill_menu ----------------------------------------------------------*/ void skill_menu_t::build() { halign = ALIGN_CENTER; xoffs = 0.5; medium(); label("Select Skill Level"); space(1); big(); button("Classic", SKILL_CLASSIC + 10); small(); space(); big(); button("Newbie", SKILL_NEWBIE + 10); button("Gamer", SKILL_GAMER + 10); button("Elite", SKILL_ELITE + 10); button("God", SKILL_GOD + 10); space(); small(); switch(skill) { case SKILL_CLASSIC: label("\"I want the original XKobo, dammit!\""); break; case SKILL_NEWBIE: label("\"Damn, this is hard...!\""); break; case SKILL_GAMER: label("\"Classic is too retro for me!\""); break; case SKILL_ELITE: label("\"Bah! Gimme some resistance here.\""); break; case SKILL_GOD: label("\"The dark is afraid of me.\""); break; } } void skill_menu_t::rebuild() { int sel = selected_index(); build_all(); select(sel); } kobo_form_t *st_skill_menu_t::open() { menu = new skill_menu_t; menu->set_skill(scorefile.profile()->skill); menu->open(); switch(scorefile.profile()->skill) { case SKILL_CLASSIC: menu->select(1); break; case SKILL_NEWBIE: menu->select(2); break; case SKILL_GAMER: menu->select(3); break; case SKILL_ELITE: menu->select(4); break; case SKILL_GOD: menu->select(5); break; } return menu; } void st_skill_menu_t::press(int button) { st_menu_base_t::press(button); switch (button) { case BTN_UP: case BTN_DOWN: menu->set_skill(menu->selected()->tag - 10); menu->rebuild(); break; } } void st_skill_menu_t::select(int tag) { if((tag >= 10) && (tag <= 20)) { scorefile.profile()->skill = menu->selected()->tag - 10; gsm.change(&st_game); } } st_skill_menu_t st_skill_menu; /*---------------------------------------------------------- st_options_main ----------------------------------------------------------*/ void options_main_t::build() { medium(); label("Options"); space(); big(); button("Game", 4); button("Controls", 3); button("Video", 1); button("Graphics", 6); button("Audio", 2); button("System", 5); space(); button("DONE!", 0); } kobo_form_t *st_options_main_t::open() { options_main_t *m = new options_main_t; m->open(); return m; } void st_options_main_t::select(int tag) { switch(tag) { case 1: gsm.push(&st_options_video); break; case 2: gsm.push(&st_options_audio); break; case 3: gsm.push(&st_options_control); break; case 4: gsm.push(&st_options_game); break; case 5: gsm.push(&st_options_system); break; case 6: gsm.push(&st_options_graphics); break; } } st_options_main_t st_options_main; /*---------------------------------------------------------- st_options_base ----------------------------------------------------------*/ kobo_form_t *st_options_base_t::open() { sounds = 0; cfg_form = oopen(); cfg_form->open(prefs); return cfg_form; } void st_options_base_t::close() { cfg_form->close(); } void st_options_base_t::enter() { sound.ui_ok(); st_menu_base_t::enter(); } void st_options_base_t::select(int tag) { if(cfg_form->status() & OS_CANCEL) cfg_form->undo(); else if(cfg_form->status() & OS_CLOSE) { if(cfg_form->status() & (OS_RESTART | OS_RELOAD)) { exit_game = 0; manage.freeze_abort(); } } /* * Handle changes that require only an update... */ if(cfg_form->status() & OS_UPDATE_AUDIO) sound.prefschange(); if(cfg_form->status() & OS_UPDATE_ENGINE) { gengine->timefilter(prefs->timefilter * 0.01f); gengine->interpolation(prefs->filter); gengine->vsync(prefs->vsync); gengine->pages(prefs->pages); } cfg_form->clearstatus(OS_UPDATE); if(cfg_form->status() & (OS_CANCEL | OS_CLOSE)) pop(); } void st_options_base_t::press(int button) { st_menu_base_t::press(button); gengine->timefilter(prefs->timefilter * 0.01f); gengine->interpolation(prefs->filter); } void st_options_base_t::escape() { sound.ui_cancel(); cfg_form->undo(); } /*---------------------------------------------------------- Options... ----------------------------------------------------------*/ st_options_system_t st_options_system; st_options_video_t st_options_video; st_options_graphics_t st_options_graphics; st_options_audio_t st_options_audio; st_options_control_t st_options_control; st_options_game_t st_options_game; /*---------------------------------------------------------- Requesters ----------------------------------------------------------*/ void yesno_menu_t::build() { halign = ALIGN_CENTER; xoffs = 0.5; big(); space(8); button("YES", MENU_TAG_OK); button("NO", MENU_TAG_CANCEL); } void yesno_menu_t::rebuild() { int sel = selected_index(); build_all(); select(sel); } /*---------------------------------------------------------- st_yesno_base_t ----------------------------------------------------------*/ kobo_form_t *st_yesno_base_t::open() { menu = new yesno_menu_t; menu->open(); menu->select(1); return menu; } void st_yesno_base_t::reenter() { menu->rebuild(); menu->select(1); st_menu_base_t::reenter(); } void st_yesno_base_t::press(int button) { switch (button) { case BTN_NO: select(MENU_TAG_CANCEL); break; case BTN_YES: select(MENU_TAG_OK); break; default: st_menu_base_t::press(button); } } void st_yesno_base_t::frame() { if(manage.game_stopped()) manage.run_intro(); else manage.run_pause(); } void st_yesno_base_t::post_render() { st_menu_base_t::post_render(); float ft = SDL_GetTicks() * 0.001; wmain->font(B_BIG_FONT); int y = PIXEL2CS(100) + (int)floor(PIXEL2CS(15)*sin(ft * 6)); wmain->center_fxp(y, msg); } /*---------------------------------------------------------- st_ask_exit ----------------------------------------------------------*/ st_ask_exit_t::st_ask_exit_t() { name = "ask_exit"; msg = "Quit Kobo Deluxe?"; } void st_ask_exit_t::select(int tag) { switch(tag) { case MENU_TAG_OK: audio_channel_stop(0, -1); //Stop any music sound.ui_ok(); exit_game = 1; pop(); break; case MENU_TAG_CANCEL: sound.ui_cancel(); if(manage.game_stopped()) pop(); else gsm.change(&st_pause_game); break; } } st_ask_exit_t st_ask_exit; /*---------------------------------------------------------- st_ask_abort_game ----------------------------------------------------------*/ st_ask_abort_game_t::st_ask_abort_game_t() { name = "ask_abort_game"; msg = "Abort Game?"; } void st_ask_abort_game_t::select(int tag) { switch(tag) { case MENU_TAG_OK: sound.ui_ok(); manage.abort(); pop(); break; case MENU_TAG_CANCEL: gsm.change(&st_pause_game); break; } } st_ask_abort_game_t st_ask_abort_game; /*---------------------------------------------------------- Debug: Audio Engine Profiling ----------------------------------------------------------*/ #ifdef PROFILE_AUDIO #include "sound.h" #include "a_midicon.h" st_profile_audio_t::st_profile_audio_t() { name = "profile_audio"; pan = 0; pitch = 60; shift = 0; } void st_profile_audio_t::enter() { audio_group_control(SOUND_GROUP_SFX, ACC_PAN, pan); audio_group_control(SOUND_GROUP_SFX, ACC_PITCH, pitch << 16); screen.set_highlight(0, 0); screen.noise(0); sound.sfx_volume(1.0f); } void st_profile_audio_t::press(int button) { switch (button) { case BTN_EXIT: pop(); break; case BTN_LEFT: pan -= 8192; if(pan < -65536) pan = -65536; audio_group_control(SOUND_GROUP_SFX, ACC_PAN, pan); break; case BTN_RIGHT: pan += 8192; if(pan > 65536) pan = 65536; audio_group_control(SOUND_GROUP_SFX, ACC_PAN, pan); break; case BTN_UP: ++pitch; if(pitch > 127) pitch = 127; audio_group_control(SOUND_GROUP_SFX, ACC_PITCH, pitch << 16); break; case BTN_DOWN: --pitch; if(pitch < 0) pitch = 0; audio_group_control(SOUND_GROUP_SFX, ACC_PITCH, pitch << 16); break; case BTN_NO: case BTN_UL: case BTN_UR: case BTN_DL: case BTN_DR: break; case BTN_INC: shift += 8; if(shift > AUDIO_MAX_WAVES-8) shift = 0; break; case BTN_DEC: shift -= 8; if(shift < 0) shift = AUDIO_MAX_WAVES-8; break; case BTN_FIRE: { audio_channel_stop(-1, -1); int startt = SDL_GetTicks(); audio_wave_load(0, "sfx.agw", 0); log_printf(VLOG, "(Loading + processing time: %d ms)\n", SDL_GetTicks() - startt); break; } case BTN_START: case BTN_SELECT: audio_channel_stop(-1, -1); break; case BTN_YES: break; case BTN_F1: sound.g_play0(0 + shift); midicon_midisock.program_change(0, 0 + shift); break; case BTN_F2: sound.g_play0(1 + shift); midicon_midisock.program_change(0, 1 + shift); break; case BTN_F3: sound.g_play0(2 + shift); midicon_midisock.program_change(0, 2 + shift); break; case BTN_F4: sound.g_play0(3 + shift); midicon_midisock.program_change(0, 3 + shift); break; case BTN_F5: sound.g_play0(4 + shift); midicon_midisock.program_change(0, 4 + shift); break; case BTN_F6: sound.g_play0(5 + shift); midicon_midisock.program_change(0, 5 + shift); break; case BTN_F7: sound.g_play0(6 + shift); midicon_midisock.program_change(0, 6 + shift); break; case BTN_F8: sound.g_play0(7 + shift); midicon_midisock.program_change(0, 7 + shift); break; case BTN_F11: switch(audio_cpu_ticks) { case 50: audio_cpu_ticks = 100; break; case 100: audio_cpu_ticks = 250; break; case 250: audio_cpu_ticks = 500; break; case 500: audio_cpu_ticks = 1000; break; default: audio_cpu_ticks = 50; break; } break; } } void st_profile_audio_t::pre_render() { /* * Heeelp! I just *can't* stay away from chances * like this to play around... :-D */ static int dither = 0; int y = 0; int y2 = wmain->height(); float t = SDL_GetTicks()/1000.0; while(y < y2) { float c1 = sin(y*0.11 + t*1.5)*30.0 + 30; float c2 = sin(y*0.07 + t*2.5)*25.0 + 25; float c3 = sin(y*0.03 - t)*40.0 + 40; //Wideband color dither - improves 15/16 bit modes. float c4 = (dither + y) & 1 ? 3.0 : 0.0; int r = (int)(c1 + c2 + c4); int g = (int)(c2 + 3.0 - c4); int b = (int)(c1 + c2 + c3 + c4); wmain->foreground(wmain->map_rgb(r, g, b)); wmain->fillrect(0, y, wmain->width(), 1); ++y; } dither = 1 - dither; } void st_profile_audio_t::post_render() { kobo_basestate_t::post_render(); wmain->font(B_BIG_FONT); wmain->center(20, "Audio CPU Load"); wmain->font(B_NORMAL_FONT); Uint32 fgc = wmain->map_rgb(0xffcc00); Uint32 bgc = wmain->map_rgb(0x006600); char buf[40]; for(int i = 0; i < AUDIO_CPU_FUNCTIONS; ++i) { int perc = (int)(audio_cpu_function[i] / audio_cpu_total * 100.0); wmain->foreground(fgc); wmain->fillrect(103, 50+i*12+9, (int)audio_cpu_function[i]/2, 2); wmain->fillrect(128+32, 50+i*12+9, (int)perc/2, 2); wmain->foreground(bgc); wmain->fillrect(103 + (int)audio_cpu_function[i]/2, 50+i*12+9, 50 - (int)audio_cpu_function[i]/2, 2); wmain->fillrect(128+32 + (int)perc/2, 50+i*12+9, 50 - (int)perc/2, 2); snprintf(buf, sizeof(buf), "%s:%5.2f%% (%1.0f%%)", audio_cpu_funcname[i], audio_cpu_function[i], audio_cpu_function[i] / audio_cpu_total * 100.0); wmain->center_token(120, 50+i*12, buf, ':'); } wmain->foreground(fgc); wmain->fillrect(80, 178, (int)audio_cpu_total, 4); wmain->foreground(bgc); wmain->fillrect(80 + (int)audio_cpu_total, 178, 100 - (int)audio_cpu_total, 4); wmain->font(B_BIG_FONT); snprintf(buf, sizeof(buf), "Total:%5.2f%%", audio_cpu_total); wmain->center_token(120, 180, buf, ':'); wmain->font(B_NORMAL_FONT); snprintf(buf, sizeof(buf), "Pan [L/R]:%5.2f " "Pitch [U/D]: %d ", (float)pan/65536.0, pitch); wmain->center(200, buf); snprintf(buf, sizeof(buf), "F1..F8 [+/-]: %d..%d", shift, shift + 7); wmain->center(215, buf); } st_profile_audio_t st_profile_audio; #endif /*PROFILE_AUDIO*/ KoboDeluxe-0.5.1/form.cpp0000644000175000001440000001301610730636177012155 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001, 2002, 2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #include "kobolog.h" #include "config.h" #include "form.h" #include "kobo.h" #include "audio.h" kobo_form_t::kobo_form_t() { ypos = 0; current_list = NULL; _big = 0; xoffs = 0.5; halign = ALIGN_DEFAULT; } kobo_form_t::~kobo_form_t() { } void kobo_form_t::next() { sound.ui_move(); ct_form_t::next(); } void kobo_form_t::prev() { sound.ui_move(); ct_form_t::prev(); } /* virtual */ void kobo_form_t::change(int delta) { ct_form_t::change(delta); if(selected()->user) { int *val = (int *)selected()->user; *val = selected()->value(); DBG(log_printf(D2LOG, "Changed to %d\n", selected()->value());) } } /* virtual */void kobo_form_t::build() { } void kobo_form_t::init_widget(ct_widget_t *w) { current_widget = w; w->init(engine); switch(_big) { case 0: w->place(x(), y()+ypos, width(), LINE_H); w->font(B_NORMAL_FONT); ypos += LINE_H; break; case 1: w->place(x(), y()+ypos, width(), BIG_LINE_H); w->font(B_BIG_FONT); ypos += BIG_LINE_H; break; case 2: w->place(x(), y()+ypos, width(), BIG_LINE_H); w->font(B_MEDIUM_FONT); ypos += BIG_LINE_H; break; } w->halign(halign); add(w); } void kobo_form_t::big() { _big = 1; } void kobo_form_t::medium() { _big = 2; } void kobo_form_t::small() { _big = 0; } void kobo_form_t::begin() { clean(); ypos = 15; current_list = NULL; small(); } void kobo_form_t::label(const char *cap) { ct_label_t *w = new ct_label_t(cap); init_widget(w); } void kobo_form_t::yesno(const char *cap, int *var, int tag) { current_list = new ct_list_t(cap); current_list->offset(xoffs, 0); current_list->user = var; current_list->tag = tag; current_list->add("Yes", 1); current_list->add("No", 0); init_widget(current_list); } void kobo_form_t::onoff(const char *cap, int *var, int tag) { current_list = new ct_list_t(cap); current_list->offset(xoffs, 0); current_list->user = var; current_list->tag = tag; current_list->add("On", 1); current_list->add("Off", 0); init_widget(current_list); } void kobo_form_t::spin(const char *cap, int *var, int min, int max, const char *unit, int tag) { ct_spin_t *w = new ct_spin_t(cap, min, max, unit); w->offset(xoffs, 0); w->user = var; w->tag = tag; init_widget(w); } void kobo_form_t::list(const char *cap, int *var, int tag) { ct_list_t *w = new ct_list_t(cap); w->offset(xoffs, 0); w->user = var; w->tag = tag; current_list = w; init_widget(w); } void kobo_form_t::item(const char *cap, int value, int ind) { if(current_list) { ct_item_t *i = new ct_item_t(cap, value); i->index(ind); current_list->add(i); } else log_printf(ELOG, "kobo_form_t::form_item(): No list!\n"); } void kobo_form_t::perc_list(int first, int last, int step) { char buf[50]; for(int i = first; i <= last; i += step) { snprintf(buf, sizeof(buf), "%d%%", i); item(buf, i); } } void kobo_form_t::enum_list(int first, int last) { char buf[50]; for(int i = first; i <= last; i++) { snprintf(buf, sizeof(buf), "%d", i); item(buf, i); } } void kobo_form_t::button(const char *cap, int tag) { ct_widget_t *w = new ct_button_t(cap); w->offset(xoffs, 0); w->tag = tag; init_widget(w); } void kobo_form_t::data(config_parser_t *_d) { _data = _d; } void kobo_form_t::editor(int handle, int tag) { if(!_data) return; switch(_data->type(handle)) { default: log_printf(ELOG, "kobo_form_t: Unknown data type!\n"); break; case CFG_BOOL: onoff(_data->description(handle), (int *)NULL, tag); current_widget->user2 = handle; break; case CFG_INT: case CFG_FLOAT: spin(_data->description(handle), (int *)NULL, -100000, 100000, "", tag); current_widget->user2 = handle; break; case CFG_STRING: log_printf(ELOG, "kobo_form_t: String editor not yet implemented!\n"); break; } } void kobo_form_t::editor(const char *name, int tag) { if(!_data) return; int h = _data->find(name); if(h < 0) return; editor(h, tag); } void kobo_form_t::space(int lines) { if(_big) ypos += BIG_SPACE_SIZE * lines; else ypos += SPACE_SIZE * lines; } void kobo_form_t::end() { } void kobo_form_t::build_all() { xoffs = 0.5; begin(); build(); end(); /* * Initialize all widgets from prefs and/or config_parser. */ ct_widget_t *w = widgets; while(w) { if(w->user) { int *val = (int *)w->user; if(val) { w->value(*val); log_printf(D3LOG, "Initialized to %d from prefs\n", w->value()); } else if(_data) { w->value(_data->get_i(w->user2)); log_printf(D3LOG, "Initialized to %d from config_parser\n", w->value()); } } w = w->next; if(w == widgets) break; //Done! } } KoboDeluxe-0.5.1/cfgparse.cpp0000644000175000001440000004366110730706410013001 00000000000000/*(LGPL) ------------------------------------------------------------------- cfgparse.cpp - Generic Config File and Argument Parser ------------------------------------------------------------------- * Copyright (C) 2001, 2007 David Olofson * * This code is released under the terms of the GNU LGPL. */ #include "config.h" #include "logger.h" #include #include #include #include "cfgparse.h" #define MAX_CONFIG_LINES 1024 /*---------------------------------------------------------- cfg_key_t ----------------------------------------------------------*/ cfg_key_t::cfg_key_t() { next = NULL; name = ""; save = 1; typecode = CFG_NONE; redefined = 0; description = NULL; } cfg_key_t::~cfg_key_t() { free(description); } int cfg_key_t::read(int argc, char *argv[]) { return 0; } int cfg_key_t::test(const char *arg) { if(arg[0] == '-' || arg[0] == '/') ++arg; return !strcmp(name, arg); } /*---------------------------------------------------------- cfg_comment_t ----------------------------------------------------------*/ void cfg_comment_t::write(FILE *f) { fprintf(f, "#%s\n", name); } int cfg_comment_t::copy(cfg_key_t *from) { if(typecode != from->typecode) return -1; return 0; } /*---------------------------------------------------------- cfg_switch_t ----------------------------------------------------------*/ cfg_switch_t::cfg_switch_t(const char *_name, int &var, int def, int _save) { name = _name; value = &var; default_value = def; save = _save; typecode = CFG_BOOL; } int cfg_switch_t::copy(cfg_key_t *from) { if(typecode != from->typecode) return -1; *value = *((cfg_switch_t *)from)->value; return 0; } int cfg_switch_t::test(const char *arg) { if(arg[0] == '-' || arg[0] == '/') ++arg; if(strncmp("no", name, 2)) if(!strncmp("no", arg, 2)) arg += 2; return !strcmp(name, arg); } int cfg_switch_t::read(int argc, char *argv[]) { char *arg = argv[0]; *value = 1; if(arg[0] == '-' || arg[0] == '/') ++arg; if(!strncmp("no", arg, 2)) *value = 0; if(!strncmp("no", name, 2)) *value = !(*value); return 1; } void cfg_switch_t::write(FILE *f) { fprintf(f, *value ? "%s\n" : "no%s\n", name); } void cfg_switch_t::set_default() { *value = default_value; } int cfg_switch_t::is_your_var(void *var) { return var == (void *)value; } /*---------------------------------------------------------- cfg_key_int_t ----------------------------------------------------------*/ cfg_key_int_t::cfg_key_int_t(const char *_name, int &var, int def, int _save) { name = _name; value = &var; default_value = def; save = _save; typecode = CFG_INT; } int cfg_key_int_t::copy(cfg_key_t *from) { if(typecode != from->typecode) return -1; *value = *((cfg_key_int_t *)from)->value; return 0; } int cfg_key_int_t::read(int argc, char *argv[]) { if(argc < 2) return -1; *value = atoi(argv[1]); return 2; } void cfg_key_int_t::write(FILE *f) { fprintf(f, "%s %d\n", name, *value); } void cfg_key_int_t::set_default() { *value = default_value; } int cfg_key_int_t::is_your_var(void *var) { return var == (void *)value; } /*---------------------------------------------------------- cfg_key_float_t ----------------------------------------------------------*/ cfg_key_float_t::cfg_key_float_t(const char *_name, float &var, float def, int _save) { name = _name; value = &var; default_value = def; save = _save; typecode = CFG_FLOAT; } int cfg_key_float_t::copy(cfg_key_t *from) { if(typecode != from->typecode) return -1; *value = *((cfg_key_float_t *)from)->value; return 0; } int cfg_key_float_t::read(int argc, char *argv[]) { if(argc < 2) return -1; *value = atof(argv[1]); return 2; } void cfg_key_float_t::write(FILE *f) { fprintf(f, "%s %f\n", name, *value); } void cfg_key_float_t::set_default() { *value = default_value; } int cfg_key_float_t::is_your_var(void *var) { return var == (void *)value; } /*---------------------------------------------------------- cfg_key_string_t ----------------------------------------------------------*/ cfg_key_string_t::cfg_key_string_t(const char *_name, cfg_string_t &var, const cfg_string_t def, int _save) { name = _name; value = &var; strncpy(default_value, def, CFG_STRING_LENGTH); save = _save; typecode = CFG_STRING; } int cfg_key_string_t::copy(cfg_key_t *from) { if(typecode != from->typecode) return -1; memcpy(*value, *((cfg_key_string_t *)from)->value, CFG_STRING_LENGTH); return 0; } int cfg_key_string_t::read(int argc, char *argv[]) { if(argc < 2) return -1; strncpy(*value, argv[1], CFG_STRING_LENGTH); return 2; } void cfg_key_string_t::write(FILE *f) { fprintf(f, "%s \"%s\"\n", name, *value); } void cfg_key_string_t::set_default() { strncpy(*value, default_value, CFG_STRING_LENGTH); } int cfg_key_string_t::is_your_var(void *var) { return var == (void *)value; } /*---------------------------------------------------------- config_parser_t ----------------------------------------------------------*/ config_parser_t::config_parser_t() { keys = last_key = NULL; changed = 0; initialized = 0; } void config_parser_t::initialize() { if(initialized) return; init(); set_defaults(); build_table(); initialized = 1; } void config_parser_t::build_table() { cfg_key_t *k = keys; nkeys = 0; while(k) { ++nkeys; k = k->next; } table = new cfg_key_t*[nkeys]; k = keys; int i = 0; while(k) { table[i++] = k; k = k->next; } } config_parser_t::~config_parser_t() { cfg_key_t *k = keys; while(k) { keys = k->next; delete k; k = keys; } delete[]table; } config_parser_t &config_parser_t::operator = (config_parser_t &from) { initialize(); from.initialize(); cfg_key_t *k = keys; while(k) { cfg_key_t *fk = from.keys; while(fk) { if(!strcmp(fk->name, k->name)) { if(k->copy(fk) < 0) log_printf(ELOG, "config_parser_t: Tried" " to copy from incompatible" " source!\n"); break; } fk = fk->next; } k = k->next; } return *this; } void config_parser_t::add(cfg_key_t *_key) { if(last_key) { last_key->next = _key; last_key = _key; } else keys = last_key = _key; } void config_parser_t::comment(const char *text) { add(new cfg_comment_t(text)); } void config_parser_t::yesno(const char *name, int &var, int def, int save) { add(new cfg_switch_t(name, var, def, save)); } void config_parser_t::command(const char *name, int &var) { add(new cfg_switch_t(name, var, 0, 0)); } void config_parser_t::key(const char *name, int &var, int def, int save) { add(new cfg_key_int_t(name, var, def, save)); } void config_parser_t::key(const char *name, float &var, float def, int save) { add(new cfg_key_float_t(name, var, def, save)); } void config_parser_t::key(const char *name, cfg_string_t &var, const cfg_string_t def, int save) { add(new cfg_key_string_t(name, var, def, save)); } void config_parser_t::desc(const char *text) { if(!last_key) { log_printf(ELOG, "config_parser_t::description() called" " with no key registered!\n"); return; } last_key->description = strdup(text); } void config_parser_t::set_defaults() { cfg_key_t *k = keys; while(k) { k->set_default(); k->redefined = 0; k = k->next; } } /* * "Uuuh, a leetle icky finite state machine parser... :-D" * (Actually a very nice and simple way of coding this kind * of stuff, if you don't want to drag in Bison or something.) */ enum scanstate_t { SS_BLANK, SS_QUOTE, SS_WORD, SS_COMMENT }; int config_parser_t::read_config(char ***cv, FILE *f) { *cv = (char **)calloc(MAX_CONFIG_LINES, sizeof(char *)); if(!*cv) return -1; if(!f) { free((*cv)); (*cv) = NULL; return -2; } fseek(f, 0, SEEK_END); int len = ftell(f); (*cv)[0] = (char *)malloc(len+1); if(!(*cv)[0]) { rewind(f); free(*cv); *cv = NULL; return -3; } rewind(f); if(fread((*cv)[0], len, 1, f) < 0) { free(*cv[0]); free(*cv); *cv = NULL; return -4; } (*cv)[0][len] = 0; char *v = (*cv)[0]; scanstate_t state = SS_BLANK; int arg = 1; int start_arg = 0; while(*v) { switch(state) { case SS_BLANK: if(*v == '"') { start_arg = 1; state = SS_QUOTE; } else if(*v == '#') state = SS_COMMENT; else if(*v > ' ') { start_arg = 1; state = SS_WORD; } break; case SS_QUOTE: if(*v == '"') { *v = 0; state = SS_BLANK; } break; case SS_WORD: if(*v <= ' ') { *v = 0; state = SS_BLANK; } break; case SS_COMMENT: if((*v == 10) || (*v == 13)) state = SS_BLANK; break; } if(start_arg) { if(arg < MAX_CONFIG_LINES) { if(state == SS_QUOTE) (*cv)[arg++] = v+1; else (*cv)[arg++] = v; } start_arg = 0; } ++v; } rewind(f); return arg; } int config_parser_t::parse(int argc, char *argv[]) { initialize(); int i = 0; while(i < argc) { if(argv[i][0] == '#') { ++i; continue; } cfg_key_t *k = keys; int grabbed = 0; while(k) { if(k->test(argv[i])) { grabbed = k->read(argc - i, argv + i); if(grabbed > 0) { k->redefined = 1; break; } else if(grabbed < 0) { log_printf(ELOG, "ERROR: Too few parameters to" " argument '%s'!\n", k->name); return -2; } } k = k->next; } if(!grabbed) { log_printf(ELOG, "ERROR: Unknown argument" " '%s'!\n", argv[i]); return -3; } i += grabbed; } postload(); return 0; /* Ok. */ } int config_parser_t::read(FILE *f) { int res = -10; int cc; char **cv; cc = read_config(&cv, f); if(cc > 0) { res = parse(cc, cv); if(cv) free(cv[0]); free(cv); } return res; } int config_parser_t::write(FILE *f) { initialize(); presave(); cfg_key_t *k = keys; while(k) { if(k->save) k->write(f); k = k->next; } return ferror(f); } int config_parser_t::_redefined(void *var) { cfg_key_t *k = keys; while(k) { if(k->is_your_var(var)) return k->redefined; k = k->next; } return 0; } void config_parser_t::_accept(void *var) { cfg_key_t *k = keys; while(k) { if(k->is_your_var(var)) { k->redefined = 0; break; } k = k->next; } } /*---------------------------------------------------------- Generic Symbol Table Style API ----------------------------------------------------------*/ int config_parser_t::find(const char *name) { if(!table) initialize(); if(!table) return -1; for(int i = 0; i < nkeys; ++i) if(table[i]->test(name)) return i; return -1; } int config_parser_t::find_next(int symbol) { if(!table) initialize(); if(!table) return -1; // Note that this simple code handles the // "find first" -1 case for free. :-) ++symbol; if(symbol < 0) return -1; else if(symbol >= nkeys) return -1; return symbol; } int config_parser_t::check_symbol(int symbol) { if(!table) return -1; if(symbol < 0) return -1; else if(symbol >= nkeys) return -1; return 0; } cfg_types_t config_parser_t::type(int symbol) { if(check_symbol(symbol) < 0) return CFG_NONE; return table[symbol]->typecode; } int config_parser_t::do_save(int symbol) { if(check_symbol(symbol) < 0) return CFG_NONE; return table[symbol]->save; } const char *config_parser_t::description(int symbol) { if(check_symbol(symbol) < 0) return ""; if(table[symbol]->description) return table[symbol]->description; else return ""; } const char *config_parser_t::name(int symbol) { if(check_symbol(symbol) < 0) return ""; if(table[symbol]->name) return table[symbol]->name; else return ""; } void config_parser_t::set(int symbol, int value) { if(check_symbol(symbol) < 0) return; switch(table[symbol]->typecode) { case CFG_NONE: return; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; *(k->value) = value ? 1 : 0; } break; case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; *(k->value) = value; } break; case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; *(k->value) = (float)value; } break; case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; snprintf(*(k->value), CFG_STRING_LENGTH-1, "%d", value); } break; } table[symbol]->redefined = 1; } void config_parser_t::set(int symbol, float value) { if(check_symbol(symbol) < 0) return; switch(table[symbol]->typecode) { case CFG_NONE: return; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; *(k->value) = value ? 1 : 0; } break; case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; *(k->value) = (int)value; } break; case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; *(k->value) = value; } break; case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; snprintf(*(k->value), CFG_STRING_LENGTH-1, "%f", value); } break; } table[symbol]->redefined = 1; } void config_parser_t::set(int symbol, const char *text) { if(check_symbol(symbol) < 0) return; switch(table[symbol]->typecode) { case CFG_NONE: return; case CFG_BOOL: { /* * Unfortunately, only *real* operating systems have * strcasecmp(), so we have to mess around a little. */ char buf[16]; strncpy(buf, text, 15); for(int i = 0; i < 15; ++i) buf[i] = tolower(buf[i]); cfg_switch_t *k = (cfg_switch_t *)table[symbol]; if( strncmp(buf, "yes", 3) || strncmp(buf, "true", 4) || strcmp(buf, "on") || strncmp(buf, "enable", 6) || strncmp(buf, "activ", 5) || strcmp(buf, "one") || strcmp(buf, "1") ) *(k->value) = 1; else *(k->value) = 0; } break; case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; *(k->value) = atoi(text); } break; case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; *(k->value) = atof(text); } break; case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; strncpy(*(k->value), text, CFG_STRING_LENGTH-1); *(k->value)[CFG_STRING_LENGTH-1] = 0; } break; } table[symbol]->redefined = 1; } int config_parser_t::get_i(int symbol) { if(check_symbol(symbol) < 0) return 0; switch(table[symbol]->typecode) { case CFG_NONE: return 0; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return *(k->value) ? 1 : 0; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; return *(k->value); } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; return (int)*(k->value); } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return atoi(*(k->value)); } } return 0; } float config_parser_t::get_f(int symbol) { if(check_symbol(symbol) < 0) return 0.0; switch(table[symbol]->typecode) { case CFG_NONE: return 0.0; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return *(k->value) ? 1.0 : 0.0; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; return (float)*(k->value); } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; return *(k->value); } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return atof(*(k->value)); } } return 0.0; } const char *config_parser_t::get_s(int symbol) { if(check_symbol(symbol) < 0) return ""; switch(table[symbol]->typecode) { case CFG_NONE: return ""; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return *(k->value) ? "On" : "Off"; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; snprintf(retbuf, sizeof(retbuf)-1, "%d", *(k->value)); return retbuf; } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; snprintf(retbuf, sizeof(retbuf)-1, "%f", *(k->value)); return retbuf; } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return *(k->value); } break; } return ""; } int config_parser_t::get_default_i(int symbol) { if(check_symbol(symbol) < 0) return 0; switch(table[symbol]->typecode) { case CFG_NONE: return 0; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return k->default_value ? 1 : 0; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; return k->default_value; } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; return (int)k->default_value; } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return atoi(k->default_value); } } return 0; } float config_parser_t::get_default_f(int symbol) { if(check_symbol(symbol) < 0) return 0.0; switch(table[symbol]->typecode) { case CFG_NONE: return 0.0; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return k->default_value ? 1.0 : 0.0; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; return (float)k->default_value; } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; return k->default_value; } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return atof(k->default_value); } } return 0.0; } const char *config_parser_t::get_default_s(int symbol) { if(check_symbol(symbol) < 0) return ""; switch(table[symbol]->typecode) { case CFG_NONE: return ""; case CFG_BOOL: { cfg_switch_t *k = (cfg_switch_t *)table[symbol]; return k->default_value ? "On" : "Off"; } case CFG_INT: { cfg_key_int_t *k = (cfg_key_int_t *)table[symbol]; snprintf(retbuf, sizeof(retbuf)-1, "%d", k->default_value); return retbuf; } case CFG_FLOAT: { cfg_key_float_t *k = (cfg_key_float_t *)table[symbol]; snprintf(retbuf, sizeof(retbuf)-1, "%f", k->default_value); return retbuf; } case CFG_STRING: { cfg_key_string_t *k = (cfg_key_string_t *)table[symbol]; return k->default_value; } break; } return ""; } KoboDeluxe-0.5.1/game.cpp0000644000175000001440000000530310734441443012115 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2002, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include "game.h" game_t game; game_t::game_t() { reset(); } void game_t::reset() { set(GAME_SINGLE, SKILL_CLASSIC); } void game_t::set(game_types_t tp, skill_levels_t sk) { type = tp; skill = sk; // Game and player speed = 30; lives = 5; bonus_first = 2000; bonus_every = 3000; health = 1; health_fade = 5; damage = 0; bolts = 10; bolt_damage = 20; noseloadtime = 1; noseheatup = 0; nosecooling = 256; altfire = 0; tailloadtime = 1; tailheatup = 0; tailcooling = 256; // Enemies rock_health = 255 * bolt_damage; rock_damage = 1000; switch(skill) { case SKILL_CLASSIC: break; case SKILL_NEWBIE: speed = 40; lives = 5; bonus_first = 5000; bonus_every = 7000; health = 100; damage = 100; bolts = MAX_BOLTS; noseloadtime = 1; noseheatup = 14; nosecooling = 5; tailloadtime = 0; tailheatup = 7; tailcooling = 5; altfire = 1; rock_health = 200; rock_damage = 50; break; case SKILL_GAMER: speed = 30; lives = 5; bonus_first = 8000; bonus_every = 8000; health = 60; damage = 100; bolts = MAX_BOLTS; noseloadtime = 0; noseheatup = 10; nosecooling = 5; tailloadtime = 1; tailheatup = 20; tailcooling = 5; rock_health = 500; rock_damage = 50; break; case SKILL_ELITE: speed = 27; lives = 4; bonus_first = 10000; bonus_every = 10000; health = 50; damage = 50; bolts = MAX_BOLTS; noseloadtime = 1; noseheatup = 26; nosecooling = 5; tailloadtime = 2; tailheatup = 39; tailcooling = 5; break; case SKILL_GOD: default: speed = 25; lives = 3; bonus_first = 10000; bonus_every = 10000; health = 40; damage = 30; bolts = MAX_BOLTS; noseloadtime = 1; noseheatup = 30; nosecooling = 5; tailloadtime = 2; tailheatup = 45; tailcooling = 5; break; } } KoboDeluxe-0.5.1/kobo.cpp0000666000175000001440000013224610733645246012157 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2005-2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) x #undef DEBUG_OUT // Use this to benchmark and create a new percentage table! #undef TIME_PROGRESS #include #include #include #include #include #include #include #include #include #ifdef DEBUG #include "audio.h" extern "C" { /*For the oscilloscope*/ #include "a_globals.h" /*For VU and voice info*/ #include "a_struct.h" } #endif #include "kobolog.h" #include "config.h" #include "kobo.h" #include "states.h" #include "screen.h" #include "manage.h" #include "score.h" #include "gamectl.h" #include "random.h" #include "version.h" #include "options.h" #include "myship.h" #include "enemies.h" #define MAX_FPS_RESULTS 64 /* Joystick support */ #define DEFAULT_JOY_LR 0 // Joystick axis left-right default #define DEFAULT_JOY_UD 1 // Joystick axis up-down default #define DEFAULT_JOY_FIRE 0 // Default fire button on joystick #define DEFAULT_JOY_START 1 /*---------------------------------------------------------- Singletons ----------------------------------------------------------*/ KOBO_sound sound; /*---------------------------------------------------------- Globals ----------------------------------------------------------*/ filemapper_t *fmap = NULL; prefs_t *prefs = NULL; kobo_gfxengine_t *gengine = NULL; screen_window_t *wscreen = NULL; dashboard_window_t *wdash = NULL; bargraph_t *whealth = NULL; bargraph_t *wtemp = NULL; bargraph_t *wttemp = NULL; radar_map_t *wmap = NULL; radar_window_t *wradar = NULL; window_t *wmain = NULL; display_t *dhigh = NULL; display_t *dscore = NULL; display_t *dstage = NULL; display_t *dships = NULL; RGN_region *logo_region = NULL; int mouse_x = 0; int mouse_y = 0; int mouse_left = 0; int mouse_middle = 0; int mouse_right = 0; int exit_game = 0; static int main_init() { prefs = new prefs_t; fmap = new filemapper_t; gengine = new kobo_gfxengine_t; return 0; } static void main_cleanup() { delete gengine; gengine = NULL; delete fmap; fmap = NULL; delete prefs; prefs = NULL; } /*---------------------------------------------------------- Various functions ----------------------------------------------------------*/ static void setup_dirs(char *xpath) { fmap->exepath(xpath); fmap->addpath("DATA", KOBO_DATA_DIR); /* * Graphics data */ /* Current dir; from within the build tree */ fmap->addpath("GFX", "./data/gfx"); /* Real data dir */ fmap->addpath("GFX", "DATA>>gfx"); /* Current dir */ fmap->addpath("GFX", "./gfx"); /* * Sound data */ /* Current dir; from within the build tree */ fmap->addpath("SFX", "./data/sfx"); /* Real data dir */ fmap->addpath("SFX", "DATA>>sfx"); /* Current dir */ fmap->addpath("SFX", "./sfx"); /* * Score files (user and global) */ fmap->addpath("SCORES", KOBO_SCORE_DIR); /* 'scores' in current dir (For importing scores, perhaps...) */ // (Disabled for now, since filemapper_t can't tell // when it hits the same dir more than once...) // fmap->addpath("SCORES", "./scores"); /* * Configuration files */ fmap->addpath("CONFIG", KOBO_CONFIG_DIR); /* System local */ fmap->addpath("CONFIG", SYSCONF_DIR); /* In current dir (last resort) */ fmap->addpath("CONFIG", "./"); } static void add_dirs(prefs_t *p) { char buf[300]; if(p->dir[0]) { char *upath = fmap->sys2unix(p->dir); snprintf(buf, 300, "%s/sfx", upath); fmap->addpath("SFX", buf, 1); snprintf(buf, 300, "%s/gfx", upath); fmap->addpath("GFX", buf, 1); snprintf(buf, 300, "%s/scores", upath); fmap->addpath("SCORES", buf, 1); snprintf(buf, 300, "%s", upath); fmap->addpath("CONFIG", buf, 0); } if(p->sfxdir[0]) fmap->addpath("SFX", fmap->sys2unix(p->sfxdir), 1); if(p->gfxdir[0]) fmap->addpath("GFX", fmap->sys2unix(p->gfxdir), 1); if(p->scoredir[0]) fmap->addpath("SCORES", fmap->sys2unix(p->scoredir), 1); } #ifdef DEBUG static void draw_osc(int mode) { int mx = oscframes; if(mx > wmain->width()) mx = wmain->width(); int yo = wmain->height() - 40; wmain->foreground(wmain->map_rgb(0x000099)); wmain->fillrect(0, yo, wmain->width(), 1); wmain->foreground(wmain->map_rgb(0x990000)); wmain->fillrect(0, yo - 32, wmain->width(), 1); wmain->fillrect(0, yo + 31, wmain->width(), 1); switch(mode) { case 0: wmain->foreground(wmain->map_rgb(0x009900)); for(int s = 0; s < mx; ++s) wmain->point(s, ((oscbufl[s]+oscbufr[s]) >> 11) + yo); break; case 1: wmain->foreground(wmain->map_rgb(0x009900)); for(int s = 0; s < mx; ++s) wmain->point(s, (oscbufl[s] >> 10) + yo); wmain->foreground(wmain->map_rgb(0xcc0000)); for(int s = 0; s < mx; ++s) wmain->point(s, (oscbufr[s] >> 10) + yo); break; case 2: wmain->foreground(wmain->map_rgb(0x009900)); for(int s = 0; s < mx; ++s) wmain->point(s>>1, (oscbufl[s] >> 10) + yo); wmain->foreground(wmain->map_rgb(0xcc0000)); for(int s = 0; s < mx; ++s) wmain->point((s>>1) + (mx>>1), (oscbufr[s] >> 10) + yo); wmain->fillrect(mx/2, yo-34, 1, 68); break; } wmain->foreground(wmain->map_rgb(0xcc0000)); wmain->fillrect(0, yo - 32, 6, limiter.attenuation >> 11); } static void draw_vu(void) { int xo = (wmain->width() - 5 * AUDIO_MAX_VOICES) / 2; int yo = wmain->height() - 50; wmain->foreground(wmain->map_rgb(0x000000)); for(int s = 4; s < 40; s += 4) wmain->fillrect(xo, yo+s, 5 * AUDIO_MAX_VOICES-1, 1); wmain->foreground(wmain->map_rgb(0x333333)); wmain->fillrect(xo-1, yo, 5 * AUDIO_MAX_VOICES+1, 1); wmain->fillrect(xo-1, yo+40, 5 * AUDIO_MAX_VOICES+1, 4); for(int s = 0; s <= AUDIO_MAX_VOICES; ++s) wmain->fillrect(xo + s*5 - 1, yo+1, 1, 39); for(int s = 0; s < AUDIO_MAX_VOICES; ++s) { int vu, vu2, vumin; if(VS_STOPPED != voicetab[s].state) { wmain->foreground(wmain->map_rgb(0x009900)); wmain->fillrect(xo + 1, yo + 41, 2, 2); vu = labs((voicetab[s].ic[VIC_LVOL].v>>1) + (voicetab[s].ic[VIC_RVOL].v>>1)) >> RAMP_BITS; #ifdef AUDIO_USE_VU vu2 = voicetab[s].vu; voicetab[s].vu = 0; #else vu2 = 0; #endif vu2 = (vu2>>4) * (vu>>4) >> 8; vu2 >>= 11; if(vu2 > 40) vu2 = 40; vu >>= 11; if(vu > 40) vu = 40; vumin = vu < vu2 ? vu : vu2; } else vu = vu2 = vumin = 0; wmain->foreground(wmain->map_rgb(0x006600)); wmain->fillrect(xo, yo + 40 - vu, 4, vu - vu2); wmain->foreground(wmain->map_rgb(0xffcc00)); wmain->fillrect(xo, yo + 40 - vu2, 4, vu2); xo += 5; } } #endif /*---------------------------------------------------------- The main object ----------------------------------------------------------*/ class KOBO_main { public: #ifdef DEBUG static int audio_vismode; #endif static SDL_Joystick *joystick; static int js_lr; static int js_ud; static int js_fire; static int js_start; static FILE *logfile; static Uint32 esc_tick; static int esc_count; static int exit_game_fast; // Frame rate counter static int fps_count; static int fps_starttime; static int fps_nextresult; static int fps_lastresult; static float *fps_results; static display_t *dfps; // Frame rate limiter static float max_fps_filter; static int max_fps_begin; static int xoffs; static int yoffs; // Backup in case we screw up we can't get back up static prefs_t safe_prefs; static int open(); static void close(); static int run(); static int open_logging(prefs_t *p); static void close_logging(); static void load_config(prefs_t *p); static void save_config(prefs_t *p); static void build_screen(); static int init_display(prefs_t *p); static void close_display(); static void show_progress(prefs_t *p); static void progress(); static void doing(const char *msg); static int load_graphics(prefs_t *p); static int load_sounds(prefs_t *p, int render_all = 0); static int init_js(prefs_t *p); static void close_js(); static int escape_hammering(); static int quit_requested(); static void brutal_quit(); static void pause_game(); static void print_fps_results(); }; #ifdef DEBUG int KOBO_main::audio_vismode = 0; #endif SDL_Joystick *KOBO_main::joystick = NULL; int KOBO_main::js_lr = DEFAULT_JOY_LR; int KOBO_main::js_ud = DEFAULT_JOY_UD; int KOBO_main::js_fire = DEFAULT_JOY_FIRE; int KOBO_main::js_start = DEFAULT_JOY_START; FILE *KOBO_main::logfile = NULL; Uint32 KOBO_main::esc_tick = 0; int KOBO_main::esc_count = 0; int KOBO_main::exit_game_fast = 0; int KOBO_main::fps_count = 0; int KOBO_main::fps_starttime = 0; int KOBO_main::fps_nextresult = 0; int KOBO_main::fps_lastresult = 0; float *KOBO_main::fps_results = NULL; display_t *KOBO_main::dfps = NULL; float KOBO_main::max_fps_filter = 0.0f; int KOBO_main::max_fps_begin = 0; int KOBO_main::xoffs = 0; int KOBO_main::yoffs = 0; prefs_t KOBO_main::safe_prefs; static KOBO_main km; void KOBO_main::print_fps_results() { int i, r = fps_nextresult; if(fps_lastresult != MAX_FPS_RESULTS-1) r = 0; for(i = 0; i < fps_lastresult; ++i) { log_printf(ULOG, "%.1f fps\n", fps_results[r++]); if(r >= MAX_FPS_RESULTS) r = 0; } free(fps_results); fps_nextresult = 0; fps_lastresult = 0; fps_results = NULL; } int KOBO_main::escape_hammering() { Uint32 nt = SDL_GetTicks(); if(nt - esc_tick > 300) esc_count = 1; else ++esc_count; esc_tick = nt; return esc_count >= 5; } int KOBO_main::quit_requested() { SDL_Event e; while(SDL_PollEvent(&e)) { switch(e.type) { case SDL_QUIT: exit_game_fast = 1; break; case SDL_VIDEOEXPOSE: gengine->invalidate(); break; case SDL_KEYUP: switch(e.key.keysym.sym) { case SDLK_ESCAPE: if(escape_hammering()) exit_game_fast = 1; break; default: break; } break; } } if(exit_game_fast) return 1; return SDL_QuitRequested(); } void KOBO_main::close_logging() { /* Flush logs to disk, close log files etc. */ log_close(); if(logfile) { fclose(logfile); logfile = NULL; } } int KOBO_main::open_logging(prefs_t *p) { close_logging(); if(log_open() < 0) return -1; if(p && p->logfile) switch (p->logformat) { case 2: logfile = fopen("log.html", "wb"); break; default: logfile = fopen("log.txt", "wb"); break; } if(logfile) { log_set_target_stream(0, logfile); log_set_target_stream(1, logfile); } else { log_set_target_stream(0, stdout); log_set_target_stream(1, stderr); } log_set_target_stream(2, NULL); if(p) switch(p->logformat) { default: log_set_target_flags(-1, LOG_TIMESTAMP); break; case 1: log_set_target_flags(-1, LOG_ANSI | LOG_TIMESTAMP); break; case 2: log_set_target_flags(-1, LOG_HTML | LOG_TIMESTAMP); break; } /* All levels output to stdout... */ log_set_level_target(-1, 0); /* ...except these, that output to stderr. */ log_set_level_target(ELOG, 1); log_set_level_target(CELOG, 1); /* Some fancy colors... */ log_set_level_attr(ULOG, LOG_YELLOW); log_set_level_attr(WLOG, LOG_YELLOW | LOG_BRIGHT); log_set_level_attr(ELOG, LOG_RED | LOG_BRIGHT); log_set_level_attr(CELOG, LOG_RED | LOG_BRIGHT | LOG_BLINK); log_set_level_attr(DLOG, LOG_CYAN); log_set_level_attr(D2LOG, LOG_BLUE | LOG_BRIGHT); log_set_level_attr(D3LOG, LOG_BLUE); /* Disable levels as desired */ if(p) switch(p->logverbosity) { case 0: log_set_level_target(ELOG, 2); case 1: log_set_level_target(WLOG, 2); case 2: log_set_level_target(DLOG, 2); case 3: log_set_level_target(D2LOG, 2); case 4: log_set_level_target(D3LOG, 2); case 5: break; } if(p && p->logfile && !logfile) log_printf(ELOG, "Couldn't open log file!\n"); return 0; } void KOBO_main::build_screen() { gengine->clear(0x000000); wdash->place(xoffs, yoffs, SCREEN_WIDTH, SCREEN_HEIGHT); whealth->place(xoffs + 4, yoffs + 92, 8, 128); whealth->bgimage(B_HEALTH_LID, 0); whealth->background(whealth->map_rgb(0x182838)); whealth->redmax(0); wmain->place(xoffs + 8 + MARGIN, yoffs + MARGIN, WSIZE, WSIZE); gengine->output(wmain); dhigh->place(xoffs + 252, yoffs + 4, 64, 18); dhigh->font(B_NORMAL_FONT); dhigh->bgimage(B_HIGH_BACK, 0); dhigh->caption("HIGHSCORE"); dhigh->text("000000000"); dscore->place(dhigh->x(), dhigh->y2() + 4, 64, 18); dscore->font(B_NORMAL_FONT); dscore->bgimage(B_SCORE_BACK, 0); dscore->caption("SCORE"); dscore->text("000000000"); wmap->place(0, 0, MAP_SIZEX, MAP_SIZEY); wmap->offscreen(); wradar->place(xoffs + 244, yoffs + (SCREEN_HEIGHT - MAP_SIZEY) / 2, MAP_SIZEX, MAP_SIZEY); wradar->bgimage(B_RADAR_BACK, 0); wtemp->place(xoffs + 244, yoffs + 188, 4, 32); wtemp->bgimage(B_TEMP_LID, 0); wtemp->background(wtemp->map_rgb(0x182838)); wtemp->redmax(1); wttemp->place(xoffs + 248, yoffs + 188, 4, 32); wttemp->bgimage(B_TTEMP_LID, 0); wttemp->background(wttemp->map_rgb(0x182838)); wttemp->redmax(1); dships->place(xoffs + 264, yoffs + 196, 38, 18); dships->font(B_NORMAL_FONT); dships->bgimage(B_SHIPS_BACK, 0); dships->caption("SHIPS"); dships->text("000"); dstage->place(dships->x(), dships->y2() + 4, 38, 18); dstage->font(B_NORMAL_FONT); dstage->bgimage(B_STAGE_BACK, 0); dstage->caption("STAGE"); dstage->text("000"); if(prefs->cmd_fps) { dfps = new display_t; dfps->init(gengine); dfps->place(0, -9, 48, 18); dfps->color(wdash->map_rgb(0, 0, 0)); dfps->font(B_NORMAL_FONT); dfps->caption("FPS"); } } int KOBO_main::init_display(prefs_t *p) { int dw, dh; // Display size int gw, gh; // Game "window" size gengine->title("Kobo Deluxe " VERSION, "kobodl"); gengine->driver((gfx_drivers_t)p->videodriver); dw = p->width; dh = p->height; if(p->fullscreen) { // This game assumes 1:1 pixel aspect ratio, or 4:3 // width:height ratio, so we need to adjust accordingly. // Note: // This code assumes 1:1 pixels for all resolutions! // This does not hold true for 1280x1024 or a CRT // for example, but that's an incorrect (although // all too common) setup anyway. (1280x1024 is for // 5:4 TFT displays only!) if(dw * 3 >= dh * 4) { // 4:3 or widescreen; Height defines size gw = dh * 4 / 3; gh = dh; } else { // "tallscreen" (probably 5:4 TFT or rotated display) // Width defines size gw = dw; gh = dw * 3 / 4; } } else { gw = dw; gh = dh; } // Scaling has 16ths granularity, so tiles scale properly! gengine->scale((int)((gw * 16 + 8) / SCREEN_WIDTH) / 16.f, (int)((gh * 16 + 8) / SCREEN_HEIGHT) / 16.f); // Read back and recalculate, in case the engine has some ideas... gw = (int)(SCREEN_WIDTH * gengine->xscale() + 0.5f); gh = (int)(SCREEN_HEIGHT * gengine->yscale() + 0.5f); if(!p->fullscreen) { //Add thin black border around the game "screen" in windowed mode. dw = gw + 8; dh = gh + 8; } xoffs = (int)((dw - gw) / 2 / gengine->xscale()); yoffs = (int)((dh - gh) / 2 / gengine->yscale()); gengine->size(dw, dh); gengine->mode(0, p->fullscreen); gengine->doublebuffer(p->doublebuf); gengine->pages(p->pages); gengine->vsync(p->vsync); gengine->shadow(p->shadow); gengine->cursor(0); gengine->period(game.speed); sound.period(game.speed); gengine->timefilter(p->timefilter * 0.01f); gengine->interpolation(p->filter); gengine->scroll_ratio(LAYER_OVERLAY, 0.0, 0.0); gengine->scroll_ratio(LAYER_BULLETS, 1.0, 1.0); gengine->scroll_ratio(LAYER_FX, 1.0, 1.0); gengine->scroll_ratio(LAYER_PLAYER, 1.0, 1.0); gengine->scroll_ratio(LAYER_ENEMIES, 1.0, 1.0); gengine->scroll_ratio(LAYER_BASES, 1.0, 1.0); gengine->wrap(MAP_SIZEX * CHIP_SIZEX, MAP_SIZEY * CHIP_SIZEY); if(gengine->open(ENEMY_MAX) < 0) return -1; gengine->clear(); wscreen = new screen_window_t; wscreen->init(gengine); wscreen->place(0, 0, (int)(gengine->width() / gengine->xscale() + 0.5f), (int)(gengine->height() / gengine->yscale() + 0.5f)); wscreen->border((int)(yoffs * gengine->yscale() + 0.5f), (int)(xoffs * gengine->xscale() + 0.5f), dw - gw - (int)(xoffs * gengine->xscale() + 0.5f), dh - gh - (int)(yoffs * gengine->yscale() + 0.5f)); wdash = new dashboard_window_t; wdash->init(gengine); whealth = new bargraph_t; whealth->init(gengine); wmain = new window_t; wmain->init(gengine); dhigh = new display_t; dhigh->init(gengine); dscore = new display_t; dscore->init(gengine); wmap = new radar_map_t; wmap->init(gengine); wradar = new radar_window_t; wradar->init(gengine); wtemp = new bargraph_t; wtemp->init(gengine); wttemp = new bargraph_t; wttemp->init(gengine); dships = new display_t; dships->init(gengine); dstage = new display_t; dstage->init(gengine); build_screen(); wdash->mode(DASHBOARD_BLACK); return 0; } void KOBO_main::close_display() { delete dfps; dfps = NULL; delete dstage; dstage = NULL; delete dships; dships = NULL; delete wttemp; wttemp = NULL; delete wtemp; wtemp = NULL; delete wradar; wradar = NULL; delete wmap; wmap = NULL; delete dscore; dscore = NULL; delete dhigh; dhigh = NULL; delete wmain; wmain = NULL; delete whealth; whealth = NULL; delete wdash; wdash = NULL; delete wscreen; wscreen = NULL; } void KOBO_main::show_progress(prefs_t *p) { wdash->mode(DASHBOARD_LOADING); wdash->doing(""); } void KOBO_main::progress() { wdash->progress(); } void KOBO_main::doing(const char *msg) { wdash->doing(msg); } #ifndef TIME_PROGRESS static float progtab_graphics[] = { 0.000000, 1.167315, 4.085603, 5.836576, 7.490273, 9.046693, 10.992218, 12.937743, 13.813230, 15.564202, 17.217899, 18.774319, 20.428015, 22.081713, 23.540855, 25.291828, 26.848249, 28.404669, 29.961090, 32.003891, 33.560310, 35.311283, 36.770428, 38.521400, 40.369648, 41.828793, 43.190662, 44.649807, 46.595329, 48.151752, 49.610893, 51.361866, 53.501945, 58.852139, 60.116730, 61.089493, 63.521400, 66.050583, 68.287941, 69.844360, 72.665367, 74.124512, 76.653694, 77.334633, 79.182877, 80.642021, 82.295723, 83.852142, 85.505836, 87.159531, 88.813232, 90.369652, 92.023346, 93.677040, 95.233459, 96.984436, 98.540855, 100.0, 0 }; static float progtab_sounds[] = { 0.000000, 58.709679, 59.516129, 98.790321, 98.790321, 100.0, 0 }; static float progtab_all[] = { 0.000000, 1.556684, 2.639594, 3.282572, 4.060914, 4.737733, 5.380711, 8.697124, 8.764806, 10.016920, 10.761421, 11.472081, 12.216582, 12.893401, 13.604061, 14.416244, 15.093062, 15.262267, 16.074450, 17.428087, 18.680202, 19.932318, 20.879864, 21.759729, 23.011845, 24.365482, 24.534687, 24.839256, 25.651438, 26.429781, 26.700508, 27.241962, 29.678511, 38.477158, 40.203045, 40.372250, 40.913704, 42.571911, 45.211506, 45.922165, 46.565144, 46.903553, 48.866329, 48.967850, 49.306259, 49.847717, 50.389172, 50.964466, 51.641285, 52.115059, 52.690357, 53.231812, 53.773266, 54.382404, 54.991539, 55.499153, 56.006767, 57.495770, 82.673431, 82.978004, 99.763115, 99.796951, 100.0, 0 }; #endif typedef enum { KOBO_CLAMP = 0x0001, // Clamp to frame edge pixels KOBO_CLAMP_OPAQUE = 0x0002, // Clamp to black instead of transparent KOBO_NOALPHA = 0x0004, // Disable alpha channel KOBO_NODITHER = 0x0008, // Disable dithering KOBO_NEAREST = 0x0010, // Force NEAREST scale mode KOBO_CENTER = 0x0020, // Center hotspot in frames KOBO_NOBRIGHT = 0x0040, // Disable brightness/contrast filter KOBO_FONT = 0x0080, // Load as "SFont" rather than tiles! KOBO_MESSAGE = 0x1000 // Not a file! 'path' is a message. } KOBO_GfxDescFlags; typedef struct KOBO_GfxDesc { const char *path; // Path + name (for filemapper) int bank; // Sprite bank ID int w, h; // Frame size (original image pixels) float scale; // Scale of source data rel. 320x240 int flags; // KOBO_GfxDescFlags } KOBO_GfxDesc; static KOBO_GfxDesc gfxdesc[] = { // Loading screen { "Loading loading screen graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>loading3.png", B_LOADING, 0, 0, 2.0f, KOBO_CLAMP | KOBO_NOALPHA }, { "GFX>>icefont2.png", B_NORMAL_FONT, 0, 0, 2.0f, KOBO_FONT }, // In-game { "Loading in-game graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>tiles-green.png", B_TILES1, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>tiles-metal.png", B_TILES2, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>tiles-blood.png", B_TILES3, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>tiles-double.png", B_TILES4, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>tiles-chrome.png", B_TILES5, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>flatstars1.png", B_OLDSTARS, 32, 32, 2.0f, KOBO_CLAMP }, { "GFX>>crosshair.png", B_CROSSHAIR, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>player.png", B_PLAYER, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bmr-green.png", B_BMR_GREEN, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bmr-purple.png", B_BMR_PURPLE, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bmr-pink.png", B_BMR_PINK, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>fighter.png", B_FIGHTER, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>missile.png", B_MISSILE1, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>missile2.png", B_MISSILE2, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>missile3.png", B_MISSILE3, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bolt.png", B_BOLT, 16, 16, 2.0f, KOBO_CENTER }, { "GFX>>boltexpl.png", B_BOLTEXPL, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>explo1e.png", B_EXPLO1, 48, 48, 2.0f, KOBO_CENTER }, { "GFX>>explo3e.png", B_EXPLO3, 64, 64, 2.0f, KOBO_CENTER }, { "GFX>>explo4e.png", B_EXPLO4, 64, 64, 2.0f, KOBO_CENTER }, { "GFX>>explo5e.png", B_EXPLO5, 64, 64, 2.0f, KOBO_CENTER }, { "GFX>>rock1c.png", B_ROCK1, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>rock2.png", B_ROCK2, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>shinyrock.png", B_ROCK3, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>rockexpl.png", B_ROCKEXPL, 64, 64, 2.0f, KOBO_CENTER }, { "GFX>>bullet5b.png", B_BULLETS, 16, 16, 2.0f, KOBO_CENTER }, { "GFX>>bulletexpl2.png", B_BULLETEXPL, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>ring.png", B_RING, 32, 32, 2.0f, KOBO_CENTER }, { "GFX>>ringexpl2b.png", B_RINGEXPL, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bomb.png", B_BOMB, 24, 24, 2.0f, KOBO_CENTER }, { "GFX>>bombdeto.png", B_BOMBDETO, 40, 40, 2.0f, KOBO_CENTER }, { "GFX>>bigship.png", B_BIGSHIP, 72, 72, 2.0f, KOBO_CENTER }, // Framework { "Loading framework graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>screen2.png", B_SCREEN, 0, 0, 2.0f, KOBO_CLAMP_OPAQUE }, // Logo { "Loading logo", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>logo-outline.png", B_LOGO, 0, 0, 2.0f, 0 }, { "GFX>>deluxe.png", B_LOGODELUXE, 0, 0, 2.0f, 0 }, { "GFX>>logomask3.png", B_LOGOMASK, 0, 0, 4.0f, KOBO_NEAREST | KOBO_NODITHER }, // Fonts { "Loading fonts", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>goldfont.png", B_MEDIUM_FONT, 0, 0, 2.0f, KOBO_FONT }, { "GFX>>bigfont3.png", B_BIG_FONT, 0, 0, 2.0f, KOBO_FONT }, { "GFX>>counterfont.png", B_COUNTER_FONT, 0, 0, 2.0f, KOBO_FONT }, // Special FX { "Loading special FX graphics", 0, 0,0, 0.0f, KOBO_MESSAGE }, { "GFX>>noise.png", B_NOISE, NOISE_SIZEX, 1, 1.0f, KOBO_CLAMP }, { "GFX>>hitnoise.png", B_HITNOISE, NOISE_SIZEX, 1, 1.0f, KOBO_CLAMP | KOBO_NEAREST }, { "GFX>>focusfx.png", B_FOCUSFX, 0, 0, 1.0f, KOBO_CLAMP }, { "GFX>>brushes.png", B_BRUSHES, 16, 16, 1.0f, KOBO_CLAMP | KOBO_NEAREST | KOBO_NOALPHA }, { NULL, 0, 0, 0, 0.0f, 0 } // Terminator }; int KOBO_main::load_graphics(prefs_t *p) { KOBO_GfxDesc *gd; gengine->reset_filters(); show_progress(p); for(gd = gfxdesc; gd->path; ++gd) { if(gd->flags & KOBO_MESSAGE) { doing(gd->path); continue; } // Set scale (filter) mode and clamping int clamping; gfx_scalemodes_t sm; if(gd->flags & KOBO_CLAMP) { gengine->clampcolor(0, 0, 0, 0); clamping = 1; } else if(gd->flags & KOBO_CLAMP_OPAQUE) { gengine->clampcolor(0, 0, 0, 255); clamping = 1; } else clamping = 0; if(gd->flags & KOBO_NEAREST) sm = GFX_SCALE_NEAREST; else sm = (gfx_scalemodes_t) p->scalemode; gengine->scalemode(sm, clamping); // Disable brightness filter? if(gd->flags & KOBO_NOBRIGHT) gengine->brightness(1.0f, 1.0f); else gengine->brightness(0.01f * p->brightness, 0.01f * p->contrast); // Dithering if(gd->flags & KOBO_NODITHER || !p->use_dither) gengine->dither(-1); else gengine->dither(p->dither_type, p->broken_rgba8); // Alpha channels if(gd->flags & KOBO_NOALPHA || !p->alpha) gengine->noalpha(NOALPHA_THRESHOLD); else gengine->noalpha(0); // Source image scale gengine->source_scale(gd->scale, gd->scale); // Load! const char *fn = fmap->get(gd->path); if(!fn) { log_printf(ELOG, "Couldn't get path to \"%s\"!\n", gd->path); return -1; } int res; if(gd->flags & KOBO_FONT) res = gengine->loadfont(gd->bank, fn); else if(!gd->w || !gd->h) res = gengine->loadimage(gd->bank, fn); else res = gengine->loadtiles(gd->bank, gd->w, gd->h, fn); if(res < 0) { log_printf(ELOG, "Couldn't load \"%s\"!\n", fn); return -1; } // Hotspot if(gd->flags & KOBO_CENTER) gengine->set_hotspot(gd->bank, -1, (int)(gd->w / gd->scale / 2), (int)(gd->h / gd->scale / 2)); // Update progress bar progress(); } // Chop up the dashboard graphics as needed SDL_Rect r; r.w = r.h = 16; r.x = (8 + MARGIN); r.y = MARGIN; if(gengine->copyrect(B_FRAME_TL, B_SCREEN, 0, &r) < 0) return -6; progress(); r.x += WSIZE - 16; if(gengine->copyrect(B_FRAME_TR, B_SCREEN, 0, &r) < 0) return -7; progress(); r.x = (8 + MARGIN); r.y = MARGIN + WSIZE - 16; if(gengine->copyrect(B_FRAME_BL, B_SCREEN, 0, &r) < 0) return -8; progress(); r.x += WSIZE - 16; if(gengine->copyrect(B_FRAME_BR, B_SCREEN, 0, &r) < 0) return -9; progress(); r.x = 252; r.y = 4; r.w = 64; r.h = 18; if(gengine->copyrect(B_HIGH_BACK, B_SCREEN, 0, &r) < 0) return -26; progress(); r.y += 18 + 4; if(gengine->copyrect(B_SCORE_BACK, B_SCREEN, 0, &r) < 0) return -27; progress(); r.x = 244; r.y = (SCREEN_HEIGHT - MAP_SIZEY) / 2; r.w = MAP_SIZEX; r.h = MAP_SIZEY; if(gengine->copyrect(B_RADAR_BACK, B_SCREEN, 0, &r) < 0) return -28; progress(); r.x = 264; r.y = 196; r.w = 38; r.h = 18; if(gengine->copyrect(B_SHIPS_BACK, B_SCREEN, 0, &r) < 0) return -29; progress(); r.y += 18 + 4; if(gengine->copyrect(B_STAGE_BACK, B_SCREEN, 0, &r) < 0) return -30; progress(); r.x = 4; r.y = 92; r.w = 8; r.h = 128; if(gengine->copyrect(B_HEALTH_LID, B_SCREEN, 0, &r) < 0) return -31; progress(); r.x = 244; r.y = 188; r.w = 4; r.h = 32; if(gengine->copyrect(B_TEMP_LID, B_SCREEN, 0, &r) < 0) return -32; progress(); r.x += 4; if(gengine->copyrect(B_TTEMP_LID, B_SCREEN, 0, &r) < 0) return -33; progress(); // Prepare the logo region s_sprite_t *s = gengine->get_sprite(B_LOGOMASK, 0); if(!s || !s->surface) return -10; RGN_FreeRegion(logo_region); logo_region = RGN_ScanMask(s->surface, SDL_MapRGB(s->surface->format, 255, 255, 255)); if(!logo_region) { log_printf(ELOG, "Could not create logo region!\n"); return -92; } progress(); return 0; } static int progress_cb(const char *msg) { if(msg) km.doing(msg); km.progress(); if(km.quit_requested()) return -999; return 0; } int KOBO_main::load_sounds(prefs_t *p, int render_all) { if(!p->use_sound) return 0; show_progress(p); return sound.load(progress_cb, render_all); } int KOBO_main::init_js(prefs_t *p) { /* Activate Joystick sub-sys if we are using it */ if(p->use_joystick) { if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) < 0) { log_printf(ELOG, "Error setting up joystick!\n"); return -1; } p->number_of_joysticks = SDL_NumJoysticks(); if(p->number_of_joysticks > 0) { SDL_JoystickEventState(SDL_ENABLE); if(p->joystick_no >= p->number_of_joysticks) p->joystick_no = 0; joystick = SDL_JoystickOpen(p->joystick_no); if(!joystick) { SDL_QuitSubSystem(SDL_INIT_JOYSTICK); return -2; } } else { log_printf(ELOG, "No joysticks found!\n"); joystick = NULL; return -3; } } return 0; } void KOBO_main::close_js() { if(!SDL_WasInit(SDL_INIT_JOYSTICK)) return; if(!joystick) return; if(SDL_JoystickOpened(0)) SDL_JoystickClose(joystick); joystick = NULL; SDL_QuitSubSystem(SDL_INIT_JOYSTICK); } void KOBO_main::load_config(prefs_t *p) { FILE *f = fmap->fopen(KOBO_CONFIG_DIR "/" KOBO_CONFIG_FILE, "r"); if(f) { p->read(f); fclose(f); } } void KOBO_main::save_config(prefs_t *p) { FILE *f; #if defined(HAVE_GETEGID) && defined(HAVE_SETGID) gid_t oldgid = getegid(); if(setgid(getgid()) != 0) { log_printf(ELOG, "Cannot save config! (%s)\n", strerror(errno)); return; } #endif f = fmap->fopen(KOBO_CONFIG_DIR "/" KOBO_CONFIG_FILE, "w"); if(f) { p->write(f); fclose(f); } #if defined(HAVE_GETEGID) && defined(HAVE_SETGID) if(setgid(oldgid) != 0) { log_printf(ELOG, "Cannot restore GID! (%s)\n", strerror(errno)); return; } #endif } void KOBO_main::brutal_quit() { if(exit_game_fast) { log_printf(ULOG, "Second try quitting; using brutal method!\n"); atexit(SDL_Quit); close_logging(); exit(1); } exit_game_fast = 1; if(gengine) gengine->stop(); } void KOBO_main::pause_game() { if(gsm.current() != &st_pause_game) gsm.press(BTN_PAUSE); } void kobo_render_highlight(ct_widget_t *wg) { screen.set_highlight(wg->y() + wg->height() / 2 - wmain->y(), wg->height()); } int KOBO_main::open() { if(init_display(prefs) < 0) return -1; #ifdef TIME_PROGRESS wdash->progress_init(NULL); #else wdash->progress_init(progtab_all); #endif if(load_graphics(prefs) < 0) return -2; #ifdef TIME_PROGRESS // Use these two lines to time graphics and sounds separately! wdash->progress_done(); wdash->progress_init(NULL); #endif sound.open(); if(load_sounds(prefs) < 0) return -3; wdash->progress_done(); wdash->nibble(); ct_engine.render_highlight = kobo_render_highlight; wdash->mode(DASHBOARD_GAME); wradar->mode(RM_NOISE); pubrand.init(); init_js(prefs); gamecontrol.init(prefs->always_fire); manage.init(); gsm.push(&st_intro_title); return 0; } void KOBO_main::close() { close_js(); RGN_FreeRegion(logo_region); logo_region = NULL; close_display(); if(gengine) { delete gengine; gengine = NULL; } sound.close(); SDL_Quit(); } int KOBO_main::run() { int retry_status = 0; int dont_retry = 0; while(1) { if(!retry_status) { safe_prefs = *prefs; gengine->run(); if(!manage.game_stopped()) manage.abort(); if(exit_game_fast) break; if(exit_game) { if(wdash) wdash->nibble(); break; } dont_retry = 0; } retry_status = 0; if(global_status & OS_RESTART_AUDIO) { if(prefs->use_sound) { log_printf(ULOG, "--- Restarting audio...\n"); sound.stop(); #ifdef TIME_PROGRESS wdash->progress_init(NULL); #else wdash->progress_init(progtab_sounds); #endif if(load_sounds(prefs) < 0) return 5; wdash->progress_done(); sound.open(); wdash->nibble(); log_printf(ULOG, "--- Audio restarted.\n"); wdash->mode(DASHBOARD_GAME); wradar->mode(screen.radar_mode); manage.set_bars(); } else { log_printf(ULOG, "--- Stopping audio...\n"); sound.close(); log_printf(ULOG, "--- Audio stopped.\n"); } } if((global_status & OS_RELOAD_AUDIO_CACHE) && prefs->cached_sounds) { log_printf(ULOG, "--- Rendering sounds to disk...\n"); #ifdef TIME_PROGRESS wdash->progress_init(NULL); #else wdash->progress_init(progtab_sounds); #endif if(load_sounds(prefs) < 0) { log_printf(ELOG, "--- Could not render sounds to disk!\n"); st_error.message("Could not render to disk!", "Please, check your installation."); gsm.push(&st_error); } wdash->progress_done(); wdash->mode(DASHBOARD_GAME); wradar->mode(screen.radar_mode); manage.set_bars(); } if(global_status & OS_RESTART_VIDEO) { log_printf(ULOG, "--- Restarting video...\n"); wdash->nibble(); gengine->hide(); close_display(); gengine->unload(); if(init_display(prefs) < 0) { log_printf(ELOG, "--- Video init failed!\n"); st_error.message("Video initialization failed!", "Try different settings."); gsm.push(&st_error); if(dont_retry) return 6; *prefs = safe_prefs; dont_retry = 1; retry_status |= OS_RESTART_VIDEO; } else { gamecontrol.init(prefs->always_fire); log_printf(ULOG, "--- Video restarted.\n"); } } if(global_status & (OS_RELOAD_GRAPHICS | OS_RESTART_VIDEO)) { if(!(global_status & OS_RESTART_VIDEO)) wdash->nibble(); gengine->unload(); RGN_FreeRegion(logo_region); logo_region = NULL; if(!retry_status) { log_printf(ULOG, "--- Reloading graphics...\n"); #ifdef TIME_PROGRESS wdash->progress_init(NULL); #else wdash->progress_init(progtab_graphics); #endif if(load_graphics(prefs) < 0) return 7; wdash->progress_done(); wdash->nibble(); wdash->mode(DASHBOARD_GAME); wradar->mode(screen.radar_mode); manage.set_bars(); log_printf(ULOG, "--- Graphics reloaded.\n"); } } if(global_status & OS_RESTART_ENGINE) log_printf(ELOG, "OS_RESTART_ENGINE not implemented!\n"); if(global_status & OS_RESTART_INPUT) { close_js(); init_js(prefs); gamecontrol.init(prefs->always_fire); } if(global_status & OS_RESTART_LOGGER) open_logging(prefs); global_status = retry_status; km.pause_game(); manage.reenter(); } return 0; } /*---------------------------------------------------------- Kobo Graphics Engine ----------------------------------------------------------*/ kobo_gfxengine_t::kobo_gfxengine_t() { } void kobo_gfxengine_t::frame() { sound.frame(); if(!gsm.current()) { log_printf(CELOG, "INTERNAL ERROR: No gamestate!\n"); exit_game = 1; stop(); return; } if(exit_game || manage.aborted()) { stop(); return; } /* * Process input */ SDL_Event ev; while(SDL_PollEvent(&ev)) { int k, ms; switch (ev.type) { case SDL_KEYDOWN: switch(ev.key.keysym.sym) { #ifdef PROFILE_AUDIO case SDLK_F10: ++km.audio_vismode; break; case SDLK_F12: audio_print_info(); break; case SDLK_r: { audio_channel_stop(-1, -1); int startt = SDL_GetTicks(); audio_wave_load(0, "sfx.agw", 0); log_printf(VLOG, "(Loading + processing time: %d ms)\n", SDL_GetTicks() - startt); break; } #endif case SDLK_DELETE: if(prefs->cmd_debug) { manage.ships = 1; myship.hit(1000); } break; case SDLK_RETURN: ms = SDL_GetModState(); if(ms & (KMOD_CTRL | KMOD_SHIFT | KMOD_META)) break; if(!(ms & KMOD_ALT)) break; km.pause_game(); prefs->fullscreen = !prefs->fullscreen; prefs->changed = 1; global_status |= OS_RELOAD_GRAPHICS | OS_RESTART_VIDEO; stop(); return; case SDLK_PRINT: case SDLK_SYSREQ: // FIXME: Doesn't this trigger when entering names and stuff...? case SDLK_s: gengine->screenshot(); break; default: break; } k = gamecontrol.map(ev.key.keysym.sym); gamecontrol.press(k); gsm.press(k, ev.key.keysym.unicode); break; case SDL_KEYUP: if((ev.key.keysym.sym == SDLK_ESCAPE) && km.escape_hammering()) { km.pause_game(); prefs->fullscreen = 0; prefs->videodriver = (int)GFX_DRIVER_SDL2D; prefs->width = 640; prefs->height = 480; prefs->aspect = 1000; prefs->depth = 0; prefs->doublebuf = 0; prefs->pages = -1; prefs->shadow = 1; prefs->scalemode = (int)GFX_SCALE_NEAREST; prefs->brightness = 100; prefs->contrast = 100; global_status |= OS_RELOAD_GRAPHICS | OS_RESTART_VIDEO; stop(); st_error.message("Safe video settings applied!", "Enter Options menu to save."); gsm.push(&st_error); return; } k = gamecontrol.map(ev.key.keysym.sym); if(k == SDLK_PAUSE) { gamecontrol.press(BTN_PAUSE); gsm.press(BTN_PAUSE); } else { gamecontrol.release(k); gsm.release(k); } break; case SDL_VIDEOEXPOSE: gengine->invalidate(); break; case SDL_ACTIVEEVENT: // Any type of focus loss should activate pause mode! if(!ev.active.gain) km.pause_game(); break; case SDL_QUIT: /*gsm.press(BTN_CLOSE);*/ km.brutal_quit(); break; case SDL_JOYBUTTONDOWN: if(ev.jbutton.button == km.js_fire) { gamecontrol.press(BTN_FIRE); gsm.press(BTN_FIRE); } else if(ev.jbutton.button == km.js_start) { gamecontrol.press(BTN_START); gsm.press(BTN_START); } break; case SDL_JOYBUTTONUP: if(ev.jbutton.button == km.js_fire) { gamecontrol.release(BTN_FIRE); gsm.release(BTN_FIRE); } break; case SDL_JOYAXISMOTION: // FIXME: We will want to allow these to be // redefined, but for now, this works ;-) if(ev.jaxis.axis == km.js_lr) { if(ev.jaxis.value < -3200) { gamecontrol.press(BTN_LEFT); gsm.press(BTN_LEFT); } else if(ev.jaxis.value > 3200) { gamecontrol.press(BTN_RIGHT); gsm.press(BTN_RIGHT); } else { gamecontrol.release(BTN_LEFT); gamecontrol.release(BTN_RIGHT); gsm.release(BTN_LEFT); gsm.release(BTN_RIGHT); } } else if(ev.jaxis.axis == km.js_ud) { if(ev.jaxis.value < -3200) { gamecontrol.press(BTN_UP); gsm.press(BTN_UP); } else if(ev.jaxis.value > 3200) { gamecontrol.press(BTN_DOWN); gsm.press(BTN_DOWN); } else { gamecontrol.release(BTN_UP); gamecontrol.release(BTN_DOWN); gsm.release(BTN_UP); gsm.release(BTN_DOWN); } } case SDL_MOUSEMOTION: mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; if(prefs->use_mouse) gamecontrol.mouse_position( mouse_x - 8 - MARGIN - WSIZE/2, mouse_y - MARGIN - WSIZE/2); break; case SDL_MOUSEBUTTONDOWN: mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; gsm.press(BTN_FIRE); if(prefs->use_mouse) { gamecontrol.mouse_position( mouse_x - 8 - MARGIN - WSIZE/2, mouse_y - MARGIN - WSIZE/2); switch(ev.button.button) { case SDL_BUTTON_LEFT: mouse_left = 1; break; case SDL_BUTTON_MIDDLE: mouse_middle = 1; break; case SDL_BUTTON_RIGHT: mouse_right = 1; break; } gamecontrol.press(BTN_FIRE); } break; case SDL_MOUSEBUTTONUP: mouse_x = (int)(ev.motion.x / gengine->xscale()) - km.xoffs; mouse_y = (int)(ev.motion.y / gengine->yscale()) - km.yoffs; if(prefs->use_mouse) { gamecontrol.mouse_position( mouse_x - 8 - MARGIN - WSIZE/2, mouse_y - MARGIN - WSIZE/2); switch(ev.button.button) { case SDL_BUTTON_LEFT: mouse_left = 0; break; case SDL_BUTTON_MIDDLE: mouse_middle = 0; break; case SDL_BUTTON_RIGHT: mouse_right = 0; break; } } if(!mouse_left && !mouse_middle && !mouse_right) { if(prefs->use_mouse) gamecontrol.release(BTN_FIRE); gsm.release(BTN_FIRE); } break; } } gamecontrol.process(); /* * Run the current gamestate for one frame */ gsm.frame(); if(prefs->cmd_autoshot && !manage.game_stopped()) { static int c = 0; ++c; if(c >= 3) { gengine->screenshot(); c = 0; } } } void kobo_gfxengine_t::pre_render() { sound.run(); gsm.pre_render(); } void kobo_gfxengine_t::post_render() { gsm.post_render(); if(!prefs->cmd_noframe) { wmain->sprite(0, 0, B_FRAME_TL, 0, 0); wmain->sprite(WSIZE - 16, 0, B_FRAME_TR, 0, 0); wmain->sprite(0, WSIZE - 16, B_FRAME_BL, 0, 0); wmain->sprite(WSIZE - 16, WSIZE - 16, B_FRAME_BR, 0, 0); } #ifdef DEBUG if(prefs->cmd_debug) { char buf[20]; snprintf(buf, sizeof(buf), "Obj: %d", gengine->objects_in_use()); wmain->font(B_NORMAL_FONT); wmain->string(160, 5, buf); } switch (km.audio_vismode % 5) { case 0: break; case 1: draw_osc(0); break; case 2: draw_vu(); break; case 3: draw_osc(1); break; case 4: draw_osc(2); break; } #endif // Frame rate counter int nt = (int)SDL_GetTicks(); int tt = nt - km.fps_starttime; if((tt > 1000) && km.fps_count) { float f = km.fps_count * 1000.0 / tt; ::screen.fps(f); km.fps_count = 0; km.fps_starttime = nt; if(prefs->cmd_fps) { char buf[20]; snprintf(buf, sizeof(buf), "%.1f", f); km.dfps->text(buf); if(!km.fps_results) km.fps_results = (float *) calloc(MAX_FPS_RESULTS, sizeof(float)); if(km.fps_results) { km.fps_results[km.fps_nextresult++] = f; if(km.fps_nextresult >= MAX_FPS_RESULTS) km.fps_nextresult = 0; if(km.fps_nextresult > km.fps_lastresult) km.fps_lastresult = km.fps_nextresult; } } } ++km.fps_count; // Frame rate limiter if(prefs->max_fps) { if(prefs->max_fps_strict) { static double nextframe = -1000000.0f; while(1) { double t = (double)SDL_GetTicks(); if(fabs(nextframe - t) > 1000.0f) nextframe = t; double d = nextframe - t; if(d > 10.0f) SDL_Delay(10); else if(d > 1.0f) SDL_Delay(1); else break; } nextframe += 1000.0f / prefs->max_fps; } else { int rtime = nt - km.max_fps_begin; km.max_fps_begin = nt; km.max_fps_filter += (float)(rtime - km.max_fps_filter) * 0.3; int delay = (int)(1000.0 / prefs->max_fps - km.max_fps_filter + 0.5); if((delay > 0) && (delay < 1100)) SDL_Delay(delay); km.max_fps_begin = (int)SDL_GetTicks(); } } } /*---------------------------------------------------------- main() and related stuff ----------------------------------------------------------*/ static void put_usage() { printf("\nKobo Deluxe %s\n", KOBO_VERSION); printf("Usage: kobodl []\n"); printf("Recognized options:\n"); int s = -1; while(1) { const char *fs; s = prefs->find_next(s); if(s < 0) break; switch(prefs->type(s)) { case CFG_BOOL: fs = " -[no]%-16.16s[%s]\t%s%s\n"; break; case CFG_INT: case CFG_FLOAT: fs = " -%-20.20s[%s]\t%s%s\n"; break; case CFG_STRING: fs = " -%-20.20s[\"%s\"]\t%s%s\n"; break; default: continue; } printf(fs, prefs->name(s), prefs->get_default_s(s), prefs->do_save(s) ? "" : "(Not saved!) ", prefs->description(s)); } } static void put_options_man() { int s = -1; while(1) { const char *fs; s = prefs->find_next(s); if(s < 0) break; switch(prefs->type(s)) { case CFG_BOOL: fs = ".TP\n.B \\-[no]%s\n%s%s. Default: %s.\n"; break; case CFG_INT: case CFG_FLOAT: fs = ".TP\n.B \\-%s\n%s%s. Default: %s.\n"; break; case CFG_STRING: fs = ".TP\n.B \\-%s\n%s%s. Default: \"%s\"\n"; break; default: continue; } printf(fs, prefs->name(s), prefs->do_save(s) ? "" : "(Not saved!) ", prefs->description(s), prefs->get_default_s(s)); } } extern "C" void emergency_close(void) { km.close(); } extern "C" RETSIGTYPE breakhandler(int dummy) { /* For platforms that drop the handlers on the first signal... */ signal(SIGTERM, breakhandler); signal(SIGINT, breakhandler); km.brutal_quit(); #if (RETSIGTYPE != void) return 0; #endif } int main(int argc, char *argv[]) { int cmd_exit = 0; atexit(emergency_close); signal(SIGTERM, breakhandler); signal(SIGINT, breakhandler); SDL_Init(0); if(main_init()) { fprintf(stderr, "INTERNAL ERROR\n"); return 1; }; km.open_logging(NULL); setup_dirs(argv[0]); --argc; ++argv; if((argc < 1) || (strcmp("-override", argv[0]) != 0)) km.load_config(prefs); if((prefs->parse(argc, argv) < 0) || prefs->cmd_help) { put_usage(); main_cleanup(); return 1; } if(prefs->cmd_options_man) { put_options_man(); main_cleanup(); return 1; } if(prefs->cmd_noparachute) { SDL_Quit(); SDL_Init(SDL_INIT_NOPARACHUTE); } km.open_logging(prefs); for(int a = 0; a < argc; ++a) log_printf(DLOG, "argv[%d] = \"%s\"\n", a, argv[a]); int k = -1; while((k = prefs->find_next(k)) >= 0) { log_printf(D3LOG, "key %d: \"%s\"\ttype=%d\t\"%s\"\n", k, prefs->name(k), prefs->type(k), prefs->description(k) ); } add_dirs(prefs); if(prefs->cmd_hiscores) { scorefile.gather_high_scores(); scorefile.print_high_scores(); cmd_exit = 1; } if(prefs->cmd_showcfg) { printf("Configuration:\n"); printf("----------------------------------------\n"); prefs->write(stdout); printf("\nPaths:\n"); printf("----------------------------------------\n"); fmap->print(stdout, "*"); printf("----------------------------------------\n"); cmd_exit = 1; } if(cmd_exit) { km.close_logging(); main_cleanup(); return 0; } if(km.open() < 0) { km.close_logging(); main_cleanup(); return 1; } km.run(); km.close(); /* * Seems like we got all the way here without crashing, * so let's save the current configuration! :-) */ if(prefs->changed) { km.save_config(prefs); prefs->changed = 0; } if(prefs->cmd_fps) km.print_fps_results(); km.close_logging(); main_cleanup(); return 0; } KoboDeluxe-0.5.1/logger.c0000644000175000001440000002403310711350173012116 00000000000000/*(LGPL) --------------------------------------------------------------------------- logger.c - Simple logger with redirection --------------------------------------------------------------------------- * Copyright (C) 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "config.h" #include "logger.h" #include "glSDL.h" #define LOG_BUFFER 1024 static int i__last; #define for_one_or_all(iterator, index, items) \ if(index < LOG_TARGETS) \ { \ if(index >= 0) \ iterator = i__last = index; \ else \ { \ iterator = 0; \ i__last = items - 1; \ } \ } \ else \ { \ iterator = 0; \ i__last = -10; \ } \ --iterator; \ while(++iterator <= i__last) typedef struct { /* Stream output */ int use_stream; FILE *stream; /* Callback output */ int handle; int (*callback)(int handle, const char *data); /* Formatting control */ unsigned flags; int written; } LOG_target; typedef struct { /* Output */ int target; /* Atributes */ unsigned attr; } LOG_level; static LOG_level *l_levels = NULL; static LOG_target *l_targets = NULL; static char *l_buffer = NULL; Uint32 start_time; /*-------------------------------------------------------------------- Low level internal stuff --------------------------------------------------------------------*/ /* Write stuff without any translation */ static inline int log_write_raw(int target, const char *text) { if(l_targets[target].use_stream) return fputs(text, l_targets[target].stream); else if(l_targets[target].callback) return l_targets[target].callback( l_targets[target].handle, text); else { /* We should never get here. */ assert(0); } } /* Write log file header if applicable. */ static inline void check_header(int target) { if(l_targets[target].written) return; if(l_targets[target].flags & LOG_HTML) { log_write_raw(target, "\n"); log_write_raw(target, "\n\t\n"); log_write_raw(target, "\t\tLog File\n"); log_write_raw(target, "\t\t\n"); log_write_raw(target, "\t\n"); log_write_raw(target, "\t\n"); } l_targets[target].written = 1; } /* Write log file footer if applicable. */ static inline void check_footer(int target) { if(!l_targets[target].written) return; if(l_targets[target].flags & LOG_HTML) log_write_raw(target, "\t\n\n"); } /* Write converting/escaping any reserved characters as needed */ static inline int log_write(int target, const char *text) { int i; if(l_targets[target].flags & LOG_HTML) { /* FIXME: Optimize this a little, maybe. :-) */ char buf[2] = "\0\0"; int last = -1; for(i = 0; text[i]; ++i) { buf[0] = text[i]; switch(text[i]) { case '\n': log_write_raw(target, "
\n"); break; case ' ': if(' ' == last) log_write_raw(target, " "); else log_write_raw(target, " "); break; case '<': log_write_raw(target, "<"); break; case '>': log_write_raw(target, ">"); break; case '&': log_write_raw(target, "&"); break; default: log_write_raw(target, buf); break; } last = text[i]; } return i; } else return log_write_raw(target, text); } static inline void put_timestamp(int level) { if(l_targets[l_levels[level].target].flags & LOG_TIMESTAMP) { char buf[16]; snprintf(buf, sizeof(buf)-1, "[%d] ", SDL_GetTicks() - start_time); log_write_raw(l_levels[level].target, buf); } } #define ANSI_SUPPORTED_FLAGS (LOG_COLORS | LOG_BRIGHT | LOG_STRONG | LOG_BLINK) #define HTML_SUPPORTED_FLAGS (LOG_COLORS | LOG_BRIGHT | LOG_STRONG | LOG_BLINK) static inline void set_attr(int level) { unsigned a = l_levels[level].attr; if(l_targets[l_levels[level].target].flags & LOG_ANSI) { #define SEP if('[' != buf[pos - 1]) buf[pos++] = ';' int pos = 0; char buf[24]; if(!(a & ANSI_SUPPORTED_FLAGS)) return; buf[pos++] = '\033'; buf[pos++] = '['; if(a & LOG_COLORS) { buf[pos++] = '3'; buf[pos++] = '0' + (a & LOG_COLORS) - 1; } if(a & LOG_BRIGHT) { SEP; buf[pos++] = '1'; } if(a & LOG_STRONG) { SEP; buf[pos++] = '4'; } if(a & LOG_BLINK) { SEP; buf[pos++] = '5'; } buf[pos++] = 'm'; buf[pos++] = '\0'; log_write_raw(l_levels[level].target, buf); #undef SEP } else if(l_targets[l_levels[level].target].flags & LOG_HTML) { if(a & LOG_COLORS) { const char *sel; if(a & LOG_BRIGHT) switch( (a & LOG_COLORS) - 1) { case 0: sel = ""; break; case 1: sel = ""; break; case 2: sel = ""; break; case 3: sel = ""; break; case 4: sel = ""; break; case 5: sel = ""; break; case 6: sel = ""; break; case 7: default: sel = ""; break; } else switch( (a & LOG_COLORS) - 1) { case 0: sel = ""; break; case 1: sel = ""; break; case 2: sel = ""; break; case 3: sel = ""; break; case 4: sel = ""; break; case 5: sel = ""; break; case 6: sel = ""; break; case 7: default: sel = ""; break; } log_write_raw(l_levels[level].target, sel); } if(a & LOG_STRONG) log_write_raw(l_levels[level].target, ""); if(a & LOG_BLINK) log_write_raw(l_levels[level].target, ""); } } static inline void reset_attr(int level) { unsigned a = l_levels[level].attr; if(l_targets[l_levels[level].target].flags & LOG_ANSI) { if(!(a & ANSI_SUPPORTED_FLAGS)) return; log_write_raw(l_levels[level].target, "\033[0m"); } else if(l_targets[l_levels[level].target].flags & LOG_HTML) { if(a & LOG_BLINK) log_write_raw(l_levels[level].target, ""); if(a & LOG_STRONG) log_write_raw(l_levels[level].target, ""); if(a & LOG_COLORS) log_write_raw(l_levels[level].target, ""); } } static inline int is_active(int level) { LOG_target *t = &l_targets[l_levels[level].target]; return (t->use_stream || t->callback); } /*-------------------------------------------------------------------- API entry points --------------------------------------------------------------------*/ int log_open(void) { if(l_levels) return 0; l_levels = calloc(LOG_LEVELS, sizeof(LOG_level)); if(!l_levels) return -1; l_targets = calloc(LOG_TARGETS, sizeof(LOG_target)); if(!l_targets) { log_close(); return -2; } l_buffer = calloc(1, LOG_BUFFER); if(!l_buffer) { log_close(); return -3; } log_set_target_stream(-1, stdout); log_set_target_flags(-1, 0); log_set_level_target(-1, 0); log_set_level_attr(-1, LOG_NOCOLOR); start_time = SDL_GetTicks(); return 0; } #define CHECK_INIT (l_levels ? 0 : -1) void log_close(void) { int i; if(CHECK_INIT < 0) return; for(i = 0; i < LOG_TARGETS; ++i) check_footer(i); free(l_targets); l_targets = NULL; free(l_levels); l_levels = NULL; free(l_buffer); l_buffer = NULL; } void log_set_target_stream(int target, FILE *stream) { int i; if(CHECK_INIT < 0) return; for_one_or_all(i, target, LOG_TARGETS) { l_targets[i].callback = NULL; l_targets[i].stream = stream; l_targets[i].use_stream = (stream != NULL); } } void log_set_target_callback(int target, int (*callback)(int handle, const char *data), int handle) { int i; if(CHECK_INIT < 0) return; for_one_or_all(i, target, LOG_TARGETS) { l_targets[i].use_stream = 0; l_targets[i].callback = callback; l_targets[i].handle = handle; } } void log_set_target_flags(int target, unsigned flags) { int i; if(CHECK_INIT < 0) return; for_one_or_all(i, target, LOG_TARGETS) l_targets[i].flags = flags; } void log_set_level_target(int level, int target) { int i; if(CHECK_INIT < 0) return; for_one_or_all(i, level, LOG_LEVELS) l_levels[i].target = target; } void log_set_level_attr(int level, unsigned attr) { int i; if(CHECK_INIT < 0) return; for_one_or_all(i, level, LOG_LEVELS) l_levels[i].attr = attr; } int log_puts(int level, const char *text) { int result, result2; if(CHECK_INIT < 0) return -1; if(level < 0 || level >= LOG_LEVELS) return -2; if(!is_active(level)) return 0; check_header(l_levels[level].target); set_attr(level); put_timestamp(level); result = log_write(l_levels[level].target, text); if(result >= 0) { result2 = log_write_raw(l_levels[level].target, "\n"); if(result2 >= 0) result += result2; } reset_attr(level); return result; } int log_printf(int level, const char *format, ...) { va_list args; int result; if(CHECK_INIT < 0) return -1; if(level < 0 || level >= LOG_LEVELS) return -2; if(!is_active(level)) return 0; check_header(l_levels[level].target); set_attr(level); put_timestamp(level); va_start(args, format); result = vsnprintf(l_buffer, LOG_BUFFER-1, format, args); va_end(args); if(result >= 0) result = log_write(l_levels[level].target, l_buffer); reset_attr(level); return result; } KoboDeluxe-0.5.1/dashboard.cpp0000644000175000001440000001751710733150014013133 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include "kobo.h" #include "random.h" #include #include #define MAX_PROGRESS 1000 /*---------------------------------------------------------- Screen ----------------------------------------------------------*/ void screen_window_t::border(int top, int left, int right, int bottom) { _top = top; _left = left; _right = right; _bottom = bottom; } void screen_window_t::refresh(SDL_Rect *r) { int x, y, w, h; foreground(map_rgb(0x000000)); x = 0; y = 0; w = width(); h = _top; fillrect(x, y, w, h); y = height() - _bottom; h = _bottom; fillrect(x, y, w, h); y = _top; w = _left; h = height() - _top - _bottom; fillrect(x, y, w, h); x = width() - _right; w = _right; fillrect(x, y, w, h); } /*---------------------------------------------------------- Dashboard ----------------------------------------------------------*/ dashboard_window_t::dashboard_window_t() { _mode = DASHBOARD_BLACK; _percent = 0.0f; _msg = NULL; } dashboard_window_t::~dashboard_window_t() { free(_msg); } void dashboard_window_t::mode(dashboard_modes_t m) { int vis; _mode = m; switch(_mode) { case DASHBOARD_GAME: vis = 1; break; default: vis = 0; break; } wmain->visible(vis); whealth->visible(vis); wtemp->visible(vis); wttemp->visible(vis); wradar->visible(vis); dhigh->visible(vis); dscore->visible(vis); dstage->visible(vis); dships->visible(vis); switch(_mode) { case DASHBOARD_OFF: break; default: gengine->invalidate(); gengine->flip(); gengine->invalidate(); gengine->flip(); gengine->invalidate(); break; } } void dashboard_window_t::doing(const char *msg) { free(_msg); _msg = strdup(msg); invalidate(); gengine->flip(); } void dashboard_window_t::progress_init(float *progtab) { if(!progtab) { progress_table = (float *)malloc(MAX_PROGRESS * sizeof(float)); progress_bench = (progress_table != NULL); } else { progress_table = progtab; progress_bench = 0; } progress_index = 0; } void dashboard_window_t::progress() { if(progress_table) { if(progress_bench) { progress_table[progress_index++] = (float)SDL_GetTicks(); _percent = 0.0f; } else _percent = progress_table[progress_index++]; } else _percent = 50.0f; invalidate(); gengine->flip(); } void dashboard_window_t::progress_done() { if(progress_bench) { int i; int total = SDL_GetTicks() - (int)progress_table[0]; printf("Progress percentages:\n"); printf("---------------------\n"); for(i = 0; i < progress_index; ++i) printf("\t%f,\n", (progress_table[i] - progress_table[0]) * 100.0f / total); printf("---------------------\n"); free(progress_table); progress_bench = 0; } progress_table = NULL; } void dashboard_window_t::render_progress() { SDL_Rect r; int x, y, w, h; x = 0; w = (int)(_percent * 0.01f * width() + 0.5f); if(w < 4) w = 4; else if(w > width()) w = width(); h = 16; y = height() - h; r.x = x; r.y = y; r.w = w; r.h = h; foreground(map_rgb(0x000099)); rectangle(x, y, w, h); ++x; ++y; w -= 2; h -= 2; foreground(map_rgb(0x0000cc)); rectangle(x, y, w, h); ++x; ++y; w -= 2; h -= 2; foreground(map_rgb(0x0000ff)); fillrect(x, y, w, h); r.x = 0; r.y = height() - 40; r.w = width(); r.h = 12; foreground(map_rgb(0x000000)); fillrect(r.x, r.y, r.w, r.h); if(_msg) { font(B_NORMAL_FONT); center(height() - 40, _msg); } } #define NIBBLE_W 4 #define NIBBLE_H 4 #define NIBBLE_TILES ((SCREEN_WIDTH/NIBBLE_W+1)*(SCREEN_HEIGHT/NIBBLE_H+1)) void dashboard_window_t::nibble(int tool) { int i; int x[NIBBLE_TILES]; int y[NIBBLE_TILES]; mode(DASHBOARD_OFF); if(tool < 0) tool = (pubrand.get(20) + SDL_GetTicks()) % 5; /* Clear */ for(i = 0; i < NIBBLE_TILES; ++i) x[i] = y[i] = -1; /* Fill in */ int ind = 0; int xx = -NIBBLE_W / 2; int yy = -NIBBLE_H / 2; for(i = 0; i < NIBBLE_TILES; ++i) { ind = pubrand.get() % NIBBLE_TILES; if(ind >= NIBBLE_TILES) ind = 0; while(x[ind] != -1) if(++ind >= NIBBLE_TILES) ind = 0; x[ind] = xx; y[ind] = yy; xx += NIBBLE_W; if(xx >= SCREEN_WIDTH + NIBBLE_W / 2) { xx = -NIBBLE_W / 2; yy += NIBBLE_H; } } /* Clear 8000 tiles/second, until all are done. */ foreground(map_rgb(0x000000)); ind = 0; int last_index; int t = SDL_GetTicks(); while(ind < NIBBLE_TILES) { int nt = SDL_GetTicks(); int dt = nt - t; t = nt; last_index = ind; /* For double buffer mode */ for(i = 0; i < dt * 8; ++i) { if(ind >= NIBBLE_TILES) break; switch (tool) { case 0: fillrect(x[ind] + NIBBLE_W / 2, y[ind] + NIBBLE_H / 2, NIBBLE_W, NIBBLE_H); break; default: sprite(x[ind] - 8 + NIBBLE_W / 2, y[ind] - 8 + NIBBLE_H / 2, B_BRUSHES, tool - 1); break; } ++ind; } gengine->invalidate(); gengine->flip(); if(gengine->doublebuffer()) { for(i = 0; i < dt * 4; ++i) { if(last_index >= NIBBLE_TILES) break; switch (tool) { case 0: fillrect(x[last_index] + NIBBLE_W / 2, y[last_index] + NIBBLE_H / 2, NIBBLE_W, NIBBLE_H); break; default: sprite(x[last_index] - 8 + NIBBLE_W / 2, y[last_index] - 8 + NIBBLE_H / 2, B_BRUSHES, tool - 1); break; } ++last_index; } } } mode(DASHBOARD_BLACK); gengine->flip(); } void dashboard_window_t::refresh(SDL_Rect *r) { switch(_mode) { case DASHBOARD_OFF: break; case DASHBOARD_BLACK: background(map_rgb(0x000000)); clear(); break; case DASHBOARD_GAME: sprite(0, 0, B_SCREEN, 0); break; case DASHBOARD_LOADING: background(map_rgb(0x000000)); clear(); sprite((width() - 250) / 2, 55, B_LOADING, 0); render_progress(); break; } } /*---------------------------------------------------------- Bar graph display ----------------------------------------------------------*/ bargraph_t::bargraph_t() { _value = 0.0f; _redmax = 1; _y = -1000; _enabled = 1; } void bargraph_t::value(float val) { if(val < 0.0f) _value = 0.0f; else _value = val; if(!_enabled) return; int y = (int)((height() - 2) * _value); if(y != _y) invalidate(); } void bargraph_t::enable(int ena) { _enabled = ena; invalidate(); } void bargraph_t::refresh(SDL_Rect *r) { if(!_enabled) { clear(); return; } float v = _value; int red, green, blue; if(v > 1.0f) { blue = 50 + (v - 1.0f) * 512; if(_redmax) { red = 255; green = blue / 2; } else { green = 255; red = blue / 2; } v = 1.0f; } else { if(_redmax) { red = (int)(v * 300.0); green = (int)((1.0 - v) * 400.0); } else { red = (int)((1.0 - v) * 300.0); green = (int)(v * 400.0); } blue = 50; } if(green > 180) green = 180; if(red > 230) red = 230; if(blue > 255) blue = 255; _y = (int)((height() - 2) * (1.0f - v)); foreground(bgcolor); fillrect(0, 0, width(), height()); foreground(map_rgb(red, green, blue)); fillrect(1, _y + 1, width() - 2, height() - _y - 2); } KoboDeluxe-0.5.1/sound.cpp0000644000175000001440000003535410734420753012346 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - Wrapper for Sound Control ------------------------------------------------------------ * Copyright (C) 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "sound.h" #include "kobo.h" #include "kobolog.h" #include "random.h" #include "audio.h" int KOBO_sound::sounds_loaded = 0; int KOBO_sound::music_loaded = 0; int KOBO_sound::time = 0; int KOBO_sound::_period = 30; int KOBO_sound::sfx2d_tag = 0; int KOBO_sound::listener_x = 0; int KOBO_sound::listener_y = 0; int KOBO_sound::wrap_x = 0; int KOBO_sound::wrap_y = 0; int KOBO_sound::scale = 65536 / 1000; int KOBO_sound::panscale = 65536 / 700; int KOBO_sound::firing = 0; int KOBO_sound::overheat = 0; unsigned KOBO_sound::rumble = 0; KOBO_sound::KOBO_sound() { } KOBO_sound::~KOBO_sound() { close(); } /*-------------------------------------------------- Open/close --------------------------------------------------*/ int KOBO_sound::load(int (*prog)(const char *msg), int force) { int res; int save_to_disk = 0; const char *ap = fmap->get("SFX>>", FM_DIR); if(!ap) { log_printf(ELOG, "Couldn't find audio data directory!\n"); return -1; } audio_set_path(ap); if(!sounds_loaded || force) { if(prog("Loading sound effects")) return -999; res = -1; if(prefs->cached_sounds && !force) { res = audio_wave_load(0, "sfx_c.agw", 0); if(res < 0) save_to_disk = 1; } if(res < 0) res = audio_wave_load(0, "sfx.agw", 0); if(res >= 0) sounds_loaded = 1; else log_printf(ELOG, "Could not load sound effects!\n"); prog(NULL); } if(prefs->use_music && !music_loaded || force) { if(prog("Loading music")) return -999; res = -1; if(prefs->cached_sounds && !force) { res = audio_wave_load(0, "music_c.agw", 0); if(res < 0) save_to_disk = 1; } if(res < 0) res = audio_wave_load(0, "music.agw", 0); if(res >= 0) music_loaded = 1; else log_printf(ELOG, "Could not load music!\n"); prog(NULL); } if(save_to_disk) if(prog("Preparing audio engine")) return -999; audio_wave_prepare(-1); if(save_to_disk) { if(prog("Writing sounds to disk")) return -999; if(audio_wave_load(0, "save_waves.agw", 0) < 0) log_printf(ELOG, "Could not save sounds to disk!\n"); } audio_wave_info(-1); return prog(NULL); } void KOBO_sound::prefschange() { /* Levels */ // audio_master_volume((float)prefs->volume/100.0); audio_group_controlf(SOUND_GROUP_UI, ACC_VOLUME, (float)prefs->intro_vol/100.0); audio_group_controlf(SOUND_GROUP_UIMUSIC, ACC_VOLUME, (float)prefs->intro_vol/100.0); audio_group_controlf(SOUND_GROUP_SFX, ACC_VOLUME, (float)prefs->sfx_vol/100.0); audio_group_controlf(SOUND_GROUP_BGMUSIC, ACC_VOLUME, (float)prefs->music_vol/100.0); set_boost(prefs->vol_boost); audio_quality((audio_quality_t)prefs->mixquality); // Bus 7: Our "Master Reverb Bus" master_reverb((float)prefs->reverb/100.0); } int KOBO_sound::open() { if(!prefs->use_sound) { log_printf(WLOG, "Sound disabled!\n"); return 0; } if(audio_start(prefs->samplerate, prefs->latency, prefs->use_oss, prefs->cmd_midi, prefs->cmd_pollaudio) < 0) { log_printf(ELOG, "Couldn't initialize audio;" " disabling sound effects.\n"); return -1; } // Channel grouping. We use only one chanel per group here, so we // just assign the first channels to the available groups. for(int i = 0; i < AUDIO_MAX_GROUPS; ++i) audio_channel_control(i, -1, ACC_GROUP, i); // Dirty hack for the music; the sequencer uses channels 16..31. for(int i = 16; i < 32; ++i) audio_channel_control(i, -1, ACC_GROUP, SOUND_GROUP_BGMUSIC); // Higher priority for music and UI effects audio_channel_control(SOUND_GROUP_BGMUSIC, AVT_ALL, ACC_PRIORITY, 1); audio_channel_control(SOUND_GROUP_UIMUSIC, AVT_ALL, ACC_PRIORITY, 2); audio_channel_control(SOUND_GROUP_UI, AVT_ALL, ACC_PRIORITY, 3); audio_channel_control(SOUND_GROUP_SFX, AVT_ALL, ACC_PRIORITY, 4); g_wrap(MAP_SIZEX*CHIP_SIZEX, MAP_SIZEY*CHIP_SIZEY); g_scale(VIEWLIMIT * 3 / 2, VIEWLIMIT); // For the noise "bzzzt" effect :-) audio_channel_control(3, -1, ACC_PRIM_BUS, 1); // Bus 0: Sound effects audio_bus_control(0, 1, ABC_FX_TYPE, AFX_NONE); audio_bus_controlf(0, 0, ABC_SEND_MASTER, 1.0); audio_bus_controlf(0, 0, ABC_SEND_BUS_7, 0.5); // Always a little rvb! // Bus 1: Sound effects with less reverb audio_bus_control(1, 1, ABC_FX_TYPE, AFX_NONE); audio_bus_controlf(1, 0, ABC_SEND_MASTER, 1.0); audio_bus_controlf(1, 0, ABC_SEND_BUS_7, 0.1); prefschange(); time = SDL_GetTicks(); return 0; } void KOBO_sound::stop() { audio_stop(); } void KOBO_sound::close() { audio_close(); sounds_loaded = 0; music_loaded = 0; } /*-------------------------------------------------- Main controls --------------------------------------------------*/ void KOBO_sound::master_reverb(float rvb) { int master_rvb = (int)(rvb * 65536.0); audio_bus_controlf(7, 0, ABC_SEND_MASTER, 0.0); audio_bus_control(7, 1, ABC_SEND_MASTER, master_rvb); if(master_rvb) audio_bus_control(7, 1, ABC_FX_TYPE, AFX_REVERB); else audio_bus_control(7, 1, ABC_FX_TYPE, AFX_NONE); } void KOBO_sound::set_boost(int boost) { switch(boost) { case 0: audio_set_limiter(1.0, 5.0); break; case 1: audio_set_limiter(.9, 4.5); break; case 2: default: audio_set_limiter(.75, 4.0); break; case 3: audio_set_limiter(.5, 3.5); break; case 4: audio_set_limiter(.25, 3.0); break; } } void KOBO_sound::sfx_volume(float vol) { audio_group_controlf(SOUND_GROUP_SFX, ACC_VOLUME, (float)prefs->sfx_vol * vol / 100.0f); } void KOBO_sound::intro_volume(float vol) { audio_group_controlf(SOUND_GROUP_UIMUSIC, ACC_VOLUME, (float)prefs->intro_vol * vol / 100.0f); } void KOBO_sound::music_volume(float vol) { audio_group_controlf(SOUND_GROUP_BGMUSIC, ACC_VOLUME, (float)prefs->music_vol * vol / 100.0f); } void KOBO_sound::period(int ms) { if(ms > 0) _period = ms; time = 0; } void KOBO_sound::frame() { #if 0 // Positional audio test static int aaa = 0; if(++aaa > 20) aaa = 0; if(aaa == 10) g_play(SOUND_OVERHEAT, listener_x + 128, listener_y, 32768, 55<<16); else if (aaa == 20) g_play(SOUND_OVERHEAT, listener_x - 128, listener_y, 32768, 67<<16); #endif // Advance to next game logic frame int nc = audio_next_callback(); if(time < nc) time = nc; else time -= 1 + (labs(time - nc) >> 5); audio_bump(time); time += _period; // Various sound control logic ++rumble; // Rumble timer } void KOBO_sound::run() { audio_run(); } /*-------------------------------------------------- In-game sound --------------------------------------------------*/ void KOBO_sound::g_music(int wid) { audio_channel_control(SOUND_GROUP_BGMUSIC, AVT_FUTURE, ACC_PATCH, wid); audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PAN, 0); audio_channel_play(SOUND_GROUP_BGMUSIC, 0, 60<<16, 65536); } void KOBO_sound::play(int wid, int vol, int pitch, int pan) { audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PATCH, wid); audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PAN, pan); audio_channel_play(SOUND_GROUP_UI, 0, pitch, vol); } void KOBO_sound::g_position(int x, int y) { listener_x = x; listener_y = y; } void KOBO_sound::g_wrap(int w, int h) { wrap_x = w; wrap_y = h; } void KOBO_sound::g_scale(int maxrange, int pan_maxrange) { scale = 65536 / maxrange; panscale = 65536 / pan_maxrange; } void KOBO_sound::g_play(int wid, int x, int y, int vol, int pitch) { int volume, vx, vy, pan; /* Calculate volume */ x -= listener_x; y -= listener_y; if(wrap_x) { x += wrap_x / 2; while(x < 0) x += wrap_x; x %= wrap_x; x -= wrap_x / 2; } if(wrap_y) { y += wrap_y / 2; while(y < 0) y += wrap_y; y %= wrap_y; y -= wrap_y / 2; } /* Approximation of distance attenuation */ vx = abs(x * scale); vy = abs(y * scale); if((vx | vy) & 0xffff0000) return; vx = (65536 - vx) >> 1; vy = (65536 - vy) >> 1; volume = vx * vy >> 14; volume = (volume>>1) * (volume>>1) >> 14; pan = x * panscale; if(pan < -65536) pan = -65536; else if(pan > 65536) pan = 65536; audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PATCH, wid); audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PAN, pan); audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_VOLUME, volume); audio_channel_play(SOUND_GROUP_SFX, sfx2d_tag, pitch, vol); sfx2d_tag = (sfx2d_tag + 1) & 0xffff; } void KOBO_sound::g_play0(int wid, int vol, int pitch) { audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PATCH, wid); audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_PAN, 0); audio_channel_control(SOUND_GROUP_SFX, AVT_FUTURE, ACC_VOLUME, 65536); audio_channel_play(SOUND_GROUP_SFX, sfx2d_tag, 60<<16, vol); sfx2d_tag = (sfx2d_tag + 1) & 0xffff; } void KOBO_sound::g_player_fire() { if(firing) g_play0(SOUND_SHOT, (prefs->cannonloud << 13) / 100); else { firing = 1; g_play0(SOUND_SHOT_START, 20000); } overheat = 0; } void KOBO_sound::g_player_fire_off() { if(firing) { firing = 0; g_play0(SOUND_SHOT_END, 20000); } } void KOBO_sound::g_player_overheat(int classic) { if(overheat) return; overheat = 1; g_play0(SOUND_SHOT_OVERHEAT, (prefs->cannonloud << 13) / 75); if(!classic) g_play(SOUND_OVERHEAT, listener_x + 100, listener_y, (prefs->overheatloud << 14) / 100); } void KOBO_sound::g_player_damage() { int p0 = (60<<16) + (pubrand.get(9) << 8); g_play(SOUND_DAMAGE, listener_x - 100, listener_y, 65536, p0 + 3000); g_play(SOUND_DAMAGE, listener_x + 100, listener_y, 65536, p0 - 3000); } void KOBO_sound::g_player_explo_start() { g_player_damage(); g_play(SOUND_EXPLO_PLAYER, listener_x - 100, listener_y, 65536, (55<<16) + 4000); g_play(SOUND_EXPLO_PLAYER, listener_x + 100, listener_y, 65536, (55<<16) - 4000); } void KOBO_sound::g_bolt_hit(int x, int y) { g_play(SOUND_METALLIC1 + (pubrand.get() % 3), CS2PIXEL(x), CS2PIXEL(y), 12000); } void KOBO_sound::g_bolt_hit_rock(int x, int y) { g_play(SOUND_HIT1 + (pubrand.get() % 3), CS2PIXEL(x), CS2PIXEL(y), 20000); } void KOBO_sound::g_base_node_explo(int x, int y) { g_play(pubrand.get(8) > 128 ? SOUND_EXPLO_NODE1 : SOUND_EXPLO_NODE2, CS2PIXEL(x), CS2PIXEL(y)); rumble = 0; } void KOBO_sound::g_base_core_explo(int x, int y) { x = CS2PIXEL(x); y = CS2PIXEL(y); g_play(pubrand.get(8) > 128 ? SOUND_EXPLO_NODE1 : SOUND_EXPLO_NODE2, x, y, 100000, 62<<16); g_play(SOUND_FINE, x + 30, y, 65536, (60<<16) + 4000); g_play(SOUND_FINE, x - 30, y, 65536, (60<<16) - 4000); rumble = 0; } void KOBO_sound::g_pipe_rumble(int x, int y) { if(rumble < 4 + pubrand.get(3)) return; g_play(pubrand.get(8) > 128 ? SOUND_RUMBLE_NODE1 : SOUND_RUMBLE_NODE2, CS2PIXEL(x), CS2PIXEL(y)); rumble = 0; } void KOBO_sound::g_enemy_explo(int x, int y) { g_play(SOUND_EXPLO_ENEMY1 + (pubrand.get() % 2), CS2PIXEL(x), CS2PIXEL(y), 40000); } void KOBO_sound::g_rock_explo(int x, int y) { g_play(SOUND_EXPLO_ROCK, CS2PIXEL(x), CS2PIXEL(y), 40000); } void KOBO_sound::g_ring_explo(int x, int y) { g_play(SOUND_EXPLO_RING1 + (pubrand.get() % 3), CS2PIXEL(x), CS2PIXEL(y), 32768); } void KOBO_sound::g_bomb_deto(int x, int y) { g_play(SOUND_BOMB_DETO, CS2PIXEL(x), CS2PIXEL(y), 40000); } void KOBO_sound::g_launch_ring(int x, int y) { g_play(SOUND_RING, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_launch_beam(int x, int y) { g_play(SOUND_BEAM, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_launch_bomb(int x, int y) { g_play(SOUND_LAUNCH2, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_launch(int x, int y) { g_play(SOUND_LAUNCH, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_m_launch_ring(int x, int y) { g_play(SOUND_RING, CS2PIXEL(x), CS2PIXEL(y)); g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_m_launch_beam(int x, int y) { g_play(SOUND_BEAM, CS2PIXEL(x), CS2PIXEL(y)); g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_m_launch_bomb(int x, int y) { g_play(SOUND_LAUNCH2, CS2PIXEL(x), CS2PIXEL(y)); g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); } void KOBO_sound::g_m_launch(int x, int y) { g_play(SOUND_LAUNCH, CS2PIXEL(x), CS2PIXEL(y)); g_play(SOUND_ENEMYM, CS2PIXEL(x), CS2PIXEL(y)); } /*-------------------------------------------------- UI sound effects --------------------------------------------------*/ void KOBO_sound::ui_music(int wid) { // KLUDGE UNTIL MIDI SONGS AND FX CONTROL IS FIXED! audio_bus_control(0, 1, ABC_FX_TYPE, AFX_NONE); audio_bus_controlf(0, 0, ABC_SEND_MASTER, 1.0); audio_bus_controlf(0, 0, ABC_SEND_BUS_7, 0.5); // KLUDGE UNTIL MIDI SONGS AND FX CONTROL IS FIXED! audio_channel_control(SOUND_GROUP_UIMUSIC, AVT_FUTURE, ACC_PATCH, wid); audio_channel_play(SOUND_GROUP_UIMUSIC, 0, 60<<16, 65536); } void KOBO_sound::ui_noise(int n) { if(n < 0) { sound.sfx_volume(0.0f); audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PATCH, SOUND_BZZZT); audio_channel_play(SOUND_GROUP_UI, 0, 60<<16, 10000 + pubrand.get(14)); return; } if(n && pubrand.get(1)) { sound.sfx_volume(0.0f); audio_channel_control(SOUND_GROUP_UI, AVT_FUTURE, ACC_PATCH, SOUND_BZZZT); audio_channel_play(SOUND_GROUP_UI, 0, 60<<16, 20000 + pubrand.get(14)); } else sound.sfx_volume(1.0f); } void KOBO_sound::ui_ok() { play(SOUND_EXPLO_NODE1, 32768); } void KOBO_sound::ui_cancel() { play(SOUND_CANCEL, 20000); } void KOBO_sound::ui_move() { play(SOUND_MOVE, 20000); } void KOBO_sound::ui_tick() { play(SOUND_METALLIC1, 15000); } void KOBO_sound::ui_error() { play(SOUND_OVERHEAT, 20000); } void KOBO_sound::ui_play() { play(SOUND_PLAY, 32768, (50<<16) + 2000, -40000); play(SOUND_PLAY, 32768, (50<<16) - 2000, 40000); } void KOBO_sound::ui_pause() { play(SOUND_PAUSE, 32768, (56<<16) + 2000, -40000); play(SOUND_PAUSE, 32768, (56<<16) - 2000, 40000); } void KOBO_sound::ui_ready() { play(SOUND_READY, 15000, (60<<16) + 3000, -40000); play(SOUND_READY, 15000, (60<<16) - 3000, 40000); } void KOBO_sound::ui_countdown(int remain) { play(SOUND_TICK, 20000, (65 - remain)<<16); } void KOBO_sound::ui_oneup() { play(SOUND_ONEUP, 32768, (60<<16) + 5000, -40000); play(SOUND_ONEUP, 32768, (60<<16) - 5000, 40000); } void KOBO_sound::ui_gameover() { play(SOUND_GAMEOVER); } KoboDeluxe-0.5.1/aconfig.h0000644000175000001440000001240110734532425012255 00000000000000/* aconfig.h. Generated from aconfig.h.in by configure. */ /* aconfig.h.in. Generated from configure.in by autoheader. */ /* Define to 1 if you have the `atexit' function. */ #define HAVE_ATEXIT 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ #define HAVE_DIRENT_H 1 /* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */ /* #undef HAVE_DOPRNT */ /* Define to 1 if you have the header file. */ #define HAVE_ERRNO_H 1 /* Define to 1 if you have the header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the `floor' function. */ #define HAVE_FLOOR 1 /* Define to 1 if you have the `getegid' function. */ #define HAVE_GETEGID 1 /* Define to 1 if you have the `getpagesize' function. */ #define HAVE_GETPAGESIZE 1 /* Define to 1 if you have the `gettimeofday' function. */ #define HAVE_GETTIMEOFDAY 1 /* Define to 1 if you have the header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the `SDL_image' library (-lSDL_image). */ #define HAVE_LIBSDL_IMAGE 1 /* Define to 1 if you have the `memcmp' function. */ #define HAVE_MEMCMP 1 /* Define to 1 if you have the `memmove' function. */ #define HAVE_MEMMOVE 1 /* Define to 1 if you have the header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `mkdir' function. */ #define HAVE_MKDIR 1 /* Define to 1 if you have a working `mmap' system call. */ #define HAVE_MMAP 1 /* Define to 1 if you have the `munmap' function. */ #define HAVE_MUNMAP 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_NDIR_H */ /* Define to 1 if you have the `pow' function. */ #define HAVE_POW 1 /* Define to 1 if you have the header file. */ #define HAVE_SDL_SDL_OPENGL_H 1 /* Define to 1 if you have the `select' function. */ #define HAVE_SELECT 1 /* Define to 1 if you have the `setgid' function. */ #define HAVE_SETGID 1 /* Define to 1 if you have the `snprintf' function. */ #define HAVE_SNPRINTF 1 /* Define to 1 if you have the `sqrt' function. */ #define HAVE_SQRT 1 /* Define to 1 if you have the `stat' function. */ #define HAVE_STAT 1 /* Define to 1 if `stat' has the bug that it succeeds when given the zero-length file name argument. */ /* #undef HAVE_STAT_EMPTY_STRING_BUG */ /* Define to 1 if you have the header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `strchr' function. */ #define HAVE_STRCHR 1 /* Define to 1 if you have the `strdup' function. */ #define HAVE_STRDUP 1 /* Define to 1 if you have the header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strrchr' function. */ #define HAVE_STRRCHR 1 /* Define to 1 if you have the `strstr' function. */ #define HAVE_STRSTR 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_SYS_DIR_H */ /* Define to 1 if you have the header file. */ #define HAVE_SYS_IOCTL_H 1 /* Define to 1 if you have the header file, and it defines `DIR'. */ /* #undef HAVE_SYS_NDIR_H */ /* Define to 1 if you have the header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TIME_H 1 /* Define to 1 if you have the header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the header file. */ #define HAVE_UNISTD_H 1 /* Define to 1 if you have the `vprintf' function. */ #define HAVE_VPRINTF 1 /* Define to 1 if you have the `vsnprintf' function. */ #define HAVE_VSNPRINTF 1 /* Define to 1 if you have the `_snprintf' function. */ /* #undef HAVE__SNPRINTF */ /* Define to 1 if you have the `_vsnprintf' function. */ /* #undef HAVE__VSNPRINTF */ /* Define to 1 if `lstat' dereferences a symlink specified with a trailing slash. */ #define LSTAT_FOLLOWS_SLASHED_SYMLINK 1 /* Name of package */ #define PACKAGE "KoboDeluxe" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ #define PACKAGE_NAME "" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "" /* Define to the version of this package. */ #define PACKAGE_VERSION "" /* Define as the return type of signal handlers (`int' or `void'). */ #define RETSIGTYPE void /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Define to 1 if you can safely include both and . */ #define TIME_WITH_SYS_TIME 1 /* Version number of package */ #define VERSION "0.5.1" /* Define to 1 if the X Window System is missing or not being used. */ /* #undef X_DISPLAY_MISSING */ /* Define to empty if `const' does not conform to ANSI C. */ /* #undef const */ /* Define to `__inline__' or `__inline' if that's what the C compiler calls it, or to nothing if 'inline' is not supported under any name. */ #ifndef __cplusplus /* #undef inline */ #endif KoboDeluxe-0.5.1/cfgform.h0000644000175000001440000000363307735435216012310 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001, 2003, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _CONFIG_FORM_H_ #define _CONFIG_FORM_H_ #include "form.h" #include "prefs.h" enum { OS_CLOSE = 0x0001, OS_CANCEL = 0x0002, OS_REBUILD = 0x0004, OS_ACTION = 0x000f, OS_RELOAD_GRAPHICS = 0x0010, OS_RELOAD_AUDIO_CACHE = 0x0020, OS_RELOAD = 0x0070, OS_RESTART_VIDEO = 0x0100, OS_RESTART_AUDIO = 0x0200, OS_RESTART_ENGINE = 0x0400, OS_RESTART_INPUT = 0x0800, OS_RESTART_LOGGER = 0x0080, OS_RESTART = 0x0f80, OS_UPDATE_AUDIO = 0x1000, OS_UPDATE_ENGINE = 0x2000, OS_UPDATE = 0xf000 }; class config_form_t : public kobo_form_t { protected: prefs_t *prf; prefs_t prfbak; int stat; public: config_form_t(); virtual ~config_form_t(); void open(prefs_t *p); virtual void build(); // <-- Override this! //...and this, if you need. Normally, //it just sets the status to 0. virtual void undo_hook(); void close(); int status(); void setstatus(int mask); void clearstatus(int mask); void undo(); void change(int delta); }; extern int global_status; #endif //_CONFIG_FORM_H_ KoboDeluxe-0.5.1/cfgparse.h0000644000175000001440000001143110730706444012443 00000000000000/* ------------------------------------------------------------------- cfgparse.h - Generic Config File and Argument Parser ------------------------------------------------------------------- * Copyright (C) 2001, 2007 David Olofson * * This code is released under the terms of the GNU LGPL. */ #ifndef CFGPARSE_H #define CFGPARSE_H #include enum cfg_types_t { CFG_NONE, CFG_BOOL, CFG_INT, CFG_FLOAT, CFG_STRING }; #define CFG_STRING_LENGTH 256 typedef char cfg_string_t[CFG_STRING_LENGTH]; class cfg_key_t { public: cfg_key_t *next; int save; int redefined; cfg_types_t typecode; const char *name; char *description; cfg_key_t(); virtual ~cfg_key_t(); virtual int read(int argc, char *argv[]); virtual int test(const char *arg); virtual int copy(cfg_key_t *from) = 0; virtual void write(FILE *f) = 0; virtual void set_default() = 0; virtual int is_your_var(void *var) = 0; }; class cfg_comment_t : public cfg_key_t { public: cfg_comment_t(const char *text) { name = text; } int read(int argc, char *argv[]) { return 0; } int copy(cfg_key_t *from); void write(FILE *f); void set_default() { ; } int is_your_var(void *var) { return 0; } }; class cfg_switch_t : public cfg_key_t { public: int *value; int default_value; cfg_switch_t(const char *_name, int &var, int def, int _save); int copy(cfg_key_t *from); virtual int test(const char *arg); int read(int argc, char *argv[]); void write(FILE *f); void set_default(); int is_your_var(void *var); }; class cfg_key_int_t : public cfg_key_t { public: int *value; int default_value; cfg_key_int_t(const char *_name, int &var, int def, int _save); int copy(cfg_key_t *from); int read(int argc, char *argv[]); void write(FILE *f); void set_default(); int is_your_var(void *var); }; class cfg_key_float_t : public cfg_key_t { public: float *value; float default_value; cfg_key_float_t(const char *_name, float &var, float def, int _save); int copy(cfg_key_t *from); int read(int argc, char *argv[]); void write(FILE *f); void set_default(); int is_your_var(void *var); }; class cfg_key_string_t : public cfg_key_t { public: cfg_string_t *value; cfg_string_t default_value; cfg_key_string_t(const char *_name, cfg_string_t &var, const cfg_string_t def, int _save); int copy(cfg_key_t *from); int read(int argc, char *argv[]); void write(FILE *f); void set_default(); int is_your_var(void *var); }; class config_parser_t { cfg_key_t *keys, *last_key; int initialized; int nkeys; // For symbol table API cfg_key_t **table; // For symbol table API cfg_string_t retbuf; // For symbol table API void initialize(); void print_switch(FILE *f, const char *base, int flag); int read_config(char ***cv, FILE *f); void add(cfg_key_t *_key); int _redefined(void *var); void _accept(void *var); void build_table(); int check_symbol(int symbol); protected: //Key registration: For use in inherited init() void comment(const char *text); void yesno(const char *name, int &var, int def, int save = 1); void command(const char *name, int &var); void key(const char *name, int &var, int def, int save = 1); void key(const char *name, float &var, float def, int save = 1); void key(const char *name, cfg_string_t &var, const cfg_string_t def, int save = 1); void desc(const char *text); //Plug key registration and custom stuff in here! virtual void init() = 0; virtual void postload() { ; } virtual void presave() { ; } public: int changed; //Set when *edited* by the user config_parser_t(); virtual ~config_parser_t(); config_parser_t &operator = (config_parser_t &from); void set_defaults(); int parse(int argc, char *argv[]); int read(FILE *f); int write(FILE *f); //Changed since last accept() call? int redefined(int &var) { return _redefined(&var); } int redefined(float &var) { return _redefined(&var); } int redefined(cfg_string_t &var) { return _redefined(&var); } //Reset redefined() state to 0. void accept(int &var) { _accept(&var); } void accept(float &var) { _accept(&var); } void accept(cfg_string_t &var) { _accept(&var); } /* Generic Symbol Table Style API */ int find(const char *name); int find_next(int symbol = -1); cfg_types_t type(int symbol); int do_save(int symbol); const char *name(int symbol); const char *description(int symbol); void set(int symbol, int value); void set(int symbol, float value); void set(int symbol, const char *text); int get_i(int symbol); int get_default_i(int symbol); float get_f(int symbol); float get_default_f(int symbol); /* * WARNING: These ones sometimes return pointers to non-constant * buffers! Therefore, you need to copy the results * before you call these functions again. */ const char *get_s(int symbol); const char *get_default_s(int symbol); }; #endif //CFGPARSE_H KoboDeluxe-0.5.1/config.h0000664000175000001440000001032210730602450012106 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001-2003, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_CONFIG_H_ #define _KOBO_CONFIG_H_ #include #ifndef DEBUG # undef DBG # undef DBG2 # undef DBG3 # undef DBG4 # define DBG(x) # define DBG2(x) # define DBG3(x) # define DBG4(x) #endif #ifndef HAVE_SNPRINTF #ifndef HAVE__SNPRINTF #error Must have snprintf() or _snprintf! #endif #define snprintf _snprintf #endif #ifndef HAVE_VSNPRINTF #ifndef HAVE__VSNPRINTF #error Must have vsnprintf() or _vsnprintf! #endif #define vsnprintf _vsnprintf #endif /* * On some platforms, assignments of these "opaque objects" are * illegal - while on others, the macro to handle that can be * missing... Oh, and this is really only in C99, of course. :-/ */ #include #ifndef va_copy # ifdef __va_copy # define va_copy(to, from) __va_copy(to, from) # else # define va_copy(to, from) (to) = (from) # endif #endif /* Key/button repeat timing */ #define KOBO_KEY_DELAY 250 #define KOBO_KEY_REPEAT 40 /* * This was originally 1024, but was changed in Kobo Deluxe 0.4.1 * to avoid the bug where we run out of enemies when destroying a * base, and thus leave parts of it behind. */ #define ENEMY_MAX 2048 /* * Game display size. * * In XKobo, there was only WSIZE - VIEWLIMIT was added * for Kobo Deluxe, and WSIZE was set to 230, to add some * extra pixels, most of which were more or less covered * by the rounded framework. * * As of Kobo Deluxe 0.4.1, WSIZE is restored to the * original 224. * * Note that if WSIZE is larger than VIEWLIMIT, some * objects might be created or deleted in view. Finding * out whether or not it can really happen calls for * closer analysis of the code. */ #define WSIZE 224 #define MARGIN 8 /* * (In XKobo, WSIZE was used where this is * used now; in the game logic code.) * * NOTE: I *DON'T* want to change the view * range as the XKobo engine knows it, * as that would make the game play * slightly differently. (Probably not * so that anyone would notice, but * let's not take chances... This is * NOT "Kobo II".) */ #define VIEWLIMIT 224 // Player ship hit rect size #define HIT_MYSHIP 5 // Player bolt hit rect size #define HIT_BOLT 5 /* Actually, this is not the *full* size in windowed mode any more. */ #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 /* Various size info (DO NOT EDIT!) */ #define CHIP_SIZEX_LOG2 4 #define CHIP_SIZEY_LOG2 4 #define MAP_SIZEX_LOG2 6 #define MAP_SIZEY_LOG2 7 #define WORLD_SIZEX_LOG2 (MAP_SIZEX_LOG2+CHIP_SIZEX_LOG2) #define WORLD_SIZEY_LOG2 (MAP_SIZEY_LOG2+CHIP_SIZEY_LOG2) #define NOISE_SIZEX_LOG2 8 #define CHIP_SIZEX (1< #include "kobo.h" #include "config.h" #include "myship.h" #include "manage.h" #include "sound.h" #define ABS(x) (((x)>=0) ? (x) : (-(x))) #define MAX(x,y) (((x)>(y)) ? (x) : (y)) #define HEALTH_INDESTRUCTIBLE 9000000 class _enemy; class _enemies; //---------------------------------------------------------------------------// struct enemy_kind { int score; void (_enemy::*make) (); void (_enemy::*move) (); void (_enemy::*kill) (); int hitsize; int bank, frame; int layer; }; extern const enemy_kind beam; extern const enemy_kind explosion; extern const enemy_kind explosion3; extern const enemy_kind explosion4; extern const enemy_kind explosion5; extern const enemy_kind ringexpl; extern const enemy_kind beamexpl; extern const enemy_kind boltexpl; extern const enemy_kind rockexpl; extern const enemy_kind enemy1; extern const enemy_kind enemy2; extern const enemy_kind enemy3; extern const enemy_kind enemy4; extern const enemy_kind enemy5; extern const enemy_kind enemy6; extern const enemy_kind enemy7; extern const enemy_kind bomb1; extern const enemy_kind bomb2; extern const enemy_kind bombdeto; extern const enemy_kind cannon; extern const enemy_kind pipe1; extern const enemy_kind core; extern const enemy_kind pipe2; extern const enemy_kind rock; extern const enemy_kind ring; extern const enemy_kind enemy_m1; extern const enemy_kind enemy_m2; extern const enemy_kind enemy_m3; extern const enemy_kind enemy_m4; //---------------------------------------------------------------------------// enum _state_t { notuse, reserved, moving }; class _enemy { cs_obj_t *object; /* For the gfxengine connection */ _state_t _state; const enemy_kind *ek; int x, y; int h, v; int di; int a, b; int count; int health; int damage; int shootable; int diffx, diffy; int norm; int hitsize; int bank, frame; void hit(int dmg); void move_enemy_m(int quick, int maxspeed); void move_enemy_template(int quick, int maxspeed); void move_enemy_template_2(int quick, int maxspeed); void move_enemy_template_3(int quick, int maxspeed); void shot_template(const enemy_kind * ekp, int shift, int rand_num, int maxspeed); void shot_template_8_dir(const enemy_kind * ekp); public: _enemy(); inline void init(); inline void release(); void state(_state_t s); inline void move(); inline void move_intro(); inline void put(); inline int make(const enemy_kind * k, int px, int py, int h1, int v1, int dir = 0); inline int realize(); inline int is_pipe(); inline int erase_cannon(int px, int py); void kill_default(); void make_beam(); void move_beam(); void kill_beam(); void make_rock(); void move_rock(); void kill_rock(); void make_ring(); void move_ring(); void kill_ring(); void make_bomb(); void move_bomb1(); void move_bomb2(); void make_expl(); void move_expl(); void make_cannon(); void move_cannon(); void kill_cannon(); void make_core(); void move_core(); void kill_core(); void make_pipe1(); void move_pipe1(); void make_pipe2(); void move_pipe2(); void make_enemy1(); void move_enemy1(); void make_enemy2(); void move_enemy2(); void make_enemy3(); void move_enemy3(); void make_enemy4(); void move_enemy4(); void make_enemy(); void move_enemy5(); void move_enemy6(); void move_enemy7(); void make_enemy_m1(); void move_enemy_m1(); void make_enemy_m2(); void move_enemy_m2(); void make_enemy_m3(); void move_enemy_m3(); void make_enemy_m4(); void move_enemy_m4(); }; //---------------------------------------------------------------------------// class _enemies { static _enemy enemy[ENEMY_MAX]; static _enemy *enemy_max; static const enemy_kind *ekind_to_generate_1; static const enemy_kind *ekind_to_generate_2; static int e1_interval; static int e2_interval; static int explocount; public: static int is_intro; static int init(); static void off(); static void move(); static void move_intro(); static void put(); static int make(const enemy_kind * ek, int x, int y, int h = 0, int v = 0, int di = 0); static const enemy_kind *randexp(); static int erase_cannon(int x, int y); static int exist_pipe(); static void set_ekind_to_generate(const enemy_kind * ek1, int i1, const enemy_kind * ek2, int i2); static inline const enemy_kind *ek1() { return ekind_to_generate_1; } static inline const enemy_kind *ek2() { return ekind_to_generate_2; } static inline int eint1() { return e1_interval; } static inline int eint2() { return e2_interval; } }; extern _enemies enemies; inline void _enemy::init() { release(); } inline void _enemy::release() { state(notuse); } inline int _enemy::make(const enemy_kind * k, int px, int py, int h1, int v1, int dir) { if(_state != notuse) return -1; ek = k; state(reserved); x = PIXEL2CS(px); y = PIXEL2CS(py); di = dir; h = h1; v = v1; a = 0; b = 0; count = 0; health = 20; damage = 50; shootable = 1; hitsize = ek->hitsize; bank = ek->bank; frame = ek->frame; (this->*(ek->make)) (); return 0; } inline void _enemy::hit(int dmg) { if(HEALTH_INDESTRUCTIBLE != health) health -= dmg; if(enemies.is_intro) { if(health <= 0) { enemies.make(&explosion, CS2PIXEL(x), CS2PIXEL(y)); release(); } return; } else if(health > 0) { if(ek == &rock) sound.g_bolt_hit_rock(x, y); else sound.g_bolt_hit(x, y); return; } manage.add_score(ek->score); (this->*(ek->kill)) (); } inline int _enemy::erase_cannon(int px, int py) { if( (_state != notuse) && (ek == &cannon) && ((signed)(CS2PIXEL(x) & (WORLD_SIZEX - 1)) >> 4 == px) && ((signed)(CS2PIXEL(y) & (WORLD_SIZEY - 1)) >> 4 == py) ) { release(); return 1; } return 0; } inline void _enemy::move() { if(_state != moving) return; x += h; y += v; diffx = CS2PIXEL(x) - myship.get_x(); diffy = CS2PIXEL(y) - myship.get_y(); if(diffx > (WORLD_SIZEX >> 1)) { diffx -= WORLD_SIZEX; x -= PIXEL2CS(WORLD_SIZEX); } if(diffx < -(WORLD_SIZEX >> 1)) { diffx += WORLD_SIZEX; x += PIXEL2CS(WORLD_SIZEX); } if(diffy > (WORLD_SIZEY >> 1)) { diffy -= WORLD_SIZEY; y -= PIXEL2CS(WORLD_SIZEY); } if(diffy < -(WORLD_SIZEY >> 1)) { diffy += WORLD_SIZEY; y += PIXEL2CS(WORLD_SIZEY); } norm = MAX(ABS(diffx), ABS(diffy)); (this->*(ek->move)) (); // Handle collisions with the player ship if((hitsize >= 0) && (norm < (hitsize + HIT_MYSHIP))) if(prefs->cmd_indicator) sound.g_player_damage(); else if(myship.alive()) { hit(game.damage); // Ship damages object myship.hit(damage); // Object damages ship } // Handle collisions with player bolts (Player bolts kill themselves // when they hit something, so we don't need to hit them from here.) if(!shootable || (norm >= ((VIEWLIMIT >> 1) + 8))) return; int dmg = myship.hit_bolt(CS2PIXEL(x), CS2PIXEL(y), hitsize + HIT_BOLT, health); if(dmg) if(prefs->cmd_indicator) sound.g_player_damage(); else hit(dmg); // Bolt damages object } inline void _enemy::move_intro() { if(_state != moving) return; x += h; y += v; diffx = CS2PIXEL(x) - myship.get_x(); diffy = CS2PIXEL(y) - myship.get_y(); if(diffx > (WORLD_SIZEX >> 1)) { diffx -= WORLD_SIZEX; x -= PIXEL2CS(WORLD_SIZEX); } if(diffx < -(WORLD_SIZEX >> 1)) { diffx += WORLD_SIZEX; x += PIXEL2CS(WORLD_SIZEX); } if(diffy > (WORLD_SIZEY >> 1)) { diffy -= WORLD_SIZEY; y -= PIXEL2CS(WORLD_SIZEY); } if(diffy < -(WORLD_SIZEY >> 1)) { diffy += WORLD_SIZEY; y += PIXEL2CS(WORLD_SIZEY); } norm = MAX(ABS(diffx), ABS(diffy)); (this->*(ek->move)) (); } inline void _enemy::put() { if(!object) return; object->point.v.x = x; object->point.v.y = y; cs_obj_image(object, bank, frame + di - 1); } inline int _enemy::realize() { if(_state == reserved) { state(moving); if(object) { object->point.v.x = x; object->point.v.y = y; cs_point_force(&object->point); } } return (_state == moving); } inline int _enemy::is_pipe() { return ((_state != notuse) && ((ek == &pipe1) || (ek == &pipe2))); } #endif // XKOBO_H_ENEMIES KoboDeluxe-0.5.1/filemap.h0000666000175000001440000001046707502000313012263 00000000000000/* ------------------------------------------------------------ filemap.h - Simple Portable File Path Mapper ------------------------------------------------------------ * © David Olofson, 2001 * This code is released under the terms of the GNU LGPL. */ /* * Path syntax: * All filemapper_t functions but exepath() * and sys2unix() (obviously!) expect paths in the * native system format. * * ALL OTHER PATHS SHOULD BE IN UNIX FORMAT. * * All arguments that are expected to be in system * format are named along the lines of "syspath". * * Classes: * The 'class>>' construct expands to one of the * paths registered for 'class', or makes the mapping * fail (NULL is returned), if the object doesn't * exist or cannot be created as applicable. * * Class references are recursive, and are resolved * late, at mapping time. (That is, they are resolved * when someone asks for it, not when registering * paths.) * * Class "HOME>>" is built-in, and resolves to the * root of the user home directory. (Currently * looks only at the environment variable "HOME", * which may not be defined on all platforms.) * * Class "EXE>>" is another built-in, and refers to * the path extracted from exepath(). */ #ifndef _FILEMAP_H_ #define _FILEMAP_H_ #include "aconfig.h" #define FM_DEREF_TOKEN ">>" #include #include #define FM_BUFFERS 16 #define FM_BUFFER_SIZE 512 struct fm_key_t { fm_key_t *next; char key[10]; char *path; }; enum { FM_ERROR = 0, FM_FILE, FM_DIR, FM_ANY, FM_FILE_CREATE, FM_DIR_CREATE }; // Not a great name - but fm_path_t would just be confusing, // and an fm_object_t can actually be either a dir or a file. struct fm_object_t { fm_object_t *next; char *path; int kind; ~fm_object_t(); }; class filemapper_t { // For get_(first|next)() fm_object_t *objects; fm_object_t *current_obj; DIR *current_dir; // File mapper keys fm_key_t *keys; // Application executable path char *app_path; // Silly/safe/string alloc :-) char buffers[FM_BUFFERS][FM_BUFFER_SIZE]; int next_buffer; char *salloc(); // Various private funcs void no_double_slashes(char *buf); void unix_slashes(char *buf); void sys_slashes(char *buf); int probe(const char *syspath); int test_file_create(const char *syspath); int test_file_dir_any(const char *syspath, int kind); int try_get(const char *path, int kind); void add_object(const char *path, int kind); int recurse_get(char *result, const char *ref, int kind, int level, int build); public: filemapper_t(); ~filemapper_t(); // Set/get path to exe file. // Note that exepath() expects a // path in the *native system* format, // while exepath() returns a Unix path. void exepath(const char *syspath); const char *exepath() { return app_path; } // Add 'path' to class 'key'. // Key should be given *without* the '::'. void addpath(const char *key, const char *path, int first = 0); // key == NULL, ref == NULL or "*": // Get first key. // key == NULL, ref == : // Get first key of class 'ref'. // key == , ref == NULL: // Get next key of same class as 'key'. // key == , ref == : // Get next key of class 'ref'. // The "*" wildcard for 'ref' is allowed. // Returns NULL if no key was found. fm_key_t *getkey(fm_key_t *key = NULL, const char *ref = NULL); // Get object path (returns path in system format!) const char *get(const char *ref, int kind = FM_FILE); /* FIXME: Do these really handle the 'kind' argument properly...? FIXME: When looking for files, they should return only files FIXME: matching the 'ref' path, while when looking for dirs, FIXME: every file inside each matching dir should be returned. */ // Initialize path scan. Use get_next() to get the // paths to all matches. void get_all(const char *ref, int kind = FM_FILE); // Get next object (returns path in system format!) const char *get_next(); // Open/create file/dir. FILE *fopen(const char *ref, const char *mode); DIR *opendir(const char *ref); int mkdir(const char *ref, int perm); // Print out all registered paths of class 'ref' // to stream 'f'. (ref == '*') ==> All classes. void print(FILE *f, const char *ref); // Translate to and from the internal Unix-like path format char *sys2unix(const char *syspath); char *unix2sys(const char *path); }; #endif KoboDeluxe-0.5.1/form.h0000644000175000001440000000445310730636244011622 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001, 2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_FORM_H_ #define _KOBO_FORM_H_ #include "toolkit.h" #include "cfgparse.h" #define LINE_H 9 #define SPACE_SIZE 7 #define BIG_LINE_H 18 #define BIG_SPACE_SIZE 14 class kobo_form_t : public ct_form_t { config_parser_t *_data; //Called by build_all(). void begin(); void end(); protected: ct_widget_t *current_widget; ct_list_t *current_list; int ypos; int _big; float xoffs; ct_align_t halign; virtual void init_widget(ct_widget_t *wg); //Toolkit void big(); void medium(); void small(); void label(const char *cap); void yesno(const char *cap, int *var, int tag = 0); void onoff(const char *cap, int *var, int tag = 0); void spin(const char *cap, int *var, int min, int max, const char *unit, int tag = 0); void button(const char *cap, int tag = 0); void space(int lines = 1); //config_parser_t aware version! :-) void data(config_parser_t *_d); void editor(int handle, int tag = 0); void editor(const char *name, int tag = 0); //List tools void list(const char *cap, int *var, int tag = 0); void item(const char *cap, int value, int ind = 0); void perc_list(int first, int last, int step); void enum_list(int first, int last); //Internal wrapper for build() void build_all(); public: kobo_form_t(); virtual ~kobo_form_t(); void next(); void prev(); virtual void change(int delta); virtual void build(); }; #endif KoboDeluxe-0.5.1/game.h0000644000175000001440000000447010733147063011566 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2002, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_GAME_H_ #define _KOBO_GAME_H_ // Max number of player bolts flying #define MAX_BOLTS 40 enum game_types_t { GAME_UNKNOWN = -1, GAME_SINGLE, GAME_SINGLE_NEW, GAME_COOPERATIVE, GAME_DEATHMATCH, GAME_EXPERIMENTAL = 0x10000000 // Testing! No official highscores. }; enum skill_levels_t { SKILL_UNKNOWN = -1, SKILL_CLASSIC, SKILL_NEWBIE, SKILL_GAMER, SKILL_ELITE, SKILL_GOD }; class game_t { public: int type; int skill; int speed; // ms per logic frame int lives; // When starting new games of certain types int bonus_first; // First bonus ship at this score int bonus_every; // New bonus ship every N points int health; // Initial health int health_fade; // Health fade period (logic frames/unit) int damage; // Damage player inflicts when colliding with // another object int bolts; // maximum active at a time int noseloadtime; // logic frames per nose shot int noseheatup; // nose cannon heatup per shot int nosecooling; // nose cannon cooling speed int altfire; // use wing mounted cannons and stuff int tailloadtime; // logic frames per tail shot int tailheatup; // tail cannon heatup per shot int tailcooling; // tail cannon cooling speed int bolt_damage; // Damage inflicted by player fire bolt // Enemies int rock_health; int rock_damage; game_t(); void reset(); void set(game_types_t tp, skill_levels_t sk); }; extern game_t game; #endif /*_KOBO_GAME_H_*/ KoboDeluxe-0.5.1/gamectl.h0000666000175000001440000000545110510147031012261 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001, 2002, 2006, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_GAMECTL_H_ #define _KOBO_GAMECTL_H_ #include "glSDL.h" #include "config.h" #define KEY_KP_DOWN SDLK_KP2 #define KEY_KP_LEFT SDLK_KP4 #define KEY_KP_UP SDLK_KP8 #define KEY_KP_RIGHT SDLK_KP6 #define KEY_KP_DL SDLK_KP1 #define KEY_KP_DR SDLK_KP3 #define KEY_KP_UL SDLK_KP7 #define KEY_KP_UR SDLK_KP9 enum buttons_t { BTN_UP, //Joystick, arrows, numpad etc BTN_DOWN, BTN_LEFT, BTN_RIGHT, BTN_UL, BTN_UR, BTN_DL, BTN_DR, BTN_INC, // + BTN_DEC, // - BTN_NEXT, // PageUp BTN_PREV, // PageDn BTN_YES, // 'Y' BTN_NO, // 'N' BTN_FIRE, //ctrl, fire button, mouse button,... BTN_START, //Space BTN_SELECT, //Return, enter,... BTN_EXIT, //ESC BTN_PAUSE, //Pause or P; also used as an internal event. BTN_CLOSE, //Window close button, ALT-F4,... BTN_BACK, //Backspace BTN_F1, //Function keys BTN_F2, BTN_F3, BTN_F4, BTN_F5, BTN_F6, BTN_F7, BTN_F8, BTN_F9, BTN_F10, BTN_F11, BTN_F12 }; enum mousemodes_t { MMD_OFF = 0, MMD_CROSSHAIR, MMD_RELATIVE }; class gamecontrol_t { static int r_delay, r_interval; static int afire; static int space; static int left, up, down, right, ul, ur, dl, dr; static int shot; static int direction, new_direction; static int latch_timer; static int movekey_pressed; static void change(); public: gamecontrol_t(); static void init(int always_fire); static void repeat(int delay, int interval); static void clear(); static int map(SDLKey sym); static void process(); // Call every frame! static void press(int k); static void release(int k); static void mouse_press(int n); static void mouse_release(int n); static void mouse_position(int h, int v); static inline int dir() { return direction; } static inline int get_shot() { return shot || afire; } static inline int dir_push() { return movekey_pressed; } }; extern gamecontrol_t gamecontrol; #endif //_KOBO_KEY_H_ KoboDeluxe-0.5.1/gamestate.h0000644000175000001440000000431310254107557012625 00000000000000/*(LGPL) ------------------------------------------------------------ Game State Manager ------------------------------------------------------------ * Copyright (C) 2001-2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GAMESTATEMANAGER_H_ #define _GAMESTATEMANAGER_H_ class gamestatemanager_t; class gamestate_t { friend class gamestatemanager_t; private: gamestate_t *next; //LIFO stack gamestatemanager_t *manager; protected: const char *name; int unicode; //for last press()/release() void pop(); virtual void press(int button); virtual void release(int button); virtual void pos(int x, int y); virtual void delta(int dx, int dy); virtual void enter(); virtual void leave(); virtual void yield(); virtual void reenter(); virtual void frame(); //Control system stuff virtual void pre_render(); //Background rendering virtual void post_render(); //Foreground rendering public: gamestate_t(); virtual ~gamestate_t(); }; class gamestatemanager_t { private: gamestate_t *top; //Stack top public: gamestatemanager_t(); ~gamestatemanager_t(); /* Event router interface */ void press(int button, int unicode = 0); void release(int button, int unicode = 0); void pos(int x, int y); void delta(int dx, int dy); /* CS frame and rendering callbacks */ void frame(); void pre_render(); void post_render(); /* State management */ void change(gamestate_t *gs); void push(gamestate_t *gs); void pop(); gamestate_t *current(); gamestate_t *previous(); }; #endif /*_GAMESTATEMANAGER_H_*/ KoboDeluxe-0.5.1/kobo.h0000666000175000001440000000660710733642215011616 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2005, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_H_ #define _KOBO_H_ #include "gfxengine.h" #include "window.h" #include "display.h" #include "filemap.h" #include "prefs.h" #include "radar.h" #include "dashboard.h" #include "sound.h" #include "region.h" /*---------------------------------------------------------- Singletons ----------------------------------------------------------*/ extern KOBO_sound sound; /*---------------------------------------------------------- Globals ----------------------------------------------------------*/ class kobo_gfxengine_t : public gfxengine_t { void frame(); void pre_render(); void post_render(); public: kobo_gfxengine_t(); }; extern kobo_gfxengine_t *gengine; extern filemapper_t *fmap; extern prefs_t *prefs; extern screen_window_t *wscreen; extern dashboard_window_t *wdash; extern bargraph_t *whealth; extern bargraph_t *wtemp; extern bargraph_t *wttemp; extern radar_map_t *wmap; extern radar_window_t *wradar; extern window_t *wmain; extern display_t *dhigh; extern display_t *dscore; extern display_t *dstage; extern display_t *dships; extern RGN_region *logo_region; extern int mouse_x, mouse_y; extern int mouse_left, mouse_middle, mouse_right; extern int exit_game; /* Sprite priority levels */ #define LAYER_OVERLAY 0 // Mouse crosshair #define LAYER_BULLETS 1 // Bullets - most important! #define LAYER_FX 2 // Explosions and similar effects #define LAYER_PLAYER 3 // Player and fire bolts #define LAYER_ENEMIES 4 // Enemies #define LAYER_BASES 5 // Bases and stationary enemies /* Graphics banks */ typedef enum { B_TILES1 = 0, B_TILES2, B_TILES3, B_TILES4, B_TILES5, B_OLDSTARS, B_CROSSHAIR, B_PLAYER, B_BULLETS, B_BULLETEXPL, B_RING, B_RINGEXPL, B_BOMB, B_BOMBDETO, B_BOLT, B_BOLTEXPL, B_EXPLO1, B_EXPLO3, B_EXPLO4, B_EXPLO5, B_ROCK1, B_ROCK2, B_ROCK3, B_ROCKEXPL, B_BMR_GREEN, B_BMR_PURPLE, B_BMR_PINK, B_FIGHTER, B_MISSILE1, B_MISSILE2, B_MISSILE3, B_BIGSHIP, B_NOISE, B_HITNOISE, B_FOCUSFX, B_SCREEN, B_FRAME_TL, B_FRAME_TR, B_FRAME_BL, B_FRAME_BR, B_LOGO, B_LOGOMASK, B_LOGODELUXE, B_BRUSHES, B_HIGH_BACK, B_SCORE_BACK, B_RADAR_BACK, B_SHIPS_BACK, B_STAGE_BACK, B_HEALTH_LID, B_TEMP_LID, B_TTEMP_LID, B_LOADING, B_NORMAL_FONT, B_MEDIUM_FONT, B_BIG_FONT, B_COUNTER_FONT } KOBO_Banks; #define NOALPHA_THRESHOLD 64 #define INTRO_SCENE -100000 typedef enum { STARFIELD_NONE = 0, STARFIELD_OLD, STARFIELD_PARALLAX } KOBO_StarfieldModes; #endif // _KOBO_H_ KoboDeluxe-0.5.1/kobolog.h0000644000175000001440000000236107744604704012316 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - Logger definitions ------------------------------------------------------------ * Copyright (C) 2003, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KOBOLOG_H #define KOBOLOG_H #include "logger.h" #ifdef __cplusplus extern "C" { #endif /* Critical error messages: "Huston, we have a problem." */ #define CELOG 5 /* Debug messages; level 2: Detailed */ #define D2LOG 6 /* Debug messages; level 3: Deep Hack Mode stuff */ #define D3LOG 7 #ifdef __cplusplus }; #endif #endif /* KOBOLOG_H */ KoboDeluxe-0.5.1/logger.h0000644000175000001440000000777207744605005012147 00000000000000/*(LGPL) --------------------------------------------------------------------------- logger.h - Simple logger with redirection --------------------------------------------------------------------------- * Copyright (C) 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef DO_LOGGER_H #define DO_LOGGER_H #include #ifdef __cplusplus extern "C" { #endif /* TODO: Levels sending to multiple targets. TODO: Printing to multiple levels. */ #define LOG_TARGETS 8 #define LOG_LEVELS 32 /* * Standard log levels (so libs and stuff can share your logger! :-) */ #define ULOG 0 /* User: Messages meant for normal users */ #define WLOG 1 /* Warning: Warning messages */ #define ELOG 2 /* Error: Error messages */ #define VLOG 3 /* Verbose: Messages for advanced users */ #define DLOG 4 /* Debug: Debug messages */ typedef enum { LOG_ANSI = 0x00000001, /* Use ANSI escape codes */ LOG_HTML = 0x00000002, /* Use HTML formatting tags */ LOG_TIMESTAMP = 0x00000100 /* Timestamp messages */ } LOG_flags; typedef enum { LOG_COLORS = 0x000f, /* Mask for color bits */ LOG_NOCOLOR = 0, /* Don't try to change! */ LOG_BLACK, LOG_RED, LOG_GREEN, LOG_YELLOW, LOG_BLUE, LOG_MAGENTA, LOG_CYAN, LOG_WHITE, LOG_BRIGHT = 0x0100, /* High intensity colors */ LOG_STRONG = 0x0200, /* Bold or underlined */ LOG_BLINK = 0x0400 /* Blinking, if possible */ } LOG_attributes; /* * The usual open/close calls... * * Note that log_close() may write footers and stuff to files, * so you may get slightly broken log files if you exit * without calling it! * * log_open() returns a negative value in case of failure. */ int log_open(void); void log_close(void); /* * Send output through 'target' to 'stream'. 'stream' must be * a valid stdio stream opened for output. * * If 'target' is -1, all targets are changed. */ void log_set_target_stream(int target, FILE *stream); /* * Send output through 'target' to 'callback'. The callback * will receive the value passed as 'handle' as it's first * argument, followed by the data to output. (NULL terminated * string.) The callback should return the number of bytes * successfully handled, or, in case of failure, a negative * value. * * If 'target' is -1, all targets are changed. */ void log_set_target_callback(int target, int (*callback)(int handle, const char *data), int handle); /* * Set formatting flags for 'target'. * * If 'target' is -1, all targets are changed. */ void log_set_target_flags(int target, unsigned flags); /* * Send output through 'level' to 'target'. 'levels' is a bit * mask with one bit for each log level. * * If 'level' is -1, all levels are changed. */ void log_set_level_target(int level, int target); /* * Set attributes for 'level'. * * If 'level' is -1, all levels are changed. */ void log_set_level_attr(int level, unsigned attr); /* * Print 'text' to 'level'. 'level' is the index of the log * level to print to. No formatting will be done, and the * output will be followed by a "newline". * * Returns a negative value in case of failure. */ int log_puts(int level, const char *text); /* * Format and print to 'level'. 'level' is the index of the * log level to print to. * * Returns a negative value in case of failure. */ int log_printf(int level, const char *format, ...); #ifdef __cplusplus }; #endif #endif /* DO_LOGGER_H */ KoboDeluxe-0.5.1/manage.h0000666000175000001440000000626710733137747012127 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_MANAGE_H_ #define _KOBO_MANAGE_H_ #include "glSDL.h" #include "score.h" class _manage { static int blank; static int next_state_out; static int next_state_next; static int game_seed; static int bonus_next; static int scroll_jump; static int delay_count; static int introtime; static int rest_cores; static int exit_manage; static int playing; static int _get_ready; static int _game_over; static s_hiscore_t hi; static int noise_flash; static int noise_duration; static int noise_timer; static float noise_level; static int intro_x; static int intro_y; static int show_bars; static void next_scene(); static void retry(); static int scene_num; static int score; static float disp_health; static float disp_temp; static int flush_score_count; static int flush_ships_count; static int score_changed; static int ships_changed; static void put_health(int force = 0); static void put_temp(int force = 0); static void put_info(); static void put_score(); static void put_ships(); static void flush_score(); static void flush_ships(); static void game_stop(); static void run_noise(); public: static int ships; static void init(); static void set_bars(); static void init_resources_title(); static void init_resources_to_play(int newship); static void noise(int duration, int flash); static void noise_out(int duration); static void noise_damage(float amt); static void update(); static void run_intro(); static void run_pause(); static void run_game(); static void lost_myship(); static void destroyed_a_core(); static void add_score(int sc); static void key_down(SDLKey sym); static void key_up(SDLKey sym); static int title_blank() { return blank; } static void select_next(int redraw_map = 1); static void select_prev(int redraw_map = 1); static void regenerate(); static void select_scene(int scene, int redraw_map = 1); static int scene() { return scene_num; } static void abort(); static void freeze_abort(); static int aborted() { return exit_manage; } static void reenter(); static int game_stopped() { return !playing; } static int get_ready(); static void game_start(); static int game_over(); }; extern _manage manage; #endif //_KOBO_MANAGE_H_ KoboDeluxe-0.5.1/map.h0000666000175000001440000000402410723055614011430 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2002, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef XKOBO_H_MAP #define XKOBO_H_MAP #include "config.h" #define SITE_MAX 1024 #define WALL 1 // Tile state bits #define U_MASK (1<<0) #define R_MASK (1<<1) #define D_MASK (1<<2) #define L_MASK (1<<3) #define CORE (1<<4) #define HIT_MASK (CORE | U_MASK | R_MASK | D_MASK | L_MASK) #define HARD (1<<5) #define SPACE (1<<6) #define MAP_BITS(x) ((x) & 0xff) #define IS_SPACE(x) ((x) & SPACE) class _map { public: void init(); void make_maze(int x, int y, int difx, int dify); void convert(unsigned ratio); /* ratio < 64 */ inline unsigned short &pos(int x, int y) { x &= MAP_SIZEX - 1; y &= MAP_SIZEY - 1; return data[(y << MAP_SIZEX_LOG2) + x]; } void clearpos(int x, int y); protected: int sitex[SITE_MAX]; int sitey[SITE_MAX]; int site_max; unsigned short data[1 << (MAP_SIZEX_LOG2 + MAP_SIZEY_LOG2)]; int maze_pop(); void maze_push(int x, int y); void maze_move_and_push(int x, int y, int d); int maze_judge(int cx, int cy, int dx, int dy, int x, int y); }; #endif // XKOBO_H_MAP KoboDeluxe-0.5.1/myship.h0000666000175000001440000000573710733146571012204 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001, 2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef XKOBO_H_MYSHIP #define XKOBO_H_MYSHIP #include "config.h" #include "gfxengine.h" #include "game.h" #define ABS(x) (((x)>=0) ? (x) : (-(x))) #define MAX(x,y) (((x)>(y)) ? (x) : (y)) //---------------------------------------------------------------------------// enum _myship_state { normal, dead }; class _myship { static _myship_state _state; static int di; /* direction */ static int virtx, virty; /* scroll position */ static int x, y; static int _health; static int health_time; static int explo_time; static int nose_reload_timer; static int nose_temperature; static int nose_alt; static int tail_reload_timer; static int tail_temperature; static int tail_alt; static int lapx, lapy; static int boltx[MAX_BOLTS], bolty[MAX_BOLTS]; static int boltdx[MAX_BOLTS], boltdy[MAX_BOLTS]; static int boltst[MAX_BOLTS]; /* For the gfxengine connection */ static cs_obj_t *object; static cs_obj_t *bolt_objects[MAX_BOLTS]; static cs_obj_t *crosshair; static void state(_myship_state s); static void shot_single(int i, int dir, int offset); static void apply_position(); static void explode(int x, int y); public: _myship(); static inline int get_x() { return x; } static inline int get_y() { return y; } static inline int get_virtx() { return virtx; } static inline int get_virty() { return virty; } static inline int get_nose_temp() { return nose_temperature; } static inline int get_tail_temp() { return tail_temperature; } static int init(); static void off(); static int move(); static int put(); static void put_crosshair(); static int xkobo_shot(); static int nose_fire(); static int tail_fire(); static int hit_structure(); static int hit_bolt(int ex, int ey, int hitsize, int health); static void hit(int dmg); static int health() { return _health; } static void health(int h) { _health = h; } static void health_bonus(int h); static void set_position(int px, int py); static int alive() { return _state == normal; } }; extern _myship myship; #endif // XKOBO_H_MYSHIP KoboDeluxe-0.5.1/options.h0000666000175000001440000000322110711213472012337 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001, 2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_OPTIONS_H_ #define _KOBO_OPTIONS_H_ #include "cfgform.h" #include "vidmodes.h" class system_options_t : public config_form_t { public: void build(); }; class video_options_t : public config_form_t { int showmodes; int showlow; int firstbuild; public: video_options_t() { showmodes = VMM_PC; showlow = 0; firstbuild = 1; } void build(); }; class graphics_options_t : public config_form_t { public: void build(); }; class audio_options_t : public config_form_t { public: void build(); void undo_hook(); }; class control_options_t : public config_form_t { public: void build(); }; class game_options_t : public config_form_t { public: void build(); void undo_hook(); }; #endif //_KOBO_OPTIONS_H_ KoboDeluxe-0.5.1/pfile.h0000644000175000001440000001122207472323454011753 00000000000000/*(LGPL) --------------------------------------------------------------------------- pfile.h - Portable File Access Toolkit --------------------------------------------------------------------------- * Copyright (C) 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _PFILE_H_ #define _PFILE_H_ //////////////////////////////////////////////////////////// // Note that these classes can keep track of only one // chunk at a time! Recursive chunk-inside-chunk is *NOT* // supported. //////////////////////////////////////////////////////////// //Create a little endian "FOURCC" ID code. (That is, 'a' will be //first if the integer result is stored in little endian format //in a file.) #define MAKE_4CC(a, b, c, d) \ ((a)&0xff | ((b)<<8)&0xff00 | \ ((c)<<16)&0xff0000 | ((d)<<24)&0xff000000) //////////////////////////////////////////////////////////// // pfile_t - Portable File Access Base Class //////////////////////////////////////////////////////////// // Handles the reading and writing of data from/to file // via the internal buffer. // // Reading can be done either directly from the file, or // through the internal buffer. // // To read through the buffer, the desired number of // bytes (for example, all bytes of a chunk) must be // read into the buffer using read_buffer(). Subsequent // reads will be from the buffer, and end-of-buffer is // treated like EOF. // // Writing is always done to the buffer. To actually // write data to file, call write_buffer(). // // IMPORTANT: // Written data is *lost* if the pfile object // is destroyed before write_buffer() is called! // // Reading RIFF style chunks: // Use chunk_read() to read the entire chunk into // the internal buffer. If this succeeds, // chunk_type() and chunk_size() will return // information about the chunk, and subsequent // read() calls will read from the data section of // the chunk. Use chunk_end() to stop reading, and // discard the buffer. The next read() will start // at the first byte after the end of the chunk. // // Writing RIFF style chunks: // Use chunk_write() to set the type of the chunk // to write. Subsequent write()ing will be done to // the internal buffer, which will grow as needed. // Use chunk_end() to write the whole chunk, with // the correct size and all data. chunk_end() will // discard the buffer and return the object to // "direct" operation. // class pfile_t { FILE *f; //Just a plain file handle... int _status; // < 0 if there was an error int bufsize; //Actual malloc()ed size of buffer int bufused; //Current buffer write position int bufpos; //Current buffer read position char *buffer; //Read/write buffer int chunk_id; //Chunk type ID int chunk_writing; //1 if we're building a chunk for writing // Initialize buffer for writing. Subsequent write() calls // will write to the buffer instead of the file. int buffer_init(); // Initialize buffer, and read 'len' bytes into it. // Subsequent read() calls will read from the buffer // instead of the file. int buffer_read(int len); //Unbuffered write operations int write_ub(void *data, int len); int write_ub(unsigned int x); int write_ub(int x); public: pfile_t(FILE *file); virtual ~pfile_t(); int status(); //Read and reset current status. int status(int new_status); //Set (provided the current status // >= 0) and return (new) status //These return # of bytes read, or -1 in case of EOF, or an error. int read(void *data, int len); int read(unsigned int &x); int read(int &x); void buffer_close(); //Discard the buffer and return to //"direct" operation. //These return # of bytes written, or -1 in case of EOF, or an error. int write(void *data, int len); int write(unsigned int x); int write(int x); int buffer_write(); //Write the whole buffer to the file. //This will flush the buffer as well. //RIFF style chunk handling int chunk_read(); int chunk_type() { return chunk_id; } int chunk_size() { return bufused; } int chunk_write(int id); int chunk_end(); }; #endif KoboDeluxe-0.5.1/prefs.h0000666000175000001440000001041210734121114011757 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003, 2007 David Olofson * Copyright (C) 2005 Erik Auerswald * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_PREFS_H_ #define _KOBO_PREFS_H_ #include "aconfig.h" #include "cfgparse.h" class prefs_t : public config_parser_t { public: //System options int logfile; //Log messages to log.txt/html int logformat; //0: text, 1: ANSI, 2: HTML int logverbosity; //Input options int use_joystick; int joystick_no; //which joystick to use int use_mouse; int mousemode; int broken_numdia; int dia_emphasis; int always_fire; int mousecapture; //Game options int filter; //Use motion filtering int timefilter; //Delta time filter int scrollradar; //Radar display mode int countdown; //"Get Ready" countdown int starfield; //None/Old/parallax int stars; //Number of parallax stars int overheatloud; //Overheat warning loudness int cannonloud; //Cannon loudness //Sound: System int use_sound; //Enable sound int use_music; //Enable "real" music int cached_sounds; //Use prerendered waveforms int use_oss; //Use OSS audio driver int samplerate; int latency; //Audio latency in ms int mixquality; //Mixer quality control int volume; //Digital master volume //Sound: Mixer int intro_vol; //Intro music volume int sfx_vol; //Sound effects volume int music_vol; //In-game music volume //Sound: Master Effects int reverb; //Master reverb level int vol_boost; //Master volume boost //Video settings int fullscreen; //Use fullscreen mode int videodriver; //Internal video driver int width; //Screen/window width int height; //Screen/window height int aspect; //Pixel aspect ratio * 1000 int depth; //Bits per pixel int max_fps; //Maximum fps int max_fps_strict; //Strictly regulated fps limiter int doublebuf; //Use double buffering int shadow; //Use software shadow buffer int videomode; //New video mode codes int vsync; //Vertical (retrace) sync int pages; //Number of physical video pages //Graphics settings int scalemode; //Scaling filter mode int use_dither; int dither_type; int broken_rgba8; //For some OpenGL setups int alpha; //Alpha blending int brightness; //Graphics brightness int contrast; //Graphics contrast //File paths cfg_string_t dir; //Path to kobo-deluxe/ cfg_string_t gfxdir; //Path to gfx/ cfg_string_t sfxdir; //Path to sfx/ cfg_string_t scoredir; //Path to scores/ //Obsolete stuff (compatibility) int o_size; //Screen scale int o_wait_msec; //ms per control system frame cfg_string_t o_bgm_indexfile; //Ext playlist path int o_threshold; //Limiter threshold int o_release; //Limiter release rate int o_internalres; //Internal resolution for OpenGL //"Hidden" stuff ("to remember until next startup") int last_profile; //Last used player profile int number_of_joysticks; //no of connected joysticks void init(); void postload(); /* "Commands" - never written to config files */ int cmd_showcfg; int cmd_hiscores; int cmd_override; int cmd_debug; int cmd_fps; int cmd_noframe; int cmd_midi; int cmd_cheat; //Unlimited lives; select any starting stage int cmd_indicator; //Enable collision testing mode int cmd_pushmove; //Stop when not holding any direction down int cmd_noparachute; //Disable SDL parachute int cmd_pollaudio; //Use polling based audio instead of thread int cmd_autoshot; //Take ingame screenshots int cmd_help; //Show help and exit int cmd_options_man; //Output OPTIONS doc in Un*x man source format }; #endif //_KOBO_PREFS_H_ KoboDeluxe-0.5.1/radar.h0000666000175000001440000000467210711253463011754 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2005-2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KOBO_RADAR_H #define KOBO_RADAR_H #include "window.h" enum radar_modes_t { RM__REINIT, // Reinitialize (lost windows etc) RM_OFF, // Gray, empty RM_RADAR, // Radar display RM_SHOW, // Show map (no player ship cursor) RM_NOISE, // Radar interference RM_INFO // Scrolling info display }; // The off-screen map window class radar_map_t : public window_t { public: int w, h; //Map size (tiles) Uint32 pixel_core; //Pixel colors Uint32 pixel_launcher; Uint32 pixel_hard; Uint32 pixel_bg; radar_map_t(); void refresh(SDL_Rect *r); void update(int x, int y, int force); //Update one tile }; // The on-screen radar window class radar_window_t : public window_t { radar_modes_t _mode; int old_scrollradar; //To detect prefs change int xpos, ypos; //Player position (tiles) int xoffs, yoffs; //Scroll offset (tiles) int pxoffs, pyoffs; //Scroll offset for player marker int platched; //p*offset latched yet? int time; //for delta time calc int refresh_pos; //Sweeping refresh posn void sweep(); //Incremental sweeping refresh void radar(); //Drive any actual radar mode void noise(); //Render noise effect void set_scroll(int xs, int ys);//Set map scroll offset public: radar_window_t(); void refresh(SDL_Rect *r); void mode(radar_modes_t newmode);//Set radar mode void update(int mx, int my); //Update map + radar void update_player(int px, int py);//Update player cursor void frame(); //Track player, drive logic etc... }; #endif // KOBO_RADAR_H KoboDeluxe-0.5.1/random.h0000666000175000001440000000366710711350161012137 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2002, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_RANDOM_H_ #define _KOBO_RANDOM_H_ #include #include "glSDL.h" class rand_num_t { Uint32 seed; public: void init(Uint32 _seed = 0) { if(_seed) seed = _seed; else seed = SDL_GetTicks(); } Uint32 get_seed() { return seed; } Uint32 get() { seed *= 1566083941UL; seed++; seed &= 0xffffffffUL; return seed; } Uint32 get(Uint32 bit) { seed *= 1566083941UL; seed++; seed &= 0xffffffffUL; return (seed >> (32 - bit)); } }; //This instance is *ONLY* for map generation and //pure game AI stuff!!! Stealing numbers from here //will screw up demo playback totally, as demos //record only the seed used for each level; not //every random number used. extern rand_num_t gamerand; //Use this "public" random number generator for //other stuff, like explosion effects, and things //that may pick different amounts of numbers //depending on engine version, configuration, //computer speed and the like. extern rand_num_t pubrand; #endif //_KOBO_RANDOM_H_ KoboDeluxe-0.5.1/scenes.h0000666000175000001440000000261010563061117012127 00000000000000 /* * XKOBO, a video-oriented game * Copyright (C) 1995,1996 Akira Higuchi * a-higuti@math.hokudai.ac.jp * Copyright (C) 2006, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. * */ #ifndef XKOBO_H_SCENES #define XKOBO_H_SCENES #include "config.h" #include "enemies.h" #define SCENE_ENEMY_MAX 20 #define SCENE_BASE_MAX 40 struct enemy_set { const enemy_kind *kind; int num; int speed; }; struct _base { int x, y, h, v; }; struct _scene { int ratio; int startx; int starty; const enemy_kind *ek1; int ek1_interval; const enemy_kind *ek2; int ek2_interval; int enemy_max; enemy_set enemy[SCENE_ENEMY_MAX]; int base_max; _base base[SCENE_BASE_MAX]; }; extern const _scene scene[]; #endif // XKOBO_H_SCENES KoboDeluxe-0.5.1/score.h0000666000175000001440000001460210711421614011763 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001, 2002 David Olofson * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_SCORE_H_ #define _KOBO_SCORE_H_ #include "config.h" #include "game.h" #include "pfile.h" #define MAX_PROFILES 100 #define MAX_HIGHSCORES 100 #define HISCORE_SAVE_MAX 100 #define PROFILE_VERSION 1 //DO NOT CHANGE! (Will break the file format.) #define SCORE_NAME_LEN 64 /*---------------------------------------------------------- s_*_t - Profile and score data wrappers ----------------------------------------------------------*/ // File format: // * The first 74 bytes are identical to those in old // XKobo score files, for compatibility reasons. // // * New sections are added in the form of RIFF style // chunks, starting at offset 74 in the file. (See // pfile.(h|cpp) for details.) // // * Chunks of unknown types are IGNORED, and are // therefore LOST if the file is overwritten by an // older version of Kobo Deluxe. // // * Extra data beyond the end of a chunk (ie data that // is added by a later version of Kobo Deluxe) is // IGNORED, and is therefore LOST if the file is // overwritten by an older version of Kobo Deluxe. // // * New versions may ADD data to chunks, but never // remove data from chunks. // // * New versions may add new chunk types. // // * New versions may remove old chunk types, although // this is STRONGLY DISCOURAGED, as it may render // old Kobo Deluxe versions seeing a vertually empty // profile file... // // * Strings are stored as fixed length, null padded // arrays of 64 bytes. All strings should have at // least one terminating null byte. // // * Signed and unsigned int are stored as little // endian 32 bit integers. // // Version 1 chunks: // // PROF: //Player profile header // Sint32 version; // Sint32 skill; // Sint32 handicap; // Sint32 color1; // Sint32 color2; // // HISC: //Hiscore entry // Uint32 start_date; // Uint32 end_date; // Sint32 skill; // Uint32 score; // Sint32 start_scene; // Sint32 end_scene; // Sint32 end_lives; // Sint32 end_health; // Uint32 playtime; // Sint32 saves; // Sint32 loads; // Sint32 gametype; // struct s_profile_t; // Stored as one "HISC" chunk for each entry. // No "real" maximum number of entries per profile, // but the current implementation uses an array of // HISCORE_SAVE_MAX entries. // FIXME: Should be dynamic, although there should // FIXME: probably be some sensible limit regardless. struct s_hiscore_t { // For all of the below, -1 (signed) or 0 (unsigned) means "unknown". unsigned int start_date; //Seconds since 2000...? unsigned int end_date; //Seconds since 2000...? int skill; //Skill setting used int gametype; //Single/cooperative/deathmatch/... unsigned int score; //Score achieved int start_scene; //Scene player started on int end_scene; //Scene player quit or died on int end_lives; //# of lives when player quit int end_health; //Health when player quit unsigned int playtime; //Effective play time, logic frames int saves; //# of times game was saved int loads; //# of times game was aborted + loaded // The fields below this line are not saved to file. s_profile_t *profile; //Profile this entry belongs to, //if any. (May be NULL!) char name[SCORE_NAME_LEN]; //(Kludge for highscore table.) s_hiscore_t(); void clear(); //Reset and clear all fields. void read(pfile_t &f); //Read this struct from pfile 'f'. void write(pfile_t &f); //Write this struct to pfile 'f'. }; // Stored as one "PROF" chunk. struct s_profile_t { //Old stuff (from XKobo) unsigned int best_score; //Best score int last_scene; //Last scene completed char name[SCORE_NAME_LEN]; //Player name //New stuff (for Kobo Deluxe 0.4) unsigned int version; //Profile file format version int skill; //Player skill setting int handicap; //Player handicap. 0 == none. int color1; //Primary color. (-1 == default) int color2; //Secondary color. (-1 == default) s_hiscore_t hiscoretab[HISCORE_SAVE_MAX]; // The fields below this line are not saved to file. unsigned int hiscores; //# of hiscores stored char *filename; s_profile_t(); ~s_profile_t(); void clear(); //Reset and clear all fields. int load(const char *fn); //Load from file 'fn'. int save(); //Save back to file. s_hiscore_t *best_hiscore(); }; /*---------------------------------------------------------- score_manager_t ----------------------------------------------------------*/ class score_manager_t { s_profile_t profiles[MAX_PROFILES]; unsigned int currentProfile; public: unsigned int highs; s_hiscore_t high_tbl[MAX_HIGHSCORES]; int numProfiles; score_manager_t(); ~score_manager_t(); int addPlayer(const char *name); void init(); s_profile_t *profile(int prof = -1) { if(prof < 0) return profiles + currentProfile; else return profiles + prof; } // NOTE: hiscore() with no argument (or -2) returns // the best known score of all found profiles; NOT // that of the current profile. int highscore(int prof = -2); int last_scene(int prof = -1) { if(prof < 0) return profiles[currentProfile].last_scene; else return profiles[prof].last_scene; } char *name(int prof = -1) { if(prof < 0) return profiles[currentProfile].name; else return profiles[prof].name; } void select_profile(int prof); int current_profile() { return currentProfile; } void record(s_hiscore_t *entry, int force = 0); void gather_high_scores(int placeholders = 0); void print_high_scores(); }; extern score_manager_t scorefile; #endif //_KOBO_SCORE_H_ KoboDeluxe-0.5.1/screen.h0000666000175000001440000000573510730563507012147 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996 Akira Higuchi * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_SCREEN_H_ #define _KOBO_SCREEN_H_ #include "map.h" #include "radar.h" #define STAR_COLORS 16 #define STAR_ZBITS 10 #define STAR_Z0 256 class window_t; struct KOBO_Star { short x; short y; unsigned short z; }; class _screen { protected: static int scene_num; static int level; static int generate_count; static _map map; static int scene_max; static int show_title; static int do_noise; static float _fps; static float scroller_speed; static float target_speed; static int noise_y; static int noise_h; static int noise_source; static float noise_fade; static float noise_bright; static float noise_depth; static int highlight_y; static int highlight_h; static int hi_sc[10]; static int hi_st[10]; static char hi_nm[10][20]; static int nstars; static KOBO_Star *stars; static Uint32 starcolors[STAR_COLORS]; static int star_oxo; static int star_oyo; static void render_noise(window_t *win); static void render_highlight(window_t *win); static void render_title_plasma(int t, float fade, int y, int h); static void render_title_noise(float fade, int y, int h, int bank, int frame); static void render_starfield(window_t *win, int xo, int yo); public: ~_screen(); static radar_modes_t radar_mode; // Last set radar mode static void init(); static void init_scene(int sc); static int prepare(); static void generate_fixed_enemies(); static inline int get_map(int x, int y) { return map.pos(x, y); } static void set_map(int x, int y, int n); static void set_highlight(int y, int h); static void set_noise(int source, float fade, float bright, float depth); static void render_background(window_t * win); static void render_fx(window_t * win); static void title(int t, float fade, int mode); static void init_highscores(); static void highscores(int t, float fade); static void credits(int t); static void help(int t); static void scroller(); static void fps(float f); static float fps() { return _fps; } static void noise(int on); }; extern _screen screen; #endif //_KOBO_SCREEN_H_ KoboDeluxe-0.5.1/sound.h0000644000175000001440000001066610733664375012023 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - Wrapper for Sound Control ------------------------------------------------------------ * Copyright (C) 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KOBO_SOUND_H #define KOBO_SOUND_H #include "kobosfx.h" /* Sound groups */ #define SOUND_GROUP_UI 0 #define SOUND_GROUP_SFX 1 #define SOUND_GROUP_UIMUSIC 2 #define SOUND_GROUP_BGMUSIC 3 class KOBO_sound { static int sounds_loaded; static int music_loaded; /* In-game sfx stuff */ static int time; static int _period; static int sfx2d_tag; static int listener_x; static int listener_y; static int wrap_x; static int wrap_y; static int scale; static int panscale; static int firing; static int overheat; static unsigned rumble; public: KOBO_sound(); ~KOBO_sound(); /*-------------------------------------------------- Open/close --------------------------------------------------*/ static int open(); static void prefschange(); static int load(int (*prog)(const char *msg), int force); static void stop(); static void close(); /*-------------------------------------------------- Main controls --------------------------------------------------*/ static void master_reverb(float rvb); static void set_boost(int vol_boost); static void sfx_volume(float vol); static void intro_volume(float vol); static void music_volume(float vol); static void period(int ms); // 0 to reset time static void frame(); static void run(); /* Play a user interface sound */ static void play(int wid, int vol = 65536, int pitch = 60<<16, int pan = 0); /* Play a sound at a specific location on the map */ static void g_play(int wid, int x, int y, int vol = 65536, int pitch = 60<<16); /* Play a sound right where the listener is. */ static void g_play0(int wid, int vol = 65536, int pitch = 60<<16); /*-------------------------------------------------- In-game sound --------------------------------------------------*/ /* Play in-game music */ static void g_music(int wid); /* Set listener position */ static void g_position(int x, int y); /* Set world size for wrapping */ static void g_wrap(int w, int h); /* * Set world scale. 'maxrange' is the distance where * a sound is out of the audible range. */ static void g_scale(int maxrange, int pan_maxrange); /* Various sound effects */ static void g_player_fire(); static void g_player_fire_off(); static void g_player_overheat(int classic = 0); static void g_player_damage(); static void g_player_explo_start(); static void g_bolt_hit(int x, int y); static void g_bolt_hit_rock(int x, int y); static void g_base_node_explo(int x, int y); static void g_base_core_explo(int x, int y); static void g_pipe_rumble(int x, int y); static void g_enemy_explo(int x, int y); static void g_rock_explo(int x, int y); static void g_ring_explo(int x, int y); static void g_bomb_deto(int x, int y); static void g_launch_ring(int x, int y); static void g_launch_beam(int x, int y); static void g_launch_bomb(int x, int y); static void g_launch(int x, int y); static void g_m_launch_ring(int x, int y); static void g_m_launch_beam(int x, int y); static void g_m_launch_bomb(int x, int y); static void g_m_launch(int x, int y); /*-------------------------------------------------- UI sound effects --------------------------------------------------*/ /* Low level interface */ static void ui_music(int wid); /* Various UI effects */ static void ui_noise(int n); static void ui_ok(); static void ui_cancel(); static void ui_move(); static void ui_tick(); static void ui_error(); static void ui_play(); static void ui_pause(); static void ui_ready(); static void ui_countdown(int remain); static void ui_oneup(); static void ui_gameover(); }; #endif /* KOBO_SOUND_H */ KoboDeluxe-0.5.1/states.h0000644000175000001440000003053310730570661012160 00000000000000/*(GPL) ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 2001-2003 David Olofson * Copyright (C) 2002 Jeremy Sheeley * Copyright (C) 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_STATES_H_ #define _KOBO_STATES_H_ #include "gamestate.h" #include "gamectl.h" #include "form.h" #include "kobo.h" #include "options.h" #define MENU_TAG_OK 99 #define MENU_TAG_CANCEL 100 class kobo_basestate_t : public gamestate_t { public: kobo_basestate_t(); void frame(); void pre_render(); void post_render(); }; /*---------------------------------------------------------- Intro ----------------------------------------------------------*/ class st_introbase_t : public kobo_basestate_t { protected: int timer, start_time; public: int duration; st_introbase_t *inext; st_introbase_t(); void enter(); void reenter(); void press(int button); void frame(); void pre_render(); void post_render(); }; class st_intro_title_t : public st_introbase_t { public: int mode; st_intro_title_t(); void enter(); void post_render(); }; class st_intro_instructions_t : public st_introbase_t { public: st_intro_instructions_t(); void enter(); void post_render(); }; class st_intro_highscores_t : public st_introbase_t { public: st_intro_highscores_t(); void enter(); void post_render(); }; class st_intro_credits_t : public st_introbase_t { public: st_intro_credits_t(); void enter(); void post_render(); }; /*---------------------------------------------------------- In-game ----------------------------------------------------------*/ class st_game_t : public kobo_basestate_t { public: st_game_t(); void enter(); void leave(); void yield(); void reenter(); void press(int button); void frame(); void post_render(); }; class st_pause_game_t : public kobo_basestate_t { public: st_pause_game_t(); void enter(); void press(int button); void frame(); void post_render(); }; class st_get_ready_t : public kobo_basestate_t { int start_time, frame_time; int countdown; public: st_get_ready_t(); void enter(); void press(int button); void frame(); void post_render(); }; class st_game_over_t : public kobo_basestate_t { int start_time, frame_time; public: st_game_over_t(); void enter(); void press(int button); void frame(); void post_render(); }; /*---------------------------------------------------------- Menu Base ----------------------------------------------------------*/ /* * Alt 1: * Derive from this and override build() * * The tags of the widgets registered by build() will be * passed to select() of your st_menu_base_t derivate when * the widgets are activated. * * BTN_EXIT and BTN_CLOSE will both have the same effect * as activating a widget with tags 0 - which means that * tags 0 is effectively the universal "exit code". Handle * this event if you like, but keep in mind that the menu * will be closed and destroyed, and the state popped * automatically afterwards. * * Alt 2: (For advanced custom forms.) * Ignore menu_base_t and plug in any other kobo_form_t * derivate instead. * * Your custom form is expected to handle input via the * normal select()/change() API of ct_form_t, and widget * tags are passed to st_menu_base_t::select() whenever a * widget is activated. * * If your custom form doesn't use tags the way * st_menu_base_t expects, override translate() to translate * according to these rules: * No action: -1 * Exit/close/cancel: 0 * Any other functions: >0 * * Either way: * Extra communication between the st_menu_base_t::select() * handler and your custom menu will have to be implemented * in custom ways. See the options forms for examples. * * Of course, other virtual methods may still be overridden * just as with the normal Kobo forms and states this * wrapper inherits from - just keep in mind to call the * inherited versions to keep things working! * * If you want to control event sounds yourself, set the * 'sounds' field to 0. (Inside open() is soon enough.) */ class menu_base_t : public kobo_form_t { public: void open(); void close(); }; /* * Derive from this and override open(), close() and select(). * * open() should instantiate, open and return your * kobo_form_t derivate. * * close() should clean up any extra stuff. (The form will be * deleted in st_menu_base_t's destructor.) * * select() is your "widget activated" event handler. * * translate() is optional, and is used for translating * widget a tag depending on, for example, what key is used to * "activate" the widget. translate() is plugged in before * select(), and is expected to return "new" tag codes that * are passed on to select(). * * Default actions: * st_menu_base_t implements default widget actions for * some keys. These actions are performed after * translate() is called, but translate() may temporarily * disable this feature by setting the do_default_action * member to 0. * * Override escape() if you want to do something special when * the menu wants to exit the "oops, forget about this" way. * Note that this is *not* called if your select() handler * explicitly makes the menu exit. Also note that select() * will still be called with a 0 argument after escape() has * been called. */ class st_menu_base_t : public kobo_basestate_t { protected: kobo_form_t *form; int sounds; int do_default_action; public: st_menu_base_t(); ~st_menu_base_t(); void enter(); void reenter(); void leave(); void press(int button); void frame(); void post_render(); virtual kobo_form_t *open() = 0; virtual void close() { ; } virtual int translate(int tag, int button); virtual void select(int tag) = 0; virtual void escape() { ; } }; /*---------------------------------------------------------- Main Menu ----------------------------------------------------------*/ class main_menu_t : public menu_base_t { public: int start_level; virtual void buildStartLevel(int profNum); void build(); void rebuild(); }; class st_main_menu_t : public st_menu_base_t { main_menu_t *menu; public: st_main_menu_t() { name = "main_menu"; } kobo_form_t *open(); void reenter(); int translate(int tag, int button); void select(int tag); }; /*---------------------------------------------------------- Skill Menu ----------------------------------------------------------*/ class skill_menu_t : public menu_base_t { int skill; public: void set_skill(int sk) { skill = sk; }; void build(); void rebuild(); }; class st_skill_menu_t : public st_menu_base_t { skill_menu_t *menu; public: st_skill_menu_t() { name = "skill_menu"; } kobo_form_t *open(); void press(int button); void select(int tag); }; /*---------------------------------------------------------- Enter name ----------------------------------------------------------*/ class new_player_t : public kobo_form_t { public: int editing; char name[60]; unsigned currentIndex; int selection; virtual void change(int delta); virtual void build(); void open(); void close(); void rebuild(); }; class st_new_player_t : public kobo_basestate_t { public: new_player_t menu; st_new_player_t(); void enter(); void leave(); void press(int button); void frame(); void post_render(); }; /*---------------------------------------------------------- Options Main ----------------------------------------------------------*/ class options_main_t : public menu_base_t { public: void build(); }; class st_options_main_t : public st_menu_base_t { public: st_options_main_t() { name = "options_main"; } kobo_form_t *open(); void select(int tag); }; /*---------------------------------------------------------- Options Base ----------------------------------------------------------*/ class st_options_base_t : public st_menu_base_t { config_form_t *cfg_form; public: st_options_base_t() { cfg_form = NULL; } virtual config_form_t *oopen() = 0; kobo_form_t *open(); void enter(); void close(); void select(int tag); void press(int button); void escape(); }; /*---------------------------------------------------------- Options Submenues ----------------------------------------------------------*/ class st_options_system_t : public st_options_base_t { public: st_options_system_t() { name = "options_system"; } config_form_t *oopen() { return new system_options_t; } }; class st_options_video_t : public st_options_base_t { public: st_options_video_t() { name = "options_video"; } config_form_t *oopen() { return new video_options_t; } }; class st_options_graphics_t : public st_options_base_t { public: st_options_graphics_t() { name = "options_graphics"; } config_form_t *oopen() { return new graphics_options_t; } }; class st_options_audio_t : public st_options_base_t { public: st_options_audio_t() { name = "options_audio"; } config_form_t *oopen() { return new audio_options_t; } }; class st_options_control_t : public st_options_base_t { public: st_options_control_t() { name = "options_control"; } config_form_t *oopen() { return new control_options_t; } }; class st_options_game_t : public st_options_base_t { public: st_options_game_t() { name = "options_game"; } config_form_t *oopen() { return new game_options_t; } }; /*---------------------------------------------------------- Requesters ----------------------------------------------------------*/ class yesno_menu_t : public menu_base_t { public: void build(); void rebuild(); }; class st_yesno_base_t : public st_menu_base_t { yesno_menu_t *menu; protected: const char *msg; public: kobo_form_t *open(); void reenter(); void press(int button); void frame(); void post_render(); }; class st_ask_exit_t : public st_yesno_base_t { public: st_ask_exit_t(); void select(int tag); }; class st_ask_abort_game_t : public st_yesno_base_t { public: st_ask_abort_game_t(); void select(int tag); }; /*---------------------------------------------------------- Debug: Audio Engine Profiling ----------------------------------------------------------*/ extern "C" { #include "a_globals.h" }; #ifdef PROFILE_AUDIO class st_profile_audio_t : public kobo_basestate_t { int pan, pitch, shift; public: st_profile_audio_t(); void enter(); void press(int button); void pre_render(); void post_render(); }; #endif /*---------------------------------------------------------- Critical Error Screen ----------------------------------------------------------*/ class st_error_t : public kobo_basestate_t { int start_time, frame_time; const char *msg[2]; public: st_error_t(); void message(const char *error, const char *hint); void enter(); void press(int button); void frame(); void post_render(); }; extern gamestatemanager_t gsm; extern st_intro_title_t st_intro_title; extern st_intro_instructions_t st_intro_instructions; extern st_intro_highscores_t st_intro_highscores; extern st_intro_credits_t st_intro_credits; extern st_ask_exit_t st_ask_exit; extern st_game_t st_game; extern st_ask_abort_game_t st_ask_abort_game; extern st_pause_game_t st_pause_game; extern st_get_ready_t st_get_ready; extern st_game_over_t st_game_over; extern st_main_menu_t st_main_menu; extern st_skill_menu_t st_skill_menu; extern st_new_player_t st_new_player; extern st_options_main_t st_options_main; extern st_options_system_t st_options_system; extern st_options_video_t st_options_video; extern st_options_graphics_t st_options_graphics; extern st_options_audio_t st_options_audio; extern st_options_control_t st_options_control; extern st_options_game_t st_options_game; extern st_error_t st_error; #ifdef PROFILE_AUDIO extern st_profile_audio_t st_profile_audio; #endif #endif //_KOBO_STATES_H_ KoboDeluxe-0.5.1/version.h0000666000175000001440000000206607406755236012357 00000000000000/* ------------------------------------------------------------ Kobo Deluxe - An enhanced SDL port of XKobo ------------------------------------------------------------ * Copyright (C) 1995, 1996, Akira Higuchi * Copyright (C) 2001, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _KOBO_VERSION_H_ #define _KOBO_VERSION_H_ #define KOBO_VERSION VERSION #define KOBO_DATE "" #endif KoboDeluxe-0.5.1/KoboPlayer0000644000175000001440000000014410711706211012460 00000000000000KoboPlayerPROF˙˙˙˙˙˙˙˙KoboDeluxe-0.5.1/rwc-20040113.txt0000644000175000001440000000126410001053156012711 00000000000000-------------------------------------------------------- (lines) (words) (bytes) Root: 17203 46478 367321 -------------------------------------------------------- Subdirs: ./autom4te.cache 0 0 0 ./data 35 108 736 ./eel 4474 13404 105546 ./graphics 9916 28839 212012 ./sound 16624 55079 397875 -------------------------------------------------------- Total: 48252 143908 1083490 -------------------------------------------------------- Filename pattern: *.([cChH]|[ch]pp|[CH]PP) -------------------------------------------------------- KoboDeluxe-0.5.1/rwc-20071005.txt0000644000175000001440000000126410701503251012720 00000000000000-------------------------------------------------------- (lines) (words) (bytes) Root: 17554 47376 376215 -------------------------------------------------------- Subdirs: ./autom4te.cache 0 0 0 ./data 35 108 736 ./eel 4474 13401 105519 ./graphics 10588 31216 229546 ./sound 16631 55108 398040 -------------------------------------------------------- Total: 49282 147209 1110056 -------------------------------------------------------- Filename pattern: *.([cChH]|[ch]pp|[CH]PP) -------------------------------------------------------- KoboDeluxe-0.5.1/README.jp0000644000175000001440000000342610701566547012003 00000000000000 Kobo Deluxe ----------- v0.4 $B%7%e!<%F%#%s%0%2!<%`(B XKobo$B$N6/2=HG(B Kobo Deluxe $B$OBh;0e>:$7!"E(5!$NAH$_9g$o$;$,JQ2=$7$^$9!#$&$^$/@Z$jH4$1$k(B $B$?$a$K$O$=$NETEYE*3N$J@oN,$rI,MW$H$7$^$9!#(B Kobo Deluxe$B$O%0%i%U%#%C%/%(%s%8%s$r?J2=$5$;!"%2!<%`$N?J9T$d%?%$(B $B%_%s%0$K0MB8$7$J$$=@Fp$J%U%l!<%`%l!<%H@_Dj$r2DG=$H$7$F$$$^$9!#$^$?!"(B $B8z2L2;!"GIe$GF0:n$7$^$9!#$"$^$j0lHLE*$G$O$J%W%i%C%H%[!<%`$G$bF0:n$9$k(B $B$+$b$7$l$^$;$s!#(B $B$R$H$3$H$G8@$&$J$i!"(BKobo Deluxe$B$O%/%i%7%C%/$J%"!<%1!<%I%9%?%$%k$N(B $B%2!<%`$r!"MM!9$J4D6-$N%^%7%s$GM7$Y$k$h$&$K$7$?$H$$$&$3$H$G$9!#(B Enjoy...! David Olofson http://olofson.net Thanks to: Akira Higuchi ($B%*%j%8%J%kHG(BXKobo$B$N:n------------------------------------ License: GPL Author: Karl Bartel WWW: http://members.linuxstart.com/~karlb/ Usage: 1. Load a font and place it in an SDL_Surface *. If your are using the SDL_image library you can do this with Font=IMG_Load("filename"); 2. Initialize the font by using InitFont(surface *Font); 3. Now you can use the font in you SDL program. Please take a look at SFont.h to get info about the funtions. FileFormat: The font file can be any type image file. The characters start with ASCII symbol #33. They are seperated by pink(255,0,255) lines at the top of the image. The space between these lines is the width of the caracter. Just take a look at the font, and you'll be able to understand what I tried to explain here. The easiest way to create a new font is to use the GIMP's Logo function. Use the following string as text (ASCII 33-127 with escape sequences and spaces between the letters): ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~ Example for the font file format: ____ _____ _____ _____ <- This is the pink line at the top # ##### #### # # # # # # # # # # # # ##### # ##### # # # # # # # # # # ##### #### |----| Width of the character |----------| Part of the font surface that is beeing blitted ChangeLog: 2.0 beta *** Added SoFont, a C++ version of SFont *** Added lock and unlock for hardware surfaces Added blinking cursor to SFont_Input Added check for ASCII<33 in SFont_Input TextWidth returned a too highh value -> fixed 1.4 Added support for multiple fonts in one program Add a missing "*" in the SFont.h file Proper '\0' at the end of stings produced by SFont_Input Fixed problems in SFont_Input, which were creating '\b' in the string Fixed two other bugs in SFont_Input Added the SFontViewer adn new test programs 1.3 Fixed three wrong interpretations of the file format o wrong division (float had to be used) o detection of right ends of pink lines (were one pixel too far right) o blit destination (all blits were too far right) support for non-alpha mapped fonts some fonts updated 1.2 added XCenteredString 1.1 renamed font.c to SFont.c and font.h to SFont.h better Makefile 1.0 Added the Input function Added a check wether the Font has been loaded 0.9 better Makefile for the example (using sdl-config) better Neon Font 0.8 First Release If you have any Questions please write a mail! KarlKoboDeluxe-0.5.1/README.xkobo0000666000175000001440000001035307341727551012515 00000000000000 ------------------------------------------------------------------------- __ __ \ \ / / \ \/ / ## ## #### ##### #### \ / ## ## ## ## ## ## ## ## / \ #### ## ## ##### ## ## / /\ \ ## ## ## ## ## ## ## ## / / \ \ ## ## #### ##### #### /_/ --' Version 1.11+-do3 by Akira Higuchi sound effects and other enhancements Masanao Izumo improved OSS sound engine David Olofson ------------------------------------------------------------------------- * DESCRIPTION Xkobo is a single player action game. The play is quite simple. Your object is to destroy all the fortresses. You can control your ship by pressing the cursor keys (or mov- ing the mouse cursor), and shot beams by pressing the SHIFT key (or the left mouse button). The game can be paused by pressing 's' (or the right mouse button). ------------------------------------------------------------------------- * REQUIREMENT Xkobo requires: 1) Unix (BSD, Linux, etc.) 2) X window system (256 colors or greater) 3) OSS compatible sound system (8 kHz, 16 bit stereo) 4) C++ compiler Xkobo is known to compile and run under the following systems: * Linux * Sun-OS 4.1.4 * BSD/OS * Solaris 2.4 (Sparc) * HP-UX 9.05 ------------------------------------------------------------------------- * INSTALLING Edit Imakefile (if you need) and run % xmkmf -a % make % su # make install # make install.man ------------------------------------------------------------------------- * OPTIONS -display displayname This option specifies the name of the X server to use. -fit This option causes xkobo to use the default colormap. Without this option, xkobo uses a private colormap. -wait value This option specifies the speed of the game. The default value is 30(msec). -doublesize This option causes xkobo to enlarge the size of the window. But it costs HUGE memory. -fast This option causes xkobo to use a faster algorithm. But it costs much memory. -cheat Cheat mode. It allows any level to be played, does not update score table. -hiscores Print the high score table to standard out, and exit. -sound Enable sound effects. (Default.) -nosound Disable sound effects. -vol value Set sound effects volume to value. Default is 100. FIXME: Some options aren't translated from README.jp. ------------------------------------------------------------------------- * THANKS TO ... Bruce Cheng Christoph Lameter Davide Rossi Eduard Martinescu Elan Feingold Helmut Hoenig Jeff Epler Joe Ramey Joey Hess Michael Sterrett Mihail Iotov Shoichi Nakayama Thomas Marsh Torsten Wolnik * David's Thanks To... Akira Higuchi (original Xkobo) Masanao Izumo (sound effects) ========================================================================= XKOBO, a video-oriented game Copyright (C) 1995,1996 Akira Higuchi a-higuti@math.hokudai.ac.jp This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ========================================================================= KoboDeluxe-0.5.1/README.xkobo.jp0000666000175000001440000001041307341727606013123 00000000000000 ------------------------------------------------------------------------- XKOBO Version 1.11+-do3 Fri Jan 10 11:17:50 JST 1997 Akira Higuchi a-higuti@math.hokudai.ac.jp ------------------------------------------------------------------------- * DESCRIPTION Xkobo $B$O#1?MMQ$N%"%/%7%g%s%2!<%`$G$9!#@N$N%J%`%3$N%2!<%`(B Bosconian $B$K;w$F$$$^$9!#%k!<%k$OC1=c$G!"<+5!$rA`$C$F2hLL>e$K$"$kMW:I$rA4$FGK(B $B2u$9$k$3$H$,%2!<%`$NL\E*$G$9!#(B ------------------------------------------------------------------------- * REQUIREMENT Xkobo $B$r%3%s%Q%$%k!?eI=<($G$-$k(B X $B%5!<%P(B) 3) C++ $B%3%s%Q%$%i(B Xkobo $B$O>/$J$/$H$b0J2<$N%7%9%F%`$GF0:n$7$^$9!#(B * Linux * Sun-OS 4.1.4 * BSD/OS * Solaris 2.4 (Sparc) * HP-UX 9.05 ------------------------------------------------------------------------- * INSTALLING $B$b$7I,MW$J$i(B Imakefile $B$rJT=8$7$F$+$i!"e$G%3%s%Q%$%k$,40N;$G$9!#$b$7$"$J$?$,(B root $B$K$J$l$k$J$i!"/$J$$$H!"(Bxkobo $B$N(B $B1GA|$N?'$,JQ$K$J$k$3$H$,$"$j$^$9!#$3$l$r;XDj$7$J$+$C$?$i!"%W(B $B%i%$%Y!<%H%+%i!<%^%C%W$r;HMQ$7$^$9!#(B $BCm!'(Bsgi $BMQ$K%O%C%/$7$?$3$N%P!<%8%g%s$G$O!$$3$N%*%W%7%g%s$O$"(B $B$j$^$;$s!%(B -wait value $B%2!<%`$N%9%T!<%I$r;XDj$7$^$9!#$3$N%*%W%7%g%s$G;XDj$7$J$1$l$P!"(B 40$B!J%_%jIC!KKh$K2hLL$,%"%C%W%G!<%H$5$l$^$9!#(B -doublesize $B2hLL$N%5%$%:$,=D2#$=$l$>$l#2G\$K$J$j$^$9!#$?$@!";HMQ$9$k%a%b(B $B%j$NNL$,Ls#4G\!*$K$J$j$^$9!#(B -tetrasize $B2hLL$N%5%$%:$,=D2#$=$l$>$l#4G\$K$J$j$^$9!#$?$@!";HMQ$9$k%a%b(B $B%j$NNL$,Ls#1#6G\!*$K$J$j$^$9!#(B -fast $BB.$$%"%k%4%j%:%`$r;HMQ$7$^$9!#%a%b%j$N;HMQNL$OA}$($^$9!#(B -cheat $B%A%c%C%H!&%b!<%I$Gr7o2<$G$N2~B$!?:FG[I[$,2DG=(B $B$G$9!#>\$7$/$O(B COPYING $B$r$_$F$/$@$5$$!#(B $B5l%P!<%8%g%s$KB8:_$7$?(B Towns PAD $BBP1~$O:o=|$7$^$7$?!#JL$N%W%m%0%i%`(B xpadtrans $B$r;H$($P(B Towns PAD $B$GA`:n$G$-$k$h$&$K$J$j$^$9!#>\$7$/$O!"(B http://www.math.hokudai.ac.jp/~a-higuti/ http://seki.math.hokudai.ac.jp:20080/ $B$"$?$j$rGA$$$F$_$F2<$5$$!#(B ------------------------------------------------------------------------- * THANKS TO ... Bruce Cheng Christoph Lameter Davide Rossi Eduard Martinescu Elan Feingold Helmut Hoenig Jeff Epler Joe Ramey Joey Hess Michael Sterrett Mihail Iotov Shoichi Nakayama Thomas Marsh Torsten Wolnik KoboDeluxe-0.5.1/README.osx0000644000175000001440000000015707534000137012165 00000000000000 you may need to do this to make kobo work: % sudo mkdir -p -m 777 /Library/Preferences/KoboDeluxe/scores KoboDeluxe-0.5.1/README.html0000644000175000001440000005050610730720240012317 00000000000000 KOBODL

KOBODL

NAME
SYNOPSIS
DESCRIPTION
CONTROLS
OPTIONS
FILES
AUTHORS
THANKS
COPYRIGHT

NAME

kobodl - Kobo Deluxe, an enhanced version of the scrolling game XKobo

SYNOPSIS

kobodl [ options ]

DESCRIPTION

Kobo Deluxe is a 3’rd person scrolling 2D shooter with a simple and responsive control system - which you’ll need to tackle the tons of enemy ships that shoot at you, chase you, circle around you shooting, or even launch other ships at you, while you’re trying to destroy the labyrinth shaped bases. There are 50 action packed levels with smoothly increasing difficulty, and different combinations of enemies that require different tactics to be dealt with successfully.

Kobo Deluxe has an improved graphics engine that delivers smoother animation, while keeping the game logic totally accurate and predictable regardless of frame rate. It also adds sound effects, new graphics, fullscreen mode, four extra skill levels with smoother gameplay and various other features expected from a modern game. (There is still a "Clasic" mode that plays exactly like the original XKobo.)

Kobo Deluxe uses SDL for sound, graphics and input, and builds and runs on all major operating systems, as well as some more unusual platforms. It can also use OpenGL for accelerated rendering, through glSDL.

In short, Kobo Deluxe is loads of classical arcade style fun for just about any machine with graphics and sound!

CONTROLS

The ship can be controlled with the keyboard, or optionally a mouse or joystick. With the keyboard, the arrow keys move the ship (two keys for diagonals), and the shift and ctrl keys shoots. The numeric key pad can also be used; the usual 2/4/6/8 (arrows), and also 1/3/7/9 for single key diagonals. Escape enters the meny system, from where it is possible to change settings, start a new game or exit the game.

OPTIONS

Note that all relevant options can be also configured in the config file, which can be edited directly, or using the options menus in the game.
−[no]logfile

Log To File. Default: Off.

−logformat

Log File Format. Default: 0.

−logverbosity

Log Verbosity Level. Default: 2.

−[no]joystick

Use Joystick. Default: Off.

−joystick_no

Joystick Number. Default: 0.

−[no]mouse

Use Mouse. Default: Off.

−mousemode

Mouse Control Mode. Default: 1.

−[no]broken_numdia

Broken NumPad Diagonals. Default: Off.

−dia_emphasis

Diagonals Emphasis Filter. Default: 0.

−[no]always_fire

Always Fire. Default: Off.

−[no]mousecapture

In-game Mouse Capture. Default: On.

−scrollradar

Radar Scroll Mode. Default: 2.

−[no]filter

Enable/disable motion interpolation. Interpolation is what makes animation smooth at high frame rates despite the game logic running at 33.33 fps. However, it also adds some input latency! Default: On.

−timefilter

Time filter, for smoothing out timing jitter induced by the operating system. Default: 50.

−countdown

Get Ready Countdown. Default: 5.

−starfield

Starfield Style. Default: 2.

−stars

Number of Parallax Stars. Default: 500.

−[no]sound

Enable Sound. Default: On.

−[no]music

Enable Music. Default: On.

−[no]cached_sounds

Use Cached Sounds. Default: Off.

−[no]oss

Use OSS Sound Driver. Default: Off.

−samplerate

Sample Rate. Default: 44100.

−latency

Sound Latency. Default: 50.

−mixquality

Mixing Quality. Default: 3.

−vol

Master Volume. Default: 100.

−intro_vol

Intro Music Volume. Default: 100.

−sfx_vol

Sound Effects Volume. Default: 100.

−music_vol

In-Game Music Volume. Default: 50.

−reverb

Reverb Level. Default: 100.

−vol_boost

Volume Boost. Default: 0.

−[no]fullscreen

Fullscreen Display. Default: Off.

−videodriver

Display Driver. Default: 0.

−width

Horizontal Resolution. Default: 640.

−height

Vertical Resolution. Default: 480.

−aspect

Pixel Aspect Ratio. Default: 1000.

−depth

Display Depth. Default: 0.

−maxfps

Limit the framerate (fps). Saves power on laptops (75 works well), and can also avoid long stalls due to timesharing and background processes. Default: 100.

−maxfpsstrict

Strictly Regulated fps. Default: 0.

−buffer

Display Buffer Mode. Default: 1.

−[no]shadow

Use Software Shadow Buffer. Default: On.

−videomode

Video Mode. Default: 17200.

−[no]vsync

Enable Vertical Sync. Default: On.

−videopages

Number of Video Pages. Default: -1.

−scalemode

Scaling Filter Mode. Default: 1.

−[no]dither

Use Dithering. Default: On.

−dither_type

Dither Type. Default: 0.

−[no]broken_rgba8

Broken RGBA (OpenGL). Default: Off.

−[no]alpha

Use Alpha Blending. Default: On.

−brightness

Brightness. Default: 100.

−contrast

Contrast. Default: 100.

−files

Specify the root path of the game. Default: ""

−gfx

Specify the path to the game’s graphics data. Default: ""

−sfx

Specify the path to the game’s sound data. Default: ""

−scores

Specify the path to the game’s score files. Default: ""

−size

(Not saved!) Screen Size (Obsolete). Default: 0.

−wait

Game Speed (Obsolete). Default: 30.

−bgm

(Not saved!) Background Music File (Obsolete). Default: ""

−threshold

(Not saved!) Limiter Gain. Default: 200.

−release

(Not saved!) Limiter Speed. Default: 50.

−internalres

(Not saved!) Texture Resolution. Default: 1.

−last_profile

Last used player profile. Default: 0.

−number_of_joysticks

Number of Connected Joysticks. Default: 0.

−[no]showcfg

(Not saved!) Show Configuration. Default: Off.

−[no]hiscores

(Not saved!) List High Scores. Default: Off.

−[no]highscores

(Not saved!) List High Scores. Default: Off.

−[no]override

(Not saved!) Ignore Configuration File. Default: Off.

−[no]debug

(Not saved!) Enable Debug Features. Default: Off.

−[no]fps

(Not saved!) Display frames per second in game screen. Default: Off.

−[no]noframe

(Not saved!) Do not render rounded corners on the playfield. Default: Off.

−[no]midi

(Not saved!) Enable MIDI Input. Default: Off.

−[no]cheat

(Not saved!) Enable/disable cheat mode. Cheat mode allows any level to be played, but highscores are not saved! Default: Off.

−[no]indicator

(Not saved!) Enable Collision Indicator Mode. Default: Off.

−[no]pushmove

(Not saved!) Enable Push Move Mode. Default: Off.

−[no]noparachute

(Not saved!) Disable SDL Parachute. Default: Off.

−[no]pollaudio

(Not saved!) Use Polling Audio Output. Default: Off.

−[no]autoshot

(Not saved!) Ingame screenshots/movie. Default: Off.

−[no]help

(Not saved!) Print usage info and exit. Default: Off.

−[no]options_man

(Not saved!) Print options for ’man’. Default: Off.

FILES

~/.kobodlrc

The per-user configuration file for Kobo Deluxe.

AUTHORS

Originally written by Akira Higuchi (a-higuti@math.hokudai.ac.jp), XKobo was turned into Kobo Deluxe by David Olofson <david@olofson.net>

THANKS

Thanks, in no particular order, to...
Akira Higuchi

Author of the Original XKobo.

Masanao Izumo

Sound effects and original sound engine.

Torsten Giebl

Slackware.

David Andersson

Various Good Ideas.

Max Horn

Mac OS X & Build Script Patches.

Jeremy Sheeley

Player Profiles.

Tsuyoshi Iguchi

FreeBSD, NetBSD.

Samuel Hart

Joystick Support.

G. Low

Solaris.

Gerry Jo Trick Jellestad

Testing and ideas.

Riki

Intel Compiler.

Andreas Spaangberg

Sun Compiler & Bug Spotting.

SixK

Amiga Port.

Joey Hess

Debian.

Martijn van Oosterhout

FPS limiter.

Antonio Messina

Stage 1601+ difficulty wrap, Always Fire option.

Hans de Goede

Audio buffer handling bug.

Marianne Ibbotson

"Autopause" idea.

Sam Palmer

MS Windows testing.

Michael Sterrett

glSDL issues.

Sam Lantinga & Others

SDL, the Simple DirectMedia library.

Members of the SDL mailing list

Testing and ideas.

COPYRIGHT

Copyright (c) 1995, 1996 Akira Higuchi

Copyright (C) 1997 Masanao Izumo

Copyright (C) 1999-2001 Simon Peter

Copyright (C) 2002 Florian Schulze

Copyright (C) 2002 Jeremy Sheeley

Copyright (C) 2005 Erik Auerswald

Copyright (c) 1999-2007 David Olofson

Kobo Deluxe is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License.


KoboDeluxe-0.5.1/cfg-work0000755000175000001440000000021010730756206012137 00000000000000#!/bin/sh CFLAGS="-O0" CXXFLAGS="-O0" ./configure --prefix=/usr --enable-epm --enable-debug --disable-alsa --enable-opengl --enable-oss KoboDeluxe-0.5.1/cfg-beta0000755000175000001440000000015407502763221012075 00000000000000#!/bin/sh CFLAGS="-O3" CXXFLAGS="-O3" ./configure --enable-debug --enable-alsa --enable-opengl --enable-oss KoboDeluxe-0.5.1/cfg-release0000755000175000001440000000015410727043032012574 00000000000000#!/bin/sh CFLAGS="-O3" CXXFLAGS="-O3" ./configure --prefix=/usr --disable-alsa --enable-opengl --enable-oss KoboDeluxe-0.5.1/cfg-profile0000755000175000001440000000014607735603377012640 00000000000000#!/bin/sh CFLAGS="-O3 -pg" CXXFLAGS="-O3 -pg" ./configure --disable-alsa --enable-opengl --enable-oss KoboDeluxe-0.5.1/cfg-cross-release0000755000175000001440000000014010711477621013726 00000000000000#!/bin/sh CFLAGS="-O3 -Wall" CXXFLAGS="-O3 -Wall" cross-configure --disable-debug --disable-epm KoboDeluxe-0.5.1/cfg-work-opt0000755000175000001440000000021010730743104012730 00000000000000#!/bin/sh CFLAGS="-O3" CXXFLAGS="-O3" ./configure --prefix=/usr --enable-epm --enable-debug --disable-alsa --enable-opengl --enable-oss KoboDeluxe-0.5.1/buildpkg.sh0000755000175000001440000000135007407766572012656 00000000000000#!/bin/sh # # How to build a solaris package, by Andreas Spĺngberg: # ./configure # make # cd solaris # ./buildpkg.sh # pkgadd -d ./ASkobodl.pkg # ARCH=`uname -p` INSTDIR=`pwd`/package cd .. make install DESTDIR=$INSTDIR cd $INSTDIR cat > pkginfo << EOPKG PKG="ASkobodl" NAME=`grep PACKAGE ../../aconfig.h | awk -e '{print $3}'` ARCH="$ARCH" VERSION=`grep VERSION ../../aconfig.h | awk -e '{print $3}'` CATEGORY="games" VENDOR="David Olofson" EMAIL="david@olofson.net" PSTAMP="Andreas Spĺngberg" BASEDIR="/usr/local" CLASSES="none" EOPKG echo "i pkginfo=./pkginfo" > prototype find . -print | pkgproto ./usr/local= >> prototype cd .. pkgmk -d . -f package/prototype -o rm -rf $INSTDIR echo 1 | pkgtrans -os . ASkobodl.pkg rm -rf ./ASkobodl KoboDeluxe-0.5.1/kobodl.60000644000175000001440000002076510734533116012051 00000000000000.TH KOBODL 6 "26 December 2007" .SH NAME kobodl - Kobo Deluxe, an enhanced version of the scrolling game XKobo .SH SYNOPSIS .B kobodl [ .I options ] .SH DESCRIPTION Kobo Deluxe is a 3'rd person scrolling 2D shooter with a simple and responsive control system - which you'll need to tackle the tons of enemy ships that shoot at you, chase you, circle around you shooting, or even launch other ships at you, while you're trying to destroy the labyrinth shaped bases. There are 50 action packed levels with smoothly increasing difficulty, and different combinations of enemies that require different tactics to be dealt with successfully. .P Kobo Deluxe has an improved graphics engine that delivers smoother animation, while keeping the game logic totally accurate and predictable regardless of frame rate. It also adds sound effects, new graphics, fullscreen mode, four extra skill levels with smoother gameplay and various other features expected from a modern game. (There is still a "Clasic" mode that plays exactly like the original XKobo.) .P Kobo Deluxe uses SDL for sound, graphics and input, and builds and runs on all major operating systems, as well as some more unusual platforms. It can also use OpenGL for accelerated rendering, through glSDL. .P In short, Kobo Deluxe is loads of classical arcade style fun for just about any machine with graphics and sound! .SH CONTROLS The ship can be controlled with the keyboard, or optionally a mouse or joystick. With the keyboard, the arrow keys move the ship (two keys for diagonals), and the shift and ctrl keys shoots. The numeric key pad can also be used; the usual 2/4/6/8 (arrows), and also 1/3/7/9 for single key diagonals. Escape enters the meny system, from where it is possible to change settings, start a new game or exit the game. .SH OPTIONS Note that all relevant options can be also configured in the config file, which can be edited directly, or using the options menus in the game. .TP .B \-[no]logfile Log To File. Default: Off. .TP .B \-logformat Log File Format. Default: 0. .TP .B \-logverbosity Log Verbosity Level. Default: 2. .TP .B \-[no]joystick Use Joystick. Default: Off. .TP .B \-joystick_no Joystick Number. Default: 0. .TP .B \-[no]mouse Use Mouse. Default: Off. .TP .B \-mousemode Mouse Control Mode. Default: 1. .TP .B \-[no]broken_numdia Broken NumPad Diagonals. Default: Off. .TP .B \-dia_emphasis Diagonals Emphasis Filter. Default: 0. .TP .B \-[no]always_fire Always Fire. Default: Off. .TP .B \-[no]mousecapture In-game Mouse Capture. Default: On. .TP .B \-scrollradar Radar Scroll Mode. Default: 2. .TP .B \-[no]filter Enable/disable motion interpolation. Interpolation is what makes animation smooth at high frame rates despite the game logic running at 33.33 fps. However, it also adds some input latency! Default: On. .TP .B \-timefilter Time filter, for smoothing out timing jitter induced by the operating system. Default: 50. .TP .B \-countdown Get Ready Countdown. Default: 5. .TP .B \-starfield Starfield Style. Default: 2. .TP .B \-stars Number of Parallax Stars. Default: 500. .TP .B \-overheatloud Overheat Warning Loudness. Default: 100. .TP .B \-cannonloud Player Cannons Loudness. Default: 100. .TP .B \-[no]sound Enable Sound. Default: On. .TP .B \-[no]music Enable Music. Default: On. .TP .B \-[no]cached_sounds Use Cached Sounds. Default: Off. .TP .B \-[no]oss Use OSS Sound Driver. Default: Off. .TP .B \-samplerate Sample Rate. Default: 44100. .TP .B \-latency Sound Latency. Default: 50. .TP .B \-mixquality Mixing Quality. Default: 3. .TP .B \-vol Master Volume. Default: 100. .TP .B \-intro_vol Intro Music Volume. Default: 100. .TP .B \-sfx_vol Sound Effects Volume. Default: 100. .TP .B \-music_vol In-Game Music Volume. Default: 30. .TP .B \-reverb Reverb Level. Default: 100. .TP .B \-vol_boost Volume Boost. Default: 0. .TP .B \-[no]fullscreen Fullscreen Display. Default: Off. .TP .B \-videodriver Display Driver. Default: 0. .TP .B \-width Horizontal Resolution. Default: 640. .TP .B \-height Vertical Resolution. Default: 480. .TP .B \-aspect Pixel Aspect Ratio. Default: 1000. .TP .B \-depth Display Depth. Default: 0. .TP .B \-maxfps Limit the framerate (fps). Saves power on laptops (75 works well), and can also avoid long stalls due to timesharing and background processes. Default: 100. .TP .B \-maxfpsstrict Strictly Regulated fps. Default: 0. .TP .B \-buffer Display Buffer Mode. Default: 1. .TP .B \-[no]shadow Use Software Shadow Buffer. Default: On. .TP .B \-videomode Video Mode. Default: 17200. .TP .B \-[no]vsync Enable Vertical Sync. Default: On. .TP .B \-videopages Number of Video Pages. Default: -1. .TP .B \-scalemode Scaling Filter Mode. Default: 1. .TP .B \-[no]dither Use Dithering. Default: On. .TP .B \-dither_type Dither Type. Default: 0. .TP .B \-[no]broken_rgba8 Broken RGBA (OpenGL). Default: Off. .TP .B \-[no]alpha Use Alpha Blending. Default: On. .TP .B \-brightness Brightness. Default: 100. .TP .B \-contrast Contrast. Default: 100. .TP .B \-files Specify the root path of the game. Default: "" .TP .B \-gfx Specify the path to the game's graphics data. Default: "" .TP .B \-sfx Specify the path to the game's sound data. Default: "" .TP .B \-scores Specify the path to the game's score files. Default: "" .TP .B \-size (Not saved!) Screen Size (Obsolete). Default: 0. .TP .B \-wait Game Speed (Obsolete). Default: 30. .TP .B \-bgm (Not saved!) Background Music File (Obsolete). Default: "" .TP .B \-threshold (Not saved!) Limiter Gain. Default: 200. .TP .B \-release (Not saved!) Limiter Speed. Default: 50. .TP .B \-internalres (Not saved!) Texture Resolution. Default: 1. .TP .B \-last_profile Last used player profile. Default: 0. .TP .B \-number_of_joysticks Number of Connected Joysticks. Default: 0. .TP .B \-[no]showcfg (Not saved!) Show Configuration. Default: Off. .TP .B \-[no]hiscores (Not saved!) List High Scores. Default: Off. .TP .B \-[no]highscores (Not saved!) List High Scores. Default: Off. .TP .B \-[no]override (Not saved!) Ignore Configuration File. Default: Off. .TP .B \-[no]debug (Not saved!) Enable Debug Features. Default: Off. .TP .B \-[no]fps (Not saved!) Display frames per second in game screen. Default: Off. .TP .B \-[no]noframe (Not saved!) Do not render rounded corners on the playfield. Default: Off. .TP .B \-[no]midi (Not saved!) Enable MIDI Input. Default: Off. .TP .B \-[no]cheat (Not saved!) Enable/disable cheat mode. Cheat mode allows any level to be played, but highscores are not saved! Default: Off. .TP .B \-[no]indicator (Not saved!) Enable Collision Indicator Mode. Default: Off. .TP .B \-[no]pushmove (Not saved!) Enable Push Move Mode. Default: Off. .TP .B \-[no]noparachute (Not saved!) Disable SDL Parachute. Default: Off. .TP .B \-[no]pollaudio (Not saved!) Use Polling Audio Output. Default: Off. .TP .B \-[no]autoshot (Not saved!) Ingame screenshots/movie. Default: Off. .TP .B \-[no]help (Not saved!) Print usage info and exit. Default: Off. .TP .B \-[no]options_man (Not saved!) Print options for 'man'. Default: Off. .SH FILES .TP .B ~/.kobodlrc The per-user configuration file for Kobo Deluxe. .SH AUTHORS Originally written by Akira Higuchi (a-higuti@math.hokudai.ac.jp), XKobo was turned into Kobo Deluxe by David Olofson .SH THANKS Thanks, in no particular order, to... .TP .B Akira Higuchi Author of the Original XKobo. .TP .B Masanao Izumo Sound effects and original sound engine. .TP .B Torsten Giebl Slackware. .TP .B David Andersson Various Good Ideas. .TP .B Max Horn Mac OS X & Build Script Patches. .TP .B Jeremy Sheeley Player Profiles. .TP .B Tsuyoshi Iguchi FreeBSD, NetBSD. .TP .B Samuel Hart Joystick Support. .TP .B G. Low Solaris. .TP .B Gerry Jo "Trick" Jellestad Testing and ideas. .TP .B "Riki" Intel Compiler. .TP .B Andreas Spaangberg Sun Compiler & Bug Spotting. .TP .B "SixK" Amiga Port. .TP .B Joey Hess Debian. .TP .B Martijn van Oosterhout FPS limiter. .TP .B Antonio Messina Stage 1601+ difficulty wrap, Always Fire option. .TP .B Hans de Goede Audio buffer handling bug. .TP .B Marianne Ibbotson "Autopause" idea. .TP .B Sam Palmer MS Windows testing. .TP .B Michael Sterrett glSDL issues. .TP .B Sam Lantinga & Others SDL, the Simple DirectMedia library. .TP .B Members of the SDL mailing list Testing and ideas. .SH COPYRIGHT Copyright (c) 1995, 1996 Akira Higuchi .P Copyright (C) 1997 Masanao Izumo .P Copyright (C) 1999-2001 Simon Peter .P Copyright (C) 2002 Florian Schulze .P Copyright (C) 2002 Jeremy Sheeley .P Copyright (C) 2005 Erik Auerswald .P Copyright (c) 1999-2007 David Olofson .P \fBKobo Deluxe\fP is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License. KoboDeluxe-0.5.1/icons.tar.gz0000644000175000001440000006273110711735554012756 00000000000000‹l»'GěgPS[نCďE ‘˘iIHĂ(˝i"]¤#5‚Hoć ]Şp(¤H!H=(@:ˇH!„Ŕϙ3÷~ߏ{÷ŢáťYY{˛w~d?Ůë}˛ě­]]â˙÷ň·˙ËV‚ŔHäżâ…‚áY$˛ĎŠ„ń?ţ‚9,ţľě>YRö˙áńwtµrµq’vs±űźâŹ@Ŕţ+ţ(ůŹçńsý‡Ăö/ń˙Ë©«ŁÁÁ*ȺȹŞzcć>ĚŚűŻÂë{–ű‹ŰUăýŻÎĆ{0hĎŇů÷ßdňÄh«1őŃńss1w^hĄ1ŞJúŘ!k‹lFŁr\uř}NyřýŹOşĄOé\š›ĽĆľ%QóĆęŮď%cµ+Có‚OxĆ^–YYĘĎŮČÝEkL† ö@i,]â)\ăea‘B©ĆsZďť÷Čj±Ź(É]Óm•†{;»‹Ŕ(6ţýdŽ˝&©ü˛·ňŚýz·šWâ Ćý¨x0ńÂő^RŻágΡŚeË+DĎHíŇ˙üŚüŢń-*íĂ~^(>5&!&V¶Ĺ.ęm|L˝ß‡ÝśEĘčá„ţDšË\d1ŇŃÖť:µBBó´;ň{^Ť8Ѹ]?­°ŢĂ•®|%­°›Yo×3/ţµ™i™VéÜďJWr†Îč¤5vwžj.)YÔőâzíÂÓiDZ]>¬µýł,а2S<+ŚĹż„ćcÖÄÁWŁŢŘŐ8_'µ »(dŁÚ } ĂY†Ň;xň‚ :¬ůŃ“ ÍWoĘ™Sżˇ™*yîjÖťĆÝ3g·×=cĐl*)-Y]K/hŤ8Ŕ0\—gZ¬Oyk‘O %´?T5b)˙ˇuŮ˙÷wŮg¤N[Xť=ţÎmbL9·µĹ?öĐÂzÎěGˇóĽ7ÖłÁŻĹŐP ké°aŕç׎´Á&â^f5ŽĚď’Âe•Ege€ປ¤ńó;Ôq©·-Ĺ«Ô󲲶ʹÖîŹ÷ĐH<3WEmzşäuď73ţR*@ˇ0%€ ~ťČy–Ćůź!FMGµTŮâ1ŕ(‡»ţCˇX(ôűŽDţŃ˙Łţ?<ţk˙CÁú? ţŮ˙0ČQ˙R˙ĆĎţo­rB˙ëţçDmĆňítô_˘Ů=S[ţŽ˝‚Ů3ťťřx\|ľö‡gŻJKěkĽěťëî•Gvľľ¶4ĐwS)ČĆÚř€jŞ|ބЯŃâ§OŹ‚Ë=X锪s˘k˘·Ő’Ä ăÂÚ:îOO”ÝĆWÝÁ<«»{+¸p®¶ťâΰŚ1.Ë·żęfŕřŰÜŇNŤ¬[ź„.vǶ%nWŽűű.ĘëáOę—×®8EvL'+Ľ•č&¶9ĘwÂlfR|řèPA­Ľbł T˙¢MÇžâć]qjÍŰG+w»#iD2®2$-z/€ś>đňĘ–Ík5(WTö{íŢb-™/±´Ä­~„őŕÚŔMëŻÖînŘ=öoř…ĺ ·ť„'›źÉ1HĄÜgM.őíŐRü˙ČŠC #oČŃ´x0aşÉM×Âëꉀ>yŁ˙ž÷ëąłÇ:)§Ç˛74Gc$Ú‚ĘBzßl w ˇúĹ÷-ĄýÉiFë÷Ą>* 08.˝‘ž–J™™›LĚt°Č"|uţP©ÁXBZ©0v#¬‰M €’ÔO%h6ĎŕeÎ$gnŰěú7t“…°KŤq÷ő’}]ŢÄ^rú¸ö…,g7iÍ—,™ŤZëh‘&·^Uč‘Ţ2=u=o+u~ŢŢvŘ‹€ŃčhyŮ|űB+§4ÖXă¬sP§ân–@ěë㢍|:;†~¦łěś$Lž±z»Â?łzW$çzÖęRĂ”’‰˝3r~ÉÍD‹9_9Óíl€xbW‰’m>ü)Ôe2ĄŢFŹů°|ObɌΛ·gĘBmѶűVÎq§ŽE5rçöL'śÎw1$´uÄ”ůŞ–ÇŹÁ<Ęäş^•÷ys—/Śř˝íĆ@“L¤9qÜ1PĆÖ Ăjé†éZ;ó@×4= }™´µŤ+ÍIouĂţ ł¤W—yu^Jśě#lW0VL+&féF}RčO*‚ĹD 9ohµ^Ąf˘"šŮu{Hđ‘輮f»zy„S&ÝoźTô ‡އşŮ{.ežďŮ­ýřŁ&Ď‘Ôů‹Ęë”ĆK^[Aee¤_4l¶ĺŤ6.˝KB=™}ăBRÚŻŐľżĐ‹8˛öíy=EE=Z—ČK$ď]8[ţ„č'×ĐH0§^´"e¸­1o ®÷ľż(受Љ×Qţs˙ËB±˛‡ę`ČO˙Cí˙"˙żŐ˙d!˛řńçţâČ˙É˙DĆO˙óđőÝř7üOrɰ)` ţáß“µś„€a{ǰѨéś_E­ëžZIčßî(ęËń q>E(Ç˝rŻ/4ÉVŚň¶ä›Ë‘¨óš™ŃĎ«Âia Ţ|¸n“;Żá-ŢŽ*>L0ReA-ŞŚ@¤§–ŇŁ Š"ŢU}ŽŻOĄsÍvĄ{0m&ďηď­ŮY}«‹Ě#‡ÇM1^ž:3ÚÉßíNľ-o´eG­Üy]ŔĄY˘–#Ü5ŽÝM\«x:Ű-ĽÓťiŹďC#‡J›–L]1UmÉîĆ3öI(ŚX"~TÇÝr®¸yCʢ˝Ĺ•Ďe\Ď8ů'¬ńä6 €K6čÄ.z&uݶ ;ĺJĂ™CĐÇËSמ§-Ş^ɢĽ%.tĆI9µw XŚQŰî!Řűp¶|şöýŢ܉)ZVoěĘą {÷Żë`?ćPĚ@‰r[ŮôLułMhŻéHZ~łißŘ;¸>°ÝP*^˙çů6ćVôăAÝđ&şKůŚÉÁŮ% Ą÷C@–íŢŃÖkĎleűÝ™IDŽ.1 őŕíüwŕn˙ěË믯]Ö ńő„>7)f‡q`ZŃ\ŻvWW[ňĚO±‰dipĽp¦N–Ň>CLŽGź/LrŮĚÚľń»cÍ˥ۢ•“ˇErŮጠôeeŹÉ[Q~¸RUĂüî‹ä·Ż-$…‹Ł3RKŘâçV˝®JÄÇË©–Ővt´˝ŮĎď[đ3JšßíR‘´YŐ±ˇ^Fă3¨áž ełşŹÂŞN>‡ÉJs˘Ź­‚'|&f PcVďóc9Ác Íő‹BżO›xHjíąť{-VŞ:đä2Z8Ѧe­lbÂŵ}íćÔ¬ŇÂŮŽDtí•Ňľţľt•‹×ŕGUvhŔ¨ć[ZíĆ;ÜŻˇ϶9ĂlRŔäËqćŠNV*äŤ=a™UDâ„{ěEPRV—×¶ży*žT6žŻĺn9ÍîCžç !7…^}đ·ąĹÇ8aN_íťĆŽň2÷Ľw>ľ´ń÷Ľ›š± •®í4{ó†X<ľnĄřâ†S®ľdäŐÓŢŔV[úëKňĺ8;·ě% ·Šô\‚=Zś«­mé386jSV?7Z]”*Yţ„Źpqë]ÚYRă”1w»fÎŚ{jM÷fm4‹GćĄöë{´Í©J)<ľ < šV'ßÔÖ +ÜJ8‚Ň•ŇĆvn`g ŽC¤TĆüJçzH9űU˘(·E{«žXţ5‘.@»ű4¬P×0oλ>9łVž‰f´ń¬ÇE†EÚç”Ä”…\ hĹńˇÓw:s“ glŐ¬Š2śYĄęč’?|í=çy­ú Sş`űŇHď3ĹG†Ďfú\Ąö–6XŽ)ŹŐýď"×ăk_EďÜá\QĂś^ýu~ůŹA­SŁątěś:›”Śc:Bh$DĹŞ ¦#Mŕlß…3AúÎ'ő‹zË4Ш0‘Ě_uŁE‹ůř‹>ŽťŐ˙<0“u'üX•^8“ŁAëSµéĹK˝ęlF _ÖF‚Ň:řr8`ĎbKůAQ]o-sEZß»®]”3íŔć×Ö|őć€Uëčĺ [€ …µ>_«Cb{LÂűÚLýoE#"ˇŃ2‰4đÇńßoUZyޤŰ;rĎ|&Q5ĆnGHţ`¬¬H§Ě‹]j`TEňcłŢĹ@SwZRÇĆźQÜPµg"FĄI>ĺ¬ÖŐ‰˘ß*&}ťěňżcř‡Ť~3Ô$Z™¨V.¨–Ńüh`—÷}ęk/ŰřCa[Ź®‰&¶;§#>ÉÜŰńűř"e¤ó˙˛BĘsŹžŃUÖ ąŰő~W¦MÇ26éŃ*[ĘćsÜT&˝Ż;µÖcôG˙*ţ/ű ……ˇÓ˙!Đ˙‡Źü˙ů˙­ţżoýú?ě`˙#Źü˙ü˙ŕ¶úż!-9üßđá›áĎ“÷ϡţôcÇŰ3>P>ŚxŰm6ŽE7Üé_äđf§ůÚ>Â^«{+˘P±äÝUŐNśŞŢ˘Ş»j4sdÂÍĽWJš""çXť ľ€ÜL5?gtŤéhŻ7^$J.ÖŤ÷¤ËÎŽ č&”·Ţµ;ٶ¶ľîżBň_Y7']i‚ßnŮž\ ô0Ě$đ™ÖN٤ą‰é¦öţfĄ€/ł{3Yů¸“ßc‘{SˇóDwů±Ä ôÜŚ!2lMÖg9pUŃ”•ż~kᚯŇ#ęŇWU¬™*ý›ŐV ÇĄĺا…ăx$µ·ĄĆźç”UuŘŐ•/úÉ^—O í¸gîÜşhNu,ĐµŻ¶]\Ş•:$vQ‘ŹÂ8O¤ÉVÄ›ú8íăÉw‰µ…}‚]ľ Ť)RoȰo§)˙3!˙íqí·ÉťL´‚†áĆš,éĺĚĎşŔČtW·_ęÁ·®Á¶ş 2ÜőąąčMץR!'č±H wEż §€ćF‹K2·Q¤ ŻŚOS,0e5µ: Ű(ţ'öĺ×Ö{ăŻËË}J·<ä´M´®rq©cBŕ.—QpŃŢU÷¦Ëúś“íXkHYÖNS7®|®„<‹1áhQ4:KI {#¸ë4W_Ů2Dü¨ľń[\Ő ˇŚÇ±Ă“,ÜËĹBíçKŰÉőËÜŠ$$w—Ą¦ ě Őů€Ď“–ő°Ëńʬ¦”Icu—aĐ6÷ sčřFö;N—ae«•Ä…2Ď_(Â)™&µ¨˝††áv›1]ÇU°”`XGÓ*†ž9Ű˝)L‡ćaCÓô„»ůÁŔ}đP‡Ĺ0w¨Ţ í \éýG»@Ăńy&áSZb=ţ{•ńiŢjóüšpX[Ź­â6BuHIźŤ{ ÚŢd6:Ś1‹Ô“+1|¬RÓź‚Yđf @Ä»cqŃmĘ›K®›rţ[â&5˙ŃŢ[@g®Ł[˘af¨ 'ć 33333s*ĚĚĚĚ\ˇ C…™™™™ńĄÎéąÓ}ďt÷ĽµzúÎ[ݶí?Ţö'ɲ$K[±äWÎ^±·ŰÓ<`Y6˙Pęnś0&5!éž^žĆ€:Ő^îFđXE\Ő¦Ö+^uP”°ŢŁŤŔžËĚd™8Ę| s†R@ń}¨úÓ[±Ýë[Úc•©Çg*Něr±XÔJ’ź×€H\c]:#‚­ý=FčÜnŻßËŚo†­[ßÖ«ę<@ĽŤ]—®ż"F†*Śń×oúäWDGgZ˘[uî4#c‡Ľ%méľMnŠŔ8űťšâáůALÄEŻx5ŠYn%ěay8ßÍšťľMĘźkžŽ i—čRNz=&}ľ:wí‹đĚťr™ă•ÖbŠsőŢ(%ř$¨PXÔR7bxm“Š%"ţ fX8ô„'šc䓝ĘŔÎ>*ăÝčČŐ{ëč:ę–YxŻĚy­óęŚct v4CHŤ:źJ߸q˘ĚڦĄ}1ł;‚?HŚ2ŢK$䱍)0h^ŕő0( Toż\X’ÖŤźŽä&¤c_fŚG‹á882Ą ̭Ɇ*TŰ”QkÇJx’zq ‹*źž=KO¬rźEˇŻűdąĂu:žÍ8Ą–ĆHA%~ŐĚņ~T€IbKűŮv! 2Ą ~§űRßHÔŘ×Ôj5ÂÜ/ź6m˘*đ¬Ť7kAÝ!— J…,ą Ň;XśNTÔÓ;rů[ďďÔĎ vtÔ ®Ç×Ú5WZ¬|Ď‚˝Çt=Y×:ĺş|¤i«S@Ű|ě‡][ł†^ôk&ɵ‡ŚźŠśíjŮ·¤ďc5ŚŤîN´ß´@4:¬÷·+“Ţž¬E¬ZćäŠމ-˛uë ýü3aťžÜć-¶*rw{{Ćáa·‡{Őt团9 tľŽśsżŠöóéžIbíáđ´Ą"%%ĄÉu#đŃ ÂôŤTÝ »)™8’p0$w žĘhä+hq2’\ y褽ʠ˛LĹ—óćËKĐĽn˝\ZŮÜ+­Ü'bë”Nć ŕťV'w+áJěz‰ÚV@áÖFfłGbmj"źË ôbv©Ë›Ü˛ÉÝÄH=Ía_\Dދו}u#˘°I Ň傊ü ,Ź k­ž©ÎC­ÎĂŻÝv„´:y$c°VëŠ2ôÉÎĽ r~IaĹ;HEú¦ ľ*ýĄ®‰,dwŁ „~b]Tw/Če\xTŮ\e0ŃĆłWřQHîçK3}am=2Ë<­ž8 6~ďýZ› bBâÎo_z˘<ÎÉ‹…\ţ §müXŕa¨čác‘ůj;]Wđćň¬Îř.~‘™ŕ\~ýŤ&¸RXŚ[bĐa:Z´YéĎsÔ7üX»¦5[#VË5 †/ÖéPęk•·+ç ŔpČ›ëdcE [6ůđÝR˝$ nĐĺ˦O“;ű¸0Čîg e@—7€Ź˝Śé¬­)«GÍčQjŐäĘűŕóůŞ×yHí˘pd¦Fz–ćŘO8 dCülË‹ň(p?_U˙R±¤¬oG%łRíö[5ĚŇX§3Ý–EÓâß:™ş `mĘábh»č¨[;…@NĄŹBdąl">óŃ:~Ë&ű’ Ř-,ŘYFčĂ‘„Ú;a9x/•نÔs‰é,Xż LëŘ,®#¸FÔú:ö(Vkf®903l5lŇjŔž\qTŹ­– yŰ«bAź$öæä˘~w¦×«E®ÝnÓŽÜőU.o7d°Ů“?Š*ě»ß˝śŁÝ,Ópibg‘ópr‹ă}ć4ýŕN,VN#&×ÂbŔ‹ú®űÝuajůěI6Ť0YäJ•ăí©ÁťEžŃk†~ýŇó>mÍétË·>âŽü¤śz»Ó•ë”ń5Űa]EĘMŚŹőMçÂëP¦WÁú}ëä?ë?&&†˙FýĎŔČô§ţ˙ýţ×cú˙;ő˙GĘ3˙Ď÷żéč˙ř˙óoý˙ߥ˙y~mč˙RS۵˙ ý-Şéx€ őýź˘®9ŻÚďe~úĽ¶ĎfżÇu‡ĺÖ7żÇ&™–ď Ť„ÚhÖUg†ţY1·őRÁ´ď+Çe7?R/„-"’Pp)ýt¬VěĂÔ‚(–ö¸‡ń™ý™[–Ç.`=ąśÖ2}˙{•yŐíéíňú[ű­4ÎaĚÇú†+îÚŘŐń”äĺ`ż{’q•Ľu–dĚ]śÄ±Çu‰Ĺęj|ٶ/ĺeűÖ-Ý®íŞb^v΄ćă¶[/n0s73…ťŢö2t â»ÖÎ~Ű­O&G»ęőŢ%ĘąÓëy+®ť©ő­–ó±yo4wŕGK›k-ç‚qK˙7¸Ď:zY§\·'öô-WĐuű´B…Ân JBśeę~zćúöóşzď #‡$$ä¶Ě_҆/öFëŻöÇÝE5\nIjŮŹąă Ž÷Ü%=\J­ß×RVÜ{j§Á…ÝĐ«-¤‹N ômm,Ľł4Z9ę)pl¶ ĎĘg‡ɇůůĽŞTáF+ćŐ÷ťÍ®Ç3Ţ`•ĹŮÖ]ź&´â;ó'ëü‰ó'ŇjTÔĚéččëęTm†*ÄŚÝžÝŰťMľť‹Ŕ ŠçtÄ“5¶ÎT0ăpůKUa"Žąëĺ&Mşsʆ~6: &ĺŻ>{ÔheŇ~ó[ď{‘0|‘úBţÝĘ‹:ǤLĄA^«tśn¤˘˛’«nĆĺ©ýú&dňJ8Pčr‰IrťN2–‡ ‘,•8Ř 3PůëűĎő·×?ĐGOśv·×»›—nşf|ŃîOĎOŚ\ß,‚{ogŃż„Ĺ~)_Yˇ/ę[Ýö# Ô ęÇ»ŔöĺABLvń춙ܸ8ëńÖž9¸(¶ÁM*"Őż‹Tu@ć%Q3:}Ń(›ýa-íru¸_X‹>Ćĺ¦Ă­ŞšżĆ`â‚Á[ŽHV#")‚6Ů ˘ŃŢ&‚ĺżďÜ —é’ČüÉ\Ą0$NśEĺčŠBZ‹+ݸb¶ůüdŁý˘ŰˇE5ëŰŮŽ­ÝTˇÖô ›h.o*RYóDŤÄ€*dQܕțÇąđĂqÇĂôa5vô¸Č°Ě™ňăî6q–ëTnë‰Č‡1(†„Č$#7·y uŚ<˝˝­Soő5AWµŃ5«ně7-UŻH´ogŔ„Ą}1W'óDČđ“"Tů±l7]L˙Ypň}ŠDŠ“Ű˙Ň9RŤ) bť‚*—0 Ś.!Z„ ߸ý +řR2ĘËóýu’Ń,âigŠo÷«s+–'sD8vĘëY@DÉMu y}da3~°P‰0‹“WVî>ő,“ëă¬Hýb tX‡@xŠąt~‘tâ@›ůh0KäGţQšŰëvŹ+S®Dö' ° i#ŔĘD8ó-Ä“đOě’‘TĐŐŁ`3á’k\@,­Źě/›_Ű;Zn4ę¸JXg»?µöxÎQÎé¬2Ňr15‡ä%Á?>€1FCÚç6®š ŢŘxٵkţŮ'Ć3,-¬IĄŁŽ81 R) RŔź ÂĐBEýµrş’yĐđ*Žűis]Éł ž]-ëšÍŐąz^Ç@Ćp]'p2ËU8Ňoęş_eNĄ´AµÔ ±‡iŠa ™ TP^f5Źb™a›B0ˇ@Ňaš7:Ómű¶lš]ÓŽ @ގâg»nÂĄnšOndO´¸c”ú0`c)έT˛,ýW2@Pţ/…'Hý8U_©í.‡0<¤‡?¶ä?Źq?/ÎÖď–ěg‘^\ę ;ŔäLZ”*ĚTŽ4ţ¨Ĺš°01IűR&C‰A¨S°¸5ŐÍ‘D.1˝_C‡…&7¸§Ř¸t‚›–\¦T–° pŃ.Ňqq¸_Tµîę·ąy2sYeچ"‰<>]bĄBIY´’~ŻjĘC5!§ŔGcbí¬RĆ(2iÔ’±·" 'í~´×Mun~ÝbüDăŕ7˙iCÝ«–Ăí®±ĂöĚÜX;ýuŔe‹^şčő[ÜU¶ŽtUźŠ¬!Ť9ŤoY…­ąä…ŃÎťŘ?á$všŇ‰­ý!µąş: *ÔÉr‡łÝťŰúëc_¦ŰëýÓ鼑ÖËŤö{7iŞé…’ŕö¸öRçP‹óËĆŕâgíV„{ěs}pM˘ yQŮ)ˇÚĂ93ůާ.°Z8hq*+eĐŃJź, EX ’4ßĆO‰.Żć žŰاŠž/şGQď(E}Ž73{wNÝëmu˝'źÖßעzÁq€Ůś™)*ú,*–’WŐÖ25U5Ň8ívâŐÍv#Ś†Žšujő'%©`,Fń¬UnöA=“«ëj¤6śÇÚěmcFKv+çÓvI˘ŕ⦿„ĂcÎ˙¨Y°[ÖbËęÓÝĺGT*uľßułBJe`ăµŔĎ÷©46ö\¶F"ÄTP„ ­źŢbJ ťBü›QsaôP4‹ň7X;˝äçĄđ(vęęËKyi/+6Č%ů5ĎĎÍülEYč‚őá%š 2šnnG=k8WˇˇţÄ<—¶QorI!śŰÄ˝ZŘłW‡L§{źŽŐaůŢ×,`P%I $R+‚G#ŕnaE+ľ„ŕĐÇ2łÔiË`P7/ęť{ÜĂ®)c0@ďrľr†ßÄPŕ ^’Ą"ň{řÖ|Ič’čťčf«Wň‹¸ý”°ŚQŹ×LÂîvť'ĎĘ9>”(ěAŃsďČH·(Ę3çݦg]^u6Ćş1ĐŐU’÷8ŐO1Z4´Äńđ8&ü®$ţQCEt>íí· ÝS¸Ů[Ś@iCÁX‡łŃĎ´úb † vâćĘFdÔ©P y¤ď`X¸ÇŰ{»°Kě°:/‡1ľ˘]LŞ˛Ćd‚A>ąb´ŔÄ\RCBĂƆµ]/©ÂőD´ŚČU÷{€ř *ă[ĎL`Ífą¤ž_&.–0Dń!^˘c d TáYľťÔňE11Nf\pâcY(¤1.ň7×nő[ĚbRZ;©¬ˇ¸äfy’ĚĽÄ+´: Ł/ď—†úÍO‰2Ŕ€|Ş«EFě…ôDř¨Âj bDŻxŔźÜ€˘ÉWK˘`Ś'.!ń‘%Ĺ,†óuŚ˘ůňÖ$Tŕ‘JaŁ$ł*„|łLňĺľ”őĎĽD§â"Rś[ž]ÄÔ¤ř¦đ–‚…Ä~‘”TÓLűş J«5Ń{ě‹€>86ÔĽĆÎɱ$Ü7Ł)ޤLËŰ?0«&2 ˝¸bU˝·xGd‹SBN`Á»'XÎı%użâ¶xěĚhç Ł‹·!q W‡5j%ÁO8Ő= éÍ‚mĆŽÁTd˝b&Yˇ¨ŹCqO«E7@†(;eôÓĽVq~±ŘąŘźŤ—ĎW †­B)ZD-Ă{ôÖěŮŽrÝ˛Ý ęä«;ţÍĄ:d}a·Q­x• ą)TčGs—¸)šçŰ;íFćŕmD‚} ţŮĘŞÍkµ`M‘IÄGU¸P\żhćV×OŁ$‹"H<€bAĹ×ZÁ4ě¬\bYŢa Ş}Öś”ĘO…lvaŚŰGĂWjR«wüe•pď("Í{XA9ź-ʎ­eŔhS¨‰˛’ŇYIÜ´©•˛YýÓI7ß­{=ę©92ăďŮ\r!C ËGąj€ËZaĚVTc®™מZ0«žµH.·×˘ą?Ě3”i®BKŠĐĚ’ŇË}q›ěŠÄ sŘT5ŐZ«>[Ě›ďgĽD/WĹŤŞî¦C6|ÚPÁ–k.Ěş»Ýe]ďŕ€źA,µT&qČzž}D÷ú1đ ’««s(Fýâ±Ű˛\˛î™Ýţ&ýµť¶şˇ™Őţj"ŰÍ}$'^tAI·3Ćć˝ä˘ë›oçÜÜSycu®ŔćT”f}¤˘w}[XYZÝ1&ü)——®®íŐ®r•d{† 9ZŕY˝TúÉ’â–›ůzNLŠ´Ç^‰ĂM§@éÎÓJFuŤqů:§ýŢĺŤyÇ5ßR‡—I |Úޫӷ"K÷;莽3V›…Ý?Eý+×íz€?7ËŰ@ĺďĚţö˙Ńұ¸|l˙Ňŕ˙Wýż´żĆŇ3Ń˙î˙ýoM˙eđ?î˙Ą§§§ý«÷żhţ˙ÁDO÷»˙÷ż©˙×ű×öG˙ďO.ÝáŢ˙ ˲š-ĚýkÜČźýż'm®ĘŠűĎ‹ÓěŹĚJłU…„‚DHtŮ€¨Ű N̤ťŠ(&Ľ˘N<<Ľ čĽjP±źp¨ÍÜfˇu%€Šýy ä!˘Łý%ŃÍ*×]Ć\÷Űć_·Á_]ŔIääD ÚÇí߸ž=ć÷5ÝNëçµÔC Šn'¸^ˇ¤€mÔŠY*¦ŇçL¤ŽŠ1Ľ§Ů`;M9 ¤;|‘ˢĽö(VĎiqjś™ąź‚˛–ÜÓÖ7ôłŢňGî°ÁŁ[O’U·žIż{_;ŹŰ,Gźŕś)Uąî?:żźĺěż.H‹éˇ¶-ĆßÚúT"á8ž<žż?Ď– 3řfş|o0ňTď:oÇëx9îčŃ~™Őć$\Ł=IĹĽ( »Çp•~ś“\gqôël¶`ůf2ŇÎŢ_AżÎVťô>'îz(®ýMű2Ú¸2”h©n¨J<–ĹęF˝—^ą~‚Ü”7B56¬\őľTŢiA''nŢ¸Ú •)}ąăKM¶;óüăőnYÚuŰkŻvŢnMđł8˝‹±)ŵfoşYr\ ď”Í\ŕő˛Ó…Xľ˛ÇËą4@ć]É%‰×Ë·z'›„Ůzś¸î„Zsó¤*÷]ä«“ý7,Ü— ‡ pn1 Żőv·‡GíüĆ…Í\lőäCB‰ŔIHÉ`?­ŃĹ}#Ę3´«„ăJçŰţ’đ…}Š$­+‹ú†É‚l6#6Hvç‘jĄUŠ÷Çޤ«m¦FĎçĺ",eíWŐµ›gë„Ú†Żvs‘ô«Ş­ĐüŞŢˇ)„Űĺ›řn QŰÜžŕĘž/Ö»ń@ĺµc;ŤÚŹbĄőťšćňsЂǰ¦ ŚóĆç §SYIënŰçöÓ’Ěj &ü±„'ÁŞ©i† ó˝!ąäŔ®9—őyĆ”ĐŘ?ş8^7±p›¶Č×ŢßŕÓŮ(©¨®Ľ^wŮĚŘË+™$ Ł2)A¶L†FZ·^łZů2ťĹ„ą\ĹŢ<ÎݸĎ_¦ąă,Pj (Ů"ćRÉAÜŹMřů¨1–ŃäPőĺľÓüŚ`^ÜŻ|L˙(–/3Ňś>VÁ*$Xđ¨Ç°;T¤§¬‡—Ŕâ×+NÔ®›ÖíÁëĎmënŔ6Ë>y+mÍC•«ô#Dč °•ˇ†|ę… †`ŠľVzźä~¦@{4PŢ>l$śďÇŠS»ňpôCJ‚ŽŹGü8ŻÔß9ޤD-/AËͦﺕűΠ÷Ţ®˙Ýzť+aźU5‘“4âýşă˘ěĺŐ1+©ÍŘr{š°¤_Z.”<ÇŚŞ©Ž´üßĘh”ŇÉJl— ˝áŰçűUç™+€¬·’٨·‰¨bý¸XĹsŮĄś8ś#ZdĚ˝o©Tęî7ú¸q$ś—˘^Ż·đlŰ^ŻĚöŽŠ Nz8´óş¦(ČĄ LĆfCl˝ŤS}(ő|G0¨¨7lZfÁř*ęęqŕÝ×Y«ťa¸×¤cÉęr»©}?Đc=Ĺf†-tcmćî÷OT7ĆZ¬’H¸w_vµßvýúĽ®™q·Śł®)®"¬WVht‰n„ ůKŮw°SŁ7Úr.Ců`¦ *Š–U€W¶ ŐĎvTÇżť}¨0í—ă—ç¬ÖäÜt:Ä'8cöÚ '*c‹Á…vK‘„ý«°qŔŻ®âM×cě¸}Üî¤IWH×°ck«űášÍ˘ţÖŮP…9Vrjëy—šG…âłNÉţÁ·:¤ľ˝¤Â[X~˛C6ş=C„k`%ĄG3€ĆY—0™—7Ee ·°ÁB}ˇ vÉ*“§fN”w¬Ű#¬B×ôW‘έü8Ş?—­×Çŵž„ČŐŚ„ŮÇjXčńésQ®đ»€Ől뢙ř”!ă…°"ĐČ­É8MĘĐŚ Ő…8[É\F͵~¶ÝŻą™^$÷s¤ kß()‰G62Â?÷ĄĆö@ó›/˛fŮŚMA/ˇ•=V¬?Q=^qżxÓż‘p?6ľ¬Ôf żťĹ}·´í đĎ 'Ř›ĹGç]Í© HLKŽPş¨Ď3ÍŁ*Eu° ç‚€ÄƤ_®  |ŁáĽ-ô>S¬Ń*{>c÷OJ ‘qIÉNžŠBÉSíŻ|„ cw[i>§Öşč~ÇŻr[=Ć‘Ŕb«ë¦b>ŹŁwşYĽ®&K×ÎĆěe‹i mE!GQMČ= ϵ’ŤČö+ŕ 1:‚NeŰ×sZĐ_>qÝźÝHzĂÇ}ľĐ¶]×Ć*!ÉΖ ŚŔ¸ĺ(‚@ţÔíĘ>®÷ś˛LÚşďXő üxővî©ýz45üŐ=Ćŕýně–Őë\©Áń“MAąk˛_ť•n)J.!rĽm1@)"EłägMsľ„moYÝazămůĎ|<Ąj»ŰpŰ|˛Iľą€Ë:* Ýw¬›áôô Ä#Ł„%»—¨MgÍÇRGaM‡…Ö5ď™ySč‹ßgiă G„ô.¸r-yQKar/%f1Ä M»€ŽÍ`gű‚Uč(kÉuŃ8AÇ®Ž+ ĆŻĺ`x‘ćĘý̇µL$Äʰ5z‹ˇŤa‘ď¨Őś¨Đ„ěÉ´ŰŤ2ßn˛îŰďŰHv Üwpw“¨_ąîB(š Ćą 9èÄNf6Ű Í(ĎHĹĄw1Ĺhë¸ B$‰R?ń‚š¸‡Í± ąĹ[UW‡ˇ¶•˙´Y/ĐŽ5ŻlÚ›ÖϤ˙(.ÚÝśAögl­}K}(ńħ==)?YZ­zUŐ÷3V·Ók?«,Đőo&8Rż&hÇiżÖk?·E\čk´nĽŽ´O÷č»;Ys7Δi”¸ćQD[BČqôW˘m–4@ôF lwDÉ)A`˙ÂJů}fc¤ŕËŘ‘Ľ=ÔB›‰ő“߼Í"űšfyůg­”-ŚąŘW«ŃűLa®Ű·µ`ËëÔŰŃkŢΚwÜ ŤçĎŤßş µđ‚ćᦍ-°kĚi~¶bâç’ĂLłé-±”.Mş—1Čd+DřC)DŘ-„˘ŘCŞŽôp‚ن‡qÚ–.ĚťŰ÷ń…×Í€l´<5sH¦ŕý0ĎE]UˇÍYN—^¨'˛éŠ ‡nĽ_¨śN •’!ŹűÜvĐëÎťĽ}™ ďyA.¤:D€ŰFß{Hm;oš@c [UĽřĐŕW*gÂsQG.ě ¨KŠ8¤*‰QpđŁ›ńU…^„J—­ PĚśEĆý} d<0E&źŕĎräbeÚ‚żLW÷ĹĎĚÓŔKłˇögťŽů»ýĆÝĽ÷ÂŞ%óŞmôń×á‘[đbN‰˛ŚĐ®™Ú ĐirF$HHABIpČŔ ±#Ň~ Áu˛'¦‰CĹ}ţX5BhËQ;®ÝÔvÄhů`we×4ŮM˛U#ş‘q‡ˇl‹+Ě@ňjă/[+µIÉš±H’}9üĂX\îţQ‡ 5†k/AÖq¸^SqDG®7ŹÜťw˝RdCä2źřZ*S¤ÜÂQw  ˇ IÉóhÁb‰iŠ }Čj& Řđ%9VÇâ­Ř ™®ňý02\ %‡}f!™ĎŐ÷¶×[# 4ŮśZŠ~€DJ«[±·ŹYp»ÁfP_Ë(T\€}vMB\»guĎ7XçĺO[{ďřęÚ^ąv•ČśU}ąbó“Ůexyť·u‹ü“ĄÝŘë–˛_ĂL^R<1*ŞŰd%]E ™‰ŔÄ>&““­ĐĚOtóŃ=ҰöńVP…¸Ářý1—ä̸=°ÎX{ -ý»—Ň›«çžŤKÍŽÇ%§€™×éűĹZLăoěĚ,6Ő:yG @ź0‘JŐФQr‚ČĹżúQ-z/půMbÉ®ě›kwV6•"Óe»očk<•}Mz9E=YâÜé^]^¤íůjź 3Ť'‘ĘŁI–ş4!…/ěŔCš{™Kł†TË5Á Š#?®×HtŤ:Ă[ăŐ¶ńäFě~v,üxuűlÓeŰ‹ŞśÎ°íĄÍŮY¦uKŽc»z”qŢ"q‡űĚćşÜuČU!1ŘÜ`!ş­AŞV|Í“Q—ŢD“O.^°—:îčÉűQÓ ŢSŕ¸Ü–˝ó¬=Ď{IŞŁś¬¶wŢQŃźŚ# űŽsŢ2B~:ÇćĘĎĆŞŹ'´ ”’€Ş@ép–ó %Tę±'1=tPËŤ,Ú‡QdŢkç/[±ą˙ŇîŮŹxwÎÝ=ŐmĄővµÎqŇy~Śr1“ĺ •őxň®0ďţ$NWÂ0=4&MŠźhß{ôŁ`@[µĎR´żgdĚhÄ¢ş™Ëm2 úř\ÖyĹ•ů«ç ć˝öÝ5t¦}%÷Ńôy_OA} U»-9Züw`“ Tš-HµścEÚyÝ“`z?ô:ŃŃÓ®.ţP7kÍMńĆ•ź«ŕđ—ČÜN´ץĘĹýÜo—đTíi8ÔşDQ,í©SPš(L(ÓŽ˝Ou«ĺą´4ˇŚĐ1{?j%2¶˝<Ď02GŚíw“ŢËŢîⲞ(;.Cç9Î źÇť(ó-ŽáűiĹ€¶C|‰g}M¶xT㕊 űvHÍs{J Ž’CSH ˛Pň3>-›Ú¦Č€őŹ GÚ/7žď.źş:f$µ>0ĎXżôUŐÖŐÝx/śłő˙\Ö¨q/ßšK14ú ĂÉŻŘĺ˛"# ‚«AĄH2aÚ0u,‘ŚI ŇŃąô­w”yťDQ±„ĺ-ɲ°ő-Âz˙4©Mú›_pŘť…áŚňŤ¤P>ö ą_•?ąo<µ‘ň `»á 5bî"Ű*ődgŚ2•3ÇXŰđŹŰ1ţ•«Ń–ĂH\—wí˛"ÎSSŽh9•*öHÓ);Nľ(Ë24fľ¬RÉ ..]ţÚ!š#ÇŹÁoËW§ěç,XC§Ťë• ÖëoQoăŤkC^ĎÎ;çUŻř×ęI m,ăŐU*#Ý„ýŇ@ČÚ_Đôâ˘Kâ9{,yc“!żß’Bń@¨†@°Č#’Ŕ6o8éMsUĚJű¶Dâî>-źoŞß×:•ďř ż$i{6-µą1Ă3x¬ţŘđ…~şĺî´tĆ%üŽŘŇBćI\U“@QŠXTƱЍEźB •÷¶Ř3ެŃuŢzVO‡ĺ:Ăę†~űÜ#5@Ţ/@ž;5 «gÓ‡-QMČĄSŢw!㲪S@•¸Až.Ë‚,˘—“&hB0&ökVˇá¦Çö–¦ýLC8,ߩԏVő~)÷c÷¦Oé9;Ŕ¸ŰÚur|·Ýóv5¸‘;QGţŻuąWfö‹¨(_HÝ'¦r§xĄŽ!,1SIł‹ş “4űthĽ^ýr//Öׯ•ĐaŤXťÇ™„Vq›og˝§čał{sĘU…ÁĂü‘ô±ĄLń·M}ű>©‡ŹÚ†ŕOĂŠRć‡uĎ$”KÁšÍ˙°]÷´j˝…cżçË|@ćîÍät›.x{dE`°ÔW­ň/5¨çs<äśF(^ö†TŚN䱊1N]Ëţ9ňc¸YÂĺ:mŤ\Ś‚$^î ń±“J:¦M—«›ŞÄ3é*^‚phb7sťĄ˙"9iAµ~DWLž’^©Ůt¶Ź?ϱ]út~L_A&ˇ-iéQh^˙|Óí…¬UÇ+Nd9ĺuëţ~’–]IóGJşĐěd3úć¬"kT16X^Jjňçř3)Ü„T‡ĺ¤ůŚ2ôŽôÔ®Ř*n~KČƲ%Ń›8¤ťÇýÎ2Ż[Ňa2ü I~ÖrzŚßČ‹†Ľ;˘ŚLĐ»ŢĹWQES_2`ŽJuF/.‘:´-RsŽ´Ź”ś®‡).ö‚†ßw!0Ů;#]ŃÄĐD2Ŕ‰ Ă©4]Z-˛ÂŇĆÄ0€_¸ĹţŕszG’ý˝ĹfŔW÷śowµYŁ~š$MŇŮŮůŮre#ĹÉZĄ˘ô‹íş\Ł"ĎFöpJ`Čťţ©ß‚áë ]ŻL‡Ź„t<¦äć‰"…NäâÍE$ę]=żŇ-DÇa"Ď x×ă[,Ű”sJ-~S ‹M¨O­żMÜťĄUBáľĘ‹ÇůůK™ÖŰďKIˇf8¸Ne3Ň{6~žÇRgK#ŠáLřL^e˘–,aĄ®Ôďósš ó¸ŰŁŘś÷¤KOŻK[]®HÔ˛SȧÝ.ź\†= ŰÄvI=Şűř1™=j‹­µŰ ˘03‘ămr˙rßëm?T^†Ô»¬Ş=µ±ý¶"›§źq’&zŚ-ń‰öÚC|fö&} T’?L¦ˇZ„ÉN—KmÜ´/u{:ĐĚě"Ov•¸7[>@4[˙K=`şŽžŔ†‚U˘Úô†»ŕrxJrn§şÖŤŢÚËYcišŐSáAˇP@Ş?„¨Cp°H°„?}¨€ŰűĹĹ)-»ó z¨ˇĆ ćçň Ą(Š9Lńi“RĄâ~]ZµqLÔ§’>¤â~yâăcB—5ĎEö™Ż//ăÓÇ·o‹¶Ü›ŇÎÚ×l·-Ö.mröĂ)‘Âńşi±čübX*STŇ?l|NŐżiÜßBzÝŢŰź\ÄcZýŕ]»­t. âŕľ]č·ß›ă6°´Ôüâ,"ä0‰—ť°w5ĚÝ­ľ~Ç„Ç`ęÇuM‡IżăďáqNÔ®ă ;ŹÉúýý”¸ß[ą +ŕv$“rO}ޞp  z#;ďľßîb±Řl8ŕlhWŁňbą‹öÍÔçZamé“ű«áÉ‚!Â/!•ó˛ şő M-ŔĹŔłč¨ń“ÇÓööÝ?0šŚÖĎk ëă\űą_7XŰŚnŽý¤RO,˛PdÍX@zä‘UśŤon Ĺ­ő(ÜÇő$ľ¬Ţs+l=Ő‰s[,|ŮĐřÂő~;Ż=âÓ"‰+©Âšn»n6ĽYßYC}A´‘[ĚFş—ˇgZĽŘ†RŁo¨Ź<ţ¸źőőůî”äŤß2Ľ˙` VT,Hvc{t Týɉ˘ L/DVH—ˇgH7ŮH䔾?S ęćzTbŠMčőh`>AÜřń:ŕˇ~!ŽdlËü yܧ¦őĐý9Ô^ŠóÜuĽEű'öť±ËŠ ôÖcÜ(Űk°Š0Č%©üô§é†x[ŢJ8|°Ő`VŮxKˇg»Ó$xűŐĎU mn÷ĄŕrŹ÷ŘŤĎ7eŻ;ůž”h„čěŕÖŢ Šš!¤2É l29ËąSôŮ\>ţjÔ:ĺhTQ5ú—=·Ô:JÄUÂ]z]îç“ ËłűÖרç(é‡ç g¸ˇ:´^-2|ăŕ­D] Wę]$!Í1g—ž)Ž.Ă—C·µÁ—|xS€Ź[˛í~—k)ľ<Ž‹&î,Ä:¨„Y·fŃąQ‡/kDoŃ“ę]źĘ„=­5m~čdď×Y­Ě‹I+˘o!,łŤĚ|ÖlĘ]ŻĹWâ/ç7™)â#Ç·E[I× óDs`.ÄÉ?E;2q›ź¦lÔ´ťČď~’—4śHĄ>S›y[t„]\ŽđIă×»:–$Đ7.aň8úLËfj§6Kzń_ˇ^3<9bĐäő,řËQŐ@§â 2›pFŕaü|ľ”ÄjIĄC=łD@0&’Ęݤ“@CíŁ\4ËvKhÓŹřCKĘ!wj”l)ŢŤ©âĽSk·n~Ňz]šŚ`^+^{čcćŞřq3•tĺCQ‰ÇŠź¦§ńąB˙;1ß"Ä~ š š|ˇZ@1 $ËCŇ{ĐJu„{łDşäSN‘MrkM~CFÖx„Î~Ô{9É~žń.RÓAŇÁŘđµp3eYtÉ“€*ÔĎÚ4%ţćßGćŰď7óë8D°Ôpô¬r„ąOiŚ[fú/‚%yXÓYŇ,¤”Ů$NâE`|‰¦`ÉÉŤPý$&Źy¬Á¦¤$ˇTÉă˛é$}hIś^ČäHšC`ŚĘśł×'GnôúhA€“Gťjđ}á‰$!ĹĂřĘŤÉĘRÝŕö^^˝úY÷Ó~Ô¤O©@”˘Ü…óQÁyńslŮ |„OěŘŤţŢŕvIČâBý3 .ľ’ß°{ůŔżçTW|¦i6%î á/Kž)”°ŚT&©,ÔFŕcďJá ká·ď¦1E3‘Äě÷@P§LŕđIśs‹ťăśFĘśL×ŐĄÖłZřňŞi/Ő|&ęe *ýÉŐŢëA,˛ ǰpŢëlB–Šm¦Ç’Ź„I\ iÉ´KM2—8uĂB<âu¤6ZqäŽü»,˙J… v”>(  dD=+q"ň±(ßqŤ¬ Sy :(¶ČwžOĚ=cşńEő°•¦ů_üS}ů`ë@±čӤؔk=ŚůÎú5Ü/{ÓG  :¬q6µ_‰ŻŤĎÇ\mĂ{uşŃŔ…đѨHgs '©Č`ŮîU‡‹I›ůćnoľ»LŹ’DĚ 4RŠ@ô”äbö˘yé—  @ćUćÍ×äçô‚¨„!LxÚ«!wşą“ćĐö´w.ł2ţJzč]j©ÂUýMNßÇËž'ĘőíÚKnż`ä¶y¤Éż2"D3pö“5'SÇ@qv0BxJtSާÚG-§naŃA$ʡý±¬‰ŇMů—)śId¬:bşÉ×5řŻÜ` ’ZBb~uájŔ:ěB‘6^ŐO;ŠŮ%¨ňÚ˛Đ38uÖ S“é-ýĆă4Ť—WIéÖ­—3 :†Ž~MWµ7-Tµmź)ę>…ßĎLé$ôš J“Ő•\X…Ö3† Yd/]ś‚śŔ†ňËś8Ť3ž¨VŹR&B•''»°ś,űÚčż`IŹ­ńÓÄŹ7†Šń‹…Ž»řěLĽ#żĽŰRóŘ8&e Ę ¸ôúŮ«`zů±Ěă©CV®§ŠÝNţ"€¬÷—ýÇ.Ü7]Ń}ó15ťdÁž/Ń`9ć0Äß˝saP…ÔŘ ŇŻE”¦NMýx¬ťčŰš'FŘ d  &ĺ‘ÄÂS˝q‘CÓsISö2ő 6A2ŹHéviôxAĹÎĐŇÉT@Ď6 ÍŃ-•č«ô˘8( ‘ôôŃ€ ŮSYU KŕN§m6Ť{µż,f˝.– ű#üŘó+/gâ¸*WM‹ô&ęËľ¬+ 0ŘNgńfÄ“ǧ$„šĎ˘áöî%͉SU¨âť‚ş1ŞZ›¨MŠ),°bčżöm15°ş‘¬z>oIĂ^H",´Ârś–aôŤ÷Ůćţ …ĚÓĚLe_Ź?TŘ#hLŔľJ¬KŚAĐFFPźP˙ G—"!… °öšŮ±5ŻuĹN·B—Żű*%‘„R’ ë›-ş”ÜŤę ,˘!N CÇßŘŃ´r|Łî°¤ü…  …‘OtMj˛%ˇ(ťIˇ‰FKZE«Šu©ŽÄęÇY™ö^QÖ5Ě#ĽôÂX˘T¸Ëx~ú”ćß@Zláa6ą BW˙F,ĎMFěŽ[¶|OBv€P#Cˇ¤Î4‚ =÷Xrú·Qęh8”–†»”ąđZ>”ŠY( ZMP[ąé,?†ÂőĎOč„Ŕ‚(Ę}şŽ<ůą€‚x3>ßËMŹëE4äBÝ ůŰÖr*ŁwzFClÓiUvN*–EbčĘçaë F]őM_÷†„ň× ł-óLęűLľ | ł¤=ZŕÄčRë±Íű¸_•ÍGä\¶łý†Ç&=‘˛YĽ±Ń3P_e€Ń)C‡üěQçřľ~7H™8d‚iŽô4egÔ܇Ę©ë εÂ(Í5,¸Ř™ötáKPF±ąTŁĄ&wŔÉ{ 5C=ý™cX̰ű#÷ŽhÚT2ĂŮúLîÍo@ľGîŃź©˛-µŐ *oäżÁú°ÚsDç– ¤ÓË;ë}Şžă%]sľĄp¨ĐÔÔďghW6 ©HŤmä°ZóŞÁô«°é]b©\1ůô”Ü´(ć¬˙aę{:Ĺś}”5hŚ!QąŁcAôhâúýzZ‰7#Ł=[!ę,źi EŽ)°ě ż(?_áÔŹ‰l?ak#Ú,äi$· S†Ŕ•Ć›ŚęZîź«˘!sO3†_Ý`q鸱hÖ“ŁZĘ` 4yđ;'D:Ëxx—&ojýy±hE°ŰTbRCëdăI{”“ĹLÜG żĚ›GJ¨+ŮŹ˙  ?†°Dµ(YB+)J[l´Ńk'Źů´ä¸TM•Mîź«(’¶Ą&^@)e¬óĹUŠ!ű23Ř?=]ŚµĐ„0ź!ňC¸.r„,[:€űó†Ç„O›xŘH?ítôtF7DÚý1${}“yR„(]DhHŔ†?Ży@©?ěWýä˝Đ[ą…drĄ"ź†ŁďS‰ @Ű2ä|ş2ŽBZ¸˝Ă!¦çHŢ(rĺCPíV¸>v eĚ-ˇě|ľÂqŕQ–KŁ źˇlŃ3„¦7 Úóă}kâńć‘c™ŢĆ®®xá:]÷ąĺ"w‘Ǹź)"š rxőű PĚjźćuŞűŮz˛ŮäŤrýIŹ„”Mlô’Iůg)kˇë ŰŠY2)ú&ŔsĘA-źędu|Ť—ľ˛ úĘíy±•–nť˝‚§RĆ0ëo±˛ń™"č#ZŇ*MšËŮaŠ ˇŐ0Öň)đ̆˘2Őń•âRÖÁU1rÂ(.mHGľJc(kŘUŔź  Ž8Rčaęk! …÷©ŠŁ`Zč LĹ«bćhtŠňPĺÔ')ýSÜNŮńüˇŰVžü‰Jg@4_ˇ0!§^·äU°˛x®Fš4ćů5řü}CŘu׺ĎskťŠÖŇ,=ĘD6›‰ŢWĘ qÍ©ŘÎŇż’J ¨Ýq¦YHl±U®Á˘"‡wÓ˛~ńQĂYł ÄőČfŁ0óµuť}o‘k=ÇZźŚV YĚŇjĘĄŔ¦O'6˛=BÉ«HŢ%Ś)ϧVÂŚ?ćsy<ęt±„+ňWvĎTň¨›,&Jł“B]yIpŽŐwŰ÷«.í‡î¤wÍć†Ďc×h¦Č=&X`´dbE&´:ÉÁüW\íŠ Srˇýn]›e‰¦e˛*xVXŞ’(ĐK„ !PĘíď+¶ýŘ­ŹđëÝ&V™ĆQ ©čt“¤—ţHKńŃVJg}B1‚©=h»X ä9SD’ţb¤a±y’R1ćW|´d¨––¦j †ů˛ëdX>:ś‚‚¤‚Ĺzîm)ĚŢçśp=랡Üž Q^#V±,ąX,¨~̡JnäđK(‘}ĐÓ 97Pçů—ńrÓß„—ŃâăŃfłË»ĹĂ ŢŘ•§9D’|îWť;Â๢–G%–ŠĚŐäy LP‘‰2%ś'™9¦q{ ™úL€×čFí1˛ä@%â Gó-’g2E§Ł“řađa7dő‚Ó’ńBÉĺzşňZ [ÍT©ˇç0%kµ® ™Űy_{¤_îŰߤ1„ř7Ëu“¨JB1ËŹ¶"xő&łÉřÁ×PęČ…q8ŕ––â5H'M «Í®iBčk|„YÖůĂ<ŞĄ1Ĺ5Á  ©ľUŠűd‹ú ZZĚMú[Ę6ăe ­ĐĚQĚ€ZĚ0N›ŠršűĺŔ‚‚nÖdS©ZuĘÓ•vĺŁ.ő<ŕˇä.AX"gg\řEya±;ťIčAtMÍYĘ˸ńŻ)ÍHv™±PćX1*ć›ń»9$ŕ÷Ë/ŠXâ@[3Ţ´ć:I©éĘP ş^Übl_&ëé|m˝Đ^!8Ŕ•HÁAžÝ×!)AűŚ2dáÄ9 §VoďS 'R@şűýňˇ{źß\-^şä{l±TńÖ'śi˝ I9g2بw©ľM^Ηʬד„ŁÝ*dŻ×ś¨áÍ}…ÓřúŰבŞÎµ^Ë“äŐĐ—őÓ őpMEtďŽúůöôáô&š‘ *ŞŚ©˛O”T5z!d„Tđr\Áź&Eô·€eiUL“‘ŞC€Qň"hô xÄP!Pryů±;ŮëśŘ¦›Ňé÷ż5ŻZŇwŤőYNé~‹ÍHßi}1ϲ~7®¨źWëřJçŻW’ě/4‹_=čC$f'+’ĐĹĆĺh‹rfi#"«ÍĎŽ“#ßoŕČPĂC j wÂń¤hm=ţl¦ěJlřnÎX‡˝›î”Ó–1ć+\4¦_CČÄ«—”Z!+Ĺ €‘˘ßµ7©„Ě ë›/ŔX>y?ßîÁĄ–“ďҵ&“@™îOŞŚČ+í–i'ĘŽb˝řššDźnŇĄ-°&“W`XÓú H‚őeKÂH¨č”ČĘQăMH‹"ÁUV)98ŐŹů¤ôoŹ˵ÚBICgKQ‡›ö–¬Ĺ ű䊉GĘ>Pˇ>Ωqč“6 ™úK”_‰Ôů‰~ďÁ_"p¤˘Mpi÷á“H$aDÜN@ďĂTěvÁaw>ËolĽĎŻ34)ÎĘÉńPň4AGΩŰSľ?ÝěÇMęrElÓ´k‘ľ@aŃ ‘ç-ç«‹–§f I«‡t ݆hwÍ+UĄ‹Reމ‡ăňëÜ?*«ÚÉ ŁVđý9ßaëÇQ/YŹzxx–ÓR} áĘ-„ -VMܧfhČ‹ošůý[/¤?ßbĽśš˝Ą‚ŃB©ľn•|ŮmúčR˝ąôŕvťÓiďą{űügŰyiĎR«ËJ­Ą±ď ŻuÍ€s˘"‚úÖňĺĆ% ˛°6öˇ3aKŮöÎ5ČĚĹË}^ě>EYqLgĹÂ{šÇçÜI>owűśGĎĚžĘ9kîϰp8ž úő´ĄCzmÁ]yDYE˝Ś(«PT˛řŠP±rřlX9ČQąź§¶’l|·‹ŐřXJŠ%^šëO–Ďëv¦đ Ć;zĎqVň´Ü ĆěżJ^Ťë —ô .IŠ@v'šÚ @±°u—bĆćŮř%Ł{Ą§*ކ܆Wl´ĹĄY·űd°{~˘Ü¸XŢĆÂŞ˘W¤FfÖŁýˇ%°ö9>‹Aú…śo úŇŽLN"†‡Ž?ďg˝,h?Lî¨n˝7R.†qľ¸ýŚ:ňÍÍ8ž–I“·‹ő+@‘TÉNöu"¤+vÎ TŤ5€b$qâžY üŠvgKŤçë·«Çا•]ířˇŞëăü¶Ú€1>%féµK™LÂÔ¨ÖíŘű‚űĐzxşVöx$††÷÷´ë_˙ăZţ®ĺ›żą¦˙lCDđˆ€čŮ“˙ÎżEDLNEEţaCô÷üů‹ Ő?°! ţ°ˇbçúeCHôŹl¸(˙© ń?°ůăzţwâw˘zţöďż(Ź‘ü·\x°Cý˙¶Kú7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7~ă7ţ ţ÷…KČKoboDeluxe-0.5.1/graphics/0002777000175000001440000000000010734700730012362 500000000000000KoboDeluxe-0.5.1/graphics/Makefile.am0000666000175000001440000000034610706003614014333 00000000000000noinst_LIBRARIES = libgraphics.a INCLUDES = @LOCALCFLAGS@ libgraphics_a_SOURCES = cs.c sprite.c filters.c glSDL.c \ gfxengine.cpp window.cpp sofont.cpp \ display.cpp toolkit.cpp vidmodes.c \ region.c EXTRA_DIST = *.h KoboDeluxe-0.5.1/graphics/Makefile.in0000644000175000001440000003506310731616146014354 00000000000000# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = graphics DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/aconfig.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru libgraphics_a_AR = $(AR) $(ARFLAGS) libgraphics_a_LIBADD = am_libgraphics_a_OBJECTS = cs.$(OBJEXT) sprite.$(OBJEXT) \ filters.$(OBJEXT) glSDL.$(OBJEXT) gfxengine.$(OBJEXT) \ window.$(OBJEXT) sofont.$(OBJEXT) display.$(OBJEXT) \ toolkit.$(OBJEXT) vidmodes.$(OBJEXT) region.$(OBJEXT) libgraphics_a_OBJECTS = $(am_libgraphics_a_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ -o $@ SOURCES = $(libgraphics_a_SOURCES) DIST_SOURCES = $(libgraphics_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUDIO_LIBS = @AUDIO_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFIGDIR = @CONFIGDIR@ CONFIGFILE = @CONFIGFILE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIR = @DATADIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXEFILE = @EXEFILE@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LOCALCFLAGS = @LOCALCFLAGS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATHLIB = @MATHLIB@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ POW_LIB = @POW_LIB@ RANLIB = @RANLIB@ SCOREDIR = @SCOREDIR@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ VERSION = @VERSION@ XMKMF = @XMKMF@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ noinst_LIBRARIES = libgraphics.a INCLUDES = @LOCALCFLAGS@ libgraphics_a_SOURCES = cs.c sprite.c filters.c glSDL.c \ gfxengine.cpp window.cpp sofont.cpp \ display.cpp toolkit.cpp vidmodes.c \ region.c EXTRA_DIST = *.h all: all-am .SUFFIXES: .SUFFIXES: .c .cpp .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign graphics/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign graphics/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libgraphics.a: $(libgraphics_a_OBJECTS) $(libgraphics_a_DEPENDENCIES) -rm -f libgraphics.a $(libgraphics_a_AR) libgraphics.a $(libgraphics_a_OBJECTS) $(libgraphics_a_LIBADD) $(RANLIB) libgraphics.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cs.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/display.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/filters.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gfxengine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glSDL.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/region.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sofont.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sprite.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/toolkit.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vidmodes.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/window.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` .cpp.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $< .cpp.obj: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: KoboDeluxe-0.5.1/graphics/cs.c0000666000175000001440000003120610707177560013064 00000000000000/*(LGPL) * Project Spitfire sprites + scrolling engine for SDL ---------------------------------------------------------------------- cs.c - Simplistic Control System ---------------------------------------------------------------------- * Copyright (C) 2001, 2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #include "cs.h" #include "logger.h" #include #include #include /*#define ABS(x) (((x)>=0) ? (x) : (-(x)))*/ #define ABS(x) labs(x) static inline void __wrap_point(cs_point_t *p, int wx, int wy) { if(wx) { if(p->gx < 0) p->gx += (-p->gx / wx + 1) * wx; p->gx %= wx; } if(wy) { if(p->gy < 0) p->gy += (-p->gy / wy + 1) * wy; p->gy %= wy; } } /* * Make one point do it's thing... */ static inline void __move_point(cs_point_t *p, int wx, int wy) { /* * Push filter */ p->ox = p->v.x; p->oy = p->v.y; /* * Update position and speed */ p->v.x += p->v.xv; p->v.y += p->v.yv; p->v.xv += p->v.xa; p->v.yv += p->v.ya; __wrap_point(p, wx, wy); } /* * Update the motion filtered output of a point. */ static inline void __update_point_f(cs_point_t *p, int ff, int wx, int wy) { int ogx = p->gx; int ogy = p->gy; int ox = p->ox; int oy = p->oy; /* Unwrap filter for correct interpolation */ if(wx | wy) { if((ox - p->v.x) > (wx >> 1)) ox -= wx; else if((p->v.x - ox) > (wx >> 1)) ox += wx; if((oy - p->v.y) > (wy >> 1)) oy -= wy; else if((p->v.y - oy) > (wy >> 1)) oy += wy; } /* * Interpolate output graphics coordinate */ p->gx = (ff * p->v.x + (256 - ff) * ox) >> 8; p->gy = (ff * p->v.y + (256 - ff) * oy) >> 8; /* * Wrap interpolated output */ if(wx) { while(p->gx < 0) p->gx += wx; p->gx %= wx; } if(wy) { while(p->gy < 0) p->gy += wy; p->gy %= wy; } /* * Generate "changed" flag mask. */ p->changed = (ogx ^ p->gx) | (ogy ^ p->gy); } static inline void __update_point(cs_point_t *p, int ff) { int ogx = p->gx; int ogy = p->gy; /* * Interpolate output graphics coordinate */ p->gx = p->v.x; p->gy = p->v.y; /* * Generate "changed" flag mask. */ p->changed = (ogx ^ p->gx) | (ogy ^ p->gy); } /* ---------------------------------------------------------------------- * cs_obj_t ---------------------------------------------------------------------- */ /* * Final adjustment of interpolated graphics coords to deal * with the display window wrapping over the edge of the world. */ static inline void __fix_wrap(cs_engine_t *e, cs_obj_t *o) { if(o->point.gx + (o->w << __CS_SHIFT) < 0) o->point.gx += e->wx; else if(o->point.gx > (e->w << __CS_SHIFT)) o->point.gx -= e->wx; if(o->point.gy + (o->h << __CS_SHIFT) < 0) o->point.gy += e->wy; else if(o->point.gy > (e->h << __CS_SHIFT)) o->point.gy -= e->wy; } static inline int __onscreen(cs_engine_t *e, cs_obj_t *o) { int gx = CS2PIXEL(o->point.gx); int gy = CS2PIXEL(o->point.gy); if((gx + o->w < 0) || (gx > e->w)) return 0; if((gy + o->h < 0) || (gy > e->h)) return 0; return 1; } static inline void __obj_set_layer(cs_obj_t *o, unsigned int layer) { if(o->layer < 0) o->layer = CS_DEFAULT_LAYER; if(layer >= CS_LAYERS) layer = CS_LAYERS - 1; o->layer = layer; } /* * Add object *first*, ie with lowest priority. * (Hmmm... Isn't that how some h/w sprite generators do it, * if you allocate in increasing channel order?) */ static inline void __obj_attach(cs_obj_t *o) { if(o->head || o->next || o->prev) { log_printf(ELOG, "cs: HEEEELP! Someone's trying" " to short-circuit my guts!\n"); return; } if(o->layer < 0) o->layer = CS_DEFAULT_LAYER; o->next = o->owner->objects[o->layer]; o->head = &o->owner->objects[o->layer]; if(o->next) o->next->prev = o; o->owner->objects[o->layer] = o; } /* * BEWARE! There's a nasty hack in here; these objects need to * keep track of the addresses of their list heads in order to * remove themselves properly! */ static inline void __obj_detach(cs_obj_t *o) { /* "Bypass" */ if(o->next) o->next->prev = o->prev; if(o->prev) o->prev->next = o->next; /* In case we're the first object in the list... */ if(o->head) if(*(o->head) == o) *(o->head) = o->next; o->head = NULL; o->next = NULL; o->prev = NULL; } void cs_obj_layer(cs_obj_t *o, unsigned int layer) { if(layer == o->layer) return; __obj_set_layer(o, layer); if(o->flags | CS_OBJ_ACTIVE) { __obj_detach(o); __obj_attach(o); } } void cs_obj_activate(cs_obj_t *o) { if(o->flags | CS_OBJ_ACTIVE) { DBG(log_printf(DLOG, "cs: Tried to activate active object!\n");) return; } __obj_attach(o); o->flags |= CS_OBJ_ACTIVE; } void cs_obj_deactivate(cs_obj_t *o) { if(!(o->flags | CS_OBJ_ACTIVE)) { DBG(log_printf(DLOG, "cs: Tried to deactivate passive object!\n");) return; } __obj_detach(o); o->flags &= ~CS_OBJ_ACTIVE; } /* Basic methods */ void cs_obj_pos(cs_obj_t *o, int x, int y) { o->point.v.x = PIXEL2CS(x); o->point.v.y = PIXEL2CS(y); } void cs_obj_vel(cs_obj_t *o, int xs, int ys) { o->point.v.xv = xs; o->point.v.yv = ys; } /*Set movement acceleration*/ void cs_obj_acc(cs_obj_t *o, int xa, int ya) { o->point.v.xa = xa; o->point.v.ya = ya; } /*Disable display*/ void cs_obj_hide(cs_obj_t *o) { o->flags &= ~CS_OBJ_VISIBLE; } /*Enable display*/ void cs_obj_show(cs_obj_t *o) { if(o->flags & CS_OBJ_VISIBLE) return; o->flags |= CS_OBJ_VISIBLE; /* * Kludge? I'm not sure this is really the right place... */ cs_point_force(&o->point); } /* * Remove and throw back in the pool */ void cs_obj_free(cs_obj_t *o) { if(o->head == &o->owner->pool) { DBG(log_printf(DLOG, "cs: Tried to free free object %p!\n", o);) return; } cs_obj_deactivate(o); if(o->on_free) o->on_free(o); cs_obj_clear(o); /* Set up head pointer for error checking. */ o->head = &o->owner->pool; /* Link to pool; singly only */ o->next = o->owner->pool; o->owner->pool = o; ++o->owner->pool_free; } void cs_obj_clear(cs_obj_t *o) { o->flags = 0; o->layer = -1; o->fire.rate = 0; o->score = 0; o->health = 0; } void cs_obj_vector(cs_obj_t *o, cs_vector_t * v) { if(v) o->point.v = *v; else memset(&(o->point.v), 0, sizeof(o->point.v)); } /* Animation methods */ void cs_obj_anim(cs_obj_t *o, int bank, int first, int num, int start, int spd) { o->anim.bank = bank; o->anim.frame = first; o->anim.fframe = first; o->anim.aframes = num; o->anim.cframe = start << 4; o->anim.aspeed = spd; o->flags |= CS_OBJ_DOANIM; } void cs_obj_image(cs_obj_t *o, int bank, int frame) { o->anim.bank = bank; o->anim.frame = frame; o->flags &= ~CS_OBJ_DOANIM; if((bank >= 0) && (bank < o->owner->nimageinfo)) { o->w = o->owner->imageinfo[bank].w; o->h = o->owner->imageinfo[bank].h; } else o->w = o->h = 1; } /*Start death sequence*/ void cs_obj_explode(cs_obj_t *o) { o->flags |= CS_OBJ_DYING; /* FIXME: Hardcoded bank for explosion!!! */ cs_obj_anim(o, 4, 0, 15, 0, 12); if(o->on_dying) o->on_dying(o); } void cs_obj_shoot(cs_obj_t *o, int xo, int yo, int xs, int ys, int rate, int delay, int ammo) { o->fire.v.x = xo; o->fire.v.y = yo; o->fire.v.xv = xs; o->fire.v.yv = ys; o->fire.rate = rate; o->fire.timer = delay; o->fire.ammo = ammo; } /* * cs_engine_t */ static cs_obj_t *__new_obj(cs_engine_t *e) { cs_obj_t *o = calloc(1, sizeof(cs_obj_t)); if(!o) return NULL; o->owner = e; o->prev = NULL; o->next = NULL; cs_obj_clear(o); ++e->pool_total; return o; } cs_engine_t *cs_engine_create(int w, int h, int objects) { cs_engine_t *e = calloc(1, sizeof(cs_engine_t)); if(!e) return NULL; cs_engine_set_size(e, w, h); cs_engine_set_wrap(e, 0, 0); /* * Create some objects and throw into the pool. * Note that "pool_free" gets initialized by * cs_obj_die(), objects are initialized and so * on, this way - automatically! */ while(objects--) { cs_obj_t *o = __new_obj(e); if(o) cs_obj_free(o); else { /* Oops, no memory... */ cs_engine_delete(e); return NULL; } } return e; } cs_obj_t *cs_engine_get_obj(cs_engine_t *e) { cs_obj_t *o = e->pool; if(o) { e->pool = o->next; o->head = NULL; o->prev = NULL; o->next = NULL; --e->pool_free; } return o; } void cs_engine_set_size(cs_engine_t *e, int w, int h) { e->w = w; e->h = h; } void cs_engine_set_image_size(cs_engine_t *e, int bank, int w, int h) { if(bank < 0) return; if(bank >= e->nimageinfo) { int nnii = bank + 16; image_info_t *nii = realloc(e->imageinfo, sizeof(image_info_t) * nnii); if(!nii) return; e->nimageinfo = nnii; e->imageinfo = nii; } e->imageinfo[bank].w = w; e->imageinfo[bank].h = h; } void cs_engine_set_wrap(cs_engine_t *e, int x, int y) { e->wx = PIXEL2CS(x); e->wy = PIXEL2CS(y); } void cs_engine_delete(cs_engine_t *e) { cs_obj_t *o; /* First get all objects to the pool... */ cs_engine_reset(e); /* ...then empty the pool. */ while((o = cs_engine_get_obj(e))) free(o); free(e->imageinfo); free(e); } void cs_engine_reset(cs_engine_t *e) { int i; for(i = 0; i < CS_LAYERS; ++i) while(e->objects[i]) cs_obj_free(e->objects[i]); e->time = 0.0; } /* ---------------------------------------------------------------------- * The actual *engine* :-) ---------------------------------------------------------------------- */ void __enemy_fire(cs_obj_t *o) { log_printf(DLOG, "fire!\n"); } void __make_move(cs_obj_t *o, int wx, int wy) { /* * Movement */ __move_point(&o->point, wx, wy); /* * Animation */ if(o->flags & CS_OBJ_DOANIM) { /* FIXME: Dirty hack here... Should play *any* death animation one-shot and then die. */ if((o->flags & CS_OBJ_DYING) && (o->anim.cframe >> 4 == 14)) cs_obj_free(o); o->anim.cframe += o->anim.aspeed; o->anim.cframe %= o->anim.aframes << 4; o->anim.frame = (o->anim.cframe >> 4) + o->anim.fframe; } /* * Fire / spawning */ if(!(o->flags & CS_OBJ_DYING) && o->fire.rate) { if(o->fire.timer > 0) --o->fire.timer; else { o->fire.timer = o->fire.rate; __enemy_fire(o); if(o->on_fire) o->on_fire(o); } } } void __update_points(cs_engine_t *e, float frac_frame) { cs_obj_t *o; int i; int ff = frac_frame * 256.0; if(ff < 0) ff = 0; else if(ff > 256) ff = 256; if(e->filter) for(i = 0; i < CS_USER_POINTS; ++i) __update_point_f(&e->points[i], ff, e->wx, e->wy); else for(i = 0; i < CS_USER_POINTS; ++i) __update_point(&e->points[i], ff); for(i = 0; i < CS_LAYERS; ++i) { if(e->filter) __update_point_f(&e->offsets[i], ff, e->wx, e->wy); else __update_point(&e->offsets[i], ff); e->changed[i] = 0; o = e->objects[i]; while(o) { if(e->filter) __update_point_f(&o->point, ff, e->wx, e->wy); else __update_point(&o->point, ff); o->point.gx -= e->offsets[i].gx; o->point.gy -= e->offsets[i].gy; e->changed[i] |= o->point.changed; __fix_wrap(e, o); o = o->next; } } } void __run_all(cs_engine_t *e) { int i; cs_obj_t *o; for(i = 0; i < CS_USER_POINTS; ++i) __move_point(&e->points[i], e->wx, e->wy); for(i = 0; i < CS_LAYERS; ++i) { __move_point(&e->offsets[i], e->wx, e->wy); o = e->objects[i]; while(o) { __make_move(o, e->wx, e->wy); o = o->next; } } } void __wrap_all(cs_engine_t *e) { int i; cs_obj_t *o; for(i = 0; i < CS_USER_POINTS; ++i) __wrap_point(&e->points[i], e->wx, e->wy); for(i = 0; i < CS_LAYERS; ++i) { __wrap_point(&e->offsets[i], e->wx, e->wy); o = e->objects[i]; while(o) { __wrap_point(&o->point, e->wx, e->wy); o = o->next; } } } void cs_engine_advance(cs_engine_t *e, double to_frame) { if(to_frame > 0) { int frames = floor(to_frame) - floor(e->time); if(frames > 0) { while(frames--) { __run_all(e); e->on_frame(e); } } } e->time = to_frame; if(e->wx || e->wy) __wrap_all(e); __update_points(e, to_frame - floor(to_frame)); } void cs_engine_render(cs_engine_t *e) { cs_obj_t *o; int i; for(i = CS_LAYERS - 1; i >= 0; --i) { o = e->objects[i]; while(o) { if(o->flags & CS_OBJ_VISIBLE) if(o->render) if(__onscreen(e, o)) o->render(o); o = o->next; } } } KoboDeluxe-0.5.1/graphics/sprite.c0000666000175000001440000003051710730340734013760 00000000000000/*(LGPL) ---------------------------------------------------------------------- sprite.c - Sprite engine for use with cs.h ---------------------------------------------------------------------- * Copyright (C) 2001, 2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* TODO: Automatic extension of the bank and sprite TODO: tables as needed when loading banks. */ #define DBG(x) x #include #include #include "logger.h" #include "glSDL.h" #include "SDL_image.h" #include "sprite.h" #include "filters.h" s_blitmodes_t s_blitmode = S_BLITMODE_AUTO; pix_t s_colorkey = {0, 0, 0, 0}; pix_t s_clampcolor = {0, 0, 0, 0}; unsigned char s_alpha = SDL_ALPHA_OPAQUE; int s_filter_flags = 0; s_filter_t *filters = NULL; /* ---------------------------------------------------------------------- Filter Plugin Interface ---------------------------------------------------------------------- */ s_filter_t *s_insert_filter(s_filter_cb_t callback) { s_filter_t *nf = calloc(1, sizeof(s_filter_t)); if(!nf) return NULL; nf->callback = callback; nf->next = filters; filters = nf; return nf; } s_filter_t *s_add_filter(s_filter_cb_t callback) { s_filter_t *nf = calloc(1, sizeof(s_filter_t)); if(!nf) return NULL; nf->callback = callback; if(!filters) filters = nf; else { s_filter_t *f = filters; while(f->next) f = f->next; f->next = nf; } return nf; } /* filter == NULL means "remove all plugins" */ void s_remove_filter(s_filter_t *filter) { s_filter_t *f; if(!filters) return; f = filters; while(f->next) { if(f->next == filter || !filter) { s_filter_t *df = f->next; f->next = f->next->next; free(df); } else f = f->next; } if(filters == filter || !filter) { s_filter_t *df = filters; filters = filters->next; free(df); } } static void __run_plugins(s_bank_t *b, unsigned first, unsigned frames) { s_filter_t *f = filters; while(f) { int oflags = f->args.flags; f->args.flags |= s_filter_flags; f->callback(b, first, frames, &f->args); f->args.flags = oflags; f = f->next; } } /* ---------------------------------------------------------------------- Basic Container Management ---------------------------------------------------------------------- */ static int __alloc_bank_table(s_container_t *c, unsigned int count) { c->max = count - 1; c->banks = (s_bank_t **)calloc((unsigned)count, sizeof(s_bank_t *)); return -(c->banks == NULL); } s_container_t *s_new_container(unsigned banks) { s_container_t *ret = (s_container_t *)calloc(1, sizeof(s_container_t)); if(!ret) return NULL; if(__alloc_bank_table(ret, banks) < 0) return NULL; return ret; } void s_delete_container(s_container_t *c) { s_delete_all_banks(c); free(c->banks); free(c); } /* * Allocates a new sprite. * If the sprite exists already, it's surface will be removed, so * that one can safely expect to get an *empty* sprite. */ s_sprite_t *s_new_sprite_b(s_bank_t *b, unsigned frame) { s_sprite_t *s = NULL; if(frame > b->max) return NULL; if(!b->sprites[frame]) { s = calloc(1, sizeof(s_sprite_t)); if(!s) return NULL; b->sprites[frame] = s; } else { if(s->surface) SDL_FreeSurface(s->surface); s->surface = NULL; } return s; } /* * Allocates a new sprite. * If the sprite exists already, it's surface will be removed, so * that one can safely expect to get an *empty* sprite. * * If the bank does not exist, or if the operation failed for * other reasons, this call returns NULL. */ s_sprite_t *s_new_sprite(s_container_t *c, unsigned bank, unsigned frame) { if(bank > c->max) return NULL; if(!c->banks[bank]) return NULL; return s_new_sprite_b(c->banks[bank], frame); } void s_delete_sprite_b(s_bank_t *b, unsigned frame) { if(!b->sprites) /* This can happen when failing to create a new bank */ return; if(frame > b->max) return; if(!b->sprites[frame]) return; if(b->sprites[frame]->surface) SDL_FreeSurface(b->sprites[frame]->surface); b->sprites[frame]->surface = NULL; free(b->sprites[frame]); b->sprites[frame] = NULL; } void s_delete_sprite(s_container_t *c, unsigned bank, unsigned frame) { s_bank_t *b = s_get_bank(c, bank); if(b) s_delete_sprite_b(b, frame); } static int __alloc_sprite_table(s_bank_t *b, unsigned frames) { b->max = frames - 1; b->sprites = (s_sprite_t **)calloc(frames, sizeof(s_sprite_t *)); if(!b->sprites) return -1; return 0; } s_bank_t *s_new_bank(s_container_t *c, unsigned bank, unsigned frames, unsigned w, unsigned h) { s_bank_t *b; DBG(log_printf(DLOG, "s_new_bank(%p, %d, %d, %d, %d)\n", c, bank, frames, w, h);) if(bank > c->max) return NULL; if(c->banks[bank]) s_delete_bank(c, bank); c->banks[bank] = (s_bank_t *)calloc(1, sizeof(s_bank_t)); if(!c->banks[bank]) return NULL; if(__alloc_sprite_table(c->banks[bank], frames) < 0) { s_delete_bank(c, bank); return NULL; } b = c->banks[bank]; b->max = frames - 1; b->w = w; b->h = h; return b; } void s_delete_bank(s_container_t *c, unsigned bank) { unsigned i; s_bank_t *b; if(!c->banks) return; if(bank > c->max) return; b = c->banks[bank]; if(b) { for(i = 0; i <= b->max; ++i) s_delete_sprite_b(b, i); free(b->sprites); free(b); c->banks[bank] = NULL; } } void s_delete_all_banks(s_container_t *c) { unsigned i; for(i = 0; i <= c->max; ++i) s_delete_bank(c, i); } /* ---------------------------------------------------------------------- Getting data ---------------------------------------------------------------------- */ s_bank_t *s_get_bank(s_container_t *c, unsigned bank) { if(bank > c->max) return NULL; if(!c->banks[bank]) return NULL; return c->banks[bank]; } s_sprite_t *s_get_sprite(s_container_t *c, unsigned bank, unsigned frame) { s_bank_t *b = s_get_bank(c, bank); if(!b) return NULL; if(frame > b->max) return NULL; return b->sprites[frame]; } s_sprite_t *s_get_sprite_b(s_bank_t *b, unsigned frame) { if(!b) return NULL; if(frame > b->max) return NULL; return b->sprites[frame]; } void s_detach_sprite(s_container_t *c, unsigned bank, unsigned frame) { s_sprite_t *s = s_get_sprite(c, bank, frame); if(!s) return; s->surface = NULL; } /* ---------------------------------------------------------------------- File tools ---------------------------------------------------------------------- */ static int extract_sprite(s_bank_t *bank, unsigned frame, SDL_Surface *src, SDL_Rect *from) { int y; SDL_Surface *tmp; if(frame > bank->max) { log_printf(ELOG, "sprite: Too many frames!\n"); return -1; } if(!s_new_sprite_b(bank, frame)) return -2; tmp = SDL_CreateRGBSurface(src->flags, from->w, from->h, src->format->BitsPerPixel, src->format->Rmask, src->format->Gmask, src->format->Bmask, src->format->Amask ); if(!tmp) return -3; /* Copy the pixel data */ if(SDL_LockSurface(src) < 0) { log_printf(ELOG, "sprite: extract_sprite() failed to lock surface!\n"); SDL_FreeSurface(tmp); return -4; } for(y = 0; y < tmp->h; ++y) { char *s = (char *)src->pixels + src->pitch * (y + from->y) + from->x * src->format->BytesPerPixel; char *d = (char *)tmp->pixels + tmp->pitch * y; memcpy(d, s, src->format->BytesPerPixel * tmp->w); } SDL_UnlockSurface(src); /* Copy palette, if any */ if(src->format->palette) SDL_SetColors(tmp, src->format->palette->colors, 0, src->format->palette->ncolors); /* Copy alpha and colorkey */ if(src->flags & SDL_SRCALPHA) SDL_SetAlpha(tmp, src->flags & (SDL_SRCALPHA | SDL_RLEACCEL), src->format->alpha); if(src->flags & SDL_SRCCOLORKEY) SDL_SetColorKey(tmp, src->flags & (SDL_SRCCOLORKEY | SDL_RLEACCEL), src->format->colorkey); bank->sprites[frame]->surface = tmp; DBG(log_printf(DLOG, "image %d: (%d,%d)/%dx%d @ %p\n", frame, from->x, from->y, from->w, from->h, bank->sprites[frame]->surface);) return 0; } int s_copy_rect(s_container_t *c, unsigned bank, unsigned frombank, unsigned fromframe, SDL_Rect *from) { #if 0 s_filter_args_t args; #endif SDL_Surface *src; s_sprite_t *s; s_bank_t *b; /* Get source image */ s = s_get_sprite(c, frombank, fromframe); if(!s) { log_printf(ELOG, "sprite: Couldn't get source sprite %d:%d!\n", frombank, fromframe); return -1; } src = s->surface; if(!src) { log_printf(ELOG, "sprite: Sprite %d:%d" " does not have a surface!\n", frombank, fromframe); return -2; } /* Create destination bank */ b = s_new_bank(c, bank, 1, from->w, from->h); if(!b) { log_printf(ELOG, "sprite: Failed to allocate bank %d!\n", bank); return -3; } if(extract_sprite(b, 0, src, from) < 0) { log_printf(ELOG, "sprite: Something went wrong while " "copying from sprite %d:%d.\n", frombank, fromframe); return -4; } #if 0 memset(&args, 0, sizeof(args)); args.x = 0; s_filter_displayformat(b, 0, 1, &args); #endif return 0; } int s_load_image(s_container_t *c, unsigned bank, const char *name) { SDL_Surface *src; s_bank_t *b; src = IMG_Load(name); if(!src) { log_printf(ELOG, "sprite: Failed to load sprite \"%s\"!\n", name); return -1; } b = s_new_bank(c, bank, 1, src->clip_rect.w, src->clip_rect.h); if(!b) { log_printf(ELOG, "sprite: Failed to allocate bank for \"%s\"!\n", name); return -2; } if(extract_sprite(b, 0, src, &src->clip_rect) < 0) { log_printf(ELOG, "sprite: Something went wrong while" " extracting sprite \"%s\".\n", name); return -3; } SDL_FreeSurface(src); __run_plugins(b, 0, 1); return 0; } int s_load_sprite(s_container_t *c, unsigned bank, unsigned frame, const char *name) { SDL_Surface *src; SDL_Rect from; s_bank_t *b = s_get_bank(c, bank); if(!b) { log_printf(ELOG, "sprite: While loading \"%s\":" " Bank %d does not exist!\n", name, bank); return -2; } src = IMG_Load(name); if(!src) { log_printf(ELOG, "sprite: Failed to load sprite \"%s\"!\n", name); return -1; } from = src->clip_rect; if( (from.w != b->w) || (from.h != b->h) ) { log_printf(ELOG, "sprite: Warning: Sprite \"%s\" cropped" " to fit in bank %d.\n", name, bank); from.w = b->w; from.h = b->h; } if(extract_sprite(b, frame, src, &from) < 0) { log_printf(ELOG, "sprite: Something went wrong while" " extracting sprite \"%s\".\n", name); return -3; } SDL_FreeSurface(src); __run_plugins(b, frame, 1); return 0; } int s_load_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, const char *name) { SDL_Surface *src; s_bank_t *b; int x, y; unsigned frame = 0; unsigned frames; DBG(log_printf(DLOG, "s_load_bank(%p, %d, %d, %d, %s)\n", c, bank, w, h, name);) src = IMG_Load(name); if(!src) { log_printf(ELOG, "sprite: Failed to load sprite palette %s!\n", name); return -1; } if(w > src->w) { log_printf(ELOG, "sprite: Source image %s not wide enough!\n", name); return -4; } if(h > src->h) { log_printf(ELOG, "sprite: Source image %s not high enough!\n", name); return -5; } frames = (src->w / w) * (src->h / h); b = s_new_bank(c, bank, frames, w, h); if(!b) { log_printf(ELOG, "sprite: Failed to allocate bank for \"%s\"!\n", name); return -2; } for(y = 0; y <= src->h - h; y += h) for(x = 0; x <= src->w - w; x += w) { SDL_Rect r; r.x = x; r.y = y; r.w = w; r.h = h; if(extract_sprite(b, frame, src, &r) < 0) { log_printf(ELOG, "sprite: Something went wrong while" " extracting sprites.\n"); return -3; } ++frame; } SDL_FreeSurface(src); __run_plugins(b, 0, frames); return 0; } int s_set_hotspot(s_container_t *c, unsigned bank, int frame, int x, int y) { if(frame < 0) { frame = 0; while(1) { s_sprite_t *s = s_get_sprite(c, bank, frame++); if(!s) break; s->x = x; s->y = y; } } else { s_sprite_t *s = s_get_sprite(c, bank, frame); s->x = x; s->y = y; } return 0; } KoboDeluxe-0.5.1/graphics/filters.c0000644000175000001440000006212310720444362014115 00000000000000/*(LGPL) ---------------------------------------------------------------------- filters.c - Filters for the sprite manager ---------------------------------------------------------------------- * Copyright (C) 2001, 2003, 2006, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "logger.h" #include "glSDL.h" #include "SDL_image.h" #include "sprite.h" #include "filters.h" /*-------------------------------------------------- RNG --------------------------------------------------*/ static unsigned int rnd = 16576; //Resets the noise generator static void noise_reset(int seed) { rnd = 16576 + seed; } //Returns a pseudo random number in the range [0, 65535] static inline int noise(void) { rnd *= 1566083941UL; rnd++; rnd &= 0xffffffffUL; /* NOP on 32 bit machines */ return (int)(rnd * (rnd >> 16) >> 16); } /*-------------------------------------------------- Pixel access ops for 32 bit RGBA --------------------------------------------------*/ static pix_t getpix32_empty = {0x7f, 0x7f, 0x7f, 0x7f}; static inline pix_t getpix32(SDL_Surface *s, int x, int y) { pix_t *p; if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) return getpix32_empty; p = (pix_t *)((char *)s->pixels + y * s->pitch); return p[x]; } /* Clamping version */ static inline pix_t getpix32c(SDL_Surface *s, int x, int y) { pix_t *p; if(x < 0) x = 0; else if(x >= s->w-1) x = s->w-1; if(y < 0) y = 0; else if(y >= s->h-1) y = s->h-1; p = (pix_t *)((char *)s->pixels + y * s->pitch); return p[x]; } #define GETPIXI(gp) \ { \ int c0x, c0y, c1x, c1y; \ int c[4]; \ pix_t e = {0, 0, 0, 0}; \ pix_t p[4], r; \ getpix32_empty = e; \ \ /* Calculate filter core */ \ x -= 8; \ y -= 8; \ c1x = x & 0xf; \ c1y = y & 0xf; \ c0x = 16 - c1x; \ c0y = 16 - c1y; \ c[0] = c0x * c0y; \ c[1] = c1x * c0y; \ c[2] = c0x * c1y; \ c[3] = c1x * c1y; \ \ /* Grab input pixels */ \ x >>= 4; \ y >>= 4; \ p[0] = gp(s, x, y); \ p[1] = gp(s, x+1, y); \ p[2] = gp(s, x, y+1); \ p[3] = gp(s, x+1, y+1); \ \ /* Interpolate... */ \ r.r = (p[0].r*c[0] + p[1].r*c[1] + p[2].r*c[2] + p[3].r*c[3])>>8; \ r.g = (p[0].g*c[0] + p[1].g*c[1] + p[2].g*c[2] + p[3].g*c[3])>>8; \ r.b = (p[0].b*c[0] + p[1].b*c[1] + p[2].b*c[2] + p[3].b*c[3])>>8; \ r.a = (p[0].a*c[0] + p[1].a*c[1] + p[2].a*c[2] + p[3].a*c[3])>>8; \ return r; \ } /* Interpolated; 28:4 fixed point coords. */ static inline pix_t getpix32i(SDL_Surface *s, int x, int y) { GETPIXI(getpix32) } /* Clamping version */ static inline pix_t getpix32ic(SDL_Surface *s, int x, int y) { GETPIXI(getpix32c) } static inline pix_t *pix32(SDL_Surface *s, int x, int y) { static pix_t dummy = {0x7f, 0x7f, 0x7f, 0x7f}; pix_t *p; if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) return &dummy; p = (pix_t *)((char *)s->pixels + y * s->pitch); return p + x; } static inline void setpix32(SDL_Surface *s, int x, int y, pix_t pix) { pix_t *p; if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) return; p = (pix_t *)((char *)s->pixels + y * s->pitch); p[x] = pix; } /*-------------------------------------------------- Non-clipping versions of everything (No clamping here, obviously...!) --------------------------------------------------*/ static inline pix_t getpix32_nc(SDL_Surface *s, int x, int y) { pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); #ifdef DEBUG if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) { log_printf(ELOG, "Clip in getpix32_nc()!" " x = %d, y = %d\n", x, y); *((char *)NULL) = 0; return getpix32_empty; } #endif return p[x]; } /* Interpolated; 28:4 fixed point coords. */ static inline pix_t getpix32i_nc(SDL_Surface *s, int x, int y) { #ifdef DEBUG if((x < 0) || (x >= s->w << 4) || (y < 0) || (y >= s->h << 4)) { log_printf(ELOG, "Clip in getpix32i_nc()!" " x = %d, y = %d\n", x>>4, y>>4); *((char *)NULL) = 0; // return getpix32_empty; } GETPIXI(getpix32) #else GETPIXI(getpix32_nc) #endif } #undef GETPIXI static inline void setpix32_nc(SDL_Surface *s, int x, int y, pix_t pix) { pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); #ifdef DEBUG if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) { log_printf(ELOG, "Clip in setpix32_nc()!" " x = %d, y = %d\n", x, y); *((char *)NULL) = 0; // return; } #endif p[x] = pix; } static inline pix_t *pix32_nc(SDL_Surface *s, int x, int y) { pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); #ifdef DEBUG // static pix_t trash; if((x < 0) || (x >= s->w) || (y < 0) || (y >= s->h)) { log_printf(ELOG, "Clip in pix32_nc()!" " x = %d, y = %d\n", x, y); *((char *)NULL) = 0; // return &trash; } #endif return p + x; } /*-------------------------------------------------- The filters --------------------------------------------------*/ int s_filter_rgba8(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { unsigned i; SDL_PixelFormat fmt; memset(&fmt, 0, sizeof(fmt)); fmt.BitsPerPixel = 32; fmt.BytesPerPixel = 4; #if SDL_BYTEORDER == SDL_BIG_ENDIAN fmt.Rmask = 0xff000000; fmt.Gmask = 0x00ff0000; fmt.Bmask = 0x0000ff00; fmt.Amask = 0x000000ff; #else fmt.Rmask = 0x000000ff; fmt.Gmask = 0x0000ff00; fmt.Bmask = 0x00ff0000; fmt.Amask = 0xff000000; #endif for(i = 0; i < frames; ++i) { SDL_Surface *tmp; s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; tmp = SDL_ConvertSurface(s->surface, &fmt, SDL_SWSURFACE); if(!tmp) return -1; SDL_FreeSurface(s->surface); s->surface = tmp; } return 0; } int s_filter_dither(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { int x, y; unsigned i; int ar, ag, ab; if(!args->x && !args->r && !args->g && !args->b) return 0; noise_reset(first); for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; ar = args->r; ag = args->g; ab = args->b; if(args->x) switch (s_blitmode) { case S_BLITMODE_AUTO: if(s->surface->format->Amask) ar = ag = ab = 8; break; case S_BLITMODE_OPAQUE: break; case S_BLITMODE_COLORKEY: case S_BLITMODE_ALPHA: ar = ag = ab = 8; break; } switch(args->y) { default: case 0: case 1: ar >>= 1; ag >>= 1; ab >>= 1; case 2: break; } for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) { pix_t *p = (pix_t *)((char *)s->surface->pixels + y * s->surface->pitch); switch(args->y) { default: case 0: /* 2x2 filter */ for(x = 0; x < b->w; ++x) { int r, g, b; pix_t *pix = p + x; if((x^y)&1) { r = pix->r + ar; g = pix->g + ag; b = pix->b + ab; if(r>255) r = 255; if(g>255) g = 255; if(b>255) b = 255; } else { r = pix->r - ar; g = pix->g - ag; b = pix->b - ab; if(r<0) r = 0; if(g<0) g = 0; if(b<0) b = 0; } pix->r = r; pix->g = g; pix->b = b; } break; case 1: /* 4x4 filter */ for(x = 0; x < b->w; ++x) { int dr, dg, db; int r, g, b; pix_t *pix = p + x; r = pix->r; g = pix->g; b = pix->b; if((x^y) & 1) { dr = ar; dg = ag; db = ab; } else { dr = -ar; dg = -ag; db = -ab; } if(y & 1) { dr += ar >> 1; dg += ag >> 1; db += ab >> 1; } else { dr -= ar >> 1; dg -= ag >> 1; db -= ab >> 1; } r += dr; g += dg; b += db; if(r>255) r = 255; else if(r<0) r = 0; if(g>255) g = 255; else if(g<0) g = 0; if(b>255) b = 255; else if(b<0) b = 0; pix->r = r; pix->g = g; pix->b = b; } break; case 2: /* Random */ for(x = 0; x < b->w; ++x) { int r, g, b, z; pix_t *pix = p + x; z = noise(); r = pix->r - ar + (((ar << 1) - 1) & z); g = pix->g - ag + (((ag << 1) - 1) & z); b = pix->b - ab + (((ab << 1) - 1) & z); if(r>255) r = 255; else if(r<0) r = 0; if(g>255) g = 255; else if(g<0) g = 0; if(b>255) b = 255; else if(b<0) b = 0; pix->r = r; pix->g = g; pix->b = b; } break; } } } return 0; } /* * Ugly hack to get around the problems caused by * SDL_SetColorKey() ignoring the alpha channel. * Basically just sets the blue LSB of any pixels * that match the colorkey, but have non-transparent * alpha. */ static void tweak_ck(SDL_Surface *s) { int x, y; if(s->format->BitsPerPixel != 32) return; for(y = 0; y < s->h; ++y) { pix_t *p = (pix_t *)((char *)s->pixels + y * s->pitch); for(x = 0; x < s->w; ++x) { pix_t *pix = p + x; if(!pix->r && !pix->g && !pix->b) if(pix->a) pix->b |= 1; } } } int s_filter_displayformat(s_bank_t * b, unsigned first, unsigned frames, s_filter_args_t * args) { unsigned i; for(i = 0; i < frames; ++i) { SDL_Surface *tmp; s_sprite_t *s = s_get_sprite_b(b, first + i); if(!s) continue; switch(s_blitmode) { case S_BLITMODE_AUTO: if(s->surface->format->Amask) SDL_SetAlpha(s->surface, SDL_SRCALPHA | SDL_RLEACCEL, SDL_ALPHA_OPAQUE); else SDL_SetColorKey(s->surface, SDL_RLEACCEL, 0); break; case S_BLITMODE_OPAQUE: SDL_SetColorKey(s->surface, SDL_RLEACCEL, 0); break; case S_BLITMODE_COLORKEY: SDL_SetColorKey(s->surface, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(s->surface->format, s_colorkey.r, s_colorkey.g, s_colorkey.b)); break; case S_BLITMODE_ALPHA: SDL_SetAlpha(s->surface, SDL_SRCALPHA | SDL_RLEACCEL, s_alpha); break; } if(args->x) { if(s->surface->format->Amask) tweak_ck(s->surface); tmp = SDL_DisplayFormat(s->surface); if(s->surface->format->Amask) SDL_SetColorKey(tmp, SDL_SRCCOLORKEY | SDL_RLEACCEL, SDL_MapRGB(tmp->format, 0,0,0)); } else { if(s->surface->format->Amask) tmp = SDL_DisplayFormatAlpha(s->surface); else tmp = SDL_DisplayFormat(s->surface); } if(!tmp) return -1; SDL_FreeSurface(s->surface); s->surface = tmp; } return 0; } typedef struct { SDL_Surface *src; /* Source surface */ SDL_Surface *dst; /* Destination surface */ int scx, scy; /* Scale (fixp 16:16) */ int start_sy, start_sx; /* Src start pos (fixp 16:16) */ int start_x, start_y; /* Dst start pos (pixels) */ int max_x, max_y; /* Dst end pos (pixels) */ } scale_params_t; static inline void select_rect(scale_params_t *p, scale_params_t *orig, int x, int y, int w, int h) { p->start_sx = orig->start_sx + x * orig->scx; p->start_sy = orig->start_sy + y * orig->scy; p->start_x = orig->start_x + x; p->start_y = orig->start_y + y; p->max_x = p->start_x + w; p->max_y = p->start_y + h; } /* Optimization tool; use the slow clipping funcs only around the edges! */ static inline void do_scale(scale_params_t *p, void (*border)(scale_params_t *p), void (*body)(scale_params_t *p)) { /* Copy the parameters */ scale_params_t lp = *p; int w = p->max_x - p->start_x; int h = p->max_y - p->start_y; int bx = (65535 + p->scx) / p->scx; int by = (65535 + p->scy) / p->scy; if(bx * 2 >= w || by * 2 >= h) { /* Area too small - body size would be zero or negative! */ select_rect(&lp, p, 0, 0, w, h); border(&lp); return; } /* Top border */ select_rect(&lp, p, 0, 0, w, by); border(&lp); /* Bottom border */ select_rect(&lp, p, 0, h - by, w, by); border(&lp); /* Left border */ select_rect(&lp, p, 0, by, bx, h - 2 * by); border(&lp); /* Right border */ select_rect(&lp, p, w - bx, by, bx, h - 2 * by); border(&lp); /* Body */ select_rect(&lp, p, bx, by, w - 2 * bx, h - 2 * by); body(&lp); } /* * Ugly but fast "nearest pixel" scaling */ static void scale_nearest(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) { pix_t *pix = (pix_t *)((char *)p->dst->pixels + y * p->dst->pitch); for(x = p->start_x, sx = p->start_sx; x < p->max_x; ++x, sx += p->scx) pix[x] = getpix32_nc(p->src, sx >> 16, sy >> 16); } } /* * Bilinear scaling */ static void do_scale_bilinear_noclip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) { pix_t *pix = (pix_t *)((char *)p->dst->pixels + y * p->dst->pitch); for(x = p->start_x, sx = p->start_sx; x < p->max_x; ++x, sx += p->scx) pix[x] = getpix32i_nc(p->src, sx >> 12, sy >> 12); } } static void do_scale_bilinear_clip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) { pix_t *pix = (pix_t *)((char *)p->dst->pixels + y * p->dst->pitch); for(x = p->start_x, sx = p->start_sx; x < p->max_x; ++x, sx += p->scx) pix[x] = getpix32i(p->src, sx >> 12, sy >> 12); } } static void do_scale_bilinear_clamp(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy; y < p->max_y; ++y, sy += p->scy) { pix_t *pix = (pix_t *)((char *)p->dst->pixels + y * p->dst->pitch); for(x = p->start_x, sx = p->start_sx; x < p->max_x; ++x, sx += p->scx) pix[x] = getpix32ic(p->src, sx >> 12, sy >> 12); } } static void scale_bilinear(scale_params_t *p) { do_scale(p, do_scale_bilinear_clip, do_scale_bilinear_noclip); } static void scale_bilinear_clamp(scale_params_t *p) { do_scale(p, do_scale_bilinear_clamp, do_scale_bilinear_noclip); } /* * Scale2x scaling * * This one's cool for 16 color graphics and the like, but * even with the fuzziness factor, it doesn't work well * with 24 bit data, or even 256 color graphics. */ #define CDIFF(x,y) (((x).r^(y).r) | ((x).g^(y).g) | ((x).b^(y).b) | ((x).a^(y).a)) #define SCALE2X(gp, sp) \ { \ int DB, BF, DH, FH; \ pix_t B ; \ pix_t D, E, F; \ pix_t H ; \ pix_t E0, E1; \ pix_t E2, E3; \ B = gp(p->src, sx, sy-1); \ D = gp(p->src, sx-1, sy); \ E = gp(p->src, sx, sy); \ F = gp(p->src, sx+1, sy); \ H = gp(p->src, sx, sy+1); \ DB = CDIFF(D, B) & 0xc0; \ BF = CDIFF(B, F) & 0xc0; \ DH = CDIFF(D, H) & 0xc0; \ FH = CDIFF(F, H) & 0xc0; \ E0 = (!DB && BF && DH) ? D : E; \ E1 = (!BF && DB && FH) ? F : E; \ E2 = (!DH && DB && FH) ? D : E; \ E3 = (!FH && DH && BF) ? F : E; \ sp(p->dst, x, y, E0); \ sp(p->dst, x+1, y, E1); \ sp(p->dst, x, y+1, E2); \ sp(p->dst, x+1, y+1, E3); \ } static void do_scale_2x_noclip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) SCALE2X(getpix32_nc, setpix32_nc); } static void do_scale_2x_clip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) SCALE2X(getpix32, setpix32); } static void do_scale_2x_clamp(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) SCALE2X(getpix32c, setpix32); } #undef CDIFF #undef SCALE2X static void scale_2x(scale_params_t *p) { do_scale(p, do_scale_2x_clip, do_scale_2x_noclip); } static void scale_2x_clamp(scale_params_t *p) { do_scale(p, do_scale_2x_clamp, do_scale_2x_noclip); } /* * Diamond2x scaling * * This works *great* though; kicks the butt of * Linear/Oversampled real hard - and at an order * of magnitude higher speed! :-) */ #define MIX(t,x,y,z) (t).r = ((x).r+(x).r+(y).r+(z).r)>>2; \ (t).g = ((x).g+(x).g+(y).g+(z).g)>>2; \ (t).b = ((x).b+(x).b+(y).b+(z).b)>>2; \ (t).a = ((x).a+(x).a+(y).a+(z).a)>>2; #define DIAMOND(gp, sp) \ { \ pix_t B; \ pix_t D, E, F; \ pix_t H; \ pix_t E0, E1; \ pix_t E2, E3; \ B = gp(p->src, sx, sy-1); \ D = gp(p->src, sx-1, sy); \ E = gp(p->src, sx, sy); \ F = gp(p->src, sx+1, sy); \ H = gp(p->src, sx, sy+1); \ MIX(E0, E, B, D); \ MIX(E1, E, B, F); \ MIX(E2, E, H, D); \ MIX(E3, E, H, F); \ sp(p->dst, x, y, E0); \ sp(p->dst, x+1, y, E1); \ sp(p->dst, x, y+1, E2); \ sp(p->dst, x+1, y+1, E3); \ } static void do_scale_diamond2x_noclip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) DIAMOND(getpix32_nc, setpix32_nc); } static void do_scale_diamond2x_clip(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) DIAMOND(getpix32, setpix32); } static void do_scale_diamond2x_clamp(scale_params_t *p) { int x, y, sx, sy; for(y = p->start_y, sy = p->start_sy >> 16; y < p->max_y; y += 2, ++sy) for(x = p->start_x, sx = p->start_sx >> 16; x < p->max_x; x += 2, ++sx) DIAMOND(getpix32c, setpix32); } #undef MIX #undef DIAMOND static void scale_diamond2x(scale_params_t *p) { do_scale(p, do_scale_diamond2x_clip, do_scale_diamond2x_noclip); } static void scale_diamond2x_clamp(scale_params_t *p) { do_scale(p, do_scale_diamond2x_clamp, do_scale_diamond2x_noclip); } int s_filter_scale(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { scale_params_t params; int fmode, smode = args->x; unsigned i; if((args->fx <= 0.0f) && (args->fy <= 0.0f)) return 0; if((args->fx == 1.0f) && (args->fy <= 1.0f)) return 0; switch(smode) { case SF_SCALE_NEAREST: case SF_SCALE_BILINEAR: break; case SF_SCALE_SCALE2X: case SF_SCALE_DIAMOND: if((args->fx != 2.0) || (args->fy != 2.0)) { log_printf(WLOG, "Scale2x and Diamond2x scaling " "works only with a scaling factor " "of exactly 2.0!\n"); /* smode = SF_SCALE_NEAREST;*/ smode = SF_SCALE_BILINEAR; } break; } getpix32_empty = s_clampcolor; params.max_x = (int)ceil(b->w * args->fx); params.scx = (int)(65536.0 / args->fx); params.scy = (int)(65536.0 / args->fy); params.start_x = 0; params.start_sx = 0; /* Check for special SFont mode */ if(args->flags & SF_CLAMP_SFONT) { params.start_y = 1; params.start_sy = 65536; params.max_y = (int)((b->h - 1) * args->fy + 1 + 0.5f); } else { params.start_y = 0; params.start_sy = 0; params.max_y = (int)(b->h * args->fy + 0.5f); } /* Decode filter type + SF_CLAMP_EXTEND flag */ fmode = (args->flags & SF_CLAMP_EXTEND) ? 1 : 0; switch(smode) { case SF_SCALE_NEAREST: fmode += 0; break; case SF_SCALE_BILINEAR: fmode += 2; /* Offset by half a pixel */ params.start_sx += params.scx / 2; params.start_sy += params.scy / 2; break; case SF_SCALE_SCALE2X: fmode += 4; break; case SF_SCALE_DIAMOND: fmode += 6; break; } for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; params.src = s->surface; params.dst = SDL_CreateRGBSurface(SDL_SWSURFACE, params.max_x, params.max_y, 32, #if SDL_BYTEORDER == SDL_BIG_ENDIAN 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); #else 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); #endif if(!params.dst) return -1; #ifdef DEBUG SDL_FillRect(params.dst, NULL, SDL_MapRGB(params.dst->format, 255, 128, 0)); #endif /* Deal with SFont marker row */ if(args->flags & SF_CLAMP_SFONT) { int x, sx; pix_t clear = {0, 0, 0, 0}; /* Scale marker row with "nearest" filter */ for(x = 0, sx = params.start_sx; x < params.max_x; ++x, sx += params.scx) setpix32_nc(params.dst, x, 0, getpix32(params.src, sx >> 16, 0)); /* Remove marker row to avoid garbage */ for(x = 0; x < b->w; ++x) setpix32_nc(params.src, x, 0, clear); } /* Do the scaling! */ switch(fmode) { case 0: /*Nearest*/ case 1: /*Nearest + extend clamping*/ scale_nearest(¶ms); break; case 2: /*Bilinear*/ scale_bilinear(¶ms); break; case 3: /*Bilinear + extend clamping*/ scale_bilinear_clamp(¶ms); break; case 4: /*Scale2x*/ scale_2x(¶ms); break; case 5: /*Scale2x + extend clamping*/ scale_2x_clamp(¶ms); break; case 6: /*Diamond2x*/ scale_diamond2x(¶ms); break; case 7: /*Diamond2x + extend clamping*/ scale_diamond2x_clamp(¶ms); break; } SDL_FreeSurface(s->surface); s->surface = params.dst; } b->w = params.max_x; b->h = params.max_y; return 0; } int s_filter_cleanalpha(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { int min = args->min; int max = args->max; int x, y; unsigned i; int contrast = (int)(args->fx * 256); int offset = args->x + 128; /* 128 for the bias! */ if(!contrast) contrast = 256; /*Default = 1.0*/ for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) { pix_t *p = (pix_t *)((char *)s->surface->pixels + y * s->surface->pitch); for(x = 0; x < b->w; ++x) { pix_t *pix = p + x; int alpha = pix->a; alpha = (alpha-128) * contrast >> 8; alpha += offset; if(alpha <= min) pix->a = pix->r = pix->g = pix->b = 0; else if(alpha > max) pix->a = 255; else pix->a = alpha; } } } return 0; } int s_filter_brightness(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { int min = args->min; int max = args->max; int x, y; unsigned i; int contrast = (int)(args->fy * 256); int offset = (int)(args->fx * 256 - 256) + 128; /* bias! */ if((256 == contrast) && (128 == offset) && (min <= 0) && (max >= 255)) return 0; /* No effect! --> */ for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first + i); if(!s) continue; for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) { pix_t *p = (pix_t *)((char *)s->surface->pixels + y * s->surface->pitch); for(x = 0; x < b->w; ++x) { int v; pix_t *pix = p + x; v = ((pix->r - 128) * contrast >> 8) + offset; if(v < min) v = min; else if(v > max) v = max; pix->r = v; v = ((pix->g - 128) * contrast >> 8) + offset; if(v < min) v = min; else if(v > max) v = max; pix->g = v; v = ((pix->b - 128) * contrast >> 8) + offset; if(v < min) v = min; else if(v > max) v = max; pix->b = v; } } } return 0; } static void construct_limits(int *min, int *max, int maxdev) { *min -= maxdev; if(*min < 0) *min = 0; *max += maxdev; if(*max > 255) *max = 255; } static inline int check_limits(int min, int max, int value) { if(value < min) return 0; if(value > max) return 0; return 1; } int s_filter_key2alpha(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { int x, y, krmin, krmax, kgmin, kgmax, kbmin, kbmax; unsigned i; krmin = krmax = s_colorkey.r; kgmin = kgmax = s_colorkey.g; kbmin = kbmax = s_colorkey.b; construct_limits(&krmin, &krmax, args->max); construct_limits(&kgmin, &kgmax, args->max); construct_limits(&kbmin, &kbmax, args->max); for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) { pix_t *p = (pix_t *)((char *)s->surface->pixels + y * s->surface->pitch); for(x = 0; x < b->h; ++x) { pix_t *pix = p + x; if(check_limits(krmin, krmax, pix->r) && check_limits(kgmin, kgmax, pix->g) && check_limits(kbmin, kbmax, pix->b)) pix->r = pix->g = pix->b = pix->a = 0; } } } return 0; } int s_filter_noise(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args) { int x, y; unsigned i; int br, bg, bb; /* bias */ int ar, ag, ab; /* amplitude */ i = args->min; br = args->r * i >> 8; bg = args->g * i >> 8; bb = args->b * i >> 8; i = args->max - args->min; ar = args->r * i >> 8; ag = args->g * i >> 8; ab = args->b * i >> 8; noise_reset(args->x); for(i = 0; i < frames; ++i) { s_sprite_t *s = s_get_sprite_b(b, first+i); if(!s) continue; for(y = (args->flags & SF_CLAMP_SFONT) ? 1 : 0; y < b->h; ++y) { pix_t *p = (pix_t *)((char *)s->surface->pixels + y * s->surface->pitch); for(x = 0; x < b->w; ++x) { int r, g, b; pix_t *pix = p + x; int rnd = noise(); r = rnd * ar + br + pix->r; g = rnd * ag + bg + pix->g; b = rnd * ab + bb + pix->b; if(r>255) r = 255; if(g>255) g = 255; if(b>255) b = 255; pix->r = r; pix->g = g; pix->b = b; } } } return 0; } KoboDeluxe-0.5.1/graphics/glSDL.c0000644000175000001440000013731410730743423013420 00000000000000/*(LGPL) ------------------------------------------------------------ glSDL 0.9 - SDL 2D API on top of OpenGL ------------------------------------------------------------ * Copyright (C) 2001-2004, 2006-2007 David Olofson * This code is released under the terms of the GNU LGPL. */ #define _GLSDL_NO_REDEFINES_ #include "glSDL.h" #ifdef HAVE_OPENGL #define LEAK_TRACKING #define DBG(x) /*error messages, warnings*/ #define DBG2(x) /*texture allocation*/ #define DBG3(x) /*chopping/tiling*/ #define DBG4(x) /*texture uploading*/ #define DBG5(x) /*two-way chopping/tiling*/ #define DBG6(x) /*OpenGL lib loading*/ #undef CKSTATS /*colorkey statistics*/ /* Keep this on for now! Makes large surfaces faster. */ #define FAKE_MAXTEXSIZE 256 #include #include #include #if HAS_SDL_OPENGL_H #include "SDL_opengl.h" #else #ifdef WIN32 #include #endif #if defined(__APPLE__) && defined(__MACH__) #include #include #else #include #include #endif #endif #if defined(_WIN32) && !defined(APIENTRY) && \ !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) #include #endif #ifndef APIENTRY #define APIENTRY #endif static inline void clip_rect(SDL_Rect *r, SDL_Rect *to) { int dx1 = r->x; int dy1 = r->y; int dx2 = dx1 + r->w; int dy2 = dy1 + r->h; if(dx1 < to->x) dx1 = to->x; if(dy1 < to->y) dy1 = to->y; if(dx2 > to->x + to->w) dx2 = to->x + to->w; if(dy2 > to->y + to->h) dy2 = to->y + to->h; if(dx2 < dx1 || dy2 < dy1) { r->x = r->y = 0; r->w = r->h = 0; } else { r->x = dx1; r->y = dy1; r->w = dx2 - dx1; r->h = dy2 - dy1; } } /*---------------------------------------------------------- OpenGL interface ----------------------------------------------------------*/ static struct { void (APIENTRY *Begin)(GLenum); void (APIENTRY *BindTexture)(GLenum, GLuint); void (APIENTRY *BlendFunc)(GLenum, GLenum); void (APIENTRY *Color4ub)(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha); void (APIENTRY *DeleteTextures)(GLsizei n, const GLuint *textures); void (APIENTRY *Disable)(GLenum cap); void (APIENTRY *Enable)(GLenum cap); void (APIENTRY *End)(void); void (APIENTRY *Flush)(void); void (APIENTRY *GenTextures)(GLsizei n, GLuint *textures); GLenum (APIENTRY *GetError)(void); void (APIENTRY *GetIntegerv)(GLenum pname, GLint *params); void (APIENTRY *LoadIdentity)(void); void (APIENTRY *MatrixMode)(GLenum mode); void (APIENTRY *Ortho)(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar); void (APIENTRY *PixelStorei)(GLenum pname, GLint param); void (APIENTRY *ReadPixels)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels); void (APIENTRY *TexCoord2f)(GLfloat s, GLfloat t); void (APIENTRY *TexImage2D)(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *TexParameteri)(GLenum target, GLenum pname, GLint param); void (APIENTRY *TexSubImage2D)(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels); void (APIENTRY *Translatef)(GLfloat x, GLfloat y, GLfloat z); void (APIENTRY *Vertex2i)(GLint x, GLint y); void (APIENTRY *Viewport)(GLint x, GLint y, GLsizei width, GLsizei height); void (APIENTRY *Rotated)(GLdouble, GLdouble, GLdouble, GLdouble); void (APIENTRY *Scalef)(GLfloat, GLfloat, GLfloat); void (APIENTRY *PushMatrix)(void); void (APIENTRY *PopMatrix)(void); } gl; static int GetGL(void) { int i; struct { const char *name; void **fn; } glfuncs[] = { {"glBegin", (void *)&gl.Begin }, {"glBindTexture", (void *)&gl.BindTexture }, {"glBlendFunc", (void *)&gl.BlendFunc }, {"glColor4ub", (void *)&gl.Color4ub }, {"glDeleteTextures", (void *)&gl.DeleteTextures }, {"glDisable", (void *)&gl.Disable }, {"glEnable", (void *)&gl.Enable }, {"glEnd", (void *)&gl.End }, {"glFlush", (void *)&gl.Flush }, {"glGenTextures", (void *)&gl.GenTextures }, {"glGetError", (void *)&gl.GetError }, {"glGetIntegerv", (void *)&gl.GetIntegerv }, {"glLoadIdentity", (void *)&gl.LoadIdentity }, {"glMatrixMode", (void *)&gl.MatrixMode }, {"glOrtho", (void *)&gl.Ortho }, {"glPixelStorei", (void *)&gl.PixelStorei }, {"glReadPixels", (void *)&gl.ReadPixels }, {"glTexCoord2f", (void *)&gl.TexCoord2f }, {"glTexImage2D", (void *)&gl.TexImage2D }, {"glTexParameteri", (void *)&gl.TexParameteri }, {"glTexSubImage2D", (void *)&gl.TexSubImage2D }, {"glTranslatef", (void *)&gl.Translatef }, {"glVertex2i", (void *)&gl.Vertex2i }, {"glViewport", (void *)&gl.Viewport }, {"glRotated", (void *)&gl.Rotated }, {"glScalef", (void *)&gl.Scalef }, {"glPushMatrix", (void *)&gl.PushMatrix }, {"glPopMatrix", (void *)&gl.PopMatrix }, {NULL, NULL } }; for(i = 0; glfuncs[i].name; ++i) { *glfuncs[i].fn = SDL_GL_GetProcAddress(glfuncs[i].name); if(!*glfuncs[i].fn) { DBG6(fprintf(stderr,"glSDL/wrapper ERROR: Could not get " "OpenGL function '%s'!\n", glfuncs[i].name);) return -1; } DBG6(printf("Got OpenGL function '%s'.\n", glfuncs[i].name);) } return 0; } static int LoadGL(void) { if(GetGL() < 0) { DBG6(printf("Couldn't get GL funcs! Trying to load lib...\n");) SDL_GL_LoadLibrary(NULL); if(GetGL() < 0) { DBG6(printf("Still couldn't get GL funcs!\n");) return -1; } } return 0; } static void UnloadGL(void) { } static void print_glerror(int point) { #if (DBG(1)+0 == 1) const char *err = ""; switch(gl.GetError()) { case GL_NO_ERROR: return; case GL_INVALID_ENUM: err = "GL_INVALID_ENUM"; break; case GL_INVALID_VALUE: err = "GL_INVALID_VALUE"; break; case GL_INVALID_OPERATION: err = "GL_INVALID_OPERATION"; break; case GL_STACK_OVERFLOW: err = "GL_STACK_OVERFLOW"; break; case GL_STACK_UNDERFLOW: err = "GL_STACK_UNDERFLOW"; break; case GL_OUT_OF_MEMORY: err = "GL_OUT_OF_MEMORY"; break; default: err = ""; break; } fprintf(stderr,"OpenGL error \"%s\" at point %d.\n", err, point); #endif } /*---------------------------------------------------------- OpenGL state wrapper ----------------------------------------------------------*/ static struct { int do_blend; int do_texture; GLint texture; GLenum sfactor, dfactor; } glstate; static void gl_reset(void) { glstate.do_blend = -1; glstate.do_blend = -1; glstate.texture = -1; glstate.sfactor = 0xffffffff; glstate.dfactor = 0xffffffff; } static __inline__ void gl_do_blend(int on) { if(glstate.do_blend == on) return; if(on) gl.Enable(GL_BLEND); else gl.Disable(GL_BLEND); glstate.do_blend = on; } static __inline__ void gl_do_texture(int on) { if(glstate.do_texture == on) return; if(on) gl.Enable(GL_TEXTURE_2D); else gl.Disable(GL_TEXTURE_2D); glstate.do_texture = on; } static __inline__ void gl_blendfunc(GLenum sfactor, GLenum dfactor) { if((sfactor == glstate.sfactor) && (dfactor == glstate.dfactor)) return; gl.BlendFunc(sfactor, dfactor); glstate.sfactor = sfactor; glstate.dfactor = dfactor; } static __inline__ void gl_texture(GLuint tx) { if(tx == (unsigned)glstate.texture) return; gl.BindTexture(GL_TEXTURE_2D, tx); glstate.texture = tx; } /*---------------------------------------------------------- Global stuff ----------------------------------------------------------*/ static int initialized = 0; static int using_glsdl = 0; #define USING_GLSDL (0 != using_glsdl) #define MAX_TEXINFOS 16384 static glSDL_TexInfo **texinfotab = NULL; static GLint maxtexsize = 256; static SDL_PixelFormat RGBfmt, RGBAfmt; static void UnloadTexture(glSDL_TexInfo *txi); static int scale = 1; static int vsync = 1; static SDL_Surface *fake_screen = NULL; static int glSDL_BlitGL(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); /*---------------------------------------------------------- glSDL Global State ----------------------------------------------------------*/ static struct { Uint8 alpha; /* Alpha */ Uint8 r, g, b; /* Color modulation */ float cx, cy; /* Transform center offset */ float sx, sy; /* Scale */ float rot; /* Rotation */ } state; void glSDL_SetBlendAlpha(Uint8 alpha) { state.alpha = alpha; } void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b) { state.r = r; state.g = g; state.b = b; } void glSDL_SetCenter(float x, float y) { state.cx = x; state.cy = y; } void glSDL_SetRotation(float angle) { state.rot = angle; } void glSDL_SetScale(float x, float y) { state.sx = x; state.sy = y; } void glSDL_ResetState(void) { glSDL_SetBlendAlpha(255); glSDL_SetBlendColor(255, 255, 255); glSDL_SetCenter(0.0f, 0.0f); glSDL_SetRotation(0.0f); glSDL_SetScale(1.0f, 1.0f); } /*---------------------------------------------------------- Code ----------------------------------------------------------*/ /* Get texinfo for a surface. */ static __inline__ glSDL_TexInfo *glSDL_GetTexInfo(SDL_Surface *surface) { if(texinfotab) return texinfotab[surface->unused1]; else return NULL; } /* Allocate a "blank" texinfo for a suface. */ glSDL_TexInfo *glSDL_AllocTexInfo(SDL_Surface *surface) { int handle, i = 0; glSDL_TexInfo *txi; if(!surface) return NULL; txi = glSDL_GetTexInfo(surface); if(txi) return txi; /* There already is one! --> */ /* Find a free handle... */ handle = -1; for(i = 1; i < MAX_TEXINFOS + 1; ++i) if(NULL == texinfotab[i]) { handle = i; break; } if(handle < 0) { DBG(fprintf(stderr, "glSDL/wrapper: Out of handles!\n")); return NULL; } /* ...and hook a new texinfo struct up to it. */ texinfotab[handle] = (glSDL_TexInfo*)calloc(1, sizeof(glSDL_TexInfo)); if(!texinfotab[handle]) return NULL; /* Connect the surface to the new TexInfo. */ surface->unused1 = (Uint32)handle; DBG2(fprintf(stderr, "glSDL/wrapper: Allocated TexInfo %d.\n", handle)); return texinfotab[handle]; } static void FreeTexInfo(Uint32 handle) { if(handle >= MAX_TEXINFOS) return; if(!texinfotab[handle]) return; UnloadTexture(texinfotab[handle]); texinfotab[handle]->textures = 0; free(texinfotab[handle]->texture); texinfotab[handle]->texture = NULL; free(texinfotab[handle]); texinfotab[handle] = NULL; DBG2(fprintf(stderr, "glSDL/wrapper: Freed TexInfo %d.\n", handle)); } /* Detach and free the texinfo of a surface. */ void glSDL_FreeTexInfo(SDL_Surface *surface) { if(!texinfotab) return; if(!surface) return; if(!glSDL_GetTexInfo(surface)) return; FreeTexInfo(surface->unused1); GLSDL_FIX_SURFACE(surface); } /* * Calculate chopping/tiling of a surface to * fit it into the smallest possible OpenGL * texture. */ static int CalcChop(SDL_Surface *s, glSDL_TexInfo *txi) { int rows, vw, vh; int vertical = 0; int texsize; int lastw, lasth, minsize; vw = s->w; vh = s->h; DBG3(fprintf(stderr, "w=%d, h=%d ", vw, vh)); if(vh > vw) { int t = vw; vw = vh; vh = t; vertical = 1; DBG3(fprintf(stderr, "(vertical) \t")); } /* * Check whether this is a "huge" surface - at least one dimension * must be <= than the maximum texture size, or we'll have to chop * in both directions. */ if(vh > maxtexsize) { /* * Very simple hack for now; we just tile * both ways with maximum size textures. */ texsize = maxtexsize; txi->tilemode = GLSDL_TM_HUGE; txi->texsize = texsize; txi->tilew = texsize; txi->tileh = texsize; txi->tilespertex = 1; /* Calculate number of textures needed */ txi->textures = (vw + texsize - 1) / texsize; txi->textures *= (vh + texsize - 1) / texsize; txi->texture = (int*)malloc(txi->textures * sizeof(int)); memset(txi->texture, -1, txi->textures * sizeof(int)); DBG5(fprintf(stderr, "two-way tiling; textures=%d\n", txi->textures)); if(!txi->texture) { fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Failed to allocate" " texture name table!\n"); return -3; } return 0; } /* Calculate minimum size */ rows = 1; lastw = vw; lasth = vh; minsize = lastw > lasth ? lastw : lasth; while(1) { int w, h, size; ++rows; w = vw / rows; h = rows * vh; size = w > h ? w : h; if(size >= minsize) { --rows; break; } lastw = w; lasth = h; minsize = size; } if(minsize > maxtexsize) { /* Handle multiple textures for very wide/tall surfaces. */ minsize = maxtexsize; rows = (vw + minsize-1) / minsize; } DBG3(fprintf(stderr, "==> minsize=%d ", minsize)); DBG3(fprintf(stderr, "(rows=%d) \t", rows)); /* Recalculate with nearest higher power-of-2 width. */ for(texsize = 1; texsize < minsize; texsize <<= 1) ; txi->texsize = texsize; rows = (vw + texsize-1) / texsize; DBG3(fprintf(stderr, "==> texsize=%d (rows=%d) \t", texsize, rows)); /* Calculate number of tiles per texture */ txi->tilespertex = txi->texsize / vh; DBG3(fprintf(stderr, "tilespertex=%d \t", txi->tilespertex)); /* Calculate number of textures needed */ txi->textures = (rows + txi->tilespertex-1) / txi->tilespertex; txi->texture = (int*)malloc(txi->textures * sizeof(int)); memset(txi->texture, -1, txi->textures * sizeof(int)); DBG3(fprintf(stderr, "textures=%d, ", txi->textures)); if(!txi->texture) { fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Failed to allocate" " texture name table!\n"); return -2; } /* Set up tile size. (Only one axis supported here!) */ if(1 == rows) { txi->tilemode = GLSDL_TM_SINGLE; if(vertical) { txi->tilew = vh; txi->tileh = vw; } else { txi->tilew = vw; txi->tileh = vh; } } else if(vertical) { txi->tilemode = GLSDL_TM_VERTICAL; txi->tilew = vh; txi->tileh = texsize; } else { txi->tilemode = GLSDL_TM_HORIZONTAL; txi->tilew = texsize; txi->tileh = vh; } DBG3(fprintf(stderr, "tilew=%d, tileh=%d\n", txi->tilew, txi->tileh)); return 0; } /* Add a glSDL_TexInfo struct to an SDL_Surface */ static int glSDL_AddTexInfo(SDL_Surface *surface) { glSDL_TexInfo *txi; if(!surface) return -1; if(IS_GLSDL_SURFACE(surface)) return 0; /* Do nothing */ glSDL_AllocTexInfo(surface); txi = glSDL_GetTexInfo(surface); if(!txi) return -2; /* Oops! Didn't get a texinfo... --> */ if(CalcChop(surface, txi) < 0) return -3; SDL_SetClipRect(surface, NULL); return 0; } /* Create a surface of the prefered OpenGL RGB texture format */ static SDL_Surface *CreateRGBSurface(int w, int h) { SDL_Surface *s; Uint32 rmask, gmask, bmask; int bits = 24; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0x00ff0000; gmask = 0x0000ff00; bmask = 0x000000ff; #else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; #endif s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bits, rmask, gmask, bmask, 0); if(s) GLSDL_FIX_SURFACE(s); glSDL_AddTexInfo(s); return s; } /* Create a surface of the prefered OpenGL RGBA texture format */ static SDL_Surface *CreateRGBASurface(int w, int h) { SDL_Surface *s; Uint32 rmask, gmask, bmask, amask; int bits = 32; #if SDL_BYTEORDER == SDL_BIG_ENDIAN rmask = 0xff000000; gmask = 0x00ff0000; bmask = 0x0000ff00; amask = 0x000000ff; #else rmask = 0x000000ff; gmask = 0x0000ff00; bmask = 0x00ff0000; amask = 0xff000000; #endif s = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, bits, rmask, gmask, bmask, amask); if(s) GLSDL_FIX_SURFACE(s); glSDL_AddTexInfo(s); return s; } static void init_formats(void) { SDL_Surface *s = CreateRGBSurface(1, 1); if(!s) return; RGBfmt = *(s->format); glSDL_FreeSurface(s); s = CreateRGBASurface(1, 1); if(!s) return; RGBAfmt = *(s->format); glSDL_FreeSurface(s); } static int FormatIsOk(SDL_Surface *surface) { SDL_PixelFormat *pf; if(!surface) return 1; /* Well, there ain't much we can do anyway... */ pf = surface->format; /* Colorkeying always requires conversion! */ if(surface->flags & SDL_SRCCOLORKEY) return 0; /* We need pitch == (width * BytesPerPixel) for glTex[Sub]Image2D() */ if(surface->pitch != (surface->w * pf->BytesPerPixel)) return 0; if(pf->Amask) { if(pf->BytesPerPixel != RGBAfmt.BytesPerPixel) return 0; if(pf->Rmask != RGBAfmt.Rmask) return 0; if(pf->Gmask != RGBAfmt.Gmask) return 0; if(pf->Bmask != RGBAfmt.Bmask) return 0; if(pf->Amask != RGBAfmt.Amask) return 0; } else { if(pf->BytesPerPixel != RGBfmt.BytesPerPixel) return 0; if(pf->Rmask != RGBfmt.Rmask) return 0; if(pf->Gmask != RGBfmt.Gmask) return 0; if(pf->Bmask != RGBfmt.Bmask) return 0; } return 1; } static void key2alpha(SDL_Surface *surface) { int x, y; #ifdef CKSTATS int transp = 0; #endif Uint32 rgbmask = surface->format->Rmask | surface->format->Gmask | surface->format->Bmask; Uint32 ckey = surface->format->colorkey & rgbmask; if(SDL_LockSurface(surface) < 0) return; for(y = 0; y < surface->h; ++y) { Uint32 *px = (Uint32 *)((char *)surface->pixels + y*surface->pitch); for(x = 0; x < surface->w; ++x) if((px[x] & rgbmask) == ckey) { px[x] = 0; #ifdef CKSTATS ++transp; #endif } } #ifdef CKSTATS printf("glSDL/wrapper: key2alpha(); %dx%d surface, %d opaque pixels.\n", surface->w, surface->h, surface->w * surface->h - transp); #endif SDL_UnlockSurface(surface); } /*---------------------------------------------------------- SDL style API ----------------------------------------------------------*/ static void KillAllTextures(void) { if(texinfotab) { unsigned i; #ifdef LEAK_TRACKING int leaked = 0; for(i = 3; i < MAX_TEXINFOS + 1; ++i) if(texinfotab[i]) { ++leaked; fprintf(stderr, "glSDL/wrapper: Leaked TexInfo" " %d! (%d %dx%d textures)\n", i, texinfotab[i]->textures, texinfotab[i]->texsize, texinfotab[i]->texsize ); } if(leaked) fprintf(stderr, "glSDL/wrapper: Leaked %d TexInfos!\n", leaked); #endif for(i = 1; i < MAX_TEXINFOS + 1; ++i) FreeTexInfo(i); free(texinfotab); texinfotab = NULL; } } void glSDL_Quit(void) { if(SDL_WasInit(SDL_INIT_VIDEO)) { glSDL_FreeTexInfo(SDL_GetVideoSurface()); if(fake_screen) { glSDL_FreeTexInfo(fake_screen); SDL_FreeSurface(fake_screen); fake_screen = NULL; } UnloadGL(); SDL_QuitSubSystem(SDL_INIT_VIDEO); } #ifndef LEAK_TRACKING KillAllTextures(); #endif } void glSDL_FullQuit(void) { #ifdef LEAK_TRACKING KillAllTextures(); #endif glSDL_Quit(); SDL_Quit(); } void glSDL_QuitSubSystem(Uint32 flags) { if(flags & SDL_INIT_VIDEO) glSDL_Quit(); SDL_QuitSubSystem(flags); } SDL_Surface *glSDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { SDL_Surface *screen; GLint gl_doublebuf; if(!initialized) { glSDL_ResetState(); initialized = 1; } if(USING_GLSDL) { glSDL_FreeTexInfo(SDL_GetVideoSurface()); if(fake_screen) { glSDL_FreeTexInfo(fake_screen); SDL_FreeSurface(fake_screen); fake_screen = NULL; } UnloadGL(); using_glsdl = 0; } if(!(flags & SDL_GLSDL)) { screen = SDL_SetVideoMode(width, height, bpp, flags); if(screen) GLSDL_FIX_SURFACE(screen); return screen; } if((SDL_Linked_Version()->major <= 1) && (SDL_Linked_Version()->minor <= 2) && (SDL_Linked_Version()->patch < 5)) fprintf(stderr, "glSDL/wrapper WARNING: Using SDL version" " 1.2.5 or later is strongly" " recommended!\n"); if(LoadGL() < 0) { fprintf(stderr, "glSDL/wrapper ERROR: Could not load OpenGL library!\n"); return NULL; } /* * FIXME: Here's the place to insert proper handling of this call being * used for resizing the window... For now, just make sure we * don't end up with invalid texinfos and stuff no matter what. */ KillAllTextures(); texinfotab = (glSDL_TexInfo**)calloc(MAX_TEXINFOS + 1, sizeof(glSDL_TexInfo *)); if(!texinfotab) return NULL; /* Remove flag to avoid confusion inside SDL - just in case! */ flags &= ~SDL_GLSDL; flags |= SDL_OPENGL; if(bpp == 15) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); } else if(bpp == 16) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5); } else if(bpp >= 24) { SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); } gl_doublebuf = (flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, gl_doublebuf); SDL_GL_SetAttribute(SDL_GL_SWAP_CONTROL, vsync); scale = 1; screen = SDL_SetVideoMode(width*scale, height*scale, bpp, flags); if(!screen) { KillAllTextures(); return NULL; } GLSDL_FIX_SURFACE(screen); #ifdef FAKE_MAXTEXSIZE maxtexsize = FAKE_MAXTEXSIZE; #else gl.GetIntegerv(GL_MAX_TEXTURE_SIZE, &maxtexsize); #endif DBG(fprintf(stderr, "glSDL/wrapper: Max texture size: %d\n", maxtexsize)); init_formats(); gl_reset(); if(glSDL_AddTexInfo(screen) < 0) { DBG(fprintf(stderr, "glSDL/wrapper: Failed to add info to screen surface!\n")); SDL_QuitSubSystem(SDL_INIT_VIDEO); return NULL; } glSDL_SetClipRect(screen, &screen->clip_rect); gl.Viewport(0, 0, screen->w * scale, screen->h * scale); /* * Note that this projection is upside down in * relation to the OpenGL coordinate system. */ gl.MatrixMode(GL_PROJECTION); gl.LoadIdentity(); gl.Ortho(0, scale * (float)screen->w, scale * (float)screen->h, 0, -1.0, 1.0); gl.MatrixMode(GL_MODELVIEW); gl.LoadIdentity(); gl.Translatef(0.0f, 0.0f, 0.0f); gl.Disable(GL_DEPTH_TEST); gl.Disable(GL_CULL_FACE); /* * Create a software shadow buffer of the requested size. * This is used for blit-from-screen and simulation of * direct software rendering. (Dog slow crap. It's only * legitimate use is probably screen shots.) */ fake_screen = CreateRGBSurface(screen->w / scale, screen->h / scale); using_glsdl = 1; return fake_screen; } SDL_Surface *glSDL_GetVideoSurface(void) { if(fake_screen) return fake_screen; else return SDL_GetVideoSurface(); } void glSDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects) { if(IS_GLSDL_SURFACE(screen)) glSDL_Flip(screen); else SDL_UpdateRects(screen, numrects, rects); } void glSDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h) { SDL_Rect r; r.x = x; r.y = y; r.w = w; r.h = h; glSDL_UpdateRects(screen, 1, &r); } int glSDL_Flip(SDL_Surface *screen) { if(!IS_GLSDL_SURFACE(screen)) return SDL_Flip(screen); SDL_GL_SwapBuffers(); return 0; } void glSDL_FreeSurface(SDL_Surface *surface) { if(!surface) return; glSDL_FreeTexInfo(surface); SDL_FreeSurface(surface); } int glSDL_LockSurface(SDL_Surface *surface) { if(!surface) return 0; if(IS_GLSDL_SURFACE(surface)) { if((surface == fake_screen) || (SDL_GetVideoSurface() == surface)) { if(scale > 1) return -1; glSDL_Invalidate(fake_screen, NULL); gl.PixelStorei(GL_UNPACK_ROW_LENGTH, fake_screen->pitch / fake_screen->format->BytesPerPixel); gl.ReadPixels(0, 0, fake_screen->w, fake_screen->h, GL_RGB, GL_UNSIGNED_BYTE, fake_screen->pixels); return 0; } else { glSDL_Invalidate(surface, NULL); return SDL_LockSurface(surface); } } else return SDL_LockSurface(surface); } void glSDL_UnlockSurface(SDL_Surface *surface) { if(!surface) return; if(IS_GLSDL_SURFACE(surface)) { glSDL_UploadSurface(surface); if((surface == fake_screen) || (SDL_GetVideoSurface() == surface)) glSDL_BlitGL(fake_screen, NULL, SDL_GetVideoSurface(), NULL); } else SDL_UnlockSurface(surface); } int glSDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key) { int res = SDL_SetColorKey(surface, flag, key); if(res < 0) return res; /* * If an application does this *after* SDL_DisplayFormat, * we're basically screwed, unless we want to do an * in-place surface conversion hack here. * * What we do is just kill the glSDL texinfo... No big * deal in most cases, as glSDL only converts once anyway, * *unless* you keep modifying the surface. */ if(IS_GLSDL_SURFACE(surface)) glSDL_FreeTexInfo(surface); return res; } int glSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha) { /* * This is just parameters to OpenGL, so the actual * "work" is done in glSDL_BlitSurface(). */ return SDL_SetAlpha(surface, flag, alpha); } SDL_bool glSDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect) { SDL_bool res; SDL_Surface *screen; SDL_Rect fsr; if(!surface) return SDL_FALSE; screen = SDL_GetVideoSurface(); res = SDL_SetClipRect(surface, rect); if(!res) return SDL_FALSE; if(!rect) { fsr.x = 0; fsr.y = 0; fsr.w = screen->w; fsr.h = screen->h; rect = &fsr; } if(surface == fake_screen) { SDL_Rect r; r.x = rect->x; r.y = rect->y; r.w = rect->w; r.h = rect->h; surface = screen; SDL_SetClipRect(surface, rect); return SDL_TRUE; } return res; } static int glSDL_BlitFromGL(SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { int i, sy0, dy0; SDL_Rect sr, dr; if(scale > 1) return -1; /* In case the destination has an OpenGL texture... */ glSDL_Invalidate(dst, dstrect); /* Abuse the fake screen buffer a little. */ gl.PixelStorei(GL_UNPACK_ROW_LENGTH, fake_screen->pitch / fake_screen->format->BytesPerPixel); if(srcrect) { sr = *srcrect; dr.x = dr.y = 0; dr.w = fake_screen->w; dr.h = fake_screen->h; clip_rect(&sr, &dr); gl.ReadPixels(sr.x, sr.y, sr.w, sr.h, GL_RGB, GL_UNSIGNED_BYTE, fake_screen->pixels); } else { sr.x = sr.y = 0; sr.w = dst->w; srcrect = &sr; gl.ReadPixels(0, 0, fake_screen->w, fake_screen->h, GL_RGB, GL_UNSIGNED_BYTE, fake_screen->pixels); } /* Blit to the actual target! (Vert. flip... Uuurgh!) */ if(dstrect) dr = *dstrect; else { dr.x = dr.y = 0; dstrect = &dr; } i = srcrect->h; sy0 = srcrect->y; dy0 = dstrect->y + dstrect->h - 1; while(i--) { sr.y = sy0 + i; dr.y = dy0 - i; sr.h = 1; if(SDL_BlitSurface(fake_screen, &sr, dst, &dr) < 0) return -1; } return 0; } static __inline__ void BlitGL_single(glSDL_TexInfo *txi, float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) { float sx2, sy2, texscale; if(!txi->textures) return; if(-1 == txi->texture[0]) return; gl_texture(txi->texture[0]); texscale = 1.0 / (float)txi->texsize; sx2 = (sx1 + (float)dst->w) * texscale; sy2 = (sy1 + (float)dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; gl.Begin(GL_QUADS); gl.Color4ub(state.r, state.g, state.b, alpha); gl.TexCoord2f(sx1, sy1); gl.Vertex2i(dst->x, dst->y); gl.TexCoord2f(sx2, sy1); gl.Vertex2i(dst->x + dst->w, dst->y); gl.TexCoord2f(sx2, sy2); gl.Vertex2i(dst->x + dst->w, dst->y + dst->h); gl.TexCoord2f(sx1, sy2); gl.Vertex2i(dst->x, dst->y + dst->h); gl.End(); } static void BlitGL_htile(glSDL_TexInfo *txi, float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) { int tex; float tile, sx2, sy2, yo; float texscale = 1.0 / (float)txi->texsize; float tileh = (float)txi->tileh * texscale; sx2 = (sx1 + (float)dst->w) * texscale; sy2 = (sy1 + (float)dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; tile = floor(sx1); tex = (int)tile / txi->tilespertex; yo = ((int)tile % txi->tilespertex) * tileh; if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); gl.Begin(GL_QUADS); while(tile < sx2) { int tdx1 = dst->x; int tdx2 = dst->x + dst->w; float tsx1 = sx1 - tile; float tsx2 = sx2 - tile; /* Clip to current tile */ if(tsx1 < 0.0) { tdx1 -= (int)(tsx1 * txi->texsize); tsx1 = 0.0; } if(tsx2 > 1.0) { tdx2 -= (int)((tsx2 - 1.0) * txi->texsize); tsx2 = 1.0; } /* Maybe select next texture? */ if(yo + tileh > 1.0) { ++tex; gl.End(); if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); yo = 0.0; gl.Begin(GL_QUADS); } gl.Color4ub(state.r, state.g, state.b, alpha); gl.TexCoord2f(tsx1, yo + sy1); gl.Vertex2i(tdx1, dst->y); gl.TexCoord2f(tsx2, yo + sy1); gl.Vertex2i(tdx2, dst->y); gl.TexCoord2f(tsx2, yo + sy2); gl.Vertex2i(tdx2, dst->y + dst->h); gl.TexCoord2f(tsx1, yo + sy2); gl.Vertex2i(tdx1, dst->y + dst->h); tile += 1.0; yo += tileh; } gl.End(); } static void BlitGL_vtile(glSDL_TexInfo *txi, float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) { int tex; float tile, sx2, sy2, xo; float texscale = 1.0 / (float)txi->texsize; float tilew = (float)txi->tilew * texscale; sx2 = (sx1 + (float)dst->w) * texscale; sy2 = (sy1 + (float)dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; tile = floor(sy1); tex = (int)tile / txi->tilespertex; xo = ((int)tile % txi->tilespertex) * tilew; if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); gl.Begin(GL_QUADS); while(tile < sy2) { int tdy1 = dst->y; int tdy2 = dst->y + dst->h; float tsy1 = sy1 - tile; float tsy2 = sy2 - tile; /* Clip to current tile */ if(tsy1 < 0.0) { tdy1 -= (int)(tsy1 * txi->texsize); tsy1 = 0.0; } if(tsy2 > 1.0) { tdy2 -= (int)((tsy2 - 1.0) * txi->texsize); tsy2 = 1.0; } /* Maybe select next texture? */ if(xo + tilew > 1.0) { ++tex; gl.End(); if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); xo = 0.0; gl.Begin(GL_QUADS); } gl.Color4ub(state.r, state.g, state.b, alpha); gl.TexCoord2f(xo + sx1, tsy1); gl.Vertex2i(dst->x, tdy1); gl.TexCoord2f(xo + sx2, tsy1); gl.Vertex2i(dst->x + dst->w, tdy1); gl.TexCoord2f(xo + sx2, tsy2); gl.Vertex2i(dst->x + dst->w, tdy2); gl.TexCoord2f(xo + sx1, tsy2); gl.Vertex2i(dst->x, tdy2); tile += 1.0; xo += tilew; } gl.End(); } static void BlitGL_hvtile(SDL_Surface *src, glSDL_TexInfo *txi, float sx1, float sy1, SDL_Rect *dst, unsigned char alpha) { int x, y, last_tex, tex; float sx2, sy2; float texscale = 1.0 / (float)txi->texsize; int tilesperrow = (src->w + txi->tilew - 1) / txi->tilew; sx2 = (sx1 + (float)dst->w) * texscale; sy2 = (sy1 + (float)dst->h) * texscale; sx1 *= texscale; sy1 *= texscale; last_tex = tex = (int)(floor(sy1) * tilesperrow + floor(sx1)); if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); gl.Begin(GL_QUADS); for(y = (int)floor(sy1); y < sy2; ++y) { int tdy1 = dst->y; int tdy2 = dst->y + dst->h; float tsy1 = sy1 - y; float tsy2 = sy2 - y; /* Clip to current tile */ if(tsy1 < 0.0) { tdy1 -= (int)(tsy1 * txi->texsize); tsy1 = 0.0; } if(tsy2 > 1.0) { tdy2 -= (int)((tsy2 - 1.0) * txi->texsize); tsy2 = 1.0; } for(x = (int)floor(sx1); x < sx2; ++x) { int tdx1 = dst->x; int tdx2 = dst->x + dst->w; float tsx1 = sx1 - x; float tsx2 = sx2 - x; /* Clip to current tile */ if(tsx1 < 0.0) { tdx1 -= (int)(tsx1 * txi->texsize); tsx1 = 0.0; } if(tsx2 > 1.0) { tdx2 -= (int)((tsx2 - 1.0) * txi->texsize); tsx2 = 1.0; } /* Select texture */ tex = y * tilesperrow + x; if(tex != last_tex) { gl.End(); if(tex >= txi->textures) return; if(-1 == txi->texture[tex]) return; gl_texture(txi->texture[tex]); last_tex = tex; gl.Begin(GL_QUADS); } gl.Color4ub(state.r, state.g, state.b, alpha); gl.TexCoord2f(tsx1, tsy1); gl.Vertex2i(tdx1, tdy1); gl.TexCoord2f(tsx2, tsy1); gl.Vertex2i(tdx2, tdy1); gl.TexCoord2f(tsx2, tsy2); gl.Vertex2i(tdx2, tdy2); gl.TexCoord2f(tsx1, tsy2); gl.Vertex2i(tdx1, tdy2); } } gl.End(); } /* * Calculate the actual blit rectangle and source offset * for a blit from a rectangle in a surface with specified * size to a surface with a cliprect. * * In: rect source rectangle * w, h source surface size * (x, y) destination coordinate * clip destination clip rectangle * * Out: (x, y) source top-left offset * rect destination rectangle * * Returns 1 if the result is visible, otherwise 0. */ static __inline__ int blitclip(SDL_Rect *rect, int w, int h, int *x, int *y, SDL_Rect *clip) { int sx1, sy1, sx2, sy2; int dx1, dy1, dx2, dy2; /* Get source and destination coordinates */ sx1 = rect->x; sy1 = rect->y; sx2 = sx1 + rect->w; sy2 = sy1 + rect->h; dx1 = *x; dy1 = *y; /* Keep source rect inside source surface */ if(sx1 < 0) { dx1 -= sx1; sx1 = 0; } if(sy1 < 0) { dy1 -= sy1; sy1 = 0; } if(sx2 > w) sx2 = w; if(sy2 > h) sy2 = h; /* Cull blits from void space */ if(sx1 >= sx2 || sy1 >= sy2) return 0; /* Calculate destination lower-right */ dx2 = dx1 + (sx2 - sx1); dy2 = dy1 + (sy2 - sy1); if(clip) { /* Clip to destination cliprect */ if(dx1 < clip->x) { sx1 += clip->x - dx1; dx1 = clip->x; } if(dy1 < clip->y) { sy1 += clip->y - dy1; dy1 = clip->y; } if(dx2 > clip->x + clip->w) dx2 = clip->x + clip->w; if(dy2 > clip->y + clip->h) dy2 = clip->y + clip->h; } /* Cull nop/off-screen blits */ if(dx1 >= dx2 || dy1 >= dy2) return 0; *x = sx1; *y = sy1; rect->x = dx1; rect->y = dy1; rect->w = dx2 - dx1; rect->h = dy2 - dy1; return 1; } static int glSDL_BlitGL(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { glSDL_TexInfo *txi; SDL_Rect r; int x, y; unsigned char alpha; int plain = (state.rot == 0.0f) && (state.sx == 1.0f) && (state.sy == 1.0f); if(!src || !dst) return -1; /* Get source and destination coordinates */ if(srcrect) r = *srcrect; else { r.x = r.y = 0; r.w = src->w; r.h = src->h; } if(dstrect) { x = dstrect->x; y = dstrect->y; } else x = y = 0; /* Clip! */ if(!blitclip(&r, src->w, src->h, &x, &y, plain ? &dst->clip_rect : NULL)) { if(dstrect) dstrect->w = dstrect->h = 0; return 0; } /* Write back the resulting cliprect */ if(dstrect) *dstrect = r; /* Make sure we have a source with a valid texture */ glSDL_UploadSurface(src); txi = glSDL_GetTexInfo(src); if(!txi) return -1; /* Set up blending */ if(src->flags & (SDL_SRCALPHA | SDL_SRCCOLORKEY) || (state.alpha != 255)) { gl_blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_do_blend(1); } else gl_do_blend(0); /* Enable texturing */ gl_do_texture(1); /* * Note that we actually *prevent* the use of "full surface alpha" * and alpha channel in combination - to stay SDL 2D compatible. */ if((src->flags & SDL_SRCALPHA) && (!src->format->Amask || (src->flags & SDL_SRCCOLORKEY))) alpha = src->format->alpha; else alpha = 255; /* ...however, the GL only global state alpha is always applied! */ alpha = (Uint32)alpha * state.alpha * 258 >> 16; /* Render! */ if(!plain) { int rcx = (r.w >> 1) + state.cx; int rcy = (r.h >> 1) + state.cy; gl.PushMatrix(); gl.Translatef(r.x + rcx, r.y + rcy, 0.0f); if(state.rot) gl.Rotated(state.rot, 0.0f, 0.0f, 1.0f); if(state.sx || state.sy) gl.Scalef(state.sx, state.sy, 1.0f); r.x = -rcx; r.y = -rcy; } switch(txi->tilemode) { case GLSDL_TM_SINGLE: BlitGL_single(txi, x, y, &r, alpha); break; case GLSDL_TM_HORIZONTAL: BlitGL_htile(txi, x, y, &r, alpha); break; case GLSDL_TM_VERTICAL: BlitGL_vtile(txi, x, y, &r, alpha); break; case GLSDL_TM_HUGE: BlitGL_hvtile(src, txi, x, y, &r, alpha); break; } if(!plain) gl.PopMatrix(); return 0; } int glSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) { SDL_Surface *vs; if(!src || !dst) return -1; /* * Figure out what to do: * Not using glSDL: SDL_BlitSurface() * screen->screen: _glSDL_BlitFromGL() + _glSDL_BlitGL() * surface->screen: _glSDL_BlitGL() * screen->surface: _glSDL_BlitFromGL() * surface->surface: SDL_BlitSurface() */ if(!USING_GLSDL) return SDL_BlitSurface(src, srcrect, dst, dstrect); vs = SDL_GetVideoSurface(); if(src == fake_screen) src = vs; if(dst == fake_screen) dst = vs; if(src == vs) { if(dst == vs) { glSDL_BlitFromGL(srcrect, fake_screen, dstrect); return glSDL_BlitGL(fake_screen, srcrect, dst, dstrect); } else { return glSDL_BlitFromGL(srcrect, dst, dstrect); } } else { if(dst == vs) { return glSDL_BlitGL(src, srcrect, dst, dstrect); } else { glSDL_Invalidate(dst, dstrect); return SDL_BlitSurface(src, srcrect, dst, dstrect); } } } int glSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color) { SDL_Surface *vs = SDL_GetVideoSurface(); SDL_PixelFormat *pf = dst->format; int dx1, dy1, dx2, dy2; Uint32 r, g, b; if(dst == fake_screen) dst = vs; if(vs != dst) glSDL_Invalidate(dst, dstrect); if((vs != dst) || !USING_GLSDL) return SDL_FillRect(dst, dstrect, color); if(dstrect) { dx1 = dstrect->x; dy1 = dstrect->y; dx2 = dx1 + dstrect->w; dy2 = dy1 + dstrect->h; if(dx1 < dst->clip_rect.x) dx1 = dst->clip_rect.x; if(dy1 < dst->clip_rect.y) dy1 = dst->clip_rect.y; if(dx2 > dst->clip_rect.x + dst->clip_rect.w) dx2 = dst->clip_rect.x + dst->clip_rect.w; if(dy2 > dst->clip_rect.y + dst->clip_rect.h) dy2 = dst->clip_rect.y + dst->clip_rect.h; dstrect->x = dx1; dstrect->y = dy1; dstrect->w = dx2 - dx1; dstrect->h = dy2 - dy1; if(!dstrect->w || !dstrect->h) return 0; } else { dx1 = dst->clip_rect.x; dy1 = dst->clip_rect.y; dx2 = dx1 + dst->clip_rect.w; dy2 = dy1 + dst->clip_rect.h; } r = color & pf->Rmask; r = r >> pf->Rshift; r = r << pf->Rloss; g = color & pf->Gmask; g = g >> pf->Gshift; g = g << pf->Gloss; b = color & pf->Bmask; b = b >> pf->Bshift; b = b << pf->Bloss; r = r * state.r * 258 >> 16; g = g * state.g * 258 >> 16; b = b * state.b * 258 >> 16; gl_do_texture(0); if(state.alpha != 255) { gl_blendfunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); gl_do_blend(1); } else gl_do_blend(0); gl.Begin(GL_QUADS); gl.Color4ub(r, g, b, state.alpha); gl.Vertex2i(dx1, dy1); gl.Vertex2i(dx2, dy1); gl.Vertex2i(dx2, dy2); gl.Vertex2i(dx1, dy2); gl.End(); return 0; } SDL_Surface *glSDL_DisplayFormat(SDL_Surface *surface) { SDL_Surface *s, *tmp; if(USING_GLSDL) { int use_rgba = (surface->flags & SDL_SRCCOLORKEY) || ((surface->flags & SDL_SRCALPHA) && surface->format->Amask); if(use_rgba) tmp = SDL_ConvertSurface(surface, &RGBAfmt, SDL_SWSURFACE); else tmp = SDL_ConvertSurface(surface, &RGBfmt, SDL_SWSURFACE); if(!tmp) return NULL; GLSDL_FIX_SURFACE(tmp); SDL_SetAlpha(tmp, 0, 0); if(surface->flags & SDL_SRCCOLORKEY) { /* * We drop colorkey data here, but we have to, * or we'll run into trouble when converting, * in particular from indexed color formats. */ SDL_SetColorKey(tmp, SDL_SRCCOLORKEY, surface->format->colorkey); key2alpha(tmp); } SDL_SetColorKey(tmp, 0, 0); if(use_rgba) s = CreateRGBASurface(surface->w, surface->h); else s = CreateRGBSurface(surface->w, surface->h); if(!s) { glSDL_FreeSurface(tmp); return NULL; } SDL_BlitSurface(tmp, NULL, s, NULL); glSDL_FreeSurface(tmp); if(surface->flags & SDL_SRCALPHA) SDL_SetAlpha(s, SDL_SRCALPHA, surface->format->alpha); return s; } else { s = SDL_DisplayFormat(surface); if(s) GLSDL_FIX_SURFACE(s); return s; } } SDL_Surface *glSDL_DisplayFormatAlpha(SDL_Surface *surface) { SDL_Surface *s, *tmp; if(USING_GLSDL) { tmp = SDL_ConvertSurface(surface, &RGBAfmt, SDL_SWSURFACE); if(!tmp) return NULL; GLSDL_FIX_SURFACE(tmp); SDL_SetAlpha(tmp, 0, 0); SDL_SetColorKey(tmp, 0, 0); s = CreateRGBASurface(surface->w, surface->h); if(!s) { glSDL_FreeSurface(tmp); return NULL; } SDL_BlitSurface(tmp, NULL, s, NULL); glSDL_FreeSurface(tmp); if(surface->flags & SDL_SRCCOLORKEY) { SDL_SetColorKey(s, SDL_SRCCOLORKEY, surface->format->colorkey); key2alpha(s); } if(surface->flags & SDL_SRCALPHA) SDL_SetAlpha(s, SDL_SRCALPHA, surface->format->alpha); return s; } else { s = SDL_DisplayFormatAlpha(surface); if(s) GLSDL_FIX_SURFACE(s); return s; } } SDL_Surface *glSDL_ConvertSurface (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags) { SDL_Surface *s = SDL_ConvertSurface(src, fmt, flags); if(s) GLSDL_FIX_SURFACE(s); return s; } SDL_Surface *glSDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_Surface *s = SDL_CreateRGBSurface(flags, width, height, depth, Rmask, Gmask, Bmask, Amask); if(s) GLSDL_FIX_SURFACE(s); return s; } SDL_Surface *glSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_Surface *s = SDL_CreateRGBSurfaceFrom(pixels, width, height, depth, pitch, Rmask, Gmask, Bmask, Amask); if(s) GLSDL_FIX_SURFACE(s); return s; } SDL_Surface *glSDL_LoadBMP(const char *file) { SDL_Surface *s = SDL_LoadBMP(file); if(s) GLSDL_FIX_SURFACE(s); return s; } int glSDL_SaveBMP(SDL_Surface *surface, const char *file) { SDL_Rect r; SDL_Surface *buf; SDL_Surface *screen = SDL_GetVideoSurface(); if(!USING_GLSDL) return SDL_SaveBMP(surface, file); if((surface != screen) && (surface != fake_screen)) return SDL_SaveBMP(surface, file); buf = CreateRGBSurface(fake_screen->w, fake_screen->h); r.x = 0; r.y = 0; r.w = fake_screen->w; r.h = fake_screen->h; if(glSDL_BlitFromGL(&r, buf, &r) < 0) return -1; return SDL_SaveBMP(buf, file); glSDL_FreeSurface(buf); } static int InitTexture(SDL_Surface *datasurf, glSDL_TexInfo *txi, int tex) { gl.GenTextures(1, (unsigned int *)&txi->texture[tex]); gl.BindTexture(GL_TEXTURE_2D, txi->texture[tex]); gl.PixelStorei(GL_UNPACK_ROW_LENGTH, datasurf->pitch / datasurf->format->BytesPerPixel); gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); gl.TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); gl.TexImage2D(GL_TEXTURE_2D, 0, datasurf->format->Amask ? GL_RGBA8 : GL_RGB8, txi->texsize, txi->texsize, 0, datasurf->format->Amask ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, NULL); print_glerror(1); return 0; } /* Image tiled horizontally (wide surface), or not at all */ static int UploadHoriz(SDL_Surface *datasurf, glSDL_TexInfo *txi) { int bpp = datasurf->format->BytesPerPixel; int res; int tex = 0; int fromx = 0; int toy = txi->texsize; /* To init first texture */ while(1) { int thistw = datasurf->w - fromx; if(thistw > txi->tilew) thistw = txi->tilew; else if(thistw <= 0) break; if(toy + txi->tileh > txi->texsize) { toy = 0; res = InitTexture(datasurf, txi, tex); if(res < 0) return res; ++tex; } gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, toy, thistw, txi->tileh, datasurf->format->Amask ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (char *)datasurf->pixels + bpp * fromx); print_glerror(2); fromx += txi->tilew; toy += txi->tileh; gl.Flush(); } return 0; } /* Image tiled vertically (tall surface) */ static int UploadVert(SDL_Surface *datasurf, glSDL_TexInfo *txi) { int res; int tex = 0; int fromy = 0; int tox = txi->texsize; /* To init first texture */ while(1) { int thisth = datasurf->h - fromy; if(thisth > txi->tileh) thisth = txi->tileh; else if(thisth <= 0) break; if(tox + txi->tilew > txi->texsize) { tox = 0; res = InitTexture(datasurf, txi, tex); if(res < 0) return res; ++tex; } gl.TexSubImage2D(GL_TEXTURE_2D, 0, tox, 0, txi->tilew, thisth, datasurf->format->Amask ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (char *)datasurf->pixels + datasurf->pitch * fromy); print_glerror(3); fromy += txi->tileh; tox += txi->tilew; gl.Flush(); } return 0; } /* Image tiled two-way (huge surface) */ static int UploadHuge(SDL_Surface *datasurf, glSDL_TexInfo *txi) { int bpp = datasurf->format->BytesPerPixel; int res; int tex = 0; int y = 0; while(y < datasurf->h) { int x; int thisth = datasurf->h - y; if(thisth > txi->tileh) thisth = txi->tileh; x = 0; while(x < datasurf->w) { int thistw = datasurf->w - x; if(thistw > txi->tilew) thistw = txi->tilew; res = InitTexture(datasurf, txi, tex++); if(res < 0) return res; gl.TexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, thistw, thisth, datasurf->format->Amask ? GL_RGBA : GL_RGB, GL_UNSIGNED_BYTE, (char *)datasurf->pixels + datasurf->pitch * y + bpp * x); print_glerror(4); x += txi->tilew; gl.Flush(); } y += txi->tileh; } return 0; } /* Upload all textures for a surface. */ static int UploadTextures(SDL_Surface *datasurf, glSDL_TexInfo *txi) { switch(txi->tilemode) { case GLSDL_TM_SINGLE: case GLSDL_TM_HORIZONTAL: UploadHoriz(datasurf, txi); break; case GLSDL_TM_VERTICAL: UploadVert(datasurf, txi); break; case GLSDL_TM_HUGE: UploadHuge(datasurf, txi); break; } return 0; } SDL_Surface *glSDL_IMG_Load(const char *file) { SDL_Surface *s; s = IMG_Load(file); if(s) GLSDL_FIX_SURFACE(s); return s; } /*---------------------------------------------------------- glSDL specific API extensions ----------------------------------------------------------*/ int glSDL_VSync(int use) { int old = vsync; if(use >= 0) vsync = use; return old; } void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area) { glSDL_TexInfo *txi; if(!surface) return; txi = glSDL_GetTexInfo(surface); if(!txi) return; if(!area) { txi->invalid_area.x = 0; txi->invalid_area.y = 0; txi->invalid_area.w = surface->w; txi->invalid_area.h = surface->h; return; } txi->invalid_area = *area; } int glSDL_UploadSurface(SDL_Surface *surface) { SDL_Surface *datasurf = surface; glSDL_TexInfo *txi; int i; /* * For now, we just assume that *every* texture needs * conversion before uploading. */ /* If there's no TexInfo, add one. */ if(!IS_GLSDL_SURFACE(surface)) glSDL_AddTexInfo(surface); txi = glSDL_GetTexInfo(surface); if(!txi) return -1; /* No partial updates implemented yet... */ if(txi->invalid_area.w) glSDL_UnloadSurface(surface); else { int missing = 0; if(txi->textures) { for(i = 0; i < txi->textures; ++i) if(-1 == txi->texture[i]) { missing = 1; break; } if(!missing) return 0; /* They're already there! */ } } if(txi->texsize > maxtexsize) { fprintf(stderr, "glSDL/wrapper: INTERNAL ERROR: Too large texture!\n"); return -1; /* This surface wasn't tiled properly... */ } /* * Kludge: Convert if not of preferred RGB or RGBA format. * * Conversion should only be done when *really* needed. * That is, it should rarely have to be done with OpenGL * 1.2+. * * Besides, any surface that's been SDL_DisplayFormat()ed * should already be in the best known OpenGL format - * preferably one that makes DMA w/o conversion possible. */ if(FormatIsOk(surface)) datasurf = surface; else { DBG(fprintf(stderr, "glSDL/wrapper: WARNING: On-the-fly conversion performed!\n")); if(surface->format->Amask) datasurf = glSDL_DisplayFormatAlpha(surface); else datasurf = glSDL_DisplayFormat(surface); if(!datasurf) return -2; } if(UploadTextures(datasurf, txi) < 0) return -3; if(datasurf != surface) glSDL_FreeSurface(datasurf); return 0; } static void UnloadTexture(glSDL_TexInfo *txi) { int i; if(SDL_WasInit(SDL_INIT_VIDEO)) for(i = 0; i < txi->textures; ++i) gl.DeleteTextures(1, (unsigned int *)&txi->texture[i]); memset(&txi->invalid_area, 0, sizeof(txi->invalid_area)); } void glSDL_UnloadSurface(SDL_Surface *surface) { glSDL_TexInfo *txi; if(!IS_GLSDL_SURFACE(surface)) return; txi = glSDL_GetTexInfo(surface); if(txi) UnloadTexture(txi); } #else /* HAVE_OPENGL */ /*---------------------------------------------------------- Dummies for glSDL extensions that require OpenGL ----------------------------------------------------------*/ void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area) { } int glSDL_UploadSurface(SDL_Surface *surface) { return 0; } void glSDL_UnloadSurface(SDL_Surface *surface) { } int glSDL_VSync(int use) { return 0; } void glSDL_SetBlendAlpha(Uint8 alpha) { } void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b) { } void glSDL_SetCenter(float x, float y) { } void glSDL_SetRotation(float angle) { } void glSDL_SetScale(float x, float y) { } void glSDL_ResetState(void) { } #endif /* HAVE_OPENGL */ KoboDeluxe-0.5.1/graphics/gfxengine.cpp0000666000175000001440000006314210731607057014771 00000000000000/*(LGPL) ---------------------------------------------------------------------- gfxengine.cpp - Graphics Engine ---------------------------------------------------------------------- * Copyright (C) 2001-2003, 2006-2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) x #include "logger.h" #include #include #include "gfxengine.h" #include "filters.h" #include "SDL_image.h" #include "glSDL.h" #include "sofont.h" #include "window.h" gfxengine_t *gfxengine; gfxengine_t::gfxengine_t() { gfxengine = this; /* Uurgh! Kludge. */ screen_surface = NULL; softbuf = NULL; fullwin = NULL; window = NULL; windows = NULL; wx = wy = 0; xs = ys = 256; // 1.0 sxs = sys = 256; // 1.0 sf1 = df = dsf = acf = NULL; gfx = NULL; csengine = NULL; _driver = GFX_DRIVER_SDL2D; _shadow = 1; _doublebuf = 1; _pages = -1; _vsync = 1; _fullscreen = 0; _centered = 0; use_interpolation = 1; _depth = 0; _title = "GfxEngine v0.4"; _icontitle = "GfxEngine"; _cursor = 1; _width = 320; _height = 240; _autoinvalidate = 1; _scalemode = GFX_SCALE_NEAREST; _clamping = 0; xflags = 0; _dither = 0; _dither_type = 0; broken_rgba8 = 0; alpha_threshold = 0; _brightness = 1.0; _contrast = 1.0; last_tick = -1000000; ticks_per_frame = 1000.0/60.0; is_running = 0; is_showing = 0; is_open = 0; memset(fonts, 0, sizeof(fonts)); xscroll = yscroll = 0; for(int i = 0; i < CS_LAYERS ; ++i) xratio[i] = yratio[i] = 0.0; dirtyrects[0] = 0; dirtyrects[1] = 0; frontpage = 0; backpage = 1; screenshot_count = 0; } gfxengine_t::~gfxengine_t() { stop(); hide(); close(); window_t *w = windows; while(w) { w->engine = NULL; w = w->next; } } void gfxengine_t::output(window_t *outwin) { window = outwin; } /*---------------------------------------------------------- Initialization ----------------------------------------------------------*/ void gfxengine_t::size(int w, int h) { int was_showing = is_showing; hide(); _width = w; _height = h; if(csengine) cs_engine_set_size(csengine, w, h); if(was_showing) show(); } void gfxengine_t::centered(int c) { int was_showing = is_showing; hide(); _centered = c; if(was_showing) show(); } void gfxengine_t::scale(float x, float y) { xs = (int)(x * 256.f); ys = (int)(y * 256.f); log_printf(DLOG, "gfxengine: Setting scale to %d:256 x %d:256.\n", xs, ys); } void gfxengine_t::mode(int bits, int fullscreen) { int was_showing = is_showing; hide(); int olddepth = _depth; _depth = bits; if(_depth != olddepth) reload(); _fullscreen = fullscreen; if(was_showing) show(); } void gfxengine_t::driver(gfx_drivers_t drv) { int was_showing = is_showing; hide(); _driver = drv; if(was_showing) show(); } void gfxengine_t::doublebuffer(int use) { if(_doublebuf == use) return; int was_showing = is_showing; hide(); _doublebuf = use; if(was_showing) show(); } void gfxengine_t::pages(int np) { _pages = np; } void gfxengine_t::vsync(int use) { if(_vsync == use) return; int was_showing = is_showing; hide(); _vsync = use; if(was_showing) show(); } void gfxengine_t::shadow(int use) { if(_shadow == use) return; int was_showing = is_showing; hide(); _shadow = use; if(was_showing) show(); } void gfxengine_t::autoinvalidate(int use) { _autoinvalidate = use; } void gfxengine_t::period(float frameduration) { if(frameduration > 0) { ticks_per_frame = frameduration; } else log_printf(DLOG, "gfxengine: Time line reset.\n"); if(csengine) cs_engine_advance(csengine, 0); } void gfxengine_t::wrap(int x, int y) { wx = x; wy = y; if(csengine) cs_engine_set_wrap(csengine, x, y); } /*---------------------------------------------------------- Data management ----------------------------------------------------------*/ void gfxengine_t::reset_filters() { /* Remove all filters */ s_remove_filter(NULL); sf1 = df = dsf = acf = NULL; /* Set up filter pipeline */ s_remove_filter(NULL); s_add_filter(s_filter_rgba8); #if 0 s_filter_t *fi; fi = s_add_filter(s_filter_key2alpha); fi->args.max = 1; #endif sf1 = s_add_filter(s_filter_scale); sf2 = s_add_filter(s_filter_scale); acf = s_add_filter(s_filter_cleanalpha); bcf = s_add_filter(s_filter_brightness); df = s_add_filter(s_filter_dither); dsf = s_add_filter(s_filter_displayformat); /* Set default parameters */ // colorkey(0, 0, 0); clampcolor(0, 0, 0, 0); scalemode(GFX_SCALE_NEAREST); dither(0, 0); noalpha(0); brightness(1.0, 1.0); filterflags(0); } void gfxengine_t::filterflags(int fgs) { s_filter_flags = fgs; } void gfxengine_t::scalemode(gfx_scalemodes_t sm, int clamping) { _scalemode = sm; _clamping = clamping; if(!sf1 || !df) return; int rxs = (xs * 256 + 128) / sxs; int rys = (ys * 256 + 128) / sys; #if 1 // Filter 2 is off in most cases sf2->args.x = 0; sf2->args.fx = 0.0f; sf2->args.fy = 0.0f; #endif if((rxs == 256) && (rys == 256)) { sf1->args.x = SF_SCALE_NEAREST; sf1->args.fx = 1.0f; sf1->args.fy = 1.0f; return; } switch(clamping) { default: case 0: filterflags(0); break; case 1: filterflags(SF_CLAMP_EXTEND); break; case 2: filterflags(SF_CLAMP_SFONT); break; } sf1->args.fx = rxs * (1.0f/256.0f); sf1->args.fy = rys * (1.0f/256.0f); switch(_scalemode) { case GFX_SCALE_NEAREST: //Nearest sf1->args.x = SF_SCALE_NEAREST; break; case GFX_SCALE_BILINEAR: //Bilinear sf1->args.x = SF_SCALE_BILINEAR; break; case GFX_SCALE_BILIN_OVER: //Bilinear + Oversampling #if 0 sf1->args.x = SF_SCALE_BILINEAR; sf2->args.x = SF_SCALE_BILINEAR; sf1->args.fx = rxs * (1.5f/256.f); sf1->args.fy = rys * (1.5f/256.f); sf2->args.fx = 1.0f/1.5f; sf2->args.fy = 1.0f/1.5f; break; /* Hack for better bilinear [+ oversampling] scaling... */ switch(clamping) { case 2: sf1->args.x = SF_SCALE_NEAREST; sf2->args.x = SF_SCALE_BILINEAR; switch((rxs + 128) / 256) { case 2: sf1->args.fx = 4.0f; sf1->args.fy = 4.0f; sf2->args.fx = 0.5f; sf2->args.fy = 0.5f; break; case 3: sf1->args.fx = 2.0f; sf1->args.fy = 2.0f; sf2->args.fx = 1.5f; sf2->args.fy = 1.5f; break; case 4: sf1->args.fx = 2.0f; sf1->args.fy = 2.0f; sf2->args.fx = 2.0f; sf2->args.fy = 2.0f; break; default: sf1->args.fx = rxs * (2.f/256.f); sf1->args.fy = rys * (2.f/256.f); sf2->args.fx = 0.5f; sf2->args.fy = 0.5f; break; } break; default: sf1->args.x = SF_SCALE_BILINEAR; break; } #endif sf1->args.x = SF_SCALE_BILINEAR; break; case GFX_SCALE_SCALE2X: //Scale2x sf1->args.x = SF_SCALE_SCALE2X; break; case GFX_SCALE_DIAMOND: //Diamond2x sf1->args.x = SF_SCALE_DIAMOND; break; } } void gfxengine_t::source_scale(float x, float y) { sxs = (int)(x * 256.f); sys = (int)(y * 256.f); scalemode(_scalemode, _clamping); } #if 0 void gfxengine_t::colorkey(Uint8 r, Uint8 g, Uint8 b) { s_colorkey.r = r; s_colorkey.g = g; s_colorkey.b = b; } #endif void gfxengine_t::clampcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) { s_clampcolor.r = r; s_clampcolor.g = g; s_clampcolor.b = b; s_clampcolor.a = b; } void gfxengine_t::dither(int type, int _broken_rgba8) { _dither = type >= 0; _dither_type = type; broken_rgba8 = _broken_rgba8; if(!df) return; if(!screen_surface) return; if(_dither) { if(_driver == GFX_DRIVER_GLSDL) { //Klugde for glSDL, which doesn't give us a faked //screen surface - while we're interested only in //the *texture* depth; not the display depth! df->args.r = df->args.g = df->args.b = 0; //Another kludge, because some cards support RGB8 //(24 bit) textures, but not RGBA8 (32 bit). df->args.x = broken_rgba8; } else { df->args.x = 0; df->args.r = 1<<(screen_surface->format->Rloss-1); df->args.g = 1<<(screen_surface->format->Gloss-1); df->args.b = 1<<(screen_surface->format->Bloss-1); } } else df->args.x = df->args.r = df->args.g = df->args.b = 0; df->args.y = type; } void gfxengine_t::noalpha(int threshold) { alpha_threshold = threshold; if(!dsf || !acf) return; if(threshold > 0) { acf->args.min = 128; acf->args.max = 128; acf->args.fx = 1.0; acf->args.x = threshold; dsf->args.x = 1; } else { acf->args.min = 16; acf->args.max = 255-16; acf->args.fx = 1.3; acf->args.x = -16; dsf->args.x = 0; } } void gfxengine_t::brightness(float bright, float contr) { _brightness = bright; _contrast = contr; if(!bcf) return; bcf->args.fx = _brightness; bcf->args.fy = _contrast; bcf->args.min = 0; bcf->args.max = 255; } int gfxengine_t::loadimage(int bank, const char *name) { if(!csengine) { log_printf(ELOG, "loadimage: Engine must be open!\n"); return -10; } s_blitmode = S_BLITMODE_AUTO; log_printf(DLOG, "Loading image %s (bank %d)...\n", name, bank); if(s_load_image(gfx, bank, name)) { log_printf(ELOG, " Failed to load %s!\n", name); return -1; } s_bank_t *b = s_get_bank(gfx, bank); if(!b) { log_printf(ELOG, " gfxengine: Internal error 1!\n"); return -15; } cs_engine_set_image_size(csengine, bank, b->w, b->h); log_printf(DLOG, " Ok.\n"); return 0; } int gfxengine_t::loadtiles(int bank, int w, int h, const char *name) { if(!csengine) { log_printf(ELOG, "loadtiles: Engine must be open!\n"); return -10; } s_blitmode = S_BLITMODE_AUTO; log_printf(DLOG, "Loading tiles %s (bank %d; %dx%d)...\n", name, bank, w, h); if(s_load_bank(gfx, bank, w, h, name)) { log_printf(ELOG, " Failed to load %s!\n", name); return -2; } cs_engine_set_image_size(csengine, bank, w, h); log_printf(DLOG, " Ok. (%d frames)\n", s_get_bank(gfx, bank)->max+1); return 0; } int gfxengine_t::loadfont(int bank, const char *name) { if(!csengine) { log_printf(ELOG, "loadfont: Engine must be open!\n"); return -10; } s_blitmode = S_BLITMODE_AUTO; scalemode(_scalemode, 2); log_printf(DLOG, "Loading font %s (bank %d)...\n", name, bank); if(s_load_image(gfx, bank, name)) { log_printf(ELOG, " Failed to load %s!\n", name); return -2; } if(bank >= GFX_BANKS) { log_printf(ELOG, " Too high bank #!\n"); return -3; } if(!fonts[bank]) fonts[bank] = new SoFont; if(!fonts[bank]) { log_printf(ELOG, " Failed to instantiate SoFont!\n"); return -4; } fonts[bank]->ExtraSpace((xs + 127) / 256); if(fonts[bank]->load(s_get_sprite(gfx, bank, 0)->surface)) { s_detach_sprite(gfx, bank, 0); log_printf(DLOG, " Ok.\n"); return 0; } else { log_printf(ELOG, " SoFont::load() failed!\n"); return -5; } return 0; } int gfxengine_t::copyrect(int bank, int sbank, int sframe, SDL_Rect *r) { SDL_Rect sr = *r; if(!csengine) { log_printf(ELOG, "copyrect: Engine must be open!\n"); return -10; } log_printf(DLOG, "Copying rect from %d:%d (bank %d)...\n", sbank, sframe, bank); int x2 = (int)((sr.x + sr.w) * xs + 128) >> 8; int y2 = (int)((sr.y + sr.h) * ys + 128) >> 8; sr.x = (int)(sr.x * xs + 128) >> 8; sr.y = (int)(sr.y * ys + 128) >> 8; sr.w = x2 - sr.x; sr.h = y2 - sr.y; if(s_copy_rect(gfx, bank, sbank, sframe, &sr) < 0) { log_printf(ELOG, " s_copy_rect() failed!\n"); return -1; } log_printf(DLOG, " Ok.\n"); return 0; } int gfxengine_t::is_loaded(int bank) { if(!csengine) return 0; if(!s_get_bank(gfx, (unsigned)bank)) return 0; return 1; } void gfxengine_t::reload() { log_printf(DLOG, "Reloading all banks. (Not implemented!)\n"); // s_reload_all_banks(gfx); } void gfxengine_t::unload(int bank) { if(bank < 0) { log_printf(DLOG, "Unloading all banks.\n"); for(int i = 0; i < GFX_BANKS; ++i) { delete fonts[i]; fonts[i] = NULL; } if(gfx) s_delete_all_banks(gfx); } else { log_printf(DLOG, "Unloading bank %d.\n", bank); if(bank < GFX_BANKS) { delete fonts[bank]; fonts[bank] = NULL; } if(gfx) s_delete_bank(gfx, bank); } } /*---------------------------------------------------------- Engine open/close ----------------------------------------------------------*/ void gfxengine_t::on_frame(cs_engine_t *e) { gfxengine->__frame(); gfxengine->frame(); } int gfxengine_t::open(int objects, int extraflags) { xflags = extraflags; if(is_open) return show(); log_printf(DLOG, "Opening engine...\n"); csengine = cs_engine_create(_width, _height, objects); if(!csengine) { log_printf(ELOG, "Failed to set up control system engine!\n"); return -1; } csengine->on_frame = on_frame; cs_engine_set_wrap(csengine, wx, wy); gfx = s_new_container(GFX_BANKS); if(!gfx) { log_printf(ELOG, "Failed to set up graphics container!\n"); cs_engine_delete(csengine); return -2; } reset_filters(); is_open = 1; return show(); } void gfxengine_t::close() { if(!is_open) return; log_printf(DLOG ,"Closing engine...\n"); stop(); hide(); unload(); cs_engine_delete(csengine); csengine = NULL; s_remove_filter(NULL); sf1 = df = dsf = acf = NULL; s_delete_container(gfx); gfx = NULL; is_open = 0; } /*---------------------------------------------------------- Settings ----------------------------------------------------------*/ void gfxengine_t::title(const char *win, const char *icon) { _title = win; _icontitle = icon; if(screen_surface) SDL_WM_SetCaption(_title, _icontitle); } /*---------------------------------------------------------- Display show/hide ----------------------------------------------------------*/ int gfxengine_t::show() { int flags = 0; if(!is_open) return -1; if(is_showing) return 0; if(_centered && !_fullscreen) SDL_putenv((char *)"SDL_VIDEO_CENTERED=1"); log_printf(DLOG, "Opening screen...\n"); if(!SDL_WasInit(SDL_INIT_VIDEO)) if(SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) { log_printf(ELOG, "Failed to initialize SDL!\n"); return -2; } switch(_driver) { case GFX_DRIVER_SDL2D: break; case GFX_DRIVER_GLSDL: if(!_doublebuf) { log_printf(WLOG, "Only double buffering is supported" " with OpenGL drivers!\n"); doublebuffer(1); } if(_shadow) { log_printf(WLOG, "Shadow buffer not supported" " with OpenGL drivers!\n"); shadow(0); } break; } switch(_driver) { case GFX_DRIVER_SDL2D: /* Nothing extra */ break; case GFX_DRIVER_GLSDL: flags |= SDL_GLSDL; break; } if(_doublebuf) flags |= SDL_DOUBLEBUF | SDL_HWSURFACE; else { if(!_shadow) flags |= SDL_HWSURFACE; } if(_fullscreen) flags |= SDL_FULLSCREEN; glSDL_VSync(_vsync); flags |= xflags; screen_surface = SDL_SetVideoMode(_width, _height, _depth, flags); if(!screen_surface) { log_printf(ELOG, "Failed to open display!\n"); return -3; } if(_driver != GFX_DRIVER_GLSDL) { if((screen_surface->flags & SDL_DOUBLEBUF) == SDL_DOUBLEBUF) { if(!_doublebuf) { log_printf(WLOG, "Could not get" " single buffered display.\n"); doublebuffer(1); } } else { if(_doublebuf) { log_printf(WLOG, "Could not get" " double buffered display.\n"); doublebuffer(0); } } } if((screen_surface->flags & SDL_HWSURFACE) == SDL_HWSURFACE) { if(_shadow) { softbuf = SDL_CreateRGBSurface(SDL_SWSURFACE, _width, _height, screen_surface->format->BitsPerPixel, screen_surface->format->Rmask, screen_surface->format->Gmask, screen_surface->format->Bmask, screen_surface->format->Amask); if(!softbuf) { log_printf(WLOG, "Failed to create shadow buffer! " "Trying direct rendering.\n"); shadow(0); } } } else { if(_shadow) log_printf(WLOG, "Shadow buffer requested; " "relying on SDL's shadow buffer.\n"); else { log_printf(WLOG, "Could not get h/w display surface.\n"); shadow(0); //...which means we're using SDL's shadow. } } SDL_WM_SetCaption(_title, _icontitle); SDL_ShowCursor(_cursor); cs_engine_set_size(csengine, _width, _height); csengine->filter = use_interpolation; dither(_dither); noalpha(alpha_threshold); is_showing = 1; fullwin = new window_t; fullwin->init(this); fullwin->place(0, 0, (int)(_width / xscale()), (int)(_height / yscale())); clear(); return 0; } void gfxengine_t::clear(Uint32 _color) { if(!fullwin) return; fullwin->background(fullwin->map_rgb(_color)); fullwin->clear(); flip(); fullwin->clear(); flip(); fullwin->clear(); } void gfxengine_t::hide(void) { if(!is_showing) return; log_printf(DLOG, "Closing screen...\n"); stop(); delete fullwin; fullwin = NULL; // Make sure no windows keep old surface pointers! window_t *w = windows; while(w) { if((w->surface == screen_surface) || (w->surface == softbuf)) w->surface = NULL; w = w->next; } if(softbuf) { SDL_FreeSurface(softbuf); softbuf = NULL; } screen_surface = NULL; is_showing = 0; } void gfxengine_t::invalidate(SDL_Rect *rect, window_t *window) { switch(_pages) { case -1: if(_doublebuf) __invalidate(1, rect, window); __invalidate(0, rect, window); break; case 0: __invalidate(0, NULL, NULL); break; case 3: __invalidate(2, rect, window); // Fallthrough! case 2: __invalidate(1, rect, window); // Fallthrough! case 1: __invalidate(0, rect, window); break; } } void gfxengine_t::__invalidate(int page, SDL_Rect *rect, window_t *window) { if(!screen_surface) return; if(!rect || (_pages == 0)) { dirtyrects[page] = 1; dirtytable[page][0].x = 0; dirtytable[page][0].y = 0; dirtytable[page][0].w = screen_surface->w; dirtytable[page][0].h = screen_surface->h; dirtywtable[page][0] = NULL; return; } /* Clip to screen (stolen from SDL_surface.c) */ SDL_Rect dr = *rect; int Amin, Amax, Bmin, Bmax; /* Horizontal intersection */ Amin = dr.x; Amax = Amin + dr.w; Bmin = screen_surface->clip_rect.x; Bmax = Bmin + screen_surface->clip_rect.w; if(Bmin > Amin) Amin = Bmin; dr.x = Amin; if(Bmax < Amax) Amax = Bmax; dr.w = Amax - Amin > 0 ? Amax - Amin : 0; /* Vertical intersection */ Amin = dr.y; Amax = Amin + dr.h; Bmin = screen_surface->clip_rect.y; Bmax = Bmin + screen_surface->clip_rect.h; if(Bmin > Amin) Amin = Bmin; dr.y = Amin; if(Bmax < Amax) Amax = Bmax; dr.h = Amax - Amin > 0 ? Amax - Amin : 0; if(!dr.w || !dr.h) return; for(int i = 0; i < dirtyrects[page]; ++i) if(memcmp(&dirtytable[page][i], &dr, sizeof(dr)) == 0) return; if(dirtyrects[page] < MAX_DIRTYRECTS - 1) { dirtytable[page][dirtyrects[page]] = dr; dirtywtable[page][dirtyrects[page]] = window; ++dirtyrects[page]; } else log_printf(ELOG, "gfxengine: Page %d out of dirtyrects!\n", page); } /*---------------------------------------------------------- Engine start/stop ----------------------------------------------------------*/ void gfxengine_t::start_engine() { last_tick = -1000000; } void gfxengine_t::stop_engine() { } /*---------------------------------------------------------- Control ----------------------------------------------------------*/ /* * Run engine until stop() is called. * * The virtual member frame() will be called once for * each control system frame. pre_render() and * post_render() will be called before/after the engine * renders each video frame. */ void gfxengine_t::run() { open(); show(); start_engine(); is_running = 1; double toframe = 0.0f; double fdt = 1.0f; cs_engine_advance(csengine, 0); while(is_running) { int t = (int)SDL_GetTicks(); int dt = t - last_tick; last_tick = t; if(abs(dt) > 500) last_tick = t; if(dt > 250) dt = (int)ticks_per_frame; if(_timefilter) fdt += (dt - fdt) * _timefilter; else fdt = ticks_per_frame; toframe += fdt / ticks_per_frame; cs_engine_advance(csengine, toframe); pre_render(); window->select(); cs_engine_render(csengine); post_render(); if(_autoinvalidate) window->invalidate(); flip(); } stop_engine(); } void gfxengine_t::stop() { if(!is_running) return; log_printf(DLOG, "Stopping engine...\n"); is_running = 0; } void gfxengine_t::cursor(int csr) { _cursor = csr; if(screen_surface) SDL_ShowCursor(csr); } void gfxengine_t::interpolation(int inter) { use_interpolation = inter; if(!csengine) return; csengine->filter = use_interpolation; } void gfxengine_t::timefilter(float coeff) { if(coeff < 0.001f) _timefilter = 0.0f; else if(coeff > 1.0f) _timefilter = 1.0f; else _timefilter = coeff; } void gfxengine_t::scroll_ratio(int layer, float xr, float yr) { if(layer < 0) return; if(layer >= CS_LAYERS) return; xratio[layer] = xr; yratio[layer] = yr; } void gfxengine_t::scroll(int xscr, int yscr) { xscroll = xscr; yscroll = yscr; /* Apply current scroll pos to layers */ for(int i = 0; i < CS_LAYERS ; ++i) { csengine->offsets[i].v.x = (int)floor(xscroll * xratio[i]); csengine->offsets[i].v.y = (int)floor(yscroll * yratio[i]); } } void gfxengine_t::force_scroll() { if(csengine) for(int i = 0; i < CS_LAYERS ; ++i) cs_point_force(&csengine->offsets[i]); } int gfxengine_t::xoffs(int layer) { if(layer < 0) return 0; if(layer >= CS_LAYERS) return 0; return csengine->offsets[layer].gx; } int gfxengine_t::yoffs(int layer) { if(layer < 0) return 0; if(layer >= CS_LAYERS) return 0; return csengine->offsets[layer].gy; } SDL_Surface *gfxengine_t::surface() { if(softbuf) return softbuf; else return screen_surface; } void gfxengine_t::screenshot() { char filename[1024]; snprintf(filename, sizeof(filename), "screen%d.bmp", screenshot_count++); SDL_SaveBMP(screen_surface, filename); } /*---------------------------------------------------------- Internal stuff ----------------------------------------------------------*/ /* Default frame handler */ void gfxengine_t::frame() { SDL_Event ev; while(SDL_PollEvent(&ev)) { if(ev.type == SDL_KEYDOWN) if(ev.key.keysym.sym == SDLK_ESCAPE) stop(); } } /* Internal frame handler */ void gfxengine_t::__frame() { } void gfxengine_t::pre_render() { } void gfxengine_t::post_render() { } void gfxengine_t::refresh_rect(SDL_Rect *r) { window_t *w = windows; for(w = windows; w; w = w->next) { if(!w->visible()) continue; SDL_Rect dr = *r; /* Clip to window */ int Amin, Amax, Bmin, Bmax; /* Horizontal intersection */ Amin = dr.x; Amax = Amin + dr.w; Bmin = w->phys_rect.x; Bmax = Bmin + w->phys_rect.w; if(Bmin > Amin) Amin = Bmin; dr.x = Amin; if(Bmax < Amax) Amax = Bmax; dr.w = Amax - Amin > 0 ? Amax - Amin : 0; /* Vertical intersection */ Amin = dr.y; Amax = Amin + dr.h; Bmin = w->phys_rect.y; Bmax = Bmin + w->phys_rect.h; if(Bmin > Amin) Amin = Bmin; dr.y = Amin; if(Bmax < Amax) Amax = Bmax; dr.h = Amax - Amin > 0 ? Amax - Amin : 0; if(dr.w && dr.h) w->phys_refresh(&dr); } } void gfxengine_t::flip() { if(!screen_surface) return; // Init dirtyrect table flipping, if necessary. switch(_pages) { case -1: if(!_doublebuf) frontpage = backpage = 0; else if(frontpage == backpage) { frontpage = 0; backpage = 1; } break; case 0: frontpage = backpage = 0; invalidate(); break; case 1: frontpage = backpage = 0; break; case 2: case 3: if(frontpage == backpage) { frontpage = 0; backpage = 1; } break; } // Process the dirtyrects. int i; for(i = 0; i < dirtyrects[backpage]; ++i) { if(dirtywtable[backpage][i]) { if(!dirtywtable[backpage][i]->visible()) continue; SDL_Rect dr = dirtytable[backpage][i]; dirtywtable[backpage][i]->phys_refresh(&dr); } else refresh_rect(&dirtytable[backpage][i]); } // Perform the actual flip or update if(_shadow) { for(i = 0; i < dirtyrects[backpage]; ++i) SDL_BlitSurface(softbuf, &dirtytable[backpage][i], screen_surface, &dirtytable[backpage][i]); } if(_doublebuf) { dirtyrects[backpage] = 0; if(_pages == -1) { backpage = !backpage; frontpage = !frontpage; } else if(_pages > 1) { backpage = (backpage + 1) % _pages; frontpage = (frontpage + 1) % _pages; } SDL_Flip(screen_surface); } else { SDL_UpdateRects(screen_surface, dirtyrects[0], dirtytable[0]); dirtyrects[0] = 0; } } /* * Generic render() callback for sprites and tiles. */ void gfxengine_t::render_sprite(cs_obj_t *o) { SDL_Rect dest_rect; s_sprite_t *s = gfxengine->get_sprite(o->anim.bank, o->anim.frame); if(!s || !s->surface) return; int x = o->point.gx - (s->x << 8); int y = o->point.gy - (s->y << 8); dest_rect.x = CS2PIXEL((x * gfxengine->xs + 128) >> 8); dest_rect.y = CS2PIXEL((y * gfxengine->ys + 128) >> 8); dest_rect.x += (gfxengine->window->x() * gfxengine->xs + 128) >> 8; dest_rect.y += (gfxengine->window->y() * gfxengine->xs + 128) >> 8; SDL_BlitSurface(s->surface, NULL, gfxengine->surface(), &dest_rect); if(!gfxengine->_autoinvalidate) { dest_rect.w = s->surface->w; dest_rect.h = s->surface->h; gfxengine->invalidate(&dest_rect); } } cs_obj_t *gfxengine_t::get_obj(int layer) { cs_obj_t *o = cs_engine_get_obj(csengine); if(o) { o->render = render_sprite; cs_obj_layer(o, layer); cs_obj_activate(o); } return o; } void gfxengine_t::free_obj(cs_obj_t *obj) { cs_obj_free(obj); } int gfxengine_t::objects_in_use() { if(!csengine) return 0; return csengine->pool_total - csengine->pool_free; } SoFont *gfxengine_t::get_font(unsigned int f) { if(f < GFX_BANKS) return fonts[f]; else return NULL; } KoboDeluxe-0.5.1/graphics/window.cpp0000666000175000001440000002740710730444464014332 00000000000000/*(LGPL) --------------------------------------------------------------------------- window.cpp - Generic Rendering Window --------------------------------------------------------------------------- * Copyright (C) 2001-2003, 2006, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "logger.h" #include "window.h" #include "gfxengine.h" #include "sofont.h" #define SELECT if(selected != this) _select(); window_t *window_t::selected = NULL; window_t::window_t() { engine = NULL; surface = NULL; next = NULL; prev = NULL; phys_rect.x = phys_rect.y = 0; phys_rect.w = 320; phys_rect.h = 240; fgcolor = bgcolor = 0; selected = 0; xs = ys = 256; bg_bank = -1; bg_frame = -1; _visible = 1; _offscreen = 0; } window_t::~window_t() { if(_offscreen && surface) SDL_FreeSurface(surface); if(selected == this) selected = NULL; unlink(); } void window_t::init(gfxengine_t *e) { link(e); xs = engine->xs; ys = engine->ys; if(_offscreen && surface) { SDL_FreeSurface(surface); surface = NULL; } _offscreen = 0; surface = engine->surface(); } void window_t::visible(int vis) { if(_offscreen) return; // Cannot be visible! if(_visible == vis) return; _visible = vis; invalidate(); } void window_t::link(gfxengine_t *e) { unlink(); engine = e; next = NULL; prev = engine->windows; if(prev) { while(prev->next) prev = prev->next; prev->next = this; } else engine->windows = this; } void window_t::unlink(void) { if(engine) { if(engine->windows == this) engine->windows = next; if(engine->surface() == surface) surface = NULL; } if(next) next->prev = prev; if(prev) prev->next = next; } void window_t::place(int left, int top, int sizex, int sizey) { int x2 = ((left + sizex) * xs + 128) >> 8; int y2 = ((top + sizey) * ys + 128) >> 8; phys_rect.x = (left * xs + 128) >> 8; phys_rect.y = (top * ys + 128) >> 8; phys_rect.w = x2 - phys_rect.x; phys_rect.h = y2 - phys_rect.y; } int window_t::offscreen() { if(!engine) return -1; if(!engine->surface()) return -1; if(_offscreen) return 0; // Already offscreen! visible(0); _offscreen = 1; SDL_Surface *s = SDL_CreateRGBSurface(SDL_SWSURFACE, phys_rect.w, phys_rect.h, 32, 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); if(!s) return -1; surface = SDL_DisplayFormat(s); SDL_FreeSurface(s); if(!surface) return -1; return 0; } void window_t::select() { if(engine) _select(); } void window_t::_select() { SDL_Rect r = phys_rect; selected = this; if(surface) SDL_SetClipRect(surface, &r); } void window_t::invalidate(SDL_Rect *r) { if(!engine) return; if(!engine->surface()) return; SELECT if(_offscreen) { if(!r) { SDL_Rect rr; rr.x = 0; rr.y = 0; rr.w = phys_rect.w; rr.h = phys_rect.h; phys_refresh(&rr); glSDL_Invalidate(surface, &rr); } else { phys_refresh(r); glSDL_Invalidate(surface, r); } return; } if(!r) engine->invalidate(&phys_rect, this); else { /* Translate to screen coordinates */ SDL_Rect dr = *r; dr.x = (dr.x * xs + 128) >> 8; dr.y = (dr.y * ys + 128) >> 8; dr.w = (((dr.w + dr.x) * xs + 128) >> 8) - dr.x; dr.h = (((dr.h + dr.y) * ys + 128) >> 8) - dr.y; dr.x += phys_rect.x; dr.y += phys_rect.y; /* Clip to window (stolen from SDL_surface.c) */ int Amin, Amax, Bmin, Bmax; /* Horizontal intersection */ Amin = dr.x; Amax = Amin + dr.w; Bmin = phys_rect.x; Bmax = Bmin + phys_rect.w; if(Bmin > Amin) Amin = Bmin; dr.x = Amin; if(Bmax < Amax) Amax = Bmax; dr.w = Amax - Amin > 0 ? Amax - Amin : 0; /* Vertical intersection */ Amin = dr.y; Amax = Amin + dr.h; Bmin = phys_rect.y; Bmax = Bmin + phys_rect.h; if(Bmin > Amin) Amin = Bmin; dr.y = Amin; if(Bmax < Amax) Amax = Bmax; dr.h = Amax - Amin > 0 ? Amax - Amin : 0; if(dr.w && dr.h) engine->invalidate(&dr, this); } } /*--------------------------------------------------------------- Rendering API ---------------------------------------------------------------*/ Uint32 window_t::map_rgb(Uint8 r, Uint8 g, Uint8 b) { if(!engine) return 0; if(surface) return SDL_MapRGB(surface->format, r, g, b); else return 0xffffff; } Uint32 window_t::map_rgb(Uint32 rgb) { if(!engine) return 0; Uint8 r = (rgb >> 16) & 0xff; Uint8 g = (rgb >> 8) & 0xff; Uint8 b = rgb & 0xff; if(surface) return SDL_MapRGB(surface->format, r, g, b); else return 0xffffff; } void window_t::bgimage(int bank, int frame) { bg_bank = bank; bg_frame = frame; } void window_t::colorkey(Uint32 color) { if(!engine) return; if(!engine->surface()) return; if(!_offscreen) return; SDL_SetColorKey(surface, SDL_SRCCOLORKEY, color); } void window_t::colorkey() { if(!engine) return; if(!engine->surface()) return; if(!_offscreen) return; SDL_SetColorKey(surface, 0, 0); } void window_t::alpha(float a) { if(!engine) return; if(!engine->surface()) return; if(!_offscreen) return; SDL_SetAlpha(surface, SDL_SRCALPHA, (int)(a * 255.0)); } void window_t::font(int fnt) { _font = fnt; } void window_t::string(int _x, int _y, const char *txt) { string_fxp(PIXEL2CS(_x), PIXEL2CS(_y), txt); } void window_t::center(int _y, const char *txt) { center_fxp(PIXEL2CS(_y), txt); } void window_t::center_token(int _x, int _y, const char *txt, char token) { center_token_fxp(PIXEL2CS(_x), PIXEL2CS(_y), txt, token); } void window_t::string_fxp(int _x, int _y, const char *txt) { if(!engine) return; _x = CS2PIXEL((_x * xs + 128) >> 8); _y = CS2PIXEL((_y * ys + 128) >> 8); SoFont *f = engine->get_font(_font); if(!f) return; SELECT _x += phys_rect.x; _y += phys_rect.y; if(surface) f->PutString(surface, _x, _y, txt); } void window_t::center_fxp(int _y, const char *txt) { _y = CS2PIXEL((_y * ys + 128) >> 8); if(!engine) return; SoFont *f = engine->get_font(_font); if(!f) return; SELECT int _x = (phys_rect.w - f->TextWidth(txt) + 1) / 2; _x += phys_rect.x; _y += phys_rect.y; if(surface) f->PutString(surface, _x, _y, txt); } void window_t::center_token_fxp(int _x, int _y, const char *txt, char token) { _x = CS2PIXEL((_x * xs + 128) >> 8); _y = CS2PIXEL((_y * ys + 128) >> 8); if(!engine) return; SoFont *f = engine->get_font(_font); if(!f) return; SELECT int _cx; if(-1 == token) _cx = _x - f->TextWidth(txt)/2; else { int tokpos; /* * My docs won't say if strchr(???, 0) is legal * or even defined, so I'm not taking any chances... */ if(token) { char *tok = strchr(txt, token); if(tok) tokpos = tok-txt; else tokpos = 255; } else tokpos = 255; _cx = _x - f->TextWidth(txt, 0, tokpos); } _cx += phys_rect.x; _y += phys_rect.y; if(surface) f->PutString(surface, _cx, _y, txt); } int window_t::textwidth_fxp(const char *txt, int min, int max) { if(!engine) return strlen(txt); SoFont *f = engine->get_font(_font); if(!f) return strlen(txt); return (f->TextWidth(txt, min, max) << 16) / xs; } int window_t::textwidth(const char *txt, int min, int max) { if(!engine) return strlen(txt); SoFont *f = engine->get_font(_font); if(!f) return strlen(txt); return (f->TextWidth(txt, min, max) << 8) / xs; } int window_t::fontheight() { if(!engine) return 1; SoFont *f = engine->get_font(_font); if(!f) return 1; return (f->FontHeight() * 256) / ys; } void window_t::clear(SDL_Rect *r) { SDL_Rect sr, dr; if(!engine) return; if(!surface) return; SELECT if(!r) { sr = phys_rect; sr.x = 0; sr.y = 0; dr = phys_rect; } else { sr.x = ((int)r->x * xs + 128) >> 8; sr.y = ((int)r->y * ys + 128) >> 8; sr.w = (((int)(r->x + r->w) * xs + 128) >> 8) - sr.x; sr.h = (((int)(r->y + r->h) * ys + 128) >> 8) - sr.y; dr = sr; dr.x += phys_rect.x; dr.y += phys_rect.y; } if((-1 == bg_bank) && (-1 == bg_frame)) SDL_FillRect(surface, &dr, bgcolor); else { s_sprite_t *s = engine->get_sprite(bg_bank, bg_frame); if(!s || !s->surface) { SDL_FillRect(surface, &dr, bgcolor); return; } SDL_BlitSurface(s->surface, &sr, surface, &dr); } } void window_t::point(int _x, int _y) { int x2 = ((_x + 1) * xs + 128) >> 8; int y2 = ((_y + 1) * ys + 128) >> 8; _x = (_x * xs + 128) >> 8; _y = (_y * ys + 128) >> 8; if(!engine) return; SELECT /* Quick hack; slow */ SDL_Rect r; r.x = phys_rect.x + _x; r.y = phys_rect.y + _y; r.w = x2 - _x; r.h = y2 - _y; if(surface) SDL_FillRect(surface, &r, fgcolor); } void window_t::fillrect(int _x, int _y, int w, int h) { int x2 = ((_x + w) * xs + 128) >> 8; int y2 = ((_y + h) * ys + 128) >> 8; _x = (_x * xs + 128) >> 8; _y = (_y * ys + 128) >> 8; if(!engine) return; SELECT SDL_Rect r; r.x = phys_rect.x + _x; r.y = phys_rect.y + _y; r.w = x2 - _x; r.h = y2 - _y; if(surface) SDL_FillRect(surface, &r, fgcolor); } void window_t::rectangle(int _x, int _y, int w, int h) { fillrect(_x, _y, w, 1); fillrect(_x, _y + h - 1, w, 1); fillrect(_x, _y + 1, 1, h - 2); fillrect(_x + w - 1, _y + 1, 1, h - 2); } void window_t::fillrect_fxp(int _x, int _y, int w, int h) { int xx = CS2PIXEL((_x * xs + 128) >> 8); int yy = CS2PIXEL((_y * ys + 128) >> 8); w = CS2PIXEL(((w + _x) * xs + 128) >> 8) - xx; h = CS2PIXEL(((h + _y) * ys + 128) >> 8) - yy; if(!engine) return; SELECT SDL_Rect r; r.x = phys_rect.x + xx; r.y = phys_rect.y + yy; r.w = w; r.h = h; if(surface) SDL_FillRect(surface, &r, fgcolor); } void window_t::sprite(int _x, int _y, int bank, int frame, int inval) { sprite_fxp(PIXEL2CS(_x), PIXEL2CS(_y), bank, frame, inval); } void window_t::sprite_fxp(int _x, int _y, int bank, int frame, int inval) { if(!engine) return; s_sprite_t *s = engine->get_sprite(bank, frame); if(!s || !s->surface) return; _x = CS2PIXEL(((_x - (s->x << 8)) * xs + 128) >> 8); _y = CS2PIXEL(((_y - (s->y << 8)) * ys + 128) >> 8); SDL_Rect dest_rect; SELECT dest_rect.x = phys_rect.x + _x; dest_rect.y = phys_rect.y + _y; if(surface) SDL_BlitSurface(s->surface, NULL, surface, &dest_rect); if(inval && !engine->autoinvalidate()) { dest_rect.w = s->surface->w; dest_rect.h = s->surface->h; engine->invalidate(&dest_rect, this); } } void window_t::blit(int dx, int dy, int sx, int sy, int sw, int sh, window_t *src) { if(!engine) return; if(!src) return; if(!surface) return; if(!src->surface) return; SELECT SDL_Rect src_rect; int sx2 = ((sx + sw) * xs + 128) >> 8; int sy2 = ((sy + sh) * ys + 128) >> 8; src_rect.x = (sx * xs + 128) >> 8; src_rect.y = (sy * ys + 128) >> 8; src_rect.w = sx2 - src_rect.x; src_rect.h = sy2 - src_rect.y; SDL_Rect dest_rect; dest_rect.x = phys_rect.x + ((dx * xs + 128) >> 8); dest_rect.y = phys_rect.y + ((dy * ys + 128) >> 8); SDL_BlitSurface(src->surface, &src_rect, surface, &dest_rect); } void window_t::blit(int dx, int dy, window_t *src) { if(!engine) return; if(!src) return; if(!surface) return; if(!src->surface) return; SELECT dx = (dx * xs + 128) >> 8; dy = (dy * ys + 128) >> 8; SDL_Rect src_rect; src_rect.x = 0; src_rect.y = 0; src_rect.w = src->surface->w; src_rect.h = src->surface->h; SDL_Rect dest_rect; dest_rect.x = phys_rect.x + dx; dest_rect.y = phys_rect.y + dy; SDL_BlitSurface(src->surface, &src_rect, surface, &dest_rect); } KoboDeluxe-0.5.1/graphics/sofont.cpp0000666000175000001440000002650710730434145014326 00000000000000#include "logger.h" #include "stdlib.h" #include "sofont.h" #include "string.h" SoFont::SoFont() { picture = NULL; CharPos = NULL; CharOffset = NULL; Spacing = NULL; height = 0; max_i = 0; spacew = 0; cursShift = 0; background = 0; xspace = 1; } SoFont::~SoFont() { if(picture) SDL_FreeSurface(picture); delete[]CharPos; delete[]CharOffset; delete[]Spacing; } namespace SoFontUtilities { Uint32 SoFontGetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y) { Uint8 *bits; Uint32 Bpp; if(!Surface) { log_printf(ELOG, "SoFontGetPixel: No surface!\n"); return 0; } if((X < 0) || (X >= Surface->w)) { log_printf(ELOG, "SoFontGetPixel: X (%d)" " out of range!\n", X); return 0; } Bpp = Surface->format->BytesPerPixel; bits = ((Uint8 *) Surface->pixels) + Y * Surface->pitch + X * Bpp; switch (Bpp) { case 1: return *((Uint8 *) Surface->pixels + Y * Surface->pitch + X); break; case 2: return *((Uint16 *) Surface->pixels + Y * Surface->pitch / 2 + X); break; case 3: // Format/endian independent Uint8 r, g, b; r = *((bits) + Surface->format->Rshift / 8); g = *((bits) + Surface->format->Gshift / 8); b = *((bits) + Surface->format->Bshift / 8); return SDL_MapRGB(Surface->format, r, g, b); break; case 4: return *((Uint32 *) Surface->pixels + Y * Surface->pitch / 4 + X); break; } log_printf(ELOG, "SoFontGetPixel: Unsupported pixel format!\n"); return 0; // David (to get rid of warning) } void SoFontSetPixel(SDL_Surface * Surface, Sint32 X, Sint32 Y, Uint32 c) { Uint8 *bits; Uint32 Bpp; if(!Surface) { log_printf(ELOG, "SoFontSetPixel: No surface!\n"); return; } if((X < 0) || (X >= Surface->w)) { log_printf(ELOG, "SoFontSetPixel: X (%d)" " out of range!\n", X); return; } Bpp = Surface->format->BytesPerPixel; bits = ((Uint8 *) Surface->pixels) + Y * Surface->pitch + X * Bpp; switch (Bpp) { case 1: *((Uint8 *) Surface->pixels + Y * Surface->pitch + X) = (Uint8) c; break; case 2: *((Uint16 *) Surface->pixels + Y * Surface->pitch / 2 + X) = (Uint16) c; break; case 3: // Format/endian independent Uint8 r, g, b; SDL_GetRGB(c, Surface->format, &r, &g, &b); *((bits) + Surface->format->Rshift / 8) = r; *((bits) + Surface->format->Gshift / 8) = g; *((bits) + Surface->format->Bshift / 8) = b; break; case 4: *((Uint32 *) Surface->pixels + Y * Surface->pitch / 4 + X) = c; break; } } void clipx(SDL_Rect * srcrect, SDL_Rect * dstrect, SDL_Rect * clip) { // Use if destination have the same size than source. int dx = clip->x - dstrect->x; int sw = srcrect->w; // Because SDL_Rect.w are // unsigned. int dw = dstrect->w; if(dx > 0) { srcrect->x += dx; dstrect->x += dx; sw -= dx; dw -= dx; } int dwx = (dstrect->x + dstrect->w) - (clip->x + clip->w); if(dwx > 0) { sw -= dwx; dw -= dwx; } if(sw > 0) srcrect->w = sw; else srcrect->w = 0; if(dw > 0) dstrect->w = dw; else dstrect->w = 0; } void sdcRects(SDL_Rect * source, SDL_Rect * destination, SDL_Rect clipping) { // Use if destination have the same size than source & // cliping on destination int dx = clipping.x - destination->x; int dy = clipping.y - destination->y; int sw = source->w; int sh = source->h; if(dx > 0) { source->x += dx; destination->x += dx; sw -= dx; destination->w -= dx; } if(dy > 0) { source->y += dy; destination->y += dy; sh -= dy; destination->h -= dy; } int dwx = (destination->x + destination->w) - (clipping.x + clipping.w); int dhy = (destination->y + destination->h) - (clipping.y + clipping.h); if(dwx > 0) { sw -= dwx; destination->w -= dwx; } if(dhy > 0) { sh -= dhy; destination->h -= dhy; } if(sw > 0) source->w = sw; else source->w = 0; if(sh > 0) source->h = sh; else source->h = 0; } } using namespace SoFontUtilities; bool SoFont::DoStartNewChar(Sint32 x) { if(!picture) return false; return SoFontGetPixel(picture, x, 0) == SDL_MapRGB(picture->format, 255, 0, 255); } void SoFont::CleanSurface() { if(!picture) return; int x = 0, y = 0; Uint32 pix = SDL_MapRGB(picture->format, 255, 0, 255); while(x < picture->w) { y = 0; if(SoFontGetPixel(picture, x, y) == pix) SoFontSetPixel(picture, x, y, background); x++; } } bool SoFont::load(SDL_Surface * FontSurface) { int x = 0, i = 0, s = 0; int _CharPos[256]; int _CharOffset[256]; int _Spacing[256]; if(!FontSurface) { log_printf(ELOG, "SoFont recieved a NULL SDL_Surface\n"); return false; } if(picture) SDL_FreeSurface(picture); picture = FontSurface; height = picture->h - 1; while(x < picture->w) { if(DoStartNewChar(x)) { if(i) _Spacing[i - 1] = x - s + xspace; int p = x; while((x < picture->w) && (DoStartNewChar(x))) x++; s = x; _CharPos[i] = (x + p + 1) / 2; _CharOffset[i] = x - _CharPos[i]; i++; } x++; } //Note that spacing is not needed for the last char, //as it's just used for the blit width calculation. if(i) _Spacing[i - 1] = x - s; _Spacing[i] = 0; _CharOffset[i] = 0; _CharPos[i++] = picture->w; max_i = START_CHAR + i - 1; background = SoFontGetPixel(picture, 0, height); // FIXME: Use this when there is no alpha channel? // SDL_SetColorKey(picture, SDL_SRCCOLORKEY, background); CleanSurface(); delete[]CharPos; delete[]CharOffset; delete[]Spacing; CharPos = new int[i]; CharOffset = new int[i]; Spacing = new int[i]; memcpy(CharPos, _CharPos, i * sizeof(int)); memcpy(CharOffset, _CharOffset, i * sizeof(int)); memcpy(Spacing, _Spacing, i * sizeof(int)); // We search for a smart space width: // Changed from "a", "A", "0" for Kobo Deluxe. // Spaces were *way* to wide! //David spacew = 0; if(!spacew) spacew = TextWidth("i") * 3 / 2; if(!spacew) spacew = TextWidth("I") * 3 / 2; if(!spacew) spacew = TextWidth(".") * 3 / 2; if(!spacew) spacew = CharPos[1] - CharPos[0]; // We search for a smart cursor position: int cursBegin = 0; int cursWidth = 0; cursShift = 0; if('|' > max_i) return true; //No bar in this font! if(background == SoFontGetPixel(picture, CharPos['|' - START_CHAR], height / 2)) { // Up to the first | color for(cursBegin = 0; cursBegin <= TextWidth("|"); cursBegin++) if(background != SoFontGetPixel(picture, CharPos['|' - START_CHAR] + cursBegin, height / 2)) break; // Up to the end of the | color for(cursWidth = 0; cursWidth <= TextWidth("|"); cursWidth++) if(background == SoFontGetPixel(picture, CharPos['|' - START_CHAR] + cursBegin + cursWidth, height / 2)) break; } else { // Up to the end of the | color for(cursWidth = 0; cursWidth <= TextWidth("|"); cursWidth++) if(background == SoFontGetPixel(picture, CharPos['|' - START_CHAR] + cursWidth, height / 2)) break; } cursShift = cursBegin + 1; // cursWidth could be used if // image format changes. return true; } void SoFont::PutString(SDL_Surface *Surface, int x, int y, const char *text, SDL_Rect *clip) { if((!picture) || (!Surface) || (!text)) return; int ofs, i = 0; SDL_Rect srcrect, dstrect; while(text[i] != '\0') { if(text[i] == ' ') { x += spacew; i++; } else if((text[i] >= START_CHAR) && (text[i] <= max_i)) { ofs = text[i] - START_CHAR; srcrect.w = dstrect.w = this->CharPos[ofs + 1] - this->CharPos[ofs]; srcrect.h = dstrect.h = height; srcrect.x = this->CharPos[ofs]; srcrect.y = 1; dstrect.x = x - CharOffset[ofs]; dstrect.y = y; x += Spacing[ofs]; if(clip) sdcRects(&srcrect, &dstrect, *clip); SDL_BlitSurface(picture, &srcrect, Surface, &dstrect); i++; } else i++; // other chars are ignored // Coarse clipping if(clip) { if(x > clip->x + clip->w) return; } else { if(x > Surface->w) return; } } } void SoFont::PutStringWithCursor(SDL_Surface * Surface, int xs, int y, const char *text, int cursPos, SDL_Rect * clip, bool showCurs) { if((!picture) || (!Surface) || (!text)) return; if('|' > max_i) showCurs = false; int ofs, i = 0, x = xs; SDL_Rect srcrect, dstrect; // We want the cursor to appear under the main text. if(showCurs) { while(text[i] != '\0') if(i == cursPos) break; else if(text[i] == ' ') { x += spacew; i++; } else if((text[i] >= START_CHAR) && (text[i] <= max_i)) { ofs = text[i] - START_CHAR; x += Spacing[ofs]; i++; } else i++; ofs = '|' - START_CHAR; srcrect.w = dstrect.w = CharPos[ofs + 1] - CharPos[ofs]; srcrect.h = dstrect.h = height; srcrect.x = this->CharPos[ofs]; srcrect.y = 1; dstrect.x = x - cursShift; dstrect.y = y; if(clip) sdcRects(&srcrect, &dstrect, *clip); SDL_BlitSurface(picture, &srcrect, Surface, &dstrect); } // Then the text: PutString(Surface, xs, y, text, clip); } int SoFont::TextWidth(const char *text, int min, int max) { if(!picture) return 0; int ofs, x = 0, i = min; while((text[i] != '\0') && (i < max)) { if(text[i] == ' ') { x += spacew; i++; } else if((text[i] >= START_CHAR) && (text[i] <= max_i)) { ofs = text[i] - START_CHAR; x += Spacing[ofs]; i++; } else i++; } return x; } void SoFont::XCenteredString(SDL_Surface * Surface, int y, const char *text, SDL_Rect * clip) { if(!picture) return; PutString(Surface, Surface->w / 2 - TextWidth(text) / 2, y, text, clip); } void SoFont::CenteredString(SDL_Surface * Surface, int x, int y, const char *text, SDL_Rect * clip) { if(!picture) return; PutString(Surface, x - TextWidth(text) / 2, y - height / 2, text, clip); } void SoFont::CenteredString(SDL_Surface * Surface, const char *text, SDL_Rect * clip) { if(!picture) return; CenteredString(Surface, Surface->clip_rect.w / 2, Surface->clip_rect.h / 2, text, clip); } void SoFont::PutStringCleverCursor(SDL_Surface * Surface, const char *text, int cursPos, SDL_Rect * r, SDL_Rect * clip, bool showCurs) { if((!picture) || (!text)) return; int w1, w2; w1 = TextWidth(text, 0, cursPos); w2 = TextWidth(text); if((w2 < r->w) || (w1 < r->w / 2)) PutStringWithCursor(Surface, r->x, r->y + (r->h - height) / 2, text, cursPos, clip, showCurs); else if(w1 < w2 - r->w / 2) PutStringWithCursor(Surface, r->x - w1 + r->w / 2, r->y + (r->h - height) / 2, text, cursPos, clip, showCurs); else PutStringWithCursor(Surface, r->x - w2 + r->w, r->y + (r->h - height) / 2, text, cursPos, clip, showCurs); } int SoFont::TextCursorAt(const char *text, int px) { if(!picture) return 0; int ofs, x = 0, i = 0, ax = 0; if(px <= 0) return 0; while(text[i] != '\0') { if(text[i] == ' ') { x += spacew; i++; } else if((text[i] >= START_CHAR) && (text[i] <= max_i)) { ofs = text[i] - START_CHAR; x += Spacing[ofs]; i++; } else i++; if(px < (ax + x) / 2) return (i - 1); ax = x; } return i; } int SoFont::CleverTextCursorAt(const char *text, int px, int cursPos, SDL_Rect * r) { if((!picture) || (!text)) return 0; int w1, w2; w1 = TextWidth(text, 0, cursPos); w2 = TextWidth(text); if((w2 < r->w) || (w1 < r->w / 2)) return TextCursorAt(text, px); else if(w1 < w2 - r->w / 2) return TextCursorAt(text, px + w1 - (r->w / 2)); else return TextCursorAt(text, px + w2 - r->w); } KoboDeluxe-0.5.1/graphics/display.cpp0000666000175000001440000000242110730431150014441 00000000000000/*(LGPL) * Simple display for score, lives etc. * © David Olofson, 2001-2003, 2007 */ #define D_LINE_HEIGHT 9 #define D_LINE1_POS 1 #define D_LINE1_TXOFFS 0 #define D_LINE2_POS 9 #define D_LINE2_TXOFFS 0 #include #include "window.h" #include "display.h" display_t::display_t() { _on = 0; caption("CAPTION"); text("TEXT"); on(); } void display_t::color(Uint32 _cl) { _color = _cl; if(_on) invalidate(); } void display_t::caption(const char *cap) { strncpy(_caption, cap, sizeof(_caption)); if(_on) invalidate(); } void display_t::text(const char *txt) { strncpy(_text, txt, sizeof(_text)); if(_on) invalidate(); } void display_t::on() { if(_on) return; _on = 1; invalidate(); } void display_t::off() { if(!_on) return; _on = 0; invalidate(); } void display_t::render_caption() { SDL_Rect r; r.x = 0; r.y = D_LINE1_POS; r.w = width(); r.h = D_LINE_HEIGHT; background(_color); clear(&r); if(_on) center(D_LINE1_POS + D_LINE1_TXOFFS, _caption); } void display_t::render_text() { SDL_Rect r; r.x = 0; r.y = D_LINE2_POS; r.w = width(); r.h = D_LINE_HEIGHT; background(_color); clear(&r); if(_on) center(D_LINE2_POS + D_LINE2_TXOFFS, _text); } void display_t::refresh(SDL_Rect *r) { render_caption(); render_text(); } KoboDeluxe-0.5.1/graphics/toolkit.cpp0000666000175000001440000002747110702725760014511 00000000000000/*(LGPL) --------------------------------------------------------------------------- toolkit.cpp - Simple "GUI" toolkit for config screens. --------------------------------------------------------------------------- * Copyright (C) 2001 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include #include #include "window.h" #include "toolkit.h" /*---------------------------------------------------------- ct_widget_t:: ----------------------------------------------------------*/ ct_widget_t::ct_widget_t() { interactive = 0; transparent = 1; highlighted = 0; user = NULL; user2 = 0; tag = 0; _color = 0; next = prev = NULL; _widget_index = -1; halign(ALIGN_DEFAULT); valign(ALIGN_DEFAULT); _token = 0; xo = yo = 0.0; } void ct_widget_t::halign(ct_align_t ha) { if(ALIGN_DEFAULT == ha) _halign = ALIGN_RIGHT; else _halign = ha; } void ct_widget_t::valign(ct_align_t va) { if(ALIGN_DEFAULT == va) _valign = ALIGN_TOP; else _valign = va; } void ct_widget_t::init(gfxengine_t *e) { window_t::init(e); _color = map_rgb(0,0,0); } void ct_widget_t::transparency(int t) { if(t == transparent) return; transparent = t; if(!transparent) render(); } void ct_widget_t::highlight(int hl) { if(hl == highlighted) return; highlighted = hl; if(!transparent) render(); } void ct_widget_t::color(Uint32 _cl) { if(_cl == _color) return; _color = _cl; if(!transparent) render(); } void ct_widget_t::render() { if(!transparent) { foreground(_color); fillrect(0, 0, width(), height()); } if(highlighted) ct_engine.render_highlight(this); } /* Handy tool function used by some descendents. */ void ct_widget_t::render_text_aligned(const char *buf) { int yy = 0; switch(_valign) { case ALIGN_DEFAULT: //dummy case ALIGN_NONE: case ALIGN_TOP: yy = yoffs(); break; case ALIGN_BOTTOM: yy = height() - fontheight() - yoffs(); break; case ALIGN_CENTER: case ALIGN_CENTER_TOKEN: yy = (height() - fontheight()) / 2 + yoffs(); break; } switch(_halign) { case ALIGN_DEFAULT: //dummy case ALIGN_NONE: case ALIGN_LEFT: string(xoffs(), yy, buf); break; case ALIGN_RIGHT: center_token(width() - xoffs(), yy, buf); break; case ALIGN_CENTER: center_token(xoffs(), yy, buf, -1); break; case ALIGN_CENTER_TOKEN: center_token(xoffs(), yy, buf, _token); break; } } void ct_widget_t::change(int delta) { _value += delta; } void ct_widget_t::value(int val) { _value = val; } int ct_widget_t::value() { return _value; } /*---------------------------------------------------------- ct_engine_t:: ----------------------------------------------------------*/ void default_render_highlight(ct_widget_t *wg) { Uint32 hlc[6]; hlc[0] = wg->map_rgb(0x440000); hlc[1] = wg->map_rgb(0x660000); hlc[2] = wg->map_rgb(0x880000); hlc[3] = wg->map_rgb(0x990000); hlc[4] = wg->map_rgb(0xaa0000); hlc[5] = wg->map_rgb(0xbb0000); wg->foreground(hlc[5]); wg->fillrect(0, 6, wg->width(), wg->height()-6-1); for(int i = 0; i < 6; ++i) { wg->foreground(hlc[i]); wg->fillrect(0, i, wg->width(), 1); wg->fillrect(0, wg->height()-1-i, wg->width(), 1); } } ct_engine_t::ct_engine_t() { ct_engine.render_highlight = default_render_highlight; } ct_engine_t ct_engine; /*---------------------------------------------------------- ct_label_t:: ----------------------------------------------------------*/ ct_label_t::ct_label_t(const char *cap) { xo = 0.5; if(cap) caption(cap); else caption("Label"); } void ct_label_t::halign(ct_align_t ha) { if(ALIGN_DEFAULT == ha) _halign = ALIGN_CENTER; else _halign = ha; } void ct_label_t::caption(const char *cap) { strncpy(_caption, cap, sizeof(_caption)); _caption[sizeof(_caption)-1] = 0; if(!transparent) render(); } void ct_label_t::render() { ct_widget_t::render(); render_text_aligned(_caption); } /*---------------------------------------------------------- ct_item_t:: ----------------------------------------------------------*/ ct_item_t::ct_item_t(const char *cap, int val) { if(cap) caption(cap); else caption("Item"); _value = val; } void ct_item_t::caption(const char *cap) { strncpy(_caption, cap, sizeof(_caption)); _caption[sizeof(_caption)-1] = 0; } static ct_item_t dummy_item("", -1); /*---------------------------------------------------------- ct_list_t:: ----------------------------------------------------------*/ ct_list_t::ct_list_t(const char *cap) : ct_label_t(cap) { interactive = 1; if(cap) caption(cap); else caption("List"); items = NULL; _selected = NULL; _token = ':'; xo = 0.55; } ct_list_t::~ct_list_t() { clean(); } void ct_list_t::halign(ct_align_t ha) { if(ALIGN_DEFAULT == ha) _halign = ALIGN_CENTER_TOKEN; else _halign = ha; } void ct_list_t::clean() { if(!items) return; /* * Break the circular list first, or we'll * blow up the memory manager...! :-) */ items->prev->next = NULL; while(items) { ct_item_t *i = items; items = i->next; delete i; } items = NULL; _selected = NULL; } void ct_list_t::add(ct_item_t *item) { if(items) { item->next = items; item->prev = items->prev; items->prev->next = item; items->prev = item; } else { item->next = item->prev = item; items = item; _selected = item; if(!transparent) render(); } } void ct_list_t::add(const char *cap, int val) { ct_item_t *it = new ct_item_t(cap, val); add(it); } void ct_list_t::select(ct_item_t *item) { _selected = item; #if 0 ct_item_t *i = items; if(i) for(int n = 0; n < 10000; ++n) //Just in case... { if(i == _selected) { _value = n; break; } i = i->next; } #endif if(_selected) _value = _selected->value(); if(!transparent) render(); } void ct_list_t::select(int ind) { if(!items) return; _selected = items; for(int i = 0; i < ind; ++i) _selected = _selected->next; select(_selected); //To update _value, render etc... } ct_item_t *ct_list_t::selected() { if(!items) return &dummy_item; return _selected; } void ct_list_t::value(int val) { if(!items) return; ct_item_t *best = items; _selected = items; while(_selected->value() != val) { if(labs(_selected->value()-val) < labs(best->value()-val)) best = _selected; if(_selected->next == items) break; _selected = _selected->next; } if(_selected->value() != val) _selected = best; select(_selected); //To update _value, render etc... } int ct_list_t::value() { if(!items) return dummy_item.value(); if(_selected) return _selected->value(); else return dummy_item.value(); } void ct_list_t::change(int delta) { if(_selected) { if(0 == delta) delta = 1; if(delta > 0) for(int i = 0; i < delta; ++i) _selected = _selected->next; else if(delta < 0) for(int i = 0; i > delta; --i) _selected = _selected->prev; select(_selected); //To update _value, render etc... } ct_widget_t::change(delta); } void ct_list_t::render() { char buf[128]; const char *ic; if(_selected) ic = _selected->caption(); else ic = dummy_item.caption(); ct_widget_t::render(); snprintf(buf, sizeof(buf), "%s: %s", caption(), ic); //center(0, buf); //center_token(width()*3/5, 0, buf, ':'); render_text_aligned(buf); } /*---------------------------------------------------------- ct_spin_t:: ----------------------------------------------------------*/ ct_spin_t::ct_spin_t(const char *cap, int _min, int _max, const char *__unit) : ct_label_t(cap) { interactive = 1; min = _min; max = _max; _token = ':'; xo = 0.55; if(__unit) unit(__unit); else unit(""); } void ct_spin_t::unit(const char *txt) { strncpy(_unit, txt, sizeof(_unit)); _unit[sizeof(_unit)-1] = 0; if(!transparent) render(); } void ct_spin_t::value(int val) { val -= min; while(val < 0) val += max - min + 1; val %= max - min + 1; val += min; ct_label_t::value(val); } void ct_spin_t::change(int delta) { value(_value + delta); } void ct_spin_t::render() { char buf[128]; ct_widget_t::render(); snprintf(buf, sizeof(buf), "%s: %d %s", caption(), _value, unit()); //center(0, buf); //center_token(width()*3/5, 0, buf, ':'); render_text_aligned(buf); } /*---------------------------------------------------------- ct_button_t:: ----------------------------------------------------------*/ ct_button_t::ct_button_t(const char *cap) : ct_label_t(cap) { interactive = 1; } void ct_button_t::render() { ct_label_t::render(); } void ct_button_t::change(int delta) { ct_label_t::change(delta); if(!transparent) render(); } /*---------------------------------------------------------- ct_form_t:: ----------------------------------------------------------*/ ct_form_t::ct_form_t() { widgets = NULL; _selected = NULL; } ct_form_t::~ct_form_t() { if(!widgets) return; /* * Break the circular list first, or we'll * blow up the memory manager...! :-) */ widgets->prev->next = NULL; while(widgets) { ct_widget_t *i = widgets; widgets = i->next; delete i; } } void ct_form_t::add(ct_widget_t *widget) { if(widgets) { widget->next = widgets; widget->prev = widgets->prev; widgets->prev->next = widget; widgets->prev = widget; widget->_widget_index = widget->prev->_widget_index + 1; if(!_selected->interactive) select(widget); } else { widget->_widget_index = 0; widget->next = widget->prev = widget; widgets = widget; select(widget); } render_nontransparent(); } void ct_form_t::clean() { if(!widgets) return; /* * Break the circular list first, or we'll * blow up the memory manager...! :-) */ widgets->prev->next = NULL; while(widgets) { ct_widget_t *w = widgets; widgets = w->next; delete w; } widgets = NULL; _selected = NULL; } void ct_form_t::select(ct_widget_t *widget) { if(_selected) _selected->highlight(0); _selected = widget; if(_selected) { _selected->highlight(1); if(!_selected->transparent) _selected->render(); } } void ct_form_t::select(int ind) { if(!widgets) return; if(!widgets) return; ct_widget_t *sel = widgets; for(int i = 0; i < ind; ++i) sel = sel->next; int lim = 10000; while(!sel->interactive) { if(!lim--) break; sel = sel->next; } select(sel); } void ct_form_t::next() { if(!widgets) return; if(!_selected) { select(0); return; } ct_widget_t *sel = _selected->next; int lim = 1000; while(!sel->interactive) { if(!lim--) break; sel = sel->next; } select(sel); } void ct_form_t::prev() { if(!widgets) return; if(!_selected) { select(0); return; } ct_widget_t *sel = _selected->prev; int lim = 1000; while(!sel->interactive) { if(!lim--) break; sel = sel->prev; } select(sel); } ct_widget_t *ct_form_t::selected() { return _selected; } int ct_form_t::selected_index() { if(_selected) return _selected->_widget_index; else return -1; } void ct_form_t::change(int delta) { if(_selected) _selected->change(delta); } void ct_form_t::render() { ct_widget_t *w = widgets; while(w) { w->render(); w = w->next; if(w == widgets) break; //Done! } } void ct_form_t::render_nontransparent() { ct_widget_t *w = widgets; while(w) { if(!w->transparent) w->render(); w = w->next; if(w == widgets) break; //Done! } } KoboDeluxe-0.5.1/graphics/vidmodes.c0000644000175000001440000001221610711215306014247 00000000000000/*(LGPL) --------------------------------------------------------------------------- vidmodes.c - Video Mode Manager for Kobo Deluxe --------------------------------------------------------------------------- * Copyright (C) 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "vidmodes.h" #include #include typedef struct VMM_IMode { int flags, width, height, id; const char *name; } VMM_IMode; static VMM_IMode modetab[] = { // 4:3 modes {VMM_4_3 | VMM_PC, 320, 200, 0x04300, "CGA"}, {VMM_4_3 | VMM_PC, 320, 240, 0x04301, "QVGA"}, {VMM_4_3, 320, 256, 0x04302, "Amiga LoRes"}, {VMM_4_3 | VMM_LORES, 400, 300, 0x04310, NULL}, {VMM_4_3 | VMM_LORES, 512, 384, 0x04320, NULL}, {VMM_4_3 | VMM_PC, 640, 480, 0x04330, "VGA"}, {VMM_4_3, 640, 512, 0x04331, "Amiga HiRes"}, {VMM_4_3 | VMM_TV, 768, 576, 0x04340, "PAL"}, {VMM_4_3 | VMM_PC, 800, 600, 0x04350, NULL}, {VMM_4_3 | VMM_LORES, 960, 720, 0x04360, NULL}, {VMM_4_3 | VMM_PC, 1024, 768, 0x04370, "XGA"}, {VMM_4_3 | VMM_PC, 1152, 864, 0x04380, NULL}, {VMM_4_3 | VMM_PC, 1280, 960, 0x04390, NULL}, {VMM_4_3 | VMM_PC, 1400, 1050, 0x043a0, "SXGA+"}, {VMM_4_3 | VMM_PC, 1600, 1200, 0x043b0, "UXGA"}, {VMM_4_3 | VMM_PC, 1920, 1440, 0x043c0, NULL}, {VMM_4_3 | VMM_PC, 2048, 1536, 0x043d0, "QXGA"}, // 3:2 modes {VMM_3_2 | VMM_LORES, 360, 240, 0x03200, NULL}, {VMM_3_2 | VMM_LORES, 720, 480, 0x03240, "NTSC"}, {VMM_3_2, 1152, 768, 0x03280, NULL}, {VMM_3_2, 1280, 854, 0x03290, NULL}, {VMM_3_2, 1440, 960, 0x032a0, NULL}, // 5:4 modes {VMM_5_4 | VMM_LORES, 320, 256, 0x05400, "Amiga LoRes"}, {VMM_5_4 | VMM_LORES, 640, 512, 0x05430, "Amiga HiRes"}, {VMM_5_4 | VMM_PC, 1280, 1024, 0x05490, "SXGA"}, {VMM_5_4, 2560, 2048, 0x054e0, "QSXGA"}, // 16:10 modes {VMM_16_10 | VMM_LORES, 320, 200, 0x10a00, NULL}, {VMM_16_10 | VMM_PC, 640, 400, 0x10a30, NULL}, {VMM_16_10 | VMM_LORES, 840, 525, 0x10a50, NULL}, {VMM_16_10 | VMM_PC, 1280, 800, 0x10a90, NULL}, {VMM_16_10 | VMM_PC, 1680, 1050, 0x10ab0, "WSXGA+"}, {VMM_16_10 | VMM_PC, 1920, 1200, 0x10ac0, "WUXGA"}, {VMM_16_10 | VMM_PC, 2560, 1600, 0x10ae0, "WQXGA"}, // 16:9 modes {VMM_16_9 | VMM_LORES, 480, 270, 0x10910, NULL}, {VMM_16_9 | VMM_LORES, 678, 384, 0x10930, NULL}, {VMM_16_9 | VMM_TV, 854, 480, 0x10950, "WVGA"}, {VMM_16_9 | VMM_LORES, 960, 540, 0x10960, NULL}, {VMM_16_9, 1280, 720, 0x10990, "HD 720"}, {VMM_16_9 | VMM_TV, 1356, 768, 0x109a0, "Flat TV"}, {VMM_16_9 | VMM_TV, 1920, 1080, 0x109c0, "HD 1080"}, {VMM_16_9, 2560, 1440, 0x109e0, NULL}, // End of table {0, 0, 0} }; /*------------------------------------------------------------------------- Gathering and constructing modes -------------------------------------------------------------------------*/ static VMM_Mode *vmm_modes = NULL; int vmm_Init(int show, int hide) { int i; VMM_Mode *lastm = NULL; vmm_Close(); /* TODO: Include detected SDL modes, if requested. */ for(i = 0; modetab[i].width; ++i) { VMM_Mode *m; double nominal_aspect; VMM_IMode *im = &modetab[i]; if(im->flags & hide) continue; if(!(im->flags & show)) continue; m = calloc(1, sizeof(VMM_Mode)); if(!m) return -1; /* Out of memory! */ m->id = im->id; m->width = im->width; m->height = im->height; m->flags = im->flags; if(im->flags & VMM_3_2) nominal_aspect = 3.0f / 2.0f; else if(im->flags & VMM_5_4) nominal_aspect = 5.0f / 4.0f; else if(im->flags & VMM_16_10) nominal_aspect = 16.0f / 10.0f; else if(im->flags & VMM_16_9) nominal_aspect = 16.0f / 9.0f; else nominal_aspect = 4.0f / 3.0f; if(im->width) m->aspect = nominal_aspect / im->width * im->height; else m->aspect = 1.0f; if(im->name) m->name = strdup(im->name); if(lastm) lastm->next = m; else vmm_modes = m; lastm = m; } return 0; } void vmm_Close(void) { VMM_Mode *m = vmm_First(); while(m) { VMM_Mode *dm = m; m = vmm_Next(m); free(dm->name); free(dm); } vmm_modes = NULL; } /*------------------------------------------------------------------------- Scanning -------------------------------------------------------------------------*/ VMM_Mode *vmm_First(void) { return vmm_modes; } VMM_Mode *vmm_Next(VMM_Mode *current) { return current->next; } /*------------------------------------------------------------------------- Indexing -------------------------------------------------------------------------*/ VMM_Mode *vmm_FindMode(int id) { VMM_Mode *m = vmm_First(); while(m) { if(m->id == id) return m; m = vmm_Next(m); } return NULL; } KoboDeluxe-0.5.1/graphics/region.c0000644000175000001440000001027610710754050013727 00000000000000/*(LGPL) ---------------------------------------------------------------------- region.c - Graphics Engine ---------------------------------------------------------------------- * Copyright (C) 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "region.h" #include static struct { RGN_region *region; int x, y; SDL_Surface *target; } s; static Uint32 gp1(SDL_Surface *surface, int x, int y) { return *((Uint8 *)surface->pixels + y * surface->pitch + x); } static Uint32 gp2(SDL_Surface *surface, int x, int y) { return *((Uint16 *)surface->pixels + y * surface->pitch / 2 + x); } static Uint32 gp3(SDL_Surface *surface, int x, int y) { int bpp = surface->format->BytesPerPixel; Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * bpp; #if (SDL_BYTEORDER == SDL_BIG_ENDIAN) return p[0] << 16 | p[1] << 8 | p[2]; #else return p[0] | p[1] << 8 | p[2] << 16; #endif } static Uint32 gp4(SDL_Surface *surface, int x, int y) { return *((Uint32 *)surface->pixels + y * surface->pitch / 4 + x); } RGN_region *RGN_ScanMask(SDL_Surface *src, Uint32 key) { RGN_region *rgn = (RGN_region *)calloc(1, sizeof(RGN_region)); Uint32 (*gp)(SDL_Surface *surface, int x, int y); int x, y; if(!rgn) return NULL; rgn->rows = src->h; rgn->spans = (Uint16 **)calloc(1, sizeof(Uint16 *) * src->h); if(!rgn->spans) { RGN_FreeRegion(rgn); return NULL; } switch(src->format->BytesPerPixel) { case 1: gp = gp1; break; case 2: gp = gp2; break; case 3: gp = gp3; break; case 4: gp = gp4; break; default: RGN_FreeRegion(rgn); return NULL; } SDL_LockSurface(src); for(y = 0; y < src->h; ++y) { int i = 0; int drawing = 0; Uint16 *sp = (Uint16 *)malloc(sizeof(Uint16) * 2 * (src->w + 1)); if(!sp) { SDL_UnlockSurface(src); RGN_FreeRegion(rgn); return NULL; } for(x = 0; x < src->w; ++x) { int nd = (gp(src, x, y) == key); if(nd != drawing) { sp[i++] = x; drawing = nd; } } if(drawing) sp[i++] = src->w; sp[i++] = 0; sp[i++] = 0; rgn->spans[y] = (Uint16 *)realloc(sp, sizeof(Uint16) * i); if(!rgn->spans[y]) rgn->spans[y] = sp; } SDL_UnlockSurface(src); return rgn; } void RGN_FreeRegion(RGN_region *rgn) { if(!rgn) return; if(rgn->spans) { int i; for(i = rgn->rows - 1; i >= 0; --i) free(rgn->spans[i]); free(rgn->spans); } free(rgn); } void RGN_Target(SDL_Surface *tgt) { s.target = tgt; } void RGN_SetRegion(RGN_region *rgn, int xpos, int ypos) { s.region = rgn; s.x = xpos; s.y = ypos; } int RGN_Blit(SDL_Surface *src, SDL_Rect *sr, int x, int y) { // FIXME: Clipping is only half done here... int yy0, yy, yy1; int sxmin, sxmax, symin, symax; SDL_Rect sr2; if(!s.region) { SDL_Rect dr; dr.x = x; dr.y = y; return SDL_BlitSurface(src, sr, s.target, &dr); } if(sr) { sxmin = sr->x; symin = sr->y; sxmax = sxmin + sr->w; symax = symin + sr->h; } else { sxmin = 0; symin = 0; sxmax = src->w; symax = src->h; } yy0 = s.y; if(yy0 >= y + (symax - symin)) return 0; if(yy0 < y) yy0 = y; yy1 = s.y + s.region->rows; if(y >= yy1) return 0; if(yy1 > y + (symax - symin)) yy1 = y + (symax - symin); sr2.h = 1; for(yy = yy0; yy < yy1; ++yy) { SDL_Rect dr; Uint16 *spans = s.region->spans[yy - s.y]; sr2.y = symin + y - yy0; dr.y = yy; for( ; spans[0] && spans[1] ; spans += 2) { int x0 = s.x + spans[0]; int x1 = s.x + spans[1]; dr.x = x0; sr2.x = sxmin + x0 - x; sr2.w = x1 - x0; SDL_BlitSurface(src, &sr2, s.target, &dr); } } return 0; } KoboDeluxe-0.5.1/graphics/cs.h0000666000175000001440000003175410730442057013071 00000000000000/*(LGPL) * Project Spitfire sprites + scrolling engine for SDL ---------------------------------------------------------------------- cs.h - Simplistic Control System ---------------------------------------------------------------------- * Copyright (C) 2001, 2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * Note on coordinates: * Normally, cs assumes that the world continues * indefinitely in every direction. (Actually, * it wraps at 4 Gpixel intervals... :-) * * However, by calling cs_engine_set_wrap(x, y), * it's possible to make the engine wrap * automatically, to nicely support old style * endless scrolling games. The movement system * will automatically wrap around edges, and * most importantly, *interpolation* will work * correctly in conjunction with wrapping. This * applies to all points in the system, user * points included. * * Note that cs doesn't have an internal notion * of layers when it comes to wrapping, which * means that it's not trivial to implement * wrapping for parallax scrolling correctly. * All parallax layers have to be of the same * size, as cs cannot tell which points belong * to which layer when performing the internal * calculations. * * Call cs_engine_set_wrap(0, 0); to disable * wrapping. Wrapping can be set or disabled * individually for each axis. * * Note on graphics coordinates: * Graphics coordinates don't always wrap at the * same time as their corresponding object * coordinates! This is because the engine must * consider the view rectangle and the bounding * rectangles of objects, and adjust the wrapping * so that all objects that should be visible * are. * * Note on wrapping (with wrapping enabled only): * When a layer is scrolled so that it's limits * end up inside the display window, the engine * automatically makes objects wrap around from * the far edge, so that continuous looping is * possible. * However, note that this breaks if objects can * be seen at more than one edge at a time! That * is, (wrap size - display size) must be bigger * than the size of the largest object. * * TODO: * * Scrap the animation system and throw * something nicer in. A primitive VM based * "scripting" system with * commands and switches based on speed, * direction, state etc would be incredibly * powerful, and still not too complicated. * * * Implement collision detection. There should * be flags to enable/disable it on per-layer * as well as per-object basis. * * * Group all per-layer stuff into a struct, * and then use an array of structs. * * * Split each layer into two lists; one for * visible objects and one for hidden objects, * so they can be handled more efficiently. * (Hidden objects are skipped one by one in * the render loop now, for example - it will * become worse over time, I think.) * * * Implement some sort of zone based collision * detection engine that scales better than * "check everything against everything". */ /* * * BUGS: * * There is a restriction on object movement * speed in a wrapping world: No object must * move more than half of the extent of the * world on either axis in one engine cycle. * STATUS: Who cares? * * * Objects that are not free or active (they * do *not* have to be visible!) are "missing * in action" as far as the engine is concerned. * It won't find them unless you free them, * or make them visible. * STATUS: Can and should be fixed. */ #ifndef _CS_H_ #define _CS_H_ #ifdef __cplusplus extern "C" { #endif #include #define __CS_SHIFT 8 #define CS2PIXEL(x) ( (x) >> __CS_SHIFT ) #define PIXEL2CS(x) ( (x) << __CS_SHIFT ) #define CS_LAYERS 8 #define CS_DEFAULT_LAYER 1 /*0 is normally for overlays*/ #define CS_USER_POINTS 16 /* FIXME: This fixpoint crap should probably be changed to float... FIXME: Would break the "changed" mask bonus feature described FIXME: below, though. */ typedef struct { /* 24:8 fixpoint values */ int x, y; /* logic position */ int xv, yv; int xa, ya; } cs_vector_t; /* * Some handy vector construction macros... * * NOTE: position (x,y) in integer format, not fixpoint! */ /* Point */ static inline cs_vector_t cs_vector_p(int x, int y) { cs_vector_t v; v.x = PIXEL2CS(x); v.y = PIXEL2CS(y); v.xv = v.yv = v.xa = v.ya = 0; return v; } /* Point + velocity */ static inline cs_vector_t cs_vector_pv(int x, int y, int xv, int yv) { cs_vector_t v; v.x = PIXEL2CS(x); v.y = PIXEL2CS(y); v.xv = xv; v.yv = yv; v.xa = v.ya = 0; return v; } /* Point + velocity + acceleration */ static inline cs_vector_t cs_vector_pva(int x, int y, int xv, int yv, int xa, int ya) { cs_vector_t v; v.x = PIXEL2CS(x); v.y = PIXEL2CS(y); v.xv = xv; v.yv = yv; v.xa = xa; v.ya = ya; return v; } /* * Generic coordinate + speed and acceleration type. Position filtering * support is built-in as well, for smooth animation regardless of * control system / video frame rate ratio. FIXME: Interpolation can break detailed animations involving multiple FIXME: sprites that move and animate (changing images) at the same FIXME: time. Provide a "CS_OBJ_NO_INTERPOLATION" flag? */ typedef struct { /* 24:8 fixpoint values here as well */ cs_vector_t v; int ox, oy; /* last position (for filtering) */ int gx, gy; /* graphic position */ /* (changed != 0) if gx or gy changed during the last update. * This is a bit mask with the same format as the coords, * which means that you can mask some low bits off to set * a coarse movement sensitivity threshold. * Ex. (changed & 0xffffff00) == "gx or gy moved to * another pixel posn." */ int changed; } cs_point_t; /* * Force the interpolation filter of a point to the current * position of the vector. (This is required when activating * new objects.) */ static inline void cs_point_force(cs_point_t *p) { p->ox = p->gx = p->v.x; p->oy = p->gy = p->v.y; } /* * This stuff is translated from Object Pascal to "Object * Oriented Style C" with my new naming conventions... * I don't consider this code needing advanced OO, so I * don't want to drag C++ in. */ struct cs_engine_t; struct cs_obj_t; /* ---------------------------------------------------------------------- * cs_obj_t (used to be object + sprite) ---------------------------------------------------------------------- * * "The Basic Move Object. * * This object reperesents a moving object on the screen. * You just tell it in what direction to go, and the Game Graphics * system will do the job." * * What to do in the callbacks: * collision() Check accurately if two objects really collide. * (The control system will ask when bounding rects * are overlapping and the collision masks indicate * that a collision would affect one or both objects.) */ typedef struct cs_obj_t { struct cs_engine_t *owner; struct cs_obj_t **head; struct cs_obj_t *next, *prev; cs_point_t point; /* Position, speed, acceleration */ int w, h; /* Sprite bounding rect size (pixels) */ int flags; int layer; /* Collision filter (new) */ int group_mask; /* bit set = "belongs to group" */ int hit_mask; /* bit set = "can hit group" */ struct { int bank; /* Image bank */ int frame; /* Image frame */ int fframe; /* First frame (integer) */ int aframes; /* # of frames; from fframe (integer) */ int cframe; /* Current frame; from fframe (28:4 fixp) */ int aspeed; /* Frames / engine cycle (28:4 fixp) */ } anim; struct { cs_vector_t v; /* weapon offset + vel + acc */ int rate; /* frames/shot */ int timer; int ammo; /* bullet type */ } fire; int score; /*Score for destroy*/ int health; /*Health points*/ /* * Event callbacks */ int (*on_hit)(struct cs_obj_t *o); /* Ouch! */ int (*on_dying)(struct cs_obj_t *o); /* Destructing... */ int (*on_fire)(struct cs_obj_t *o); /* BOOM! */ /* * Collision detection callbacks * Called when bounding rect intersection is detected. * Should return 1 if there actually is a collision. */ int (*collision)(struct cs_obj_t *o1, struct cs_obj_t *o2); /* * Rendering callback * NOTE: Use (gx,gy) when rendering, *NOT* (x,y)! */ void (*render)(struct cs_obj_t *o); /* * User destructor; Object is freed after you return. */ int (*on_free)(struct cs_obj_t *o); /* User data */ int tag; /* user ID */ void *user; /* user data */ } cs_obj_t; /* cs_obj_t flags */ /* * True when an object is "in the system"; ie when it's in one of * the sprite lists, as opposed to in the free pool, or unattached. * ("Unattached" is the state an object is in when you've just got * it from cs_engine_get_obj().) */ #define CS_OBJ_ACTIVE 0x00000001 /* * Note that an object with a 0 visible flag is still *active*! It's * coordinates are updated, animation, collisions, spawning/shooting * etc runs - it's just not visible. (Well, whatever is spawned is.) */ #define CS_OBJ_VISIBLE 0x00000002 /* * Set by the collision detection system whenever any part of the * object's bounding rectangle is inside the bounding rectangle * of the screen. */ #define CS_OBJ_ONSCREN 0x00000004 /* * Set whenever the cs animation system is to be used to generate * image frame numbers for this object. */ #define CS_OBJ_DOANIM 0x00000008 /* * Set while the object is marked as dying. Normally, you would * run some animation and perhaps spawn some explosion objects, * and then free the object. */ #define CS_OBJ_DYING 0x00000010 /* Basic methods */ /* * Note: You only really need cs_obj_layer(), cs_obj_show() * and cs_obj_free(). The others are just for more fine * grained life cycle control. */ void cs_obj_layer(cs_obj_t *o, unsigned int layer); void cs_obj_activate(cs_obj_t *o); /* Add to cs */ void cs_obj_show(cs_obj_t *o); /* Enable display */ void cs_obj_hide(cs_obj_t *o); /* Disable display */ void cs_obj_deactivate(cs_obj_t *o); /* Disengage from cs */ void cs_obj_free(cs_obj_t *o); /* Remove and throw back in the pool */ void cs_obj_pos(cs_obj_t *o, int x, int y); /* Set new position */ void cs_obj_vel(cs_obj_t *o, int xs, int ys); /* Set movement speed */ void cs_obj_acc(cs_obj_t *o, int xa, int ya); /* Set movement acceleration */ void cs_obj_vector(cs_obj_t *o, cs_vector_t *v);/* Set all */ void cs_obj_clear(cs_obj_t *o); /* Animation methods */ void cs_obj_image(cs_obj_t *o, int bank, int frame); void cs_obj_anim(cs_obj_t *o, int bank, int first, int num, int start, int spd); void cs_obj_explode(cs_obj_t *o); /*Start death sequence*/ /* Fire/spawning control */ /* NOTE: In the original version, spawned object speed was absolute, while here, it's relative to object 'o'. */ void cs_obj_shoot(cs_obj_t *o, int xo, int yo, int xs, int ys, int rate, int delay, int ammo); typedef struct { int w, h; } image_info_t; /* ---------------------------------------------------------------------- * cs_engine_t (new) ---------------------------------------------------------------------- */ typedef struct cs_engine_t { /* Display window size (pixels) */ int w, h; /* Wrapping limits (pixels) */ int wx, wy; /* Motion filtering */ int filter; /* 0: newest, * 1: linear interpolation */ /* Current time in frames */ double time; /* * Callback that's called once per Control System * frame from within cs_engine_advance(). */ void (*on_frame)(struct cs_engine_t *e); /* Active objects */ cs_obj_t *objects[CS_LAYERS]; /* Layer position/offset control */ cs_point_t offsets[CS_LAYERS]; /* Position control for custom stuff */ cs_point_t points[CS_USER_POINTS]; /* * Combined "changed" flag masks for the object groups above. */ int changed[CS_LAYERS]; /* Pool of unused objects */ cs_obj_t *pool; int pool_free; /* # of objects in here */ int pool_total; /* # of objects in system */ /* Image info table */ image_info_t *imageinfo; int nimageinfo; } cs_engine_t; cs_engine_t *cs_engine_create(int w, int h, int objects); void cs_engine_set_size(cs_engine_t *e, int w, int h); void cs_engine_set_image_size(cs_engine_t *e, int bank, int w, int h); void cs_engine_set_wrap(cs_engine_t *e, int x, int y); void cs_engine_delete(cs_engine_t *e); void cs_engine_reset(cs_engine_t *e); void cs_engine_advance(cs_engine_t *e, double to_frame); /* 0 == reset timer*/ void cs_engine_render(cs_engine_t *e); cs_obj_t *cs_engine_get_obj(cs_engine_t *e); #ifdef __cplusplus }; #endif #endif /* _CS_H_ */ KoboDeluxe-0.5.1/graphics/display.h0000666000175000001440000000063207701727776014142 00000000000000/*(LGPL) * Simple display for score, lives etc. * © David Olofson, 2001 */ #include "window.h" class display_t : public window_t { char _caption[64]; char _text[64]; int _on; Uint32 _color; void render_caption(); void render_text(); public: display_t(); void refresh(SDL_Rect *r); void color(Uint32 _cl); void caption(const char *cap); void text(const char *txt); void on(); void off(); }; KoboDeluxe-0.5.1/graphics/filters.h0000644000175000001440000001256710062307420014121 00000000000000/*(LGPL) ---------------------------------------------------------------------- filters.h - Filters for the sprite manager ---------------------------------------------------------------------- * Copyright (C) David Olofson, 2001, 2003 * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef SPRITE_FILTERS_H #define SPRITE_FILTERS_H #include "sprite.h" #ifdef __cplusplus extern "C" { #endif /* * Flags (args.flags) that apply to most plugins: */ #define SF_CLAMP_EXTEND 0x00000001 #define SF_CLAMP_SFONT 0x00000002 /* * Convert bank to RGBA 8:8:8:8 format. * * (No arguments.) */ int s_filter_rgba8(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Dither R, G and B channels to the specified bit depth. * * args.x = 1 activates 16 bit RGBA fix (assume +/-16 dither depth for RGBA) * args.y = dither type (0 = 2x2 filter, 1 = random) * * args.r = red dither depth * args.g = green dither depth * args.b = blue dither depth * * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. * * Note: This plugin does *not* dither the alpha channel! */ int s_filter_dither(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Convert bank to display format for fast rendering. * * args.x = 1 forces use of SDL_DisplayFormat(). * RGBA surfaces get a colorkey of <0,0,0,0>. */ int s_filter_displayformat(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Convert colorkey to alpha channel. * * The global colorkey variable is used for base colorkey value. * args.max = colorkey detection fuzziness factor * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. */ int s_filter_key2alpha(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Adjust alpha level and contrast, and then clean out almost opaque * and almost transparent pixels. * * args.fx = alpha contrast (1.0 = unchanged; 2.0 = double; scales around 128) * args.x = alpha offset (0 = unchanged; -255 = all transp.; 255 = all opaque) * * args.min = min alpha passed (lower ==> 0) * args.max = max alpha passed (higher ==> 255) * * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. */ int s_filter_cleanalpha(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Adjust brightness and contrast. * * args.fx = brightness (1.0 = unchanged; 0.0 = black; 2.0 = white) * args.fy = contrast (1.0 = unchanged; 0.5 = 50%; 2.0 = 200%) * * args.min = min value (clamping) * args.max = max value (clamping) * * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. */ int s_filter_brightness(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); /* * Scale images by the specified factor, using the specified method. * * args.x = scaling mode; * SF_SCALE_NEAREST Nearest * SF_SCALE_BILINEAR Bilinear interpolation * SF_SCALE_SCALE2X Scale2x (Based on an algo from AdvanceMAME) * SF_SCALE_DIAMOND Diamond (Weighted diamond shaped core) * * args.fx = horizontal scale factor (1.0 ==> 1:1) * args.fy = vertical scale factor (1.0 ==> 1:1) * * args.flags; * SF_CLAMP_EXTEND Clamp at edges; image edge is extended outwards * SF_CLAMP_SFONT SFont mode; first row is treated specially. * */ #define SF_SCALE_NEAREST 0 #define SF_SCALE_BILINEAR 1 #define SF_SCALE_SCALE2X 2 #define SF_SCALE_DIAMOND 3 int s_filter_scale(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); #if 0 /* TODO: * Add shaded light to images. * * args.fx = Highlight X position ([0,1]) * args.fy = Highlight Y position ([0,1]) * args.fz = Highlight "half intensity" radius * * args.x = Gradient type: * SF_LIGHT_LINEAR Linear gradient * SF_LIGHT_CIRCULAR Circular spotlight * * args.z = Gradient rotation (65536 units/rotation) * * args.min = "Ambient light" * args.max = Max brightness * * args.r = Light color, red component * args.g = Light color, green component * args.b = Light color, blue component * * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. */ #define SF_LIGHT_LINEAR 0 #define SF_LIGHT_CIRCULAR 1 int s_filter_light(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); #endif /* * Add single colored noise to images. * * args.x = Pseudo-RNG seed for first frame * * args.min = Min brightness ([0,255]) * args.max = Max brightness ([0,255]) * * args.r = Noise color, red component ([0,255]) * args.g = Noise color, green component ([0,255]) * args.b = Noise color, blue component ([0,255]) * * args.flags; * SF_CLAMP_SFONT SFont mode; first row is ignored. */ int s_filter_noise(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); #ifdef __cplusplus } #endif #endif /* SPRITE_FILTERS_H */ KoboDeluxe-0.5.1/graphics/gfxengine.h0000666000175000001440000001607710731606741014442 00000000000000/*(LGPL) ---------------------------------------------------------------------- gfxengine.h - Graphics Engine ---------------------------------------------------------------------- * Copyright (C) 2001-2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _GFXENGINE_H_ #define _GFXENGINE_H_ #define GFX_BANKS 256 #define MAX_DIRTYRECTS 1024 #define MAX_PAGES 3 #include #include #include #include "glSDL.h" #include "sprite.h" #include "cs.h" enum gfx_drivers_t { GFX_DRIVER_SDL2D = 0, GFX_DRIVER_GLSDL = 1 }; enum gfx_scalemodes_t { GFX_SCALE_NEAREST = 0, GFX_SCALE_BILINEAR = 1, GFX_SCALE_BILIN_OVER = 2, GFX_SCALE_SCALE2X = 3, GFX_SCALE_DIAMOND = 4 }; class window_t; class SoFont; class gfxengine_t { friend class window_t; public: gfxengine_t(); virtual ~gfxengine_t(); void output(window_t *outwin); window_t *output() { return window; } void screen(window_t *fullwin); window_t *screen() { return fullwin; } /* * Initialization */ void size(int w, int h); void centered(int c); void scale(float x, float y); void driver(gfx_drivers_t drv); void mode(int bits, int fullscreen); // 1: Use double buffering if possible void doublebuffer(int use); // -1: Use default for shadow() and doublebuffer() settings // 0: None; assume flipping gives you a garbage buffer // 1: Assume flipping leaves the back buffer intact // 2: Assume two buffers that are swapped when flipping // 3: Assume three buffers cycled when flipping void pages(int np); // 1: Enable vsync, if available void vsync(int use); // 1: Use a software shadow back buffer, if possible void shadow(int use); void autoinvalidate(int use); void interpolation(int inter); // 0 to reset internal timer void period(float frameduration); // 0 to disable timing, running one logic frame per rendered frame. // 1 to disable filtering, using raw delta times for timing. void timefilter(float coeff); void wrap(int x, int y); /* Info */ int doublebuffer() { return _doublebuf; } int shadow() { return _shadow; } int autoinvalidate() { return _autoinvalidate; } /* Engine open/close */ int open(int objects = 1024, int extraflags = 0); void close(); /* Data management (use while engine is open) */ void reset_filters(); void filterflags(int fgs); void scalemode(gfx_scalemodes_t sm, int clamping = 0); void source_scale(float x, float y); // void colorkey(Uint8 r, Uint8 g, Uint8 b); void clampcolor(Uint8 r, Uint8 g, Uint8 b, Uint8 a); void dither(int type = 0, int _broken_rgba8 = 0); void noalpha(int threshold = 128); void brightness(float bright, float contr); int loadimage(int bank, const char *name); int loadtiles(int bank, int w, int h, const char *name); int loadfont(int bank, const char *name); int copyrect(int bank, int sbank, int sframe, SDL_Rect *r); int is_loaded(int bank); void reload(); void unload(int bank = -1); /* Settings (use while engine is open) */ void title(const char *win, const char *icon); /* Display show/hide */ int show(); void hide(); /* Main loop take-over */ void run(); /* * Override these; * frame() is called once per control system frame, * after the control system has executed. * pre_render() is called after the engine has advanced * to the state for the current video frame * (interpolated state is calculated), before * the engine renders all graphics. * post_render() is called after the engine have * rendered all sprites, but before video the * sync/flip/update operation. */ virtual void frame(); virtual void pre_render(); virtual void post_render(); /* --------------------------------------------- * The members below this line can safely be * called from within the frame() handler. */ /* Rendering */ void clear(Uint32 _color = 0x000000); void invalidate(SDL_Rect *rect = NULL, window_t *window = NULL); /* Screenshots */ void screenshot(); /* Control */ cs_engine_t *cs() { return csengine; } SDL_Surface *surface(); void flip(); // Flip pages void update(); // Full update, making current draw page visible void stop(); cs_obj_t *get_obj(int layer); void free_obj(cs_obj_t *obj); void cursor(int csr); s_sprite_t *get_sprite(unsigned bank, int _frame) { return s_get_sprite(gfx, bank, _frame); } SoFont *get_font(unsigned int f); int set_hotspot(unsigned bank, int _frame, int x, int y) { return s_set_hotspot(gfx, bank, _frame, x, y); } void scroll_ratio(int layer, float xr, float yr); void scroll(int xs, int ys); void force_scroll(); int xoffs(int layer); int yoffs(int layer); /* Info */ int objects_in_use(); int width() { return _width; } int height() { return _height; } float xscale() { return xs * (1.f/256.f); } float yscale() { return ys * (1.f/256.f); } protected: gfx_drivers_t _driver; gfx_scalemodes_t _scalemode; int _clamping; SDL_Surface *screen_surface; SDL_Surface *softbuf; int backpage; int frontpage; int dirtyrects[MAX_PAGES]; SDL_Rect dirtytable[MAX_PAGES][MAX_DIRTYRECTS]; window_t *dirtywtable[MAX_PAGES][MAX_DIRTYRECTS]; window_t *fullwin; window_t *window; window_t *windows; // Linked list int wx, wy; int xs, ys; // fix 24:8 int sxs, sys; // fix 24:8 s_filter_t *sf1, *sf2; // Scaling filter plugins s_filter_t *acf; // Alpha cleaning plugin s_filter_t *bcf; // Brightness/contrast plugin s_filter_t *df; // Dither filter plugin s_filter_t *dsf; // Display format plugin int xscroll, yscroll; float xratio[CS_LAYERS]; float yratio[CS_LAYERS]; s_container_t *gfx; SoFont *fonts[GFX_BANKS]; // Kludge. cs_engine_t *csengine; int xflags; int _doublebuf; int _pages; int _vsync; int _shadow; int _fullscreen; int _centered; int _autoinvalidate; int use_interpolation; int _width, _height; int _depth; const char *_title; const char *_icontitle; int _cursor; int _dither; int _dither_type; int broken_rgba8; //Klugde for OpenGL (if RGBA8 ==> RGBA4) int alpha_threshold; //For noalpha() float _brightness; float _contrast; int last_tick; float ticks_per_frame; float _timefilter; int is_showing; int is_running; int is_open; int screenshot_count; void __invalidate(int page, SDL_Rect *rect = NULL, window_t *window = NULL); void refresh_rect(SDL_Rect *r); static void on_frame(cs_engine_t *e); void __frame(); void start_engine(); void stop_engine(); static void render_sprite(cs_obj_t *o); }; extern gfxengine_t *gfxengine; #endif KoboDeluxe-0.5.1/graphics/glSDL.h0000644000175000001440000002723710727042537013433 00000000000000/*(LGPL) ------------------------------------------------------------ glSDL 0.9 - SDL 2D API on top of OpenGL ------------------------------------------------------------ * Copyright (C) 2001-2004, 2006-2007 David Olofson * This code is released under the terms of the GNU LGPL. */ #ifndef _GLSDL_H_ #define _GLSDL_H_ /* * If you don't use GNU autotools or similar, uncomment this to * compile with OpenGL enabled: #define HAVE_OPENGL * * NOTE: * See README about using this glSDL wrapper with * SDL versions that have the glSDL backend! */ /* We're still using SDL datatypes here - we just add some stuff. */ #include "SDL.h" /* * Ignore the flag from SDL w/ glSDL backend, since we're going * to use glSDL/wrapper by default. */ #ifdef SDL_GLSDL #undef SDL_GLSDL #endif #ifndef HAVE_OPENGL /* Fakes to make glSDL code compile with SDL. */ #define SDL_GLSDL 0 #define GLSDL_FIX_SURFACE(s) #else /* HAVE_OPENGL */ #ifdef __cplusplus extern "C" { #endif #if (SDL_MAJOR_VERSION <= 1) && (SDL_MINOR_VERSION <= 2) && \ (SDL_PATCHLEVEL < 5) #warning glSDL: Using SDL version 1.2.5 or later is strongly recommended! #endif /*---------------------------------------------------------- SDL style API ----------------------------------------------------------*/ typedef enum glSDL_TileModes { GLSDL_TM_SINGLE, GLSDL_TM_HORIZONTAL, GLSDL_TM_VERTICAL, GLSDL_TM_HUGE } glSDL_TileModes; typedef struct glSDL_TexInfo { int textures; int *texture; int texsize; /* width/height of OpenGL texture */ glSDL_TileModes tilemode; int tilew, tileh; /* At least one must equal texsize! */ int tilespertex; /* Area of surface to download when/after unlocking */ SDL_Rect invalid_area; } glSDL_TexInfo; #define GLSDL_FIX_SURFACE(s) (s)->unused1 = 0; #define IS_GLSDL_SURFACE(s) ((s) && texinfotab && glSDL_GetTexInfo(s)) #ifdef SDL_GLSDL #undef SDL_GLSDL /* In case SDL has the glSDL backend... */ #endif #define SDL_GLSDL 0x00100000 /* Create an OpenGL 2D rendering context */ /* * Wraps SDL_SetVideoMode(), and adds support for the SDL_GLSDL flag. * * If 'flags' contains SDL_GLSDL, glSDL_SetVideoMode() sets up a "pure" * OpenGL rendering context for use with the glSDL_ calls. * * SDL can be closed as usual (using SDL_ calls), but you should call * glSDL_Quit() (kludge) to allow glSDL to clean up it's internal stuff. */ SDL_Surface *glSDL_SetVideoMode(int width, int height, int bpp, Uint32 flags); void glSDL_Quit(void); void glSDL_QuitSubSystem(Uint32 flags); /* Replaces SDL_Quit() entirely, when using the override defines */ void glSDL_FullQuit(void); SDL_Surface *glSDL_GetVideoSurface(void); void glSDL_UpdateRects(SDL_Surface *screen, int numrects, SDL_Rect *rects); void glSDL_UpdateRect(SDL_Surface *screen, Sint32 x, Sint32 y, Uint32 w, Uint32 h); /* * Works like SDL_Flip(), but may also perform enqueued blits. * (That is, it's possible that the implementation renders * *nothing* until glSDL_Flip() is called.) */ int glSDL_Flip(SDL_Surface *screen); void glSDL_FreeSurface(SDL_Surface *surface); int glSDL_LockSurface(SDL_Surface *surface); void glSDL_UnlockSurface(SDL_Surface *surface); /* * Like the respective SDL functions, although they ignore * SDL_RLEACCEL, as it makes no sense in this context. */ int glSDL_SetColorKey(SDL_Surface *surface, Uint32 flag, Uint32 key); int glSDL_SetAlpha(SDL_Surface *surface, Uint32 flag, Uint8 alpha); /* * Sets up clipping for the screen, or a SDL_Surface. * * Note that this function takes both SDL_Surfaces and * glSDL_Surfaces. */ SDL_bool glSDL_SetClipRect(SDL_Surface *surface, SDL_Rect *rect); int glSDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect); int glSDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, Uint32 color); /* * Convert the given surface into a SDL_Surface (if it isn't * one already), and makes sure that the underlying SDL_Surface * is of a pixel format suitable for fast texture downloading. * * Note that you *only* have to use this function if you want * fast pixel access to surfaces (ie "procedural textures"). * Any surfaces that aren't converted will be downloaded * automatically upon the first call to glSDL_BlitSurface(), * but if conversion is required, it will be required for * every glSDL_UnlockSurface() call. * * IMPORTANT: * You *can* pass an SDL_Surface directly to this function, * and it will try to deal with it nicely. However, this * requires that a temporary SDL_Surface is created, and * this surface is cached only until the texture memory is * needed for new surfaces. */ SDL_Surface *glSDL_DisplayFormat(SDL_Surface *surface); SDL_Surface *glSDL_DisplayFormatAlpha(SDL_Surface *surface); SDL_Surface *glSDL_ConvertSurface (SDL_Surface *src, SDL_PixelFormat *fmt, Uint32 flags); SDL_Surface *glSDL_CreateRGBSurface (Uint32 flags, int width, int height, int depth, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); SDL_Surface *glSDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask); SDL_Surface *glSDL_LoadBMP(const char *file); int glSDL_SaveBMP(SDL_Surface *surface, const char *file); #ifdef __cplusplus } #endif /* Some ugly "overriding"... */ #ifndef _GLSDL_NO_REDEFINES_ /* * You *always* need to lock and unlock a glSDL surface in * order to get glSDL to update the OpenGL texture! */ #undef SDL_MUSTLOCK #define SDL_MUSTLOCK(surface) \ (surface->offset || \ ((surface->flags & (SDL_HWSURFACE|SDL_ASYNCBLIT|SDL_RLEACCEL)) != 0) || \ IS_GLSDL_SURFACE(surface)) #define SDL_SetVideoMode glSDL_SetVideoMode #define SDL_GetVideoSurface glSDL_GetVideoSurface #define SDL_Quit glSDL_FullQuit #define SDL_QuitSubSystem glSDL_QuitSubSystem #define SDL_UpdateRects glSDL_UpdateRects #define SDL_UpdateRect glSDL_UpdateRect #define SDL_Flip glSDL_Flip #define SDL_FreeSurface glSDL_FreeSurface #define SDL_LockSurface glSDL_LockSurface #define SDL_UnlockSurface glSDL_UnlockSurface #define SDL_SetColorKey glSDL_SetColorKey #define SDL_SetAlpha glSDL_SetAlpha #define SDL_SetClipRect glSDL_SetClipRect #undef SDL_BlitSurface #define SDL_BlitSurface glSDL_BlitSurface #define SDL_FillRect glSDL_FillRect #define SDL_DisplayFormat glSDL_DisplayFormat #define SDL_DisplayFormatAlpha glSDL_DisplayFormatAlpha #define SDL_ConvertSurface glSDL_ConvertSurface #define SDL_CreateRGBSurface glSDL_CreateRGBSurface #define SDL_CreateRGBSurfaceFrom glSDL_CreateRGBSurfaceFrom #undef SDL_AllocSurface #define SDL_AllocSurface glSDL_CreateRGBSurface #undef SDL_LoadBMP #define SDL_LoadBMP glSDL_LoadBMP #undef SDL_SaveBMP #define SDL_SaveBMP glSDL_SaveBMP #define IMG_Load(x) glSDL_IMG_Load(x) #endif #endif /* HAVE_OPENGL */ #ifdef HAVE_OPENGL /* Some extra overloading for common external lib calls... */ #include "SDL_image.h" #ifdef __cplusplus extern "C" { #endif SDL_Surface *glSDL_IMG_Load(const char *file); #ifdef __cplusplus } #endif #endif /* HAVE_OPENGL */ /*---------------------------------------------------------- glSDL API extensions, transparent ----------------------------------------------------------*/ #ifdef __cplusplus extern "C" { #endif /* * Invalidate part of a texture. * * This function can be used either between calls to * glSDL_LockSurface() and glSDL_UnlockSurface(), or before * calling glSDL_DownloadSurface(). * * In either case, it causes only the specified area to be * downloaded when unlocking the surface, or calling * glSDL_UnlockSurface(), respectively. * * Note that if this function is not used, glSDL assumes that * the entire surface has to be updated. (That is, it's safe * to ignore this function - it's "just a performance hack.") * * Passing a rectangle with zero height or width cancels the * downloading when/after unlocking the surface. Use if you * just want to read the texture, but feel like being nice and * obeying SDL_MUSTLOCK() - which is a good idea, as things * may change... * * Passing NULL for the 'area' argument results in the entire * surface being invalidated. * * NOTE: This function does NOT perform clipping! Weird or * even Bad Things may happen if you specify areas * that protrude outside the edges of the actual * surface. */ void glSDL_Invalidate(SDL_Surface *surface, SDL_Rect *area); /* * Make sure that the texture of the specified surface is up * to date in OpenGL texture memory. * * This can be used together with glSDL_UnloadSurface() to * implement custom texture caching schemes. * * Returns 0 on success, or a negative value if something * went wrong. */ int glSDL_UploadSurface(SDL_Surface *surface); /* * Free the texture space used by the specified surface. * * Normally, glSDL should download textures when needed, and * unload the oldest (in terms of use) surfaces, if it runs out * of texture space. */ void glSDL_UnloadSurface(SDL_Surface *surface); /*---------------------------------------------------------- glSDL API extensions, OpenGL mode ONLY ----------------------------------------------------------*/ /* * Enable, disable or check the state of "vsync" or * vertical retrace synchronization. Note that enabling * this does not *guarantee* that the driver actually * uses vsync; it only instructs OpenGL to do so if * possible. * Pass 1 for 'use' to enable vsync, '0' to disable * it, and -1 to just return the current state without * changing it. * Returns the vsync state *before* any change made * by the call. * * NOTE: Ignored when not using OpenGL acceleration! */ int glSDL_VSync(int use); /* * Set alpha multiplier. This is multiplied with any full * surface alpha or alpha channels of surfaces. * * The default value is 255, which makes glSDL render like * the standard SDL 2D backends, ie based only on the * surface settings. * * This function affects the global state of glSDL. * * NOTE: NOT available without OpenGL acceleration! */ void glSDL_SetBlendAlpha(Uint8 alpha); /* * Set color multipliers. These are multiplied with the * respective color channers of rendered surfaces, * modulating the brightness of the resulting output. * * The default values are 255, which makes glSDL render * like the standard SDL 2D backends. * * This function affects the global state of glSDL. * * NOTE: NOT available without OpenGL acceleration! */ void glSDL_SetBlendColor(Uint8 r, Uint8 g, Uint8 b); /* * Set center offset in pixels for scaling and rotation. * * The default is (0, 0), which makes surfaces rotate and * scale around their centers. * * This function affects the global state of glSDL. * * NOTE: NOT available without OpenGL acceleration! */ void glSDL_SetCenter(float x, float y); /* * Set rotation angle in degrees. Rotation is done around * the center point, which is defined as * (w/2 + cx, h/2 + cy) * where w and h are the width and height of the source * surface, and cx and cy are the center offsets set by * glSDL_SetCenter(). * * The default value is 0.0f, which makes glSDL render * like a normal SDL 2D backend. * * This function affects the global state of glSDL. * * NOTE: NOT available without OpenGL acceleration! */ void glSDL_SetRotation(float angle); /* * Set scale factor. Scaling is centered around around * the point * (w/2 + cx, h/2 + cy) * where w and h are the width and height of the source * surface, and cx and cy are the center offsets set by * glSDL_SetCenter(). * * The default value is 1.0f, which makes glSDL render * like a normal SDL 2D backend. * * This function affects the global state of glSDL. * * NOTE: NOT available without OpenGL acceleration! */ void glSDL_SetScale(float x, float y); /* * Reset glSDL global state to defaults. */ void glSDL_ResetState(void); #ifdef __cplusplus } #endif #endif /* _GLSDL_H_ */ KoboDeluxe-0.5.1/graphics/region.h0000644000175000001440000000333210706111341013722 00000000000000/*(LGPL) ---------------------------------------------------------------------- region.h - Graphics Engine ---------------------------------------------------------------------- * Copyright (C) 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KOBO_REGION_H #define KOBO_REGION_H #include "glSDL.h" #ifdef __cplusplus extern "C" { #endif /* * Region * Describes an area as a number of pixel spaced rows, * each containing zero or more spans on the form . */ typedef struct RGN_region { int rows; Uint16 **spans; } RGN_region; /* Construct region by scanning an SDL surface */ RGN_region *RGN_ScanMask(SDL_Surface *src, Uint32 key); /* Free a region */ void RGN_FreeRegion(RGN_region *rgn); /* Set target for region rendering */ void RGN_Target(SDL_Surface *tgt); /* Select and position region for subsequent operations */ void RGN_SetRegion(RGN_region *rgn, int xpos, int ypos); /* Blit to region! */ int RGN_Blit(SDL_Surface *src, SDL_Rect *sr, int x, int y); #ifdef __cplusplus }; #endif #endif /* KOBO_REGION_H */ KoboDeluxe-0.5.1/graphics/sofont.h0000666000175000001440000000676410730341237013775 00000000000000 /* SoFont - SDL Object Font Library This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; if not, write to the Free Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Originally from C Library: Karl Bartel * SFONT - SDL Font Library by Karl Bartel * * * * All functions are explained below. There are two versions of each * * funtction. The first is the normal one, the function with the * * 2 at the end can be used when you want to handle more than one font * * in your program. * * * Copied into a C++ object to allow multiple fonts by: Luc-Olivier de Charriere David Olofson : * Strings changed to 'const char *' * Cursor tests first check if '|' is present. * Shadowed variables fixed. * Garbage data in spacing table fixed. (Thanks to Andreas Spĺngberg for discovering this one!) * Added ExtraSpace(). (Scaling support hack...) * Disabled colorkeying. (Ruins some RGBA fonts!) */ #ifndef __SOFONT_H #define __SOFONT_H #include "glSDL.h" class SoFont { public: SoFont(); ~SoFont(); bool load(SDL_Surface *FontSurface); // Blits a string to a surface // Destination: the suface you want to blit to // text: a string containing the text you want to blit. void PutString(SDL_Surface *Surface, int x, int y, const char *text, SDL_Rect *clip=NULL); void PutStringWithCursor(SDL_Surface *Surface, int x, int y, const char *text, int cursPos, SDL_Rect *clip=NULL, bool showCurs=true); // Returns the width of "text" in pixels int TextWidth(const char *text, int min=0, int max=255); int FontHeight() { return height; } // Blits a string to with centered x position void XCenteredString(SDL_Surface *Surface, int y, const char *text, SDL_Rect* clip=NULL); // Blits a string to with centered x & y position void CenteredString(SDL_Surface *Surface, const char *text, SDL_Rect* clip=NULL); // Blits a string to with centered around x & y positions void CenteredString(SDL_Surface *Surface, int x, int y, const char *text, SDL_Rect* clip=NULL); // This was specially developped for GUI void PutStringCleverCursor(SDL_Surface *Surface, const char *text, int cursPos, SDL_Rect *r, SDL_Rect* clip=NULL, bool showCurs=true); // Gives the cursor position given a x-axix point in the text int TextCursorAt(const char *text, int px); int CleverTextCursorAt(const char *text, int px, int cursPos, SDL_Rect *r); # define START_CHAR 33 int getMinChar(){return START_CHAR;} int getMaxChar(){return max_i;} void ExtraSpace(int xs) { xspace = xs; } protected: int height; SDL_Surface *picture; int *CharPos; int *CharOffset; int *Spacing; int xspace; int max_i, spacew, cursShift; Uint32 background; bool DoStartNewChar(Sint32 x); void CleanSurface(); }; #endif KoboDeluxe-0.5.1/graphics/sprite.h0000666000175000001440000001505710710726501013765 00000000000000/*(LGPL) ---------------------------------------------------------------------- sprite.h - Sprite engine for use with cs.h ---------------------------------------------------------------------- * Copyright (C) 2001, 2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _SPRITE_H_ #define _SPRITE_H_ #ifdef __cplusplus extern "C" { #endif #include "glSDL.h" typedef enum { S_BLITMODE_AUTO = 0, /* Use source alpha if present */ S_BLITMODE_OPAQUE, /* Alpha: blend over black during conv. */ S_BLITMODE_COLORKEY, /* Like OPAQUE, but apply colorkey to the result */ S_BLITMODE_ALPHA /* Apply source alpha during conv, * then use full surface alpha */ } s_blitmodes_t; struct s_container_t; /* sprite image */ typedef struct { int x, y; /* kern or hot-spot*/ #if 0 /* TODO TODO TODO TODO TODO TODO */ struct { int x, y, w, h; /* spacing or collision rect */ } logic; /* /TODO TODO TODO TODO TODO TODO */ #endif SDL_Surface *surface; } s_sprite_t; /* Bank of sprite images */ typedef struct { #if 0 /* TODO TODO TODO TODO TODO TODO */ struct s_container_t *container; int index; /* Index of this bank */ /* /TODO TODO TODO TODO TODO TODO */ #endif unsigned w, h; /* Same size for all sprites in bank! */ unsigned last; unsigned max; s_sprite_t **sprites; } s_bank_t; /* Two dimensionally indexed sprite container */ typedef struct s_container_t { unsigned max; s_bank_t **banks; } s_container_t; /* * Basic Container Management */ s_container_t *s_new_container(unsigned banks); void s_delete_container(s_container_t *c); s_bank_t *s_new_bank(s_container_t *c, unsigned bank, unsigned frames, unsigned w, unsigned h); void s_delete_bank(s_container_t *c, unsigned bank); void s_delete_all_banks(s_container_t *c); s_sprite_t *s_new_sprite(s_container_t *c, unsigned bank, unsigned frame); void s_delete_sprite(s_container_t *c, unsigned bank, unsigned frame); /* * Getting data */ s_sprite_t *s_get_sprite(s_container_t *c, unsigned bank, unsigned frame); /* Detach sprite image from the manager. */ void s_detach_sprite(s_container_t *c, unsigned bank, unsigned frame); /* * File Import Tools * (Will run plugins as files are loaded!) */ int s_load_image(s_container_t *c, unsigned bank, const char *name); int s_load_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, const char *name); int s_load_sprite(s_container_t *c, unsigned bank, unsigned frame, const char *name); /* * Rendering Tools */ int s_generate_bank(s_container_t *c, unsigned bank, unsigned w, unsigned h, const char *name); /* * Sprite metadata */ /* Set sprite hotspot. Pass -1 for 'frame' to set hotspot for all frames. */ int s_set_hotspot(s_container_t *c, unsigned bank, int frame, int x, int y); /* * Internal data manipulation API * (Will not automatically run plugins.) */ int s_copy_rect(s_container_t *c, unsigned bank, unsigned frombank, unsigned fromframe, SDL_Rect *from); /* * Lower level interfaces */ s_bank_t *s_get_bank(s_container_t *c, unsigned bank); s_sprite_t *s_get_sprite_b(s_bank_t *b, unsigned frame); s_sprite_t *s_new_sprite_b(s_bank_t *b, unsigned frame); void s_delete_sprite_b(s_bank_t *b, unsigned frame); /* * Filter Plugin Interface * * Rules: * * Plugins are called to process one bank at a time, * after new frames have been loaded. * * * Plugins are called in the order they were * registered. * * * Plugins may replace the surfaces of sprites. If * they do so, they're responsible for disposing of * the old surfaces. * * * It is recommended that plugins operate only on * the specified range of frames in a bank. * * * The surface size of all sprites in a bank should * preferably match that of the bank. A chain of * plugins may break this rule temporarily, as long * as "order is restored" (ie surfaces are resized, or * bank size values is adjusted) before the chain ends. * * Cool plugin ideas: * * Rotator: * Takes a bank and generates N rotated versions of * each sprite. * * * Bumpmapper: * Takes a bank and applies light, shadows, highlights * and stuff to frames that have bumpmap channels. * (Q: Where do we put bumpmaps? Extend the bank to * twice the # of frames, using the last half for BMs? * Use two banks? I think we need an API change that * make plugins operators; X = A B, where the * banks X, A and B are arguments.) * * * Mixer: * A plugin that takes two banks and performs various * operations between them to produce the output. * * * Colorizer: * Converts images to HSV and then replaces hue with * a fixed color. * * * Map Colorizer: * Like Colorizer, but uses a (wrapping) source image * as a map to determine the new hue for each pixel. * * * Tiled Stretch: * Given a list of tile interdependencies, generate * all tiles required for seamless rendering of the * map for which the interdependency list was generated. */ typedef struct s_filter_args_t { int x, y, z; float fx, fy, fz; int min, max; short r, g, b; int flags; unsigned bank; void *data; } s_filter_args_t; typedef int (*s_filter_cb_t)(s_bank_t *b, unsigned first, unsigned frames, s_filter_args_t *args); typedef struct s_filter_t { struct s_filter_t *next; s_filter_cb_t callback; s_filter_args_t args; } s_filter_t; s_filter_t *s_insert_filter(s_filter_cb_t callback); s_filter_t *s_add_filter(s_filter_cb_t callback); /* callback == NULL means "remove all plugins" */ void s_remove_filter(s_filter_t *filter); /* RGBA pixel type (used internally by most filters as well) */ typedef struct { Uint8 r; Uint8 g; Uint8 b; Uint8 a; } pix_t; /* * UURGH!!! This should be OO like the rest... */ extern s_blitmodes_t s_blitmode; extern pix_t s_colorkey; /* NOTE: Alpha is ignored! */ extern pix_t s_clampcolor; extern unsigned char s_alpha; extern int s_filter_flags; /* Global flags; applied to all plugins. */ #ifdef __cplusplus }; #endif #endif /* _SPRITE_H_ */ KoboDeluxe-0.5.1/graphics/toolkit.h0000666000175000001440000001111607462556476014162 00000000000000/*(LGPL) --------------------------------------------------------------------------- toolkit.h - Simple "GUI" toolkit for config screens. --------------------------------------------------------------------------- * Copyright (C) 2001, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * Note: change(0) means "apply", and would be the normal * result of pressing enter while a widget is selected. */ #include "window.h" enum ct_align_t { ALIGN_DEFAULT = -1, ALIGN_NONE = 0, ALIGN_LEFT, ALIGN_TOP = ALIGN_LEFT, ALIGN_RIGHT, ALIGN_BOTTOM = ALIGN_RIGHT, ALIGN_CENTER, ALIGN_CENTER_TOKEN }; class ct_widget_t : public window_t { protected: friend class ct_form_t; int interactive; int transparent; int highlighted; Uint32 _color; int _value; int _widget_index; ct_align_t _halign; ct_align_t _valign; char _token; float xo, yo; //[0,1] maps to [0,width()]! virtual void render(); void render_text_aligned(const char *buf); public: ct_widget_t *next, *prev; //*CIRCULAR* list! void *user; //user stuff int user2; //user stuff int tag; //user stuff ct_widget_t(); virtual void init(gfxengine_t *e); void transparency(int t); void highlight(int hl); void color(Uint32 _cl); virtual void change(int delta); virtual void value(int val); virtual int value(); //Contents alignment modes. virtual void halign(ct_align_t ha); virtual void valign(ct_align_t va); ct_align_t halign() { return _halign; } ct_align_t valign() { return _valign; } //Token and offsets- used by some alignment modes. virtual void token(char tok) { _token = tok; } char token() { return _token; } virtual void offset(float x, float y) { xo = x; yo = y; } int xoffs() { return (int)(xo * width()); } int yoffs() { return (int)(yo * height()); } float rxoffs() { return xo; } float ryoffs() { return yo; } }; class ct_engine_t { public: ct_engine_t(); void (*render_highlight)(ct_widget_t *wg); }; extern ct_engine_t ct_engine; class ct_label_t : public ct_widget_t { protected: char _caption[64]; void render(); public: ct_label_t(const char *cap = NULL); void caption(const char *cap); const char *caption() { return _caption; } virtual void halign(ct_align_t ha); }; class ct_item_t { protected: char _caption[64]; int _index; int _value; public: ct_item_t *next, *prev; //*CIRCULAR* list! ct_item_t(const char *cap = NULL, int val = 0); void caption(const char *cap); const char *caption() { return _caption; } void value(int val) { _value = val; } int value() { return _value; } void index(int i) { _index = i; } int index() { return _index; } }; class ct_list_t : public ct_label_t { protected: ct_item_t *items; ct_item_t *_selected; void render(); public: ct_list_t(const char *cap = NULL); virtual ~ct_list_t(); void add(ct_item_t *item); void add(const char *cap, int val); void clean(); void select(ct_item_t *item); void select(int ind); ct_item_t *selected(); void value(int val); int value(); void change(int delta); virtual void halign(ct_align_t ha); }; class ct_spin_t : public ct_label_t { protected: int min; int max; char _unit[32]; void render(); public: ct_spin_t(const char *cap = NULL, int _min = 0, int _max = 99999, const char *__unit = NULL); void value(int val); void change(int delta); void unit(const char *txt); const char *unit() { return _unit; } }; class ct_button_t : public ct_label_t { protected: void render(); public: ct_button_t(const char *cap = NULL); void change(int delta); }; class ct_form_t : public window_t { protected: ct_widget_t *widgets; ct_widget_t *_selected; public: ct_form_t(); virtual ~ct_form_t(); void add(ct_widget_t *w); void clean(); virtual void select(ct_widget_t *w); virtual void select(int ind); virtual void next(); virtual void prev(); ct_widget_t *selected(); int selected_index(); void render(); void render_nontransparent(); virtual void change(int delta); }; KoboDeluxe-0.5.1/graphics/vidmodes.h0000644000175000001440000000606410711213303014253 00000000000000/*(LGPL) --------------------------------------------------------------------------- vidmodes.h - Video Mode Manager for Kobo Deluxe --------------------------------------------------------------------------- * Copyright (C) 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef KOBO_VIDMODES_H #define KOBO_VIDMODES_H #ifdef __cplusplus extern "C" { #endif /*------------------------------------------------------------------------- Data Types and Structures -------------------------------------------------------------------------*/ typedef enum { VMM_ALL = 0xffffffff, VMM_DETECT = 0x00000001, /* Available modes as detected by SDL */ VMM_4_3 = 0x00000010, /* 4:3 modes */ VMM_3_2 = 0x00000020, /* 3:2 modes */ VMM_5_4 = 0x00000040, /* 5:4 modes */ VMM_16_10 = 0x00000080, /* 16:10 modes */ VMM_16_9 = 0x00000100, /* 16:9 modes */ VMM_PC = 0x00010000, /* Standard PC/Mac modes */ VMM_WPC = 0x00020000, /* Widescreen PC/Mac modes */ VMM_TV = 0x00040000, /* Standard TV modes */ VMM_WTV = 0x00080000, /* Widescreen TV modes */ VMM_LORES = 0x10000000 /* Special low resolution modes */ } VMM_Flags; typedef struct VMM_Mode VMM_Mode; struct VMM_Mode { VMM_Mode *next; /* Next mode in list */ char *name; /* Name, if any */ int id; /* Somewhat constant mode ID */ int width; /* Display width in pixels */ int height; /* Display height in pixels */ int flags; /* (WMM_Flags) */ float aspect; /* Pixel aspect ratio */ }; /*------------------------------------------------------------------------- Gathering and constructing modes -------------------------------------------------------------------------*/ int vmm_Init(int show, int hide); void vmm_Close(void); /*------------------------------------------------------------------------- Scanning -------------------------------------------------------------------------*/ VMM_Mode *vmm_First(void); VMM_Mode *vmm_Next(VMM_Mode *current); /*------------------------------------------------------------------------- Indexing -------------------------------------------------------------------------*/ VMM_Mode *vmm_FindMode(int id); /*------------------------------------------------------------------------- Searching -------------------------------------------------------------------------*/ /* TODO: VMM_Mode *vmm_Find(int width, int height, int aspect); */ #ifdef __cplusplus }; #endif #endif /* KOBO_VIDMODES_H */ KoboDeluxe-0.5.1/graphics/window.h0000666000175000001440000002626410730444361013773 00000000000000/*(LGPL) --------------------------------------------------------------------------- window.h - Generic Rendering Window --------------------------------------------------------------------------- * Copyright (C) 2001-2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * Programmer's Documentation: * The window_t class represents a simple window of the * screen surface. It provides some high level rendering * functions that operate inside the window's bounding * rectangle. All operations are clipped. However, * window occlusion is *not* handled, so you can't use * this class for "real" windows. * * virtual void init(gfxengine_t *e); * Call this to connect a window_t instance to * the gfxengine_t instance that manages your * screen. You *must* call this for pretty much * any other calls to work. * * void place(int left, int top, int sizex, int sizey); * Position the window on the screen. * * int offscreen(); * Make this an off-screen window, with a * surface of it's own for rendering. An off- * screen window will never be directly visible, * but can be used as a source window for blit(). * May return -1 if there is an error. * * void select(); * Makes this window active, and sets up SDL's * clipping appropriately. You should not use * this call normally, but it's provided to * allow this engine to interface with other * SDL code. * * void invalidate(SDL_Rect *r = NULL); * Invalidate the specified area, or the whole * window if r is NULL. This will ensure that * any changes in the invalidated area are made * visible on the screen. Note that this call * may also indirectly cause one or more calls * to refresh(). * * virtual void refresh(SDL_Rect *r); * Virtual refresh call to be implemented by * windows that aren't repainted every frame. * After a call to invalidate(), refresh() will * be called by the engine as necessary to * produce a correct display. Note that in some * cases, this means that refresh() will be * called once for each screen flip, until all * buffers (usually two) are up to date. Also * note that you should do all rendering to the * window either directly *or* in the refresh() * function. * * Uint32 map_rgb(Uint8 r, Uint8 g, Uint8 b); * Uint32 map_rgb(Uint32 rgb); * Two different ways of translating a color in * standard RGB format (separate components or * HTML style hex code, respectively) into a * pixel value compatible with the screen. * * void foreground(Uint32 color); * void background(Uint32 color); * Change the foreground and background colors * used by subsequent rendering operations. * Note that the arguments have to be in screen * pixel format - the easiest way is to use the * map_rgb() calls to generate the values. * * void bgimage(int bank, int frame); * Select a background image, to use instead of * a background color. Setting bank and frame to * -1 (default) disables the image, so that the * background color is used instead. * * void colorkey(Uint32 color); * void colorkey(); * Set the colorkey for this window to 'color' * and enable colorkeying. This affects blit() * when this window is used as the source. The * version without arguments disables * colorkeying for this window. * NOTE: Colorkeying is only supported by * offscreen windows. * * void alpha(float a); * Set the full surface alpha of this window. * 0.0 is fully transparent and 1.0 is opaque. * NOTE: Alpha is only supported by offscreen * windows. * * void clear(SDL_Rect *r = NULL); * Fill the specified rectangle with the current * background color or background image. If r is * NULL (default), clear the whole window. * * void font(int fnt); * Select the font to be used for subsequent * text rendering operations. The argument is a * gfxengine_t bank index, and must refer to a * bank that has been loaded with * gfxengine_t::loadfont(). * * void string(int _x, int _y, const char *txt); * Put text string 'txt' starting at (_x, _y). * * void center(int _y, const char *txt); * Put text string 'txt' centered horizontally * inside the window, using '_y' as the y coord. * * void center_token(int _x, int _y, const char *txt, char token = 0); * Print string 'txt', positioning it so that * the first occurrence of character 'token' * is located at (_x, _y). Omitting the 'token' * argument, or passing 0 aligns the end of the * string with _x. Setting 'token' to -1 results * in the graphical center of the string being * located at (_x, _y) - basically an advanced * version of center(). * * void string_fxp(int _x, int _y, const char *txt); * void center_fxp(int _y, const char *txt); * void center_token_fxp(int _x, int _y, const char *txt, char token = 0); * gfxengine_t fixed point format versions of * the corresponding non-fxp calls. (For sub- * pixel accurate rendering and/or to make use * of the higher resolutions in scaled modes.) * * int textwidth(const char *txt, int min = 0, int max = 255); * Calculates the graphical width of 'txt' if it * was to be printed with the current font. * Calculation starts at position 'min' in the * string, and ends at 'max', which makes it * possible to use this call for various * advanced alignment calculations. * * int fontheight(); * Returns the height of the currently selected * font. * * void point(int _x, int _y); * Plot a pixel with the current foreground * color at (_x, _y). Note that the pixel will * become a quadratic block if the screen is * scaled to a higher resolution. * * void rectangle(int _x, int _y, int w, int h); * Draw a hollow rectangle of w x h pixels at * (_x, _y). The line thickness is scaled along * with screen resolution, as with point(). * * void fillrect(int _x, int _y, int w, int h); * Draw a solid rectangle of w x h pixels at * (_x, _y). * * void fillrect_fxp(int _x, int _y, int w, int h); * As fillrect(), but with pixel or sub-pixel * accuracy, depending on scaling and video * driver. * * void sprite(int _x, int _y, int bank, int frame, int inval = 1); * Render sprite 'bank':'frame' at (_x, _y). If * inval is passed and set to 0, the affected * area will *not* be invalidated automatically. * * void sprite_fxp(int _x, int _y, int bank, int frame, int inval = 1); * As sprite(), but with pixel or sub-pixel * accuracy, depending on scaling and video * driver. * * void blit(int dx, int dy, window_t *src); * Blit from window 'src' into this window, placing * the top left corner of 'src' at (dx, dy). * * void blit(int dx, int dy, int sx, int sy, int sw, int sh, window_t *src); * Blit rectangle (sx, sy, sw, sh) from window 'src' * into this window, placing the top left corner of * 'src' at (dx, dy). * * int x() { return rect.x / xsc; } * int y() { return rect.y / ysc; } * int width() { return rect.w / xsc; } * int height() { return rect.h / ysc; } * Get the current screen position of the * window's top-left corner, and it's size. * * int x2() { return (rect.x + rect.w) / xsc; } * int y2() { return (rect.y + rect.h) / ysc; } * Get the screen position of the bottom-right * corner of the window. */ #ifndef _WINDOW_H_ #define _WINDOW_H_ #include "glSDL.h" class gfxengine_t; class window_t { friend class gfxengine_t; public: window_t(); window_t(gfxengine_t *e); virtual ~window_t(); virtual void init(gfxengine_t *e); void place(int left, int top, int sizex, int sizey); int offscreen(); void visible(int vis); int visible() { return _visible; } void select(); void invalidate(SDL_Rect *r = NULL); virtual void refresh(SDL_Rect *r) { ; } /* Color tools */ Uint32 mulrgb(Uint32 c1, Uint32 c2) { int r = ((c1 >> 16) & 0xff) * ((c2 >> 16) & 0xff) * 258 >> 16; int g = ((c1 >> 8) & 0xff) * ((c2 >> 8) & 0xff) * 258 >> 16; int b = (c1 & 0xff) * (c2 & 0xff) * 258 >> 16; return r << 16 | g << 8 | b; } Uint32 fadergb(Uint32 rgb, Uint8 fade) { int r = ((rgb >> 16) & 0xff) * fade * 258 >> 16; int g = ((rgb >> 8) & 0xff) * fade * 258 >> 16; int b = (rgb & 0xff) * fade * 258 >> 16; return r << 16 | g << 8 | b; } /* Rendering */ Uint32 map_rgb(Uint8 r, Uint8 g, Uint8 b); Uint32 map_rgb(Uint32 rgb); void foreground(Uint32 color) { fgcolor = color; } void background(Uint32 color) { bgcolor = color; }; void bgimage(int bank = -1, int frame = -1); void colorkey(Uint32 color); void colorkey(); void alpha(float a); void clear(SDL_Rect *r = NULL); void font(int fnt); void string(int _x, int _y, const char *txt); void center(int _y, const char *txt); void center_token(int _x, int _y, const char *txt, char token = 0); void string_fxp(int _x, int _y, const char *txt); void center_fxp(int _y, const char *txt); void center_token_fxp(int _x, int _y, const char *txt, char token = 0); int textwidth(const char *txt, int min = 0, int max = 255); int textwidth_fxp(const char *txt, int min = 0, int max = 255); int fontheight(); void point(int _x, int _y); void rectangle(int _x, int _y, int w, int h); void fillrect(int _x, int _y, int w, int h); void fillrect_fxp(int _x, int _y, int w, int h); void sprite(int _x, int _y, int bank, int frame, int inval = 1); void sprite_fxp(int _x, int _y, int bank, int frame, int inval = 1); void blit(int dx, int dy, int sx, int sy, int sw, int sh, window_t *src); void blit(int dx, int dy, window_t *src); int x() { return (phys_rect.x * 256 + 128) / xs; } int y() { return (phys_rect.y * 256 + 128) / ys; } int x2() { return ((phys_rect.x + phys_rect.w) * 256 + 128) / xs; } int y2() { return ((phys_rect.y + phys_rect.h) * 256 + 128) / ys; } int width() { return x2() - x(); } int height() { return y2() - y(); } SDL_Rect phys_rect; protected: window_t *next, *prev; /* * Kludge: This is for window selection to work. * the problem is that this will break (along * with some other things) if more than one * gfxengine_t instance is used. */ static window_t *selected; //Currently selected window gfxengine_t *engine; SDL_Surface *surface; int xs, ys; //fixp 24:8 Uint32 fgcolor, bgcolor; int bg_bank, bg_frame; int _font; int _visible; int _offscreen; void _select(); //Internal version void link(gfxengine_t *e); void unlink(void); void phys_refresh(SDL_Rect *r) { if(!r) refresh(NULL); else { SDL_Rect dr; dr.x = r->x - phys_rect.x; dr.y = r->y - phys_rect.y; int x2 = (int)(dr.x + r->w) * 256 / xs; int y2 = (int)(dr.y + r->h) * 256 / ys; dr.x = (int)dr.x * 256 / xs; dr.y = (int)dr.y * 256 / ys; dr.w = x2 - dr.x; dr.h = y2 - dr.y; refresh(&dr); } } }; #endif KoboDeluxe-0.5.1/sound/0002777000175000001440000000000010734700732011714 500000000000000KoboDeluxe-0.5.1/sound/Makefile.am0000666000175000001440000000062310711350346013664 00000000000000noinst_LIBRARIES = libsound.a INCLUDES = -I../eel -I../graphics @LOCALCFLAGS@ libsound_a_SOURCES = audio.c a_globals.c a_struct.c \ audiodev.c a_midi.c sfifo.c a_pitch.c a_midisock.c \ a_wave.c a_patch.c a_channel.c a_voice.c a_bus.c \ a_commands.c a_control.c a_midicon.c a_midifile.c \ a_plugin.c a_delay.c a_limiter.c a_filters.c \ a_wca.c a_agw.c a_sequencer.c a_events.c EXTRA_DIST = *.h KoboDeluxe-0.5.1/sound/Makefile.in0000644000175000001440000003552110731616146013703 00000000000000# Makefile.in generated by automake 1.9.6 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ top_builddir = .. am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd INSTALL = @INSTALL@ install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ target_triplet = @target@ subdir = sound DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/aconfig.h CONFIG_CLEAN_FILES = LIBRARIES = $(noinst_LIBRARIES) AR = ar ARFLAGS = cru libsound_a_AR = $(AR) $(ARFLAGS) libsound_a_LIBADD = am_libsound_a_OBJECTS = audio.$(OBJEXT) a_globals.$(OBJEXT) \ a_struct.$(OBJEXT) audiodev.$(OBJEXT) a_midi.$(OBJEXT) \ sfifo.$(OBJEXT) a_pitch.$(OBJEXT) a_midisock.$(OBJEXT) \ a_wave.$(OBJEXT) a_patch.$(OBJEXT) a_channel.$(OBJEXT) \ a_voice.$(OBJEXT) a_bus.$(OBJEXT) a_commands.$(OBJEXT) \ a_control.$(OBJEXT) a_midicon.$(OBJEXT) a_midifile.$(OBJEXT) \ a_plugin.$(OBJEXT) a_delay.$(OBJEXT) a_limiter.$(OBJEXT) \ a_filters.$(OBJEXT) a_wca.$(OBJEXT) a_agw.$(OBJEXT) \ a_sequencer.$(OBJEXT) a_events.$(OBJEXT) libsound_a_OBJECTS = $(am_libsound_a_OBJECTS) DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(libsound_a_SOURCES) DIST_SOURCES = $(libsound_a_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ AMDEP_FALSE = @AMDEP_FALSE@ AMDEP_TRUE = @AMDEP_TRUE@ AMTAR = @AMTAR@ AUDIO_LIBS = @AUDIO_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ BUILD_MACOSX_BUNDLE_FALSE = @BUILD_MACOSX_BUNDLE_FALSE@ BUILD_MACOSX_BUNDLE_TRUE = @BUILD_MACOSX_BUNDLE_TRUE@ BUILD_SIMPLE_BUNDLE_FALSE = @BUILD_SIMPLE_BUNDLE_FALSE@ BUILD_SIMPLE_BUNDLE_TRUE = @BUILD_SIMPLE_BUNDLE_TRUE@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CONFIGDIR = @CONFIGDIR@ CONFIGFILE = @CONFIGFILE@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CXX = @CXX@ CXXDEPMODE = @CXXDEPMODE@ CXXFLAGS = @CXXFLAGS@ CYGPATH_W = @CYGPATH_W@ DATADIR = @DATADIR@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ EXEFILE = @EXEFILE@ GREP = @GREP@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ LOCALCFLAGS = @LOCALCFLAGS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MATHLIB = @MATHLIB@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ POW_LIB = @POW_LIB@ RANLIB = @RANLIB@ SCOREDIR = @SCOREDIR@ SDL_CFLAGS = @SDL_CFLAGS@ SDL_CONFIG = @SDL_CONFIG@ SDL_LIBS = @SDL_LIBS@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ UNIX_SCOREDIR_FALSE = @UNIX_SCOREDIR_FALSE@ UNIX_SCOREDIR_TRUE = @UNIX_SCOREDIR_TRUE@ VERSION = @VERSION@ XMKMF = @XMKMF@ X_CFLAGS = @X_CFLAGS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_LIBS = @X_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ ac_ct_CC = @ac_ct_CC@ ac_ct_CXX = @ac_ct_CXX@ am__fastdepCC_FALSE = @am__fastdepCC_FALSE@ am__fastdepCC_TRUE = @am__fastdepCC_TRUE@ am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@ am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build = @build@ build_alias = @build_alias@ build_cpu = @build_cpu@ build_os = @build_os@ build_vendor = @build_vendor@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host = @host@ host_alias = @host_alias@ host_cpu = @host_cpu@ host_os = @host_os@ host_vendor = @host_vendor@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target = @target@ target_alias = @target_alias@ target_cpu = @target_cpu@ target_os = @target_os@ target_vendor = @target_vendor@ noinst_LIBRARIES = libsound.a INCLUDES = -I../eel -I../graphics @LOCALCFLAGS@ libsound_a_SOURCES = audio.c a_globals.c a_struct.c \ audiodev.c a_midi.c sfifo.c a_pitch.c a_midisock.c \ a_wave.c a_patch.c a_channel.c a_voice.c a_bus.c \ a_commands.c a_control.c a_midicon.c a_midifile.c \ a_plugin.c a_delay.c a_limiter.c a_filters.c \ a_wca.c a_agw.c a_sequencer.c a_events.c EXTRA_DIST = *.h all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \ && exit 0; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign sound/Makefile'; \ cd $(top_srcdir) && \ $(AUTOMAKE) --foreign sound/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) libsound.a: $(libsound_a_OBJECTS) $(libsound_a_DEPENDENCIES) -rm -f libsound.a $(libsound_a_AR) libsound.a $(libsound_a_OBJECTS) $(libsound_a_LIBADD) $(RANLIB) libsound.a mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_agw.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_bus.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_channel.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_commands.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_control.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_delay.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_events.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_filters.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_globals.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_limiter.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midi.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midicon.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midifile.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_midisock.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_patch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_pitch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_plugin.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_sequencer.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_struct.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_voice.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_wave.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/a_wca.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audiodev.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sfifo.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \ @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` uninstall-info-am: ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$tags $$unique; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) tags=; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) ' { files[$$0] = 1; } \ END { for (i in files) print i; }'`; \ test -z "$(CTAGS_ARGS)$$tags$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$tags $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && cd $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) $$here distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \ list='$(DISTFILES)'; for file in $$list; do \ case $$file in \ $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \ $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \ esac; \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \ if test "$$dir" != "$$file" && test "$$dir" != "."; then \ dir="/$$dir"; \ $(mkdir_p) "$(distdir)$$dir"; \ else \ dir=''; \ fi; \ if test -d $$d/$$file; then \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \ fi; \ cp -pR $$d/$$file $(distdir)$$dir || exit 1; \ else \ test -f $(distdir)/$$file \ || cp -p $$d/$$file $(distdir)/$$file \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(LIBRARIES) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstLIBRARIES mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am info: info-am info-am: install-data-am: install-exec-am: install-info: install-info-am install-man: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstLIBRARIES ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-exec install-exec-am install-info \ install-info-am install-man install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: KoboDeluxe-0.5.1/sound/audio.c0000666000175000001440000005522210731603055013102 00000000000000/*(GPL) --------------------------------------------------------------------------- audio.c - Public Audio Engine Interface --------------------------------------------------------------------------- * Written for SGI DMedia API by Masanao Izumo * Mostly rewritten by David Olofson , 2001 * * Copyright (C) 19??, Masanao Izumo * Copyright (C) 2001-2003, 2007 David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2.1 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kobolog.h" #include "a_globals.h" #include "config.h" #include #include #include #include #include #ifdef HAVE_OSS #include #include #include #ifdef OSS_USE_SOUNDCARD_H #include #else #include #endif #include "audiodev.h" #endif #include "SDL.h" #include "SDL_audio.h" #include "logger.h" #include "a_struct.h" #include "a_commands.h" #include "a_control.h" #include "a_pitch.h" #include "a_filters.h" #include "a_limiter.h" #include "a_midicon.h" #include "a_midi.h" #include "a_midifile.h" #include "a_sequencer.h" #include "a_agw.h" #include "a_events.h" /*---------------------------------------------------------- Engine stuff ----------------------------------------------------------*/ #ifdef HAVE_OSS static audiodev_t adev; static pthread_t engine_thread; #endif static int using_oss = 0; static int using_midi = 0; static int using_polling = 0; int _audio_pause = 1; /* * Note that a_settings.buffersize is in stereo samples! */ static int *mixbuf = NULL; static int *busbufs[AUDIO_MAX_BUSSES]; limiter_t limiter; /* Silent buffer for plugins */ int *audio_silent_buffer = NULL; #if defined(AUDIO_LOCKING) && defined(HAVE_OSS) static pthread_mutex_t _audio_mutex = PTHREAD_MUTEX_INITIALIZER; static int _audio_mutex_locked = 0; #endif /*---------------------------------------------------------- Timing/Sync code ----------------------------------------------------------*/ static int audio_last_callback = 0; /* Running timer (milliseconds) */ static double audio_timer = 0.0; /* Call this to nudge the current time towards 'ms'. */ static inline void sync_time(int ms) { if(labs((int)audio_timer - ms) > 1000) audio_timer = (double)ms; else audio_timer = audio_timer * 0.95 + (double)ms * 0.05; } /* Advance time by 'frames' audio samples. */ static inline void advance_time(int frames) { audio_timer += (double)frames * 1000.0 / (double)a_settings.samplerate; if(audio_timer >= 2147483648.0) audio_timer -= 4294967296.0; } /* Get current audio time in ms, wrapping Sint32. */ static int get_time(void) { return (Sint32)audio_timer; } int audio_next_callback(void) { return get_time() + a_settings.buffersize * 1000 / a_settings.samplerate; } /*---------------------------------------------------------- Engine code ----------------------------------------------------------*/ static int hold_until = 0; /* * This is where buffered asynchronous commands are * processed. Some of them turn directly into timestamped * events right here. */ static void _run_commands(void) { int d = hold_until - get_time(); if(labs(d) > 1000) hold_until = get_time(); else if(d > 0) return; while(sfifo_used(&commands) >= sizeof(command_t)) { command_t cmd; if(sfifo_read(&commands, &cmd, (unsigned)sizeof(cmd)) < 0) { log_printf(ELOG, "audio.c: Engine failure!\n"); _audio_running = 0; return; } switch(cmd.action) { case CMD_STOP: DBG2(log_printf(D3LOG, "%d: CMD_STOP\n", get_time());) (void)ce_stop(channeltab + cmd.cid, 0, cmd.tag, 32768); break; case CMD_STOP_ALL: DBG2(log_printf(D3LOG, "%d: CMD_STOP_ALL\n", get_time());) channel_stop_all(); break; case CMD_PLAY: DBG2(log_printf(D3LOG, "%d: CMD_PLAY\n", get_time());) (void)ce_start(channeltab + cmd.cid, 0, cmd.tag, cmd.arg1, cmd.arg2); break; case CMD_CCONTROL: DBG2(log_printf(D3LOG, "%d: CMD_CCONTROL\n", get_time());) (void)ce_control(channeltab + cmd.cid, 0, cmd.tag, cmd.index, cmd.arg1); break; case CMD_GCONTROL: DBG2(log_printf(D3LOG, "%d: CMD_GCONTROL\n", get_time());) acc_group_set((unsigned)cmd.cid, cmd.index, cmd.arg1); break; case CMD_MCONTROL: DBG2(log_printf(D3LOG, "%d: CMD_MCONTROL\n", get_time());) bus_ctl_set((unsigned)cmd.cid, (unsigned)cmd.arg1, cmd.index, cmd.arg2); break; case CMD_WAIT: DBG2(log_printf(D3LOG, "%d: CMD_WAIT", get_time());) hold_until = cmd.arg1; DBG2(log_printf(D3LOG, " (Holding until %d)\n", hold_until);) if(hold_until - get_time() > 0) return; break; } } } #define CLIP_MIN -32700 #define CLIP_MAX 32700 #if 0 /* * Convert with saturation */ static void _clip(Sint32 *inbuf, Sint16 *outbuf, unsigned frames) { unsigned i; frames <<= 1; for(i = 0; i < frames; i+=2) { int l = inbuf[i]; int r = inbuf[i+1]; if(l < CLIP_MIN) outbuf[i] = CLIP_MIN; else if(l > CLIP_MAX) outbuf[i] = CLIP_MAX; else outbuf[i] = l; if(r < CLIP_MIN) outbuf[i+1] = CLIP_MIN; else if(r > CLIP_MAX) outbuf[i+1] = CLIP_MAX; else outbuf[i+1] = r; } } #endif /* * Convert to Sint16; no saturation */ static void _s32tos16(Sint32 *inbuf, Sint16 *outbuf, unsigned frames) { unsigned i; frames <<= 1; for(i = 0; i < frames; i+=2) { int l = inbuf[i]; int r = inbuf[i+1]; outbuf[i] = (Sint16)l; outbuf[i+1] = (Sint16)r; } } #ifdef DEBUG static void _grab(Sint16 *buf, unsigned frames) { static int locktime = 0; static int trig = 0; unsigned i = 0; if(!trig) for(i = 0; i < frames-1; ++i) { int c1 = buf[i<<1] + buf[(i<<1)+1]; int c2 = buf[(i<<1)+2] + buf[(i<<1)+3]; if((c1 > 0) && (c2 < 0)) { trig = 1; break; } } if(locktime - SDL_GetTicks() > 200) trig = 1; if(!trig) return; for( ; i < frames; ++i) { oscbufl[oscpos] = buf[i<<1]; oscbufr[oscpos] = buf[(i<<1)+1]; ++oscpos; if(oscpos >= oscframes) { oscpos = 0; trig = 0; locktime = SDL_GetTicks(); break; } } } #endif #ifdef PROFILE_AUDIO # define DBGT(x) x /* * Replace with something else on non-x86 archs, or * compilers that don't understand this. Replacement * must have better resolution than 1 ms to be useful. * Unit is not important as calculations are relative. */ # if defined(__GNUC__) && defined(i386) inline int timestamp(void) { unsigned long long int x; __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x)); return x >> 8; } # else # ifdef HAVE_GETTIMEOFDAY # if TIME_WITH_SYS_TIME # include # include # else # if HAVE_SYS_TIME_H # include # else # include # endif # endif inline int timestamp(void) { struct timeval tv; gettimeofday(&tv, NULL); return tv.tv_sec * 1000000 + tv.tv_usec; } # else inline int timestamp(void) { return SDL_GetTicks(); } # endif # endif #else # define DBGT(x) #endif #ifdef PROFILE_AUDIO int audio_cpu_ticks = 333; float audio_cpu_total = 0.0; float audio_cpu_function[AUDIO_CPU_FUNCTIONS] = { 0,0,0,0,0,0,0,0,0,0 }; char audio_cpu_funcname[AUDIO_CPU_FUNCTIONS][20] = { "Async. Commands", "MIDI Input", "Sequencer", "MIDI -> Control", "Channel/Patch Proc.", "Voice Mixer", "Clearing Master Buf", "Bus & Mixdown", "Limiter Effect", "32 -> 16 bit Conv" }; #endif /* * Engine callback for SDL_audio and OSS */ static void _audio_callback(void *ud, Uint8 *stream, int len) { #ifdef PROFILE_AUDIO int i; int t[AUDIO_CPU_FUNCTIONS+2]; static int avgt[AUDIO_CPU_FUNCTIONS+1]; static int avgtotal; static int lastt = 0; static int last_out = 0; int adjust; int ticks; #define TS(x) t[x] = timestamp(); #else #define TS(x) #endif unsigned remaining_frames; Sint16 *outbuf = (Sint16 *)stream; audio_last_callback = SDL_GetTicks(); sync_time(audio_last_callback); if(_audio_pause) { memset(stream, 0, (unsigned)len); advance_time(len / (sizeof(Sint16) * 2)); return; } remaining_frames = len / sizeof(Sint16) / 2; while(remaining_frames) { unsigned frames; if(remaining_frames > a_settings.buffersize) frames = a_settings.buffersize; else frames = remaining_frames; remaining_frames -= frames; TS(0); TS(1); aev_client("_run_commands()"); _run_commands(); TS(2); aev_client("midi_process()"); if(using_midi) midi_process(); TS(3); /* This belongs in the MIDI patch plugin. */ aev_client("sequencer_process()"); sequencer_process(frames); TS(4); aev_client("midicon_process()"); midicon_process(frames); TS(5); aev_client("channel_process_all()"); channel_process_all(frames); TS(6); aev_client("voice_process_all()"); voice_process_all(busbufs, frames); TS(7); memset(mixbuf, 0, frames * sizeof(int) * 2); TS(8); aev_client("bus_process_all()"); bus_process_all(busbufs, mixbuf, frames); TS(9); lims_process(&limiter, mixbuf, mixbuf, frames); TS(10); _s32tos16(mixbuf, outbuf, frames); TS(11); #ifdef DEBUG _grab(outbuf, frames); #endif #ifdef PROFILE_AUDIO adjust = t[1] - t[0]; avgt[0] += t[1] - lastt; lastt = t[1]; if(!avgt[0]) avgt[0] = 1; for(i = 1; i <= AUDIO_CPU_FUNCTIONS; ++i) { int tt = t[i+1] - t[i] - adjust; if(tt > 0) { avgt[i] += tt; avgtotal += tt; } } ticks = SDL_GetTicks(); if((ticks-last_out) > audio_cpu_ticks) { for(i = 1; i <= AUDIO_CPU_FUNCTIONS; ++i) audio_cpu_function[i-1] = (float)avgt[i] * 100.0 / avgt[0]; audio_cpu_total = (float)avgtotal * 100.0 / avgt[0]; memset(avgt, 0, sizeof(avgt)); avgtotal = 0; last_out = ticks; } #undef TS #endif outbuf += frames * 2; aev_advance_timer(frames); advance_time(frames); } aev_client("Unknown"); } #ifdef HAVE_OSS /* * Engine thread for OSS */ int oss_outbufsize = 0; Sint16 *oss_outbuf = NULL; void *_audio_engine(void *dummy) { while(_audio_running) { # ifdef AUDIO_LOCKING pthread_mutex_lock(&_audio_mutex); # endif _audio_callback(NULL, (Uint8 *)oss_outbuf, oss_outbufsize); # ifdef AUDIO_LOCKING pthread_mutex_unlock(&_audio_mutex); # endif write(adev.outfd, oss_outbuf, oss_outbufsize); } audiodev_close(&adev); return NULL; } #endif /* * "Driver" call for polling mode. */ void audio_run(void) { #ifdef HAVE_OSS audio_buf_info info; if(!(using_oss && using_polling && _audio_running)) return; ioctl(adev.outfd, SNDCTL_DSP_GETOSPACE, &info); while(info.bytes >= oss_outbufsize) { _audio_callback(NULL, (Uint8 *)oss_outbuf, oss_outbufsize); write(adev.outfd, oss_outbuf, oss_outbufsize); info.bytes -= oss_outbufsize; } #endif } static int _start_oss_output() { #ifdef HAVE_OSS audiodev_init(&adev); adev.rate = a_settings.samplerate; adev.fragmentsize = a_settings.output_buffersize * sizeof(Sint16) * 2; adev.fragments = OSS_FRAGMENTS; _audio_running = 1; if(audiodev_open(&adev) < 0) { log_printf(ELOG, "audio.c: Failed to open audio!\n"); _audio_running = 0; return -2; } if(a_settings.output_buffersize > MAX_BUFFER_SIZE) a_settings.buffersize = MAX_BUFFER_SIZE; else a_settings.buffersize = a_settings.output_buffersize; free(mixbuf); mixbuf = calloc(1, a_settings.buffersize * sizeof(int) * 2); if(!mixbuf) return -1; oss_outbufsize = a_settings.output_buffersize * sizeof(Sint16) * 2; oss_outbuf = calloc(1, oss_outbufsize); if(!oss_outbuf) { audiodev_close(&adev); _audio_running = 0; log_printf(ELOG, "audio.c: Failed to allocate output buffer!\n"); return -4; } if(using_polling) return 0; //That's it! if(pthread_create(&engine_thread, NULL, _audio_engine, NULL)) { free(oss_outbuf); oss_outbuf = NULL; audiodev_close(&adev); log_printf(ELOG, "audio.c: Failed to start audio engine!\n"); return -3; } return 0; #else log_printf(ELOG, "OSS audio not compiled in!\n"); return -1; #endif } static int _start_SDL_output(void) { SDL_AudioSpec as; SDL_AudioSpec audiospec; if(SDL_InitSubSystem(SDL_INIT_AUDIO) < 0) return -2; as.freq = a_settings.samplerate; as.format = AUDIO_S16SYS; as.channels = 2; as.samples = (Uint16)a_settings.output_buffersize; as.callback = _audio_callback; if(SDL_OpenAudio(&as, &audiospec) < 0) return -3; if(audiospec.format != AUDIO_S16SYS) { log_printf(ELOG, "audio.c: ERROR: Only 16 bit output supported!\n"); SDL_CloseAudio(); return -4; } if(audiospec.channels != 2) { log_printf(ELOG, "audio.c: ERROR: Only stereo output supported!\n"); SDL_CloseAudio(); return -5; } if(a_settings.samplerate != audiospec.freq) { log_printf(ELOG, "audio.c: Warning: Requested fs=%d Hz, but" "got %d Hz.\n", a_settings.samplerate, audiospec.freq); a_settings.samplerate = audiospec.freq; } if((unsigned)audiospec.samples != a_settings.output_buffersize) { log_printf(ELOG, "audio.c: Warning: Requested %u sample" "buffer, but got %u samples.\n", a_settings.output_buffersize, audiospec.samples); a_settings.output_buffersize = audiospec.samples; } if(a_settings.output_buffersize > MAX_BUFFER_SIZE) a_settings.buffersize = MAX_BUFFER_SIZE; else a_settings.buffersize = a_settings.output_buffersize; free(mixbuf); mixbuf = calloc(1, a_settings.buffersize * sizeof(int) * 2); if(!mixbuf) { SDL_CloseAudio(); return -1; } _audio_running = 1; SDL_PauseAudio(0); return 0; } static int _mixing_open = 0; static void _close_mixing(void) { int i; if(!_mixing_open) return; /* KLUDGE */ lim_close(&limiter); for(i = 0; i < AUDIO_MAX_BUSSES; ++i) { free(busbufs[i]); busbufs[i] = NULL; } free(audio_silent_buffer); audio_silent_buffer = NULL; _mixing_open = 0; } static int _open_mixing(void) { unsigned bytes = a_settings.buffersize * sizeof(int) * 2; unsigned i; if(_mixing_open) return 0; for(i = 0; i < AUDIO_MAX_BUSSES; ++i) { busbufs[i] = calloc(1, bytes); if(!busbufs[i]) { _close_mixing(); return -1; } } audio_silent_buffer = calloc(1, bytes); if(!audio_silent_buffer) { _close_mixing(); return -2; } /* KLUDGE */ if(lim_open(&limiter, a_settings.samplerate) < 0) /* KLUDGE */ { /* KLUDGE */ _close_mixing(); /* KLUDGE */ return -3; /* KLUDGE */ } /* KLUDGE */ lim_control(&limiter, LIM_THRESHOLD, DEFAULT_LIM_THRESHOLD); /* KLUDGE */ lim_control(&limiter, LIM_RELEASE, DEFAULT_LIM_RELEASE); _mixing_open = 1; return 0; } static void _stop_output(void) { _audio_running = 0; if(using_oss) { #ifdef HAVE_OSS if(!using_polling) { # ifdef AUDIO_LOCKING if(_audio_mutex_locked) pthread_mutex_unlock(&_audio_mutex); # endif pthread_join(engine_thread, NULL); # ifdef AUDIO_LOCKING pthread_mutex_destroy(&_audio_mutex); _audio_mutex_locked = 0; # endif } free(oss_outbuf); oss_outbuf = NULL; #endif } else SDL_CloseAudio(); free(mixbuf); mixbuf = NULL; } #ifdef AUDIO_LOCKING /* * This sucks. The engine should *never* be locked! * * Using the API mostly results in single-reader/single-writer * situations (the *API* is not guaranteed to be thread safe!), * so we just need to do things in the right order. */ void audio_lock(void) { if(using_oss) { #ifdef HAVE_OSS if(using_polling) return; if(!_audio_mutex_locked) pthread_mutex_lock(&_audio_mutex); ++_audio_mutex_locked; #endif } else SDL_LockAudio(); } void audio_unlock(void) { if(using_oss) { #ifdef HAVE_OSS if(using_polling) return; if(_audio_mutex_locked) { --_audio_mutex_locked; if(!_audio_mutex_locked) pthread_mutex_unlock(&_audio_mutex); } #endif } else SDL_UnlockAudio(); } #endif /*---------------------------------------------------------- Open/close code ----------------------------------------------------------*/ static int _wasinit = 0; int audio_open(void) { if(_wasinit) return 0; aev_client("audio_open()"); audio_wave_open(); audio_patch_open(); audio_group_open(); /* NOTE: AGW will auto-initialize if used! */ _wasinit = 1; return 0; } int audio_start(int rate, int latency, int use_oss, int use_midi, int pollaudio) { int i, fragments; if(audio_open() < 0) return -100; audio_stop(); aev_client("audio_start()"); a_settings.samplerate = rate; using_oss = use_oss; using_polling = pollaudio; if(sfifo_init(&commands, sizeof(command_t) * MAX_COMMANDS) < 0) { log_printf(ELOG, "audio.c: Failed to set up audio engine!\n"); return -1; } if(ptab_init(65536) < 0) { log_printf(ELOG, "audio.c: Failed to set up pitch table!\n"); sfifo_close(&commands); return -2; } audio_channel_open(); audio_voice_open(); audio_bus_open(); if(aev_open(AUDIO_MAX_VOICES * MAX_BUFFER_SIZE) < 0) { audio_stop(); return -1; } if(using_oss) fragments = OSS_FRAGMENTS; else fragments = SDL_FRAGMENTS; if(latency > 1000) latency = 1000; a_settings.output_buffersize = MIN_BUFFER_SIZE; /* We use 707 instead of 1000 for correct rounding. */ while(fragments * a_settings.output_buffersize * 707 / a_settings.samplerate < latency) a_settings.output_buffersize <<= 1; a_settings.output_buffersize >>= 1; log_printf(DLOG, "audio.c: Requested latency %d ms ==>" " buffer size: %d samples;" " latency: %.2f ms (error: %.2f).\n", latency, a_settings.output_buffersize, fragments * a_settings.output_buffersize * 1000.0 / a_settings.samplerate, fabs(latency - fragments * a_settings.output_buffersize * 1000.0 / a_settings.samplerate) ); _audio_pause = 1; /* Don't touch anything yet! */ if(using_polling && !using_oss) { log_printf(ELOG, "WARNING: Overriding driver selection!" " 'pollaudio' requires OSS.\n"); using_oss = 1; } if(using_oss) i = _start_oss_output(); else i = _start_SDL_output(); if(i < 0) { audio_stop(); return -6; } if(_open_mixing() < 0) { audio_stop(); return -5; } #ifdef DEBUG oscbufl = calloc(1, OSCFRAMES*sizeof(int)); oscbufr = calloc(1, OSCFRAMES*sizeof(int)); oscframes = OSCFRAMES; #endif midicon_open((float)a_settings.samplerate, 16); if(use_midi) using_midi = midi_open(&midicon_midisock) >= 0; else using_midi = 0; sequencer_open(&midicon_midisock, (float)a_settings.samplerate); audio_wave_prepare(-1); /* Update "natural speeds" and stuff... */ aev_reset_timer(); /* Reset event system timer */ aev_client("Unknown"); _audio_pause = 0; /* GO! */ _wasinit = 1; return 0; } void audio_stop(void) { if(_audio_running) { log_printf(VLOG, "Stopping audio engine...\n"); _audio_pause = 1; _stop_output(); } _close_mixing(); sequencer_close(); if(using_midi) midi_close(); midicon_close(); ptab_close(); sfifo_close(&commands); #ifdef DEBUG oscframes = 0; free(oscbufl); free(oscbufr); oscbufl = NULL; oscbufr = NULL; #endif audio_bus_close(); audio_voice_close(); audio_channel_close(); aev_close(); } void audio_close(void) { if(!_wasinit) return; audio_stop(); agw_close(); audio_group_close(); audio_patch_close(); audio_wave_close(); _wasinit = 0; } /*---------------------------------------------------------- Engine Control ----------------------------------------------------------*/ void audio_quality(audio_quality_t quality) { a_settings.quality = quality; } void audio_set_limiter(float thres, float rels) { int t, r; t = (int)(32768.0 * thres); if(t < 256) t = 256; r = (int)(rels * 65536.0); lim_control(&limiter, LIM_THRESHOLD, t); lim_control(&limiter, LIM_RELEASE, r); } /*---------------------------------------------------------- Engine Debugging Stuff ----------------------------------------------------------*/ #ifdef DEBUG static void print_accbank(accbank_t *ctl, int is_group) { const char names[ACC_COUNT][8] = { "GRP", "PRI", "PATCH", "PBUS", "SBUS", "PAN", "PITCH", "VOL", "SEND", "MOD1", "MOD2", "MOD3", "X", "Y", "Z" }; int i; if(is_group) i = ACC_PAN; else i = 0; for(; i < ACC_COUNT; ++i) { log_printf(DLOG, "%s=", names[i]); if(ACC_IS_FIXEDPOINT(i)) log_printf(DLOG, "%.4g ", (double)((*ctl)[i]/65536.0)); else log_printf(DLOG, "%d ", (*ctl)[i]); } } static void print_vc(audio_voice_t *v) { const char names[VC_COUNT][8] = { "WAVE", "LOOP", "PITCH", "RETRIG", "RANDTR", "PBUS", "SBUS" }; const char inames[VIC_COUNT][8] = { "LVOL", "RVOL", "LSEND", "RSEND" }; int i; for(i = 0; i < VC_COUNT; ++i) { log_printf(DLOG, "%s=", names[i]); switch(i) { case VC_PITCH: case VC_RANDTRIG: log_printf(DLOG, "%.4g ", (double)(v->c[i]/65536.0)); break; default: log_printf(DLOG, "%d ", v->c[i]); break; } } for(i = 0; i < VIC_COUNT; ++i) { log_printf(DLOG, "%s=", inames[i]); log_printf(DLOG, "%.4g ", (double)(v->ic[i].v/(65536.0*128.0))); } } static void print_voices(int channel) { int i; for(i = 0; i < AUDIO_MAX_VOICES; ++i) if(channel == -1 || (voicetab[i].channel == (channeltab + channel) && (voicetab[i].state != VS_STOPPED)) ) { if((channel == -1) && (voicetab[i].state != VS_STOPPED)) log_printf(DLOG, " ==>"); else log_printf(DLOG, " -"); log_printf(DLOG, "VOICE %.2d: ", i); print_vc(&voicetab[i]); log_printf(DLOG, "\n"); } } static void print_channels(int group) { int i; for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { if(channeltab[i].ctl[ACC_GROUP] != group) continue; log_printf(DLOG, " -CHANNEL %.2d: ", i); print_accbank(&channeltab[i].rctl, 0); log_printf(DLOG, "\n"); log_printf(DLOG, " Transf.: "); print_accbank(&channeltab[i].ctl, 0); log_printf(DLOG, "\n"); print_voices(i); } } static int group_in_use(int group) { int i; for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { if(channeltab[i].ctl[ACC_GROUP] == group) return 1; } return 0; } void audio_print_info(void) { int i; log_printf(DLOG, "--------------------------------------" "--------------------------------------\n"); log_printf(DLOG, "Audio Engine Info:\n"); for(i = 0; i < AUDIO_MAX_GROUPS; ++i) { if(!group_in_use(i)) continue; log_printf(DLOG, "-GROUP %.2d-----------------------------" "--------------------------------------\n", i); log_printf(DLOG, " ctl: "); print_accbank(&grouptab[i].ctl, 1); log_printf(DLOG, "\n def: "); print_accbank(&grouptab[i].ctl, 1); log_printf(DLOG, "\n"); print_channels(i); } log_printf(DLOG, "--------------------------------------" "--------------------------------------\n"); #if 0 print_voices(-1); log_printf(DLOG, "--------------------------------------" "--------------------------------------\n"); #endif } #endif KoboDeluxe-0.5.1/sound/a_globals.c0000644000175000001440000000517407502603247013726 00000000000000/*(GPL) --------------------------------------------------------------------------- audio_p.c - Private global audio engine stuff --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2.1 of the License, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "a_globals.h" /* For debug oscilloscope */ #ifdef DEBUG int *oscbufl = NULL; int *oscbufr = NULL; int oscframes = 0; int oscpos = 0; #endif int _audio_running = 0; /* Global engine settings: defaults */ struct settings_t a_settings = { 44100, /* samplerate */ 256, /* output_buffersize */ 32, /* buffersize */ AQ_HIGH /* quality */ }; /* * Default control values */ accbank_t a_channel_def_ctl = { 0, /* ACC_GROUP */ 1000, /* ACC_PRIORITY */ 0, /* ACC_PATCH */ 0, /* ACC_PRIM_BUS */ -1, /* ACC_SEND_BUS [Off] */ 0, /* ACC_PAN [0.0] */ 60<<16, /* ACC_PITCH [1.0 * sample_rate] */ 65536, /* ACC_VOLUME [1.0] */ 0, /* ACC_SEND [0.0] */ 0, /* ACC_MOD1 [0.0] */ 0, /* ACC_MOD2 [0.0] */ 0, /* ACC_MOD3 [0.0] */ 0, /* ACC_X [0.0] */ 0, /* ACC_Y [0.0] */ 0 /* ACC_Z [0.0] */ }; accbank_t a_group_def_ctl = { 0, /* ACC_GROUP */ 1000, /* ACC_PRIORITY */ 0, /* ACC_PATCH */ 0, /* ACC_PRIM_BUS */ -1, /* ACC_SEND_BUS [Off] */ 0, /* ACC_PAN [0.0] */ 60<<16, /* ACC_PITCH [1.0 * sample_rate] */ 65536, /* ACC_VOLUME [1.0] */ 65536, /* ACC_SEND [1.0] */ 0, /* ACC_MOD1 [0.0] */ 0, /* ACC_MOD2 [0.0] */ 0, /* ACC_MOD3 [0.0] */ 0, /* ACC_X [0.0] */ 0, /* ACC_Y [0.0] */ 0 /* ACC_Z [0.0] */ }; abcbank_t a_bus_def_ctl = { 0, /* ABC_FX_TYPE[None - allpass] */ 0, /* ABC_FX_PARAM_1 */ 0, /* ABC_FX_PARAM_2 */ 0, /* ABC_FX_PARAM_3 */ 0, /* ABC_FX_PARAM_4 */ 0, /* ABC_FX_PARAM_5 */ 0, /* ABC_FX_PARAM_6 */ 0, /* ABC_SEND_MASTER */ 0, /* ABC_SEND_BUS_0 */ 0, /* ABC_SEND_BUS_1 */ 0, /* ABC_SEND_BUS_2 */ 0, /* ABC_SEND_BUS_3 */ 0, /* ABC_SEND_BUS_4 */ 0, /* ABC_SEND_BUS_5 */ 0, /* ABC_SEND_BUS_6 */ 0 /* ABC_SEND_BUS_7 */ }; KoboDeluxe-0.5.1/sound/a_struct.c0000644000175000001440000000267107503021675013626 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_struct.c - Audio Engine internal structures --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_globals.h" #include "a_struct.h" #include "a_control.h" /*---------------------------------------------------------- Engine Global Data ----------------------------------------------------------*/ audio_wave_t wavetab[AUDIO_MAX_WAVES]; audio_patch_t patchtab[AUDIO_MAX_PATCHES]; audio_voice_t voicetab[AUDIO_MAX_VOICES]; audio_group_t grouptab[AUDIO_MAX_GROUPS]; audio_channel_t channeltab[AUDIO_MAX_CHANNELS]; audio_bus_t bustab[AUDIO_MAX_BUSSES]; KoboDeluxe-0.5.1/sound/audiodev.c0000666000175000001440000000731407670702526013613 00000000000000/* ------------------------------------------------------------ audiodev.h: Little silly audio device "class" ------------------------------------------------------------ * Copyright (C) David Olofson, 1999, 2001 * This code is released under the terms of the LGPL */ #include "audiodev.h" #include "kobolog.h" #include #ifndef HAVE_OSS void audiodev_init(struct audiodev_t *ad) { log_printf(ELOG, "OSS sound output not compiled in!\n"); } int audiodev_open(struct audiodev_t *ad) { return -1; } void audiodev_close(struct audiodev_t *ad) { } #else /* HAVE_OSS */ #include #include #include #include #include #ifdef OSS_USE_SOUNDCARD_H #include #else #include #endif void audiodev_init(struct audiodev_t *ad) { ad->devicename = "/dev/dsp"; ad->mode = O_WRONLY; ad->rate = 44100; ad->fragmentsize = 256; ad->fragments = 4; ad->infd = ad->outfd = 0; } /* Open the audio device */ int audiodev_open(struct audiodev_t *ad) { int r,v; struct audio_buf_info abinfo; int fragmentshift; fragmentshift=(int)floor((log(ad->fragmentsize)/log(2.0))+0.5); if(fragmentshift < 4) fragmentshift = 4; log_printf(DLOG, " Fragment size: %d bytes\n", 1<outfd = ad->infd = open(ad->devicename, ad->mode | O_NONBLOCK); if(ad->outfd < 0) { log_printf(ELOG, "Failed to open audio device!\n"); return -1; } if(!(ad->mode & O_NONBLOCK)) { r = fcntl(ad->outfd, F_SETFL, ad->mode); if(r < 0) { log_printf(ELOG, "Failed to set blocking mode!\n"); close(ad->outfd); return -2; } } r = ioctl(ad->outfd, SNDCTL_DSP_RESET, NULL); if(r < 0) { log_printf(ELOG, "Failed to reset device!\n"); close(ad->outfd); return -2; } /* Redundant? */ v = 16; r = ioctl(ad->outfd, SNDCTL_DSP_SAMPLESIZE, &v); if(r < 0) { log_printf(ELOG, "16 bit samples not supported!\n"); close(ad->outfd); return -2; } v = AFMT_S16_LE; r = ioctl(ad->outfd, SNDCTL_DSP_SETFMT, &v); if(r < 0) { log_printf(ELOG, "Failed to set sample format!\n"); close(ad->outfd); return -3; } else if(v != AFMT_S16_LE) { log_printf(ELOG, "16 bit stereo LE not supported!\n"); close(ad->outfd); return -4; } v = 1; r = ioctl(ad->outfd, SNDCTL_DSP_STEREO, &v); if(r < 0) { log_printf(ELOG, "Stereo not supported!\n"); close(ad->outfd); return -5; } v = ad->rate; r = ioctl(ad->outfd, SNDCTL_DSP_SPEED, &v); if(r < 0) { log_printf(ELOG, "Failed to set %d Hz sample rate!\n", ad->rate); close(ad->outfd); return -6; } if(O_RDWR == ad->mode) { r = ioctl(ad->outfd, SNDCTL_DSP_SETDUPLEX, NULL); if(r < 0) { log_printf(ELOG, "Full duplex not supported!\n"); close(ad->outfd); return -4; } v = ((ad->fragments+2) << 16) | fragmentshift; } else v = ((ad->fragments) << 16) | fragmentshift; r = ioctl(ad->outfd, SNDCTL_DSP_SETFRAGMENT, &v); if(r < 0) { log_printf(ELOG, "Failed to set fragment size/count!\n"); close(ad->outfd); return -5; } r = ioctl(ad->outfd, SNDCTL_DSP_GETOSPACE, &abinfo); if(r >= 0) { log_printf(DLOG, " Driver: fragments = %d, fragsize = %d\n", abinfo.fragstotal, abinfo.fragsize); if( (abinfo.fragstotal != ad->fragments) && (O_RDWR != ad->mode) ) log_printf(WLOG, "Number of fragments is %d, " "not %d as requested.\n", abinfo.fragstotal, ad->fragments); if(abinfo.fragsize != ad->fragmentsize) log_printf(WLOG, "Fragment size is %d, " "not %d as requested.\n", abinfo.fragsize, ad->fragmentsize); } return 0; } void audiodev_close(struct audiodev_t *ad) { if( (ad->infd != ad->outfd) && ad->infd ) close(ad->infd); if(ad->outfd) close(ad->outfd); ad->infd = ad->outfd = 0; } #endif /* HAVE_OSS */ KoboDeluxe-0.5.1/sound/a_midi.c0000644000175000001440000001426507670676652013246 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_midi.c - midi_socket_t MIDI Input Driver for OSS or ALSA --------------------------------------------------------------------------- * Copyright (C) 2001, 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * NOTE: This code will build for ALSA *or* OSS, in that order of preference. */ #include "config.h" #include #include #include "kobolog.h" #include "a_midi.h" #ifdef HAVE_ALSA # include # define USE_MIDI #elif defined(HAVE_OSS) # include # include # define USE_MIDI #else # undef USE_MIDI #endif #define MDBG(x) #define MDBG2(x) #ifdef USE_MIDI /* MIDI open/close */ #ifdef HAVE_ALSA static snd_rawmidi_t *m_in_fd = NULL; static snd_rawmidi_t *m_out_fd = NULL; #elif defined(HAVE_OSS) static int m_fd = 0; #endif /* MIDI I/O */ #ifdef HAVE_ALSA # define midi_read(b,s) snd_rawmidi_read(m_in_fd, b, s) # define midi_write(b,s) snd_rawmidi_write(m_out_fd, b, s) #elif defined(HAVE_OSS) # define midi_read(b,s) read(m_fd, b, s) # define midi_write(b,s) write(m_fd, b, s) #endif /* * Basic real time MIDI parsing */ static midisock_t *ms; static midisock_t *mon; /* Global state stuff - *not* per channel! */ static int m_channel = 0; /* current channel */ static int m_datacount = 0; /* current data byte */ static char m_status = 0; /* current (last seen) status */ static char m_buf[3]; /* space for data bytes */ static int m_expect = -1; /* expected message data length */ static inline void decode_midi_message(void) { /* Seems like we've got a complete message! */ int val; switch(m_status & 0xf0) { case 0x80: /* Note off */ MDBG2(mon->note_off(m_channel, m_buf[0], m_buf[1]);) ms->note_off(m_channel, m_buf[0], m_buf[1]); break; case 0x90: /* Note on */ MDBG2(mon->note_on(m_channel, m_buf[0], m_buf[1]);) ms->note_on(m_channel, m_buf[0], m_buf[1]); break; case 0xa0: /* Poly pressure */ MDBG2(mon->poly_pressure(m_channel, m_buf[0], m_buf[1]);) ms->poly_pressure(m_channel, m_buf[0], m_buf[1]); break; case 0xb0: /* Control change */ MDBG2(mon->control_change(m_channel, m_buf[0], m_buf[1]);) ms->control_change(m_channel, m_buf[0], m_buf[1]); break; case 0xc0: /* Program change */ MDBG2(mon->program_change(m_channel, m_buf[0]);) ms->program_change(m_channel, m_buf[0]); break; case 0xd0: /* Channel pressure */ MDBG2(mon->channel_pressure(m_channel, m_buf[0]);) ms->channel_pressure(m_channel, m_buf[0]); break; case 0xe0: /* Pitch bend */ val = ((m_buf[1] << 7) | m_buf[0]) - 8192; MDBG2(mon->pitch_bend(m_channel, val);) ms->pitch_bend(m_channel, val); break; case 0xf0: /* System message */ break; } m_datacount = 0; } static const int full_xtab[8] = { 2, /* 0x80/0: Note off, */ 2, /* 0x90/1: Note on */ 2, /* 0xa0/2: Poly pressure */ 2, /* 0xb0/3: Control change */ 1, /* 0xc0/4: Program change */ 1, /* 0xd0/5: Channel pressure */ 2, /* 0xe0/6: Pitch bend */ -1 /* 0xf0/7: System message (unsupported) */ }; static int xtab[8]; static inline void decode_midi_byte(unsigned char b) { if(b & 0x80) /* New status! */ { MDBG(log_printf(D3LOG, "\n%2.2X", b & 0xff)); m_status = b; m_datacount = 0; m_channel = b & 0x0f; m_expect = xtab[(m_status >> 4) & 0x07]; return; } MDBG(log_printf(D3LOG, " %2.2X", b)); if(m_expect < 0) return; /* Ignore --> */ m_buf[m_datacount++] = b; if(m_datacount >= m_expect) decode_midi_message(); } #endif /*USE_MIDI*/ int midi_open(midisock_t *output) { #ifdef USE_MIDI if(!output) output = &dummy_midisock; ms = output; /* * Set up the message length table to ignore messages * that aren't supported by the output midisock. */ memset(xtab, -1, sizeof(xtab)); if(output->note_off) xtab[0] = full_xtab[0]; if(output->note_on) xtab[1] = full_xtab[1]; if(output->poly_pressure) xtab[2] = full_xtab[2]; if(output->control_change) xtab[3] = full_xtab[3]; if(output->program_change) xtab[4] = full_xtab[4]; if(output->channel_pressure) xtab[5] = full_xtab[5]; if(output->pitch_bend) xtab[6] = full_xtab[6]; mon = &monitor_midisock; #ifdef HAVE_ALSA if(snd_rawmidi_open(&m_in_fd, 0, 0, SND_RAWMIDI_OPEN_INPUT | SND_RAWMIDI_OPEN_NONBLOCK)) { log_printf(ELOG, "Failed to open MIDI input device!\n"); return -1; } # ifdef MIDI_THRU if(snd_rawmidi_open(&m_out_fd, 0, 0, SND_RAWMIDI_OPEN_OUTPUT)) { log_printf(ELOG, "Failed to open MIDI output device!\n"); return -2; } # endif return 0; #elif defined(HAVE_OSS) { # ifdef MIDI_THRU int flags = O_RDWR | O_NONBLOCK; # else int flags = O_RDONLY | O_NONBLOCK; # endif m_fd = open("/dev/midi00", flags); if(m_fd < 0) { log_printf(ELOG, "Failed to open MIDI device!\n"); return -1; } return 0; } #endif /*HAVE_OSS*/ #else /*USE_MIDI*/ log_printf(ELOG, "MIDI support not compiled in!\n"); return -3; #endif /*USE_MIDI*/ } void midi_close(void) { #ifdef USE_MIDI #ifdef HAVE_ALSA if(m_in_fd) { snd_rawmidi_input_flush(m_in_fd); snd_rawmidi_close(m_in_fd); } if(m_out_fd) { snd_rawmidi_output_flush(m_out_fd); snd_rawmidi_close(m_out_fd); } m_in_fd = m_out_fd = NULL; #elif defined(HAVE_OSS) if(m_fd) close(m_fd); m_fd = 0; #endif #endif /*USE_MIDI*/ } void midi_process(void) { #ifdef USE_MIDI int bytes; static char buf[MIDIMAXBYTES]; if( (bytes = midi_read(buf, MIDIMAXBYTES)) > 0 ) { char *bufp = buf; #ifdef MIDI_THRU midi_write(buf, bytes); /* MIDI Thru */ #endif while(bytes--) decode_midi_byte(*bufp++); } #endif /*USE_MIDI*/ } KoboDeluxe-0.5.1/sound/sfifo.c0000666000175000001440000001343007502731641013107 00000000000000/* ------------------------------------------------------------ SFIFO 1.4 ------------------------------------------------------------ * Simple portable lock-free FIFO * (c) 2000-2002, David Olofson ----------------------------------------------------------- TODO: * Is there a way to avoid losing one byte of buffer space to avoid extra variables or locking? * Test more compilers and environments. ----------------------------------------------------------- */ #ifdef __KERNEL__ # include # include # include # define _sf_malloc(x) kmalloc(x, GFP_KERNEL) # define _sf_free(x, y) kfree_s(x, y) #else # include # include # define _sf_malloc(x) malloc(x) # define _sf_free(x, y) free(x) #endif #include "sfifo.h" #ifdef _SFIFO_TEST_ #include #include #include #define DBG(x) /*(x)*/ #define TEST_BUFSIZE 10 #else #define DBG(x) #endif /* * Alloc buffer, init FIFO etc... */ int sfifo_init(sfifo_t *f, unsigned size) { memset(f, 0, sizeof(sfifo_t)); if(size > SFIFO_MAX_BUFFER_SIZE) return -EINVAL; /* * Set sufficient power-of-2 size. * * No, there's no bug. If you need * room for N bytes, the buffer must * be at least N+1 bytes. (The fifo * can't tell 'empty' from 'full' * without unsafe index manipulations * otherwise.) */ f->size = 1; for(; f->size <= size; f->size <<= 1) ; /* Get buffer */ if( 0 == (f->buffer = (void *)_sf_malloc(f->size)) ) return -ENOMEM; return 0; } /* * Dealloc buffer etc... */ void sfifo_close(sfifo_t *f) { if(f->buffer) { _sf_free(f->buffer, f->size); memset(f, 0, sizeof(sfifo_t)); } } /* * Empty FIFO buffer */ void sfifo_flush(sfifo_t *f) { /* Reset positions */ f->readpos = 0; f->writepos = 0; } /* * Write bytes to a FIFO * Return number of bytes written, or an error code */ int sfifo_write(sfifo_t *f, const void *_buf, unsigned len) { unsigned total; int i; const char *buf = (const char *)_buf; if(!f->buffer) return -ENODEV; /* No buffer! */ /* total = len = min(space, len) */ total = sfifo_space(f); DBG(printf("sfifo_space() = %d\n",total)); if(len > total) len = total; else total = len; i = f->writepos; if(i + len > f->size) { memcpy(f->buffer + i, buf, f->size - i); buf += f->size - i; len -= f->size - i; i = 0; } memcpy(f->buffer + i, buf, len); f->writepos = i + len; return (int)total; } #ifdef __KERNEL__ /* * Write bytes to a FIFO from a user space buffer * Return number of bytes written, or an error code */ int sfifo_write_user(sfifo_t *f, const void *buf, unsigned len) { int total; int i; if(!f->buffer) return -ENODEV; /* No buffer! */ /* total = len = min(space, len) */ total = sfifo_space(f); if(len > total) len = total; else total = len; i = f->writepos; if(i + len > f->size) { if(f->size - i) { if(copy_from_user(f->buffer + i, buf, f->size - i)) return -EFAULT; buf += f->size - i; len -= f->size - i; } i = 0; } if(copy_from_user(f->buffer + i, buf, len)) return -EFAULT; f->writepos = i + len; return total; } #endif /* * Read bytes from a FIFO * Return number of bytes read, or an error code */ int sfifo_read(sfifo_t *f, void *_buf, unsigned len) { unsigned total; int i; char *buf = (char *)_buf; if(!f->buffer) return -ENODEV; /* No buffer! */ /* total = len = min(used, len) */ total = sfifo_used(f); DBG(printf("sfifo_used() = %d\n",total)); if(len > total) len = total; else total = len; i = f->readpos; if(i + len > f->size) { memcpy(buf, f->buffer + i, f->size - i); buf += f->size - i; len -= f->size - i; i = 0; } memcpy(buf, f->buffer + i, len); f->readpos = i + len; return (int)total; } #ifdef __KERNEL__ /* * Read bytes from a FIFO into a user space buffer * Return number of bytes read, or an error code */ int sfifo_read_user(sfifo_t *f, void *buf, unsigned len) { int total; int i; if(!f->buffer) return -ENODEV; /* No buffer! */ /* total = len = min(used, len) */ total = sfifo_used(f); if(len > total) len = total; else total = len; i = f->readpos; if(i + len > f->size) { if(f->size - i) { if(copy_to_user(buf, f->buffer + i, f->size - i)) return -EFAULT; buf += f->size - i; len -= f->size - i; } i = 0; } if(copy_to_user(buf, f->buffer + i, len)) return -EFAULT; f->readpos = i + len; return total; } #endif #ifdef _SFIFO_TEST_ void *sender(void *arg) { char buf[TEST_BUFSIZE*2]; int i,j; int cnt = 0; int res; sfifo_t *sf = (sfifo_t *)arg; while(1) { j = sfifo_space(sf); for(i = 0; i < j; ++i) { ++cnt; buf[i] = cnt; } res = sfifo_write(sf, &buf, j); if(res != j) { printf("Write failed!\n"); sleep(1); } else if(res) printf("Wrote %d\n", res); } } int main() { sfifo_t sf; char last = 0; pthread_t thread; char buf[100] = "---------------------------------------"; printf("sfifo_init(&sf, %d) = %d\n", TEST_BUFSIZE, sfifo_init(&sf, TEST_BUFSIZE) ); #if 0 printf("sfifo_write(&sf,\"0123456789\",7) = %d\n", sfifo_write(&sf,"0123456789",7) ); printf("sfifo_write(&sf,\"abcdefghij\",7) = %d\n", sfifo_write(&sf,"abcdefghij",7) ); printf("sfifo_read(&sf,buf,8) = %d\n", sfifo_read(&sf,buf,8) ); buf[20] = 0; printf("buf =\"%s\"\n",buf); printf("sfifo_write(&sf,\"0123456789\",7) = %d\n", sfifo_write(&sf,"0123456789",7) ); printf("sfifo_read(&sf,buf,10) = %d\n", sfifo_read(&sf,buf,10) ); buf[20] = 0; printf("buf =\"%s\"\n",buf); #else pthread_create(&thread, NULL, sender, &sf); while(1) { static int c = 0; ++last; while( sfifo_read(&sf,buf,1) != 1 ) /*sleep(1)*/; if(last != buf[0]) { printf("Error %d!\n", buf[0]-last); last = buf[0]; } else printf("Ok. (%d)\n",++c); } #endif sfifo_close(&sf); printf("sfifo_close(&sf)\n"); return 0; } #endif KoboDeluxe-0.5.1/sound/a_pitch.c0000644000175000001440000000320110711176130013367 00000000000000/* --------------------------------------------------------------------------- a_pitch.c - Simple fixed point linear pitch table. --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_globals.h" #include "a_pitch.h" /* * Start pitch, based on the assumption that 1.0 (original * sample playback speed) gives you a middle C (MIDI #60). */ #define FIVE_OCTAVES (1 << 5) /* 1 + twelfth root of two */ #define SEMITONE_MULTIPLIER 1.0594630943592953 int *__pitchtab = NULL; int ptab_init(int middle_c) { int p; double pitch; free(__pitchtab); __pitchtab = malloc(129 * sizeof(int)); if(!__pitchtab) return -1; pitch = (double)middle_c / FIVE_OCTAVES; for(p = 0; p < 129; ++p) { __pitchtab[p] = (int)pitch; pitch *= SEMITONE_MULTIPLIER; } return 0; } void ptab_close(void) { free(__pitchtab); __pitchtab = NULL; } KoboDeluxe-0.5.1/sound/a_midisock.c0000644000175000001440000001266407670676617014130 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_midisock.c - Generic Interface for Modular MIDI Management --------------------------------------------------------------------------- * Copyright (C) 2001, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_midisock.h" #include "kobolog.h" /*---------------------------------------------------------- Dummy MIDI Socket implementation ----------------------------------------------------------*/ static void dummy_note_off(unsigned ch, unsigned pitch, unsigned vel) {} static void dummy_note_on(unsigned ch, unsigned pitch, unsigned vel) {} static void dummy_poly_pressure(unsigned ch, unsigned pitch, unsigned press) {} static void dummy_control_change(unsigned ch, unsigned ctrl, unsigned amt) {} static void dummy_program_change(unsigned ch, unsigned prog) {} static void dummy_channel_pressure(unsigned ch, unsigned press) {} static void dummy_pitch_bend(unsigned ch, int amt) {} midisock_t dummy_midisock = { dummy_note_off, dummy_note_on, dummy_poly_pressure, dummy_control_change, dummy_program_change, dummy_channel_pressure, dummy_pitch_bend }; /*---------------------------------------------------------- Monitor MIDI Socket implementation ----------------------------------------------------------*/ static const char notenames[12][4] = { "C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-" }; static const char *controlnames[128] = { /*0..7*/ "Bank Select MSB", "Modulation", "Breath Controller", NULL, "Foot Controller", "Portamento Time", "Data Entry MSB", "Volume", /*8..15*/ "Balance", NULL, "Pan", "Expression", "FX Control 1", "FX Control 2", NULL, NULL, /*16..23*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*24..31*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*32..39*/ "Bank Select LSB", NULL, NULL, NULL, NULL, NULL, "Data Entry LSB", "BC: Select Insert Slot", /*40..47*/ "BC: IFX Type", "BC: IFX Param 1 (Time 1)", "BC: IFX Param 2 (Time 2)", "BC: IFX Param 3 (Depth 1)", "BC: IFX Param 4 (Depth 2)", "BC: IFX Param 5 (Rate)", "BC: IFX Param 6 (Mode)", "BC: Send to Master", /*48..55*/ "BC: Send to Bus 1", "BC: Send to Bus 2", "BC: Send to Bus 3", "BC: Send to Bus 4", "BC: Send to Bus 5", "BC: Send to Bus 6", "BC: Send to Bus 7", "BC: Send to Bus 8", /*56..63*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*64..71*/ "Hold 1", "Portamento", "Sostenuto", "Soft Pedal", "Legato", "Hold 2", "SC 1", "SC 2: Harmonic Content", /*72..79*/ "SC 3: Release Time", "SC 4: Attack Time", "SC 5: Brightness", NULL, NULL, NULL, NULL, NULL, /*80..87*/ NULL, NULL, NULL, NULL, "Portamento Control", NULL, NULL, NULL, /*88..95*/ "BC: Primary Bus Select", "BC: Send Bus Select", NULL, "FX 1 Depth: Reverb", "FX 2 Depth", "FX 3 Depth: Chorus", "FX 4 Depth: Variation", "FX 5 Depth", /*96..103*/ "RPN Increment", "RPN Decrement", "NRPN LSB", "NRPN MSB", "RPN LSB", "RPN MSB", NULL, NULL, /*104..111*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*112..119*/ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /*120..127*/ "All Sound Off", "Reset All Controllers", NULL, "All Notes Off", "Omni Off", "Omni On", "Mono", "Poly" }; #if 0 #define KNOWN_RPNS 5 static const char RPNnames[KNOWN_RPNS][24] = { "Pitch Bend Sensitivity", "Fine Tuning", "Coarse Tuning", "Tuning Program Select", "Tuning Bank Select" }; #endif static void monitor_note_off(unsigned ch, unsigned pitch, unsigned vel) { log_printf(DLOG, "NoteOff(%u, %s%u(%u), %u)\n", ch, notenames[pitch % 12], pitch / 12, pitch, vel); } static void monitor_note_on(unsigned ch, unsigned pitch, unsigned vel) { log_printf(DLOG, "NoteOn(%u, %s%u(%u), %u)\n", ch, notenames[pitch % 12], pitch / 12, pitch, vel); } static void monitor_poly_pressure(unsigned ch, unsigned pitch, unsigned press) { log_printf(DLOG, "PolyPress(%u, %s%u(%u), %u)\n", ch, notenames[pitch % 12], pitch / 12, pitch, press); } static void monitor_control_change(unsigned ch, unsigned ctrl, unsigned amt) { const char *cn = controlnames[ctrl]; if(!cn) cn = ""; log_printf(DLOG, "ControlChg(%u, %s(%u), %u)\n", ch, controlnames[ctrl], ctrl, amt); } static void monitor_program_change(unsigned ch, unsigned prog) { log_printf(DLOG, "ProgramChg(%u, %u)\n", ch, prog); } static void monitor_channel_pressure(unsigned ch, unsigned press) { log_printf(DLOG, "ChannelPress(%u, %u)\n", ch, press); } static void monitor_pitch_bend(unsigned ch, int amt) { log_printf(DLOG, "PitchBend(%u, %d)\n", ch, amt); } midisock_t monitor_midisock = { monitor_note_off, monitor_note_on, monitor_poly_pressure, monitor_control_change, monitor_program_change, monitor_channel_pressure, monitor_pitch_bend }; KoboDeluxe-0.5.1/sound/a_wave.c0000644000175000001440000005003710733167346013250 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_wave.c - Wava Data Manager --------------------------------------------------------------------------- * Copyright (C) 2001-2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "kobolog.h" #include "a_globals.h" #include "a_wave.h" #include "a_struct.h" #include "a_math.h" #include "a_tools.h" #include "a_agw.h" #include "eel.h" static int _was_init = 0; void audio_wave_open(void) { if(_was_init) return; memset(wavetab, 0, sizeof(wavetab)); _was_init = 1; } void audio_wave_close(void) { if(!_was_init) return; audio_wave_free(-1); _was_init = 0; } #define CHECKINIT if(!_was_init) audio_wave_open(); /*---------------------------------------------------------- Internal Tools ----------------------------------------------------------*/ /* * Fill in the loop/interpolation extension zone with the right * data, depending on whether the waveform is looped or not. * * (This should probably be replaced with smarter mixers. Cheap * sample players like the EMU8000 chips, have the same problem * with interpolation over loop wraps, which causes various * problems with anything but plain "loop forever" samples.) */ static void _render_extension(int wid) { Sint8 *eos; if(AF_MIDI == wavetab[wid].format) return; eos = wavetab[wid].data.si8 + wavetab[wid].size; if(wavetab[wid].looped) { unsigned s, from = 0; for(s = 0; s < wavetab[wid].xsize; ++s) { eos[s] = wavetab[wid].data.si8[from++]; if(from >= wavetab[wid].size) from = 0; } } else memset(eos, 0, wavetab[wid].xsize); } static void _calc_info(int wid) { wavetab[wid].speed = (unsigned)((double)wavetab[wid].rate * 65536.0 / (double)a_settings.samplerate); switch(wavetab[wid].format) { case AF_MONO8: wavetab[wid].samples = wavetab[wid].size; break; case AF_STEREO8: case AF_MONO16: wavetab[wid].samples = wavetab[wid].size / 2; break; case AF_STEREO16: case AF_MONO32: wavetab[wid].samples = wavetab[wid].size / 4; break; case AF_STEREO32: wavetab[wid].samples = wavetab[wid].size / 8; break; case AF_MIDI: wavetab[wid].samples = 1; break; } } void audio_wave_prepare(int wid) { int w, first, last; if(wid < 0) { first = 0; last = AUDIO_MAX_WAVES - 1; } else first = last = wid; for(w = first; w <= last; ++w) { if(!wavetab[w].allocated) continue; _calc_info(w); _render_extension(w); } } static int _get_free_wid(void) { int w; for(w = 0; w < AUDIO_MAX_WAVES; ++w) if(!wavetab[w].allocated) return w; return -1; } /* * Flip back and forth between big and little endian, * unless we're on big endian hardware. */ static void flip_endian(Uint8 *data, Uint32 size, int format) { #if SDL_BYTEORDER == SDL_LITTLE_ENDIAN int i, s; switch(format) { case AF_MIDI: case AF_MONO8: case AF_STEREO8: break; case AF_MONO16: case AF_STEREO16: for(i = 0; i < size; i += 2) { s = data[i]; data[i] = data[i + 1]; data[i + 1] = s; } break; case AF_MONO32: case AF_STEREO32: for(i = 0; i < size; i += 4) { s = data[i]; data[i] = data[i + 3]; data[i + 3] = s; s = data[i + 1]; data[i + 1] = data[i + 2]; data[i + 2] = s; } break; } #endif } static int LoadRAW(const char *name, Uint8 ** data, Uint32 * size, int *format, int *rate, int *loop) { unsigned char header[8]; int startpos = 0; FILE *f = fopen(name, "rb"); if(!f) return -1; if(fread(header, sizeof(header), 1, f) == 1) { if(strncmp("RAW", (char *)header, 3) == 0) { const char *fmt; *format = (int)header[3] & 0x0f; *loop = (header[3] & 0x80) != 0; startpos = sizeof(header); *rate = header[4]; *rate |= header[5] << 8; *rate |= header[6] << 16; *rate |= header[7] << 24; switch (*format) { case AF_MONO8: fmt = "MONO8"; break; case AF_STEREO8: fmt = "STEREO8"; break; case AF_MONO16: fmt = "MONO16"; break; case AF_STEREO16: fmt = "STEREO16"; break; case AF_MONO32: fmt = "MONO32"; break; case AF_STEREO32: fmt = "STEREO32"; break; case AF_MIDI: fmt = "MIDI (Huh!?)"; break; default: fmt = "Unknown"; break; } log_printf(DLOG, "LoadRAW: %s, %d Hz", fmt, *rate); if(*loop) log_printf(DLOG, ", looped\n"); else log_printf(DLOG, ", one-shot\n"); } else fseek(f, 0, SEEK_SET); } if(fseek(f, 0, SEEK_END) == 0) { int s = (int)ftell(f) - startpos; if(s <= 0) { fclose(f); return -2; } *size = (Uint32) s; if(fseek(f, startpos, SEEK_SET) == 0) { *data = malloc(*size); if(*data) { if(fread(*data, *size, 1, f) == 1) { fclose(f); flip_endian(*data, *size, *format); return 0; } free(*data); *data = NULL; } } } fclose(f); return -3; } static int SaveRAW(const char *name, void *data, Uint32 size, int format, int rate, int loop) { unsigned char header[8] = "RAW\0rate"; int result; FILE *f = fopen(name, "wb"); if(!f) return -1; header[3] = (char)format; if(loop) header[3] |= 0x80; header[4] = rate & 0xff; header[5] = (rate >> 8) & 0xff; header[6] = (rate >> 16) & 0xff; header[7] = (rate >> 24) & 0xff; if(fwrite(header, sizeof(header), 1, f) != 1) return -2; flip_endian(data, size, format); result = fwrite(data, size, 1, f); flip_endian(data, size, format); if(result != 1) return -3; fclose(f); return 0; } /* * Calculate waveform memory needed, including the extra bytes * needed for proper end-of-waveform handling. Will set the * 'xsize' and 'play_samples' field. * * Must know sample format and original size! * * Also note that this is heavily dependent on the voice * mixer - that's where the extra samples are needed. FIXME: ...which means that this code probably belongs there, FIXME: or that the voice mixer should set the parameters. * * Returns the total size required in bytes. */ static unsigned _calc_xsize(int wid) { unsigned samples, fsamples; unsigned bytes_sample = 1; unsigned ssize = wavetab[wid].size; switch(wavetab[wid].format) { case AF_MONO8: bytes_sample = 1; break; case AF_STEREO8: case AF_MONO16: bytes_sample = 2; ssize >>= 1; break; case AF_STEREO16: case AF_MONO32: bytes_sample = 4; ssize >>= 2; break; case AF_STEREO32: bytes_sample = 8; ssize >>= 3; break; case AF_MIDI: wavetab[wid].xsize = 0; return 0; } /* Fixed part: */ /* Looping. */ samples = ssize; while(samples < MIN_LOOP) samples <<= 1; wavetab[wid].play_samples = samples; samples -= ssize; /* Interpolation. */ samples += 3; /* Freq. ratio dependent part: oversampling and looping */ fsamples = AUDIO_MAX_MIX_RATE / AUDIO_MIN_OUTPUT_RATE; fsamples *= AUDIO_MAX_OVERSAMPLING; ++fsamples; wavetab[wid].xsize = bytes_sample * (samples + fsamples); return wavetab[wid].size + wavetab[wid].xsize; } /*---------------------------------------------------------- Basic Wave API ----------------------------------------------------------*/ int audio_wave_alloc(int wid) { CHECKINIT if(wid >= AUDIO_MAX_WAVES) return -1; if(wid < 0) wid = _get_free_wid(); if(wid < 0) return -2; audio_wave_free(wid); wavetab[wid].allocated = 1; return wid; } int audio_wave_alloc_range(int first_wid, int last_wid) { int w, res, last_done; if(last_wid < first_wid) return -1; last_done = -1; res = 0; for(w = first_wid; w <= last_wid; ++w) { res = audio_wave_alloc(w); if(res < 0) break; last_done = w; } if(res < 0) { if(last_done >= 0) for(w = first_wid; w <= last_done; ++w) audio_wave_free(w); return -2; } else return first_wid; } audio_wave_t *audio_wave_get(int wid) { if(wid < 0) return NULL; if(wid >= AUDIO_MAX_WAVES) return NULL; return &wavetab[wid]; } int audio_wave_format(int wid, audio_formats_t fmt, int fs) { unsigned old_xsize, new_size; wid = audio_wave_alloc(wid); if(wid < 0) return wid; old_xsize = wavetab[wid].xsize; wavetab[wid].format = fmt; wavetab[wid].rate = fs; if(wavetab[wid].data.si8) { new_size = _calc_xsize(wid); if(wavetab[wid].xsize != old_xsize) { void *ndata = realloc(wavetab[wid].data.si8, new_size); if(!ndata) return -3; wavetab[wid].data.si8 = ndata; _calc_info(wid); } } return wid; } int audio_wave_load_mem(int wid, void *data, unsigned size, int looped) { wid = audio_wave_alloc(wid); if(wid < 0) return wid; wavetab[wid].size = size; wavetab[wid].looped = looped; wavetab[wid].data.si8 = (Sint8 *)malloc(_calc_xsize(wid)); wavetab[wid].howtofree = HTF_FREE; if(!wavetab[wid].data.si8) { audio_wave_free(wid); return -1; } if(data) memcpy(wavetab[wid].data.si8, data, size); else memset(wavetab[wid].data.si8, 0, size); #ifdef xDEBUG { int i; int peak = 0; double avg = 0; double power = 0; int iavg, ipower; for(i = 0; i < size; ++i) { int s; s = wavetab[wid].data.si8[i]; avg += s; power += labs(s); if(labs(s) > peak) peak = labs(s); } avg /= size; power /= size; iavg = (int)avg; ipower = (int)power; log_printf(D3LOG, "audio_wave_load_mem(id=%d): size=%d peak=%d" " average=%d power=%d\n", wid, size, peak, iavg, ipower); } #endif _calc_info(wid); return wid; } int audio_wave_blank(int wid, unsigned samples, int looped) { int bps = 0; wid = audio_wave_alloc(wid); if(wid < 0) return wid; switch(wavetab[wid].format) { case AF_MONO8: bps = 1; break; case AF_STEREO8: case AF_MONO16: bps = 2; break; case AF_STEREO16: case AF_MONO32: bps = 4; break; case AF_STEREO32: bps = 8; break; case AF_MIDI: return wid; } return audio_wave_load_mem(wid, NULL, samples * bps, looped); } int audio_wave_convert(int wid, int new_wid, audio_formats_t fmt, int fs, audio_resample_t resamp) { int inplace, private_pool = 0, i; audio_voice_t resampler; audio_quality_t old_quality; int *bus; Sint8 *out8; Sint16 *out16; float *out32; unsigned newlen, j; /* We need this to run the voice mixer... */ if(ptab_init(65536) < 0) { log_printf(ELOG, "audio_wave_convert(): ptab_init() failed!\n"); return -20; } if(AF_MIDI == fmt) { log_printf(ELOG, "audio_wave_convert(): Cannot convert to MIDI!\n"); return -10; } if(wid >= AUDIO_MAX_WAVES) return -1; if(wid < 0) return -2; if(AF_MIDI == wavetab[wid].format) { log_printf(ELOG, "audio_wave_convert(): Cannot convert from MIDI!\n"); return -11; } if(new_wid == wid) { inplace = 1; new_wid = audio_wave_alloc(-1); if(new_wid < 0) return new_wid; } else { inplace = 0; new_wid = audio_wave_alloc(new_wid); if(new_wid < 0) return new_wid; } audio_wave_format(new_wid, fmt, fs); newlen = (unsigned)ceil((float)wavetab[wid].samples * (float)fs / (float)wavetab[wid].rate); audio_wave_blank(new_wid, newlen, wavetab[wid].looped); /* Must prepare, as we're gonna use the wave mixer! */ audio_wave_prepare(wid); memset(&resampler, 0, sizeof(resampler)); /* We need to tweak the 'speed' to get the output rate right! */ wavetab[wid].speed = (unsigned)((double)wavetab[wid].rate * 65536.0 / (double)wavetab[new_wid].rate); old_quality = a_settings.quality; a_settings.quality = AQ_VERY_HIGH; if(!aev_event_pool) { private_pool = 1; aev_open(20); } switch(resamp) { case AR_WORST: resamp = AR_NEAREST; break; case AR_MEDIUM: resamp = AR_LINEAR_2X_R; break; case AR_BEST: resamp = AR_CUBIC_R; break; default: break; } aev_timer = 0; (void)aev_send1(&resampler.port, 0, VE_START, wid); (void)aev_sendi1(&resampler.port, 0, VE_SET, VC_PITCH, 60<<16); (void)aev_sendi1(&resampler.port, 0, VE_SET, VC_RESAMPLE, resamp); (void)aev_sendi1(&resampler.port, 0, VE_SET, VC_SEND_BUS, -1); (void)aev_sendi2(&resampler.port, 0, VE_IRAMP, VIC_LVOL, 65536 >> (16-VOL_BITS), 0); (void)aev_sendi2(&resampler.port, 0, VE_IRAMP, VIC_RVOL, 65536 >> (16-VOL_BITS), 0); bus = malloc(256 * sizeof(int) * 2); out8 = wavetab[new_wid].data.si8; out16 = wavetab[new_wid].data.si16; out32 = wavetab[new_wid].data.f32; for(i = (int)wavetab[new_wid].samples; i > 0; i -= 256) { unsigned frames; if(i > 256) frames = 256; else frames = (unsigned)i; s32clear(bus, frames); voice_process_mix(&resampler, &bus, frames); switch(wavetab[new_wid].format) { case AF_MONO8: for(j = 0; j < frames; ++j) *out8++ = (bus[j<<1] + bus[(j<<1)+1]) >> 9; break; case AF_STEREO8: for(j = 0; j < frames; ++j) { *out8++ = bus[j<<1] >> 8; *out8++ = bus[(j<<1)+1] >> 8; } break; case AF_MONO16: for(j = 0; j < frames; ++j) *out16++ = (Sint16)(bus[j<<1] + bus[(j<<1)+1]) >> 1; break; case AF_STEREO16: for(j = 0; j < frames; ++j) { *out16++ = (Sint16)(bus[j<<1]); *out16++ = (Sint16)(bus[(j<<1)+1]); } break; case AF_MONO32: for(j = 0; j < frames; ++j) *out32++ = (float)(bus[j<<1] + bus[(j<<1)+1]) * 0.5; break; case AF_STEREO32: for(j = 0; j < frames; ++j) { *out32++ = (float)bus[j<<1]; *out32++ = (float)bus[(j<<1)+1]; } break; case AF_MIDI: /* whinestopper... */ break; } } free(bus); _calc_info(new_wid); voice_kill(&resampler); a_settings.quality = old_quality; if(private_pool) aev_close(); if(inplace) { audio_wave_free(wid); memcpy(wavetab + wid, wavetab + new_wid, sizeof(audio_wave_t)); memset(wavetab + new_wid, 0, sizeof(audio_wave_t)); return wid; } else { _calc_info(wid); /* Restore after our tweaking */ return new_wid; } } int audio_wave_clone(int wid, int new_wid) { if(wid >= AUDIO_MAX_WAVES) return -1; if(wid < 0) return -2; new_wid = audio_wave_format(new_wid, wavetab[wid].format, wavetab[wid].rate); if(new_wid < 0) return new_wid; return audio_wave_load_mem(new_wid, wavetab[wid].data.si8, wavetab[wid].size, wavetab[wid].looped); } /* We're simply using the same path for everything. */ void audio_set_path(const char *path) { eel_set_path(path); } const char *audio_path(void) { return eel_path(); } static int load_midi(int wid, const char *name) { midi_file_t *mf; wid = audio_wave_alloc(wid); if(wid < 0) return wid; mf = mf_open(name); if(!mf) { log_printf(ELOG, "load_midi(): Failed to load file" " \"%s\"! (Path = \"%s\")\n", name, eel_path()); audio_wave_free(wid); return -1; } wavetab[wid].data.midi = mf; wavetab[wid].size = 1; /* Duration in ms or something? */ wavetab[wid].xsize = 0; /* N/A */ wavetab[wid].howtofree = HTF_FREE; wavetab[wid].format = AF_MIDI; wavetab[wid].rate = 120; /* PPQN? */ wavetab[wid].looped = 0; /* Not yet implemented */ wavetab[wid].speed = 120; /* ? */ wavetab[wid].samples = 1; /* Number of events? */ log_printf(DLOG, ".------------------------------------------------------\n"); log_printf(DLOG, "| MIDI File: %s\n", name); log_printf(DLOG, "| Format: %u\n", mf->format); log_printf(DLOG, "| Title: %s\n", mf->title); log_printf(DLOG, "| Author: %s\n", mf->author); log_printf(DLOG, "| Remarks: %s\n", mf->remarks); log_printf(DLOG, "'------------------------------------------------------\n"); return wid; } int audio_wave_load(int wid, const char *name, int looped) { char buf[1024]; SDL_AudioSpec spec; Uint8 *data = NULL; Uint32 size; int format = -2; int rate = 0; /* Warning suppressor */ int res; int using_loadwav = 0; /* Prepend path */ strncpy(buf, eel_path(), sizeof(buf)); #ifdef WIN32 strncat(buf, "\\", sizeof(buf)); #elif defined MACOS strncat(buf, ":", sizeof(buf)); #else strncat(buf, "/", sizeof(buf)); #endif strncat(buf, name, sizeof(buf)); /* Check extension */ if(strstr(name, ".raw") || strstr(name, ".RAW")) { format = -1; res = LoadRAW(buf, &data, &size, &format, &rate, &looped); if(res < 0) format = -1; } else if(strstr(name, ".agw") || strstr(name, ".AGW")) return agw_load(wid, name); /* No full path here! */ else if(strstr(name, ".mid") || strstr(name, ".MID")) return load_midi(wid, buf); else { using_loadwav = 1; res = SDL_LoadWAV(buf, &spec, &data, &size) ? 0 : -1; } wid = audio_wave_alloc(wid); if(wid < 0) return wid; if(format >= 0) { wavetab[wid].format = format; wavetab[wid].rate = rate; } else if(using_loadwav) { switch (spec.format) { case AUDIO_S8: wavetab[wid].format = AF_MONO8; break; case AUDIO_S16SYS: wavetab[wid].format = AF_MONO16; break; default: log_printf(ELOG, "sound_load(): Unsupported wave format!\n"); SDL_FreeWAV((Uint8 *)(wavetab[wid].data.si8)); res = -1; break; } if(spec.channels == 2) ++wavetab[wid].format; wavetab[wid].rate = spec.freq; } if(res < 0) { log_printf(ELOG, "audio_wave_load(): Failed to load file" " \"%s\"! (Path = \"%s\")\n", name, eel_path()); audio_wave_free(wid); return -3; } if(data) audio_wave_load_mem(wid, data, size, looped); if(using_loadwav) SDL_FreeWAV(data); else free(data); return wid; } int audio_wave_save(int wid, const char *name) { char buf[1024]; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return -1; /* Prepend path */ strncpy(buf, eel_path(), sizeof(buf)); #ifdef WIN32 strncat(buf, "\\", sizeof(buf)); #elif defined MACOS strncat(buf, ":", sizeof(buf)); #else strncat(buf, "/", sizeof(buf)); #endif strncat(buf, name, sizeof(buf)); log_printf(DLOG, "Saving to \"%s\"\n", buf); /* Check extension */ if(strstr(name, ".raw") || strstr(name, ".RAW")) return SaveRAW(buf, wave->data.si8, wave->size, (int)wave->format, wave->rate, wave->looped); else return -2; } void audio_wave_free(int wid) { int w, first, last; CHECKINIT if(wid < 0) { first = 0; last = AUDIO_MAX_WAVES - 1; } else first = last = wid; for(w = first; w <= last; ++w) { if(!wavetab[w].data.si8) continue; if(HTF_FREE == wavetab[w].howtofree) switch(wavetab[w].format) { case AF_MONO8: case AF_STEREO8: case AF_MONO16: case AF_STEREO16: case AF_MONO32: case AF_STEREO32: free(wavetab[w].data.si8); break; case AF_MIDI: mf_close(wavetab[w].data.midi); break; } wavetab[w].data.si8 = NULL; wavetab[w].size = 0; wavetab[w].xsize = 0; wavetab[w].allocated = 0; } } void audio_wave_info(int wid) { int w, first, last; int count = 0; int total_size = 0; int total_time = 0; if(wid < 0) { first = 0; last = AUDIO_MAX_WAVES - 1; } else first = last = wid; log_printf(VLOG, "Waveform info:\n"); for(w = first; w <= last; ++w) { const char *f; if(!wavetab[w].allocated) continue; switch(wavetab[w].format) { case AF_MONO8: f = "MONO8 "; break; case AF_STEREO8: f = "STEREO8 "; break; case AF_MONO16: f = "MONO16 "; break; case AF_STEREO16: f = "STEREO16"; break; case AF_MONO32: f = "MONO32 "; break; case AF_STEREO32: f = "STEREO32"; break; case AF_MIDI: f = "MIDI "; break; default: f = "Unknown "; break; } if(wavetab[w].format == AF_MIDI) log_printf(VLOG, " (%3d: %s %s, %d PPQN,\t%d events)\n", w, f, wavetab[w].data.midi->title, wavetab[w].rate, wavetab[w].size); else { float d = (float)wavetab[w].samples / wavetab[w].rate; log_printf(VLOG, " %3d: %s %s, %d Hz,\t%d bytes\t" "(%.2f s)\n", w, f, wavetab[w].looped ? "LOOPED" : "ONESHOT", wavetab[w].rate, wavetab[w].size, d); total_size += wavetab[w].size; total_time += d; ++count; } } log_printf(VLOG, " Total %d waveforms, total size: %d bytes, " "total time: %d s\n", count, total_size, total_time); } KoboDeluxe-0.5.1/sound/a_patch.c0000644000175000001440000004164010730742156013400 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_patch.c - Audio Engine "instrument" definitions --------------------------------------------------------------------------- * Copyright (C) 2001-2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "kobolog.h" #include "a_struct.h" #include "a_patch.h" #include "a_sequencer.h" #define EDBG(x) #define EGDBG(x) static int _is_open = 0; #define CHECKINIT if(!_is_open) audio_patch_open(); /* * Common tools for mono and poly... */ static inline int __calc_randpitch(audio_patch_t *p, int pitch) { static int rnd = 16576; int rp = p->param[APP_RANDPITCH]; if(rp) { rnd *= 1566083941UL; rnd++; rnd &= 0xffffffffUL; pitch += (rnd % rp) - rp/2; } return pitch; } static inline int __get_wave(audio_patch_t *p) { int wave = p->param[APP_WAVE]; if((wave < 0) || (wave >= AUDIO_MAX_WAVES)) return -1; if(AF_MIDI == wavetab[wave].format) return -1; return wave; } /* Update base vol/send levels after control change. */ static inline void __env_control_recalc(audio_patch_t *p, audio_channel_t *c, audio_voice_t *v) { patch_closure_t *clos = &v->closure; clos->lvol = clos->rvol = clos->velvol; clos->lvol *= 64 - (c->ctl[ACC_PAN] >> 10); clos->rvol *= 64 + (c->ctl[ACC_PAN] >> 10); clos->lvol >>= 6; clos->rvol >>= 6; clos->lsend = c->ctl[ACC_SEND] >> (16-VOL_BITS); clos->lsend *= clos->velvol; clos->lsend >>= 16; clos->rsend = clos->lsend; clos->lsend *= 64 - (c->ctl[ACC_PAN] >> 10); clos->rsend *= 64 + (c->ctl[ACC_PAN] >> 10); clos->lsend >>= 6; clos->rsend >>= 6; } /* Initialize envelope to PES_START. */ static inline void __env_start(audio_patch_t *p, audio_channel_t *c, audio_voice_t *v) { patch_closure_t *clos = &v->closure; clos->env_state = PES_START; clos->env_next = aev_timer; } static inline void __env_stop(audio_patch_t *p, audio_channel_t *c, audio_voice_t *v) { patch_closure_t *clos = &v->closure; if(p->param[APP_ENV_T3] >= 0) return; EGDBG(log_printf(D3LOG, "stop!\n");) switch (clos->env_state) { case PES_START: case PES_START2: case PES_DELAY: case PES_ATTACK: case PES_HOLD: case PES_DECAY: clos->queued_stop = 1; if(p->param[APP_ENV_SKIP]) { clos->env_next = aev_timer; clos->env_state = PES_SUSTAIN; } break; case PES_SUSTAIN: /* No interactive sustain! */ case PES_RELEASE: /* Release already active... */ case PES_DEAD: break; case PES_WAIT: clos->env_next = aev_timer; clos->env_state = PES_SUSTAIN; break; } } /* FIXME: Support longer times than 65535 timestamp units. FIXME: When that's done, this will need fixing as well... */ #define S2S(x) ((((x)>>2) * a_settings.samplerate) >> 14) static inline void __env_run(audio_patch_t *p, audio_channel_t *c, audio_voice_t *v, unsigned frames) { patch_closure_t *clos = &v->closure; int lvol, rvol, lsend, rsend; aev_timestamp_t t; while((t = (unsigned)((clos->env_next - aev_timer) & AEV_TIMESTAMP_MASK)) < frames) { int duration; int target = 0; aev_timestamp_t timestamp = (aev_timestamp_t) (clos->env_next - aev_timer) & AEV_TIMESTAMP_MASK; EGDBG(log_printf(D3LOG, "%d: ", clos->env_next);) switch(clos->env_state) { case PES_START: duration = 0; target = p->param[APP_ENV_L0]; clos->env_state = PES_START2; clos->queued_stop = 0; break; case PES_START2: duration = S2S(p->param[APP_ENV_DELAY]); target = p->param[APP_ENV_L0]; clos->env_state = PES_DELAY; clos->queued_stop = 0; break; case PES_DELAY: duration = S2S(p->param[APP_ENV_T1]); target = p->param[APP_ENV_L1]; clos->env_state = PES_ATTACK; break; case PES_ATTACK: duration = S2S(p->param[APP_ENV_HOLD]); target = p->param[APP_ENV_L1]; clos->env_state = PES_HOLD; break; case PES_HOLD: duration = S2S(p->param[APP_ENV_T2]); target = p->param[APP_ENV_L2]; clos->env_state = PES_DECAY; break; case PES_DECAY: if(p->param[APP_ENV_T3] >= 0) { /* Timed sustain or no sustain */ target = p->param[APP_ENV_L2]; duration = S2S(p->param[APP_ENV_T3]); clos->env_state = PES_SUSTAIN; break; } else if(!clos->queued_stop) { /* Interactive sustain */ target = p->param[APP_ENV_L2]; duration = 30000; clos->env_state = PES_WAIT; break; } /* Fall though if interactive and stopped! */ case PES_SUSTAIN: duration = S2S(p->param[APP_ENV_T4]); target = 0; clos->env_state = PES_RELEASE; break; case PES_WAIT: /* Interactive sustain */ target = p->param[APP_ENV_L2]; duration = 30000; break; case PES_RELEASE: (void)aev_send0(&v->port, timestamp, VE_STOP); --c->playing; case PES_DEAD: clos->env_next += 30000; default: /* Warning supressor */ continue; } EGDBG(log_printf(D3LOG, " (duration: %d, target: %d)\n", duration, target);) lvol = (clos->lvol >> 1) * target >> 15; rvol = (clos->rvol >> 1) * target >> 15; lsend = (clos->lsend >> 1) * target >> 15; rsend = (clos->rsend >> 1) * target >> 15; (void)aev_sendi2(&v->port, t, VE_IRAMP, VIC_LVOL, lvol, duration); (void)aev_sendi2(&v->port, t, VE_IRAMP, VIC_RVOL, rvol, duration); if(v->use_double) { (void)aev_sendi2(&v->port, t, VE_IRAMP, VIC_LSEND, lsend, duration); (void)aev_sendi2(&v->port, t, VE_IRAMP, VIC_RSEND, rsend, duration); } clos->env_next += duration; } } static void _env_run_all(audio_patch_t *p, audio_channel_t *c, unsigned frames) { audio_voice_t *v = chan_get_first_voice(c); while(v) { __env_run(p, c, v, frames); v = chan_get_next_voice(v); } } static inline void __start_voice(audio_patch_t *p, audio_channel_t *c, audio_voice_t *v, int wave, int pitch, int velocity) { patch_closure_t *clos = &v->closure; /* Apply random pitch */ pitch = __calc_randpitch(p, pitch); /* Store base pitch and vel to closure */ clos->pitch = pitch; clos->velocity = velocity; /* Transform to get actual pitch */ pitch += c->ctl[ACC_PITCH]; pitch -= 60<<16; /* Start voice! */ (void)aev_sendi1(&v->port, 0, VE_SET, VC_PRIM_BUS, c->ctl[ACC_PRIM_BUS]); (void)aev_sendi1(&v->port, 0, VE_SET, VC_SEND_BUS, c->ctl[ACC_SEND_BUS]); (void)aev_send1(&v->port, 0, VE_START, wave); (void)aev_sendi1(&v->port, 0, VE_SET, VC_PITCH, pitch); /* Calculate "base volume" for envelope */ clos->velvol = c->ctl[ACC_VOLUME] >> (16-VOL_BITS); clos->velvol *= velocity; clos->velvol >>= 16; __env_control_recalc(p, c, v); /* Initialize and start envelope */ __env_start(p, c, v); ++c->playing; } /*---------------------------------------------------------- Default patches for polyphonic wave playback ----------------------------------------------------------*/ static inline void poly_start(audio_patch_t *p, audio_channel_t *c, int tag, int pitch, int velocity) { int voice; int wave = __get_wave(p); if(wave < 0) return; voice = voice_alloc(c); if(voice < 0) return; __start_voice(p, c, voicetab + voice, wave, pitch, velocity); voicetab[voice].tag = tag; } static inline void poly_stop(audio_patch_t *p, audio_channel_t *c, int tag, int velocity) { if(tag < 0) { audio_voice_t *v = chan_get_first_voice(c); while(v) { __env_stop(p, c, v); v = chan_get_next_voice(v); } } else { audio_voice_t *v = chan_get_first_voice(c); while(v) { if(v->tag == tag) { __env_stop(p, c, v); return; } v = chan_get_next_voice(v); } } } static inline void poly_control(audio_patch_t *p, audio_channel_t *c, int tag, int ctl, int arg) { int mask; if(AVT_ALL == tag) mask = tag = 0; else mask = -1; switch(ctl) { case ACC_GROUP: case ACC_PRIORITY: case ACC_PATCH: break; case ACC_PRIM_BUS: { audio_voice_t *v = chan_get_first_voice(c); while(v) { if((v->tag & mask) == tag) v->c[VC_PRIM_BUS] = arg; v = chan_get_next_voice(v); } break; } case ACC_SEND_BUS: { audio_voice_t *v = chan_get_first_voice(c); while(v) { if((v->tag & mask) == tag) v->c[VC_SEND_BUS] = arg; v = chan_get_next_voice(v); } break; } case ACC_PITCH: { audio_voice_t *v = chan_get_first_voice(c); while(v) { int pitch; if((v->tag & mask) == tag) { pitch = c->ctl[ACC_PITCH]; pitch += v->closure.pitch; pitch -= 60<<16; (void)aev_sendi1(&v->port, 0, VE_SET, VC_PITCH, pitch); } v = chan_get_next_voice(v); } break; } case ACC_PAN: case ACC_VOLUME: case ACC_SEND: { audio_voice_t *v = chan_get_first_voice(c); while(v) { if((v->tag & mask) == tag) { /* TODO: Ramping... */ __env_control_recalc(p, c, v); } v = chan_get_next_voice(v); } break; } } } static void poly_process(audio_patch_t *p, audio_channel_t *c, unsigned frames) { unsigned eframes = frames ? frames : 1; while(aev_next(&c->port, 0) < eframes) { aev_event_t *ev = aev_read(&c->port); switch(ev->type) { case CE_START: EDBG(log_printf(DLOG, "poly: CE_START %d\n", p->param[APP_WAVE]);) poly_start(p, c, ev->arg1, ev->arg2, ev->arg3); break; case CE_STOP: EDBG(log_printf(DLOG, "poly: CE_STOP\n");) poly_stop(p, c, ev->arg1, ev->arg2); break; case CE_CONTROL: EDBG(log_printf(DLOG, "poly: CE_CONTROL %d = %d\n", ev->index, ev->arg2);) c->ctl[ev->index] = ev->arg2; if(AVT_FUTURE != ev->arg1) poly_control(p, c, ev->arg1, ev->index, ev->arg2); break; } aev_free(ev); } /* FIXME: We need to split buffers or something for control FIXME: events that affect the envelope generators! */ if(frames) _env_run_all(p, c, frames); } /*---------------------------------------------------------- Default patches for monophonic wave playback ----------------------------------------------------------*/ static void mono_start(audio_patch_t *p, audio_channel_t *c, int tag, int pitch, int velocity) { int wave = __get_wave(p); if(wave < 0) return; if(voice_alloc(c) < 0) return; __start_voice(p, c, c->voices, wave, pitch, velocity); c->voices->tag = tag; c->playing = 1; } static void mono_stop(audio_patch_t *p, audio_channel_t *c, int tag, int velocity) { if(!c->voices) return; if(c->voices->channel != c) return; __env_stop(p, c, c->voices); c->playing = 0; } static void mono_control(audio_patch_t * p, audio_channel_t *c, int tag, int ctl, int arg) { audio_voice_t *v = c->voices; if(!v) return; if(v->channel != c) return; switch (ctl) { case ACC_GROUP: /* We don't care. */ case ACC_PRIORITY: /* Only for *new* voices. */ case ACC_PATCH: /* We just got selected. And? :-) */ break; case ACC_PRIM_BUS: (void)aev_sendi1(&v->port, 0, VE_SET, VC_PRIM_BUS, arg); break; case ACC_SEND_BUS: (void)aev_sendi1(&v->port, 0, VE_SET, VC_SEND_BUS, arg); break; case ACC_PITCH: (void)aev_sendi1(&v->port, 0, VE_SET, VC_PITCH, arg); break; case ACC_PAN: case ACC_VOLUME: case ACC_SEND: __env_control_recalc(p, c, v); break; } } static void mono_process(audio_patch_t *p, audio_channel_t *c, unsigned frames) { unsigned eframes = frames ? frames : 1; while(aev_next(&c->port, 0) < eframes) { aev_event_t *ev = aev_read(&c->port); switch(ev->type) { case CE_START: EDBG(log_printf(DLOG, "mono: CE_START %d\n", p->param[APP_WAVE]);) mono_start(p, c, ev->arg1, ev->arg2, ev->arg3); break; case CE_STOP: EDBG(log_printf(DLOG, "mono: CE_STOP\n");) mono_stop(p, c, ev->arg1, ev->arg2); break; case CE_CONTROL: EDBG(log_printf(DLOG, "mono: CE_CONTROL %d = %d\n", ev->index, ev->arg2);) c->ctl[ev->index] = ev->arg2; if(ACC_PATCH == ev->index) p = patchtab + c->ctl[ACC_PATCH]; if(AVT_FUTURE != ev->arg1) mono_control(p, c, ev->arg1, ev->index, ev->arg2); break; } aev_free(ev); } if(frames) _env_run_all(p, c, frames); } /*---------------------------------------------------------- Default patch for MIDI playback ----------------------------------------------------------*/ static void midi_start(audio_patch_t *p, audio_channel_t *c, int tag, int pitch, int velocity) { int wave = p->param[APP_WAVE]; if((wave < 0) || (wave >= AUDIO_MAX_WAVES)) return; if(AF_MIDI != wavetab[wave].format) return; /* Can't play this! */ pitch = __calc_randpitch(p, pitch); pitch += c->ctl[ACC_PITCH]; pitch -= 60<<16; if(pitch < 0) pitch = 0; else if(pitch > 128<<16) pitch = 128<<16; if(sequencer_play(wavetab[wave].data.midi, tag, pitch, velocity) < 0) return; ++c->playing; } static void midi_process(audio_patch_t *p, audio_channel_t *c, unsigned frames) { unsigned eframes = frames ? frames : 1; while(aev_next(&c->port, 0) < eframes) { aev_event_t *ev = aev_read(&c->port); switch(ev->type) { case CE_START: EDBG(log_printf(DLOG, "midi: CE_START %d\n", p->param[APP_WAVE]);) midi_start(p, c, ev->arg1, ev->arg2, ev->arg3); break; case CE_STOP: EDBG(log_printf(DLOG, "midi: CE_STOP\n");) /* FIXME: Handle cid == -1 correctly! */ c->playing = 0; sequencer_stop(ev->arg1); break; case CE_CONTROL: EDBG(log_printf(DLOG, "midi: CE_CONTROL %d = %d\n", ev->index, ev->arg2);) c->ctl[ev->index] = ev->arg2; break; } aev_free(ev); } /* This is where to run the sequencer. */ } /*---------------------------------------------------------- User EEL Patch Driver ----------------------------------------------------------*/ static void eel_process(audio_patch_t *p, audio_channel_t *c, unsigned frames) { unsigned eframes = frames ? frames : 1; while(aev_next(&c->port, 0) < eframes) { aev_event_t *ev = aev_read(&c->port); switch(ev->type) { case CE_START: EDBG(log_printf(DLOG, "eel: CE_START %d\n", p->param[APP_WAVE]);) break; case CE_STOP: EDBG(log_printf(DLOG, "eel: CE_STOP\n");) break; case CE_CONTROL: EDBG(log_printf(DLOG, "eel: CE_CONTROL %d = %d\n", ev->index, ev->arg2);) c->ctl[ev->index] = ev->arg2; break; } aev_free(ev); } /* Run timer driven EEL code here. */ } /*---------------------------------------------------------- Dummy Patch Driver ----------------------------------------------------------*/ static void dummy_process(audio_patch_t *p, audio_channel_t *c, unsigned frames) { unsigned eframes = frames ? frames : 1; while(aev_next(&c->port, 0) < eframes) { aev_event_t *ev = aev_read(&c->port); switch(ev->type) { case CE_START: EDBG(log_printf(DLOG, "dummy: CE_START %d\n", p->param[APP_WAVE]);) break; case CE_STOP: EDBG(log_printf(DLOG, "dummy: CE_STOP\n");) break; case CE_CONTROL: EDBG(log_printf(DLOG, "dummy: CE_CONTROL %d = %d\n", ev->index, ev->arg2);) c->ctl[ev->index] = ev->arg2; break; } aev_free(ev); } } /*---------------------------------------------------------- Patch programming API ----------------------------------------------------------*/ /* Set parameter for a patch */ void audio_patch_param(int pid, int pparam, int value) { CHECKINIT if(pid < 0) return; if(pid >= AUDIO_MAX_PATCHES) return; if(pparam < 0) return; if(pparam > APP_LAST) return; if(APP_DRIVER == pparam) { switch(value) { case PD_MONO: patchtab[pid].process = mono_process; break; case PD_POLY: patchtab[pid].process = poly_process; break; case PD_MIDI: patchtab[pid].process = midi_process; break; case PD_EEL: patchtab[pid].process = eel_process; break; default: patchtab[pid].process = dummy_process; log_printf(ELOG, "a_patch.c: Illegal patch" " driver selected!\n"); break; } } patchtab[pid].param[pparam] = value; } /*---------------------------------------------------------- Global init ----------------------------------------------------------*/ void audio_patch_open(void) { int i; if(_is_open) return; memset(patchtab, 0, sizeof(patchtab)); for(i = 0; i < AUDIO_MAX_PATCHES; ++i) { /* patchtab[i].param[APP_DRIVER] = PD_NONE; patchtab[i].process = dummy_process; */ /* FIXME: This hack is just until the EEL<->patch binding is sorted out. */ patchtab[i].param[APP_DRIVER] = PD_POLY; patchtab[i].process = poly_process; patchtab[i].param[APP_WAVE] = i; patchtab[i].param[APP_ENV_L0] = 1<<16; patchtab[i].param[APP_ENV_L1] = 1<<16; patchtab[i].param[APP_ENV_L2] = 1<<16; patchtab[i].param[APP_ENV_T3] = -1; patchtab[i].param[APP_ENV_T4] = (1<<16) / 100; patchtab[i].param[APP_ENV2VOL] = 1<<16; } _is_open = 1; } void audio_patch_close(void) { if(!_is_open) return; memset(patchtab, 0, sizeof(patchtab)); _is_open = 0; } KoboDeluxe-0.5.1/sound/a_channel.c0000644000175000001440000001531207737015253013712 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_channel.c - Audio Engine high level control abstraction --------------------------------------------------------------------------- * Copyright (C) 2001, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "kobolog.h" #include "a_globals.h" #include "a_struct.h" #include "a_control.h" #include "a_sequencer.h" #include "a_tools.h" #define SDBG(x) void channel_stop_all(void) { int i; for(i = 0; i < AUDIO_MAX_VOICES; ++i) voice_kill(voicetab + i); for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) channeltab[i].playing = 0; /* Reset "voice" count */ sequencer_stop(-1); } /* FIXME: What if there are sounds playing when an ACC_PATCH comes in!? FIXME: Maybe patch plugins should have a "detach + release" feature? FIXME: FIXME: Another alternative would be some way of forwarding events to FIXME: "unknown" tags (easy now that the controller must provide the FIXME: tags!) on to whatever patch they were started by. That is, an FIXME: actively managed, per channel "patch history". "Affect all" FIXME: events (-1 tags) would have to be processed *and* forwarded. FIXME: FIXME: Patch plugins could just pass events for unknown tags to some FIXME: "forward to previous patch" event port, that the engine checks FIXME: after running a patch plugin. Of course, this would require FIXME: that all patches actually remember tags, even if they don't FIXME: really care about them... In fact, it would be a problem even FIXME: for patches that *do* use tags, as those will generally FIXME: "remember" only tags that actually get the required resources. FIXME: (That is, if a poly patch runs out of voices, it'll start FIXME: forgetting tags...) FIXME: FIXME: A much simpler solution would be to just keep patches running FIXME: until they say they have no more "contexts" active. Events FIXME: would have to be duplicated - or we could have all plugins FIXME: just pass events on to a "garbage port", that actually becomes FIXME: a forwarding port when needed. In the normal case, the engine FIXME: would just flush this port when appropriate. */ /* FIXME: Maybe we actually want to pass ACC_PATCH change events FIXME: on to patch drivers? If so, should they be sent to FIXME: the old or new patch, or both? That question alone FIXME: seems to suggest that ACC_PATCH should die here, but FIXME: then again, some drivers might need these events... */ static inline void channel_process(audio_channel_t *c, unsigned frames) { aev_event_t *first_ev = c->port.first; unsigned split_frames = frames; /* * This one's rather ugly... Better ideas, anyone? */ aev_timestamp_t timer_save = aev_timer; while(1) { aev_event_t *ev = c->port.first; aev_event_t *prev_ev = NULL; aev_event_t *rerun_ev = NULL; while(ev && (AEV_TIME(ev->frame, 0) < split_frames)) { if(ev->type != CE_CONTROL) { prev_ev = ev; ev = ev->next; continue; } c->rctl[ev->index] = ev->arg2; switch(ev->index) { /* case_ACC_NOTRANSFORM:*/ case ACC_GROUP: case ACC_PRIORITY: break; case ACC_PATCH: { aev_event_t *del_ev = ev; SDBG(log_printf(D3LOG, "(patch) ");) if(c->ctl[ACC_PATCH] == c->rctl[ACC_PATCH]) { SDBG(log_printf(D3LOG, "[IGNORE]\n");) ev = ev->next; if(prev_ev) prev_ev->next = ev; else c->port.first = ev; } else if(ev == first_ev) { SDBG(log_printf(D3LOG, "[FIRST]\n");) c->ctl[ACC_PATCH] = c->rctl[ACC_PATCH]; ev = ev->next; c->port.first = ev; first_ev = NULL; } else { SDBG(log_printf(D3LOG, "[SPLIT]\n");) split_frames = AEV_TIME(ev->frame, 0); rerun_ev = ev->next; /* * Note that we really must break the list! * Going by the timestams is insufficient, * as there may be more events for the same * frame. */ if(prev_ev) prev_ev->next = NULL; else c->port.first = NULL; ev = NULL; } aev_free(del_ev); continue; } case ACC_PRIM_BUS: case ACC_SEND_BUS: break; case_ACC_ADDTRANSFORM: { audio_group_t *g; int min, max; g = grouptab + c->rctl[ACC_GROUP]; min = addtrans_min[ev->index - ACC_ADDTRANSFORM_FIRST]; max = addtrans_max[ev->index - ACC_ADDTRANSFORM_FIRST]; ev->arg2 += g->ctl[ev->index]; ev->arg2 -= addtrans_bias[ev->index - ACC_ADDTRANSFORM_FIRST]; if(ev->arg2 < min) ev->arg2 = min; else if(ev->arg2 > max) ev->arg2 = max; break; } case_ACC_MULTRANSFORM: { audio_group_t *g; g = grouptab + c->rctl[ACC_GROUP]; ev->arg2 = fixmul(ev->arg2, g->ctl[ev->index]); break; } } prev_ev = ev; ev = ev->next; } /* Run the patch plugin! */ /* if(c->ctl[ACC_PATCH] < AUDIO_MAX_PATCHES)*/ { audio_patch_t *p = patchtab + c->ctl[ACC_PATCH]; p->process(p, c, split_frames); } /* Apply last patch change, if any */ c->ctl[ACC_PATCH] = c->rctl[ACC_PATCH]; frames -= split_frames; if(!frames) break; /* Done! */ SDBG(log_printf(D3LOG, "split!\n");) /* Set up event port and timing for next fragment */ aev_advance_timer(split_frames); split_frames = frames; c->port.first = rerun_ev; } aev_timer = timer_save; } void channel_process_all(unsigned frames) { int i; for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) channel_process(channeltab + i, frames); } static int _wasinit = 0; void audio_channel_open(void) { int i; if(_wasinit) return; memset(channeltab, 0, sizeof(channeltab)); for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { char *buf = malloc(64); snprintf(buf, 64, "Audio Channel %d", i); aev_port_init(&channeltab[i].port, buf); acc_copya(&channeltab[i].rctl, &a_channel_def_ctl); acc_copya(&channeltab[i].ctl, &a_channel_def_ctl); channeltab[i].voices = NULL; } _wasinit = 1; } void audio_channel_close(void) { int i; if(!_wasinit) return; for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { aev_flush(&channeltab[i].port); free((char *)channeltab[i].port.name); } memset(channeltab, 0, sizeof(channeltab)); _wasinit = 0; } KoboDeluxe-0.5.1/sound/a_voice.c0000644000175000001440000003553307670677762013435 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_voice.c - Audio Engine low level mixer voices --------------------------------------------------------------------------- * Copyright (C) 2001-2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "kobolog.h" #include "a_voice.h" #include "a_struct.h" #include "a_globals.h" #include "a_tools.h" #include "a_control.h" #define LDBG(x) #define EVDBG(x) #define CHECKPOINTS /* Random number generator state for randtrig etc */ static int rnd = 16576; #define UPDATE_RND rnd *= 1566083941UL; rnd++; rnd &= 0x7fffffffUL; /* Last allocated voice (good starting point!) */ static int last_voice = 0; void voice_kill(audio_voice_t *v) { v->vu = 65535; /* Newly allocated voices are harder to steal */ aev_flush(&v->port); if(v->channel) { --v->channel->playing; chan_unlink_voice(v); } v->state = VS_STOPPED; } int voice_alloc(audio_channel_t *c) { int lv = 0; int i, pri, v, vol; /* Pass 1: Look for an unused voice. */ for(v = 0; v < AUDIO_MAX_VOICES; ++v) { if(voicetab[v].state != VS_STOPPED) continue; /* Not interesting here... */ last_voice = v; chan_link_voice(c, &voicetab[v]); voicetab[v].priority = c->ctl[ACC_PRIORITY]; voicetab[v].state = VS_RESERVED; return v; } /* * Pass 2: Look for the most silent voice with * same or lower priority. */ lv = last_voice; vol = 2000000000; v = -1; for(i = 0; i < AUDIO_MAX_VOICES; ++i) { int vu; if(++lv >= AUDIO_MAX_VOICES) lv = 0; if(voicetab[lv].priority < c->ctl[ACC_PRIORITY]) continue; #ifdef AUDIO_USE_VU vu = voicetab[lv].vu; vu *= (voicetab[lv].ic[VIC_LVOL].v + voicetab[lv].ic[VIC_RVOL].v + voicetab[lv].ic[VIC_LSEND].v + voicetab[lv].ic[VIC_RSEND].v) >> (RAMP_BITS + 2); vu >>= VOL_BITS; #else vu = (voicetab[lv].ic[VIC_LVOL].v + voicetab[lv].ic[VIC_RVOL].v + voicetab[lv].ic[VIC_LSEND].v + voicetab[lv].ic[VIC_RSEND].v) >> (RAMP_BITS + 2); #endif if(vu < vol) { vol = vu; v = lv; } } if(v >= 0) { voice_kill(&voicetab[v]); chan_link_voice(c, &voicetab[v]); last_voice = v; voicetab[v].priority = c->ctl[ACC_PRIORITY]; voicetab[v].state = VS_RESERVED; return v; } /* Pass 3: Grab voice with lowest priority. */ lv = last_voice; pri = c->ctl[ACC_PRIORITY]; v = -1; for(i = 0; i < AUDIO_MAX_VOICES; ++i) { if(++lv >= AUDIO_MAX_VOICES) lv = 0; if(voicetab[lv].priority > pri) { pri = voicetab[lv].priority; v = lv; } } if(v >= 0) { voice_kill(&voicetab[v]); chan_link_voice(c, &voicetab[v]); last_voice = v; voicetab[v].priority = c->ctl[ACC_PRIORITY]; voicetab[v].state = VS_RESERVED; return v; } return -1; } void voice_start(audio_voice_t *v, int wid) { int retrig, randtrig; v->wave = v->c[VC_WAVE] = wid; v->c[VC_LOOP] = wavetab[wid].looped; v->position = 0; v->position_frac = 0; if(!wavetab[wid].data.si8) { voice_kill(v); return; } /* Set up retrig and looping */ randtrig = (int)v->c[VC_RANDTRIG]; retrig = (int)v->c[VC_RETRIG]; if(randtrig) { UPDATE_RND randtrig = rnd % (randtrig<<1) - randtrig; randtrig = retrig * randtrig >> 16; retrig += randtrig; } if(retrig > 0) { if((unsigned)retrig > wavetab[wid].play_samples) v->section_end = wavetab[wid].play_samples; else v->section_end = (unsigned)retrig; } else v->section_end = wavetab[wid].play_samples; /* Start voice! */ v->state = VS_PLAYING; } static inline int __handle_looping(audio_voice_t *v) { unsigned int samples = wavetab[v->c[VC_WAVE]].play_samples; int randtrig = v->c[VC_RANDTRIG]; int retrig = v->c[VC_RETRIG]; /* Latch (new) waveform index */ v->wave = v->c[VC_WAVE]; if(randtrig) { UPDATE_RND randtrig = rnd % (randtrig<<1) - randtrig; randtrig = retrig * randtrig >> 16; retrig += randtrig; } if(retrig > 0) { unsigned int old_se = v->section_end; if((unsigned)retrig > samples) v->section_end = samples; else v->section_end = (unsigned)retrig; if(old_se > v->position) { /* Force instant initial retrig */ v->position = 0; v->position_frac = 0; } else { /* Wrap loop */ if(v->position >= old_se) v->position = 0; else v->position -= old_se; } } else { if(v->c[VC_LOOP]) { v->position -= v->section_end; v->section_end = samples; } else return 0; /* Stop playing! */ } return 1; } void voice_check_retrig(audio_voice_t *v) { if(wavetab[v->wave].data.si8) { int retrig_max = v->c[VC_RETRIG] * v->c[VC_RANDTRIG] >> 16; retrig_max += v->c[VC_RETRIG]; if(v->position > (unsigned)retrig_max) __handle_looping(v); } } /* * Macro Mayhem! Create all the mixer variants... */ static inline void __mix_m8(audio_voice_t *v, int *out, unsigned frames) { #undef __SEND #undef __STEREO #undef __16BIT #include "a_mixers.h" } static inline void __mix_s8(audio_voice_t *v, int *out, unsigned frames) { #undef __SEND #define __STEREO #undef __16BIT #include "a_mixers.h" } static inline void __mix_m16(audio_voice_t *v, int *out, unsigned frames) { #undef __SEND #undef __STEREO #define __16BIT #include "a_mixers.h" } static inline void __mix_s16(audio_voice_t *v, int *out, unsigned frames) { #undef __SEND #define __STEREO #define __16BIT #include "a_mixers.h" } static inline void __mix_m8d(audio_voice_t *v, int *out, int *sout, unsigned frames) { #define __SEND #undef __STEREO #undef __16BIT #include "a_mixers.h" } static inline void __mix_s8d(audio_voice_t *v, int *out, int *sout, unsigned frames) { #define __SEND #define __STEREO #undef __16BIT #include "a_mixers.h" } static inline void __mix_m16d(audio_voice_t *v, int *out, int *sout, unsigned frames) { #define __SEND #undef __STEREO #define __16BIT #include "a_mixers.h" } static inline void __mix_s16d(audio_voice_t *v, int *out, int *sout, unsigned frames) { #define __SEND #define __STEREO #define __16BIT #include "a_mixers.h" } #undef __SEND #undef __STEREO #undef __16BIT /* * Calculates resampling input "step", and selects resampling mode. */ static inline unsigned int __calc_step(audio_voice_t *v) { audio_resample_t mode = AR_LINEAR; /* Resampling factor */ int pitch = v->c[VC_PITCH]; unsigned step = (unsigned)fixmul(ptab_convert(pitch), wavetab[v->wave].speed); #if (FREQ_BITS < 16) step >>= 16 - FREQ_BITS; #elif (FREQ_BITS > 16) step <<= FREQ_BITS - 16; #endif /* * We must prevent high pithes from locking the mixer in * an infinite loop with short looped waveforms... */ if(step > MAX_STEP) { #ifdef DEBUG log_printf(ELOG, "Too high pitch!\n"); #endif while(step > MAX_STEP) step >>= 1; } switch(a_settings.quality) { case AQ_VERY_LOW: mode = AR_NEAREST; break; case AQ_LOW: mode = AR_NEAREST_4X; break; case AQ_NORMAL: mode = AR_LINEAR; break; case AQ_HIGH: /* Select resampling method based on in/out ratio */ if(step > (unsigned)(6 << FREQ_BITS)) mode = AR_LINEAR_8X_R; /* Above 6:1 */ else if(step > (unsigned)(3 << FREQ_BITS)) mode = AR_LINEAR_4X_R; /* Above 3:1 */ else mode = AR_LINEAR_2X_R; /* Below 2:1 */ break; case AQ_VERY_HIGH: /* Select resampling method based on in/out ratio */ if(step > (unsigned)(4 << FREQ_BITS)) mode = AR_LINEAR_16X_R; /* Above 4:1 */ else if(step > (unsigned)(3 << FREQ_BITS)) mode = AR_LINEAR_8X_R; /* Above 3:1 */ else if(step > (unsigned)(2 << FREQ_BITS)) mode = AR_LINEAR_4X_R; /* Above 2:1 */ else if(step > (unsigned)(3 << (FREQ_BITS-1))) mode = AR_LINEAR_2X_R; /* Above 1.5:1 */ else mode = AR_CUBIC_R; /* Below 1.5:1 */ break; } v->c[VC_RESAMPLE] = mode; return step; } /* * Calculates # of output frames to the nearest of 'frames', * end of segment and the "fragment span limit". */ static inline unsigned int __endframes(audio_voice_t *v, unsigned int frames) { #ifdef A_USE_INT64 Uint64 n, n2; #else double n, n2; #endif if(!v->step) return frames; #ifdef A_USE_INT64 n = ((Uint64)(v->position) << 32) | (Uint64)(v->position_frac); n >>= 32 - FREQ_BITS; n = ((Uint64)(v->section_end) << FREQ_BITS) - n + v->step - 1; n /= v->step; #else n = (double)(v->position) + (double)(v->position_frac) / 4294967296.0; n = (double)(v->section_end) - n; n /= (double)v->step / (double)(1< 0xffffffff) n = 0xffffffff; #ifdef A_USE_INT64 if(n > (Uint64)frames) n = (Uint64)frames; #else if(n > (double)frames) n = (double)frames; #endif /* * Restrict fragment size to prevent read position overflows. * * (In order to maximize pitch accuracy, voice mixers can only * handle a very limited number of input samples without * recalculating their "base pointers".) */ #ifdef A_USE_INT64 n2 = (Uint64)MAX_FRAGMENT_SPAN << FREQ_BITS; n2 /= (Uint64)v->step * (Uint64)frames; #else n2 = (double)MAX_FRAGMENT_SPAN * (1 << FREQ_BITS); n2 /= (double)v->step * (double)frames; #endif if(n > n2) n = n2; #ifdef CHECKPOINTS if(!frames) { voice_kill(v); log_printf(ELOG, "Voice locked up! (Too high pitch " "resulted in zero fragment size.)\n"); } #endif return (unsigned int)n; } static inline void __fragment_single(audio_voice_t *v, int *out, unsigned int frames) { switch(wavetab[v->wave].format) { case AF_MONO8: __mix_m8(v, out, frames); break; case AF_STEREO8: __mix_s8(v, out, frames); break; case AF_MONO16: __mix_m16(v, out, frames); break; case AF_STEREO16: __mix_s16(v, out, frames); break; case AF_MONO32: /*__mix_m32(v, out, frames);*/ break; case AF_STEREO32: /*__mix_s32(v, out, frames);*/ case AF_MIDI: /* warning eliminator */ break; } } static inline void __fragment_double(audio_voice_t * v, int *out, int *sout, unsigned int frames) { switch(wavetab[v->wave].format) { case AF_MONO8: __mix_m8d(v, out, sout, frames); break; case AF_STEREO8: __mix_s8d(v, out, sout, frames); break; case AF_MONO16: __mix_m16d(v, out, sout, frames); break; case AF_STEREO16: __mix_s16d(v, out, sout, frames); break; case AF_MONO32: /*__mix_m32d(v, out, sout, frames);*/ break; case AF_STEREO32: /*__mix_s32d(v, out, sout, frames);*/ case AF_MIDI: /* warning eliminator */ break; } } /* * Figure out if we should use the "double output" mixers, * and where to connect the output(s). */ static inline int __setup_output(audio_voice_t *v) { int prim, send; /* FIXME: This "automatic routing optimization" isn't needed, FIXME: and causes trouble elsewhere. Simplify. */ v->fx1 = v->c[VC_PRIM_BUS]; v->fx2 = v->c[VC_SEND_BUS]; prim = (v->fx1 >= 0) && (v->fx1 < AUDIO_MAX_BUSSES); send = (v->fx2 >= 0) && (v->fx2 < AUDIO_MAX_BUSSES); if(!prim && !send) return -1; /* No busses selected! --> */ if(prim && send) v->use_double = (v->fx1 != v->fx2); else { if(send) v->fx1 = v->fx2; else v->fx2 = v->fx1; v->use_double = 0; } return 0; } void voice_process_mix(audio_voice_t *v, int *busses[], unsigned frames) { unsigned s, frag_s; if((VS_STOPPED == v->state) && (aev_next(&v->port, 0) > frames)) return; /* Stopped, and no events for this buffer --> */ /* Loop until buffer is full, or the voice is "dead". */ s = 0; while(frames) { unsigned frag_frames; while( !(frag_frames = aev_next(&v->port, s)) ) { aev_event_t *ev = aev_read(&v->port); switch(ev->type) { case VE_START: voice_start(v, ev->arg1); if(VS_STOPPED == v->state) { aev_free(ev); return; /* Error! --> */ } /* * NOTE: * This being checked here means that * it's not possible to change routing * during playback. Who would, anyway? */ if(__setup_output(v) < 0) { voice_kill(v); aev_free(ev); return; /* No sends! --> */ } break; case VE_STOP: voice_kill(v); aev_free(ev); return; /* Back in the voice pool! --> */ case VE_SET: #ifdef CHECKPOINTS if(ev->index >= VC_COUNT) { log_printf(ELOG, "BUG! VC index out of range!"); break; } #endif v->c[ev->index] = ev->arg1; if(VC_PITCH == ev->index) v->step = __calc_step(v); break; case VE_IRAMP: #ifdef CHECKPOINTS if(ev->index >= VIC_COUNT) { log_printf(ELOG, "BUG! VIC index out of range!"); break; } #endif if(ev->arg2) { v->ic[ev->index].dv = ev->arg1 << RAMP_BITS; v->ic[ev->index].dv -= v->ic[ev->index].v; v->ic[ev->index].dv /= ev->arg2 + 1; } else v->ic[ev->index].v = ev->arg1 << RAMP_BITS; break; } aev_free(ev); } if(frag_frames > frames) frag_frames = frames; /* Handle fragmentation, end-of-waveform and looping */ frag_s = (VS_PLAYING == v->state) ? 0 : frag_frames; while(frag_s < frag_frames) { unsigned offs = (s + frag_s) << 1; unsigned do_frames = __endframes(v, frag_frames - frag_s); if(do_frames) { #ifdef CHECKPOINTS if(v->position >= v->section_end) { log_printf(ELOG, "BUG! position = %u while section_end = %u.", v->position, v->section_end); log_printf(ELOG, " (step = %u)\n", v->step >> FREQ_BITS); v->position = 0; } #endif bustab[v->fx1].in_use = 1; if(v->use_double) { bustab[v->fx2].in_use = 1; __fragment_double(v, busses[v->fx1] + offs, busses[v->fx2] + offs, do_frames); } else __fragment_single(v, busses[v->fx1] + offs, do_frames); frag_s += do_frames; // This is just for that damn oversampling... if(v->position >= v->section_end) do_frames = 0; } if(!do_frames && !__handle_looping(v)) { voice_kill(v); return; } } s += frag_frames; frames -= frag_frames; } } void voice_process_all(int *bufs[], unsigned frames) { int i; for(i = 0; i < AUDIO_MAX_VOICES; ++i) voice_process_mix(voicetab + i, bufs, frames); } static int _is_open = 0; void audio_voice_open(void) { int i; if(_is_open) return; memset(voicetab, 0, sizeof(voicetab)); for(i = 0; i < AUDIO_MAX_VOICES; ++i) { char *buf = malloc(64); snprintf(buf, 64, "Audio Voice %d", i); aev_port_init(&voicetab[i].port, buf); } _is_open = 1; } void audio_voice_close(void) { int i; if(!_is_open) return; for(i = 0; i < AUDIO_MAX_VOICES; ++i) { aev_flush(&voicetab[i].port); free((char *)voicetab[i].port.name); } memset(voicetab, 0, sizeof(voicetab)); _is_open = 0; } KoboDeluxe-0.5.1/sound/a_bus.c0000644000175000001440000001476707736665745013130 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_bus.c - Audio Engine bus --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include "a_bus.h" #include "a_struct.h" #include "a_delay.h" #include "a_tools.h" #define BDBG(x) static inline int __bus_run_fx(int bus, int slot, int *busses[], unsigned frames) { audio_bus_t *b = &bustab[bus]; --slot; /* No IFX on slot 0! */ switch(b->insert[slot].current_state) { case FX_STATE_RUNNING: case FX_STATE_SILENT: case FX_STATE_RESTING: if(b->in_use) /* Do we have input? */ b->insert[slot].process(&b->insert[slot], busses[bus], frames); else { b->insert[slot].process_r(&b->insert[slot], NULL, busses[bus], frames); b->in_use = 1; } /* Check if the plugin actually produced valid output! */ return (FX_STATE_RUNNING == b->insert[slot].current_state); default: /* No plugin, or plugin not running. */ return 0; } } static inline void __bus_process(int bus, int *busses[], int *master, unsigned frames) { audio_bus_t *b = &bustab[bus]; int i, s; /* Tail detection hack for the DC supression filter... */ if(!b->in_use) if(!dcf6s_silent(&b->dcfilter)) { b->in_use = 1; s32clear(busses[bus], frames); } if(b->in_use) /* Only if we actually have input! */ { /* DC suppression filter */ dcf6s_process(&b->dcfilter, busses[bus], frames); /* Mix pre-insert sends */ s32mix(busses[bus], master, b->bctl[0][ABC_SEND_MASTER], frames); for(i = bus + 1; i < AUDIO_MAX_BUSSES; ++i) if(s32mix(busses[bus], busses[i], b->bctl[0][ABC_SEND_BUS_0 + i], frames)) bustab[i].in_use = 1; } /* Mix post-insert sends */ for(s = 1; s <= AUDIO_MAX_INSERTS; ++s) { /* Run the insert */ if(!__bus_run_fx(bus, s, busses, frames)) continue; /* No output, no sends! */ s32mix(busses[bus], master, b->bctl[s][ABC_SEND_MASTER], frames); for(i = bus + 1; i < AUDIO_MAX_BUSSES; ++i) if(s32mix(busses[bus], busses[i], b->bctl[s][ABC_SEND_BUS_0 + i], frames)) bustab[i].in_use = 1; } /* Prepare for the next engine cycle */ if(b->in_use) { s32clear(busses[bus], frames); b->in_use = 0; } } void bus_process_all(int *bufs[], int *master, unsigned frames) { int i; for(i = 0; i < AUDIO_MAX_BUSSES; ++i) __bus_process(i, bufs, master, frames); } static void __remove_insert(unsigned bus, unsigned insert) { audio_bus_t *b = &bustab[bus]; audio_plugin_close(&b->insert[insert]); } static void __change_insert(unsigned bus, unsigned insert, int fx) { int reopen = 0; audio_bus_t *b = &bustab[bus]; audio_plugin_t *ins; if(bus < 1) return; __remove_insert(bus, insert); ins = &b->insert[insert-1]; switch(fx) { case AFX_NONE: break; case AFX_DELAY: break; case AFX_ECHO: break; case AFX_REVERB: delay_init(ins); reopen = 1; break; case AFX_CHORUS: break; case AFX_FLANGER: break; case AFX_FILTER: break; case AFX_DIST: break; case AFX_WAH: break; case AFX_EQ: break; case AFX_ENHANCER: break; case AFX_COMPRESSOR: break; case AFX_MAXIMIZER: break; } if(!reopen) return; if(audio_plugin_open(ins, a_settings.buffersize, a_settings.samplerate, a_settings.quality) < 0) return; /* FIXME: This should be done in a butler thread... */ if(audio_plugin_state(ins, FX_STATE_RUNNING) < 0) { audio_plugin_close(ins); return; } /* /FIXME */ /* FIXME: We rely on plugins loading their defaults. Plugins should FIXME: probably be able to export their default settings instead. */ #if 0 for(i = 0; i < 5; ++i) ins->control(ins, FXC_PARAM_1 + i, b->bctl[insert][ABC_FX1_PARAM_1 + i]); #endif b->bctl[insert][ABC_FX_TYPE] = fx; } void bus_ctl_set(unsigned bus, unsigned slot, unsigned ctl, int arg) { if(0 BDBG(+ 1)) { const char *ctls[] = { "ABC_FX_TYPE", "ABC_FX_PARAM_1", "ABC_FX_PARAM_2", "ABC_FX_PARAM_3", "ABC_FX_PARAM_4", "ABC_FX_PARAM_5", "ABC_FX_PARAM_6", "ABC_SEND_MASTER", "ABC_SEND_BUS_0", "ABC_SEND_BUS_1", "ABC_SEND_BUS_2", "ABC_SEND_BUS_3", "ABC_SEND_BUS_4", "ABC_SEND_BUS_5", "ABC_SEND_BUS_6", "ABC_SEND_BUS_7", "" }; unsigned c = ctl; if(ctl < ABC_FIRST || ctl > ABC_LAST) c = (unsigned)(ABC_LAST + 1); log_printf(DLOG, "Bus %u, slot %u %s set to %d\n", bus, slot, ctls[c], arg); } switch(ctl) { case ABC_FX_TYPE: if(arg != bustab[bus].bctl[slot][ctl]) __change_insert(bus, slot, arg); break; case ABC_FX_PARAM_1: case ABC_FX_PARAM_2: case ABC_FX_PARAM_3: case ABC_FX_PARAM_4: case ABC_FX_PARAM_5: case ABC_FX_PARAM_6: if(slot < 1) break; if(bustab[bus].insert[slot].current_state < FX_STATE_READY) break; bustab[bus].insert[slot].control(&bustab[bus].insert[slot], ctl - ABC_FX_PARAM_1 + FXC_PARAM_1, arg); bustab[bus].bctl[slot][ctl] = arg; break; default: if(slot >= AUDIO_MAX_INSERTS) break; if(ctl > ABC_LAST) break; bustab[bus].bctl[slot][ctl] = arg; break; } /* * This is where the "connection table" would be * updated in a more optimized implementation. */ } static int _is_open = 0; void audio_bus_open(void) { int i, s; if(_is_open) return; memset(bustab, 0, sizeof(bustab)); for(i = 0; i < AUDIO_MAX_BUSSES; ++i) { for(s = 0; s < AUDIO_MAX_INSERTS; ++s) memcpy(bustab[i].bctl[s], a_bus_def_ctl, sizeof(a_bus_def_ctl)); dcf6s_init(&bustab[i].dcfilter, a_settings.samplerate); dcf6s_set_f(&bustab[i].dcfilter, 10); bustab[i].in_use = 0; } _is_open = 1; } void audio_bus_close(void) { unsigned i, j; if(!_is_open) return; for(i = 0; i < AUDIO_MAX_BUSSES; ++i) for(j = 0; j < AUDIO_MAX_INSERTS; ++j) __change_insert(i, j, AFX_NONE); memset(bustab, 0, sizeof(bustab)); _is_open = 0; } KoboDeluxe-0.5.1/sound/a_commands.c0000644000175000001440000001177210703237623014103 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_commands.c - Asynchronous Command Interface for the audio engine --------------------------------------------------------------------------- * Copyright (C) 2001-2003, 2007 David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "kobolog.h" #include "a_globals.h" /* * These really shouldn't be here, but are * required for some shortcuts around here... */ #include "a_struct.h" #include "a_sequencer.h" #include "a_control.h" #undef DBG2D sfifo_t commands; static inline void __push_command(command_t *cmd) { if(sfifo_space(&commands) < sizeof(command_t)) { if(_audio_running) log_printf(WLOG, "Audio command FIFO overflow!\n"); return; } sfifo_write(&commands, cmd, (unsigned)sizeof(command_t)); } /*---------------------------------------------------------- Mixer Control ----------------------------------------------------------*/ void audio_bus_controlf(unsigned bus, unsigned slot, unsigned ctl, float arg) { audio_bus_control(bus, slot, ctl, (int)(arg * 65536.0)); } void audio_bus_control(unsigned bus, unsigned slot, unsigned ctl, int arg) { command_t cmd; #ifdef AUDIO_SAFE if(bus >= AUDIO_MAX_BUSSES) { log_printf(ELOG, "audio_bus_control(): Bus out of range!\n"); return; } if(ctl >= ABC_COUNT) { log_printf(ELOG, "audio_bus_control(): Control out of range!\n"); return; } #endif cmd.action = CMD_MCONTROL; cmd.cid = (signed char)bus; cmd.index = ctl; cmd.arg1 = (int)slot; cmd.arg2 = arg; __push_command(&cmd); } /*---------------------------------------------------------- Group Control ----------------------------------------------------------*/ void audio_group_stop(unsigned gid) { int i; #ifdef AUDIO_SAFE if(gid >= AUDIO_MAX_GROUPS) { log_printf(ELOG, "audio_group_stop(): Group out of range!\n"); return; } #endif /* FIXME: This isn't exactly thread safe... */ for(i = 0; i < AUDIO_MAX_VOICES; i++) { audio_channel_t *c; audio_voice_t *v = voicetab + i; if(VS_STOPPED == v->state) continue; c = v->channel; if((unsigned)c->ctl[ACC_GROUP] == gid) audio_channel_stop(i, -1); } } void audio_group_controlf(unsigned gid, unsigned ctl, float arg) { audio_group_control(gid, ctl, (int)(arg * 65536.0)); } void audio_group_control(unsigned gid, unsigned ctl, int arg) { command_t cmd; #ifdef AUDIO_SAFE if(gid >= AUDIO_MAX_GROUPS) { log_printf(ELOG, "audio_group_control(): Group out of range!\n"); return; } if(ctl >= ACC_COUNT) { log_printf(ELOG, "audio_group_control(): Control out of range!\n"); return; } #endif cmd.action = CMD_GCONTROL; cmd.cid = (char)gid; cmd.index = ctl; cmd.arg1 = arg; __push_command(&cmd); } /*---------------------------------------------------------- Channel Control ----------------------------------------------------------*/ void audio_channel_play(int cid, int tag, int pitch, int velocity) { command_t cmd; #ifdef AUDIO_SAFE if(cid < 0 || cid >= AUDIO_MAX_CHANNELS) { log_printf(ELOG, "audio_play(): Channel out of range!\n"); return; } #endif cmd.action = CMD_PLAY; cmd.cid = cid; cmd.tag = tag; cmd.arg1 = pitch; cmd.arg2 = velocity; __push_command(&cmd); } void audio_channel_controlf(int cid, int tag, int ctl, float arg) { if(ACC_IS_FIXEDPOINT(ctl)) arg *= 65536.0; audio_channel_control(cid, tag, ctl, (int)arg); } void audio_channel_control(int cid, int tag, int ctl, int arg) { command_t cmd; #ifdef AUDIO_SAFE if(cid < 0 || cid >= AUDIO_MAX_CHANNELS) { log_printf(ELOG, "audio_channel_control(): Channel out of range!\n"); return; } if(ctl < 0 || ctl >= ACC_COUNT) { log_printf(ELOG, "audio_channel_control(): Control out of range!\n"); return; } #endif cmd.action = CMD_CCONTROL; cmd.cid = cid; cmd.tag = tag; cmd.index = (unsigned char)ctl; cmd.arg1 = arg; __push_command(&cmd); } void audio_channel_stop(int cid, int tag) { command_t cmd; #ifdef AUDIO_SAFE if(cid >= AUDIO_MAX_CHANNELS) { log_printf(ELOG, "audio_stop(): Channel out of range!\n"); return; } #endif if(cid >= 0) cmd.action = CMD_STOP; else cmd.action = CMD_STOP_ALL; cmd.cid = cid; cmd.tag = tag; __push_command(&cmd); } int audio_channel_playing(int cid) { return channeltab[cid].playing; } void audio_bump(unsigned ms) { command_t cmd; cmd.action = CMD_WAIT; cmd.arg1 = (int)ms; __push_command(&cmd); } KoboDeluxe-0.5.1/sound/a_control.c0000644000175000001440000000707407503020222013747 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_control.c - Group/Channel/Voice Control Implementation --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * The control routing model: * * Group * ^ | * | V * MIDI -> Channel -> Patch ---> Voice * | |-> Voice * V ... ... * Bus Control '-> Voice * * Groups are used by Channels, to transform some of the control * data sent to them, before passing it on to the current Patch. * That is, they would effectively fit in in between Channels * and Patches, from the data flow POV. * * Note that while Groups act as passive data containers most of * the time, they *can* become active, and force Channels to * refresh some Controls. This can happen when changing the * "music volume" in an application, for example. FIXME: What about busses with non-linear insert effects? Looks like FIXME: at least *some* Group Controls should not be applied on the FIXME: Channel or Patch level, but rather on the Busses... Maybe FIXME: Busses should have 'group' fields? That way, one can still FIXME: use them as with the current design, although for example FIXME: ACC_VOLUME would be sent off to the bus send that acts as FIXME: master volume for all Voices of the Group. FIXME: Then again, this may result in general confusion! It's FIXME: theoretically possible to select busses on a *per-Voice FIXME: basis* (via Patches), and quite easy to select busses FIXME: directly using MIDI CCs. Good bye to application control FIXME: over the mixing...! FIXME: The only simple solution I can see is to prevent sending FIXME: between busses across group boundaries. */ #include "a_globals.h" #include "a_control.h" #include "a_tools.h" const int addtrans_min[2] = { -65536, 0 }; const int addtrans_max[2] = { 65536, 128<<16 }; const int addtrans_bias[2] = { 0, 60<<16 }; /*---------------------------------------------------------- Group Control ----------------------------------------------------------*/ void acc_group_set(unsigned gid, unsigned ctl, int arg) { int i; audio_group_t *g = grouptab + gid; g->ctl[ctl] = arg; if(!_audio_running) return; /* Update all channels of the group */ for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { audio_channel_t *c = channeltab + i; if((unsigned)c->ctl[ACC_GROUP] != gid) continue; (void)ce_control_i(c, 0, -1, ctl, c->rctl[ctl]); } } static int _is_open = 0; void audio_group_open(void) { int i; if(_is_open) return; memset(grouptab, 0, sizeof(grouptab)); for(i = 0; i < AUDIO_MAX_GROUPS; ++i) acc_copya(&grouptab[i].ctl, &a_group_def_ctl); _is_open = 1; } void audio_group_close(void) { if(!_is_open) return; memset(grouptab, 0, sizeof(grouptab)); _is_open = 0; } KoboDeluxe-0.5.1/sound/a_midicon.c0000644000175000001440000001747207670700342013731 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_midicon.c - Engine MIDI Control Implementation --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "kobolog.h" #include "a_midicon.h" #include "a_control.h" #include "a_math.h" #include "a_sequencer.h" static int first_channel = 0; #define MIDI_MAP_CH(x) ((x)+first_channel) #define CH_MAP_MIDI(x) ((x)-first_channel) static float fs = 44100; /* Exponential table which maps [0, 127] ==> [0, 65535] */ static unsigned short explut[128]; typedef struct midi_channel_t { /* Volume & velocity */ int volume; /* Linear [0, 65535] */ int pan; /* Linear [-65536, 65535] */ int velocity[128]; /* For each key, linear [0, 65535] */ /* Send control */ int send; /* Linear [0, 65535+] */ /* Pitch */ int bend_depth; int bend; int f_pitch; /* Key Management */ int last; signed char next[128]; /* Index-linked list :-) */ signed char prev[128]; /* Index-linked list :-) */ /* Voice Management */ int poly; int tag[128]; /* To keep track of individual notes */ /* Modulation */ unsigned mod; /* Bus Control */ unsigned ifx_slot; } midi_channel_t; static midi_channel_t m[16]; static void __init(void) { int i, j; for(i = 0; i < 16; ++i) { m[i].volume = 100*512; for(j = 0; j < 128; ++j) m[i].velocity[j] = 0; m[i].bend_depth = 12; m[i].bend = 0; m[i].f_pitch = 0; m[i].last = -1; memset(m[i].next, -1, sizeof(m[i].next)); memset(m[i].prev, -1, sizeof(m[i].prev)); m[i].poly = 1; memset(m[i].tag, -1, sizeof(m[i].tag)); m[i].mod = 0; } for(i = 0; i < 128; ++i) { float linear = (float)(i+1) / 128; explut[i] = (unsigned short)((0.25*linear + 0.5*linear*linear + 0.25*linear*linear*linear) * 65535.0); } #if 0 for(i = 0; i < 128; ++i) { int j; for(j=0; j < (explut[i]>>9); ++j) log_printf(D3LOG, "#"); log_printf(D3LOG, "\n"); } for(i = 0; i < 128; ++i) log_printf(D3LOG, "%d ==> %f\n", i, (float)explut[i]/65536.0); #endif } static inline void __poly(unsigned ch, unsigned on) { m[ch].poly = (int)on; /* FIXME: Maybe reimplement this somehow...? FIXME: acc_set(MIDI_MAP_CH(ch), ACC_DETACH, on ? ADM_POLY : ADM_MONO); */ } static inline void __press(unsigned ch, unsigned key) { m[ch].next[key] = -1; m[ch].prev[key] = m[ch].last; m[ch].next[m[ch].last] = (char)key; m[ch].last = (char)key; } /* * Returns the new last key (-1 if none), * or -2 if there's no change. */ static inline int __release(unsigned ch, unsigned key) { if(m[ch].prev[key] != -1) m[ch].next[m[ch].prev[key]] = m[ch].next[key]; if(m[ch].next[key] != -1) { m[ch].prev[m[ch].next[key]] = m[ch].prev[key]; m[ch].next[key] = m[ch].prev[key] = -1; return -2; } else { m[ch].last = m[ch].prev[key]; m[ch].next[key] = m[ch].prev[key] = -1; return m[ch].last; } } /* Returns 1 if the specified key on the specified channel is down. */ static inline int __is_down(unsigned ch, int key) { return (m[ch].tag[key] != -1); } static void midicon_note_off(unsigned ch, unsigned pitch, unsigned vel) { __release(ch, pitch); (void)ce_stop(channeltab + MIDI_MAP_CH(ch), 0, (int)pitch, (int)explut[vel]); } static void midicon_note_on(unsigned ch, unsigned pitch, unsigned vel) { if(!vel) { midicon_note_off(ch, pitch, 64); return; } m[ch].velocity[pitch] = (int)explut[vel]; (void)ce_start(channeltab + MIDI_MAP_CH(ch), 0, (int)pitch, (int)pitch << 16, m[ch].velocity[pitch]); __press(ch, pitch); } static void midicon_pitch_bend(unsigned ch, int bend) { m[ch].bend = bend << 3; m[ch].bend *= m[ch].bend_depth; (void)ce_control(channeltab + MIDI_MAP_CH(ch), 0, -1, ACC_PITCH, m[ch].bend + (60<<16)); } static void midicon_control_change(unsigned ch, unsigned ctrl, unsigned amt) { audio_channel_t *c = channeltab + MIDI_MAP_CH(ch); switch (ctrl) { case 1: m[ch].mod = amt; break; case 7: m[ch].volume = (int)explut[amt]; (void)ce_control(c, 0, -1, ACC_VOLUME, m[ch].volume); break; case 10: m[ch].pan = (amt << 10) - 65536; (void)ce_control(c, 0, -1, ACC_PAN, m[ch].pan); break; /* Bus Control */ case 39: /* Select IFX Slot */ m[ch].ifx_slot = (unsigned)amt; break; case 40: /* IFX Type */ if(ch >= AUDIO_MAX_BUSSES) break; if(m[ch].ifx_slot > AUDIO_MAX_INSERTS-1) break; bus_ctl_set(ch, m[ch].ifx_slot, ABC_FX_TYPE, (int)amt); break; case 41: /* IFX P1 (Time 1) */ case 42: /* IFX P2 (Time 2) */ case 43: /* IFX P3 (Depth 1) */ case 44: /* IFX P4 (Depth 2)*/ case 45: /* IFX P5 (Rate) */ case 46: /* IFX P6 (Mode/Special) */ if(ch >= AUDIO_MAX_BUSSES) break; if(m[ch].ifx_slot > AUDIO_MAX_INSERTS-1) break; if(ctrl != 46) amt = (unsigned)(explut[amt]) << 1; bus_ctl_set(ch, m[ch].ifx_slot, ctrl - 41 + ABC_FX_PARAM_1, (int)amt); break; case 47: /* IFX Wet -> master */ if(ch >= AUDIO_MAX_BUSSES) break; if(m[ch].ifx_slot > AUDIO_MAX_INSERTS-1) break; bus_ctl_set(ch, m[ch].ifx_slot, ABC_SEND_MASTER, explut[amt] << 1); break; case 48: /* Sends to other busses */ case 49: case 50: case 51: case 52: case 53: case 54: case 55: if(ch >= AUDIO_MAX_BUSSES) break; if(m[ch].ifx_slot > AUDIO_MAX_INSERTS-1) break; bus_ctl_set(ch, m[ch].ifx_slot, ABC_SEND_BUS_0 + ctrl-48, explut[amt] << 1); break; case 88: /* Primary output bus */ (void)ce_control(c, 0, -1, ACC_PRIM_BUS, amt-1); break; case 89: /* Send bus */ (void)ce_control(c, 0, -1, ACC_SEND_BUS, amt-1); break; case 91: /* Send Level ("Reverb") */ m[ch].send = (int)explut[amt] << 1; (void)ce_control(c, 0, -1, ACC_SEND, m[ch].send); break; case 120: /* All Sound Off */ case 123: /* All Notes Off */ if(m[ch].poly) { int note = m[ch].last; while(note >= 0) { int n = note; note = m[ch].prev[note]; midicon_note_off(ch, (unsigned)n, 64); } } else midicon_note_off(ch, (unsigned)m[ch].last, 64); break; case 121: /* Reset All Controllers */ __poly(ch, 1); m[ch].mod = 0; m[ch].volume = 100*512; m[ch].send = 0; m[ch].pan = 0; (void)ce_control(c, 0, -1, ACC_VOLUME, m[ch].volume); (void)ce_control(c, 0, -1, ACC_SEND, m[ch].send); (void)ce_control(c, 0, -1, ACC_PAN, m[ch].pan); midicon_pitch_bend(ch, 0); break; case 126: /* Mono */ __poly(ch, 0); break; case 127: /* Poly */ __poly(ch, 1); break; default: break; } } static void midicon_program_change(unsigned ch, unsigned prog) { (void)ce_control(channeltab + MIDI_MAP_CH(ch), 0, -2, ACC_PATCH, (int)prog); } midisock_t midicon_midisock = { midicon_note_off, midicon_note_on, NULL, /* poly_pressure */ midicon_control_change, midicon_program_change, NULL, /* channel_pressure */ midicon_pitch_bend }; int midicon_open(float framerate, int first_ch) { unsigned i; aev_client("midicon_open()"); fs = framerate; first_channel = first_ch; __init(); for(i = 0; i < 16; ++i) __poly(i, 1); return 0; } void midicon_close(void) { aev_client("midicon_close()"); } void midicon_process(unsigned frames) { aev_client("midicon_process()"); /* * This is where MIDI clock and stuff goes. */ } KoboDeluxe-0.5.1/sound/a_midifile.c0000664000175000001440000004253107670702636014075 00000000000000/*(LGPL) ------------------------------------------------------------ a_midifile.c - MIDI file loader and player ------------------------------------------------------------ * Stolen from the AdPlug player, stripped down, * translated into C, and adapted for the Audio Engine * by David Olofson, 2002. * * Below is the original copyright. Of course, the LGPL * license still applies. ------------------------------------------------------------ * Adplug - Replayer for many OPL2/OPL3 audio file formats. * Copyright (C) 1999, 2000, 2001 Simon Peter, , et al. * * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * * MIDI & MIDI-like file player - Last Update: 8/16/2000 * by Phil Hassey - www.imitationpickles.org * philhassey@hotmail.com * * Can play the following * .LAA - a raw save of a Lucas Arts Adlib music * or * a raw save of a LucasFilm Adlib music * .MID - a "midi" save of a Lucas Arts Adlib music * - or general MIDI files * .CMF - Creative Music Format * .SCI - the sierra "midi" format. * Files must be in the form * xxxNAME.sci * So that the loader can load the right patch file: * xxxPATCH.003 (patch.003 must be saved from the * sierra resource from each game.) * * 6/2/2000: v1.0 relased by phil hassey * Status: LAA is almost perfect * - some volumes are a bit off (intrument too quiet) * MID is fine (who wants to listen to MIDI vid adlib anyway) * CMF is okay (still needs the adlib rythm mode implemented * for real) * 6/6/2000: * Status: SCI: there are two SCI formats, orginal and advanced. * original: (Found in SCI/EGA Sierra Adventures) * played almost perfectly, I believe * there is one mistake in the instrument * loader that causes some sounds to * not be quite right. Most sounds are fine. * advanced: (Found in SCI/VGA Sierra Adventures) * These are multi-track files. (Thus the * player had to be modified to work with * them.) This works fine. * There are also multiple tunes in each file. * I think some of them are supposed to be * played at the same time, but I'm not sure * when. * 8/16/200: * Status: LAA: now EGA and VGA lucas games work pretty well * * Other acknowledgements: * Allegro - for the midi instruments and the midi volume table * SCUMM Revisited - for getting the .LAA / .MIDs out of those * LucasArts files. * FreeSCI - for some information on the sci music files * SD - the SCI Decoder (to get all .sci out of the Sierra files) */ /* TODO: * Number of subsongs and other stuff should be checked in mf_open(), rather than in mp_rewind(). */ #undef TESTING #undef TESTING2 #include #include #include #include #include "kobolog.h" #include "a_midifile.h" #ifdef TESTING #define midiprintf log_printf #else static inline void midiprintf(int level, const char *format, ...) { } #endif #ifdef TESTING2 #define midiprintf2 log_printf #else static inline void midiprintf2(int level, const char *format, ...) { } #endif static inline unsigned char datalook(midi_player_t *mp, unsigned pos) { if(pos < 0 || pos > mp->mf->flen) return 0; return mp->mf->data[pos]; } static inline unsigned getnext(midi_player_t *mp, unsigned num) { unsigned v = 0; unsigned i; for(i = 0; i < num; i++) { v <<= 8; v += datalook(mp, mp->pos); mp->pos++; } return v; } static inline unsigned getval(midi_player_t *mp) { unsigned v = 0; unsigned char b; b = (unsigned char)getnext(mp, 1); v = b & 0x7f; while((b & 0x80) != 0) { b = (unsigned char)getnext(mp, 1); v = (v << 7) + (b & 0x7F); } return v; } static inline void set_tempo(midi_player_t *mp, unsigned ppqn, unsigned usqtr) { mp->c.ppqn = ppqn; mp->c.usqtr = usqtr; mp->c.spulse = (float)usqtr / (float)ppqn / 1000000.0; midiprintf(D2LOG, "ppqn = %u ", ppqn); midiprintf(D2LOG, "µsqtr = %u ", usqtr); midiprintf(D2LOG, "spulse = %f ", mp->c.spulse); } static int matchnext(midi_player_t *mp, const char *s, unsigned len) { while(len--) if(getnext(mp, 1) != (unsigned)(((int)*s++) & 0xff)) return 0; return 1; } static int readheader(midi_player_t *mp, const char *s) { if(!matchnext(mp, s, 4)) return -1; return (int)getnext(mp, 4); } static int printnext(midi_player_t *mp, unsigned len) { #ifdef TESTING midiprintf(D2LOG, "\""); while(len--) { unsigned int ch = getnext(mp, 1); if(ch < 32) midiprintf(D2LOG, "."); else midiprintf(D2LOG, "%c", (char)ch); } midiprintf(D2LOG, "\""); #else while(len--) getnext(mp, 1); #endif return 1; } /* FIXME: This won't work if there are signature changes... */ static void mp_print_time(midi_player_t *mp, unsigned pulses) { #ifdef TESTING unsigned beatval, beat, tick, bar; if(mp->c.timesig.value) beatval = mp->c.ppqn * 4 / mp->c.timesig.value; else beatval = 120; beat = pulses / beatval; tick = pulses % beatval; if(mp->c.timesig.beats) { bar = beat / mp->c.timesig.beats; beat = beat % mp->c.timesig.beats; } else { bar = beat / 4; beat = beat % 4; } midiprintf(D2LOG, "(%u:%u:%u)", bar+1, beat+1, tick); #endif } static long filelength(FILE *f) { long buf, size; buf = ftell(f); if(buf < 0) return buf; size = fseek(f, 0, SEEK_END); if(size < 0) return size; size = ftell(f); if(size < 0) return size; fseek(f, buf, SEEK_SET); return size; } midi_file_t *mf_open(const char *name) { FILE *f; unsigned char s[6]; midi_file_t *mf = calloc(1, sizeof(midi_file_t)); if(!mf) return NULL; mf->title = mf->author = ""; mf->remarks = ""; f = fopen(name, "rb"); if(!f) { free(mf); return NULL; } if(fread(s, 6, 1, f) != 1) { fclose(f); free(mf); return NULL; } if(!memcmp(s, "MThd", 4)) mf->subsongs = 1; else { mf->subsongs = 0; fclose(f); free(mf); return NULL; } fseek(f, 0, SEEK_SET); mf->flen = (unsigned)filelength(f); mf->data = malloc(mf->flen); if(!mf->data) { fclose(f); free(mf); return NULL; } if(fread(mf->data, mf->flen, 1, f) != 1) { fclose(f); free(mf->data); free(mf); return NULL; } fclose(f); return mf; } void mf_close(midi_file_t *mf) { if(!mf) return; free(mf->data); free(mf); } int mp_select(midi_player_t *mp, midi_file_t *midifile) { mp_stop(mp); mp->mf = midifile; mp_rewind(mp, 0); return 0; } static void mp_mark_loop(midi_player_t *mp) { int i; for(i = 0; i < 16; i++) if(mp->track[i].enabled) mp->track[i].loop_start = mp->track[i].c; mp->loop_start = mp->c; mp_print_time(mp, mp->c.time); midiprintf(D2LOG, ": mp_mark_loop\n"); } static void mp_loop(midi_player_t *mp) { int i; for(i = 0; i < 16; i++) if(mp->track[i].enabled) mp->track[i].c = mp->track[i].loop_start; mp_print_time(mp, mp->c.time); midiprintf(D2LOG, ": mp_loop\n"); mp->c = mp->loop_start; } static int mp_parse_command(midi_player_t *mp, unsigned len) { char buf[128]; unsigned i; for(i = 0; i < len; i++) { if(i < 127) buf[i] = (char)datalook(mp, mp->pos); mp->pos++; } buf[len < 127 ? len : 127] = 0; if('#' != buf[0]) { midiprintf(D2LOG, "Marker: %s", buf); return 0; } if(!memcmp(buf + 1, "LOOP", 4)) { if(!memcmp(buf + 5, "_START", 6)) mp_mark_loop(mp); else if(!memcmp(buf + 5, "_END", 4)) { mp_loop(mp); return 1; } } return 0; } static void mp_read_time_sig(midi_player_t *mp) { mp_timesig_t *ts = &mp->c.timesig; ts->beats = getnext(mp, 1); ts->value = 1 << getnext(mp, 1); ts->clock = getnext(mp, 1); ts->qn = getnext(mp, 1); midiprintf(D2LOG, "Time Sig: %d/%d;", ts->beats, ts->value); midiprintf(D2LOG, " %d clock %d qn", ts->clock, ts->qn); } #define FOR_TRACKS_ON for(trk = 0; trk < 16; trk++) \ if(mp->track[trk].c.on) int mp_update(midi_player_t *mp) { unsigned note, vel, ctrl, x, l; unsigned i, j, c; int trk, ret; if(mp->doing == 1) { /* just get the first wait and ignore it :> */ midiprintf(D2LOG, "Initial wait: "); FOR_TRACKS_ON { mp_track_t *mt = mp->track + trk; mp->pos = mt->c.pos; mt->c.iwait += getval(mp); midiprintf(D2LOG, "%d:%u ", trk, mt->c.iwait); mt->c.pos = mp->pos; } mp->doing = 0; midiprintf(D2LOG, "\n\n"); } do { ret = 0; FOR_TRACKS_ON { mp_track_t *mt = mp->track + trk; if(mt->c.iwait) continue; if(mt->c.pos >= mt->tend) { midiprintf(D2LOG, "(%d) End Of Track\n", trk); mt->c.on = 0; continue; } ret = 1; midiprintf2(D2LOG, "<%u>: ", mt->c.pos); mp->pos = mt->c.pos; x = getnext(mp, 1); /* This is for MIDI "running status" */ if(x < 0x80) { x = mt->c.pv; mp->pos--; } mt->c.pv = (unsigned char)x; c = x & 0x0f; midiprintf2(D2LOG, "(%d)[%2X]", trk, x); switch (x & 0xf0) { case 0x80: /* note off */ note = getnext(mp, 1) + (mp->pitch >> 16); if(note > 127) note = 127; else if(note < 0) note = 0; vel = getnext(mp, 1); if(mp->sock->note_off) mp->sock->note_off(c, note, vel); break; case 0x90: /* note on */ /* doing=0; */ note = getnext(mp, 1) + (mp->pitch >> 16); if(note > 127) note = 127; else if(note < 0) note = 0; vel = getnext(mp, 1); if(mp->sock->note_on) mp->sock->note_on(c, note, vel); break; case 0xa0: /* key aftertouch */ note = getnext(mp, 1) + (mp->pitch >> 16); if(note > 127) note = 127; else if(note < 0) note = 0; vel = getnext(mp, 1); if(mp->sock->poly_pressure) mp->sock->poly_pressure(c, note, vel); break; case 0xb0: /* control change */ ctrl = getnext(mp, 1); vel = getnext(mp, 1); if(mp->sock->control_change) mp->sock->control_change(c, ctrl, vel); break; case 0xc0: /* patch change */ x = getnext(mp, 1); if(mp->sock->program_change) mp->sock->program_change(c, x); break; case 0xd0: /* channel aftertouch */ x = getnext(mp, 1); if(mp->sock->channel_pressure) mp->sock->channel_pressure(c, x); break; case 0xe0: /* pitch wheel */ x = getnext(mp, 1); x |= getnext(mp, 1) << 7; if(mp->sock->pitch_bend) mp->sock->pitch_bend(c, (int)x - 8192); break; case 0xf0: switch (x) { case 0xf0: case 0xf7: /* sysex */ l = getval(mp); i = (datalook(mp, mp->pos + l) == 0xf7); midiprintf2(D2LOG, "{%ld}", l); midiprintf2(D2LOG, "\n"); for(j = 0; j < l; j++) midiprintf2(D2LOG, "%2lX ", getnext(mp, 1)); midiprintf2(D2LOG, "\n"); if(i) getnext(mp, 1); break; case 0xf1: break; case 0xf2: getnext(mp, 2); break; case 0xf3: getnext(mp, 1); break; case 0xf4: break; case 0xf5: break; case 0xf6: /* something */ case 0xf8: case 0xfa: case 0xfb: case 0xfc: break; case 0xfe: break; case 0xfd: break; case 0xff: x = getnext(mp, 1); l = getval(mp); midiprintf(D2LOG, " {%X (%X): ", x, l); switch(x) { case 1: midiprintf(D2LOG, "Text: "); printnext(mp, l); break; case 2: midiprintf(D2LOG, "Copyright: "); printnext(mp, l); break; case 3: midiprintf(D2LOG, "Track Name: "); printnext(mp, l); break; case 4: midiprintf(D2LOG, "Instrument: "); printnext(mp, l); break; case 5: midiprintf(D2LOG, "Lyric: "); printnext(mp, l); break; case 6: if(mp_parse_command(mp, l)) { trk = -1; continue; } break; case 7: midiprintf(D2LOG, "Cue Point: "); printnext(mp, l); break; case 8: case 9: case 10: case 11: case 12: case 13: case 14: case 15: midiprintf(D2LOG, "Text event: "); printnext(mp, l); break; case 0x21: /* MIDI Port # */ x = getnext(mp, 1); midiprintf(D2LOG, "Port %u", x); break; case 0x2f: /* End Of Track */ mt->c.on = 0; midiprintf(D2LOG, "End Of Track"); break; case 0x51: /* Set Tempo */ x = getnext(mp, l); set_tempo(mp, mp->c.ppqn, x); midiprintf(D2LOG, "(µsqtr:%u ==> BPM:%f)", mp->c.usqtr, 60.0*1000000.0 / (float)mp->c.usqtr); break; case 0x58: /* Time signature */ mp_read_time_sig(mp); break; default: for(i = 0; i < l; i++) midiprintf2(D2LOG, "%2lX ", getnext(mp, 1)); break; } midiprintf(D2LOG, "}\n"); break; } break; default: /* if we get down here, an error occurred */ log_printf(ELOG, "a_midifile.c: INTERNAL ERROR;" " illegal status byte!\n"); break; } if(mt->c.on) mt->c.iwait = getval(mp); mt->c.pos = mp->pos; midiprintf2(D2LOG, "\n"); } } while(ret); /* Find first track to play */ mp->c.iwait = 1000000000; /* Bigger than any wait can be! */ FOR_TRACKS_ON if(mp->track[trk].c.iwait < mp->c.iwait) mp->c.iwait = mp->track[trk].c.iwait; if(1000000000 == mp->c.iwait) { /* No tracks playing! */ mp->c.iwait = 0; mp->c.fwait = 1000; return 0; } /* Calculate time to next event */ mp->c.fwait = mp->c.iwait * mp->c.spulse; midiprintf2(D2LOG, "fwait = %f\n", mp->c.fwait); /* Update "track timers" and check if any tracks are playing */ ret = 0; midiprintf2(D2LOG, "Wait: "); FOR_TRACKS_ON { ret = 1; mp->track[trk].c.iwait -= mp->c.iwait; midiprintf2(D2LOG, "%d:%ld ", trk, mp->track[trk].c.iwait); } midiprintf2(D2LOG, "\n"); /* Update song time */ mp->c.time += mp->c.iwait; midiprintf2(D2LOG, "----------------------------\n"); return ret; } #undef FOR_TRACKS_ON int mp_play(midi_player_t *mp, float dt) { if(!mp->mf) return 0; while(dt > 0.0) { if(dt < mp->c.fwait) { mp->c.fwait -= dt; return 1; } dt -= mp->c.fwait; if(!mp_update(mp)) return 0; } return 1; } void mp_stop(midi_player_t *mp) { unsigned c; if(!mp) return; if(!mp->sock->control_change) return; for(c = 0; c < 16; ++c) { mp->sock->control_change(c, 120, 1); mp->sock->control_change(c, 121, 1); mp->sock->control_change(c, 123, 1); } mp->mf = NULL; } void mp_rewind(midi_player_t *mp, unsigned subsong) { unsigned i; int len; if(!mp->mf) return; mp->pos = 0; set_tempo(mp, 250, (unsigned)(1000.0 / (120.0/60.0))); mp->c.time = 0; mp->c.fwait = 0; mp->c.iwait = 0; mp->mf->subsongs = 1; for(i = 0; i < 16; i++) { mp->track[i].tend = 0; mp->track[i].spos = 0; mp->track[i].c.pos = 0; mp->track[i].c.iwait = 0; mp->track[i].c.on = 0; mp->track[i].c.pv = 0; } len = readheader(mp, "MThd"); if(len < 0) { log_printf(ELOG, "mp_rewind(): Is this a MIDI file...?\n"); mp->mf = NULL; return; } midiprintf(D2LOG, "header length:%d\n", len); if(len >= 6) { mp->mf->format = getnext(mp, 2); mp->mf->tracks = getnext(mp, 2); set_tempo(mp, getnext(mp, 2), mp->c.usqtr); midiprintf(D2LOG, "format:%u\n", mp->mf->format); midiprintf(D2LOG, "tracks:%u\n", mp->mf->tracks); midiprintf(D2LOG, " ppqn:%u\n", mp->c.ppqn); if(0 == mp->mf->format) mp->mf->tracks = 1; } else { log_printf(ELOG, "mp_rewind(): WARNING: Short header!\n"); mp->mf->format = 0; mp->mf->tracks = 1; } if(len > 6) getnext(mp, (unsigned)(len - 6)); /* Skip rest of header */ if(mp->mf->tracks > 16) { log_printf(ELOG, "mp_rewind(): WARNING: Too many tracks!\n"); mp->mf->tracks = 16; } for(i = 0; i < mp->mf->tracks; ++i) { len = readheader(mp, "MTrk"); if(len < 0) { log_printf(ELOG, "mp_rewind(): Bad MIDI file!\n"); mp->mf = NULL; return; } mp->track[i].enabled = 1; mp->track[i].c.on = 1; mp->track[i].spos = mp->pos; mp->track[i].tend = mp->pos + len; midiprintf(D2LOG, "track %u; start:%u length:%d\n", i, mp->track[i].spos, len); getnext(mp, (unsigned)len); } for(i = 0; i < 16; i++) if(mp->track[i].enabled) { mp->track[i].c.pos = mp->track[i].spos; mp->track[i].c.pv = 0; mp->track[i].c.iwait = 0; mp->track[i].loop_start = mp->track[i].c; } mp->doing = 1; } midi_player_t *mp_open(midisock_t *ms) { midi_player_t *mp = calloc(1, sizeof(midi_player_t)); if(!mp) return NULL; mp->sock = ms; mp->mf = NULL; return mp; } void mp_close(midi_player_t *mp) { mp_stop(mp); free(mp); } KoboDeluxe-0.5.1/sound/a_plugin.c0000644000175000001440000001421410711175717013576 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_plugin.c - Audio Engine Plugin API --------------------------------------------------------------------------- * Copyright (C) 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_plugin.h" #include "a_tools.h" static int usecount = 0; #define EMULBUF_FRAMES 256 static int *emulbuf = NULL; static int init_emulbuf(void) { if(!emulbuf) emulbuf = malloc(EMULBUF_FRAMES * sizeof(int) * 2); if(!emulbuf) return -1; return 0; } int audio_plugin_state(audio_plugin_t *p, audio_fxstates_t new_state) { int res, s = p->current_state; /* We don't care about SILENT and RESTING here. */ if(s > FX_STATE_RUNNING) s = FX_STATE_RUNNING; /* Nor do we allow forced switches to SILENT or RESTING! */ if(new_state > FX_STATE_RUNNING) return -1; while(new_state > s) { ++s; res = p->state(p, s); if(res < 0) return res; p->current_state = s; } while(new_state < s) { --s; res = p->state(p, s); if(res < 0) return res; p->current_state = s; switch(new_state) { case FX_STATE_CLOSED: free(p->ctl); p->ctl = NULL; --usecount; if(usecount <= 0) { free(emulbuf); emulbuf = NULL; usecount = 0; } break; case FX_STATE_OPEN: case FX_STATE_READY: case FX_STATE_PAUSED: case FX_STATE_RUNNING: /* Can't happen. */ case FX_STATE_SILENT: /* Can't happen. */ case FX_STATE_RESTING: /* Can't happen. */ break; } } return 0; } int default_state(struct audio_plugin_t *p, audio_fxstates_t new_state) { if(new_state > p->current_state) switch(new_state) { case FX_STATE_CLOSED: /* Can't happen. */ case FX_STATE_OPEN: if(!audio_plugin_alloc_ctls(p, FXC_COUNT)) return -1; break; case FX_STATE_READY: case FX_STATE_PAUSED: case FX_STATE_RUNNING: case FX_STATE_SILENT: /* Can't happen. */ case FX_STATE_RESTING: /* Can't happen. */ break; } else switch(new_state) { case FX_STATE_CLOSED: case FX_STATE_OPEN: case FX_STATE_READY: case FX_STATE_PAUSED: case FX_STATE_RUNNING: case FX_STATE_SILENT: case FX_STATE_RESTING: /* Can't happen. */ break; } return 0; } #define SPLIT_BUFFER \ unsigned s, f; \ for(s = 0; f = (unsigned)(frames > EMULBUF_FRAMES ? \ EMULBUF_FRAMES : frames), \ s < frames; s += f) void default_control(struct audio_plugin_t *p, unsigned ctl, int arg) { if((ctl < p->controls) && p->ctl) p->ctl[ctl] = arg; } static void process_with_process_r(struct audio_plugin_t *p, int *buf, unsigned frames) { p->process_r(p, buf, buf, frames); } static void process_with_process_m(struct audio_plugin_t *p, int *buf, unsigned frames) { SPLIT_BUFFER { s32clear(emulbuf + s, f); p->process_r(p, buf + s, emulbuf + s, f); s32copy(emulbuf + s, buf + s, f); } } static void process_r_with_process(struct audio_plugin_t *p, int *in, int *out, unsigned frames) { if(in) s32copy(in, out, frames); else s32clear(out, frames); p->process(p, out, frames); } static void process_r_with_process_m(struct audio_plugin_t *p, int *in, int *out, unsigned frames) { s32clear(out, frames); p->process_m(p, in, out, frames); } static void process_m_with_process(struct audio_plugin_t *p, int *in, int *out, unsigned frames) { SPLIT_BUFFER { if(in) s32copy(in + s, emulbuf + s, f); else s32clear(emulbuf + s, f); p->process(p, emulbuf + s, f); s32add(emulbuf + s, out + s, f); } } static void process_m_with_process_r(struct audio_plugin_t *p, int *in, int *out, unsigned frames) { SPLIT_BUFFER { if(in) p->process_r(p, in + s, emulbuf + s, f); else p->process_r(p, NULL, emulbuf + s, f); s32add(emulbuf + s, out + s, f); } } int audio_plugin_init(audio_plugin_t *p) { int uses_emulbuf = 0; /* * This may change, but right now, a plugin cannot * generate *any* useful form of output without at * least one process*() callback, so... */ if(!p->process && !p->process_r && !p->process_m) return -1; /* Must have at least one! */ if(!p->state) p->state = default_state; if(!p->control) p->control = default_control; if(!p->process) { if(p->process_r) p->process = process_with_process_r; else if(p->process_m) { p->process = process_with_process_m; uses_emulbuf = 1; } } if(!p->process_r) { if(p->process) p->process_r = process_r_with_process; else if(p->process_m) p->process_r = process_r_with_process_m; } if(!p->process_m) { if(p->process) { p->process_m = process_m_with_process; uses_emulbuf = 1; } else if(p->process_r) { p->process_m = process_m_with_process_r; uses_emulbuf = 1; } } if(uses_emulbuf) return init_emulbuf(); return 0; } int audio_plugin_open(audio_plugin_t *p, unsigned max_frames, int fs, int quality) { int res = audio_plugin_init(p); if(res < 0) return res; res = audio_plugin_state(p, FX_STATE_OPEN); if(res < 0) return res; p->control(p, FXC_MAX_FRAMES, (int)max_frames); p->control(p, FXC_SAMPLERATE, fs); p->control(p, FXC_QUALITY, quality); ++usecount; return 0; } void audio_plugin_close(audio_plugin_t *p) { audio_plugin_state(p, FX_STATE_CLOSED); } /*---------------------------------------------------------- Tools for plugins (NOT for hosts!) ----------------------------------------------------------*/ int *audio_plugin_alloc_ctls(audio_plugin_t *p, unsigned count) { p->controls = count; p->ctl = calloc(p->controls, sizeof(int)); return p->ctl; } KoboDeluxe-0.5.1/sound/a_delay.c0000644000175000001440000003060007670701214013370 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_delay.c - Feedback delay w/ LP filter --------------------------------------------------------------------------- * Copyright (C) 2001, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_globals.h" #include "a_delay.h" #include "a_tools.h" #define DELAY_BUFSIZE 65536 #define DELAY_MAX_TAPS 16 #define DELAY_MAX_TAIL_TAPS 8 typedef struct dtap_t { unsigned delay; int shift; } dtap_t; typedef struct delay_t { int *delaybuf; int inspos; int cl, cr, lpf; /* LPF */ int level; unsigned taps, tailtaps; int ttimer; float tlevel; dtap_t tap[DELAY_MAX_TAPS]; dtap_t tailtap[DELAY_MAX_TAIL_TAPS]; } delay_t; #define DELAY_MASK (DELAY_BUFSIZE-1) #define INTERNAL_BITS 8 static int _init(delay_t *d) { d->inspos = 0; d->cl = 0; d->cr = 0; d->delaybuf = calloc(1, sizeof(int)*DELAY_BUFSIZE); if(!d->delaybuf) return -2; return 0; } #define DB(x) delaybuf[(inspos-(x)) & DELAY_MASK] #define TAP(n) (DB(d->tap[n].delay) >> d->tap[n].shift) #define TTAP(n) (DB(d->tailtap[n].delay) >> d->tailtap[n].shift) #if 0 /* Stereo in, stereo out */ static void o_delay_process_mix_s(delay_t *d, int *in, int *out, unsigned frames) { int *delaybuf = d->delaybuf; int inspos = d->inspos; int cl = d->cl; int cr = d->cr; unsigned s = frames; int outl, outr; int vm = d->level >> 8; int i; while(s--) { /* Feedback with LP filters */ cl += (TTAP(0) + TTAP(3) + TTAP(4) - cl) >> 3; cr += (TTAP(1) + TTAP(2) + TTAP(5) - cr) >> 3; DB(0) = cl; DB(1) = cr; /* "Tap 0" */ outl = cl; outr = cr; /* Taps */ for(i = 0; i < d->taps; i += 2) { outl += TAP(i); outr += TAP(i+1); } /* Input */ DB(0) += in[0]; DB(1) += in[1]; /* Output */ out[0] += (outl*vm)>>8; out[1] += (outr*vm)>>8; inspos += 2; in += 2; out += 2; } d->cl = cl; d->cr = cr; d->inspos = inspos; } #endif /* * Stereo, replacing, without level control. */ static void o_delay_process_r_s(delay_t *d, int *in, int *out, unsigned frames) { int *delaybuf = d->delaybuf; int inspos = d->inspos; int cl = d->cl; int cr = d->cr; unsigned s = frames; int outl, outr; unsigned i; while(s--) { /* Tail taps */ outl = outr = 0; for(i = 0; i < d->tailtaps; i += 2) { outl += TTAP(i); outr += TTAP(i+1); } /* LPF */ // cl += (outl - (cl>>INTERNAL_BITS)) * d->lpf; // cr += (outr - (cr>>INTERNAL_BITS)) * d->lpf; cl += (outl - cl) * d->lpf >> INTERNAL_BITS; cr += (outr - cr) * d->lpf >> INTERNAL_BITS; /* Feedback */ DB(0) = cl;// >> INTERNAL_BITS; DB(1) = cr;// >> INTERNAL_BITS; /* "Tap 0" */ outl = cl; outr = cr; /* Taps */ for(i = 0; i < d->taps; i += 2) { outl += TAP(i); outr += TAP(i+1); } /* Input */ DB(0) += in[0] << INTERNAL_BITS; DB(1) += in[1] << INTERNAL_BITS; /* Output */ out[0] = outl >> INTERNAL_BITS; out[1] = outr >> INTERNAL_BITS; inspos += 2; in += 2; out += 2; } d->cl = cl; d->cr = cr; d->inspos = inspos; } /* * Stereo, replacing in-place, without output level control * (for inserts) */ static void o_delay_process_s(delay_t *d, int *buf, unsigned frames) { int *delaybuf = d->delaybuf; int inspos = d->inspos; int cl = d->cl; int cr = d->cr; int outl, outr; unsigned i, s; frames <<= 1; for(s = 0; s < frames; s += 2) { /* Tail taps */ outl = outr = 0; for(i = 0; i < d->tailtaps; i += 2) { outl += TTAP(i); outr += TTAP(i+1); } /* LP filters */ // cl += (outl - (cl>>INTERNAL_BITS)) * d->lpf; // cr += (outr - (cr>>INTERNAL_BITS)) * d->lpf; cl += (outl - cl) * d->lpf >> INTERNAL_BITS; cr += (outr - cr) * d->lpf >> INTERNAL_BITS; /* Input + Feedback */ DB(0) = cl + (buf[s] << INTERNAL_BITS); DB(1) = cr + (buf[s+1] << INTERNAL_BITS); /* "Tap 0" - the Feedback Signal */ outl = cl; outr = cr; /* Early Reflection Taps */ for(i = 0; i < d->taps; i += 2) { outl += TAP(i); outr += TAP(i+1); } /* Output */ buf[s] = outl >> INTERNAL_BITS; buf[s+1] = outr >> INTERNAL_BITS; inspos += 2; } d->cl = cl; d->cr = cr; d->inspos = inspos; } /* * Stereo, replacing, with silent input and no level control. * Returns the approximate peak level of the generated output. */ static int o_delay_process_tail_s(delay_t *d, int *out, unsigned frames) { int level = 0; int *delaybuf = d->delaybuf; int inspos = d->inspos; int cl = d->cl; int cr = d->cr; int outl, outr; unsigned i, s; frames <<= 1; for(s = 0; s < frames; s += 2) { /* Tail taps */ outl = outr = 0; for(i = 0; i < d->tailtaps; i += 2) { outl += TTAP(i); outr += TTAP(i+1); } /* LP filters */ // cl += (outl - (cl>>INTERNAL_BITS)) * d->lpf; // cr += (outr - (cr>>INTERNAL_BITS)) * d->lpf; cl += (outl - cl) * d->lpf >> INTERNAL_BITS; cr += (outr - cr) * d->lpf >> INTERNAL_BITS; /* Feedback (No input!) */ DB(0) = cl; DB(1) = cr; /* "Tap 0" - the Feedback Signal */ outl = cl; outr = cr; /* Early Reflection Taps */ for(i = 0; i < d->taps; i += 2) { outl += TAP(i); outr += TAP(i+1); } /* Output */ out[s] = outl >> INTERNAL_BITS; out[s+1] = outr >> INTERNAL_BITS; /* Level meter */ level |= labs(outl) | labs(outr); inspos += 2; } d->cl = cl; d->cr = cr; d->inspos = inspos; return level >> INTERNAL_BITS; } #if 0 /* UNTESTED: Mono in, stereo out. Obviously not in-place capable! */ void o_delay_process_mix_ms(delay_t *d, int *in, int *out, unsigned frames) { int *delaybuf = d->delaybuf; int inspos = d->inspos; int cl = d->cl; int cr = d->cr; int s = frames; int outl, outr; int vm = d->level >> 8; int i; while(s--) { /* Feedback with LP filters */ cl += (TTAP(0) + TTAP(3) + TTAP(4) - cl) >> 3; cr += (TTAP(1) + TTAP(2) + TTAP(5) - cr) >> 3; DB(0) = cl; DB(1) = cr; /* "Tap 0" */ outl = cl; outr = cr; /* Taps */ for(i = 0; i < d->taps; i += 2) { outl += TAP(i); outr += TAP(i+1); } /* Input */ DB(0) += in[0]; DB(1) += in[0]; /* Output */ out[0] += (outl*vm)>>8; out[1] += (outr*vm)>>8; inspos += 2; in += 1; out += 2; } d->cl = cl; d->cr = cr; d->inspos = inspos; } #endif #undef DB #undef TAP /* * New API ====================================================================== */ static void _load_taps(struct audio_plugin_t *p, const float *taps) { int i; p->ctl[DC_EARLY_TIME] = (int)(1.0 * 65536.0); p->ctl[DC_TAIL_TIME] = (int)(1.0 * 65536.0); p->ctl[DC_EARLY_LEVEL] = (int)(1.0 * 65536.0); p->ctl[DC_FEEDBACK] = (int)(1.0 * 65536.0); p->ctl[DC_LP_FILTER] = (int)(6500.0 * 65536.0); for(i = 0; i < DELAY_MAX_TAPS + DELAY_MAX_TAIL_TAPS; ++i) { p->ctl[DC_EARLY_TAP_1_TIME + i*2] = (int)(*taps++ * 65536.0); p->ctl[DC_EARLY_TAP_1_LEVEL + i*2] = (int)(*taps++ * 65536.0); } } static void _scale_early_taps(struct audio_plugin_t *p) { delay_t *d = (delay_t *)p->user; unsigned i, t, scale; /* samples per ms */ float s_ms = (float)p->ctl[FXC_SAMPLERATE] * 0.001; s_ms *= (float)p->ctl[DC_EARLY_TIME]; /* scale */ s_ms *= 1.0/1024.0; /* Throw away 10 of the 16 fraction bits */ scale = (unsigned)s_ms; for(t = 0, i = 0; i < DELAY_MAX_TAPS; ++i) { unsigned delay; int shift; if(!p->ctl[DC_EARLY_TAP_1_LEVEL + i*2]) continue; shift = fixp2shift(p->ctl[DC_EARLY_TAP_1_LEVEL + i*2]); delay = (unsigned)p->ctl[DC_EARLY_TAP_1_TIME + i*2] >> 8; delay *= scale; delay >>= 14; if(delay > DELAY_BUFSIZE-2) delay = DELAY_BUFSIZE-2; else if(delay < 0) delay = 0; delay &= (DELAY_MASK-1); delay |= t & 1; /* L->L, R->R, L->L, R->R,... */ d->tap[t].delay = delay; d->tap[t].shift = shift; ++t; } d->taps = t; } static void _scale_tail_taps(struct audio_plugin_t *p) { delay_t *d = (delay_t *)p->user; unsigned i, t, scale; /* samples per ms */ float s_ms = (float)p->ctl[FXC_SAMPLERATE] * 0.001; s_ms *= (float)p->ctl[DC_TAIL_TIME]; /* scale */ s_ms *= 1.0/1024.0; /* Throw away 10 of the 16 fraction bits */ scale = (unsigned)s_ms; for(t = 0, i = 0; i < DELAY_MAX_TAIL_TAPS; ++i) { unsigned delay; int shift; if(!p->ctl[DC_TAIL_TAP_1_LEVEL + i*2]) continue; shift = fixp2shift(p->ctl[DC_TAIL_TAP_1_LEVEL + i*2]); delay = (unsigned)p->ctl[DC_TAIL_TAP_1_TIME + i*2] >> 8; delay *= scale; delay >>= 14; if(delay > DELAY_BUFSIZE-2) delay = DELAY_BUFSIZE-2; delay &= (DELAY_MASK-1); delay |= (t>>1) & 1; /* L->L, L->R, R->L, R->R,... */ d->tailtap[t].delay = delay; d->tailtap[t].shift = shift; ++t; } d->tailtaps = t; } static inline void __calc_filters(audio_plugin_t *p) { delay_t *d = (delay_t *)p->user; d->lpf = p->ctl[DC_LP_FILTER] / p->ctl[FXC_SAMPLERATE] >> (16-INTERNAL_BITS); if(d->lpf > (1<<(16-INTERNAL_BITS))) d->lpf = (1<<(16-INTERNAL_BITS)); } static const float default_taps[(DELAY_MAX_TAPS + DELAY_MAX_TAIL_TAPS)*2] = { /* Early Reflection Taps */ 17, 1.0/4, 31, 1.0/4, 87, 1.0/4, 179, 1.0/4, 379, 1.0/16, 246, 1.0/16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* Tail Feedback Taps */ 552, 1.0/4, 642, 1.0/4, 883, 1.0/4, 851, 1.0/4, 1204, 1.0/4, 1176, 1.0/4, 0, 0, 0, 0 }; static int delay_state(struct audio_plugin_t *p, audio_fxstates_t new_state) { delay_t *d; if(new_state > p->current_state) switch(new_state) { case FX_STATE_CLOSED: /* Can't happen. */ case FX_STATE_OPEN: if(!audio_plugin_alloc_ctls(p, DC_COUNT)) return -1; d = calloc(1, sizeof(delay_t)); if(!d) return -2; p->user = d; /*_load_taps(d, default_taps, p->ctl[FXC_SAMPLERATE]);*/ _load_taps(p, default_taps); break; case FX_STATE_READY: d = (delay_t *)p->user; if(_init(d) < 0) return -2; _scale_early_taps(p); _scale_tail_taps(p); __calc_filters(p); break; case FX_STATE_PAUSED: case FX_STATE_RUNNING: case FX_STATE_SILENT: case FX_STATE_RESTING: p->current_state = FX_STATE_RESTING; break; } else switch(new_state) { case FX_STATE_CLOSED: free(p->user); p->user = NULL; break; case FX_STATE_OPEN: d = (delay_t *)p->user; free(d->delaybuf); d->delaybuf = NULL; break; case FX_STATE_READY: break; case FX_STATE_PAUSED: case FX_STATE_RUNNING: /* Can't happen. */ case FX_STATE_SILENT: /* Can't happen. */ case FX_STATE_RESTING: /* Can't happen. */ break; } return 0; } static void delay_control(struct audio_plugin_t *p, unsigned ctl, int arg) { /* 1: Early reflections duration * 2: Tail duration * 3: Early reflections level * 4: Feedback Level * 5: Feedback LPF Cutoff * 6: (Unused) */ p->ctl[ctl] = arg; switch(ctl) { case DC_EARLY_TIME: _scale_early_taps(p); break; case DC_TAIL_TIME: _scale_tail_taps(p); break; case DC_EARLY_LEVEL: case DC_FEEDBACK: break; case DC_LP_FILTER: __calc_filters(p); break; } } static void delay_process(struct audio_plugin_t *p, int *buf, unsigned frames) { delay_t *d = (delay_t *)p->user; d->tlevel = 1000; d->ttimer = 0; p->current_state = FX_STATE_RUNNING; o_delay_process_s(d, buf, frames); } static void delay_process_r(struct audio_plugin_t *p, int *in, int *out, unsigned frames) { delay_t *d = (delay_t *)p->user; if(in) { d->tlevel = 1000; d->ttimer = 0; p->current_state = FX_STATE_RUNNING; o_delay_process_r_s(d, in, out, frames); } else { int level; if(FX_STATE_RESTING == p->current_state) return; level = o_delay_process_tail_s(d, out, frames); d->tlevel += (float)((level - d->tlevel) * frames) / (float)(p->ctl[FXC_SAMPLERATE] * 0.1); d->ttimer += frames; if(d->ttimer < p->ctl[FXC_SAMPLERATE] * 2) return; if(d->tlevel < 5.0) { d->tlevel = 1000; p->current_state = FX_STATE_RESTING; return; } } } void delay_init(struct audio_plugin_t *p) { p->state = delay_state; p->control = delay_control; p->process = delay_process; p->process_r = delay_process_r; } KoboDeluxe-0.5.1/sound/a_limiter.c0000644000175000001440000000663307502604164013750 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_limiter.h - Simple limiter --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_limiter.h" #include "a_types.h" int lim_open(limiter_t *lim, int samplerate) { lim->samplerate = samplerate; lim_control(lim, LIM_THRESHOLD, 32768); lim_control(lim, LIM_RELEASE, 300000); lim->peak = (unsigned)(32768<<8); lim->attenuation = 0; return 0; } void lim_close(limiter_t *lim) { /* Nothing to destruct */ } void lim_control(limiter_t *lim, int param, int value) { switch(param) { case LIM_THRESHOLD: lim->threshold = (unsigned)(value << 8); if(lim->threshold < 256) lim->threshold = 256; break; case LIM_RELEASE: if(lim->samplerate < 1) lim->samplerate = 44100; lim->release = (value << 8) / lim->samplerate; break; } } void lims_process(limiter_t *lim, int *in, int *out, unsigned frames) { unsigned i; frames <<= 1; for(i = 0; i < frames; i += 2) { int gain; int lp = abs(in[i]) << 8; int rp = abs(in[i+1]) << 8; unsigned maxp = (unsigned)(lp > rp ? lp : rp); if(maxp > lim->peak) { lim->peak = maxp; gain = (32767<<16) / ((lim->peak+255)>>8); } else { gain = (32767<<16) / ((lim->peak+255)>>8); lim->peak -= lim->release; if(lim->peak < lim->threshold) lim->peak = lim->threshold; } #ifdef A_USE_INT64 out[i] = (Sint64)in[i] * (Sint64)gain >> 16; out[i+1] = (Sint64)in[i+1] * (Sint64)gain >> 16; #else if(gain < 8192) { out[i] = in[i] * gain >> 16; out[i+1] = in[i+1] * gain >> 16; } else { out[i] = in[i] * (gain>>4) >> 12; out[i+1] = in[i+1] * (gain>>4) >> 12; } #endif } lim->attenuation = (lim->peak - lim->threshold) >> 8; } void limss_process(limiter_t *lim, int *in, int *out, unsigned frames) { unsigned i; frames <<= 1; for(i = 0; i < frames; i += 2) { int gain; int lp = abs(in[i]); int rp = abs(in[i+1]); unsigned maxp = (unsigned)(lp > rp ? lp : rp); unsigned p = maxp << 8; p += (maxp - abs(lp - rp)) << 7; if(p > lim->peak) { lim->peak = p; gain = (32767<<16) / ((lim->peak+255)>>8); } else { gain = (32767<<16) / ((lim->peak+255)>>8); lim->peak -= lim->release; if(lim->peak < lim->threshold) lim->peak = lim->threshold; } #ifdef A_USE_INT64 out[i] = (Sint64)in[i] * (Sint64)gain >> 16; out[i+1] = (Sint64)in[i+1] * (Sint64)gain >> 16; #else if(gain < 8192) { out[i] = in[i] * gain >> 16; out[i+1] = in[i+1] * gain >> 16; } else { out[i] = in[i] * (gain>>4) >> 12; out[i+1] = in[i+1] * (gain>>4) >> 12; } #endif } lim->attenuation = (lim->peak - lim->threshold) >> 8; } KoboDeluxe-0.5.1/sound/a_filters.c0000644000175000001440000001605007502603120013734 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_filters.c - Various Audio Signal Filters --------------------------------------------------------------------------- * Copyright (C) 2001, 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include "a_math.h" #include "a_tools.h" #include "a_filters.h" /*-------------------------------------------------------------------- f6_t - Simple mono 6 dB/oct state variable filter --------------------------------------------------------------------*/ void f6_process_lp(f6_t *fil, int *buf, unsigned frames) { int f = fil->f; int d = fil->d; unsigned s; for(s = 0; s < frames; ++s) { d += (buf[s] - (d>>12)) * f; buf[s] = d>>12; } fil->d = d; } void f6_process_hp(f6_t *fil, int *buf, unsigned frames) { int f = fil->f; int d = fil->d; unsigned s; for(s = 0; s < frames; ++s) { d += (buf[s] - (d>>12)) * f; buf[s] -= d>>12; } fil->d = d; } void f6_set_f(f6_t *fil, int f) { fil->f = (f<<13) / fil->rate; if(fil->f > 1<<13) fil->f = 1<<13; } void f6_init(f6_t *fil, int fs) { fil->rate = fs; fil->d = 0; f6_set_f(fil, 400); } /*-------------------------------------------------------------------- f6s_t - Simple stereo 6 dB/oct state variable filter --------------------------------------------------------------------*/ void f6s_process_lp(f6s_t *fil, int *buf, unsigned frames) { int f = fil->f; int dl = fil->dl; int dr = fil->dr; unsigned s; frames <<= 1; for(s = 0; s < frames; s += 2) { dl += (buf[s] - (dl>>12)) * f; dr += (buf[s+1] - (dr>>12)) * f; buf[s] = dl>>12; buf[s+1] = dr>>12; } fil->dl = dl; fil->dr = dr; } void f6s_process_hp(f6s_t *fil, int *buf, unsigned frames) { int f = fil->f; int dl = fil->dl; int dr = fil->dr; unsigned s; frames <<= 1; for(s = 0; s < frames; s += 2) { dl += (buf[s] - (dl>>12)) * f; dr += (buf[s+1] - (dr>>12)) * f; buf[s] -= dl>>12; buf[s+1] -= dr>>12; } fil->dl = dl; fil->dr = dr; } void f6s_set_f(f6s_t *fil, int f) { fil->f = (f<<13) / fil->rate; if(fil->f > 1<<13) fil->f = 1<<13; } void f6s_init(f6s_t *fil, int fs) { fil->rate = fs; fil->dl = fil->dr = 0; f6s_set_f(fil, 400); } /*-------------------------------------------------------------------- dcf6s_t - Fast stereo 6 dB/oct HPF for DC suppression --------------------------------------------------------------------*/ void dcf6s_process(dcf6s_t *fil, int *buf, unsigned frames) { int f = fil->f; int dl = fil->dl; int dr = fil->dr; unsigned s; frames <<= 1; for(s = 0; s < frames; s += 2) { dl += (buf[s] - (dl>>12)) >> f; dr += (buf[s+1] - (dr>>12)) >> f; buf[s] -= dl>>12; buf[s+1] -= dr>>12; } fil->dl = dl; fil->dr = dr; } int dcf6s_silent(dcf6s_t *fil) { if(labs(fil->dl) > 4096) return 0; if(labs(fil->dr) > 4096) return 0; return 1; } void dcf6s_set_f(dcf6s_t *fil, int f) { fil->f = int2shift(fil->rate / f) - 13; if(fil->f < 0) fil->f = 0; } void dcf6s_init(dcf6s_t *fil, int fs) { fil->rate = fs; fil->dl = fil->dr = 0; dcf6s_set_f(fil, 10); } /*-------------------------------------------------------------------- resof12_t - Resonant mono 12 dB/oct state variable filter --------------------------------------------------------------------*/ /* In-place LP */ void resof12_process_lp(resof12_t *rf, int *buf, unsigned frames) { int d1 = rf->d1; int d2 = rf->d2; int f = rf->f; int q = rf->q; int l, b, h; unsigned s; for(s = 0; s < frames; ++s) { l = d2 + (f*d1 >> 8); h = (buf[s] << 4) - l - (q*d1 >> 8); b = (f*h >> 8) + d1; buf[s] = l >> 4; d1 = b; d2 = l; } rf->d1 = d1; rf->d2 = d2; } /* In-place HP */ void resof12_process_hp(resof12_t *rf, int *buf, unsigned frames) { int d1 = rf->d1; int d2 = rf->d2; int f = rf->f; int q = rf->q; int l, b, h; unsigned s; for(s = 0; s < frames; ++s) { l = d2 + (f*d1 >> 8); h = (buf[s] << 4) - l - (q*d1 >> 8); b = (f*h >> 8) + d1; buf[s] = h >> 4; d1 = b; d2 = l; } rf->d1 = d1; rf->d2 = d2; } /* In-place BP */ void resof12_process_bp(resof12_t *rf, int *buf, unsigned frames) { int d1 = rf->d1; int d2 = rf->d2; int f = rf->f; int q = rf->q; int l, b, h; unsigned s; for(s = 0; s < frames; ++s) { l = d2 + (f*d1 >> 8); h = (buf[s] << 4) - l - (q*d1 >> 8); b = (f*h >> 8) + d1; buf[s] = b >> 4; d1 = b; d2 = l; } rf->d1 = d1; rf->d2 = d2; } /* * LP filter the 'buf' buffer, while separating off * the HP part into buffer 'out'. */ void resof12_process_split(resof12_t *rf, int *buf, int *out, unsigned frames) { int d1 = rf->d1; int d2 = rf->d2; int f = rf->f; int q = rf->q; int l, b, h; unsigned s; for(s = 0; s < frames; ++s) { l = d2 + (f*d1 >> 8); h = (buf[s] << 4) - l - (q*d1 >> 8); b = (f*h >> 8) + d1; buf[s] = l >> 4; out[s] = h >> 4; d1 = b; d2 = l; } rf->d1 = d1; rf->d2 = d2; } void resof12_set_f(resof12_t *rf, int f) { rf->f = (int)(512.0 * sin(M_PI * (float)f / rf->rate)); if(rf->f > 256) rf->f = 256; } void resof12_set_q(resof12_t *rf, int q) { if(q < 1) rf->q = 256; else rf->q = 256 / q; } void resof12_init(resof12_t *rf, int fs) { rf->rate = fs; rf->d1 = rf->d2 = 0; resof12_set_f(rf, 400); resof12_set_q(rf, 10); } /*-------------------------------------------------------------------- resof12s_t - Resonant stereo 12 dB/oct state variable filter --------------------------------------------------------------------*/ /* In-place LP */ void resof12s_process_lp(resof12s_t *rf, int *buf, unsigned frames) { int d1l = rf->d1l; int d1r = rf->d1r; int d2l = rf->d2l; int d2r = rf->d2r; int f = rf->f; int q = rf->q; int ll, bl, hl; int lr, br, hr; unsigned s; frames <<= 1; for(s = 0; s < frames; s += 2) { ll = d2l + (f*d1l >> 8); lr = d2r + (f*d1r >> 8); hl = (buf[s] << 4) - ll - (q*d1l >> 8); hr = (buf[s+1] << 4) - lr - (q*d1r >> 8); bl = (f*hl >> 8) + d1l; br = (f*hr >> 8) + d1r; buf[s] = ll >> 4; buf[s+1] = lr >> 4; d1l = bl; d1r = br; d2l = ll; d2r = lr; } rf->d1l = d1l; rf->d1r = d1r; rf->d2l = d2l; rf->d2r = d2r; } void resof12s_set_f(resof12s_t *rf, int f) { rf->f = (int)(512.0 * sin(M_PI * (float)f / rf->rate)); if(rf->f > 256) rf->f = 256; } void resof12s_set_q(resof12s_t *rf, int q) { if(q < 1) rf->q = 256; else rf->q = 256 / q; } void resof12s_init(resof12s_t *rf, int fs) { rf->rate = fs; rf->d1l = rf->d2l = 0; rf->d1r = rf->d2r = 0; resof12s_set_f(rf, 400); resof12s_set_q(rf, 10); } KoboDeluxe-0.5.1/sound/a_wca.c0000644000175000001440000010776407670701274013072 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_wca.c - WCA, the Wave Construction API --------------------------------------------------------------------------- * Copyright (C) 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* # of frames to process per loop in most functions */ #define BLOCK_FRAMES 64 #define MAX_SPECTRUM_OSCILLATORS 128 #define ONEDIV32K 3.0517578125e-5 #define ONEDIV65K 1.52587890625e-5 #include #include #include "kobolog.h" #include "a_wca.h" #include "a_math.h" /*---------------------------------------------------------- Framework for Buffer Based Processing ----------------------------------------------------------*/ /* * Parameters */ static audio_wave_t *s_w = NULL; /* Target waveform */ static int s_stereo = 0; /* 1 if waveform is stereo */ static float s_fs = 44100.0f; /* Target sample rate (Hz) */ static float s_dt = 1.0f/44100.0f; /* Target delta time (s) */ /* * State */ /* * IMPORTANT: These two MUST NOT, under any circumstances, * be allowed to increment beyond s_w->samples! * If they do, and you're use this framework * stuff, all hell will break lose. * * (One could use signs instead, but what's the point? * You have no business outside waveforms anyway.) */ static unsigned s_rpos = 0; /* Current target read position */ static unsigned s_wpos = 0; /* Current target write position */ static void _init_processing(audio_wave_t *w) { s_w = w; s_fs = (float)w->rate; s_dt = 1.0f / s_fs; s_rpos = s_wpos = 0; switch(s_w->format) { case AF_STEREO8: case AF_STEREO16: case AF_STEREO32: s_stereo = 1; break; case AF_MONO8: case AF_MONO16: case AF_MONO32: case AF_MIDI: s_stereo = 0; break; } } /* * Returns the number of frames left to process, if 'pos' * is the current position. If there are more than 'limit' * frames left to process, 'limit' is returned. */ static inline unsigned _next_block(unsigned pos, unsigned limit) { unsigned frames; frames = s_w->samples - (pos >> s_stereo); if(frames > limit) return limit; else return frames; } /*---------------------------------------------------------- Internal Toolkit ----------------------------------------------------------*/ /* * NOTE: * These work with floats in the 0 dB range [-32768, 32767], * regardless of waveform format. */ static inline void read_sample(audio_wave_t *w, unsigned s, float *inl, float *inr) { switch(w->format) { case AF_MONO8: *inr = *inl = (float)(w->data.si8[s]<<8); break; case AF_STEREO8: *inl = (float)(w->data.si8[s*2]<<8); *inr = (float)(w->data.si8[s*2+1]<<8); break; case AF_MONO16: *inr = *inl = (float)w->data.si16[s]; break; case AF_STEREO16: *inl = (float)w->data.si16[s*2]; *inr = (float)w->data.si16[s*2+1]; break; case AF_MONO32: *inr = *inl = w->data.f32[s] * 32768.0f; break; case AF_STEREO32: *inl = w->data.f32[s*2] * 32768.0f; *inr = w->data.f32[s*2+1] * 32768.0f; break; case AF_MIDI: *inr = *inl = *inr = 0; break; } } static inline void write_sample(audio_wave_t *w, unsigned s, float outl, float outr) { if(outl < -32768.0f) outl = -32768.0f; else if(outl > 32767.0f) outl = 32767.0f; if(outr < -32768.0f) outr = -32768.0f; else if(outr > 32767.0f) outr = 32767.0f; switch(w->format) { case AF_MONO8: w->data.si8[s] = (int)outl >> 8; break; case AF_STEREO8: w->data.si8[s*2] = (int)outl >> 8; w->data.si8[s*2+1] = (int)outr >> 8; break; case AF_MONO16: w->data.si16[s] = (Sint16)outl; break; case AF_STEREO16: w->data.si16[s*2] = (Sint16)outl; w->data.si16[s*2+1] = (Sint16)outr; break; case AF_MONO32: w->data.f32[s] = outl * ONEDIV32K; break; case AF_STEREO32: w->data.f32[s*2] = outl * ONEDIV32K; w->data.f32[s*2+1] = outr * ONEDIV32K; break; case AF_MIDI: break; } } static inline void add_sample(audio_wave_t *w, unsigned s, float outl, float outr) { float l, r; switch(w->format) { case AF_MONO8: l = (float)(w->data.si8[s]<<8) + outl; if(l > 32767.0f) w->data.si8[s] = 127; else if(l < -32768.0f) w->data.si8[s] = -128; else w->data.si8[s] = (int)l >> 8; break; case AF_STEREO8: s <<= 1; l = (float)(w->data.si8[s]<<8) + outl; if(l > 32767.0f) w->data.si8[s] = 127; else if(l < -32768.0f) w->data.si8[s] = -128; else w->data.si8[s] = (int)l >> 8; ++s; r = (float)(w->data.si8[s]<<8) + outr; if(r > 32767.0f) w->data.si8[s] = 127; else if(r < -32768.0f) w->data.si8[s] = -128; else w->data.si8[s] = (int)r >> 8; break; case AF_MONO16: l = (float)w->data.si16[s] + outl; if(l > 32767.0f) w->data.si16[s] = 32767; else if(l < -32768.0f) w->data.si16[s] = -32768; else w->data.si16[s] = (Sint16)l; break; case AF_STEREO16: s <<= 1; l = (float)w->data.si16[s] + outl; if(l > 32767.0f) w->data.si16[s] = 32767; else if(l < -32768.0f) w->data.si16[s] = -32768; else w->data.si16[s] = (Sint16)l; ++s; r = (float)w->data.si16[s] + outr; if(r > 32767.0f) w->data.si16[s] = 32767; else if(r < -32768.0f) w->data.si16[s] = -32768; else w->data.si16[s] = (Sint16)r; break; case AF_MONO32: w->data.f32[s] += outl * ONEDIV32K; break; case AF_STEREO32: w->data.f32[s*2] += outl * ONEDIV32K; w->data.f32[s*2+1] += outr * ONEDIV32K; break; case AF_MIDI: break; } } /* * Block based versions */ /* * Read 'frames' samples into the array(s). * * Only 'l' is used on mono waveforms! * Reading past the end of the waveform is NOT ALLOWED. * * Upon returning, s_rpos will index the first sample after the read block. */ static void read_samples(float *inl, float *inr, unsigned frames) { unsigned wp = 0; switch(s_w->format) { case AF_MONO8: { Sint8 *d = s_w->data.si8; while(wp < frames) inl[wp++] = (float)(d[s_rpos++]<<8); break; } case AF_STEREO8: { Sint8 *d = s_w->data.si8; while(wp < frames) { inl[wp] = (float)(d[s_rpos++]<<8); inr[wp] = (float)(d[s_rpos++]<<8); ++wp; } break; } case AF_MONO16: { Sint16 *d = s_w->data.si16; while(wp < frames) inl[wp++] = (float)(d[s_rpos++]); break; } case AF_STEREO16: { Sint16 *d = s_w->data.si16; while(wp < frames) { inl[wp] = (float)(d[s_rpos++]); inr[wp] = (float)(d[s_rpos++]); ++wp; } break; } case AF_MONO32: { float *d = s_w->data.f32; while(wp < frames) inl[wp++] = d[s_rpos++] * 32768.0f; break; } case AF_STEREO32: { float *d = s_w->data.f32; while(wp < frames) { inl[wp] = d[s_rpos++] * 32768.0f; inr[wp] = d[s_rpos++] * 32768.0f; ++wp; } break; } case AF_MIDI: break; } } /* * Write 'frames' samples from the array(s). * * Only 'l' is used on mono waveforms! * Writing past the end of the waveform is NOT ALLOWED. * Data is clipped to the limits of the waveform data format. * * Upon returning, s_wpos will index the first sample after the written block. */ #define __CLIP(s) \ if(s < -32768.0f) \ s = -32768.0f; \ else if(s > 32767.0f) \ s = 32767.0f; static void write_samples(float *outl, float *outr, unsigned frames) { unsigned rp = 0; switch(s_w->format) { case AF_MONO8: { Sint8 *d = s_w->data.si8; while(rp < frames) { float l = outl[rp++]; __CLIP(l) d[s_wpos++] = (int)l >> 8; } break; } case AF_STEREO8: { Sint8 *d = s_w->data.si8; while(rp < frames) { float l = outl[rp]; float r = outr[rp]; __CLIP(l) __CLIP(r) d[s_wpos++] = (int)l >> 8; d[s_wpos++] = (int)r >> 8; ++rp; } break; } case AF_MONO16: { Sint16 *d = s_w->data.si16; while(rp < frames) { float l = outl[rp++]; __CLIP(l) d[s_wpos++] = (Sint16)l; } break; } case AF_STEREO16: { Sint16 *d = s_w->data.si16; while(rp < frames) { float l = outl[rp]; float r = outr[rp]; __CLIP(l) __CLIP(r) d[s_wpos++] = (Sint16)l; d[s_wpos++] = (Sint16)r; ++rp; } break; } case AF_MONO32: { float *d = s_w->data.f32; while(rp < frames) d[s_wpos++] = outl[rp++] * ONEDIV32K; break; } case AF_STEREO32: { float *d = s_w->data.f32; while(rp < frames) { d[s_wpos++] = outl[rp] * ONEDIV32K; d[s_wpos++] = outl[rp] * ONEDIV32K; ++rp; } break; } case AF_MIDI: break; } } #if 0 /* * Add 'frames' samples from the array(s) to the waveform contents. * * Only 'l' is used on mono waveforms! * Working past the end of the waveform is NOT ALLOWED. * Resulting data is clipped to the limits of the waveform data format. * * Upon returning, s_wpos will index the first sample after the written block. */ static void add_samples(float *outl, float *outr, unsigned frames) { unsigned rp = 0; switch(s_w->format) { case AF_MONO8: { Sint8 *d = s_w->data.si8; while(rp < frames) { float l = outl[rp++] + (float)(d[s_wpos]<<8); __CLIP(l) d[s_wpos++] = (int)l >> 8; } break; } case AF_STEREO8: { Sint8 *d = s_w->data.si8; while(rp < frames) { float l = outl[rp] + (float)(d[s_wpos]<<8); float r = outr[rp] + (float)(d[s_wpos+1]<<8); __CLIP(l) __CLIP(r) d[s_wpos++] = (int)l >> 8; d[s_wpos++] = (int)r >> 8; ++rp; } break; } case AF_MONO16: { Sint16 *d = s_w->data.si16; while(rp < frames) { float l = outl[rp++] + (float)d[s_wpos]; __CLIP(l) d[s_wpos++] = (Sint16)l; } break; } case AF_STEREO16: { Sint16 *d = s_w->data.si16; while(rp < frames) { float l = outl[rp] + (float)d[s_wpos]; float r = outr[rp] + (float)d[s_wpos+1]; __CLIP(l) __CLIP(r) d[s_wpos++] = (Sint16)l; d[s_wpos++] = (Sint16)r; ++rp; } break; } case AF_MONO32: { float *d = s_w->data.f32; while(rp < frames) d[s_wpos++] += outl[rp++] * ONEDIV32K; break; } case AF_STEREO32: { float *d = s_w->data.f32; while(rp < frames) { d[s_wpos++] += outl[rp] * ONEDIV32K; d[s_wpos++] += outl[rp] * ONEDIV32K; ++rp; } break; } case AF_MIDI: break; } } #endif #undef __CLIP /*---------------------------------------------------------- The WCA calls ----------------------------------------------------------*/ void wca_reset(void) { int i; for(i = 0; i < _WCA_MODTARGETS; ++i) wca_mod_reset(i); wca_val(WCA_AMPLITUDE, 1.0f); wca_val(WCA_FREQUENCY, 100.0f); wca_val(WCA_LIMIT, 100000.0f); } /* * Simple envelope generator. TODO: This could use some serious optimizations... */ typedef struct modulator_t { /* Parameters */ unsigned steps; /* # of sections */ float v[WCA_MAX_ENV_STEPS]; /* target value */ float t[WCA_MAX_ENV_STEPS]; /* section start time */ float d[WCA_MAX_ENV_STEPS]; /* duration of section */ float mod_f, mod_a, mod_d; /* Modulation component */ /* State */ unsigned step; /* Current section */ unsigned done; /* samples of current section done */ unsigned remain; /* samples left of current section */ } modulator_t; void _env_reset(modulator_t *e) { e->steps = 0; e->v[0] = e->t[0] = e->d[0] = 0.0f; } void _env_add(modulator_t *e, float duration, float v) { if(e->steps >= WCA_MAX_ENV_STEPS) { log_printf(ELOG, "audio: Envelope overflow!\n"); return; } e->v[e->steps] = v; e->d[e->steps] = duration; if(e->steps) e->t[e->steps] = e->t[e->steps-1] + e->d[e->steps-1]; else e->t[e->steps] = 0.0f; ++e->steps; } #if 0 /* * Dog slow sample-by-sample API. (KILLME) */ static inline float _env_output(modulator_t *e, float t) { float output, w; int step = 0; while(step < e->steps) if(e->t[step] + e->d[step] > t) break; else ++step; if(step >= e->steps) output = e->v[e->steps-1]; else if(0 == step) output = e->v[0] * t / e->d[0]; else { float ip = (t - e->t[step]) / e->d[step]; output = e->v[step - 1] * (1.0f - ip) + e->v[step] * ip; } w = t * e->mod_f * 2.0f * M_PI; output *= 1.0f + sin(w) * e->mod_d; output += sin(w) * e->mod_a; return output; } #endif /* * New block based interface */ /* Initialize modulator 'e' for block based processing. */ static void _env_start(modulator_t *e) { e->step = 0; e->remain = e->d[0] * s_fs; e->done = 0; } /* Generate 'frame' samples of output from modulator 'e'. */ static void _env_process(modulator_t *e, float *out, unsigned frames) { while(frames) { unsigned i = 0; unsigned frag; float begv, endv, dv, ip, t; if(e->step >= e->steps) { /* Beyond the end ==> flat forever */ if(0 == e->steps) endv = 0.0; else endv = e->v[e->steps-1]; for(; i < frames; ++i) out[i] = endv; return; } frag = frames < e->remain ? frames : e->remain; if(frag) { if(0 == e->step) { /* First section */ begv = 0.0f; endv = e->v[0]; } else { /* All other sections */ begv = e->v[e->step - 1]; endv = e->v[e->step]; } t = (float)e->done * s_dt; dv = (endv - begv) / e->d[e->step] * s_dt; ip = t / e->d[e->step]; begv = endv * ip + begv * (1.0f - ip); while(i < frag) { out[i++] = begv; begv += dv; } out += frag; frames -= frag; e->done += frag; e->remain -= frag; } if(!e->remain) { /* Next section! */ ++e->step; if(e->step < e->steps) { /* FIXME: This rounds the start of each section to the nearest sample. FIXME: Normally, that wouldn't be an issue (although a proper band FIXME: limited rendition of envelopes would be nice), but here, the FIXME: errors will add up! This might matter with lots of sections FIXME: and/or low sample rates. */ e->remain = e->d[e->step] * s_fs; e->done = 0; } /* * NOTE: * e->step does the whole job in the 'else' * case, so we don't have to set the others. */ } } } /* * Global envelope generators. */ static modulator_t env[_WCA_MODTARGETS]; static void _env_start_all(void) { int i; for(i = 0; i < _WCA_MODTARGETS; ++i) _env_start(env + i); } void wca_mod_reset(wca_modtargets_t target) { if(target < 0) return; if(target >= _WCA_MODTARGETS) return; _env_reset(&env[target]); wca_mod(target, 0, 0, 0); } void wca_env(wca_modtargets_t target, float duration, float v) { if(target < 0) return; if(target >= _WCA_MODTARGETS) return; _env_add(&env[target], duration, v); } void wca_mod(wca_modtargets_t target, float frequency, float amplitude, float depth) { if(target < 0) return; if(target >= _WCA_MODTARGETS) return; env[target].mod_f = frequency; env[target].mod_a = amplitude; env[target].mod_d = depth; } void wca_val(wca_modtargets_t target, float v) { wca_mod_reset(target); wca_env(target, 0, v); wca_mod(target, 0, 0, 0); } #include "a_wcaosc.h" void wca_osc(int wid, wca_waveform_t wf, wca_mixmodes_t mm) { unsigned s, frames; char sync[BLOCK_FRAMES]; float olev = 1.0f; float nyqvist = s_fs * 0.5f; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return; _init_processing(wave); _env_start_all(); noise_reset(); osc_w = 0.0; osc_yit = 0.0f; noise_out = 0.0f; switch(mm) { case WCA_ADD: case WCA_MUL: case WCA_FM: case WCA_FM_ADD: memset(sync, 0, sizeof(sync)); break; case WCA_SYNC: case WCA_SYNC_ADD: break; } while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { float inl[BLOCK_FRAMES]; float inr[BLOCK_FRAMES]; float a[BLOCK_FRAMES]; float bal[BLOCK_FRAMES]; float f[BLOCK_FRAMES]; float limit[BLOCK_FRAMES]; float mod1[BLOCK_FRAMES]; float mod2[BLOCK_FRAMES]; float mod3[BLOCK_FRAMES]; float out[BLOCK_FRAMES]; _env_process(&env[WCA_AMPLITUDE], a, frames); _env_process(&env[WCA_BALANCE], bal, frames); _env_process(&env[WCA_FREQUENCY], f, frames); _env_process(&env[WCA_LIMIT], limit, frames); _env_process(&env[WCA_MOD1], mod1, frames); _env_process(&env[WCA_MOD2], mod2, frames); _env_process(&env[WCA_MOD3], mod3, frames); for(s = 0; s < frames; ++s) if(limit[s] > nyqvist) limit[s] = nyqvist; read_samples(inl, inr, frames); /* Handle FM and SYNC modes*/ switch(mm) { case WCA_ADD: case WCA_MUL: break; case WCA_FM: case WCA_FM_ADD: if(s_stereo) for(s = 0; s < frames; ++s) f[s] *= 1.0f + (inl[s] + inr[s]) * ONEDIV65K * bal[s]; else for(s = 0; s < frames; ++s) f[s] *= 1.0f + inl[s] * ONEDIV65K * bal[s]; break; case WCA_SYNC: case WCA_SYNC_ADD: /* FIXME: Storing retrig points as a list of "timestamps" would probably FIXME: be more efficient than this per-sample array hack... FIXME: More importantly, that can provide sub-sample accurate sync FIXME: timing. Fractional timing would have to be derived by looking FIXME: at the samples before and after each zero crossing. */ if(s_stereo) for(s = 0; s < frames; ++s) { float lev = inl[s] + inr[s]; sync[s] = (olev > 0.0f) && (lev < 0.0f); olev = lev; } else for(s = 0; s < frames; ++s) { float lev = inl[s]; sync[s] = (olev > 0.0f) && (lev < 0.0f); olev = lev; } break; } /* Oscillators! */ switch(wf) { case WCA_DC: for(s = 0; s < frames; ++s) out[s] = 1.0f; break; case WCA_SINE: _osc_sine(sync, f, mod1, out, frames); break; case WCA_HALFSINE: _osc_halfsine(sync, f, mod1, out, frames); break; case WCA_RECTSINE: _osc_rectsine(sync, f, mod1, out, frames); break; case WCA_PULSE: _osc_pulse(sync, f, mod1, out, frames); break; case WCA_TRIANGLE: _osc_triangle(sync, f, mod1, out, frames); break; case WCA_SINEMORPH: _osc_sinemorph(sync, f, mod1, mod2, limit, out, frames); break; case WCA_BLMORPH: _osc_blmorph(sync, f, mod1, mod2, mod3, limit, out, frames); break; case WCA_BLCROSS: _osc_blcross(sync, f, mod1, mod2, mod3, limit, out, frames); break; case WCA_NOISE: _osc_noise(sync, f, out, frames); break; case WCA_SPECTRUM: _osc_spectrum(sync, f, mod1, mod2, limit, out, frames); break; case WCA_ASPECTRUM: _osc_aspectrum(sync, f, mod1, mod2, limit, out, frames); break; case WCA_HSPECTRUM: _osc_hspectrum(sync, f, mod1, mod2, mod3, limit, out, frames); break; case WCA_AHSPECTRUM: _osc_ahspectrum(sync, f, mod1, mod2, mod3, limit, out, frames); break; } /* Output */ switch(mm) { case WCA_ADD: case WCA_FM_ADD: case WCA_SYNC_ADD: if(s_stereo) for(s = 0; s < frames; ++s) { float sout = out[s] * a[s] * 32767.0f; inl[s] += sout; inr[s] += sout; } else for(s = 0; s < frames; ++s) { float sout = out[s] * a[s] * 32767.0f; inl[s] += sout; } break; case WCA_MUL: if(s_stereo) for(s = 0; s < frames; ++s) { float sout = inl[s] * out[s] * 0.5f; sout *= bal[s]; sout *= a[s]; inl[s] = inl[s] * (1.0f - bal[s]) + sout; inr[s] = inr[s] * (1.0f - bal[s]) + sout; } else for(s = 0; s < frames; ++s) { float sout = inl[s] * out[s] * 0.5f; sout *= bal[s]; sout *= a[s]; inl[s] = inl[s] * (1.0f - bal[s]) + sout; } break; case WCA_FM: case WCA_SYNC: if(s_stereo) for(s = 0; s < frames; ++s) { float sout = out[s] * a[s] * 32767.0f; inl[s] = sout; inr[s] = sout; } else for(s = 0; s < frames; ++s) { float sout = out[s] * a[s] * 32767.0f; inl[s] = sout; } break; } write_samples(inl, inr, frames); } } void wca_filter(int wid, wca_filtertype_t ft) { unsigned s, frames; float ll = 0.0f, bl = 0.0f, hl = 0.0f; float lr = 0.0f, br = 0.0f, hr = 0.0f; float d1l = 0.0f; float d1r = 0.0f; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return; switch(ft) { case WCA_ALLPASS: return; default: break; } _init_processing(wave); _env_start_all(); while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { float f[BLOCK_FRAMES]; float q[BLOCK_FRAMES]; float l[BLOCK_FRAMES]; float r[BLOCK_FRAMES]; float amp[BLOCK_FRAMES]; float fe[BLOCK_FRAMES]; float mod1[BLOCK_FRAMES]; _env_process(&env[WCA_AMPLITUDE], amp, frames); _env_process(&env[WCA_FREQUENCY], fe, frames); _env_process(&env[WCA_MOD1], mod1, frames); read_samples(l, r, frames); /* Generate f and q buffers */ switch(ft) { case WCA_ALLPASS: case WCA_LOWPASS_6DB: case WCA_HIGHPASS_6DB: for(s = 0; s < frames; ++s) if(fe[s] > s_fs) f[s] = 1.0f; else f[s] = fe[s] * s_dt; break; case WCA_LOWPASS_12DB: case WCA_HIGHPASS_12DB: case WCA_BANDPASS_12DB: case WCA_NOTCH_12DB: case WCA_PEAK_12DB: for(s = 0; s < frames; ++s) { float qlim; /* * Here we have some safety limits to keep the * filter from blowing up... */ if(fe[s] > s_fs * 0.5f) fe[s] = s_fs * 0.5f; f[s] = 2.0f * sin(M_PI * fe[s] * s_dt * 0.5f); q[s] = 1.0f / amp[s]; if(q[s] > 1.0f) q[s] = 1.0f; qlim = s_fs / fe[s]; if(qlim < 5.0f) { qlim *= qlim * qlim; qlim /= 125.0f; if(q[s] > qlim) q[s] = qlim; } } break; } /* Perform the actual filtering */ switch(ft) { case WCA_ALLPASS: case WCA_LOWPASS_6DB: if(s_stereo) for(s = 0; s < frames; ++s) { d1r += (r[s] - d1r) * f[s]; r[s] = r[s] * mod1[s] + d1r * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { d1l += (l[s] - d1l) * f[s]; l[s] = l[s] * mod1[s] + d1l * (1.0f - mod1[s]); } break; case WCA_HIGHPASS_6DB: if(s_stereo) for(s = 0; s < frames; ++s) { d1r += (r[s] - d1r) * f[s]; r[s] = r[s] * mod1[s] + (r[s] - d1r) * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { d1l += (l[s] - d1l) * f[s]; l[s] = l[s] * mod1[s] + (l[s] - d1l) * (1.0f - mod1[s]); } break; case WCA_LOWPASS_12DB: /* * 2x oversampling - although this quick hack * performs no input interpolation, and just * drops every other output sample. */ if(s_stereo) for(s = 0; s < frames; ++s) { lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; r[s] = r[s] * mod1[s] + lr * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; l[s] = l[s] * mod1[s] + ll * (1.0f - mod1[s]); } break; case WCA_HIGHPASS_12DB: if(s_stereo) for(s = 0; s < frames; ++s) { lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; r[s] = r[s] * mod1[s] + hr * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; l[s] = l[s] * mod1[s] + hl * (1.0f - mod1[s]); } break; case WCA_BANDPASS_12DB: if(s_stereo) for(s = 0; s < frames; ++s) { lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; r[s] = r[s] * mod1[s] + br * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; l[s] = l[s] * mod1[s] + bl * (1.0f - mod1[s]); } break; case WCA_NOTCH_12DB: if(s_stereo) for(s = 0; s < frames; ++s) { lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; r[s] = r[s] * mod1[s] + (lr + hr) * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; l[s] = l[s] * mod1[s] + (ll + hl) * (1.0f - mod1[s]); } break; case WCA_PEAK_12DB: if(s_stereo) for(s = 0; s < frames; ++s) { lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; lr += f[s]*br; hr = r[s] - lr - q[s]*br; br += f[s]*hr; r[s] = r[s] * mod1[s] + (lr + hr + br) * (1.0f - mod1[s]); } for(s = 0; s < frames; ++s) { ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; ll += f[s]*bl; hl = l[s] - ll - q[s]*bl; bl += f[s]*hl; l[s] = l[s] * mod1[s] + (ll + hl + bl) * (1.0f - mod1[s]); } break; } write_samples(l, r, frames); } } void wca_gain(int wid) { unsigned s, frames; float a[BLOCK_FRAMES]; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return; _init_processing(wave); _env_start_all(); switch(wave->format) { case AF_MIDI: return; case AF_STEREO32: { float *d = wave->data.f32; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) { d[s_wpos++] *= a[s]; d[s_wpos++] *= a[s]; } } break; } case AF_MONO32: { float *d = wave->data.f32; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) d[s_wpos++] *= a[s]; } break; } case AF_STEREO16: { Sint16 *d = wave->data.si16; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) { float r = (float)d[s_wpos] * a[s]; if(r > 32767.0) d[s_wpos] = 32767; else if(r < -32768.0) d[s_wpos] = -32768; else d[s_wpos] = (Sint16)r; ++s_wpos; r = (float)d[s_wpos] * a[s]; if(r > 32767.0) d[s_wpos] = 32767; else if(r < -32768.0) d[s_wpos] = -32768; else d[s_wpos] = (Sint16)r; ++s_wpos; } } break; } case AF_MONO16: { Sint16 *d = wave->data.si16; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) { float r = (float)d[s_wpos] * a[s]; if(r > 32767.0) d[s_wpos] = 32767; else if(r < -32768.0) d[s_wpos] = -32768; else d[s_wpos] = (Sint16)r; ++s_wpos; } } break; } case AF_STEREO8: { Sint8 *d = wave->data.si8; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) { float r = (float)d[s_wpos] * a[s]; if(r > 127.0f) d[s_wpos] = 127; else if(r < -128.0f) d[s_wpos] = -128; else d[s_wpos] = (Sint16)r; ++s_wpos; r = (float)d[s_wpos] * a[s]; if(r > 127.0f) d[s_wpos] = 127; else if(r < -128.0f) d[s_wpos] = -128; else d[s_wpos] = (Sint16)r; ++s_wpos; } } break; } case AF_MONO8: { Sint8 *d = wave->data.si8; while( (frames = _next_block(s_wpos, BLOCK_FRAMES)) ) { _env_process(&env[WCA_AMPLITUDE], a, frames); for(s = 0; s < frames; ++s) { float r = (float)d[s_wpos] * a[s]; if(r > 127.0f) d[s_wpos] = 127; else if(r < -128.0f) d[s_wpos] = -128; else d[s_wpos] = (Sint16)r; ++s_wpos; } } break; } } } #if 0 void wca_mix(int src_wid, int dst_wid) { } #endif /* TODO: Output saturation. */ void wca_enhance(int wid, int f, float level) { unsigned s, samples; int bpl, bpr, a; int outl, outr, gain, vu; int d1l, d2l, d1r, d2r; int ldl, ldr, lf, h; int release; int sl = 0, sr = 0; int samp = 0; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return; _init_processing(wave); if(AF_MIDI == wave->format) { log_printf(ELOG, "wca_enhance(): MIDI not supported!\n"); return; } a = (int)(level * 32768.0); lf = (f * 256 * 2) / wave->rate; if(lf > 256) lf = 256; f = (int)(512.0f * sin(M_PI * (float)f / wave->rate)); if(f > 256) f = 256; release = (20 << 16) / wave->rate; if(release > 65536) release = 65536; d1l = d1r = d2l = d2r = 0; ldl = ldr = 0; gain = 0; samples = wave->samples; switch (wave->format) { case AF_MONO8: case AF_MONO16: case AF_MONO32: for(s = 0; s < samples; ++s) { switch (wave->format) { case AF_MONO8: samp = wave->data.si8[s] << 8; break; case AF_MONO16: samp = wave->data.si16[s]; break; case AF_MONO32: samp = (int)(wave->data.f32[s] * 32768.0); default: break; } /* 12 dB LP + BP + HP */ d2l += f * d1l >> 8; h = (samp << 4) - d2l - d1l; d1l += f * h >> 8; bpl = d1l >> 4; /* Octave shift up + 6 dB gain */ outl = abs(bpl) << 2; /* 6 dB HPF on the artificial treble */ ldl += (outl - ldl) * lf >> 8; outl -= ldl; /* Use BP level to control artificial treble level */ vu = abs(bpl); vu = vu * a >> 15; if(vu > gain) { /* Fast attacks! */ if(vu > 65535) gain = 65535; else gain = vu; } else gain -= gain * release >> 16; /* Artificial treble level */ outl = outl * gain >> 16; /* Add in the original signal */ outl += samp; /* Clip + output */ if(outl > 32767) samp = 32767; else if(outl < -32768) samp = -32768; else samp = outl; switch (wave->format) { case AF_MONO8: wave->data.si8[s] = samp >> 8; break; case AF_MONO16: wave->data.si16[s] = (Sint16)samp; break; case AF_MONO32: wave->data.f32[s] = (float)samp * ONEDIV32K; default: break; } } break; case AF_STEREO8: case AF_STEREO16: case AF_STEREO32: samples <<= 1; for(s = 0; s < samples; s += 2) { switch (wave->format) { case AF_STEREO8: sl = wave->data.si8[s] << 8; sr = wave->data.si8[s+1] << 8; break; case AF_STEREO16: sl = wave->data.si16[s]; sr = wave->data.si16[s+1]; break; case AF_STEREO32: sl = (int)(wave->data.f32[s] * 32768.0); sr = (int)(wave->data.f32[s+1] * 32768.0); default: break; } /* 12 dB BP */ d2l += f * d1l >> 8; h = (sl << 4) - d2l - d1l; d1l += f * h >> 8; bpl = d1l >> 4; d2r += f * d1r >> 8; h = (sr << 4) - d2r - d1r; d1r += f * h >> 8; bpr = d1l >> 4; /* Octave shift up + 6 dB gain */ outl = abs(bpl) << 2; outr = abs(bpr) << 2; /* 6 dB HPF on the artificial treble */ ldl += (outl - ldl) * lf >> 8; ldr += (outr - ldr) * lf >> 8; outl -= ldl; outr -= ldr; /* Use BP level to control artificial treble level */ vu = (abs(bpl) + abs(bpr)) >> 1; vu = vu * a >> 15; if(vu > gain) { /* Fast attacks! */ if(vu > 65535) gain = 65535; else gain = vu; } else gain -= gain * release >> 16; /* Artificial treble level */ outl = outl * gain >> 16; outr = outr * gain >> 16; /* Add in the original signal */ outl += sl; outr += sr; /* Clip + output */ if(outl > 32767) sl = 32767; else if(outl < -32768) sl = -32768; else sl = outl; if(outr > 32767) sr = 32767; else if(outr < -32768) sr = -32768; else sr = outr; switch (wave->format) { case AF_STEREO8: wave->data.si8[s] = sl >> 8; wave->data.si8[s+1] = sr >> 8; break; case AF_STEREO16: wave->data.si16[s] = (Sint16)sl; wave->data.si16[s+1] = (Sint16)sr; break; case AF_STEREO32: wave->data.f32[s] = (float)sl * ONEDIV32K; wave->data.f32[s+1] = (float)sr * ONEDIV32K; default: break; } } case AF_MIDI: break; } } void wca_gate(int wid, int f, float min, float thr, float att) { unsigned s, samples; int thresh, min_gain; int lpl, lpr, hpl, hpr, h; int outl, outr, gain, vu; int d1l, d2l, d1r, d2r; int attack, release, track, track_level; int sl = 0, sr = 0; audio_wave_t *wave = audio_wave_get(wid); if(!wave) return; _init_processing(wave); if(AF_MIDI == wave->format) { log_printf(ELOG, "wca_gate(): MIDI not supported!\n"); return; } f = (int)(512.0f * sin(M_PI * (float)f / wave->rate)); if(f > 256) f = 256; attack = (5000 << 15) / wave->rate; if(attack > 32767) attack = 32767; release = (10 << 15) / wave->rate; if(release > 32768) release = 32767; thresh = (int)(thr * 32767.0); min_gain = (int)(min * 32767.0); if(min_gain > 32767) min_gain = 32767; track = (att * 32768.0 * 256.0f) / wave->rate; if(track > 32767*256) track = 32767*256; track_level = 0; d1l = d1r = d2l = d2r = 0; gain = 0; samples = wave->samples; switch (wave->format) { case AF_MONO8: case AF_MONO16: case AF_MONO32: for(s = 0; s < samples; ++s) { switch (wave->format) { case AF_MONO8: sl = wave->data.si8[s] << 8; break; case AF_MONO16: sl = wave->data.si16[s]; break; case AF_MONO32: sl = (int)(wave->data.f32[s] * 32768.0); default: break; } /* 12 dB LP / HP split */ d2l += f * d1l >> 8; h = (sl << 4) - d2l - d1l; d1l += f * h >> 8; lpl = d2l >> 4; hpl = (d1l + h) >> 4; /* Auto Threshold Tracking */ vu = abs(sl); if(vu > (thresh>>8)) track_level += ((vu<<8) - track_level) * track >> 16; else track_level += ((vu<<8) - track_level) * track >> 16; /* Envelope generator */ vu = abs(hpl); if(vu > thresh + (track_level>>8)) gain += (32767 - gain) * attack >> 14; else { gain -= gain * release >> 16; if(gain < min_gain) gain = min_gain; } /* Gate the hp part */ outl = hpl * gain >> 15; /* Add in the LP part */ outl += lpl; /* Clip + output */ if(outl > 32767) sl = 32767; else if(outl < -32768) sl = -32768; else sl = outl; switch (wave->format) { case AF_MONO8: wave->data.si8[s] = sl >> 8; break; case AF_MONO16: wave->data.si16[s] = (Sint16)sl; break; case AF_MONO32: wave->data.f32[s] = (float)sl * ONEDIV32K; default: break; } } break; case AF_STEREO8: case AF_STEREO16: case AF_STEREO32: samples <<= 1; for(s = 0; s < samples; s += 2) { switch (wave->format) { case AF_STEREO8: sl = wave->data.si8[s] << 8; sr = wave->data.si8[s+1] << 8; break; case AF_STEREO16: sl = wave->data.si16[s]; sr = wave->data.si16[s+1]; break; case AF_STEREO32: sl = (int)(wave->data.f32[s] * 32768.0); sr = (int)(wave->data.f32[s+1] * 32768.0); default: break; } /* 12 dB LP / HP split */ d2l += f * d1l >> 8; h = (sl << 4) - d2l - d1l; d1l += f * h >> 8; lpl = d2l >> 4; hpl = (d1l + h) >> 4; d2r += f * d1r >> 8; h = (sr << 4) - d2r - d1r; d1r += f * h >> 8; lpr = d2r >> 4; hpr = (d1r + h) >> 4; /* Auto Threshold Tracking */ vu = (abs(sl) + abs(sr)) >> 1; if(vu > (thresh>>8)) track_level += ((vu<<8) - track_level) * track >> 16; else track_level += ((vu<<8) - track_level) * track >> 16; /* Envelope generator */ vu = (abs(hpl) + abs(hpr)) >> 1; if(vu > thresh + (track_level>>8)) gain += (32767 - gain) * attack >> 14; else { gain -= gain * release >> 16; if(gain < min_gain) gain = min_gain; } /* Gate the hp part */ outl = hpl * gain >> 15; outr = hpr * gain >> 15; /* Add in the LP part */ outl += lpl; outr += lpr; /* Clip + output */ if(outl > 32767) sl = 32767; else if(outl < -32768) sl = -32768; else sl = outl; if(outr > 32767) sr = 32767; else if(outr < -32768) sr = -32768; else sr = outr; switch (wave->format) { case AF_STEREO8: wave->data.si8[s] = sl >> 8; wave->data.si8[s+1] = sr >> 8; break; case AF_STEREO16: wave->data.si16[s] = (Sint16)sl; wave->data.si16[s+1] = (Sint16)sr; break; case AF_STEREO32: wave->data.f32[s] = (float)sl * ONEDIV32K; wave->data.f32[s+1] = (float)sr * ONEDIV32K; default: break; } } break; case AF_MIDI: break; } } KoboDeluxe-0.5.1/sound/a_agw.c0000644000175000001440000003430607733152674013071 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_agw.c - "Algorithmically Generated Waveform" file support --------------------------------------------------------------------------- * Copyright (C) 2002, 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define DBG(x) #include #include "kobolog.h" #include "config.h" #include "eel.h" #include "a_types.h" #include "a_wca.h" #include "a_control.h" /* Enum class handles */ static int enum_aformat, enum_amodtarget, enum_awaveform, enum_afiltertype; static int enum_amixmode, enum_aresample; static int enum_pparam, enum_pdriver; /*---------------------------------------------------------- AGW Command Callbacks ----------------------------------------------------------*/ static int op_w_reset(int argc, struct eel_data_t *argv) { DBG(log_printf(D2LOG, "w_reset;\n");) wca_reset(); return 1; } static int op_w_format(int argc, struct eel_data_t *argv) { int target; double fs; int format = enum_aformat; #if 0 /* Alternative, more verbose method. */ eel_symbol_t *fmt; if(eel_get_args("iEr", &target, &fmt, &fs) != 3) return -1; if(fmt->token != enum_aformat) { eel_error("Wrong enum class!"); return -1; } DBG(log_printf(D2LOG, "w_format %d, %s, %f;\n", target, eel_s_stringrep(fmt), fs);) format = fmt->data.value.i; #else if(eel_get_args("ier", &target, &format, &fs) != 3) return -1; #endif DBG(log_printf(D2LOG, "w_format %d, %d, %f;\n", target, format, fs);) audio_wave_format(target, format, (int)fs); return 1; } static int op_w_gain(int argc, struct eel_data_t *argv) { int target; if(eel_get_args("i", &target) != 1) return -1; DBG(log_printf(D2LOG, "w_gain %d;\n", target);) wca_gain(target); return 1; } static int op_w_convert(int argc, struct eel_data_t *argv) { int source, target; double fs; int format = enum_aformat; int interpol = enum_aresample; argc = eel_get_args("iie[re]", &source, &target, &format, &fs, &interpol); if(argc < 3) return -1; if(argc < 4) fs = 0; if(argc < 5) interpol = AR_BEST; DBG(log_printf(D2LOG, "w_convert %d, %d, %d, %d, %d;\n", source, target, format, (int)fs, interpol);) audio_wave_convert(source, target, format, (int)fs, interpol); return 1; } static int op_w_enhance(int argc, struct eel_data_t *argv) { int target; double f, level; if(eel_get_args("irr", &target, &f, &level) != 3) return -1; DBG(log_printf(D2LOG, "w_enhance %d, %d, %f;\n", target, (int)f, level);) wca_enhance(target, (int)f, level); return 1; } static int op_w_gate(int argc, struct eel_data_t *argv) { int target; double f, min, thres, att; if(eel_get_args("irrrr", &target, &f, &min, &thres, &att) != 5) return -1; DBG(log_printf(D2LOG, "w_gate %d, %d, %f, %f, %f;\n", target, (int)f, min, thres, att);) wca_gate(target, (int)f, min, thres, att); return 1; } static int op_w_blank(int argc, struct eel_data_t *argv) { int target, loop; unsigned samples; argc = eel_get_args("ii[i]", &target, &samples, &loop); if(argc < 2) return -1; if(argc < 3) loop = 0; DBG(log_printf(D2LOG, "w_blank %d, %d, %d;\n", target, samples, loop);) audio_wave_blank(target, samples, loop); return 1; } static int op_w_load(int argc, struct eel_data_t *argv) { int target, loop; const char *fn; argc = eel_get_args("is[i]", &target, &fn, &loop); if(argc < 2) return -1; if(argc < 3) loop = 0; DBG(log_printf(D2LOG, "w_load %d, \"%s\", %d;\n", target, fn, loop);) if(audio_wave_load(target, fn, loop) < 0) return -1; return 1; } static int op_w_save(int argc, struct eel_data_t *argv) { int target; const char *fn; if(eel_get_args("is", &target, &fn) != 2) return -1; DBG(log_printf(D2LOG, "w_save %d, \"%s\";\n", target, fn);) if(audio_wave_save(target, fn) < 0) return -1; return 1; } static int op_w_prepare(int argc, struct eel_data_t *argv) { int target; if(eel_get_args("i", &target) < 1) return -1; DBG(log_printf(D2LOG, "w_prepare %d;\n", target);) audio_wave_prepare(target); return 1; } static int op_w_env(int argc, struct eel_data_t *argv) { int i; int modtarget = enum_amodtarget; double dur[WCA_MAX_ENV_STEPS]; double val[WCA_MAX_ENV_STEPS]; if(argc > 1 + 2*WCA_MAX_ENV_STEPS) { eel_error("Too many envelope steps!"); return -1; } if(eel_get_args("e[]", &modtarget, &dur, &val) != argc) return -1; DBG(log_printf(D2LOG, "w_env %d", modtarget);) wca_mod_reset(modtarget); if(2 == argc) { /* * Note that dur[0] actually becomes a *value* * rather than a time in this case! */ DBG(log_printf(D2LOG, ", %f;\n", dur[0]);) wca_val(modtarget, dur[0]); return 1; } for(i = 1; i < argc; i += 2) { int sec = (i-1)/2; DBG(log_printf(D2LOG, ", <%f", dur[sec]);) if(i+1 >= argc) { eel_error(" argruments must" " come in pairs!"); return -1; } DBG(else log_printf(D2LOG, ", %f", val[sec]);) DBG(log_printf(D2LOG, ">");) wca_env(modtarget, dur[sec], val[sec]); } DBG(log_printf(D2LOG, ";\n");) return 1; } static int op_w_mod(int argc, struct eel_data_t *argv) { int mt; double f, a, d; mt = enum_amodtarget; if(eel_get_args("errr", &mt, &f, &a, &d) != 4) return -1; DBG(log_printf(D2LOG, "w_mod %d, %f, %f, %f;\n", mt, f, a, d);) wca_mod(mt, f, a, d); return 1; } static int op_w_osc(int argc, struct eel_data_t *argv) { int target, wf, mm; wf = enum_awaveform; mm = enum_amixmode; switch(eel_get_args("ie[e]", &target, &wf, &mm)) { case 2: mm = WCA_ADD; case 3: break; default: return -1; } DBG(log_printf(D2LOG, "w_osc %d, %d, %d;\n", target, wf, mm);) wca_osc(target, wf, mm); return 1; } static int op_w_filter(int argc, struct eel_data_t *argv) { int target, ft; ft = enum_afiltertype; if(eel_get_args("ie", &target, &ft) != 2) return -1; DBG(log_printf(D2LOG, "w_filter %d, %d;\n", target, ft);) wca_filter(target, ft); return 1; } /*---------------------------------------------------------- Patch Command Callbacks ----------------------------------------------------------*/ static int op_p_param(int argc, struct eel_data_t *argv) { int patch, param; double value; param = enum_pparam; if(eel_get_args("ier", &patch, ¶m, &value) != 3) return -1; switch(param) { case APP_DRIVER: case APP_WAVE: case APP_ENV_SKIP: case APP_LFO_SHAPE: audio_patch_param(patch, param, (int)value); break; default: audio_patch_param(patch, param, (int)(value * 65536.0)); break; } DBG(log_printf(D2LOG, "p_param %d, %d, %f;\n", patch, param, value);) return 1; } static int op_p_driver(int argc, struct eel_data_t *argv) { int patch; eel_symbol_t *callback; if(eel_get_args("if", &patch, &callback) != 2) return -1; DBG(log_printf(D2LOG, "p_driver %d, %s;\n", patch, eel_s_stringrep(callback));) return 1; } /*---------------------------------------------------------- Init code ----------------------------------------------------------*/ static void load_keywords(void) { /* WCA calls */ eel_register_operator("w_reset", op_w_reset, 100, 0 ,0); eel_register_operator("w_format", op_w_format, 100, 0 ,0); eel_register_operator("w_blank", op_w_blank, 100, 0 ,0); eel_register_operator("w_load", op_w_load, 100, 0 ,0); eel_register_operator("w_save", op_w_save, 100, 0 ,0); eel_register_operator("w_prepare", op_w_prepare, 100, 0 ,0); eel_register_operator("w_env", op_w_env, 100, 0 ,0); eel_register_operator("w_mod", op_w_mod, 100, 0 ,0); eel_register_operator("w_osc", op_w_osc, 100, 0 ,0); eel_register_operator("w_filter", op_w_filter, 100, 0 ,0); eel_register_operator("w_gain", op_w_gain, 100, 0 ,0); eel_register_operator("w_convert", op_w_convert, 100, 0 ,0); eel_register_operator("w_enhance", op_w_enhance, 100, 0 ,0); eel_register_operator("w_gate", op_w_gate, 100, 0 ,0); /* w_convert resampling modes */ enum_aresample = eel_register_enum_class(); eel_register_enum(enum_aresample, "NEAREST", AR_NEAREST); eel_register_enum(enum_aresample, "NEAREST4X", AR_NEAREST_4X); eel_register_enum(enum_aresample, "LINEAR", AR_LINEAR); eel_register_enum(enum_aresample, "LINEAR2X", AR_LINEAR_2X_R); eel_register_enum(enum_aresample, "LINEAR4X", AR_LINEAR_4X_R); eel_register_enum(enum_aresample, "LINEAR8X", AR_LINEAR_8X_R); eel_register_enum(enum_aresample, "LINEAR16X", AR_LINEAR_16X_R); eel_register_enum(enum_aresample, "CUBIC", AR_CUBIC_R); eel_register_enum(enum_aresample, "WORST", AR_WORST); eel_register_enum(enum_aresample, "MEDIUM", AR_MEDIUM); eel_register_enum(enum_aresample, "BEST", AR_BEST); /* Sample formats */ enum_aformat = eel_register_enum_class(); eel_register_enum(enum_aformat, "MONO8", AF_MONO8); eel_register_enum(enum_aformat, "STEREO8", AF_STEREO8); eel_register_enum(enum_aformat, "MONO16", AF_MONO16); eel_register_enum(enum_aformat, "STEREO16", AF_STEREO16); eel_register_enum(enum_aformat, "MONO32", AF_MONO32); eel_register_enum(enum_aformat, "STEREO32", AF_STEREO32); /* Modulation targets */ enum_amodtarget = eel_register_enum_class(); eel_register_enum(enum_amodtarget, "AMPLITUDE", WCA_AMPLITUDE); eel_register_enum(enum_amodtarget, "BALANCE", WCA_BALANCE); eel_register_enum(enum_amodtarget, "FREQUENCY", WCA_FREQUENCY); eel_register_enum(enum_amodtarget, "LIMIT", WCA_LIMIT); eel_register_enum(enum_amodtarget, "MOD1", WCA_MOD1); eel_register_enum(enum_amodtarget, "MOD2", WCA_MOD2); eel_register_enum(enum_amodtarget, "MOD3", WCA_MOD3); /* Oscillator output modes */ enum_amixmode = eel_register_enum_class(); eel_register_enum(enum_amixmode, "ADD", WCA_ADD); eel_register_enum(enum_amixmode, "MUL", WCA_MUL); eel_register_enum(enum_amixmode, "FM", WCA_FM); eel_register_enum(enum_amixmode, "FM_ADD", WCA_FM_ADD); eel_register_enum(enum_amixmode, "SYNC", WCA_SYNC); eel_register_enum(enum_amixmode, "SYNC_ADD", WCA_SYNC_ADD); /* Oscillator waveforms */ enum_awaveform = eel_register_enum_class(); eel_register_enum(enum_awaveform, "DC", WCA_DC); eel_register_enum(enum_awaveform, "SINE", WCA_SINE); eel_register_enum(enum_awaveform, "HALFSINE", WCA_HALFSINE); eel_register_enum(enum_awaveform, "RECTSINE", WCA_RECTSINE); eel_register_enum(enum_awaveform, "SINEMORPH", WCA_SINEMORPH); eel_register_enum(enum_awaveform, "BLMORPH", WCA_BLMORPH); eel_register_enum(enum_awaveform, "BLCROSS", WCA_BLCROSS); eel_register_enum(enum_awaveform, "PULSE", WCA_PULSE); eel_register_enum(enum_awaveform, "TRIANGLE", WCA_TRIANGLE); eel_register_enum(enum_awaveform, "NOISE", WCA_NOISE); eel_register_enum(enum_awaveform, "SPECTRUM", WCA_SPECTRUM); eel_register_enum(enum_awaveform, "ASPECTRUM", WCA_ASPECTRUM); eel_register_enum(enum_awaveform, "HSPECTRUM", WCA_HSPECTRUM); eel_register_enum(enum_awaveform, "AHSPECTRUM", WCA_AHSPECTRUM); /* Filter types */ enum_afiltertype = eel_register_enum_class(); eel_register_enum(enum_afiltertype, "ALLPASS", WCA_ALLPASS); eel_register_enum(enum_afiltertype, "LOWPASS_6", WCA_LOWPASS_6DB); eel_register_enum(enum_afiltertype, "HIGHPASS_6", WCA_HIGHPASS_6DB); eel_register_enum(enum_afiltertype, "LOWPASS_12", WCA_LOWPASS_12DB); eel_register_enum(enum_afiltertype, "HIGHPASS_12", WCA_HIGHPASS_12DB); eel_register_enum(enum_afiltertype, "BANDPASS_12", WCA_BANDPASS_12DB); eel_register_enum(enum_afiltertype, "NOTCH_12", WCA_NOTCH_12DB); eel_register_enum(enum_afiltertype, "PEAK_12", WCA_PEAK_12DB); /* Patch calls */ eel_register_operator("p_param", op_p_param, 100, 0 ,0); eel_register_operator("p_driver", op_p_driver, 100, 0 ,0); /* Patch Parameters */ enum_pparam = eel_register_enum_class(); eel_register_enum(enum_pparam, "DRIVER", APP_DRIVER); eel_register_enum(enum_pparam, "WAVE", APP_WAVE); eel_register_enum(enum_pparam, "RANDPITCH", APP_RANDPITCH); eel_register_enum(enum_pparam, "RANDVOL", APP_RANDVOL); eel_register_enum(enum_pparam, "ENV_SKIP", APP_ENV_SKIP); eel_register_enum(enum_pparam, "ENV_L0", APP_ENV_L0); eel_register_enum(enum_pparam, "ENV_DELAY", APP_ENV_DELAY); eel_register_enum(enum_pparam, "ENV_T1", APP_ENV_T1); eel_register_enum(enum_pparam, "ENV_L1", APP_ENV_L1); eel_register_enum(enum_pparam, "ENV_HOLD", APP_ENV_HOLD); eel_register_enum(enum_pparam, "ENV_T2", APP_ENV_T2); eel_register_enum(enum_pparam, "ENV_L2", APP_ENV_L2); eel_register_enum(enum_pparam, "ENV_T3", APP_ENV_T3); eel_register_enum(enum_pparam, "ENV_T4", APP_ENV_T4); /* Patch Drivers */ enum_pdriver = eel_register_enum_class(); eel_register_enum(enum_pdriver, "MONO", PD_MONO); eel_register_enum(enum_pdriver, "POLY", PD_POLY); eel_register_enum(enum_pdriver, "MIDI", PD_MIDI); eel_register_enum(enum_pdriver, "EEL", PD_EEL); } /*---------------------------------------------------------- API code ----------------------------------------------------------*/ static int _agw_initialized = 0; int agw_open(void) { if(_agw_initialized) return 0; eel_open(); eel_push_scope(); /* begin AGW extensions scope */ load_keywords(); /* Built-in variables */ (void)eel_set_integer("target", -1); _agw_initialized = 1; return 0; } void agw_close(void) { if(!_agw_initialized) return; eel_pop_scope(); /* end AGW extensions scope */ eel_close(); _agw_initialized = 0; } #define CHECKINIT if(!_agw_initialized) agw_open(); int agw_load(int wid, const char *name) { int script, res; CHECKINIT if(wid < 0) { wid = audio_wave_alloc(wid); if(wid < 0) return wid; } script = eel_load(name); if(script < 0) return -1; eel_push_scope(); /* begin script scope */ /* Initialize "argument" variables */ (void)eel_set_integer("target", wid); /* Reset the waveform construction engine */ wca_reset(); res = eel_run(script); eel_free(script); eel_pop_scope(); /* end script scope */ if(res < 0) return -1; audio_wave_prepare(wid); return wid; } KoboDeluxe-0.5.1/sound/a_sequencer.c0000644000175000001440000000473007503021334014262 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_sequencer.c - MIDI Sequencer --------------------------------------------------------------------------- * Copyright (C) 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "a_globals.h" #include "a_struct.h" #include "a_sequencer.h" #include "a_midisock.h" /* * Temporary MIDI playback hack. * * Only one sequence at a time, and it uses the * same midisock as the external MIDI input. */ midi_player_t *midiplayer = 0; static float fs = 44100; int sequencer_open(midisock_t *ms, float framerate) { aev_client("sequencer_open()"); fs = framerate; #if 1 midiplayer = mp_open(ms); #else midiplayer = mp_open(&monitor_midisock); #endif return (midiplayer != 0); } void sequencer_close(void) { aev_client("sequencer_close()"); if(!midiplayer) return; mp_close(midiplayer); midiplayer = 0; } int sequencer_play(midi_file_t *mf, int tag, int pitch, int volume) { aev_client("sequencer_play()"); if(!midiplayer) return -1; midiplayer->pitch = pitch - (60 << 16); mp_select(midiplayer, mf); return 0; } void sequencer_stop(int tag) { aev_client("sequencer_stop()"); if(!midiplayer) return; mp_stop(midiplayer); } int sequencer_playing(int tag) { if(!midiplayer) return 0; return (midiplayer->mf != 0); } void sequencer_process(unsigned frames) { int i; aev_client("sequencer_process()"); if(!midiplayer) return; if(mp_play(midiplayer, (float)frames / fs)) return; for(i = 0; i < AUDIO_MAX_CHANNELS; ++i) { int wave; if(!channeltab[i].playing) continue; wave = patchtab[channeltab[i].ctl[ACC_PATCH]].param[APP_WAVE]; if((wave < 0) || (wave >= AUDIO_MAX_WAVES)) continue; if(AF_MIDI != wavetab[wave].format) continue; channeltab[i].playing = 0; } } KoboDeluxe-0.5.1/sound/a_events.c0000644000175000001440000001225107670702004013576 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_events.c - Internal Event System --------------------------------------------------------------------------- * Copyright (C) 2002, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #define EVDBG(x) #include #include "kobolog.h" #include "a_events.h" #define EVENTS_PER_BLOCK 256 /*---------------------------------------------------------- The global event timestamp time base ----------------------------------------------------------*/ Uint16 aev_timer = 0; /*---------------------------------------------------------- Event pool management ----------------------------------------------------------*/ aev_event_t *aev_event_pool = NULL; #ifdef AEV_TRACKING int aev_event_counter = 0; int aev_event_counter_max = 0; const char *aev_current_client = "Unknown"; #endif typedef struct evblock_t { struct evblock_t *next; aev_event_t events[EVENTS_PER_BLOCK]; } evblock_t; static evblock_t *blocks = NULL; int _aev_refill_pool(void) { /* * We can't refill in real time context on some * platforms - and it would be a bad idea anyway... */ log_printf(ELOG, "Audio event pool exhausted!\n"); return -1; } /* * A job for a future butler thread. For now, we only use * this during initialization. */ static int refill_pool(void) { int i; evblock_t *eb = calloc(1, sizeof(evblock_t)); if(!eb) return -1; /* Add to block list */ eb->next = blocks; blocks = eb; /* Add the events to the pool */ for(i = 0; i < EVENTS_PER_BLOCK; ++i) { eb->events[i].type = AEV_ET_FREE; aev_free(&eb->events[i]); } return 0; } /*---------------------------------------------------------- Event Input Port ----------------------------------------------------------*/ void aev_insert(aev_port_t *evp, aev_event_t *ev) { EVDBG(log_printf(D2LOG, "aev_insert:\n");) if(!evp->first) { EVDBG(log_printf(D2LOG, " empty list\n");) ev->next = NULL; evp->first = evp->last = ev; } else if((Sint16)(evp->last->frame - ev->frame) <= 0) { EVDBG(log_printf(D2LOG, " last\n");) ev->next = NULL; evp->last->next = ev; evp->last = ev; } else { aev_event_t *e_prev = NULL; aev_event_t *e = evp->first; EVDBG(log_printf(D2LOG, " scanning...\n");) while((Sint16)(e->frame - ev->frame) <= 0) { EVDBG(log_printf(D2LOG, "e->frame = %d, ev->frame = %d\n", e->frame, ev->frame);) e_prev = e; e = e->next; } ev->next = e; if(e_prev) { EVDBG(log_printf(D2LOG, " insert\n");) e_prev->next = ev; } else { EVDBG(log_printf(D2LOG, " first\n");) evp->first = ev; } } #ifdef AEV_TRACKING ev->port = evp; #endif } /*---------------------------------------------------------- Open/Close ----------------------------------------------------------*/ int aev_open(int pool_size) { while(pool_size > 0) { if(refill_pool() < 0) { aev_close(); return -1; /* OOM! */ } pool_size -= EVENTS_PER_BLOCK; } #if 0 { aev_evport_t port; int i; aev_evport_init(&port, "testport"); aev_timer = 0; aev_event_client(42); for(i = 0; i < 5; ++i) aev_put0(&port, 20+i*20, 42); for(i = 0; i < 5; ++i) aev_put0(&port, 100-i*20, 43); i = 0; aev_timer = 0; while(i < 200) { unsigned int frames; log_printf(D2LOG, "aev_timer = %d\n", aev_timer); while(!(frames = aev_next(&port, 0))) { aev_event_t *ev = aev_read(&port); log_printf(D2LOG, " event.frame = %d, type = %d\n", ev->frame, ev->type); aev_free(ev); } if(frames > 5) frames = 5; aev_timer += frames; i += frames; } } #endif #ifdef AEV_TRACKING aev_event_counter = 0; aev_event_counter_max = 0; #endif return 0; } void aev_close(void) { log_printf(DLOG, "aev_close(): max events used: %d\n", aev_event_counter_max); #ifdef AEV_TRACKING if(aev_event_counter) { evblock_t *eb = blocks; log_printf(ELOG, "INTERNAL ERROR: Closing audio event system" " system with %d events in use!" " (Memory leaked.)\n", aev_event_counter); while(eb) { int i; for(i = 0; i < EVENTS_PER_BLOCK; ++i) { if(eb->events[i].type == AEV_ET_FREE) continue; log_printf(ELOG, " Event %p, " "sent from client \"%s\", " "to port \"%s\".\n", eb->events + i, eb->events[i].client, eb->events[i].port->name ); } eb = eb->next; } } else #endif while(blocks) { evblock_t *eb = blocks; blocks = eb->next; free(eb); } blocks = NULL; aev_event_pool = NULL; #ifdef AEV_TRACKING aev_event_counter = 0; aev_event_counter_max = 0; #endif } KoboDeluxe-0.5.1/sound/a_agw.h0000644000175000001440000002651407662013667013077 00000000000000/*(LGPL) --------------------------------------------------------------------------- a_agw.h - "Algorithmically Generated Waveform" file support --------------------------------------------------------------------------- * Copyright (C) 2002, 2003, David Olofson * * This program 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 program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software Foundation, * Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* * The AGW v0.1 file format: * * This extension to the EEL language makes it possible * to use EEL scripts to construct waveforms using the * "Waveform Construction API" of the engine. * * Why!? * Well, pages of hard-coded calls to the Waveform * Construction API and recompiling for every turn * while creating sounds got boring, so I decided to * hack up something simple to get cleaner code and * faster sound editing. * * Over a few weeks, the file format turned into an * interpreted language, which I eventually cleaned up * and separated from the engine. This language is * called "EEL" - Extensible Embeddable Language, and * is not tied to the audio engine. * * Built-in commands: * // * C++ style comment. * */ /* ... */ /* C style comment. * * w_reset; * Resets the AGW engine state to the default. * This is done automatically before a script * is executed after being loaded with w_load(). * See below for default settings for w_env etc. * * w_format , , ; * Set format of to ; * samples per second. * * Supported sample formats: * MONO8 STEREO8 * MONO16 STEREO16 * * w_blank , , ; * Create samples of silent data * for waveform . can be either 0 * or 1, and if it's 1, the waveform will be * set up for looping playback. * * w_env [,